Exemple #1
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     if (Customer::model()->count('active=1') == 0) {
         throw new CHttpException(412, 'No hay clientes activos. Para crear un contacto, primero debe ' . CHtml::link('crear un cliente', array('customer/create')) . '.');
     }
     $model = new Contact('scenarioCreate');
     if (isset($_GET['customer_id'])) {
         $model->customer_id = $_GET['customer_id'];
     }
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Contact'])) {
         $model->attributes = $_POST['Contact'];
         if ($model->save()) {
             if (!empty($_POST['yt1'])) {
                 Yii::app()->user->setFlash('contact-created', "¡El contacto <b><i>&quot;{$model->name}&quot;</i></b> fue creado exitosamente!");
                 if (isset($_GET['customer_id'])) {
                     $this->redirect(array('create', 'customer_id' => $model->customer_id));
                 } else {
                     $this->redirect(array('create'));
                 }
             } else {
                 if (isset($_GET['customer_id'])) {
                     $this->redirect(array('customer/view', 'id' => $model->customer_id));
                 } else {
                     $this->redirect(array('view', 'id' => $model->id));
                 }
             }
         }
     }
     $this->render('create', array('model' => $model));
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate($id)
 {
     if (!empty($id) && !Yii::app()->user->isGuest) {
         $customer_email = Yii::app()->user->name;
         $customerModel = Customer::model()->findByAttributes(array('customer_email' => $customer_email));
         $productId = $id;
         $productModel = Product::model()->findByPk($productId);
         $model = new Order();
         $model->order_product_id = $productModel->product_id;
         $model->order_customer_id = $customerModel->customer_id;
         $model->order_amount = $productModel->product_price + $productModel->product_shipping_price;
         if ($model->save()) {
             $attribuits = Order::model()->findByPk($model->order_id);
             $str = "Product Name:{$productModel->product_name}\r\n" . "Order Id:{$attribuits->order_id}\r\n" . "Order Product Id:{$attribuits->order_product_id}\r\n" . "Order Customer Id:{$attribuits->order_customer_id}\r\n" . "Total Amount With Shipping Charges:{$attribuits->order_amount}\r\n";
             $message = new YiiMailMessage();
             $message->subject = "Your order details";
             $message->setBody($str);
             $message->addTo(Yii::app()->user->name);
             $message->from = $customerModel->customer_email;
             Yii::app()->mail->send($message);
             $this->redirect(array('view', 'id' => $model->order_id));
         } else {
             echo "booking failed";
         }
     }
 }
 public function authenticate()
 {
     // Special case for admin account
     if ($this->username == 'ccplus1') {
         $model = Meta::model()->findByAttributes(array('field' => 'adminpass'));
         if ($this->password == $model->value) {
             $this->errorCode = self::ERROR_NONE;
         } else {
             $this->errorCode = self::ERROR_PASSWORD_INVALID;
         }
     } else {
         $user = Customer::model()->findByAttributes(array('billogin' => $this->username));
         if ($user === null) {
             $this->errorCode = self::ERROR_USERNAME_INVALID;
         } else {
             if ($user->bilpass !== $this->password) {
                 $this->errorCode = self::ERROR_PASSWORD_INVALID;
             } else {
                 $this->_id = $user->bilkey;
                 $this->errorCode = self::ERROR_NONE;
             }
         }
     }
     return !$this->errorCode;
 }
 public function check_db_password($attribute, $params)
 {
     $user = Customer::model()->findByPk($this->id);
     if ($user->password != $this->{$attribute}) {
         $this->addError($attribute, '原密码输入错误!');
     }
 }
 public function authenticate()
 {
     $record = Customer::model()->findByAttributes(array('email' => $this->username));
     if ($record === null) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } else {
         if (!$record->validatePassword($this->password)) {
             $this->errorCode = self::ERROR_PASSWORD_INVALID;
         } else {
             if ($record->is_active == 0) {
                 $this->_id = $record->id;
                 $this->errorCode = self::ERROR_USER_NOT_ACTIVE;
             } else {
                 $this->_id = $record->id;
                 $this->setState('id', $record->id);
                 $this->setState('name', $record->name);
                 $this->setState("email", $record->email);
                 $this->setState("isAdmin", 0);
                 $this->setState("signup_completed_step", $record->signup_completed_step);
                 $this->errorCode = self::ERROR_NONE;
             }
         }
     }
     return !$this->errorCode;
 }
