示例#1
0
 public function getAll($uuid)
 {
     $customers = Customers::findWithUuid($uuid);
     if (empty($customers)) {
         throw new Shineisp_Api_Exceptions(400006, ":: 'uuid' not valid");
         exit;
     }
     $id = $customers['customer_id'];
     $services = Products::getAllServicesByCustomerID($id, 'o.order_id, oi.detail_id as detail_id, pd.name as productname, 
     DATE_FORMAT(oi.date_start, "%d/%m/%Y") AS date_start, DATE_FORMAT(oi.date_end, "%d/%m/%Y") AS date_end, 
     DATEDIFF(oi.date_end, CURRENT_DATE) AS daysleft, oi.price as price, oi.autorenew as autorenew, oi.uuid as uuid, s.status as status');
     return $services;
 }
示例#2
0
 private function servicesGrid()
 {
     $request = Zend_Controller_Front::getInstance()->getRequest();
     try {
         if (isset($request->id) && is_numeric($request->id)) {
             // In order to select only the fields interested we have to add an alias to all the fields. If the aliases are not created Doctrine will require an index field for each join created.
             //$rs = Products::getAllServicesByCustomerID ( $request->id, 'oi.detail_id as detail_id, pd.name as productname' );
             $rs = Products::getAllServicesByCustomerID($request->id, 'o.order_id, oi.detail_id as detail_id, pd.name as productname, DATE_FORMAT(oi.date_start, "%d/%m/%Y") AS date_start, DATE_FORMAT(oi.date_end, "%d/%m/%Y") AS date_end, DATEDIFF(oi.date_end, CURRENT_DATE) AS daysleft, oi.price as price, oi.autorenew as autorenew, oi.status_id as status');
             if ($rs) {
                 $arrStatuses = Statuses::getList('orders');
                 foreach ($rs as $k => $v) {
                     if (isset($v['price'])) {
                         //* TODO: Format price based on locale
                         $rs[$k]['price'] = $v['price'];
                     }
                     if (isset($v['status']) && isset($arrStatuses[$v['status']])) {
                         $rs[$k]['status'] = $arrStatuses[$v['status']];
                     }
                     if (isset($v['autorenew'])) {
                         $rs[$k]['autorenew'] = $v['autorenew'] == 1 ? $this->translator->translate('Yes') : $this->translator->translate('Yes');
                     }
                     if (isset($v['date_start'])) {
                         $rs[$k]['date_start'] = Shineisp_Commons_Utilities::formatDateIn($v['date_start']);
                     }
                     if (isset($v['date_end'])) {
                         $rs[$k]['date_end'] = Shineisp_Commons_Utilities::formatDateIn($v['date_end']);
                     }
                 }
                 $columns[] = $this->translator->translate('Product');
                 $columns[] = $this->translator->translate('Creation Date');
                 $columns[] = $this->translator->translate('Expiry Date');
                 $columns[] = $this->translator->translate('Days left');
                 $columns[] = $this->translator->translate('Price');
                 $columns[] = $this->translator->translate('Automatic renewal');
                 $columns[] = $this->translator->translate('Status');
                 return array('name' => 'services', 'columns' => $columns, 'records' => $rs, 'edit' => array('controller' => 'ordersitems', 'action' => 'edit'), 'pager' => true);
             }
         }
     } catch (Exception $e) {
         $this->_helper->redirector('edit', 'customers', 'admin', array('id' => $request->id, 'mex' => $this->translator->translate('Unable to process the request at this time.') . ": " . $e->getMessage(), 'status' => 'danger'));
     }
 }