Example #1
0
 public function sel_detail($user_id)
 {
     $query = Self::find()->select('*')->from('fin_detail')->where(['user_id' => $user_id]);
     $pages = new Pagination(['defaultPageSize' => 5, 'totalCount' => $query->count()]);
     $detail = $query->offset($pages->offset)->limit($pages->limit)->Asarray()->all();
     return ['detail' => $detail, 'pages' => $pages];
 }
Example #2
0
 public function getOrder($user_id)
 {
     $query = Self::find()->select('*')->from('fin_order as order')->leftjoin('fin_student as student', 'order.user_id = student.user_id')->where(['order.merchant_id' => $user_id]);
     $pages = new Pagination(['defaultPageSize' => 5, 'totalCount' => $query->count()]);
     $order = $query->offset($pages->offset)->limit($pages->limit)->Asarray()->all();
     return ['order' => $order, 'pages' => $pages];
 }
Example #3
0
 static function getDefault($payment_types)
 {
     $def = Self::find($payment_types, 'payment_type_is_default', 1);
     if (isset($def)) {
         return $def;
     } else {
         return $payment_types[0];
     }
 }
Example #4
0
 public static function formAction($inputs, $modelId)
 {
     if (null == $modelId) {
         $form = new self();
         $form->i18n_title = i18n::add($inputs['title'], 'title');
         $form->i18n_description = i18n::add($inputs['description'], 'description');
     } else {
         $form = Self::find($modelId);
         i18n::change($form->i18n_title, $inputs['title']);
         i18n::change($form->i18n_description, $inputs['description']);
     }
     //var_dump($inputs); die;
     $form->finish_on = $inputs['finish_on'];
     $form->type = $inputs['type'];
     $form->save();
     if (null == $modelId) {
         return Redirect::route('admin.form.show', $form->id)->with('success', Lang::get('forms.create.success'));
     } else {
         return Redirect::route('admin.form.show', $form->id)->with('success', Lang::get('forms.update.success'));
     }
 }
Example #5
0
 public function getTypes()
 {
     return Self::find()->select('type_id,type_name')->asArray()->all();
 }
Example #6
0
 public function checkPhone($uid, $phone)
 {
     return Self::find()->select('user_phone')->where(['user_id' => $uid, 'user_phone' => $phone])->Asarray()->One();
 }
Example #7
0
 public function getParentList($region_id)
 {
     return Self::find()->where(['pid' => $region_id])->asArray()->all();
 }
Example #8
0
 public function payment($merchant_id, $discount_id, $user_id)
 {
     //echo $merchant_id;die;
     $merchant = Self::find()->select('merchant.merchant_id, merchant.merchant_name')->from('fin_merchant as merchant')->where(['merchant.merchant_id' => $merchant_id])->Asarray()->one();
     //优惠信息
     $model1 = new Discount();
     $discount = $model1::find()->select('discount.discount_id, discount.discount_type, discount.discount_explain')->from('fin_discount as discount')->where(['discount.discount_id' => $discount_id])->asArray()->one();
     //学生信息
     $model2 = new User();
     $user = $model2::find()->select('student.student_id, student.student_balance, student.student_pay_pwd')->from('fin_user as user')->leftjoin('fin_student as student', 'user.user_id=student.user_id')->where(['user.user_id' => $user_id])->Asarray()->one();
     return ['merchant' => $merchant, 'discount' => $discount, 'user' => $user];
 }
Example #9
0
 public function getPartJob()
 {
     return Self::find()->select('partjob_id,type_name,partjob_name, partjob_job_starttime, partjob_job_endtime, partjob_wages,partjob_set_method,partjob_is_model')->from('fin_partjob as p')->leftjoin('fin_type as t', 'p.type_id=t.type_id')->leftjoin('fin_user as u', 'p.user_id=u.user_id')->where(['p.user_id' => 1, 'u.user_type' => 1])->Asarray()->all();
 }
Example #10
0
 static function getDefault($delivery_types)
 {
     return Self::find($delivery_types, 'delivery_type_is_default', 1);
 }
Example #11
0
 public function getFamilyMembersById()
 {
     return Self::find()->where(['family_id' => $this->id])->all();
 }
Example #12
0
 public static function getLibelleTypeSemaine($ligne)
 {
     return Self::find($ligne)->libelleTypeSemaine;
 }
