Inheritance: extends CI_Controller
 public function actionGet_list_basket()
 {
     $order_id = $_POST['order_id'];
     $order = new Orders();
     $data['basket'] = $order->_get_list_order($order_id);
     $this->renderPartial('//backend/order/basket', $data);
 }
 public function testGetAnnualMonthlyReport()
 {
     /*insert last month*/
     foreach (range(0, 5) as $key => $value) {
         /*insert 5 orders row*/
         $newOrder = new Orders();
         $newOrder->paid = 5000.0;
         $newOrder->order_date = (string) Carbon::parse('monday last month');
         $newOrder->save(false);
     }
     foreach (range(0, 5) as $key => $value) {
         /*insert 5 orders row*/
         $newOrder = new Orders();
         $newOrder->paid = 5000.0;
         $newOrder->order_date = (string) Carbon::parse('monday this month');
         $newOrder->save(false);
     }
     /*insert this month*/
     $reportArr = $this->annualReport->getAnnualMonthlyReport();
     /*check if Month is complete*/
     $this->assertNotNull($reportArr['January'], 'Check if January is in the report');
     $this->assertNotNull($reportArr['February'], 'Check if February is in the report');
     $this->assertNotNull($reportArr['March'], 'Check if March is in the report');
     $this->assertNotNull($reportArr['April'], 'Check if April is in the report');
     $this->assertNotNull($reportArr['May'], 'Check if May is in the report');
     $this->assertNotNull($reportArr['June'], 'Check if June is in the report');
     $this->assertNotNull($reportArr['July'], 'Check if July is in the report');
     $this->assertNotNull($reportArr['August'], 'Check if August is in the report');
     $this->assertNotNull($reportArr['September'], 'Check if September is in the report');
     $this->assertNotNull($reportArr['October'], 'Check if October is in the report');
     $this->assertNotNull($reportArr['November'], 'Check if November is in the report');
     $this->assertNotNull($reportArr['December'], 'Check if December is in the report');
     $this->assertEquals($reportArr['October'], 30000, 'Make sure total is 30000');
     $this->assertEquals($reportArr['November'], 30000, 'Make sure total is 30000');
 }
Example #3
0
 public function viewResultDetail()
 {
     $objOrder = new Orders();
     $objOrder->setTest(request_var("info"));
     $objOrder->setOrderId(request_var("ordId"));
     $objOrder->setTable(TEMP_TABLE_RESULTS . $objOrder->getOrderId());
     echo $objOrder->viewResultDetail();
 }
 /**
  * 订单列表
  */
 public function actionIndex()
 {
     $pageIndex = isset($_GET['page']) ? $_GET['page'] : 1;
     $view = isset($_GET['view']) ? $_GET['view'] : 0;
     $conditionArr = array();
     //待发货 pay_status:1;ship_status:0
     if ($view == 0) {
         $conditionArr = array('pay_status' => 1, 'ship_status' => 0);
     }
     //已发货 ship_status:1
     if ($view == 1) {
         $conditionArr = array('ship_status' => 1);
     }
     //待支付 pay_status:0
     if ($view == 2) {
         $conditionArr = array('pay_status' => 0);
     }
     //已支付到担保方 pay_status:2
     if ($view == 3) {
         $conditionArr = array('pay_status' => 2);
     }
     //已支付 pay_status:1
     if ($view == 4) {
         $conditionArr = array('pay_status' => 1);
     }
     //货到付款
     if ($view == 5) {
         $conditionArr = array('pay_status' => 10);
     }
     //活动 status:active
     if ($view == 6) {
         $conditionArr = array('status' => 'active', 'pay_status' => 0);
     }
     //已作废 status:dead
     if ($view == 7) {
         $conditionArr = array('status' => 'dead');
     }
     //已完成 status:finish
     if ($view == 8) {
         $conditionArr = array('status' => 'finish');
     }
     //全部
     if ($view == 9) {
         $conditionArr = array();
     }
     $Order = new Orders();
     $result = $Order->orderList($conditionArr, $pageIndex, $this->pagesize);
     $order_list = array();
     foreach ($result['items'] as $k => $v) {
         $order_list[$k] = $v;
         $order_list[$k]['pay_status_name'] = Params::PayStatus($v['pay_status']);
         $order_list[$k]['ship_status_name'] = Params::ShipStatus($v['ship_status']);
         $order_list[$k]['member_name'] = Params::PamMember($v['member_id']);
     }
     //分页
     $pages = new CPagination($result['count']);
     $this->render('index', array('dataProvider' => $order_list, 'view' => $view, 'pages' => $pages, 'pageIndex' => $pageIndex - 1));
 }
 /**
  * 退货
  */
 public function actionReship()
 {
     $order_id = $this->post('order_id');
     $Order = new Orders();
     $order_info = $Order->Item($order_id);
     $dlycorp_list = Dlycorp::model()->findAll("disabled = 'false'");
     $Delivery = new Delivery();
     $addr_info = $Delivery->AreaToAddr($order_info['ship_area']);
     echo $this->renderPartial('reship', array('order_id' => $order_id, 'order_info' => $order_info, 'dlycorp_list' => $dlycorp_list, 'addr_info' => $addr_info), true);
 }
