public function actionSettings() { $delivery = new Delivery(); $contact = new ContactSettings(); if (Yii::app()->request->isPostRequest) { if ($delivery->attributes = Yii::app()->request->getPost('Delivery')) { $delivery->save(); } if ($contact->attributes = Yii::app()->request->getPost('ContactSettings')) { $contact->save(); } } $this->render('settings', array('delivery' => $delivery, 'contact' => $contact)); }
/** * Subscribe action * @throws CHttpException */ public function run() { if (Yii::app()->request->isAjaxRequest) { $model = new Delivery(); if (isset($_POST['Delivery'])) { $model->attributes = $_POST['Delivery']; if ($model->validate()) { $model->save(); Yii::app()->user->setFlash('success', Yii::t('SubscribeWidget.default', 'SUBSCRIBE_SUCCESS')); } } $this->controller->render('mod.delivery.widgets.subscribe.views._subscribe', array('model' => $model)); } else { throw new CHttpException(403); } }
/** * create a delivery * * @return \Illuminate\Http\RedirectResponse */ public function postCreate() { $nowDateTime = $this->getDateTimeAfterNow(5); $validator = Validator::make(Input::all(), array('store' => 'required|numeric|exists:stores,id', 'closing_time' => 'date_format:Y-m-d H:i:s|after:' . $nowDateTime->format('Y-m-d H:i:s'))); if ($validator->passes() === false) { return Redirect::back()->withErrors($validator); } $storeId = Input::get('store'); $closingTime = Input::get('closing_time'); $store = Store::find($storeId); $delivery = new Delivery(); $delivery->user()->associate(Auth::user()); $delivery->store()->associate($store); $delivery->closing_time = $closingTime; $delivery->save(); // push notification F4H\Pusher::push('delivery.created', array('user' => Auth::user()->email, 'store' => $store->name, 'closing_time' => $closingTime, 'delivery' => $delivery->getKey())); return Redirect::route('delivery.active'); }
/** * */ public function actionCreate() { $model = new Delivery(); if (isset($_POST['Delivery'])) { $model->attributes = $_POST['Delivery']; if ($model->save()) { Yii::app()->user->setFlash(yupe\widgets\YFlashMessages::SUCCESS_MESSAGE, Yii::t('DeliveryModule.delivery', 'Record created!')); if (!isset($_POST['submit-type'])) { $this->redirect(['update', 'id' => $model->id]); } else { $this->redirect([$_POST['submit-type']]); } } } $criteria = new CDbCriteria(); $criteria->select = new CDbExpression('MAX(position) as position'); $max = $model->find($criteria); $model->position = $max->position + 1; $payments = Payment::model()->published()->findAll(['order' => 'position']); $this->render('create', ['model' => $model, 'payments' => $payments]); }
public function postRecoverEmptyGood($goodEmptyId) { $good_empty = GoodEmpty::find($goodEmptyId); $branch = Branch::find($good_empty->branch_id); $delivery = new Delivery(); $delivery->bn = date("YmdHis", time()) . $this->random(4, 1); $delivery->ship_name = $branch->name; $delivery->ship_addr = $branch->address; $delivery->ship_mobile = $branch->mobile; $delivery->t_begin = $this->__time(); $delivery->branch_id = $branch->id; $delivery->user_id = Auth::user()->id; $delivery->money = '0'; $delivery->status = '1'; $delivery->pay_status = '0'; $delivery->warehouse_id = Input::get('warehouse_id'); $delivery->type = '1'; $delivery->save(); $good_info = Good::find($good_empty->good_id); // 计算实际兑换量 // $empty_num = floor($good_empty->empty / $good_info->unit / $good_info->empty_unit); $empty = $empty_num * $good_info->unit; $good_info->empty = $good_info->empty + $empty; $good_info->store = $good_info->store - $empty; $good_info->save(); $product_info = Product::find(Input::get('item_id')); $product_info->empty = $product_info->empty + $empty; $product_info->store = $product_info->store - $empty; $product_info->save(); $delivery_item = new DeliveryItems(); $delivery_item->delivery_id = $delivery->id; $delivery_item->branch_id = $branch->id; $delivery_item->good_id = $good_info->id; $delivery_item->product_id = $product_info->id; $delivery_item->good_name = $good_info->name; $delivery_item->spec_info = ''; $delivery_item->number = $empty; $delivery_item->presentation = 0; $delivery_item->price = 0; $delivery_item->money = 0; $delivery_item->life_date = $product_info->life_date; $delivery_item->warehouse_id = $product_info->warehouse_id; $delivery_item->save(); // 日志 // $this->__goodLog($good_info->id, $product_info->id, 'empty'); $branch->last_visit_at = $branch->last_ship_at = $this->__time(); $branch->save(); $good_empty->delivery_id = $delivery->id; $good_empty->save(); return Redirect::to('picking/view/' . $delivery->id)->with('success', '兑换成功!'); }
public function postCreate() { $branch_id = Input::get('branch_id'); $picking = Session::get('picking'); if (array_key_exists($branch_id, $picking)) { $branch_picking = $picking[$branch_id]; if (count($branch_picking['items']) == 0) { return Redirect::to('picking/add/' . $branch_id)->with('error', '出货清单为空,请添加货品清单再生成出货单!'); } else { $branch = Branch::find($branch_id); $user_id = (int) Auth::user()->id; // 发货单 // $delivery = new Delivery(); $delivery->bn = $branch_picking['order_id']; $delivery->ship_name = $branch->name; $delivery->ship_addr = $branch->address; $delivery->ship_mobile = $branch->mobile; $delivery->t_begin = $this->__time(); $delivery->branch_id = $branch_id; $delivery->user_id = $user_id; $delivery->money = Input::get('items_price'); $delivery->status = '1'; $delivery->pay_status = '0'; $delivery->warehouse_id = Input::get('warehouse_id'); $delivery->save(); $item_num = 0; // 发货单货品 // foreach ($branch_picking['items'] as $item) { $item_num += $item['num'] + $item['presentation_num']; // 统计发货数量 $good_info = Good::find($item['good_id']); $good_info->sell = $good_info->sell + ($item['num'] + $item['presentation_num']) * $good_info->unit; $good_info->store = $good_info->store - ($item['num'] + $item['presentation_num']) * $good_info->unit; $good_info->save(); $product_info = Product::find($item['id']); $product_info->sell = $product_info->sell + ($item['num'] + $item['presentation_num']) * $good_info->unit; $product_info->store = $product_info->store - ($item['num'] + $item['presentation_num']) * $good_info->unit; $product_info->save(); $delivery_item = new DeliveryItems(); $delivery_item->delivery_id = $delivery->id; $delivery_item->branch_id = $branch->id; $delivery_item->good_id = $item['good_id']; $delivery_item->product_id = $item['id']; $delivery_item->good_name = $item['name']; $delivery_item->spec_info = ''; $delivery_item->number = $item['num'] * $good_info->unit; $delivery_item->presentation = $item['presentation_num'] * $good_info->unit; $delivery_item->price = $item['price']; $delivery_item->money = $item['price'] * $item['num']; $delivery_item->life_date = $product_info->life_date; $delivery_item->warehouse_id = $product_info->warehouse_id; $delivery_item->save(); // 日志 // $this->__goodLog($item['good_id'], $item['id'], 'picking'); } // 清空出货清单 // Session::forget('picking.' . $branch_id); // 重置最后发货、回访时间 // $branch->last_visit_at = $branch->last_ship_at = $this->__time(); // 合同存量 // if ($branch->stock) { if ($branch->stock > $item_num) { $branch->stock = $branch->stock - $item_num; } else { $branch->stock = 0; } } $branch->save(); return Redirect::to('picking/view/' . $delivery->id)->with('success', '出货单生成成功!'); } } }