/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Box(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Box'])) { $model->attributes = $_POST['Box']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->box_id)); } } $this->render('create', array('model' => $model)); }
/** * Generate new delivery dates and boxes for each date */ public function actionCreateFutureDeliveryDatesAndBoxes() { $weeksInAdvance = SnapUtil::config('boxomatic/autoCreateDeliveryDates'); $latestDate = DeliveryDate::getLastEnteredDate(); if ($latestDate) { $latestDate = strtotime($latestDate->date); } else { $latestDate = time(); } $targetDate = strtotime('+' . $weeksInAdvance . ' weeks'); $BoxSizes = BoxSize::model()->findAll(); while ($latestDate <= $targetDate) { // $dateStr = date('j-n-Y',$latestDate); // $parts = explode('-',$dateStr); // mktime(0,0,0,$parts[1],$parts[0],$parts[2]); foreach (SnapUtil::config('boxomatic/deliveryDateLocations') as $day => $locationIds) { if (!empty($locationIds)) { $latestDate = strtotime('next ' . $day, $latestDate); //var_dump(date('l, d-m-Y',$latestDate)); //$latestDateStr=date('Y-m-d',$latestDate); //$latestDate=strtotime($latestDateStr . ' +1 week'); $newDateStr = date('Y-m-d', $latestDate); $DeliveryDate = new DeliveryDate(); $DeliveryDate->date = $newDateStr; $DeliveryDate->Locations = $locationIds; $DeliveryDate->save(); foreach ($BoxSizes as $BoxSize) { $Box = new Box(); $Box->size_id = $BoxSize->id; $Box->box_price = $BoxSize->box_size_price; $Box->delivery_date_id = $DeliveryDate->id; $Box->save(); } echo '<p>Created new delivery_date: ' . $DeliveryDate->date . '</p>'; } } } echo '<p><strong>Finished.</strong></p>'; Yii::app()->end(); }
public function createBox($delivery_id, $order_id, $fulfillment_code, $boxcount) { $boxcount = intval($boxcount); for ($i = 0; $i < $boxcount; $i++) { $box = new \Box(); $box->delivery_id = $delivery_id; $box->merchant_trans_id = $order_id; $box->fulfillment_code = $fulfillment_code; $box->box_id = strval($i + 1); $box->save(); } }
public function updateBox($delivery_id, $order_id, $fulfillment_code, $box_count, $position) { for ($n = 0; $n < $box_count; $n++) { $box = new Box(); $box->delivery_id = $delivery_id; $box->order_id = $order_id; $box->fulfillment_code = $fulfillment_code; $box->box_id = $n + 1; $box->position = $position; $box->deliveryStatus = Config::get('jayon.trans_status_confirmed'); $box->courierStatus = Config::get('jayon.trans_cr_atmerchant'); $box->warehouseStatus = Config::get('jayon.trans_wh_atmerchant'); $box->pickupStatus = Config::get('jayon.trans_status_tobepickup'); $box->save(); } }
public function updateBox($delivery_id, $order_id, $fulfillment_code, $box_count) { for ($n = 0; $n < $box_count; $n++) { $box = new Box(); $box->delivery_id = $delivery_id; $box->order_id = $order_id; $box->fulfillment_code = $fulfillment_code; $box->box_id = $n + 1; $box->save(); } }
/** * Duplicate a Box and all its items * @return boolean */ public function duplicate() { $newBox = new Box(); $newBox->attributes = $this->attributes; $newBox->box_id = null; $newBox->save(); foreach ($this->BoxItems as $BoxItem) { $newBoxItem = new BoxItem(); $newBoxItem->attributes = $BoxItem->attributes; $newBoxItem->box_item_id = null; $newBoxItem->box_id = $newBox->box_id; $newBoxItem->save(); } return true; }
public static function save_box($delivery_id, $merchant_trans_id, $fulfillment_code, $count) { $affected = Box::where('delivery_id', '=', $delivery_id)->where('merchant_trans_id', '=', $merchant_trans_id)->where('fulfillment_code', '=', $fulfillment_code)->delete(); for ($i = 0; $i < $count; $i++) { $bd = new Box(); $bd->delivery_id = $delivery_id; $bd->merchant_trans_id = $merchant_trans_id; $bd->fulfillment_code = $fulfillment_code; $bd->box_id = $i + 1; $bd->save(); $bds = new Boxstatus(); $bds->delivery_id = $delivery_id; $bds->merchant_trans_id = $merchant_trans_id; $bds->fulfillment_code = $fulfillment_code; $bds->box_id = $i + 1; $bds->timestamp = date('Y-m-d H:i:s', time()); $bds->save(); } }