/**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate($id)
 {
     $this->customerData = Customer::model()->findByPk($id);
     $model = MagicSpool::model()->findByAttributes(array('cus_id' => getCurCusId()));
     $magic_model = new MagicSpoonOptions();
     if (!$model) {
         $model = new MagicSpool();
         $magic_model = new MagicSpoonOptions();
     }
     DynamicCall::GetEdit1stPdf(getCurCusId());
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['MagicSpool'])) {
         $model->attributes = $_POST['MagicSpool'];
         $model->one = $_POST['MagicSpool']['one'];
         $model->two = $_POST['MagicSpool']['two'];
         $model->three = $_POST['MagicSpool']['three'];
         $model->four = $_POST['MagicSpool']['four'];
         if (Yii::app()->user->isUser()) {
             $model->cus_id = $id;
         }
         if ($model->save()) {
             //                if (Yii::app()->user->isUser()):
             $this->redirect(createUrl('site/menu', array('id' => $id)));
             //                endif;
             //                $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model, 'magic_model' => $magic_model));
 }
 public function actionSuggestion()
 {
     $criteria = new CDbCriteria();
     $criteria->select = array('t.id,t.name');
     $pro_type = ProductType::model()->findAll($criteria);
     $products = array();
     DynamicCall::GetEdit1stPdf(getCurCusId());
     if (isset($_GET['id'])) {
         $typeid = $_GET['id'];
         if (isset($_POST['sel_pro'])) {
             $customer = Customer::model()->findByPk(getCurCusId());
             $customer->sel_products = $_POST['sel_pro'];
             if ($customer->save()) {
                 $this->redirect(array('customer/customerreply'));
             }
         }
         $pro = Product::model()->findAll(array('condition' => "type_id =" . $typeid));
         $products[] = $pro;
         $pro_desc = array();
         $i = 1;
         foreach ($pro as $p) {
             $product = array('name' => $p->name, 'desc' => $p->desc);
             $pro_desc[$i] = $product;
             $i++;
         }
     }
     $products = isset($products[0]) ? $products[0] : array();
     //        e($products);
     $this->render('suggestion', array('products' => $products, 'types' => $pro_type, 'pro_desc' => $pro_desc));
 }
 public function actionCustomerQuest()
 {
     DynamicCall::GetEdit1stPdf(getCurCusId());
     $customer_questions = $this->loadModel(getCurCusId());
     if (isset($_POST['customer']) && isset($_POST['customer']['ajax'])) {
         $customer_questions['earliest_timedelivery'] = isset($_POST['customer']['earliest_timedelivery']) ? $_POST['customer']['earliest_timedelivery'] : "";
         $customer_questions['more_companies'] = isset($_POST['customer']['more_companies']) ? $_POST['customer']['more_companies'] : "";
         $customer_questions['no_people'] = isset($_POST['customer']['no_people']) ? $_POST['customer']['no_people'] : "";
         $customer_questions['present_carters'] = isset($_POST['customer']['present_carters']) ? $_POST['customer']['present_carters'] : "";
         $customer_questions['company_order'] = isset($_POST['customer']['company_order']) ? $_POST['customer']['company_order'] : "";
         $customer_questions['avg_attend'] = isset($_POST['customer']['avg_attend']) ? $_POST['customer']['avg_attend'] : "";
         $customer_questions['email'] = isset($_POST['customer']['email']) ? $_POST['customer']['email'] : "";
         $customer_questions['linked_in'] = isset($_POST['customer']['linked_in']) ? $_POST['customer']['linked_in'] : "";
         $customer_questions['competitor_id'] = isset($_POST['customer']['competitor_id']) ? $_POST['customer']['competitor_id'] : "";
         if ($customer_questions->save()) {
             $currentCustomerId = getCurCusId();
             if (!Yii::app()->session['edit_1st_pdf']) {
                 $cusApp = CustAppoint::model()->findByAttributes(array('cus_id' => getCurCusId(), 'app_id' => 1));
                 $cusApp->status = 1;
                 $time = time();
                 $cusApp->update_time = date("Y-m-d h:i:s", $time);
                 if ($cusApp->save()) {
                     $cusApp = new CustAppoint();
                     $cusApp->app_id = 2;
                     $cusApp->cus_id = getCurCusId();
                     $cusApp->status = 1;
                     $cusApp->save();
                 }
             }
             unset(Yii::app()->session['sel_prod']);
             $this->UpdateRemote($currentCustomerId);
             //exit;
         }
         echo json_encode(array('success' => 'true'));
         exit;
     }
     $time_range = range(7.3, 19.55, 0.05);
     $dd_time_range = array();
     foreach ($time_range as $range) {
         $decimalPart = (int) substr($range, strrpos($range, '.') + 1);
         if ($decimalPart <= 60) {
             $time = number_format((double) $range, 2, ':', '');
             $dd_time_range[$time] = $time;
         }
     }
     $peopleOnSite = array("0-5" => '0-5', "6-10" => '6-10', "11-20" => '11-20', "21-40" => '21-40', "41-100" => '41-100', "101-150" => '101-150', "151-200" => '151-200', "201-250" => '201-250', "251-300" => '251-300', "300+" => '300+');
     $competitor = JaspersCompetitor::model()->findAll(array("condition" => "competitor_oid = " . getCurCusDet('jaspers_franchise')));
     $email = getCurCusDet('email');
     $this->render('customer_quest', array('customer' => $customer_questions, 'time_range' => $dd_time_range, 'peopleOnSite' => $peopleOnSite, 'competitor' => $competitor, 'email' => $email));
 }
 public function actionCustomerQuest()
 {
     DynamicCall::GetEdit1stPdf(getCurCusId());
     $customer_questions = $this->loadModel(getCurCusId());
     if (isset($_POST['customer']) && isset($_POST['customer']['ajax'])) {
         $customer_questions['earliest_timedelivery'] = isset($_POST['customer']['earliest_timedelivery']) ? $_POST['customer']['earliest_timedelivery'] : "";
         $customer_questions['more_companies'] = isset($_POST['customer']['more_companies']) ? $_POST['customer']['more_companies'] : "";
         $customer_questions['no_people'] = isset($_POST['customer']['no_people']) ? $_POST['customer']['no_people'] : "";
         $customer_questions['present_carters'] = isset($_POST['customer']['present_carters']) ? $_POST['customer']['present_carters'] : "";
         $customer_questions['company_order'] = isset($_POST['customer']['company_order']) ? $_POST['customer']['company_order'] : "";
         $customer_questions['avg_attend'] = isset($_POST['customer']['avg_attend']) ? $_POST['customer']['avg_attend'] : "";
         $customer_questions['email'] = isset($_POST['customer']['email']) ? $_POST['customer']['email'] : "";
         $customer_questions['linked_in'] = isset($_POST['customer']['linked_in']) ? $_POST['customer']['linked_in'] : "";
         //            p($_REQUEST);
         //            p($customer_questions->attributes);
         if ($customer_questions->save()) {
             if (!Yii::app()->session['edit_1st_pdf']) {
                 $cusApp = CustAppoint::model()->findByAttributes(array('cus_id' => getCurCusId(), 'app_id' => 1));
                 $cusApp->status = 1;
                 $time = time();
                 $cusApp->update_time = date("Y-m-d h:i:s", $time);
                 if ($cusApp->save()) {
                     $cusApp = new CustAppoint();
                     $cusApp->app_id = 2;
                     $cusApp->cus_id = getCurCusId();
                     $cusApp->status = 1;
                     $cusApp->save();
                 }
             }
             unset(Yii::app()->session['sel_prod']);
         }
         echo json_encode(array('success' => 'true'));
         exit;
     }
     $this->render('customer_quest', array('customer' => $customer_questions));
 }