/** * This is the default 'index' action that is invoked * when an action is not explicitly requested by users. */ public function actionIndex() { $client = new Client(); $vehicle = new VehicleClient(); $technicaldate = new TechnicalDate(); $concessioners = Concessioner::model()->findAll(); $criteria = new CDbCriteria(); //$criteria->condition = 'id != 32 AND id != 33 AND id != 34 AND id != 36 AND id != 37 AND id != 38 AND id != 39 AND id != 40 AND id != 41 AND id != 42'; //$criteria->order=name; $criteria = new CDbCriteria(); //$criteria->condition = 'id != 36'; $criteria->order = "name"; $versions = VehicleVersion::model()->with('vehicle')->findAllbyAttributes(array(), $criteria); //$versions= VehicleVersion::model()->findAllbyAttributes(array('status'=>'ACTIVE'),$criteria); if (isset($_POST['ajax']) && $_POST['ajax'] === 'client-form') { echo CActiveForm::validate($client); Yii::app()->end(); } if (isset($_POST['siguiente'])) { // die("hola"); if (isset($_POST['Client']) && isset($_POST['TechnicalDate']) && isset($_POST['VehicleClient'])) { //die("hola"); $client = new Client(); $client->attributes = $_POST['Client']; $client->save(); $vehicle = new VehicleClient(); $vehicle->attributes = $_POST['VehicleClient']; $vehicle->save(); $technicaldate = new TechnicalDate(); $technicaldate->attributes = $_POST['TechnicalDate']; $technicaldate->client_id = $client->primaryKey; $technicaldate->vehicle_id = $vehicle->primaryKey; if ($technicaldate->save()) { $message = new YiiMailMessage(); $message->view = 'agendamiento'; $message->setSubject('Prospecto agendamiento de Cita'); $message->setBody(array("client" => $client, "vehicle" => $vehicle, "technicaldate" => $technicaldate), 'text/html'); $message->setFrom(array(Yii::app()->params['adminEmail'] => 'El Equipo Nissan Ecuador')); foreach ($technicaldate->concessioner->emails as $email) { if ($email->type == "TECHNICAL_DATE") { $message->addTo($email->description); } } //$message->addTo("*****@*****.**"); Yii::app()->mail->send($message); $this->render('result', array("client" => $client, "vehicle" => $vehicle, "technicaldate" => $technicaldate)); } else { $this->render('error'); } } //$this->render('index',array('concessioners'=>$concessioners,"client"=>$client,"vehicle"=>$vehicle,"technicaldate"=>$technicaldate)); } else { $this->render('index', array('concessioners' => $concessioners, "client" => $client, "vehicle" => $vehicle, "technicaldate" => $technicaldate, "versions" => $versions)); } }
public function actionDiagnostic() { $medio = "default"; if (isset($_GET["medio"])) { $medio = $_GET["medio"]; } $client = new Client(); $vehicle = new VehicleClient(); $replacement = new Replacement(); $criteria2 = new CDbCriteria(); //$criteria2->condition = 'id = 1 OR id = 2 OR id = 9 OR id = 10 OR id = 11 OR id = 13 OR id = 14 OR id= 15 OR id = 16'; $concessioners = Concessioner::model()->findAllbyAttributes(array(), $criteria2); $criteria = new CDbCriteria(); //$criteria->condition = 'id != 36'; $criteria->order = 'name'; $versions = VehicleVersion::model()->with('vehicle')->findAllbyAttributes(array(), $criteria); if (isset($_POST['ajax']) && $_POST['ajax'] === 'replacement-form') { echo CActiveForm::validate($client); Yii::app()->end(); } if (isset($_POST['siguiente'])) { if (isset($_POST['Client']) && isset($_POST['Replacement']) && isset($_POST['VehicleClient'])) { $client = new Client(); $client->attributes = $_POST['Client']; $client->save(); $vehicle = new VehicleClient(); $vehicle->attributes = $_POST['VehicleClient']; //die(print_r($vehicle->attributes)); $vehicle->kilometer = "1"; $vehicle->save(); $replacement = new Replacement(); $replacement->attributes = $_POST['Replacement']; $replacement->client_id = $client->primaryKey; $replacement->vehicle_id = $vehicle->primaryKey; if ($replacement->save()) { $rep = Replacement::model()->findByPk($replacement->primaryKey); $message = new YiiMailMessage(); $message->view = 'repuesto'; $message->setBody(array("replacement" => $rep), 'text/html'); $message->setSubject('Prospecto para repuesto'); foreach ($rep->concessioner->emails as $email) { if ($email->type == "REPLACEMENT") { $message->addTo($email->description); } } $message->addTo("*****@*****.**"); $message->addTo("*****@*****.**"); $message->addTo("*****@*****.**"); $message->addTo("*****@*****.**"); $message->setFrom(array(Yii::app()->params['adminEmail'] => 'El Equipo Nissan Ecuador')); Yii::app()->mail->send($message); $this->render('result', array("client" => $client, "vehicle" => $vehicle, "replacement" => $replacement)); } else { $this->render('error'); } } //$this->render('index',array('concessioners'=>$concessioners,"client"=>$client,"vehicle"=>$vehicle,"replacement"=>$replacement)); } else { $this->render('index_d', array('concessioners' => $concessioners, "client" => $client, "vehicle" => $vehicle, "replacement" => $replacement, "versions" => $versions, "medio" => $medio)); } }
public function actionIndex() { $medio = "default"; if (isset($_GET["medio"])) { $medio = $_GET["medio"]; } $client = new Client(); $vehicle = new VehicleClient(); $suggestion = new Suggestion(); $concessioners = Concessioner::model()->findAll(); $criteria = new CDbCriteria(); $criteria->order = "name"; $versions = VehicleVersion::model()->with('vehicle')->findAllbyAttributes(array(), $criteria); if (isset($_POST['ajax']) && $_POST['ajax'] === 'suggestion-form') { echo CActiveForm::validate($client); Yii::app()->end(); } if (isset($_POST['siguiente'])) { if (isset($_POST['Client']) && isset($_POST['Suggestion']) && isset($_POST['VehicleClient'])) { $client = new Client(); $client->attributes = $_POST['Client']; $client->preference_contact = "email"; $client->save(); $vehicle = new VehicleClient(); $vehicle->attributes = $_POST['VehicleClient']; $vehicle->kilometer = "1"; $vehicle->save(); $suggestion = new Suggestion(); $suggestion->attributes = $_POST['Suggestion']; $suggestion->type = $_POST['Suggestion']['type'] . "-" . $_POST['Suggestion']['type2']; $suggestion->client_id = $client->primaryKey; $suggestion->vehicle_id = $vehicle->primaryKey; //die(print_r($suggestion)); $aux = substr($_POST['Suggestion']['type2'], 0, 1); if ($suggestion->save()) { $message = new YiiMailMessage(); $message->setSubject('Sugerencia del Servicio.'); $message->view = 'sugerencia'; $message->setBody(array("client" => $client, "vehicle" => $vehicle, "suggestion" => $suggestion), 'text/html'); foreach ($suggestion->concessioner->emails as $email) { if ($email->type == "SUGGESTION-{$aux}") { $message->addTo($email->description); // $message->addTo('*****@*****.**'); // $message->addTo("*****@*****.**"); $message->addTo("*****@*****.**"); $message->addTo("*****@*****.**"); $message->addTo("*****@*****.**"); $message->addTo("*****@*****.**"); $message->addTo("*****@*****.**"); /*if($email->type=="SUGGESTION-O"){ $message->addTo("*****@*****.**"); }*/ $message->setFrom(array(Yii::app()->params['adminEmail'] => 'El Equipo Nissan Ecuador')); } } Yii::app()->mail->send($message); $this->render('result', array("client" => $client, "vehicle" => $vehicle, "suggestion" => $suggestion)); } else { $this->render('error'); } } //$this->render('index',array('concessioners'=>$concessioners,"client"=>$client,"vehicle"=>$vehicle,"suggestion"=>$suggestion)); } else { $this->render('index', array('concessioners' => $concessioners, "client" => $client, "vehicle" => $vehicle, "suggestion" => $suggestion, "versions" => $versions, "medio" => $medio)); } }