Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (! empty($make_flag) && $make_flag){
- // set go to active
- $go = new Application_Model_GroupOrders($go_id);
- $go->active = 1;
- $go->save();
- //update go status
- $go_status = new Application_Model_Statuses();
- $go_status->item_id = $go_id;
- $go_status->item_type = 'group_order';
- $go_status->date = time();
- $go_status->status = 'В работе';
- $go_status->comment = 'Выставлены счета клиентам';
- $go_status->admin_user = $this->_identity->email;
- $go_status->save();
- $addition = 1;
- // update orders statuses
- foreach($go_info['orders_list'] as $order_info){
- // add new bill for each order
- $new_bill = new Application_Model_Bills();
- $new_bill->user_id = $order_info['user_id'];
- $new_bill->order_id = $order_info['order_id'];
- $new_bill->date = time() + $addition++;
- $new_bill->type = 'payment';
- $new_bill->amount = $order_info['bill_price'];
- $new_bill->cur_id = $order_info['cur_id'];
- $new_bill->comment = '';
- if ($new_bill->save()){
- $bill_id = $new_bill->getLastInsertId();
- if(! empty($bill_id)){
- // add products info to bill
- foreach($order_info['products'] as $product_info){
- $new_product = new Application_Model_BillsProducts();
- $new_product->bill_id = $bill_id;
- $new_product->p_id = $product_info['p_id'];
- $new_product->p_info = $product_info['name'] . '(' . $product_info['color'] . '/' . $product_info['size'].')';
- $new_product->p_amount = $product_info['amount'];
- $new_product->save();
- }
- } else {
- throw new Zend_Exception('bill_id is empty');
- }
- // update order status
- $order_status = new Application_Model_Statuses();
- $order_status->item_id = $order_info['order_id'];
- $order_status->item_type = 'order';
- $order_status->date = time() + $addition++;
- $order_status->status = 'В обработке';
- $order_status->comment = 'Выставлен счет на оплату #' . $bill_id;
- $order_status->admin_user = $this->_identity->email;
- $order_status->save();
- // notifications to users
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement