/**
  * 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 Sandwiches the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Sandwiches::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
 public function actionCustomerReply()
 {
     if (isset($_POST['customer']) && isset($_POST['customer']['ajax'])) {
         //            echo $_POST['customer']['provisional_date'];
         //            print_r($_POST['customer']);
         //                    $customer_questions = $this->loadModel(getCurCusId());
         $customer_questions = $this->loadModel(getCurCusId());
         $customer_questions->provisional_date = isset($_POST['customer']['provisional_date']) ? $_POST['customer']['provisional_date'] : "";
         $customer_questions->call_date = isset($_POST['customer']['call_date']) ? $_POST['customer']['call_date'] : "";
         //                    mErrors($customer_questions);
         $customer_questions->save();
         echo json_encode(array('success' => 1));
         exit;
     }
     //        $magic_spoon = MagicSpool::model()->findByAttributes(array('cus_id' => getCurCusId()));
     //        $magic_spoon = MagicSpool::model()->find()->findByAttributes(array('cus_id' => getCurCusId()));
     $magic_spoon = MagicSpool::model()->findAll(array('select' => 'one,two,three,four,five', 'condition' => 'cus_id=:cus_id', 'params' => array(':cus_id' => getCurCusId())));
     $lunch_count = Lunch::model()->count(array('condition' => 'cus_id=:cus_id', 'params' => array(':cus_id' => getCurCusId())));
     $break_count = Breakfast::model()->count(array('condition' => 'cus_id=:cus_id', 'params' => array(':cus_id' => getCurCusId())));
     $hotf_count = HotFood::model()->count(array('condition' => 'cus_id=:cus_id', 'params' => array(':cus_id' => getCurCusId())));
     $sandw_count = Sandwiches::model()->count(array('condition' => 'cus_id=:cus_id', 'params' => array(':cus_id' => getCurCusId())));
     $sundr_count = Sundries::model()->count(array('condition' => 'cus_id=:cus_id', 'params' => array(':cus_id' => getCurCusId())));
     $IndusFood_count = IndusFood::model()->count(array('condition' => 'cus_id=:cus_id', 'params' => array(':cus_id' => getCurCusId())));
     $customer = Customer::model()->findByPk(getCurCusId());
     $criteria = new CDbCriteria();
     $criteria->select = 't.name,t.desc';
     $ee1 = explode(',', $customer->sel_products);
     $criteria->addInCondition('id', $ee1);
     $selProdt = Product::model()->findAll($criteria);
     $this->render('customerreply', array('magic_spoon' => $magic_spoon, 'lunch_count' => $lunch_count, 'break_count' => $break_count, 'hotf_count' => $hotf_count, 'sandw_count' => $sandw_count, 'sundr_count' => $sundr_count, 'indusFood_count' => $IndusFood_count, 'selProdt' => $selProdt));
 }
 public function actionAdminSolns1()
 {
     if (isset($_GET['id'])) {
         $id = intval($_GET['id']);
         $curUser = Customer::model()->findByPk($id);
         if (empty($curUser->id)) {
             throw new CHttpException(403, 'Customer Does\'t exists');
         }
         Yii::app()->session['last_created_user'] = $curUser->attributes;
     }
     $cust = Customer::model()->findAll(array('condition' => 'id=:id ', 'params' => array(':id' => getCurCusId())));
     $selProd = SelProducts::model()->findAll(array("condition" => "cus_id =" . getCurCusId(), "order" => "product_id asc"));
     $selData = CHtml::listData($selProd, 'id', 'product_id');
     $criteria = new CDbCriteria();
     $criteria->addInCondition('id', $selData);
     $selproducts = Product::model()->findAll($criteria);
     foreach ($cust as $k => $val) {
         $magicSpools = $val->magicSpools;
         $magicSpoolsAns = $val->magicSpoolsAns;
         $notes = $val->notes;
         $workingWells = $val->workingWells;
         $hotFoods = $val->hotFoods;
         $lunches = $val->lunches;
         $breakfasts = $val->breakfasts;
         $sundries = $val->sundries;
         $indusFoods = $val->indusFoods;
         $sandwiches = $val->sandwiches;
     }
     if (isset($_POST['ajax']) && $_POST['ajax'] == 1) {
         $cust[0]->unable_to_commit = $_POST['final_comment'];
         $cust[0]->save();
         if (count($magicSpools)) {
             $mspoon = MagicSpoolAns::model()->findByAttributes(array('cus_id' => getCurCusId()));
             if ($mspoon === NULL) {
                 $mspoon = new MagicSpoolAns();
                 $mspoon->cus_id = getCurCusId();
             }
             $mspoon->one = isset($_POST['one']) ? $_POST['one'] : "";
             $mspoon->two = isset($_POST['two']) ? $_POST['two'] : "";
             $mspoon->three = isset($_POST['three']) ? $_POST['three'] : "";
             $mspoon->four = isset($_POST['four']) ? $_POST['four'] : "";
             $mspoon->five = isset($_POST['five']) ? $_POST['five'] : "";
             $mspoon->one_comment = isset($_POST['magicspools']['one']['comment']) ? $_POST['magicspools']['one']['comment'] : "";
             $mspoon->two_comment = isset($_POST['magicspools']['two']['comment']) ? $_POST['magicspools']['two']['comment'] : "";
             $mspoon->three_comment = isset($_POST['magicspools']['three']['comment']) ? $_POST['magicspools']['three']['comment'] : "";
             $mspoon->four_comment = isset($_POST['magicspools']['four']['comment']) ? $_POST['magicspools']['four']['comment'] : "";
             $mspoon->five_comment = isset($_POST['magicspools']['five']['comment']) ? $_POST['magicspools']['five']['comment'] : "";
             $mspoon->one_like = isset($_POST['magicspools']['one']['like']) ? intval($_POST['magicspools']['one']['like']) : "0";
             $mspoon->two_like = isset($_POST['magicspools']['two']['like']) ? intval($_POST['magicspools']['two']['like']) : "0";
             $mspoon->three_like = isset($_POST['magicspools']['three']['like']) ? intval($_POST['magicspools']['three']['like']) : "0";
             $mspoon->four_like = isset($_POST['magicspools']['four']['like']) ? intval($_POST['magicspools']['four']['like']) : "0";
             $mspoon->five_like = isset($_POST['magicspools']['five']['like']) ? intval($_POST['magicspools']['five']['like']) : "0";
             //                p($_POST['magicspools']);
             //                exit;
             $mspoon->save();
         }
         if (isset($_POST['hotFoods'])) {
             if (isset($_POST['hotFoods']['ans'])) {
                 foreach ($_POST['hotFoods']['ans'] as $ans) {
                     //                        p($ans);
                     $model = HotFood::model()->findByPk(intval($ans['pro']));
                     $model->ans = $ans['comment'];
                     $model->menu_name = $ans['menuname'];
                     $model->price_per_head_f = $ans['price_per_head_pound'];
                     $model->whats_included = $ans['whats_included'];
                     if (isset($ans['like'])) {
                         $model->like = $ans['like'];
                     }
                     if (isset($ans['cus_comment'])) {
                         $model->comment = $ans['cus_comment'];
                     }
                     $model->save();
                 }
             }
         }
         if (isset($_POST['sandwiches'])) {
             if (isset($_POST['sandwiches']['ans'])) {
                 foreach ($_POST['sandwiches']['ans'] as $ans) {
                     $model = Sandwiches::model()->findByPk(intval($ans['pro']));
                     $model->ans = $ans['comment'];
                     $model->menu_name = $ans['menuname'];
                     $model->price_per_head_f = $ans['price_per_head_pound'];
                     $model->whats_included = $ans['whats_included'];
                     if (isset($ans['like'])) {
                         $model->like = $ans['like'];
                     }
                     if (isset($ans['cus_comment'])) {
                         $model->comment = $ans['cus_comment'];
                     }
                     $model->save();
                 }
             }
         }
         if (isset($_POST['breakfasts'])) {
             if (isset($_POST['breakfasts']['ans'])) {
                 foreach ($_POST['breakfasts']['ans'] as $ans) {
                     $model = Breakfast::model()->findByPk(intval($ans['pro']));
                     $model->ans = $ans['comment'];
                     $model->menu_name = $ans['menuname'];
                     $model->price_per_head_f = $ans['price_per_head_pound'];
                     $model->whats_included = $ans['whats_included'];
                     if (isset($ans['like'])) {
                         $model->like = $ans['like'];
                     }
                     if (isset($ans['cus_comment'])) {
                         $model->comment = $ans['cus_comment'];
                     }
                     //                        p($model->attributes);
                     $model->save();
                 }
             }
         }
         if (isset($_POST['indusFoods'])) {
             if (isset($_POST['indusFoods']['ans'])) {
                 foreach ($_POST['indusFoods']['ans'] as $ans) {
                     $model = IndusFood::model()->findByPk(intval($ans['pro']));
                     $model->ans = $ans['comment'];
                     $model->menu_name = $ans['menuname'];
                     $model->price_per_head_f = $ans['price_per_head_pound'];
                     $model->whats_included = $ans['whats_included'];
                     if (isset($ans['like'])) {
                         $model->like = $ans['like'];
                     }
                     if (isset($ans['cus_comment'])) {
                         $model->comment = $ans['cus_comment'];
                     }
                     $model->save();
                 }
             }
         }
         if (isset($_POST['lunch'])) {
             if (isset($_POST['lunch']['ans'])) {
                 foreach ($_POST['lunch']['ans'] as $ans) {
                     $model = Lunch::model()->findByPk(intval($ans['pro']));
                     $model->ans = $ans['comment'];
                     $model->menu_name = $ans['menuname'];
                     $model->price_per_head_f = $ans['price_per_head_pound'];
                     $model->whats_included = $ans['whats_included'];
                     if (isset($ans['like'])) {
                         $model->like = $ans['like'];
                     }
                     if (isset($ans['cus_comment'])) {
                         $model->comment = $ans['cus_comment'];
                     }
                     //                        p($model->attributes);
                     $model->save();
                 }
             }
         }
         if (isset($_POST['sundries'])) {
             //                $model = Sundries::model()->findByPk($sundries[0]->id);
             //                if ($model !== null) {
             //                    $model->ans = (isset($_POST['sundries']['ans']) ? $_POST['sundries']['ans'] : "");
             //                    $model->comment = (isset($_POST['sundries']['comment']) ? $_POST['sundries']['comment'] : "");
             //                    $model->save();
             //                }
             if (isset($_POST['sundries']['ans'])) {
                 foreach ($_POST['sundries']['ans'] as $ans) {
                     $model = Sundries::model()->findByPk(intval($ans['pro']));
                     $model->ans = $ans['comment'];
                     $model->menu_name = $ans['menuname'];
                     $model->price_per_head_f = $ans['price_per_head_pound'];
                     $model->whats_included = $ans['whats_included'];
                     if (isset($ans['like'])) {
                         $model->like = $ans['like'];
                     }
                     if (isset($ans['cus_comment'])) {
                         $model->comment = $ans['cus_comment'];
                     }
                     $model->save();
                 }
             }
         }
         if (isset($_POST['selproduct']['ans'])) {
             foreach ($_POST['selproduct']['ans'] as $ans) {
                 $selProd = SelProducts::model()->findByPk($ans['pro']);
                 if ($selProd) {
                     $selProd->menu_name = $ans['menuname'];
                     $selProd->price_per_head_f = $ans['price_per_head_pound'];
                     $selProd->ans = $ans['comment'];
                     $selProd->whats_included = $ans['whats_included'];
                     $selProd->save();
                 }
             }
         }
         if (isset($_POST['selprod'])) {
             foreach ($_POST['selprod'] as $comment) {
                 $selProd = SelProducts::model()->findByPk(intval($comment['id']));
                 $selProd->comment = $comment['comment'];
                 $selProd->like = $comment['like'];
                 $selProd->save();
             }
         }
         echo json_encode(array('success' => '1'));
         exit;
     }
     $lunch_note = "";
     $breakfast_note = "";
     $sandwiches_note = "";
     $hotfood_note = "";
     $indusfood_note = "";
     $sundries_note = "";
     //        e($notes);
     foreach ($notes as $value => $kval) {
         //            print_r($kval);
         if ($kval['form'] == 'lunch') {
             $lunch_note = $kval['text'];
         }
         if ($kval['form'] == 'breakfast') {
             $breakfast_note = $kval['text'];
         }
         if ($kval['form'] == 'sandwiches') {
             $sandwiches_note = $kval['text'];
         }
         if ($kval['form'] == 'hotfood') {
             $hotfood_note = $kval['text'];
         }
         if ($kval['form'] == 'indusfood') {
             $indusfood_note = $kval['text'];
         }
         if ($kval['form'] == "sundries") {
             $sundries_note = $kval['text'];
         }
         if ($kval['form'] == 'magicspoon') {
             $mspoon_note = $kval['text'];
         }
     }
     $this->render('adminsolns_pdf', array('customer' => $cust, 'magic_spools' => $magicSpools, 'magicSpoolsAns' => $magicSpoolsAns, 'notes' => $notes, 'workingWells' => $workingWells, 'sundries' => $sundries, 'lunches' => $lunches, 'indusFoods' => $indusFoods, 'breakfasts' => $breakfasts, 'sandwiches' => $sandwiches, 'hotFoods' => $hotFoods, 'sundries_note' => $sundries_note, 'lunch_note' => $lunch_note, 'indusfood_note' => $indusfood_note, 'breakfast_note' => $breakfast_note, 'sandwiches_note' => $sandwiches_note, 'hotfood_note' => $hotfood_note, 'selproducts' => $selproducts, 'selproductsComment' => $selProd));
 }
Пример #4
0
 public function actionAdminSolns()
 {
     $cust = Customer::model()->findAll(array('condition' => 'id=:id ', 'params' => array(':id' => getCurCusId())));
     foreach ($cust as $k => $val) {
         $magicSpools = $val->magicSpools;
         $notes = $val->notes;
         $workingWells = $val->workingWells;
         $hotFoods = $val->hotFoods;
         $lunches = $val->lunches;
         $breakfasts = $val->breakfasts;
         $sundries = $val->sundries;
         $indusFoods = $val->indusFoods;
         $sandwiches = $val->sandwiches;
     }
     if (isset($_POST['ajax']) && $_POST['ajax'] == 1) {
         if (count($magicSpools)) {
             //getCurCusId()
             $mspoon = MagicSpoolAns::model()->findByAttributes(array('cus_id' => getCurCusId()));
             if ($mspoon === NULL) {
                 $mspoon = new MagicSpoolAns();
                 $mspoon->cus_id = getCurCusId();
             }
             $mspoon->one = isset($_POST['one']) ? $_POST['one'] : "";
             $mspoon->two = isset($_POST['two']) ? $_POST['two'] : "";
             $mspoon->three = isset($_POST['three']) ? $_POST['three'] : "";
             $mspoon->four = isset($_POST['four']) ? $_POST['four'] : "";
             $mspoon->five = isset($_POST['five']) ? $_POST['five'] : "";
             $mspoon->one_comment = isset($_POST['magicspools']['one']['comment']) ? $_POST['magicspools']['one']['comment'] : "";
             $mspoon->two_comment = isset($_POST['magicspools']['two']['comment']) ? $_POST['magicspools']['two']['comment'] : "";
             $mspoon->three_comment = isset($_POST['magicspools']['three']['comment']) ? $_POST['magicspools']['three']['comment'] : "";
             $mspoon->four_comment = isset($_POST['magicspools']['four']['comment']) ? $_POST['magicspools']['four']['comment'] : "";
             $mspoon->five_comment = isset($_POST['magicspools']['five']['comment']) ? $_POST['magicspools']['five']['comment'] : "";
             $mspoon->one_like = isset($_POST['magicspools']['one']['like']) ? intval($_POST['magicspools']['one']['like']) : "0";
             $mspoon->two_like = isset($_POST['magicspools']['two']['like']) ? intval($_POST['magicspools']['two']['like']) : "0";
             $mspoon->three_like = isset($_POST['magicspools']['three']['like']) ? intval($_POST['magicspools']['three']['like']) : "0";
             $mspoon->four_like = isset($_POST['magicspools']['four']['like']) ? intval($_POST['magicspools']['four']['like']) : "0";
             $mspoon->five_like = isset($_POST['magicspools']['five']['like']) ? intval($_POST['magicspools']['five']['like']) : "0";
             $mspoon->save();
         }
         //
         if (isset($_POST['hotFoods'])) {
             $cusApp = CustAppoint::model()->findByAttributes(array('app_id' => 2, 'cus_id' => getCurCusId()));
             $cusApp->status = 2;
             $cusApp->save();
             $model = HotFood::model()->findByPk($hotFoods[0]->id);
             if ($model !== null) {
                 $model->ans = isset($_POST['hotFoods']['ans']) ? $_POST['hotFoods']['ans'] : "";
                 $model->comment = isset($_POST['hotFoods']['comment']) ? $_POST['hotFoods']['comment'] : "";
                 $model->save();
             }
         }
         if (isset($_POST['sandwiches'])) {
             $model = Sandwiches::model()->findByPk($sandwiches[0]->id);
             if ($model !== null) {
                 $model->ans = isset($_POST['sandwiches']['ans']) ? $_POST['sandwiches']['ans'] : "";
                 $model->comment = isset($_POST['sandwiches']['comment']) ? $_POST['sandwiches']['comment'] : "";
                 $model->save();
             }
         }
         if (isset($_POST['breakfast'])) {
             $model = Breakfast::model()->findByPk($breakfast[0]->id);
             if ($model !== null) {
                 $model->ans = isset($_POST['breakfast']['ans']) ? $_POST['breakfast']['ans'] : "";
                 $model->comment = isset($_POST['breakfast']['comment']) ? $_POST['breakfast']['comment'] : "";
                 $model->save();
             }
         }
         if (isset($_POST['indusFoods'])) {
             $model = IndusFood::model()->findByPk($indusFoods[0]->id);
             if ($model !== null) {
                 $model->ans = isset($_POST['indusFoods']['ans']) ? $_POST['indusFoods']['ans'] : "";
                 $model->comment = isset($_POST['indusFoods']['comment']) ? $_POST['indusFoods']['comment'] : "";
                 $model->save();
             }
         }
         if (isset($_POST['lunch'])) {
             $model = Lunch::model()->findByPk($lunches[0]->id);
             if ($model !== null) {
                 $model->ans = isset($_POST['lunch']['ans']) ? $_POST['lunch']['ans'] : "";
                 $model->comment = isset($_POST['lunch']['comment']) ? $_POST['lunch']['comment'] : "";
                 $model->save();
             }
         }
         if (isset($_POST['sundries'])) {
             $model = Sundries::model()->findByPk($sundries[0]->id);
             if ($model !== null) {
                 $model->ans = isset($_POST['sundries']['ans']) ? $_POST['sundries']['ans'] : "";
                 $model->comment = isset($_POST['sundries']['comment']) ? $_POST['sundries']['comment'] : "";
                 $model->save();
             }
         }
         echo json_encode(array('success' => '1'));
         exit;
     }
     $lunch_note = "";
     $breakfast_note = "";
     $sandwiches_note = "";
     $hotfood_note = "";
     $indusfood_note = "";
     $sundries_note = "";
     foreach ($notes as $value => $kval) {
         //            print_r($kval);
         if ($kval['form'] == 'lunch') {
             $lunch_note = $kval['text'];
         }
         if ($kval['form'] == 'breakfast') {
             $breakfast_note = $kval['text'];
         }
         if ($kval['form'] == 'sandwiches') {
             $sandwiches_note = $kval['text'];
         }
         if ($kval['form'] == 'hotfood') {
             $hotfood_note = $kval['text'];
         }
         if ($kval['form'] == 'indusfood') {
             $indusfood_note = $kval['text'];
         }
         if ($kval['form'] == "sundries") {
             $sundries_note = $kval['text'];
         }
         if ($kval['form'] == 'magicspoon') {
             $mspoon_note = $kval['text'];
         }
     }
     $this->render('adminsolns', array('customer' => $cust, 'magic_spools' => $magicSpools, 'notes' => $notes, 'workingWells' => $workingWells, 'sundries' => $sundries, 'lunches' => $lunches, 'indusFoods' => $indusFoods, 'breakfasts' => $breakfasts, 'sandwiches' => $sandwiches, 'hotFoods' => $hotFoods, 'sundries_note' => $sundries_note, 'lunch_note' => $lunch_note, 'indusfood_note' => $indusfood_note, 'breakfast_note' => $breakfast_note, 'sandwiches_note' => $sandwiches_note, 'hotfood_note' => $hotfood_note));
 }
 public function actionCustomerReply()
 {
     $this->layout = '//layouts/maindate';
     if (isset($_POST['customer']) && isset($_POST['customer']['ajax'])) {
         $customer_questions = $this->loadModel(getCurCusId());
         $customer_questions->provisional_date = isset($_POST['customer']['provisional_date']) ? $_POST['customer']['provisional_date'] : "";
         $customer_questions->call_date = isset($_POST['customer']['call_date']) ? $_POST['customer']['call_date'] : "";
         //                    mErrors($customer_questions);
         $customer_questions->save();
         echo json_encode(array('success' => 1));
         exit;
     }
     DynamicCall::GetEdit1stPdf(getCurCusId());
     $id = $_GET['id'];
     $customer = Customer::model()->findByPk($id);
     //        $magic_spoon = MagicSpool::model()->findByAttributes(array('cus_id' => getCurCusId()));
     //        $magic_spoon = MagicSpool::model()->find()->findByAttributes(array('cus_id' => getCurCusId()));
     $magic_spoon = MagicSpool::model()->findAll(array('select' => 'one,two,three,four,five', 'condition' => 'cus_id=:cus_id', 'limit' => 1, 'params' => array(':cus_id' => $id)));
     $lunch_count = Lunch::model()->findAll(array('condition' => 'cus_id=:cus_id', 'params' => array(':cus_id' => $id)));
     $break_count = Breakfast::model()->findAll(array('condition' => 'cus_id=:cus_id', 'params' => array(':cus_id' => $id)));
     $hotf_count = HotFood::model()->findAll(array('condition' => 'cus_id=:cus_id', 'params' => array(':cus_id' => $id)));
     $sandw_count = Sandwiches::model()->findAll(array('condition' => 'cus_id=:cus_id', 'params' => array(':cus_id' => $id)));
     $sundr_count = Sundries::model()->findAll(array('condition' => 'cus_id=:cus_id', 'params' => array(':cus_id' => $id)));
     $IndusFood_count = IndusFood::model()->findAll(array('condition' => 'cus_id=:cus_id', 'params' => array(':cus_id' => $id)));
     $Christmas_count = Christmas::model()->findAll(array('condition' => 'cus_id=:cus_id', 'params' => array(':cus_id' => $id)));
     $customer = Customer::model()->findByPk($id);
     $selProdt = array();
     if (count(Yii::app()->session['sel_prod'])) {
         $criteria = new CDbCriteria();
         $criteria->select = 't.name,t.desc';
         $criteria->addInCondition('id', Yii::app()->session['sel_prod']);
         $selProdt = Product::model()->findAll($criteria);
     }
     $this->render('customerreply', array('magic_spoon' => $magic_spoon, 'lunch_count' => $lunch_count, 'break_count' => $break_count, 'hotf_count' => $hotf_count, 'sandw_count' => $sandw_count, 'sundr_count' => $sundr_count, 'indusFood_count' => $IndusFood_count, 'christmas_count' => $Christmas_count, 'selProdt' => $selProdt, 'customer' => $customer));
 }