Example #6
0
 public function getOrderProducts($request)
 {
     $check = $this->checkDetails($request);
     if ($check) {
         $order = new Orders();
         $array = $order->getOrderProducts($request["restaurantID"], $request["orderID"]);
         return $array;
     } else {
         return $check;
     }
 }
Example #7
0
 public static function create()
 {
     $model = new Orders();
     $dateCreated = new DateTime('now');
     $model->created = $dateCreated->format('Y-m-d H:i:s');
     $model->status = Orders::STATUS_CREATED;
     if ($model->save()) {
         return $model->id;
     } else {
         return false;
     }
 }
Example #8
0
 public function doneAction()
 {
     session_start();
     $orderid = $this->getRequest()->getParam('orderid');
     $totalprice = $this->getRequest()->getParam('totalprice');
     $orders = new Orders();
     $db = $orders->getAdapter();
     $sql = "select b.name,b.price,oi.nums from orders o, orderitem oi, book b where oi.orderid = o.id and oi.bookid = b.id and o.userid =" . $_SESSION['userid'] . " and o.id=" . $orderid;
     $res = $db->query($sql)->fetchAll();
     //EMAIL内容
     $str = "<h1>欢迎您" . $_SESSION['loginuser'] . "来到 http://shoppingcar.com</h1>";
     $str .= "您购买的东西有如下<br/>";
     $str .= "<table border='1px' width='400px'>";
     for ($i = 0; $i < count($res); $i++) {
         $str .= "<tr><td>{$i}</td><td>{$res[$i]['name']}</td>\r\n\t\t\t<td>{$res[$i]['price']}</td>\r\n\t\t\t<td>{$res[$i]['nums']}</td></tr>";
     }
     $str .= "</table>";
     $str .= "<br/><br/>总价格:" . $totalprice;
     $str .= "<br/>有什么事情请联系我们的E-MAIL yuxujian@shoppingcar.com.";
     $filename = dirname(__FILE__) . '../../../public/email/contents.html';
     file_put_contents($filename, $str);
     error_reporting(E_STRICT);
     date_default_timezone_set('America/Toronto');
     $body = file_get_contents(dirname(__FILE__) . '../../../public/email/contents.html');
     $mail = new PHPMailer();
     $mail->IsSMTP();
     $mail->SMTPAuth = true;
     // enable SMTP authentication
     $mail->SMTPSecure = "ssl";
     // sets the prefix to the servier
     $mail->Host = "smtp.gmail.com";
     // sets GMAIL as the SMTP server
     $mail->Port = 465;
     // set the SMTP port for the GMAIL server
     $mail->Username = "******";
     // GMAIL username
     $mail->Password = "******";
     // GMAIL password
     $mail->CharSet = "UTF-8";
     $address = "*****@*****.**";
     $mail->AddAddress($address, "Dear Customer");
     $mail->SetFrom('*****@*****.**', 'Customer Service');
     $mail->Subject = "您的订单 shoppingcar.com";
     $mail->AltBody = "We have receive your order, you can check your order from our web site shoppingcar.com";
     // optional, comment out and test
     $mail->IsHTML(true);
     $mail->MsgHTML($body);
     if (!$mail->Send()) {
         echo "Mailer Error: " . $mail->ErrorInfo;
     } else {
         echo "Message sent!";
     }
 }
 public function actionEdit($id)
 {
     $model = new Orders();
     $order_id = Yii::app()->request->getPost('order_id');
     $price = Yii::app()->request->getPost('price');
     $description = Yii::app()->request->getPost('description');
     $available = Yii::app()->request->getPost('available');
     $data = array('description' => $description, 'order_id' => $order_id, 'price' => $price, 'description' => $description, 'available' => $available);
     if (Yii::app()->request->isPostRequest) {
         $model->edit($data, $id);
     }
     $editOrders = $model->selectFromId($id);
     $this->render('edit', array('editOrders' => $editOrders));
 }
