Esempio n. 1
0
 public function procAjax()
 {
     if (Request::has('name')) {
         $data = Request::all();
         extract($data);
         switch ($name) {
             case "insert":
                 $insertArray = array('category_name' => $category_master_name, 'category_parent' => $category_master_id_parent, 'category_code' => 'CTG' . AutoGenerate::generateUniqueDigital());
                 $this->categoryCls->insert($insertArray);
                 $data['category_master_id'] = $this->categoryCls->getIdMax('id');
                 if ($category_master_id_parent != 0) {
                     $data['parent_name'] = $this->categoryCls->getCategoryNameById($category_master_id_parent);
                 }
                 break;
             case "update":
                 $this->categoryCls->update(array('category_name' => $category_master_name), array('id' => $category_master_id));
                 break;
             case "delete":
                 $this->categoryCls->delete(array('id' => $category_master_id));
                 $this->categoryCls->delete(array('category_parent' => $category_master_id));
                 break;
         }
         $data['errno'] = 0;
         print json_encode($data);
     }
 }
Esempio n. 2
0
 public function register()
 {
     if (Request::ajax()) {
         $data = Input::all();
         $error = false;
         $errorMsg = '';
         try {
             // Validate
             $this->registerForm->validate($data);
         } catch (FormValidationException $e) {
             $error = true;
             $errorMsg = $e->getErrors();
         }
         if (!$error) {
             if ($this->customersCls->getUserByEmail($data['email'])) {
                 $errorMsg = (object) array('email' => 'Email này đã được đăng kí. Vui lòng nhập email khác!');
                 $error = true;
             } else {
                 $insertArray = array('customer_email' => $data['email'], 'customer_password' => $data['password'], 'customer_code' => AutoGenerate::generateUniqueCustomersCode(), 'customer_name' => $data['username'], 'customer_address' => $data['address'], 'customer_phone' => $data['phone']);
                 if ($this->customersCls->insert($insertArray)) {
                     Session::put('customer_email', $data['email']);
                     Session::put('customer_name', $data['username']);
                     Session::put('register_flag', true);
                 }
             }
         }
         $result = array("error" => $error, "error_msg" => $errorMsg);
         return json_encode($result);
     }
 }
Esempio n. 3
0
 public function __construct()
 {
     $this->billing = Session::get('billing');
     $this->shipping = Session::get('shipping');
     $this->productBuy = Session::get('buy');
     $this->orderCode = AutoGenerate::generateUniqueOrdersCode();
     if (Session::get('customer_email')) {
         $this->customerId = DB::table('customers')->where('customer_email', Session::get('customer_email'))->pluck('id');
     }
 }
Esempio n. 4
0
 /**
  * Check user login, then insert or update info of user
  * @param object $userData
  */
 public function findByUserNameOrCreate($userData)
 {
     $user = $this->getUserByEmail($userData->email);
     if (!$user) {
         $user = array('customer_email' => $userData->email, 'customer_name' => $userData->name, 'customer_code' => AutoGenerate::generateUniqueCustomersCode());
         $this->insert($user);
     }
     $this->checkIfUserNeedsUpdating($userData, $user);
     Session::put('customer_email', $userData->email);
     Session::put('customer_name', $userData->name);
 }