add_stack.php 892 B

1234567891011121314151617181920212223242526
  1. <?php /** Created by Anton on 31.01.2020. */
  2. require '../yiiInit.php';
  3. $warehouseId = (int) Yii::$app->request->post('warehouse');
  4. $cellCount = (int) Yii::$app->request->post('count');
  5. $warehouse = \app\models\entity\Warehouse::findOne($warehouseId);
  6. $stack = new \app\models\entity\Stack();
  7. $stack->warehouse = $warehouse->id;
  8. $stack->number = (int) Yii::$app->request->post('number');
  9. $stack->title = $stack->toFormTitle();
  10. $stack->save();
  11. for($i = 1; $i <= $cellCount; $i++) {
  12. $storage = new \app\models\entity\Storage();
  13. $storage->company = $warehouse->getCompany()->id;
  14. $storage->warehouse = $warehouseId;
  15. $storage->stack = $stack->id;
  16. $storage->cell = $i;
  17. $storage->title = $storage->toFormTitle();
  18. $storage->tmc = 0;
  19. $storage->save();
  20. }
  21. Yii::$app->response->redirect(\yii\helpers\Url::to($_SERVER['HTTP_REFERER']))->send();