Example #10
0
 public static function map(Orders $order, array $properties)
 {
     if (array_key_exists('id', $properties)) {
         $order->setId($properties['id']);
     }
     if (array_key_exists('user_id', $properties)) {
         $order->setUserId($properties['user_id']);
     }
     if (array_key_exists('business_id', $properties)) {
         $order->setBusinessId($properties['business_id']);
     }
     if (array_key_exists('date', $properties)) {
         $formattedDate = $properties['date'];
         $orderDate = self::createDateTime($formattedDate);
         if ($orderDate) {
             $order->setDate($orderDate);
         }
         if (array_key_exists('status', $properties)) {
             $order->setStatus($properties['status']);
         }
         if (array_key_exists('assigned_to', $properties)) {
             $order->setAssignedTo($properties['assigned_to']);
         }
         if (array_key_exists('order_details', $properties)) {
             $order->setOrderDetails($properties['order_details']);
         }
     }
 }
function cakemake()
{
    $cake = new Cakes();
    $wedding = new Orders('hogs', 'chocolate', $cake);
    isset($_GET['frosting_color']) ? $cake->frosting_color = $_GET['frosting_color'] : ($cake->frosting_color = 'none');
    isset($_GET['cake_flavor']) ? $cake->cake_flavor = $_GET['cake_flavor'] : ($cake->cake_flavor = 'none');
    if (isset($_GET['decor_message'])) {
        $cake->decor_message = $_GET['decor_message'];
        $wedding->cost();
    } else {
        $cake->decor_message = '';
    }
    $pass = ['cake' => $cake, 'wedding' => $wedding];
    return $pass;
}
 public function paymentAction()
 {
     if ($this->request->isPost()) {
         $orderarray = $this->request->getPost('orderarray');
         $orderarray = json_decode($orderarray, TRUE);
         $sum = 0;
         foreach ($orderarray as $veg) {
             $sum += $veg[m_price] * $veg[quant];
         }
         //echo $sum;
         $auth = $this->session->get('auth');
         $id = $auth[uid];
         $orders = new Orders();
         $orders->u_id = $id;
         $orders->o_price = $sum;
         $orders->o_date = date("Y-m-d");
         $orders->o_payment = "Failed";
         $orders->o_delivery = 0;
         if ($orders->save() == false) {
             foreach ($orders->getMessages() as $message) {
                 echo $message;
             }
         } else {
             foreach ($orderarray as $veg) {
                 $orderdetails = new Orderdetails();
                 $orderdetails->o_id = $orders->o_id;
                 $orderdetails->m_id = $veg[m_id];
                 $orderdetails->od_quantity = $veg[quant];
                 $orderdetails->od_prepared = 0;
                 if ($orderdetails->save() == false) {
                     foreach ($orderdetails->getMessages() as $message) {
                         echo $message;
                     }
                 } else {
                     $user = Userdetails::findFirst(array("(u_id = :id:)", 'bind' => array('id' => $id)));
                     if ($user != false) {
                         $datename = $user->u_fname;
                         $dataemail = $user->u_email;
                         $dataphone = $user->u_phno;
                         $dataamount = $sum;
                         $url = "https://www.instamojo.com/slickaccount/test-for-integration-monthly-payment/?intent=buy&data_name=" . $dataname . "&data_email=" . $dataemail . "&data_phone=" . $dataphone . "&data_amount=" . $dataamount . "&data_readonly=data_phone&data_readonly=data_name&data_readonly=data_email";
                         header('Location: ' . $url);
                     }
                 }
             }
         }
     }
 }