Exemple #6
0
 public function run($id)
 {
     $customer_info = Customer::model()->findByPk($id);
     if ($customer_info->delete()) {
         $this->controller->success('');
     }
 }
 public function init()
 {
     parent::init();
     // Create new field in your users table for store dashboard preference
     // Set table name, user ID field name, user preference field name
     $this->setTableParams('dashboard_page', 'user_id', 'title');
     // set array of portlets
     $this->setPortlets(array(array('id' => 1, 'title' => 'Ultimos clientes', 'content' => Customer::model()->Top(4)), array('id' => 2, 'title' => 'Ultimas reservas', 'content' => Book::model()->Top(4)), array('id' => 3, 'title' => 'Puntos cr&iacute;ticos', 'content' => Point::model()->Top(4)), array('id' => 4, 'title' => 'Ultimos boletines', 'content' => Mail::model()->Top(4)), array('id' => 5, 'title' => 'Informes', 'content' => Functions::lastReports()), array('id' => 6, 'title' => 'Ultimas facturas', 'content' => Invoice::model()->Top(4))));
     //set content BEFORE dashboard
     $this->setContentBefore();
     // uncomment the following to apply jQuery UI theme
     // from protected/components/assets/themes folder
     $this->applyTheme('ui-lightness');
     // uncomment the following to change columns count
     //$this->setColumns(4);
     // uncomment the following to enable autosave
     $this->setAutosave(true);
     // uncomment the following to disable dashboard header
     $this->setShowHeaders(false);
     // uncomment the following to enable context menu and add needed items
     /*
     $this->menu = array(
         array('label' => 'Index', 'url' => array('index')),
     );
     */
 }
 /**
  * Send reminder emails to those who haven't paid for their next week's box
  */
 public function actionSendReminderEmails()
 {
     $Customers = Customer::model()->findAllWithNoOrders();
     foreach ($Customers as $Cust) {
         $validator = new CEmailValidator();
         if ($validator->validateValue(trim($Cust->User->email))) {
             $User = $Cust->User;
             $User->auto_login_key = $User->generatePassword(50, 4);
             $User->update_time = new CDbExpression('NOW()');
             $User->update();
             $adminEmail = SnapUtil::config('boxomatic/adminEmail');
             $adminEmailFromName = SnapUtil::config('boxomatic/adminEmailFromName');
             $message = new YiiMailMessage('Running out of orders');
             $message->view = 'customer_running_out_of_orders';
             $message->setBody(array('Customer' => $Cust, 'User' => $User), 'text/html');
             $message->addTo($Cust->User->email);
             $message->addBcc($adminEmail);
             //$message->addTo('*****@*****.**');
             $message->setFrom(array($adminEmail => $adminEmailFromName));
             if (!@Yii::app()->mail->send($message)) {
                 echo '<p style="color:red"><strong>Email failed sending to: ' . $Cust->User->email . '</strong></p>';
             } else {
                 echo '<p>Running out of orders message sent to: ' . $Cust->User->email . '</p>';
             }
         } else {
             echo '<p style="color:red"><strong>Email not valid: "' . $Cust->User->email . '"</strong></p>';
         }
     }
     echo '<p><strong>Finished.</strong></p>';
     //Yii::app()->end();
 }
 /**
  * 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 actionCoupon_activate($id)
 {
     if ($this->userHasRedeemedCoupon($id)) {
         $this->render('coupon_already_redeemed');
         return;
     }
     $this->layout = "main";
     $model = new CouponRedemption();
     $customer = Customer::model()->findByPk(Yii::app()->user->getId());
     if ($customer == null) {
         throw new CHttpException(400, 'Invalid request. No customer found!');
     }
     $model->phone = $customer->mobile;
     if (isset($_POST['CouponRedemption'])) {
         $model->attributes = $_POST['CouponRedemption'];
         $model->date_created = date("Y-m-d h:i:s");
         if ($model->save()) {
             $this->redirect(array('listing/coupon_activated', 'id' => $model->credemption_id));
         }
     }
     if (isset($_GET['CouponRedemption'])) {
         $model->attributes = $_GET['CouponRedemption'];
     }
     $model->coupon_id = $id;
     $this->render('coupon_activate', array('model' => $model));
 }
 private function insertSampleRecord()
 {
     $rawPostedData = array("shippingAddress" => array("shipping_address_street" => "#018 Gaddang Street Barangay Quirino", "shipping_address_city" => "Solano", "shipping_address_province" => "Nueva Vizcaya", "shipping_address_country" => "Philippines"), "orderInformation" => array("notes" => "this is a random note . heres a proof . " . uniqid(), "invoice_number" => uniqid(), "sales_person" => "Marcials Furniture", "ship_date" => "November 25,2015", "order_date" => "November 23,2015", "ordered_products" => array(array("product_name" => "wooden chair 2x", "description" => "a wooden chair made of wood", "quantity" => 10, "unit_price" => 3000, "line_total" => 30000), array("product_name" => "wooden chair 3x", "description" => "a wooden chair made of wood but with color", "quantity" => 20, "unit_price" => 4000, "line_total" => 80000), array("product_name" => "Banana Chair", "description" => "A chair that is shaped like a banana", "quantity" => 10, "unit_price" => 3000, "line_total" => 30000)), "sub_total" => 140000, "tax" => 0.5, "shipping" => 2, "total" => 140702, "paid" => 141000, "change" => 298), "customerModel" => array("title" => "Mr", "firstname" => "john " . Customer::model()->count(), "middlename" => "middle " . Customer::model()->count(), "lastname" => "doe " . Customer::model()->count(), "contact_number" => "09069148369"));
     $this->totalPaid += 141000;
     $invoiceDataPersistor = new InvoiceDataPersistor($rawPostedData);
     $invoiceDataPersistor->save();
     return $invoiceDataPersistor;
 }
Exemple #12
0
 public function getIsGuest()
 {
     $customer = Customer::model()->findByPk($this->id);
     if ($customer !== null) {
         return CPropertyValue::ensureInteger($customer->record_type) === Customer::GUEST;
     }
     return parent::getIsGuest();
 }
 /**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'view' page.
  */
 public function actionUpdate()
 {
     $model = $this->loadUser();
     $profile = $model->profile;
     //$model->c_group_id = $model->groups;
     $this->loadAddress($model->id);
     //$this->performAjaxValidation(array($model,$profile), 'customer-form');
     if (isset($_POST['Customer']) || isset($_POST['Staff'])) {
         if (isset($_POST['Customer'])) {
             $model->attributes = $_POST['Customer'];
         } else {
             $model->attributes = $_POST['Staff'];
         }
         //$model->status = $_POST['Customer']['status'];
         $profile->attributes = $_POST['Profile'];
         //$profile->branch_id = $_POST['Profile']['branch_id'];
         if ($model->validate() && $profile->validate() && $this->validateAddress()) {
             $old_password = Customer::model()->notsafe()->findByPk($model->id);
             /*if ($old_password->password!=$model->password) {
             			$model->password=PasswordHelper::hashPassword($model->password);
             			$model->activkey=PasswordHelper::hashPassword(microtime().$model->password);
             		}*/
             $model->save();
             $profile->save();
             $criteria = new CDbCriteria();
             $criteria->condition = 'user_id=:user_id';
             $criteria->params = array(':user_id' => $model->id);
             /*CustomerCGroup::model()->deleteAll($criteria);
             		if(!empty($_POST['Customer']['c_group_id'])){
             			
             			foreach ($_POST['Customer']['c_group_id'] as $groupid){
             				$userGroup = new CustomerCGroup;
             				$userGroup->user_id = $model->id;
             				$userGroup->c_group_id = $groupid;
             				$userGroup->save();
             			}
             		}*/
             //$data = CheckoutAddress::model()->findAll('user_id=:user_id', array(':user_id'=>$model->id));
             CheckoutAddress::model()->deleteAll('user_id=:user_id', array(':user_id' => $model->id));
             foreach ($this->_address as $address) {
                 $address->user_id = $model->id;
                 $address->save();
             }
             Yii::app()->user->setFlash(TbHtml::ALERT_COLOR_SUCCESS, Yii::t('info', 'Your Profile was successfully updated'));
             //$this->renderPartial('view', array('model' => $model,'profile'=>$profile,'address'=>$this->_address), false, true);
             echo json_encode(array('redirect' => $this->createUrl('view')));
             Yii::app()->end();
         } else {
             $profile->validate();
             $this->validateAddress();
         }
     }
     if (Yii::app()->getRequest()->getIsAjaxRequest()) {
         $this->renderPartial('update', array('model' => $model, 'profile' => $profile, 'address' => $this->_address), false, true);
         Yii::app()->end();
     }
     $this->render('update', array('model' => $model, 'profile' => $profile, 'address' => $this->_address));
 }
