Exemplo n.º 1
0
 public function FoodItemAdd()
 {
     $mtid = Yii::app()->functions->getMerchantID();
     if (!Yii::app()->functions->validateMerchantCanPost($mtid)) {
         if (isset($this->data['id']) && is_numeric($this->data['id'])) {
         } else {
             $this->msg = Yii::t("default", "Sorry but you reach the limit of adding food item. Please upgrade your membership");
             return;
         }
     }
     $price = '';
     if (isset($this->data['price']) && count($this->data['price']) >= 1) {
         foreach ($this->data['price'] as $key => $val) {
             if (!empty($val)) {
                 $price[$this->data['size'][$key]] = $val;
             }
         }
     }
     $params = array('date_created' => date('c'), 'ip_address' => $_SERVER['REMOTE_ADDR'], 'merchant_id' => Yii::app()->functions->getMerchantID(), 'item_name' => isset($this->data['item_name']) ? $this->data['item_name'] : "", 'item_description' => isset($this->data['item_description']) ? $this->data['item_description'] : '', 'status' => $this->data['status'], 'category' => isset($this->data['category']) ? json_encode($this->data['category']) : "", 'price' => isset($price) ? json_encode($price) : '', 'addon_item' => isset($this->data['sub_item_id']) ? json_encode($this->data['sub_item_id']) : "", 'cooking_ref' => isset($this->data['cooking_ref']) ? json_encode($this->data['cooking_ref']) : "", 'discount' => isset($this->data['discount']) ? $this->data['discount'] : "", 'multi_option' => isset($this->data['multi_option']) ? json_encode($this->data['multi_option']) : "", 'multi_option_value' => isset($this->data['multi_option_value']) ? json_encode($this->data['multi_option_value']) : "", 'photo' => isset($this->data['photo']) ? $this->data['photo'] : "", 'ingredients' => isset($this->data['ingredients']) ? json_encode($this->data['ingredients']) : "", 'spicydish' => isset($this->data['spicydish']) ? $this->data['spicydish'] : "", 'two_flavors' => isset($this->data['two_flavors']) ? $this->data['two_flavors'] : '', 'two_flavors_position' => isset($this->data['two_flavors_position']) ? json_encode($this->data['two_flavors_position']) : "", 'require_addon' => isset($this->data['require_addon']) ? json_encode($this->data['require_addon']) : "", 'dish' => isset($this->data['dish']) ? json_encode($this->data['dish']) : '', 'non_taxable' => isset($this->data['non_taxable']) ? $this->data['non_taxable'] : 1);
     if (isset($this->data['item_name_trans'])) {
         if (okToDecode()) {
             $params['item_name_trans'] = json_encode($this->data['item_name_trans'], JSON_UNESCAPED_UNICODE);
         } else {
             $params['item_name_trans'] = json_encode($this->data['item_name_trans']);
         }
     }
     if (isset($this->data['item_description_trans'])) {
         if (okToDecode()) {
             $params['item_description_trans'] = json_encode($this->data['item_description_trans'], JSON_UNESCAPED_UNICODE);
         } else {
             $params['item_description_trans'] = json_encode($this->data['item_description_trans']);
         }
     }
     /*dump($params);		
     		die();*/
     $command = Yii::app()->db->createCommand();
     if (isset($this->data['id']) && is_numeric($this->data['id'])) {
         unset($params['date_created']);
         $params['date_modified'] = date('c');
         $res = $command->update('{{item}}', $params, 'item_id=:item_id', array(':item_id' => addslashes($this->data['id'])));
         if ($res) {
             $this->code = 1;
             $this->msg = Yii::t("default", 'Item updated.');
         } else {
             $this->msg = Yii::t("default", "ERROR: cannot update");
         }
     } else {
         if ($res = $command->insert('{{item}}', $params)) {
             $this->details = Yii::app()->db->getLastInsertID();
             $this->code = 1;
             $this->msg = Yii::t("default", 'Item added.');
         } else {
             $this->msg = Yii::t("default", 'ERROR. cannot insert data.');
         }
     }
 }
Exemplo n.º 2
0
 public function AddIngredients()
 {
     $params = array('ingredients_name' => $this->data['ingredients_name'], 'status' => addslashes($this->data['status']), 'date_created' => date('c'), 'ip_address' => $_SERVER['REMOTE_ADDR'], 'merchant_id' => Yii::app()->functions->getMerchantID());
     if (isset($this->data['ingredients_name_trans'])) {
         if (okToDecode()) {
             $params['ingredients_name_trans'] = json_encode($this->data['ingredients_name_trans'], JSON_UNESCAPED_UNICODE);
         } else {
             $params['ingredients_name_trans'] = json_encode($this->data['ingredients_name_trans']);
         }
     }
     $command = Yii::app()->db->createCommand();
     if (isset($this->data['id']) && is_numeric($this->data['id'])) {
         unset($params['date_created']);
         $params['date_modified'] = date('c');
         $res = $command->update('{{ingredients}}', $params, 'ingredients_id=:ingredients_id', array(':ingredients_id' => addslashes($this->data['id'])));
         if ($res) {
             $this->code = 1;
             $this->msg = Yii::t("default", 'ingredients updated');
         } else {
             $this->msg = Yii::t("default", "ERROR: cannot update");
         }
     } else {
         if ($res = $command->insert('{{ingredients}}', $params)) {
             $this->details = Yii::app()->db->getLastInsertID();
             $this->code = 1;
             $this->msg = Yii::t("default", 'ingredients added');
         } else {
             $this->msg = Yii::t("default", 'ERROR. cannot insert data.');
         }
     }
 }