Example #13
0
 public function actionStep2($id, $day)
 {
     $models_orders = new Orders();
     if (isset($_POST['Orders'])) {
         $models_orders->name = $_POST['Orders']['name'];
         $models_orders->tel = $_POST['Orders']['tel'];
         $models_orders->selected_time_id = $_POST['selected_time_id'];
         $models_orders->quest_id = $_GET['id'];
         $models_orders->date_day = $_GET['day'];
         $models_orders->setScenario('insert');
         if ($models_orders->save()) {
             $this->redirect('/site/success');
         }
     }
     $this->render('step2', array('model' => $this->loadModel($id), 'day' => $date_day, 'models_orders' => $models_orders));
 }
 public function indexAction()
 {
     $dateSelected = "";
     $sqlWithDate = "";
     if ($this->request->getPost()) {
         $dateSelected = $this->request->getPost('date');
         $sqlWithDate = " AND date_created = '{$dateSelected}'";
         $today = Carbon::now()->toDateString();
     }
     $hours = ['09' => ['hours' => '09', 'desc' => '09:00 - 10:00'], '10' => ['hours' => '10', 'desc' => '10:00 - 11:00'], '11' => ['hours' => '11', 'desc' => '11:00 - 12:00'], '12' => ['hours' => '12', 'desc' => '12:00 - 13:00'], '13' => ['hours' => '13', 'desc' => '13:00 - 14:00'], '14' => ['hours' => '14', 'desc' => '14:00 - 15:00'], '15' => ['hours' => '15', 'desc' => '15:00 - 16:00'], '16' => ['hours' => '16', 'desc' => '16:00 - 17:00'], '17' => ['hours' => '17', 'desc' => '17:00 - 18:00'], '18' => ['hours' => '18', 'desc' => '18:00 - 19:00'], '19' => ['hours' => '19', 'desc' => '19:00 - 20:00'], '20' => ['hours' => '20', 'desc' => '20:00 - 21:00'], '21' => ['hours' => '21', 'desc' => '21:00 - 22:00']];
     $stadium = [];
     $userID = "";
     for ($i = 1; $i <= 8; $i++) {
         foreach ($hours as $key => $value) {
             $order = Orders::findFirst("stadium = '{$i}' AND start_hour = '{$key}' {$sqlWithDate}");
             $link = "<a href=\"/process/add/{$i}/{$key}/{$this->session->get('user_id')}\" class=\"btn-xs btn-success\">Book Now</a>";
             $name = $link;
             if (isset($order->user_id)) {
                 $name = "<a class=\"btn-xs btn-default\">{$order->Userss->name}</a>";
                 if ($order->user_id == $this->session->get('user_id')) {
                     $name = "<a class=\"btn-xs btn-warning\">Yours</a>";
                 }
                 $userID = isset($order->user_id) ? $order->user_id : "";
             }
             if ($dateSelected < $today) {
                 $name = "<a class=\"btn-xs btn-danger\">Expired Book</a>";
             }
             $stadium[$key][$i] = ['desc' => $value['desc'], 'userId' => $userID, 'name' => $name];
         }
     }
     $this->view->setVar('data', $stadium);
     $this->view->setVar('dateSelected', $dateSelected . " (yy-mm-dd)");
 }
Example #15
0
 public function actionLogin()
 {
     switch ($_GET['model']) {
         case 'viivakoodi':
             if (isset($_POST['username']) and isset($_POST['password'])) {
                 $criteria = new CDbCriteria();
                 $criteria->order = " id DESC ";
                 $criteria->condition = " \n\t\t\tusername='******'username'] . "' \n\t\t\tAND password='******'password']) . "' \n\t\t";
                 $user = User::model()->find($criteria);
                 if (!isset($user->id)) {
                     $this->_sendResponse(200, "userError");
                     exit;
                 }
                 $criteria = new CDbCriteria();
                 $criteria->order = " id DESC ";
                 $criteria->condition = " \n\t\t\tuser_id='" . $user->id . "'\n\t\t\tAND CURDATE() BETWEEN start AND stop \n\t\t\tAND status=1 \n\t\t";
                 $order = Orders::model()->find($criteria);
                 if (!isset($order->id)) {
                     $this->_sendResponse(200, 'Käyttöaika umpeutunut. Osta aikaa käyttääksesi ohjelmaa.');
                     exit;
                 }
                 if (isset($user->id) and isset($order->id)) {
                     $this->_sendResponse(200, $user->id);
                 }
             } else {
                 $this->_sendResponse(200, "Jotain on väärin");
             }
             break;
     }
 }
Example #16
0
 /**
  * @param $rule
  * @return bool
  */
 private function ckLaboratoryResults($rule)
 {
     if (isset($rule['concepts']['LAB']) && !empty($rule['concepts']['LAB'])) {
         $count = 0;
         foreach ($rule['concepts']['LAB'] as $concept) {
             $observations = $this->Orders->getOrderResultObservationsByPidAndCode($this->Patient->getPatientPid(), $concept['concept_code']);
             if (empty($observations) && $concept['frequency_operator'] != '<') {
                 continue;
             }
             $frequency = 0;
             foreach ($observations as $observation) {
                 if ($concept['value'] == '' || $this->compare($observation['value'], $concept['value_operator'], $concept['value'])) {
                     if ($this->isWithInterval($observation['result_date'], $concept['frequency_interval'], $concept['frequency_operator'], 'Y-m-d')) {
                         $frequency++;
                         if ($concept['frequency'] == $frequency) {
                             break;
                         }
                     }
                 }
             }
             if ($concept['frequency_operator'] == '' || $this->compare($frequency, $concept['frequency_operator'], $concept['frequency'])) {
                 $count++;
             }
         }
         return $count == count($rule['concepts']['LAB']);
     }
     return true;
 }
Example #17
0
 /**
  *   Добавляет запись в таблицу ns_order_dubl
  *
  */
 public function addOrder($order, $month, $week, $year)
 {
     $o = new Orders($this->connDB);
     if (!($o_id = $o->getIdOrder($order))) {
         echo "<br>Не могу определить o_id для {$order}";
         return false;
     }
     $query = "INSERT INTO `ns_order_dubl`(`o_id`,`aYear`,`month`,`aWeek`) \n                VALUES ('{$o_id}','{$year}','{$month}','{$week}')";
     if (mysql_query($query)) {
         $last_od_id = mysql_insert_id();
         $this->reload();
         return $last_od_id;
     } else {
         return false;
     }
 }
 public function indexAction()
 {
     $auth = $this->session->get('auth');
     $id = $auth[uid];
     $orders = Orders::find(array("conditions" => "u_id = :uid:", "bind" => array("uid" => $id), "order" => "o_id DESC"));
     $this->view->orders = $orders;
 }
Example #19
0
 public function actionOrderView()
 {
     $id = $_REQUEST['id'];
     $cri = new CDbCriteria(array('condition' => 'order_id =' . $id));
     $model = Orders::model()->find($cri);
     $this->render('orderView', array('model' => $model));
 }
