Advertisement
turist_ua

example for zend_db current usage

Nov 8th, 2012
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.16 KB | None | 0 0
  1.         if (! empty($make_flag) && $make_flag){
  2.             // set go to active
  3.             $go = new Application_Model_GroupOrders($go_id);
  4.             $go->active = 1;
  5.             $go->save();
  6.  
  7.             //update go status
  8.             $go_status = new Application_Model_Statuses();
  9.             $go_status->item_id = $go_id;
  10.             $go_status->item_type = 'group_order';
  11.             $go_status->date = time();
  12.             $go_status->status = 'В работе';
  13.             $go_status->comment = 'Выставлены счета клиентам';
  14.             $go_status->admin_user = $this->_identity->email;
  15.             $go_status->save();
  16.  
  17.             $addition = 1;
  18.             // update orders statuses
  19.             foreach($go_info['orders_list'] as $order_info){
  20.  
  21.                 // add new bill for each order
  22.                 $new_bill = new Application_Model_Bills();
  23.                 $new_bill->user_id = $order_info['user_id'];
  24.                 $new_bill->order_id = $order_info['order_id'];
  25.                 $new_bill->date = time() + $addition++;
  26.                 $new_bill->type = 'payment';
  27.                 $new_bill->amount = $order_info['bill_price'];
  28.                 $new_bill->cur_id = $order_info['cur_id'];
  29.                 $new_bill->comment = '';
  30.                 if ($new_bill->save()){
  31.                     $bill_id = $new_bill->getLastInsertId();
  32.                     if(! empty($bill_id)){
  33.                         // add products info to bill
  34.                         foreach($order_info['products'] as $product_info){
  35.                             $new_product = new Application_Model_BillsProducts();
  36.                             $new_product->bill_id = $bill_id;
  37.                             $new_product->p_id = $product_info['p_id'];
  38.                             $new_product->p_info = $product_info['name'] . '(' . $product_info['color'] . '/' . $product_info['size'].')';
  39.                             $new_product->p_amount = $product_info['amount'];
  40.                             $new_product->save();
  41.                         }
  42.                     } else {
  43.                         throw new Zend_Exception('bill_id is empty');
  44.                     }
  45.                     // update order status
  46.                     $order_status = new Application_Model_Statuses();
  47.                     $order_status->item_id = $order_info['order_id'];
  48.                     $order_status->item_type = 'order';
  49.                     $order_status->date = time() + $addition++;
  50.                     $order_status->status = 'В обработке';
  51.                     $order_status->comment = 'Выставлен счет на оплату #' . $bill_id;
  52.                     $order_status->admin_user = $this->_identity->email;
  53.                     $order_status->save();
  54.  
  55.                     // notifications to users      
  56.  
  57.                 }
  58.             }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement