コード例 #1
0
 /**
  * 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));
 }
コード例 #2
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate($id)
 {
     $curUser = Customer::model()->findByPk($id);
     $this->customerData = $curUser;
     if (empty($curUser->id)) {
         throw new CHttpException(403, 'Customer Does\'t exists');
     }
     // saving current customer to session
     Yii::app()->session['last_created_user'] = $curUser->attributes;
     //$curUser->selectedCategories;
     $model = WorkingWell::model()->findByAttributes(array('cus_id' => $id));
     $working_model = new WorkingWellOptions();
     if (!$model) {
         $model = new WorkingWell();
         $working_model = new WorkingWellOptions();
     }
     if (isset($_GET['editpdf'])) {
         setCurCus($id);
         DynamicCall::SetEdit1stPdf(getCurCusId());
         DynamicCall::loadProducts(getCurCusId());
         //            DynamicCall::loadMenu(getCurCusId());
         $cusApp = CustAppoint::model()->findByAttributes(array('cus_id' => getCurCusId(), 'app_id' => 2));
         if ($cusApp) {
             $cusApp->status = 1;
             $cusApp->save();
         }
     }
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['WorkingWell'])) {
         $model->attributes = $_POST['WorkingWell'];
         $model->one = $_POST['WorkingWell']['one'];
         $model->two = $_POST['WorkingWell']['two'];
         $model->three = $_POST['WorkingWell']['three'];
         $model->four = $_POST['WorkingWell']['four'];
         if (Yii::app()->user->isUser()) {
             $model->cus_id = $id;
         }
         if ($model->save()) {
             //                if (Yii::app()->user->isUser()):
             $this->redirect(createUrl('MagicSpool/create', array('id' => $id)));
             //                endif;
             //                $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model, 'working_model' => $working_model));
 }
コード例 #3
0
 public function actionfranchises()
 {
     $url = 'http://mccreative.jaspersonline.co.uk/api/products/getFranchises';
     DynamicCall::syncFranchise($url);
 }
コード例 #4
0
 public function actionTest()
 {
     //        $franchises = DynamicCall::getBmsFranchise('http://orders.jaspersonline.co.uk/info/branchlist.php');
     //        $total = 0;
     //        $total_updates = 0;
     //        $total_not_updates = 0;
     //        $errors = array();
     //        $customers = array();
     //        foreach ($franchises as $franchise) {
     //            if (!$franchise instanceof Franchise)
     //                continue;
     //            foreach ($franchise->customers as $customer):
     ////                $result = DynamicCall::getBmsCustomer('chester', 90, 'http://dev.jaspersonline.co.uk/soap/jaspers.wsdl');
     //                $result = DynamicCall::getBmsCustomer(strtolower($franchise->name), $customer->id, 'http://dev.jaspersonline.co.uk/soap/jaspers.wsdl');
     //                if ($result) {
     //                    $date1 = getFmtDate($customer->update_time, 'Y-m-d H:i:s', 0, 20);
     //                    $date2 = getFmtDate($result['update_time'], 'Y-m-d H:i:s', 0, 20);
     //                    if (($date1 > $date2) || !($customer->update_time)) {
     //                        $errors[] = CActiveForm::validate($customer);
     ////                        $customer->attributes = $result;
     //                        $customers[] = $customer->attributes;
     //                        ++$total_updates;
     //                    } else {
     //                        ++$total_not_updates;
     //                    }
     //                    ++$total;
     //                }
     //            endforeach;
     //        }
     //        e($customers, 0);
     //        echo "total records Traversed = " . $total . "<br>";
     //        echo "total records Updated = " . $total_updates . "<br>";
     //        echo "total records Not Updated = " . $total_not_updates . "<br>";
     ////        echo print_r($errors);
     $franchises = DynamicCall::getBmsFranchise('http://orders.jaspersonline.co.uk/info/branchlist.php');
     $total = 0;
     $total_updates = 0;
     $total_not_updates = 0;
     $errors = array();
     foreach ($franchises as $franchise) {
         if (!$franchise instanceof Franchise) {
             continue;
         }
         foreach ($franchise->customers as $customer) {
             //                $result = DynamicCall::getBmsCustomer('chester', 90, 'http://dev.jaspersonline.co.uk/soap/jaspers.wsdl');
             //                $result = DynamicCall::getBmsCustomer(strtolower($franchise->name), $customer->id, 'http://dev.jaspersonline.co.uk/soap/jaspers.wsdl');
             $result = DynamicCall::getBmsCustomer('chester', $customer->id, 'http://dev.jaspersonline.co.uk/soap/jaspers.wsdl');
             if ($result) {
                 $date1 = getFmtDate($customer->update_time, 'Y-m-d H:i:s', 0, 20);
                 $date2 = getFmtDate($result['update_time'], 'Y-m-d H:i:s', 0, 20);
                 //                    if (($date1 > $date2) || !($customer->update_time)) {  // remove htis
                 echo "customer <br>";
                 e($customer->attributes, 0);
                 echo "geting data <br>";
                 e($result, 0);
                 echo "sync data <br>";
                 $customer->attributes = $result;
                 //                        e($result,0);
                 e($customer->attributes);
                 //                        $customer->save();
                 $errors[] = CActiveForm::validate($customer);
                 //                        e($errors);
                 ++$total_updates;
                 //                    } else {      // uncomment else part
                 //                        ++$total_not_updates;
                 //                    }
                 ++$total;
             }
         }
     }
     echo "total records Traversed = " . $total . "<br>";
     echo "total records Updated = " . $total_updates . "<br>";
     echo "total records Not Updated = " . $total_not_updates . "<br>";
     echo print_r($errors);
 }
コード例 #5
0
 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));
 }
コード例 #6
0
<br/>
<br/>
<?php 
$data = DynamicCall::getFranchiseDetail();
//e($data);
?>
<div class="col-lg-12">
    <div class="col-lg-6">
        <div class="table-responsive">
            <table class="table table-condensed pull-left table-bordered table-hover table-striped">
                <caption>Franchise Current Status</caption>
                <tr>
                    <td>Accounts Seen</td>
                    <td><?php 
echo $data['accountsSeen'];
?>
</td>
                </tr>
                <tr>
                    <td>Total Weekly Value</td>
                    <td><?php 
echo $data['totalWeeklyValue'];
?>
</td>
                </tr>
                <tr>
                    <td>Total Ordered Once</td>
                    <td><?php 
echo $data['totalOrderedOnce'];
?>
</td>
コード例 #7
0
 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));
 }
コード例 #8
0
 public static function syncProd($cat_id, $pid)
 {
     if (!$cat_id) {
         return false;
     }
     if (!$pid) {
         $url = 'http://mccreative.jaspersonline.co.uk/api/products/getCatPro/' . $cat_id;
     } else {
         $url = 'http://mccreative.jaspersonline.co.uk/api/products/getModrenCatPro/' . $cat_id;
     }
     $products = DynamicCall::getData($url);
     if (!$products->count) {
         return false;
     }
     foreach ($products->data as $product) {
         $pro = Product::model()->findByPk($product->id);
         if (!$pro) {
             $pro = new Product();
             $pro->id = $product->id;
         }
         $pro->name = $product->name;
         $pro->desc = $product->description;
         $pro->cat_id = $product->jcid;
         $pro->per100g = $product->per100g;
         $pro->allergies = $product->allergies;
         $pro->ingredients = $product->ingridients;
         $pro->pic = "http://bmsdev.jaspersonline.co.uk/store/products/order_images/{$pro->id}.jpg";
         $pro->save();
         mErrors($pro, 0);
     }
 }
コード例 #9
0
 public static function getCustomerWeekSpend($id)
 {
     $customerData = DynamicCall::getFranchiseName($id);
     $result = DynamicCall::getBmsCustomer(strtolower($customerData['franchise_name']), $customerData['customer_id'], 'http://dev.jaspersonline.co.uk/soap/jaspers.wsdl');
     //        $result = DynamicCall::getBmsCustomer('chester', 90, 'http://dev.jaspersonline.co.uk/soap/jaspers.wsdl');
     if (isset($result['wkspend'])) {
         echo $result['wkspend'];
     } else {
         echo 0;
     }
 }
コード例 #10
0
 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));
 }