Example #20
0
 public function init()
 {
     // Set the custom decorator
     $this->addElementPrefixPath('Shineisp_Decorator', 'Shineisp/Decorator/', 'decorator');
     $translate = Shineisp_Registry::get('Zend_Translate');
     $this->addElement('text', 'date_start', array('filters' => array('StringTrim'), 'required' => true, 'label' => $translate->_('Creation date'), 'decorators' => array('Bootstrap'), 'class' => 'form-control date', 'dateformat' => Settings::getJsDateFormat()));
     $this->addElement('text', 'date_end', array('filters' => array('StringTrim'), 'label' => $translate->_('Expiry Date'), 'decorators' => array('Bootstrap'), 'class' => 'form-control date', 'dateformat' => Settings::getJsDateFormat()));
     $this->addElement('text', 'quantity', array('filters' => array('StringTrim'), 'required' => true, 'label' => $translate->_('Quantity'), 'decorators' => array('Bootstrap'), 'class' => 'form-control'));
     $this->addElement('textarea', 'message', array('filters' => array('StringTrim'), 'label' => $translate->_('Message'), 'decorators' => array('Bootstrap'), 'class' => 'col-lg-12 form-control wysiwyg'));
     $this->addElement('textarea', 'note', array('filters' => array('StringTrim'), 'label' => $translate->_('Note'), 'description' => $translate->_('Write here a note. An email will be sent to the ISP staff.'), 'decorators' => array('Bootstrap'), 'class' => 'col-lg-12 form-control wysiwyg'));
     $this->addElement('textarea', 'setup', array('filters' => array('StringTrim'), 'label' => $translate->_('Setup Configuration'), 'description' => $translate->_('Here you can read the service configuration written by the ISP modules. These information are read-only.'), 'decorators' => array('Bootstrap'), 'class' => 'col-lg-12'));
     $this->addElement('select', 'order_id', array('label' => $translate->_('Orders'), 'decorators' => array('Bootstrap'), 'class' => 'form-control'));
     $this->getElement('order_id')->setAllowEmpty(false)->setMultiOptions(Orders::getList(true));
     $this->addElement('multiselect', 'domains', array('label' => $translate->_('Available domains'), 'decorators' => array('Bootstrap'), 'class' => 'form-control col-lg-12 tmpitems'));
     $this->getElement('domains')->setAllowEmpty(false)->setRegisterInArrayValidator(false)->setMultiOptions(Domains::getList());
     $this->addElement('multiselect', 'domains_selected', array('label' => $translate->_('Selected domains'), 'decorators' => array('Bootstrap'), 'class' => 'form-control col-lg-12 items'));
     $this->getElement('domains_selected')->setRegisterInArrayValidator(false);
     // Disable the Validator in order to manage a dynamic list.
     $this->addElement('select', 'product_id', array('label' => $translate->_('Products'), 'decorators' => array('Bootstrap'), 'class' => 'form-control'));
     $this->getElement('product_id')->setAllowEmpty(false)->setMultiOptions(Products::getList(true));
     $this->addElement('select', 'billing_cycle_id', array('label' => $translate->_('Billing Cycle'), 'decorators' => array('Bootstrap'), 'class' => 'form-control'));
     $this->getElement('billing_cycle_id')->setAllowEmpty(false)->setMultiOptions(BillingCycle::getList(true));
     $this->addElement('select', 'status_id', array('label' => $translate->_('Status'), 'decorators' => array('Bootstrap'), 'class' => 'form-control'));
     $this->getElement('status_id')->setAllowEmpty(false)->setMultiOptions(Statuses::getList('orders', false, true));
     $this->addElement('select', 'autorenew', array('filters' => array('StringTrim'), 'decorators' => array('Bootstrap'), 'label' => $translate->_('Auto Renewal'), 'description' => $translate->_('Enable or disable the automatic renewal of the service'), 'class' => 'form-control'));
     $this->getElement('autorenew')->setAllowEmpty(false)->setMultiOptions(array('1' => $translate->_('Yes, I would like to renew the service at the expiration date.'), '0' => $translate->_('No, I am not interested in the service renew.')));
     $this->addElement('hidden', 'detail_id');
 }
 public function updateOrderStatus()
 {
     //create an order class
     $order = new Orders();
     //check if the result array is empty or not
     if (is_array($this->result)) {
         //looping through each order
         foreach ($this->result as $eachItem) {
             //find the primary key of each order
             $temp = $eachItem['U_id'];
             //Perform check to ignore completed orders else indexing error occurs
             if ($eachItem['status'] === 'Processing' or $eachItem['status'] === 'placed') {
                 if ($this->order_status[$temp] === "Processing") {
                     $order = Orders::model()->findByPk($temp);
                     $order->status = "Processing";
                     $order->save();
                 } else {
                     if ($this->order_status[$temp] === "Done") {
                         $order = Orders::model()->findByPk($temp);
                         $order->status = "Done";
                         $order->save();
                     } else {
                         if ($this->order_status[$temp] === "Delivering") {
                             $order = Orders::model()->findByPk($temp);
                             $order->status = "Delivering";
                             $order->save();
                         }
                     }
                 }
             }
         }
     }
 }