Example #13
0
 public static function destroy($id)
 {
     Self::find($id)->delete();
     return redirect('results');
 }
Example #14
0
 /**
  * Updates the status of the reservation to cancel.
  * 
  * @access  public
  * @static  true
  * @param integer $reservationID
  * @return  array
  * @since 1.0.0
  */
 public static function cancelReservation($reservationID, $reservationType)
 {
     //array to hold response
     $arrResponse = array();
     $queryResult = Self::where('id', $reservationID)->where('reservation_status', '!=', 'cancel')->first()->toArray();
     if ($queryResult) {
         $reservation = Self::find($reservationID);
         $reservation->reservation_status = 'cancel';
         $reservation->save();
         $arrResponse['status'] = 'ok';
     } else {
         $arrResponse['status'] = 'failed';
         $arrResponse['msg'] = 'Sorry. No Such record exists.';
     }
     return $arrResponse;
 }
Example #15
0
 /**
  * Updates the reservation details stored in DB.
  * 
  * @access	public
  * @param	array 	$arrData
  * @return	array
  * @since	1.0.0
  */
 public static function updateReservationDetail($arrData)
 {
     //array to hold response
     $arrResponse = array();
     $date = date_create($arrData['reservationTime']);
     $arrData['reservationTime'] = date_format($date, "h:i A");
     //Read and hold the last reservation details
     $lastReservationDetail = self::getLastReservationDetail($arrData);
     $queryResult = Self::where('id', $arrData['reservationID'])->whereIn('reservation_status', array('new', 'edited'))->first();
     if ($queryResult) {
         $reservation = Self::find($arrData['reservationID']);
         //initializing the data
         $reservation->reservation_status = 'edited';
         $reservation->reservation_date = $arrData['reservationDate'];
         $reservation->reservation_time = $arrData['reservationTime'];
         $reservation->no_of_persons = $arrData['partySize'];
         $reservation->vendor_location_id = $arrData['vendorLocationID'];
         $reservation->guest_name = $arrData['guestName'];
         $reservation->guest_email = $arrData['guestEmail'];
         $reservation->guest_phone = $arrData['phone'];
         $reservation->reservation_type = $arrData['reservationType'];
         //setting up the variables that may be present
         if (isset($arrData['specialRequest'])) {
             $reservation->special_request = $arrData['specialRequest'];
         }
         if (isset($arrData['giftCardID'])) {
             $reservation->giftcard_id = $arrData['giftCardID'];
         }
         if (isset($arrData['addedBy'])) {
             $reservation->added_by = $arrData['addedBy'];
         }
         //setting up the value of the location id as per type
         if ($arrData['reservationType'] == 'alacarte') {
             $reservation->vendor_location_id = $arrData['vendorLocationID'];
             $reservation->product_vendor_location_id = 0;
         } else {
             if ($arrData['reservationType'] == 'experience') {
                 $reservation->vendor_location_id = 0;
                 $reservation->product_vendor_location_id = $arrData['vendorLocationID'];
                 //----------------------------------------------------------------------
                 $arrResult = self::readProductIdAndVendorLocation($arrData['vendorLocationID']);
                 $reservation->vendor_location_id = $arrResult->vendor_location_id;
                 $reservation->product_id = $arrResult->product_id;
                 //-----------------------------------------------------------------------
                 if (array_key_exists('addon', $arrData) && !empty($arrData['addon'])) {
                     //self::updateReservationAddonDetails($arrData['reservationID'],$arrData['addon']);
                     //Reading value for addon
                     $count = $arrData['addon'];
                     if ($count == "") {
                         $arrData['addon'] = array();
                     }
                     // echo "<pre>"; print_r($dataPost);
                     $addonsText = '';
                     foreach ($arrData['addon'] as $key => $value) {
                         if ($value['qty'] > 0) {
                             //echo "prod id = ".$prod_id." , qty = ".$qty;
                             $prod_id = $value['prod_id'];
                             $addonsDetails = DB::select("SELECT attribute_value from product_attributes_text where product_id = {$prod_id} and product_attribute_id = 17");
                             //echo "<pre>"; print_r($addonsDetails);
                             $addonsText .= $addonsDetails[0]->attribute_value . " (" . $value['qty'] . ") , ";
                         }
                     }
                     /* foreach($arrData['addon'] as $prod_id => $qty) {
                     			            if($qty > 0){
                     			                //echo "prod id = ".$prod_id." , qty = ".$qty;
                     			                $addonsDetails = DB::select("SELECT attribute_value from product_attributes_text where product_id = $prod_id and product_attribute_id = 17");
                     
                     			                //echo "<pre>"; print_r($addonsDetails);
                     			                $addonsText .= $addonsDetails[0]->attribute_value." (".$qty.") , ";
                     			            }	        
                     
                             			}
                             			*/
                     $finalAddontext = isset($addonsText) && $addonsText != "" ? "Addons: " . $addonsText : " ";
                     $special_request = isset($arrData['specialRequest']) && !empty($arrData['specialRequest']) ? "Spl Req: " . $arrData['specialRequest'] : "";
                     $arrData['addons_special_request'] = $finalAddontext . " " . $special_request;
                     //---------------------------------------------------------------------------
                 } else {
                     $finalAddontext = " ";
                     $special_request = isset($arrData['specialRequest']) && !empty($arrData['specialRequest']) ? "Spl Req: " . $arrData['specialRequest'] : "";
                     $arrData['addons_special_request'] = $finalAddontext . " " . $special_request;
                 }
             }
         }
         #saving the information into the DB
         $savedData = $reservation->save();
         //Added on 28.5.15
         $resultData = Self::where('id', $arrData['reservationID'])->select('reservation_type', 'product_vendor_location_id', 'vendor_location_id')->first();
         //print_r($resultData['product_vendor_location_id']);
         //print_r($resultData['vendor_location_id']);
         //die();
         $zohoMailStatus = Self::sendZohoMailupdate($arrData, $lastReservationDetail);
         if ($resultData['reservation_type'] == 'alacarte') {
             //reading the resturants detail
             $aLaCarteDetail = self::readVendorDetailByLocationID($arrData['vendorLocationID']);
             $arrResponse['data']['reservation_id'] = $arrData['reservationID'];
             $arrResponse['data']['name'] = $aLaCarteDetail['name'];
             $arrResponse['data']['url'] = URL::to('/') . '/alacarte/' . $aLaCarteDetail['vl_id'];
             $arrResponse['data']['reservationDate'] = $arrData['reservationDate'];
             $arrResponse['data']['reservationTime'] = $arrData['reservationTime'];
             $arrResponse['data']['partySize'] = $arrData['partySize'];
             $arrResponse['data']['reward_point'] = $aLaCarteDetail['reward_point'];
         } else {
             if ($resultData['reservation_type'] == 'experience') {
                 //reading the product detail
                 $productDetail = self::readProductDetailByProductVendorLocationID($arrData['vendorLocationID']);
                 $arrResponse['data']['reservation_id'] = $arrData['reservationID'];
                 $arrResponse['data']['name'] = $productDetail['name'];
                 $arrResponse['data']['url'] = URL::to('/') . '/experience/' . $productDetail['id'];
                 $arrResponse['data']['reservationDate'] = $arrData['reservationDate'];
                 $arrResponse['data']['reservationTime'] = $arrData['reservationTime'];
                 $arrResponse['data']['partySize'] = $arrData['partySize'];
                 $arrResponse['data']['reward_point'] = $productDetail['reward_point'];
             }
         }
         $arrResponse['status'] = $savedData ? Config::get('constants.API_SUCCESS') : Config::get('constants.API_FAILED');
     } else {
         $arrResponse['status'] = Config::get('constants.API_ERROR');
     }
     return $arrResponse;
 }
Example #16
0
 /**
  * Search by condtions
  * @param string $accountId
  * @param array $condtion
  */
 public static function search($accountId, $condtion)
 {
     $query = Self::find();
     $condtions = ['accountId' => $accountId, 'isDeleted' => \backend\components\BaseModel::NOT_DELETED];
     if (is_array($condtion)) {
         $condtions = array_merge($condtions, $condtion);
     }
     $query->where($condtions);
     return new ActiveDataProvider(['query' => $query]);
 }
Example #17
0
 /**
  * valida que el invoice no este cerrado
  * antes del update.
  * @return [type] [description]
  */
 public function beforeUpdate()
 {
     if (Self::find($this->id)->status == 'closed') {
         throw new ValidationException(['sale_is_closed' => trans('awme.stocket::lang.sales.sale_is_closed')]);
     }
 }