Ejemplo n.º 1
0
 public function actionFranchise()
 {
     $id = $_POST['id'];
     $franchise = Franchise::model()->findByPk($id);
     if (!$franchise) {
         echo "No data found";
         Yii::app()->end;
     }
     $return = array();
     $return['total'] = $franchise->countTotal;
     $return['customer'] = $franchise->countCustomer;
     $return['prospect'] = $franchise->countProspect;
     $return['lost'] = $franchise->countLost;
     $this->_sendResponse(200, CJSON::encode($return));
 }
Ejemplo n.º 2
0
 public static function syncFranchise($url)
 {
     $franchises = self::getData($url);
     foreach ($franchises as $franchise) {
         $fran = Franchise::model()->findByPk($franchise->id);
         if (!$fran) {
             $fran = new Franchise();
         }
         $fran->id = $franchise->id;
         $fran->name = $franchise->d_city ? $franchise->d_city : $franchise->username;
         $fran->pid = $franchise->pid;
         mErrors($fran, 0);
         if ($fran->save()) {
             self::syncFranchiseUser($franchise);
         }
     }
 }
Ejemplo n.º 3
0
 public static function getFranchise()
 {
     $model = Franchise::model()->findAll();
     return CHtml::listData($model, 'id', 'name');
 }
 /**
  * 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 Franchise the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Franchise::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }