/**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return Booking the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Booking::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Example #2
0
 public function actionExport()
 {
     $re = Booking::model()->findAll();
     //echo "<pre>";print_r($re);
     foreach ($re as $res) {
         $detail = $res['cleaningDetail'];
         $trans = $res['trans_id'];
         $price = $res['price'];
         $serName = $res->serviceType['service_name'];
         $cAdd = $res->customerAddress['address'];
         $company = $res->service['company_name'];
         $val[] = array('Copmany Name' => $company, 'Customer Address' => $cAdd, 'Service Name' => $serName, 'price' => $price, 'TransId' => $trans, 'Detail' => $detail);
     }
     //echo "<pre>";print_r($val);die;
     $filename = "payment.csv";
     $csv = new ECSVExport($val);
     $content = $csv->toCSV();
     Yii::app()->getRequest()->sendFile($filename, $content, "text/csv", false);
     exit;
 }
Example #3
0
				<?php 
echo $form->labelEx($model, 'office_close_time');
?>
				<?php 
echo $form->textField($model, 'office_close_time', array('size' => 5));
?>
				<?php 
echo $form->error($model, 'office_close_time');
?>
			</div>
			<div class="row">
				<?php 
echo $form->labelEx($model, 'address_type');
?>
				<?php 
echo $form->dropDownList($model, 'address_type', Booking::model()->list_address_type, array('prompt' => ''));
?>
				<?php 
echo $form->error($model, 'address_type');
?>
			</div>
		</div>
		<div class="c50r">
			<div class="row">
				<?php 
echo $form->labelEx($model, 'pickup_note');
?>
				<?php 
echo $form->textArea($model, 'pickup_note', array('rows' => 6, 'cols' => 50));
?>
				<?php 
 public function actionRequestPickUp()
 {
     $req = Yii::app()->request;
     $shipment_id = $req->getQuery('shipment_id');
     if (!isset($_POST['Booking'])) {
         echo CJSON::encode($this->statusError('Must be in POST method'));
         Yii::app()->end();
     }
     $booking = new Booking();
     $booking->setAttributes($_POST['Booking']);
     $booking->setAttribute('booking_code', dechex(time()));
     if ($shipment_id != null) {
         $shipment = Shipment::model()->findByPk($shipment_id);
         if (!$shipment instanceof Shipment) {
             echo CJSON::encode($this->statusError('Your Shipment is invalid'));
             Yii::app()->end();
         }
     }
     $trans = Yii::app()->db->beginTransaction();
     try {
         if ($booking->save()) {
             if (isset($shipment) && $shipment instanceof Shipment) {
                 Booking::model()->updateByPk($booking->id, array('customer_id' => $shipment->customer_id));
                 $shipment->setAttribute('booking_id', $booking->id);
                 if (!$shipment->save()) {
                     throw ServiceControllerException($shipment->getErrors());
                 }
             } else {
                 if ($this->token instanceof Token) {
                     $customer = Customer::model()->findByPk($this->token->customer_id);
                     if (!$customer instanceof Customer) {
                         throw new ServiceControllerException('You have to login first');
                     } else {
                         Booking::model()->updateByPk($booking->id, array('customer_id' => $customer->id));
                     }
                 } else {
                     $customer = new Customer();
                     $customer->name = $booking->name;
                     $customer->type = 'personal';
                     $customer->accountnr = 'WEB' . time();
                     if ($customer->save()) {
                         $contact = new Contact();
                         $contact->parent_id = $customer->id;
                         $contact->parent_model = 'Customer';
                         $contact->full_name = $booking->name;
                         $contact->address = $booking->address;
                         $contact->country = $booking->country;
                         $contact->city = $booking->city;
                         $contact->postal = $booking->postal;
                         if ($contact->save()) {
                             Booking::model()->updateByPk($booking->id, array('customer_id' => $customer->id));
                         } else {
                             throw new ServiceControllerException($contact->getErrors());
                         }
                     } else {
                         throw new ServiceControllerException($customer->getErrors());
                     }
                 }
             }
             $data = array('booking_code' => $booking->booking_code);
         } else {
             throw ServiceControllerException($booking->getErrors());
         }
         $trans->commit();
     } catch (ServiceControllerException $e) {
         $errors = $e->errors;
         $trans->rollback();
         echo CJSON::encode($this->statusError($errors));
         Yii::app()->end();
     }
     echo CJSON::encode($this->statusSuccess($data));
     Yii::app()->end();
 }
Example #5
0
<?php

$redirect = $this->getAction()->id;
$this->widget('zii.widgets.grid.CGridView', array('id' => 'assign_courier-grid', 'dataProvider' => $driver_list_available, 'htmlOptions' => array('class' => 'hastable'), 'columns' => array(array('header' => 'Driver Name', 'type' => 'raw', 'name' => 'user.username', 'value' => function ($data, $row) use($redirect, $model) {
    return CHtml::link($data->user->username, array('booking/' . $redirect, 'id' => $model->id, 'driver_id' => $data->user_id));
}), 'routing_code', array('header' => 'Assignment', 'type' => 'raw', 'value' => function ($data, $row) {
    return Booking::model()->count('driver_id=:driver_id', array(':driver_id' => $data->user_id));
}))));
?>

<br />
<?php 
echo CHtml::link('Back', Yii::app()->createUrl('/booking'), array('class' => 'l-btn'));
 public function actionAssignlist()
 {
     if (!isset($_REQUEST['token'])) {
         echo CJSON::encode($this->statusError(0));
     }
     $booking = Booking::model()->findAllByAttributes(array('driver_id' => $driver = Driver::getUserId($_REQUEST['token'])));
     $arr = array();
     foreach ($booking as $row) {
         $arr[] = $row->booking_code;
     }
     echo CJSON::encode($this->statusSuccess($arr));
 }
Example #7
0
 public function actionIndex()
 {
     $model = new PaymentCustomerUser();
     $booking = new CustomerBooking();
     $address = new CustomerAddress();
     $company = new CompanyRequest();
     $ses = Yii::app()->session['CleaningDetail'];
     $servicetype = Yii::app()->session['ServiceTypeId'];
     $zip = $ses['CleaningTime']['PostCode'];
     // echo "<pre>";print_r(base64_decode($_REQUEST['value']));die;
     //echo "<pre>";print_r($ses);die;
     //$myProducts = Yii::app()->session['detail'];
     $detail = Yii::app()->session['detail'];
     foreach ($detail['Additional'] as $k => $d) {
         $detailadnl[$k] = ServicetypeAdditionalservices::model()->findAll(array('condition' => 'id=:id', 'params' => array(':id' => $k)));
     }
     foreach ($detailadnl as $key => $nam) {
         // echo "<pre>";print_r($nam);
         foreach ($nam as $value) {
             $detailadnl[$key] = $value['additional_service_name'];
         }
     }
     //echo "<pre>";print_r($detail['Additional']);
     $finalDetailadnl = array_combine($detailadnl, $detail['Additional']);
     //echo "<pre>";print_r($fin);die;
     //$price         =$_REQUEST['price'];
     // code to get the method from admin %age or fiexd cost  of total amount
     $paymentAdmin = PaymentToAdmin::model()->find(array('condition' => 'status=1'));
     if (!empty($paymentAdmin)) {
         //echo "adda";die;
         if ($paymentAdmin['type_of_cost'] == 'Fixed') {
             $price = $paymentAdmin['cost_percentage'];
         } else {
             if (isset($_REQUEST['value'])) {
                 $pri = $paymentAdmin['cost_percentage'] * base64_decode($_REQUEST['value']);
                 $pce = $pri / 100;
                 $price = $pce;
             } else {
                 $price = base64_decode($_REQUEST['value1']);
             }
         }
     } else {
         $price = base64_decode($_REQUEST['value']);
     }
     //echo $price;die;
     $service_id = $_REQUEST['service_id'];
     $rec = UkPostcodes::model()->findByattributes(array('postcode' => $zip));
     // detail for logged user
     $loggedId = Yii::app()->session['loggedId'];
     $customerDetail = PaymentCustomerUser::model()->findByPk(array('id' => $loggedId));
     //echo "<pre>";print_r($customerDetail);die;
     //echo "<pre>";print_r($servicetype);die;
     if (isset($_POST['PaymentCustomerUser'])) {
         $logged = Yii::app()->session['loggedId'];
         //echo "<pre>";print_r($ses);die;
         $model->attributes = $_POST['PaymentCustomerUser'];
         if ($model->validate()) {
             // echo "<pre>";print_r($_REQUEST);die;
             $exp = $_REQUEST['PaymentCustomerUser']['expire'];
             $res = explode("/", $exp);
             $month = $res[0];
             $year = $res[1];
             $cardDetail = implode(explode(" ", trim($_REQUEST['PaymentCustomerUser']['cardDetail'])));
             /*if($_REQUEST['value']==0)
               {
               	 $price=0;
               }	*/
             $paymentInfo = array('Member' => array('first_name' => $_REQUEST['PaymentCustomerUser']['cname'], 'last_name' => $_REQUEST['PaymentCustomerUser']['clname'], 'billing_address' => $_REQUEST['PaymentCustomerUser']['caddress'], 'billing_address2' => $_REQUEST['PaymentCustomerUser']['caddress'], 'billing_country' => $_REQUEST['PaymentCustomerUser']['country'], 'billing_city' => $_REQUEST['PaymentCustomerUser']['city'], 'billing_zip' => $_REQUEST['PaymentCustomerUser']['zipcode']), 'CreditCard' => array('card_number' => $cardDetail, 'expiration_month' => trim($month), 'expiration_year' => trim($year), 'cv_code' => $_REQUEST['PaymentCustomerUser']['code'], 'credit_type' => $_REQUEST['PaymentCustomerUser']['cardType']), 'Order' => array('theTotal' => $price));
             // echo "<pre>";print_r($paymentInfo);
             $result = Yii::app()->Paypal->DoDirectPayment($paymentInfo);
             //echo http_build_query($data, 'flags_');
             //echo "<pre>";print_r($result);die;
             if ($result['ACK'] == 'Failure') {
                 $links = CmsPages::model()->findAll();
                 Yii::app()->params['MyArray'] = $links;
                 Yii::app()->user->setFlash('ack', "Please check your card details");
                 $this->render('index', array('model' => $model, 'town' => $rec, 'price' => $price, 'service_id' => $service_id));
             }
             if (!Yii::app()->Paypal->isCallSucceeded($result)) {
                 if (Yii::app()->Paypal->apiLive === true) {
                     //Live mode basic error message
                     $error = 'We were unable to process your request. Please try again later';
                 } else {
                     //Sandbox output the actual error message to dive in.
                     $error = $result['L_LONGMESSAGE0'];
                 }
                 echo $error;
             } else {
                 //Payment was completed successfully, do the rest of your stuff
                 // code to register the customer and save  transaction id in differ table
                 if (!empty($result['TRANSACTIONID'])) {
                     $model->cname = $_REQUEST['PaymentCustomerUser']['cname'];
                     $model->clname = $_REQUEST['PaymentCustomerUser']['clname'];
                     $model->caddress = $_REQUEST['PaymentCustomerUser']['caddress'];
                     $model->zipcode = $_REQUEST['PaymentCustomerUser']['zipcode'];
                     $model->phone = $_REQUEST['PaymentCustomerUser']['phone'];
                     $model->email = $_REQUEST['PaymentCustomerUser']['email'];
                     $model->city = $_REQUEST['PaymentCustomerUser']['city'];
                     $model->country = $_REQUEST['PaymentCustomerUser']['country'];
                     $model->cregistered = date('Y-m-d');
                     $email = $_REQUEST['PaymentCustomerUser']['email'];
                     $user = PaymentCustomerUser::model()->exists('email=:email', array('email' => $email));
                     // $user=PaymentCustomerUser::model()->findByAttributes(array('email'=>$email));
                     //echo "<pre>";print_r($user);die;
                     //if(count($user)<0)
                     if (empty($user)) {
                         //echo "hlo";die;
                         $cleartext_password = rand(0, 9999);
                         $model->password = md5($cleartext_password);
                         if ($model->save()) {
                             $signature = md5($model->email . $model->password);
                             $subject = 'Welcome to Wow Cleans';
                             $body = $this->renderPartial('registrationEmail', array('model' => $model, 'password' => $cleartext_password, 'url' => $this->createAbsoluteUrl('../registration/login', array('email' => $model->email, 'signature' => $signature))), true);
                             Yii::app()->mailer->send($model->email, $subject, $body);
                             // booking detail for register customer here
                             $custId = Yii::app()->db->getLastInsertID();
                             $transId = $result['TRANSACTIONID'];
                             $cust = PaymentCustomerUser::model()->findByAttributes(array('id' => $custId));
                             $companyDetail = ServiceUser::model()->findByAttributes(array('id' => $_REQUEST['service_id']));
                             //echo "<pre>";print_r($companyDetail);die;
                             // save address for customer in different table
                             $address->address = $_REQUEST['PaymentCustomerUser']['caddress'];
                             $address->zipcode = $_REQUEST['PaymentCustomerUser']['zipcode'];
                             $address->date = date('Y-m-d');
                             $address->customer_id = $custId;
                             $address->save();
                             $address_id = Yii::app()->db->getLastInsertID();
                             $re = CustomerAddress::model()->findByAttributes(array('customer_id' => $custId));
                             //echo "<pre>";print_r($re);die;
                             $addressId = $re->id;
                             $booking->customer_id = $custId;
                             $booking->service_id = $_REQUEST['service_id'];
                             $booking->service_type_id = $servicetype;
                             //$booking->price          =$_REQUEST['price'];
                             $booking->price = $price;
                             $booking->trans_id = $transId;
                             $booking->date = date('Y-m-d');
                             if (!empty($address_id)) {
                                 $booking->customer_address_id = $address_id;
                             } else {
                                 $booking->customer_address_id = $addressId;
                             }
                             $detail = Yii::app()->session['detail'];
                             // echo "<pre>";print_r($detail);die;
                             foreach ($detail['Cleaning'] as $type => $number) {
                                 $cleaningDetail .= $number . "-" . $type . ",";
                             }
                             $booking->cleaningDetail = substr($cleaningDetail, 0, -1);
                             /*foreach($detail['Additional'] as $k=>$val)
                               {
                               	  if($val!=0)
                               	  {
                               	  	 $addnl .=$val."-".$k.",";
                               	  }	
                               }	*/
                             foreach ($finalDetailadnl as $k => $val) {
                                 if ($val != 0) {
                                     $addnl .= $val . "-" . $k . ",";
                                 }
                             }
                             $booking->additional = substr($addnl, 0, -1);
                             $booking->additional_details = $detail['AdditionalCustDetail']['AdditionalCustDetail'];
                             if ($booking->save()) {
                                 //booking id for thaks page
                                 $insert_id = Yii::app()->db->getLastInsertID();
                                 $cutId = Booking::model()->findByPk(array('id' => $insert_id));
                                 $customerId = $cutId->customer_id;
                                 /*code to enter the company request details in company request table*/
                                 $company->booking_id = $insert_id;
                                 $company->service_id = $_REQUEST['service_id'];
                                 $company->customer_id = $customerId;
                                 $company->cleaningtime = $ses['CleaningTime']['time'];
                                 $company->postcode = $ses['CleaningTime']['PostCode'];
                                 $company->cleaningdate = date("Y-m-d", strtotime($ses['CleaningTime']['CleaningDate']));
                                 $company->date = date('Y-m-d');
                                 $company->no_of_hours = $ses['CleaningTime']['noOfhour'];
                                 $company->no_of_cleaners = $ses['CleaningTime']['noOfCleaners'];
                                 $company->save(false);
                                 // echo $insert_id;die;
                                 // send mail to customer
                                 $subject = 'Welcome to Wow Cleans';
                                 $body = $this->renderPartial('customerEmail', array('model' => $companyDetail, 'cust' => $_REQUEST, 'detail' => $detail, 'adnl' => $finalDetailadnl, 'price' => $price, 'trans' => $result['TRANSACTIONID']), true);
                                 Yii::app()->mailer->send($cust->email, $subject, $body);
                                 // send mail to company
                                 $subject = 'Welcome to Wow Cleans';
                                 $body = $this->renderPartial('companyEmail', array('model' => $companyDetail, 'cust' => $_REQUEST, 'detail' => $detail, 'adnl' => $finalDetailadnl, 'price' => $price, 'trans' => $result['TRANSACTIONID']), true);
                                 Yii::app()->mailer->send($companyDetail->email, $subject, $body);
                                 //$this->refresh();
                                 //$this->redirect(array('../registration/index'));
                             }
                             // booking detail for register customer ends here
                             $link = CmsPages::model()->findAll();
                             Yii::app()->params['MyArray'] = $link;
                             // $this->redirect('thanks','param1'=>$companyDetail);
                             $this->redirect(array('payment/thanks', 'param1' => $insert_id));
                             //exit();
                             //$this->refresh();
                             //$this->redirect(array('registration/registration'));
                         }
                     } else {
                         // echo "fsf";die;
                         //$price     =$_REQUEST['price'];
                         $email = $_REQUEST['PaymentCustomerUser']['email'];
                         $transId = $result['TRANSACTIONID'];
                         $rec = PaymentCustomerUser::model()->findByAttributes(array('email' => $email));
                         //echo "<pre>";print_r($rec);die;
                         $custId = $rec->id;
                         $companyDetail = ServiceUser::model()->findByAttributes(array('id' => $_REQUEST['service_id']));
                         // save address for customer in different table
                         $address->address = $_REQUEST['PaymentCustomerUser']['caddress'];
                         $address->zipcode = $_REQUEST['PaymentCustomerUser']['zipcode'];
                         $address->date = date('Y-m-d');
                         $address->customer_id = $custId;
                         if (!($user = CustomerAddress::model()->exists('address=:address', array('address' => $_REQUEST['PaymentCustomerUser']['caddress'])))) {
                             $address->save();
                             $address_id = Yii::app()->db->getLastInsertID();
                         }
                         //$address_id = Yii::app()->db->getLastInsertID();
                         $re = CustomerAddress::model()->findByAttributes(array('customer_id' => $custId));
                         //echo "<pre>";print_r($rec->id);die;
                         $addressId = $re->id;
                         $booking->customer_id = $custId;
                         $booking->service_id = $_REQUEST['service_id'];
                         $booking->service_type_id = $servicetype;
                         //$booking->price          =$_REQUEST['price'];
                         $booking->price = $price;
                         $booking->trans_id = $transId;
                         $booking->date = date('Y-m-d');
                         if (!empty($address_id)) {
                             $booking->customer_address_id = $address_id;
                         } else {
                             $booking->customer_address_id = $addressId;
                         }
                         $detail = Yii::app()->session['detail'];
                         // echo "<pre>";print_r($detail);die;
                         foreach ($detail['Cleaning'] as $type => $number) {
                             $cleaningDetail .= $number . "-" . $type . ",";
                         }
                         $booking->cleaningDetail = substr($cleaningDetail, 0, -1);
                         //echo "<pre>";print_r($detail['Additional']);die;
                         /*foreach($detail['Additional'] as $k=>$val)
                           {
                           	  if($val!=0)
                           	  {
                           	  	 $addnl .=$val."-".$k.",";
                           	  }	
                           } */
                         foreach ($finalDetailadnl as $k => $val) {
                             if ($val != 0) {
                                 $addnl .= $val . "-" . $k . ",";
                             }
                         }
                         $booking->additional = substr($addnl, 0, -1);
                         $booking->additional_details = $detail['AdditionalCustDetail']['AdditionalCustDetail'];
                         if ($booking->save(false)) {
                             $insert_id = Yii::app()->db->getLastInsertID();
                             $cutId = Booking::model()->findByPk(array('id' => $insert_id));
                             //echo "<pre>";print_r($cutId);die;
                             $customerId = $cutId->customer_id;
                             /*code to add the company request details in company request table*/
                             $company->booking_id = $insert_id;
                             $company->service_id = $_REQUEST['service_id'];
                             $company->customer_id = $customerId;
                             $company->cleaningtime = $ses['CleaningTime']['time'];
                             $company->postcode = $ses['CleaningTime']['PostCode'];
                             $company->cleaningdate = date("Y-m-d", strtotime($ses['CleaningTime']['CleaningDate']));
                             $company->date = date('Y-m-d');
                             $company->no_of_hours = $ses['CleaningTime']['noOfhour'];
                             $company->no_of_cleaners = $ses['CleaningTime']['noOfCleaners'];
                             $company->save(false);
                             // send mail to customer
                             $subject = 'Welcome to Wow Cleans';
                             $body = $this->renderPartial('customerEmail', array('model' => $companyDetail, 'cust' => $_REQUEST, 'detail' => $detail, 'adnl' => $finalDetailadnl, 'price' => $price, 'trans' => $result['TRANSACTIONID']), true);
                             Yii::app()->mailer->send($rec->email, $subject, $body);
                             // send mail to company
                             $subject = 'Welcome to Wow Cleans';
                             $body = $this->renderPartial('companyEmail', array('model' => $companyDetail, 'cust' => $_REQUEST, 'detail' => $detail, 'adnl' => $finalDetailadnl, 'price' => $price, 'trans' => $result['TRANSACTIONID']), true);
                             Yii::app()->mailer->send($companyDetail->email, $subject, $body);
                             //$this->refresh();
                             if ($logged != '') {
                                 //$this->redirect(array('../registration/customerdashboard'));
                                 $this->redirect(array('payment/thanks', 'param1' => $insert_id));
                             } else {
                                 $this->redirect(array('payment/thanks', 'param1' => $insert_id));
                                 //$this->redirect(array('../registration/index'));
                             }
                         }
                         //echo $servicetype; die;
                         //echo "<pre>";print_r($rec);die;
                     }
                 }
             }
             Yii::app()->end();
         } else {
             $errors = $model->getErrors();
             // var_dump($errors);
         }
     }
     $links = CmsPages::model()->findAll();
     Yii::app()->params['MyArray'] = $links;
     $this->render('index', array('model' => $model, 'town' => $rec, 'price' => $price, 'service_id' => $service_id, 'customerDetail' => $customerDetail));
 }
 public function actionChnagequotesDashboardSpeciUser()
 {
     //$id      =$_REQUEST['id'];
     $admin = new ParticularPrice();
     $adnl = new AdditionalParticularPrice();
     $price = new ParticularPrice();
     $loggedId = Yii::app()->session['loggedId'];
     $providerId = CompanyRequest::model()->findByPk(array('id' => $id));
     $bookId = $providerId['booking_id'];
     $bookingrec = Booking::model()->findByPk(array('id' => $bookId));
     //echo "<pre>";print_r($bookingrec);die;
     $servicetype = $bookingrec['service_type_id'];
     $provId = $bookingrec['service_id'];
     // echo $bookingId;die;
     $priceAdmin = PriceAdmin::model()->find(array('condition' => 'service_id=:service_id AND service_type_id=:service_type_id', 'params' => array(':service_id' => $provId, ':service_type_id' => $servicetype)));
     $addPriceDetl = AdditionalServicePrice::model()->findAll(array('condition' => 'service_id=:service_id', 'params' => array(':service_id' => $provId)));
     $particularRec = ParticularPrice::model()->find(array('condition' => 'booking_id=:booking_id', 'params' => array(':booking_id' => $_REQUEST['booking_id'])));
     /*code to save the particular quote*/
     if (isset($_REQUEST['ParticularPrice'])) {
         $partiRecord = ParticularPrice::model()->find(array('condition' => 'booking_id=:booking_id', 'params' => array(':booking_id' => $_REQUEST['booking_id'])));
         if (!empty($partiRecord)) {
             //echo "<pre>";print_r($_REQUEST);die;
             $priceParticular = ParticularPrice::model()->find(array('condition' => 'booking_id=:booking_id', 'params' => array(':booking_id' => $_REQUEST['booking_id'])));
             foreach ($_REQUEST['ParticularPrice'] as $k => $p) {
                 if ($k == "bedroom") {
                     $modifiedKey = "Bedrooms";
                 } else {
                     if ($k == "bathroom") {
                         $modifiedKey = "Bathrooms";
                     } else {
                         if ($k == "property") {
                             $modifiedKey = "Property";
                         } else {
                             if ($k == "desk") {
                                 $modifiedKey = "Desk";
                             }
                         }
                     }
                 }
                 $firstArrayVal = $_REQUEST['noBedBathDesk'][$modifiedKey];
                 $newAr[] = $firstArrayVal * $p;
                 $priceParticular->{$k} = $p;
                 // $k++;
             }
             $result = array_sum($newAr);
             $priceParticular->particular_price = $result;
             $priceParticular->save(false);
             /*chnage the details for additional particular prices*/
             $additionalPartiPrice = AdditionalParticularPrice::model()->findAll(array('condition' => 'booking_id=:booking_id', 'params' => array(':booking_id' => $_REQUEST['booking_id'])));
             //foreach($additionalPartiPrice)
             //echo "<pre>";print_r($additionalPartiPrice);die;
             if (!empty($_REQUEST['AdditionalParticularPrice'])) {
                 //echo "<pre>";print_r($_REQUEST);die;
                 /* foreach($additionalPartiPrice as $key=>$edit)
                 				              {
                 				              	  //echo "<pre>";print_r($edit);
                 				              	       foreach($_REQUEST['AdditionalParticularPrice'] as $k=>$adnlprice)
                 						              {
                 						                  //echo "<pre>";print_r($adnlprice);      
                 						                  if($edit['additional_service_id']==$k)
                 						                  {	
                 						                     $edit->price                =$adnlprice;
                 						                  } 
                 						                  // $sum = 0;
                 						                  foreach($_REQUEST['adnl'] as $tot)
                 						                  {
                 						                      $arr[] =$tot*$adnlprice;
                 						                      $res =array_sum($arr);
                 
                 						                  }
                 						                   $edit->total_price=$res+$result;
                 						                   $edit->save(false);
                 						                                  
                 						                      $res=array(); 
                 						                      $arr=array(); 
                 						                 					                 
                 						              }
                 				              	 
                 				              } */
                 foreach ($additionalPartiPrice as $key => $edit) {
                     foreach ($_REQUEST['AdditionalParticularPrice'] as $k => $adnlprice) {
                         $edit->price = $adnlprice;
                         $total = array();
                         foreach ($_REQUEST['AdditionalParticularPrice'] as $key => $adnlpr) {
                             $total[] = $adnlpr * $_REQUEST['adnl'][$key];
                             //echo "<pre>";print_r($total);
                         }
                         //die;
                         $sum1 = array_sum($total);
                         $edit->total_price = $sum1 + $result;
                         $edit->save(false);
                     }
                 }
             }
             /* mail to customer*/
             $subject = 'Welcome to Wow Cleans';
             $body = $this->renderPartial('chnagequoteparticularCustomerEmail', array('model' => $partiRecord), true);
             Yii::app()->mailer->send($partiRecord->customer['email'], $subject, $body);
             /*mail to company */
             $subject = 'Welcome to Wow Cleans';
             $body = $this->renderPartial('chnagequoteparticularCustomerEmail', array('model' => $partiRecord), true);
             Yii::app()->mailer->send($partiRecord->customer['email'], $subject, $body);
             $this->redirect(array('dashboard'));
         } else {
             $price->customer_id = $_REQUEST['customer_id'];
             $price->service_id = $loggedId;
             $price->booking_id = $_REQUEST['booking_id'];
             $price->date = date('Y-m-d');
             //$k=0;
             foreach ($_REQUEST['ParticularPrice'] as $k => $p) {
                 if ($k == "bedroom") {
                     $modifiedKey = "Bedrooms";
                 } else {
                     if ($k == "bathroom") {
                         $modifiedKey = "Bathrooms";
                     } else {
                         if ($k == "property") {
                             $modifiedKey = "Property";
                         } else {
                             if ($k == "desk") {
                                 $modifiedKey = "Desk";
                             }
                         }
                     }
                 }
                 $firstArrayVal = $_REQUEST['noBedBathDesk'][$modifiedKey];
                 $newAr[] = $firstArrayVal * $p;
                 $price->{$k} = $p;
                 // $k++;
             }
             $result = array_sum($newAr);
             $price->particular_price = $result;
             $price->save(false);
             if (!empty($_REQUEST['AdditionalParticularPrice'])) {
                 /*   foreach($_REQUEST['AdditionalParticularPrice'] as $k=>$adnlprice)
                 					               {
                 					                  $adnl    =new AdditionalParticularPrice; 
                 					                  $adnl->service_id           =$loggedId;
                 					                  $adnl->customer_id          =$_REQUEST['customer_id'];
                 					                  $adnl->booking_id           =$_REQUEST['booking_id']; 
                 					                  $adnl->date                 =date('Y-m-d'); 
                 					                  $adnl->additional_service_id=$k;
                 					                  
                 					                  $adnl->price                =$adnlprice;
                 					                  // $sum = 0;
                 					                  foreach($_REQUEST['adnl'] as $tot)
                 					                  {
                 					                      $arr[] =$tot*$adnlprice;
                 					                      $res =array_sum($arr);
                 
                 					                  }
                 					                   $adnl->total_price=$res+$result;
                 					                   $adnl->save(false);
                 					                                  
                 					                      $res=array(); 
                 					                      $arr=array(); 
                 					                  
                 					                 
                 					              } */
                 //$total = array();
                 foreach ($_REQUEST['AdditionalParticularPrice'] as $k => $adnlprice) {
                     $adnl = new AdditionalParticularPrice();
                     $adnl->service_id = $loggedId;
                     $adnl->customer_id = $_REQUEST['customer_id'];
                     $adnl->booking_id = $_REQUEST['booking_id'];
                     $adnl->date = date('Y-m-d');
                     $adnl->additional_service_id = $k;
                     $adnl->price = $adnlprice;
                     $total = array();
                     foreach ($_REQUEST['AdditionalParticularPrice'] as $key => $adnlpr) {
                         $total[] = $adnlpr * $_REQUEST['adnl'][$key];
                         //echo "<pre>";print_r($total);
                     }
                     //die;
                     $sum1 = array_sum($total);
                     $adnl->total_price = $sum1 + $result;
                     $adnl->save(false);
                 }
                 //die;
             }
             //die("fsdfsd");
             /* mail to customer*/
             $subject = 'Welcome to Wow Cleans';
             $body = $this->renderPartial('chnagequoteparticularCustomerEmail', array('model' => $particularRec), true);
             Yii::app()->mailer->send($partiRecord->customer['email'], $subject, $body);
             /*mail to company */
             $subject = 'Welcome to Wow Cleans';
             $body = $this->renderPartial('chnagequoteparticularCustomerEmail', array('model' => $particularRec), true);
             Yii::app()->mailer->send($partiRecord->customer['email'], $subject, $body);
             $this->redirect(array('dashboard'));
         }
         //$price
         // echo "<pre>";print_r($_REQUEST);die;
     }
     $links = CmsPages::model()->findAll();
     Yii::app()->params['MyArray'] = $links;
     $this->render('chnagequotesDashboardSpeciUser', array('bookingrec' => $bookingrec, 'priceAdmin' => $priceAdmin, 'admin' => $admin, 'addPriceDetl' => $addPriceDetl, 'adnl' => $adnl, 'particularRec' => $particularRec));
 }
Example #9
0
 public function isBooked($appointmentID)
 {
     $result = Booking::model()->count('appointment_id="' . $appointmentID . '"');
     return $result > 0 ? 1 : 0;
 }