Exemple #14
0
 public function getModel()
 {
     if (!$this->_model) {
         if ($this->id) {
             $this->_model = Customer::model()->findByPk($this->id);
         } else {
             $this->_model = Customer::model();
         }
     }
     return $this->_model;
 }
 public function tearDown()
 {
     /*delete all productOrders*/
     ProductOrders::model()->deleteAll();
     /*delete all products*/
     Product::model()->deleteAll();
     /*delete all orders*/
     Orders::model()->deleteAll();
     /*delete all customers*/
     Customer::model()->deleteAll();
 }
 protected function tearDown()
 {
     /*delete all productOrders*/
     ProductOrders::model()->deleteAll();
     /*delete all products*/
     Product::model()->deleteAll();
     /*delete all orders*/
     Orders::model()->deleteAll();
     /*delete all customers*/
     Customer::model()->deleteAll();
     parent::tearDown();
 }
 public function duplicatedClientEmail($attribute, $params)
 {
     if ($this->isNewRecord) {
         if (count(Customer::model()->findALl('email=:email', array("email" => $this->email))) > 0) {
             $this->addError($attribute, str_replace("{attribute}", $attribute, Yii::app()->params["templateDuplicatedValueErrorMessage"]));
         }
     } else {
         if (count(Customer::model()->findALl('email=:email and id <> :id', array("email" => $this->email, "id" => $this->id))) > 0) {
             $this->addError($attribute, str_replace("{attribute}", $attribute, Yii::app()->params["templateDuplicatedValueErrorMessage"]));
         }
     }
 }
 public function actionTrackingDetails($id)
 {
     $this->layout = '//layouts/column2';
     $shipment = Shipment::model()->findByPk($id);
     $customer = Customer::model()->findByPk($shipment->customer_id);
     $criteria = new CDbCriteria();
     $criteria->compare('shipment_id', $shipment->id);
     $list_event = new CActiveDataProvider('ShipmentEvent', array('criteria' => $criteria));
     $new_event = new ShipmentEvent();
     $new_event->event_time = date('m/d/Y H:i', time());
     $new_event->status = $shipment->shipping_status;
     $new_event->recipient_name = $shipment->recipient_name;
     $new_event->recipient_title = $shipment->recipient_title;
     if ($shipment->recipient_date != '') {
         $new_event->recipient_date = date('m/d/Y H:i', $shipment->recipient_date);
     }
     if (isset($_POST['ShipmentEvent'])) {
         $new_event->setAttributes($_POST['ShipmentEvent']);
         $shipment->shipping_status = $new_event->status;
         $shipment->shipping_remark = $new_event->remark;
         $shipment->recipient_name = $new_event->recipient_name;
         $shipment->recipient_title = $new_event->recipient_title;
         $shipment->event_time = strtotime($new_event->event_time);
         if (isset($new_event->recipient_date)) {
             $shipment->recipient_date = strtotime($new_event->recipient_date);
         }
         $shipment->setScenario('event');
         $trans = Yii::app()->db->beginTransaction();
         //			error_log(strtotime($new_event->recipient_date).' - '.$new_event->recipient_date);
         error_log($shipment->recipient_date);
         try {
             if ($new_event->save()) {
                 error_log($shipment->recipient_date);
                 if ($shipment->save()) {
                     error_log($shipment->recipient_date);
                     Yii::app()->user->setFlash('success', 'Order status has successfully updated');
                     $trans->commit();
                     $this->redirect(array('trackingDetails', 'id' => $id));
                 } else {
                     //						throw new CException(var_export($shipment->getErrors()));
                     CVarDumper::dump($shipment->getErrors(), 10, true);
                     exit;
                 }
             } else {
                 throw new CException(var_export($new_event->getErrors()));
             }
         } catch (CException $e) {
             $trans->rollback();
             throw $e;
         }
     }
     $this->render('view', array('list_event' => $list_event, 'new_event' => $new_event, 'shipment' => $shipment, 'customer' => $customer));
 }
 public function actionGetCustomerInfo($customerName)
 {
     $criteria = new CDbCriteria();
     $criteria->compare("concat(title,' ',firstName,' ',middleName,' ',lastName)", $customerName);
     $model = Customer::model()->find($criteria);
     if ($model) {
         header("Content-Type: application/json");
         echo json_encode($model->attributes);
     } else {
         throw new CHttpException(404, "Customer doesnt exists");
     }
 }
 /**
  * Authenticates a user.
  * The example implementation makes sure if the username and password
  * are both 'demo'.
  * In practical applications, this should be changed to authenticate
  * against some persistent user identity storage (e.g. database).
  * @return boolean whether authentication succeeds.
  */
 public function authenticate()
 {
     $allCustomers = Customer::model()->findAll();
     $customer = CHtml::listData($allCustomers, 'customer_email', 'customer_password');
     if (!isset($customer[$this->username])) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } elseif ($customer[$this->username] !== $this->password) {
         $this->errorCode = self::ERROR_PASSWORD_INVALID;
     } else {
         $this->errorCode = self::ERROR_NONE;
     }
     return !$this->errorCode;
 }
 public function actionGetCustomersList()
 {
     $criteria = new CDbCriteria();
     $models = Customer::model()->findAll($criteria);
     $customersList = Yii::app()->db->createCommand()->select('c.id,c.name, c.phone, c.address')->from('customer c')->where('1', array())->queryAll();
     $i = 0;
     foreach ($customersList as $item) {
         $ordersList = Yii::app()->db->createCommand()->select('o.id, o.posted_at, o.amount, o.paid_at')->from('order o')->where('o.customer_id=:id', array(':id' => $item['id']))->queryAll();
         $customersList[$i]['orders'] = $ordersList;
         $i++;
     }
     $this->renderJSON($customersList);
 }
