public function actionCompleteRegistrationAjax() { $client = new Client(); $client->attributes = $_POST['Client']; if ($client->save()) { $quotation = new Quotation(); $quotation->attributes = $_POST['Quotation']; $quotation->client_id = $client->primaryKey; $quotation->creation_date = date("Y-m-d H:i:s"); if ($quotation->save()) { $quot = Quotation::model()->findByPk($quotation->primaryKey); $message = new YiiMailMessage(); $message->view = 'cotizador'; $message->setBody(array("client" => $client, "quotation" => $quot), 'text/html'); $message->setSubject('Prospecto para Cotización'); foreach ($quot->concessioner->emails as $email) { if ($email->type == "QUOTATION") { $message->addTo($email->description); } } // $message->addTo("*****@*****.**"); //$message->addTo("*****@*****.**"); //$message->addTo("*****@*****.**"); $message->addTo("*****@*****.**"); $message->addTo("*****@*****.**"); $message->setFrom(array(Yii::app()->params['adminEmail'] => 'El Equipo Nissan Ecuador')); Yii::app()->mail->send($message); echo json_encode(true); } else { echo json_encode(false); } } // $vehicle_version= VehicleVersion::model()->findAllByAttributes(array("vehicle_id"=>$_POST['vehicle_id'],"status"=>"ACTIVE")); echo json_encode(true); }
public function run($args) { $daynow = date("d"); $monthnow = date("m"); $datenow = date("Y-m-d"); $datenow1 = new DateTime($datenow); //die($datenow); $quotations = Quotation::model()->findAllByAttributes(array('review' => 'NO')); foreach ($quotations as $quotation) { // $datequotation=date("Y-m-d",$quotation->registration_date); $datequotation1 = new DateTime($quotation->creation_date); $aux = date_diff($datenow1, $datequotation1); //die(print_r($datequotation1)); //die(print_r($aux->days)); if ($aux->days == 2) { $message = new YiiMailMessage(); $message->view = '48hours'; $message->setBody(array("quotation" => $quotation), 'text/html'); $message->setSubject('¿Le ofrecieron la información requerida del vehículo Nissan cotizado?. Trabajamos para ofrecerle un mejor servicio.'); $message->addTo($quotation->client->email); $message->from = Yii::app()->params['adminEmail']; if (Yii::app()->mail->send($message)) { $quotation->review = "YES"; $quotation->save(); } } } $suggestions = Suggestion::model()->findAllByAttributes(array('review' => 'NO')); foreach ($suggestions as $suggestion) { // $datequotation=date("Y-m-d",$quotation->registration_date); $datequotation1 = new DateTime($suggestion->creation_date); $aux = date_diff($datenow1, $datequotation1); //die(print_r($datequotation1)); //die(print_r($aux->days)); if ($aux->days == 2) { $message = new YiiMailMessage(); $message->view = '48hours_sugerencia'; $message->setBody(array("suggestion" => $suggestion), 'text/html'); $message->setSubject('¿Le ofrecieron la información requerida de la sugerencia solicitada.?. Trabajamos para ofrecerle un mejor servicio.'); $message->addTo($suggestion->client->email); $message->from = Yii::app()->params['adminEmail']; if (Yii::app()->mail->send($message)) { $suggestion->review = "YES"; $suggestion->save(); } } } $replacements = Replacement::model()->findAllByAttributes(array('review' => 'NO')); foreach ($replacements as $replacement) { // $datequotation=date("Y-m-d",$quotation->registration_date); $datequotation1 = new DateTime($replacement->creation_date); $aux = date_diff($datenow1, $datequotation1); //die(print_r($datequotation1)); //die(print_r($aux->days)); if ($aux->days == 2) { $message = new YiiMailMessage(); $message->view = '48hours_repuesto'; $message->setBody(array("replacement" => $replacement), 'text/html'); $message->setSubject('¿Le ofrecieron la información requerida del repuesto Nissan solicitado?. Trabajamos para ofrecerle un mejor servicio.'); $message->addTo($replacement->client->email); $message->from = Yii::app()->params['adminEmail']; if (Yii::app()->mail->send($message)) { $replacement->review = "YES"; $replacement->save(); } } } $technicals = TechnicalDate::model()->findAllByAttributes(array('review' => 'NO')); foreach ($technicals as $technical) { // $datequotation=date("Y-m-d",$quotation->registration_date); $datequotation1 = new DateTime($technical->creation_date); $aux = date_diff($datenow1, $datequotation1); //die(print_r($datequotation1)); //die(print_r($aux->days)); if ($aux->days == 2) { $message = new YiiMailMessage(); $message->view = '48hours_agendamiento'; $message->setBody(array("technical" => $technical), 'text/html'); $message->setSubject('Nos interesa servirle mejor.'); $message->addTo($technical->client->email); $message->from = Yii::app()->params['adminEmail']; if (Yii::app()->mail->send($message)) { $technical->review = "YES"; $technical->save(); } } } }
public function actionSendFromQuotationBillToBillSale() { $this->checkLogin(); $quotation_id = (int) $_POST['quotation_id']; $vat_price = $_POST['vat_price']; $quotation = Quotation::model()->findByPk((int) $quotation_id); if (!empty($quotation)) { $billSale = BillSale::model()->findByAttributes(array('quotation_id' => $quotation_id)); if (empty($billSale)) { $user_id = Yii::app()->request->cookies['user_id']->value; $user = User::model()->findByPk($user_id); // // create bill_sale // $billSale = new BillSale(); $billSale->quotation_id = $quotation_id; $billSale->sale_type = 'sale'; $billSale->bill_sale_pay_date = new CDbExpression('NOW()'); $billSale->branch_id = $user->branch_id; $billSale->user_id = $user_id; $billSale->member_id = 0; $billSale->bill_sale_status = 'pay'; $billSale->bill_sale_created_date = new CDbExpression('NOW()'); if ($quotation->vat > 0) { $vat_price = str_replace(',', '', $vat_price); $billSale->vat_type = 'out'; $billSale->out_vat = $vat_price; $billSale->bill_sale_vat = 'vat'; $billSale->vat_percen = $quotation->vat; } if ($billSale->save()) { // // read from quotation and transfer to tb_bill_sale_detail // $quotationDetails = QuotationDetail::model()->findAllByAttributes(array('quotation_id' => $quotation_id)); foreach ($quotationDetails as $quotationDetail) { $billSaleDetail = new BillSaleDetail(); $billSaleDetail->bill_id = $billSale->bill_sale_id; $billSaleDetail->bill_sale_detail_barcode = $quotationDetail->barcode; $billSaleDetail->bill_sale_detail_price = $quotationDetail->old_price; $billSaleDetail->bill_sale_detail_qty = $quotationDetail->qty; $billSaleDetail->sub = $quotationDetail->sub; $billSaleDetail->quotation_detail_id = $quotationDetail->id; $billSaleDetail->save(); } echo $billSale->bill_sale_id; } } else { echo $billSale->bill_sale_id; } } }
public function actionFindQuotationById($id) { $quotation = Quotation::model()->findByPk((int) $id); echo CJSON::encode($quotation); }