public function save() { $colonia = Session::get('colonia'); $urbanism = Urbanism::where('colony_id', '=', $colonia)->first(); $user_id = Auth::user()->id; $bd_inbox = Input::get('bd_inbox'); $asunto = Input::get('asunto'); $contenido = Input::get('contenido'); $tray = Input::get('tray'); $status = Input::get('status'); $id_receptor = Input::get('id_receptor'); $admin = NeighborProperty::join('neighbors', 'neighbors.id', '=', 'neighbors_properties.neighbors_id')->join('assigned_roles', 'neighbors.user_id', '=', 'assigned_roles.user_id')->where('assigned_roles.colony_id', '=', $colonia)->where('urbanism_id', '=', $urbanism->id)->where('assigned_roles.role_id', '=', 2)->first(); $neighbor_id = Neighbors::where('user_id', '=', $user_id)->pluck('id'); $neighbor = NeighborProperty::with('Urbanism.Colony')->where('neighbors_id', '=', $neighbor_id)->get(); try { $sugerencia = new Suggestion(); $sugerencia->user_id = $user_id; $sugerencia->bd_inbox = $bd_inbox; $sugerencia->asunto = $asunto; $sugerencia->contenido = $contenido; $sugerencia->tray = $tray; $sugerencia->status = $status; $sugerencia->id_receptor = $admin->user_id; $sugerencia->id_mensaje = uniqid('msn'); $sugerencia->mark = 'unread'; $sugerencia->save(); return 1; } catch (Exception $exc) { return 0; } }
public static function save_suggestion($cid, $uid, $title, $body, $track, $tags, $ccid = 0, $is_active = 1, $display_on = 0, $is_default_content = FALSE) { // global var $path_prefix has been removed - please, use PA::$path static variable $errors = array(); // ensure integers here $cid = (int) $cid; $uid = (int) $uid; $ccid = (int) $ccid; // if a new post, make one, otherwise load the existing one if ($cid) { $post = Content::load_content($cid, $uid); // ignore $ccid passed to function if the post already exists // - we don't allow users to move posts between // ContentCollections. $ccid = (int) $post->parent_collection_id; } else { $post = new Suggestion(); $post->author_id = $uid; if ($ccid) { $post->parent_collection_id = $ccid; } } if ($ccid && $ccid != -1) { $g = ContentCollection::load_collection($ccid, $uid); $g->assert_user_access($uid); } else { $g = NULL; } $post->title = $title; $post->body = $body; $post->allow_comments = 1; $post->is_active = $is_active; $post->display_on = $display_on; $post->trackbacks = ''; if ($track) { $post->trackbacks = implode(",", $track); } $post->is_default_content = $is_default_content; $post->save(); //if ($tags) { Tag::add_tags_to_content($post->content_id, $tags); //} if ($track) { foreach ($track as $t) { if (!$post->send_trackback($t)) { $errors[] = array("code" => "trackback_failed", "msg" => "Failed to send trackback", "url" => $t); } } } if ($g && !$cid) { // new post - post it to the group as well $g->post_content($post->content_id, $uid); } if (!$cid) { // add to suggestion queue automatically if not editing ModerationQueue::moderate_suggestion($post->content_id); } return array("cid" => (int) $post->content_id, "moderation_required" => $g ? $g->is_moderated == 1 && $g->author_id != $uid : FALSE, "errors" => $errors); }
public function add() { $suggestion = new Suggestion(); $suggestion->user_id = $this->session->userdata('id'); $suggestion->text = $this->input->post('suggestion-body'); $suggestion->save(); // Redirect to view mode header('Location: /suggestions'); }
public static function store() { $params = $_POST; $suggestion = new Suggestion(array('creationtime' => null, 'description' => $params['description'], 'justification' => $params['justification'], 'processed' => null)); $errors = $suggestion->errors(); if (count($errors) == 0) { $suggestion->save(); View::make('suggestion_confirmation.html'); } else { View::make('suggestion.html', array('errors' => $errors, 'attributes' => $params)); } }
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)); } }