Exemple #22
0
 public function actionDelete(array $ids)
 {
     foreach ($ids as $id) {
         $user = User::model()->findByPk($id);
         $userEmails = array($user->email);
         // Delete contact of this user
         $contact = CustomerContact::model()->find("user_id = {$id}");
         if ($contact instanceof CustomerContact) {
             // Get all emails of his contact
             $sql = 'SELECT DISTINCT email
                     FROM ' . SITE_ID . "_crm_contactemail\n                        WHERE contactid = {$contact->id}";
             $contactEmails = app()->db->createCommand($sql)->queryAll();
             foreach ($contactEmails as $contactEmail) {
                 $userEmails[] = $contactEmail['email'];
             }
             $result = app()->XService->run("CustomerContact.CustomerContact.delete", array('id' => $contact->id));
             if ($result instanceof CException) {
                 return $this->result = $result;
             }
         }
         // Delete customer of this user
         $customer = Customer::model()->find("user_id = {$id}");
         if ($customer instanceof Customer) {
             $result = app()->XService->run("Customer.Customer.delete", array('ids' => array($customer->id), 'isForceDelete' => true));
             if ($result instanceof CException) {
                 return $this->result = $result;
             }
         }
         // Delete all rows in table alliance_qualification has email match with emails of this user
         $userEmails = "'" . implode("','", $userEmails);
         $userEmails = rtrim($userEmails, ",'") . "'";
         OfferQualification::model()->deleteAll("email IN ({$userEmails})");
         // Delete alliance info of this user
         $result = app()->XService->run('Alliance.IComfortApplication.deleteICCardInfoByUser', array('userId' => $id));
         if ($result instanceof CException) {
             return $this->result = $result;
         }
         // Delete vip rewards info of this user
         $result = app()->XService->run('VipRewards.VipRewards.deleteByUser', array('userId' => $id));
         if ($result instanceof CException) {
             return $this->result = $result;
         }
         try {
             $user->delete();
         } catch (CException $ex) {
             errorHandler()->commonException()->modelsWithGiveIdsCantBeDeleted('User', array($id));
         }
     }
     return $this->result = true;
 }