Example #22
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Contracts();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_GET['byorder']) and is_numeric($_GET['byorder'])) {
         $order_id = (int) $_GET['byorder'];
         $model->order_id = $order_id;
         $model->order = Orders::model()->findByPk($order_id);
         $model->name = $model->order->name;
         $model->client_id = $model->order->client_id;
         $model->sum = Yii::app()->db->createCommand()->select('SUM(cost*quantity) as order_sum')->from('{{works}}')->where('{{works}}.order_id = ' . $order_id)->queryScalar();
         $model->num = Yii::app()->db->createCommand()->select('max(num*1) as max')->from('{{contracts}}')->queryScalar();
         $model->num = $model->num + 1;
         if (isset($_POST['Contracts'])) {
             //			CVarDumper::dump($_POST['Contracts'],10,true);die;
             $model->attributes = $_POST['Contracts'];
             if ($model->save()) {
                 $msg = 'Договор #' . $model->id . ' - ' . $model->name . ' для ' . $model->client->name . ' создан';
                 Yii::app()->user->setFlash('success', $msg);
                 Yii::app()->logger->write($msg);
                 if (isset($order_id)) {
                     $this->redirect(array('orders/view', 'id' => $order_id));
                 } else {
                     $this->redirect(array('view', 'id' => $model->id));
                 }
             }
         }
     }
     $model->date = $model->isNewRecord ? date('Y-m-d') : $model->date;
     $this->render('create', array('model' => $model));
 }
 public function checkoutAction()
 {
     $id = $this->session->get('user_id');
     $orderList = TempOrder::find("user_id = '{$this->session->get('user_id')}'");
     foreach ($orderList as $key => $value) {
         $order = new Orders();
         $order->id = UUID::v4();
         $order->stadium = $value->stadium;
         $order->start_hour = $value->start_hour;
         $order->end_hour = $value->end_hour;
         $order->user_id = $value->user_id;
         $order->date_created = Carbon::now()->toDateString();
         $order->save();
         $value->delete();
     }
     $this->response->redirect('/dashboard');
 }
 public function actionWechatResult()
 {
     $order_code = $_GET['order_code'];
     Orders::model()->updateAll(array('status' => 2), 'order_code=:order_code', array(':order_code' => $order_code));
     $this->_seoTitle = '支付成功';
     $result = 'success';
     $this->render('alipay_result', array('result' => $result, 'order_code' => $order_code));
 }
Example #25
0
 public function summary($year = null)
 {
     $this->view->income_yearly = Orders::incomes();
     $this->view->income_quarter = Orders::incomes(array(), 'quarter');
     $this->view->income_text_monthly = Orders::incomes(array(), 'month');
     $this->view->income_graph_monthly = Orders::incomes(array(), 'month');
     return $this->view->render('partials/summary.phtml');
 }
Example #26
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return Orders the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Orders::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Example #27
0
 public function deleteOrder($id)
 {
     $result = Orders::model()->findByAttributes(array('id' => $id));
     $result->status = '0';
     if ($result->save()) {
         $data = array('code' => 200, 'message' => 'SUCCESS');
     }
     return $data;
 }
Example #28
0
 /**
  * __construct
  * @param integer $orderid
  * @return array
  */
 public function __construct($orderid)
 {
     $order = Orders::getAllInfo($orderid, 'o.*, oi.*, c.*', true);
     $this->orderid = $orderid;
     if (!empty($order[0])) {
         $this->order = $order[0];
     }
     $this->translator = Shineisp_Registry::getInstance()->Zend_Translate;
 }
 public function actionIndex()
 {
     $ordersModel = new Orders('search');
     $ordersModel->unsetAttributes();
     // clear any default values
     if (isset($_GET['Orders'])) {
         $ordersModel->attributes = $_GET['Orders'];
     }
     $ordersModel->user_id = Yii::app()->user->id;
     $carsModel = new Cars('search');
     $carsModel->unsetAttributes();
     // clear any default values
     if (isset($_GET['Cars'])) {
         $carsModel->attributes = $_GET['Cars'];
     }
     $carsModel->ower_id = Yii::app()->user->id;
     $this->render('index', array('user' => $this->loadModel(Yii::app()->user->id), 'userid' => Yii::app()->user->id, 'orders' => $ordersModel, 'cars' => $carsModel));
 }
 protected function tearDown()
 {
     //        /*delete all productOrders*/
     ProductOrders::model()->deleteAll();
     /*delete all products*/
     Product::model()->deleteAll();
     /*delete all orders*/
     Orders::model()->deleteAll();
     parent::tearDown();
 }