コード例 #1
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 the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = RateCompany::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
コード例 #2
0
 public function actionGetExtTypeService()
 {
     $result = array('status' => 'error', 'data' => '');
     $data = array();
     if (isset($_REQUEST['Shipment'])) {
         $shipment = new Shipment();
         $shipment->setAttributes($_REQUEST['Shipment']);
         if ($shipment->customer_id != '') {
             $join = 'INNER JOIN product_service t2 ON t.id = t2.product_id INNER JOIN service_detail t3 ON t2.id = t3.product_service_id INNER JOIN rate_company_service t4 ON t4.id = t3.rate_company_service_id JOIN rate_company t5 ON t5.id = t4.rate_company_id JOIN customer_discount t6 ON t3.id = t6.service_id';
             $select = 't4.id as service_id,t2.name as service_name,t2.code,t4.name as carrier_service,t5.name vendor_name,t6.use_rate';
         } else {
             $join = 'INNER JOIN product_service t2 ON t.id = t2.product_id INNER JOIN service_detail t3 ON t2.id = t3.product_service_id INNER JOIN rate_company_service t4 ON t4.id = t3.rate_company_service_id JOIN rate_company t5 ON t5.id = t4.rate_company_id';
             $select = 't4.id as service_id,t2.name as service_name,t2.code,t4.name as carrier_service,t5.name vendor_name';
         }
         $cek_routing = RateCompany::model()->findByAttributes(array('code' => $shipment->destination_code));
         $criteria = new CDbCriteria();
         $criteria->join = $join;
         $criteria->select = $select;
         $criteria->addSearchCondition('t.name', $shipment->service_type);
         if ($shipment->customer_id != '') {
             $criteria->params[':customer_id'] = $shipment->customer_id;
             $criteria->addCondition('t6.customer_id =:customer_id AND use_rate = 1');
         }
         if ($shipment->service_type == 'City Courier') {
             if ($cek_routing instanceof RateCompany) {
                 $criteria->addSearchCondition('t5.code', $shipment->destination_code);
             } else {
                 $criteria->addSearchCondition('t5.id', 5);
             }
         }
         if ($shipment->service_type == 'Domestic') {
             $criteria->addSearchCondition('t5.code', $shipment->destination_code);
         }
         if ($shipment->service_type == 'International') {
             $criteria->addSearchCondition('t5.code', $shipment->destination_code);
             if (ucfirst($shipment->receiver_country) != 'indonesia') {
                 $criteria->addSearchCondition('t2.id', 10);
             } else {
                 $criteria->addSearchCondition('t2.id', 11);
             }
         }
         $builder = new CDbCommandBuilder(Yii::app()->db->Schema);
         $command = $builder->createFindCommand('product', $criteria);
         $services = $command->queryAll();
         if (!!$services) {
             $result = array('status' => 'success', 'data' => $services);
         }
     }
     echo CJSON::encode($result);
     Yii::app()->end();
 }
コード例 #3
0
ファイル: Shipment.php プロジェクト: aantonw/dcourier.system
 public function GetExtCarrierData()
 {
     $data = array();
     $carriers = RateCompany::model()->findAll();
     if (count($carriers) != 0) {
         foreach ($carriers as $carrier) {
             array_push($data, array("id" => "{$carrier->id}", "code" => "{$carrier->code}"));
         }
     }
     return CJSON::encode($data);
 }