Exemple #23
0
 /**
  * Authenticates a user.
  * @return boolean whether authentication succeeds.
  */
 public function authenticate()
 {
     $user = Customer::model()->findByAttributes(array('email' => $this->username, 'status' => 1));
     if (is_null($user)) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } else {
         if ($user->password != User::encryptPassword($this->password, $user->salt)) {
             $this->errorCode = self::ERROR_PASSWORD_INVALID;
         } else {
             $this->errorCode = self::ERROR_NONE;
         }
     }
     return !$this->errorCode;
 }
 public function actionGetcustomers()
 {
     $models = Customer::model()->findAll();
     $rows = array();
     if (count($models)) {
         foreach ($models as $model) {
             $data = $model->attributes;
             $data['franchise'] = $model->franchise0->attributes;
             unset($data['password']);
             $rows[] = $data;
         }
     }
     $this->_sendResponse(200, CJSON::encode($rows));
 }
 /**
  * Authenticate user
  * @return type
  */
 public function authenticate()
 {
     $user = Customer::model()->findByAttributes(array('facebook' => $this->password));
     if ($user instanceof Customer) {
         $this->loginHousekeeping($user);
     } else {
         //We didn't find the Facebook ID in the database, but let's see if the user has an account already
         $user = Customer::model()->findByAttributes(array('email' => $this->username));
         if ($user instanceof Customer) {
             //We found an existing account under this email
             if (is_null($user->facebook)) {
                 //We found an account, merge them
                 $user->facebook = $this->password;
                 $user->save();
                 $this->loginHousekeeping($user);
             } else {
                 //Somehow we've found an existing account with an email from facebook but not the same ID
                 //Clear Facebook ID and bail, this is a serious conflict
                 $user->facebook = $this->password;
                 $user->save();
                 $this->redirect(Yii::app()->homeUrl);
             }
         } else {
             //New user to our site using Facebook, so set up an account
             $model = new Customer();
             $model->scenario = 'createfb';
             $results = Yii::app()->facebook->api('/me');
             $model->first_name = $results['first_name'];
             $model->last_name = $results['last_name'];
             $model->email = $results['email'];
             $model->email_repeat = $results['email'];
             $model->record_type = Customer::REGISTERED;
             $model->newsletter_subscribe = 1;
             $model->facebook = $results['id'];
             if (_xls_get_conf('MODERATE_REGISTRATION', 0) == 1) {
                 $this->errorCode = self::ERROR_NOT_APPROVED;
                 $model->allow_login = Customer::UNAPPROVED_USER;
             } else {
                 $model->allow_login = Customer::NORMAL_USER;
                 if (!$model->save()) {
                     Yii::log("Error creating Facebook account " . print_r($model->getErrors(), true), 'error', 'application.' . __CLASS__ . "." . __FUNCTION__);
                     die("A serious error has occurred creating a Facebook account");
                 }
                 $this->loginHousekeeping($model);
             }
         }
     }
     return $this->errorCode;
 }
