protected function HTMLtoLunchArray($html)
 {
     $doc = new DOMDocument();
     @$doc->loadHTML($html);
     $xpath = new DOMXpath($doc);
     $dElements = array(0 => array(1), 1 => array(2), 2 => array(3), 3 => array(4), 4 => array(5));
     $arr = array();
     foreach ($dElements as $dId => $dArr) {
         $dayMenu = '';
         foreach ($dArr as $dRow) {
             $element = $xpath->query('/html/body/div[2]/div[2]/article/div/div/p[' . $dRow . ']');
             foreach ($element as $e) {
                 $dayMenuExploded = explode(PHP_EOL, $e->nodeValue);
                 $foodArray = array();
                 foreach ($dayMenuExploded as $foods) {
                     $foods = parent::cleanStr($foods);
                     if (!empty($foods)) {
                         $foodArray[] = preg_replace('/([\\t0-9, ]+$)/', '', $foods);
                     }
                 }
                 $dayMenu = implode(' / ', $foodArray);
             }
         }
         $weekDay = parent::weekNumToText($dId);
         $arr[$weekDay] = parent::fixSpaces(preg_replace('/[0-9, ]+$/', '', $dayMenu));
     }
     if (!empty($arr)) {
         return $arr;
     }
     return false;
 }
Beispiel #2
0
 /**
  * @param string $html HTML document
  * @return boolean|array
  */
 public function HTMLtoLunchArray($html)
 {
     $doc = new DOMDocument();
     @$doc->loadHTML($html);
     $xpath = new DOMXpath($doc);
     $dElements = array(0 => array(2, 3, 4));
     $arr = array();
     foreach ($dElements as $dId => $dArr) {
         $dayMenu = array();
         foreach ($dArr as $dRow) {
             $element = $xpath->query('/html/body/div[2]/div/div/div/div/div[' . $dRow . ']/div[1]');
             foreach ($element as $e) {
                 $dish = ucfirst(strtolower(parent::cleanStr(utf8_decode(parent::fixSpaces(trim($e->nodeValue))))));
                 $dish = preg_replace('/\\([a-z, ]+\\)/e', 'strtoupper("$0")', $dish);
                 $dayMenu[] = $dish;
             }
         }
         $weekDay = parent::today();
         $arr[$weekDay] = implode(' / ', $dayMenu);
     }
     if (!empty($arr)) {
         return $arr;
     }
     return false;
 }
Beispiel #3
0
 /**
  * @param string $html HTML document
  * @return boolean|array
  */
 public function HTMLtoLunchArray($html)
 {
     $doc = new DOMDocument();
     @$doc->loadHTML($html);
     $xpath = new DOMXpath($doc);
     $elements = $xpath->query('//html/body/div/div/div/article/section/div/p');
     $arr = array();
     $i = 1;
     if (!is_null($elements)) {
         foreach ($elements as $element) {
             $nodes = $element->childNodes;
             foreach ($nodes as $node) {
                 $dish = parent::fixSpaces(trim(utf8_decode($node->nodeValue)));
                 if (!empty($dish)) {
                     $arr[$i][] = parent::fixSpaces(trim($node->nodeValue));
                 }
             }
             $i++;
         }
     }
     foreach ($arr as $dayNo => $dayDishArr) {
         $weekDay = parent::weekNumToText($dayNo + 1);
         $dishes[$weekDay] = implode(' / ', $dayDishArr);
     }
     if (!empty($dishes)) {
         return $dishes;
     }
     return false;
 }
Beispiel #4
0
 /**
  * @param string $html HTML document
  * @return boolean|array
  */
 public function HTMLtoLunchArray($html)
 {
     $doc = new DOMDocument();
     @$doc->loadHTML($html);
     $xpath = new DOMXpath($doc);
     $elements = $xpath->query('//*[@id="o-learys-forum-helsinki"]');
     $i = 0;
     $arr = array();
     foreach ($elements as $element) {
         $nodes = $element->childNodes;
         foreach ($nodes as $node) {
             $htmlString = $doc->saveHTML($node);
             if (preg_match('/<strong>O\'Learys Forum Helsinki<\\/strong>/', $htmlString)) {
                 preg_match_all("/<strong>([a-zA-Z]+) [0-9\\. ]+<\\/strong> <p>([a-zA-Z0-9\\’\\'\\,\\.\\-\\_\\)\\(äöÄÖ ]+)10€/", $htmlString, $res);
                 if (isset($res[2])) {
                     foreach ($res[2] as $result) {
                         $weekDay = parent::weekNumToText($i);
                         $arr[$weekDay] = $result;
                         $i++;
                     }
                 }
             }
         }
     }
     if (empty($arr)) {
         return false;
     }
     return $arr;
 }
Beispiel #5
0
 /**
  * @param string $html HTML document
  * @return boolean|array
  */
 public function HTMLtoLunchArray($html)
 {
     $doc = new DOMDocument();
     @$doc->loadHTML($html);
     $xpath = new DOMXpath($doc);
     $dElements = array(0 => array(2, 3, 4), 1 => array(8, 9, 10), 2 => array(14, 15, 16), 3 => array(20, 21, 22), 4 => array(26, 27, 28));
     $arr = array();
     $i = 0;
     foreach ($dElements as $dId => $dArr) {
         $dayMenu = array();
         foreach ($dArr as $dRow) {
             $element = $xpath->query('//*[@id="lounaslistaTable"]/tr[' . $dRow . ']/td[1]');
             foreach ($element as $e) {
                 $dayMenu[] = trim($e->nodeValue);
             }
         }
         $weekDay = parent::weekNumToText($i);
         $arr[$weekDay] = parent::fixSpaces(trim(implode(' / ', $dayMenu)));
         $i++;
     }
     if (!empty($arr)) {
         return $arr;
     }
     return false;
 }