Exemple #26
0
 public function run()
 {
     $id = Yii::app()->request->getParam('id', 0);
     $customer_info = Customer::model()->findByPk($id);
     //定义性别信息
     $sex = array('0' => '男', '1' => '女');
     if (isset($_POST['Customer'])) {
         $customer_info->attributes = $_POST['Customer'];
         if ($customer_info->save()) {
             $this->controller->redirect('/mama/Customer/index');
         }
     }
     $var = array('sex' => $sex, 'customer_info' => $customer_info);
     $this->controller->render('update', $var);
 }
Exemple #27
0
 public function run($status, $id)
 {
     $customer_info = Customer::model()->findByPk($id);
     if ($status == 0) {
         $customer_info->status = 1;
     } else {
         $customer_info->status = 0;
     }
     if ($customer_info->update()) {
         $flag = 0;
     } else {
         $flag = 1;
     }
     $vars = array('flag' => $flag);
     $this->controller->success('', $vars);
 }
 public function actionStatussyc()
 {
     $json = file_get_contents('http://iform.checksample.co.uk/data.php');
     $datas = json_decode($json);
     foreach ($datas as $data) {
         $criteria = new CDbCriteria();
         $criteria->condition = "reference = :reference and ( update_time != :update_time or update_time IS NULL)";
         $criteria->params = array(':reference' => $data->reference, ':update_time' => $data->update_time);
         $customer = Customer::model()->find($criteria);
         if ($customer) {
             $customer->status = $data->status;
             $customer->update_time = $data->update_time;
             $customer->save();
         }
     }
 }
 /**
  * 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));
 }
Exemple #30
0
 /**
  * Authenticates a user.
  * @return boolean whether authentication succeeds.
  */
 public function authenticate()
 {
     $u = Customer::model()->findByAttributes(array('mobile' => $this->username));
     if (!$u) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } else {
         if ($u->password != $this->password) {
             $this->errorCode = self::ERROR_PASSWORD_INVALID;
             //		} else if( $u->status == User::STATUS_PENDING) {
             //			$this->errorCode = self::ERROR_STATUS_PENDING;
         } else {
             $this->_id = $u->customer_id;
             $this->errorCode = self::ERROR_NONE;
         }
     }
     return !$this->errorCode;
 }