Beispiel #6
0
 protected function HTMLtoLunchArray($html)
 {
     $doc = new DOMDocument();
     @$doc->loadHTML($html);
     $xpath = new DOMXpath($doc);
     $element = $xpath->query('//*[@id="menu"]/div[*]');
     $arr = array();
     $i = 0;
     $lunchListInHTML = $doc->saveHTML($element->item(0));
     $lunchListInArray = explode('<hr class="mini">', $lunchListInHTML);
     foreach ($lunchListInArray as $lunchPerDay) {
         $foods = preg_replace('/^[a-zA-Z]{2} [0-9]{1,2}\\.[0-9]{1,2}\\./', '', trim(strip_tags($lunchPerDay)));
         $foodsArray = explode(PHP_EOL, $foods);
         $dayMenu = array();
         foreach ($foodsArray as $food) {
             $dayMenu[] = preg_replace('/ ([a-zA-Z,]+)$/', ' (${1})', parent::cleanStr($food));
         }
         $weekDay = parent::weekNumToText($i);
         $arr[$weekDay] = parent::fixSpaces(implode(' / ', $dayMenu));
         $i++;
     }
     if (!empty($arr)) {
         return $arr;
     }
     return false;
 }
Beispiel #7
0
 /**
  * @param string $html HTML document
  * @return boolean|array
  */
 public function HTMLtoLunchArray($html)
 {
     $xml = simplexml_load_string($html);
     foreach ($xml->channel as $channel) {
         foreach ($channel->item as $item) {
             $data = $item->description;
             $doc = new DOMDocument();
             @$doc->loadHTML($data);
             $xpath = new DOMXpath($doc);
             $elements = $xpath->query('//p');
             $foodArrs = array();
             $i = -1;
             if (!is_null($elements)) {
                 foreach ($elements as $element) {
                     $nodes = $element->childNodes;
                     foreach ($nodes as $node) {
                         if (preg_match('/Maanantai|Tiistai|Keskiviikko|Torstai|Perjantai/i', $node->nodeValue)) {
                             $i++;
                         } elseif (preg_match('/tervetuloa|P.*iv.*n j.*lkiruoka|pienet muutokset/i', $node->nodeValue)) {
                             continue;
                         } else {
                             if ($i > -1 && strlen($node->nodeValue) > 3) {
                                 $weekDay = parent::weekNumToText($i);
                                 $foodArrs[$weekDay][] = utf8_decode(trim($node->nodeValue));
                             }
                         }
                     }
                 }
             }
             $arr = array();
             foreach ($foodArrs as $weekDay => $foodArr) {
                 $arr[$weekDay] = parent::cleanStr(str_replace('*, ', '', parent::fixSpaces(implode(' / ', $foodArr))));
             }
             continue 2;
         }
     }
     if (!empty($arr)) {
         return $arr;
     }
     return false;
 }
Beispiel #8
0
 protected function HTMLtoLunchArray($html)
 {
     $doc = new DOMDocument();
     @$doc->loadHTML($html);
     $xpath = new DOMXpath($doc);
     $elements = $xpath->query('//*[@id="ctl00_ContentPlaceHolder1_TemplateArea_TC30900_CellContent"]/div/div[2]/div[2]/div/div/span[*]/span[2]/span[2]');
     $arr = array();
     $i = 0;
     if (!is_null($elements)) {
         foreach ($elements as $element) {
             $nodes = $element->childNodes;
             foreach ($nodes as $node) {
                 $weekDay = parent::weekNumToText($i);
                 $arr[$weekDay] = parent::fixSpaces(trim(utf8_decode($node->nodeValue)));
                 $i++;
             }
         }
     }
     if (!empty($arr)) {
         return $arr;
     }
     return false;
 }
Beispiel #9
0
 protected function HTMLtoLunchArray($html)
 {
     $doc = new DOMDocument();
     @$doc->loadHTML($html);
     $xpath = new DOMXpath($doc);
     $dElements = array(0 => array(2, 3, 4));
     $arr = array();
     foreach ($dElements as $dId => $dArr) {
         $dayMenu = array();
         foreach ($dArr as $dRow) {
             $element = $xpath->query('/html/body/div[2]/div/div/div/div/div[' . $dRow . ']/div[1]');
             foreach ($element as $e) {
                 $dayMenu[] = trim($e->nodeValue);
             }
         }
         $weekDay = parent::today();
         $arr[$weekDay] = parent::fixSpaces(trim(utf8_decode(implode(' / ', $dayMenu))));
     }
     if (!empty($arr)) {
         return $arr;
     }
     return false;
 }
 /**
  * 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 Lunch the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Lunch::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));
 }
    ?>
)</h3>
                                </td>
                            </tr>

                            <?php 
    $count = 1;
    ?>
                            <?php 
    foreach ($lunches as $key => $val) {
        ?>
                                <tr>
                                    <td>
                                        <div class="ftext">
                                            <?php 
        $lunch = new Lunch();
        $lunchAttributes = $lunch->attributeLabels();
        echo "<h4>Lunch Menu -" . $count . " </h4>";
        foreach ($val as $vkey => $vval) {
            if (in_array($vkey, array('finger_food', 'dessert', 'drinks', 'price_per_head', 'per_veg', 'other_items', 'pre_perf_lunch', 'bread_type', 'notes')) && !empty($vval)) {
                echo ' <span style="color:#0069A4;">' . $lunchAttributes[$vkey] . '</span> : ' . $vval . " <br> ";
            }
        }
        $count++;
        ?>
                                            <!--</div>-->
                                        </div>
                                    </td>
                                    <td>
                                        <div class="finput">
                                            <?php 
 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 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));
 }
 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));
 }