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 function run() { $suggestion_fake1 = array("email" => "test2", "active_principle" => "AAS", "suggestion" => "loreipsum lore ipsumm"); $suggestion_fake2 = array("email" => "test2", "active_principle" => "ACECLOFENACO", "suggestion" => "loreipsum lore ipsumm"); $suggestion_fake3 = array("email" => "test2", "active_principle" => "AGOMELATINA", "suggestion" => "loreipsum lore ipsumm. loreipsum lore ipsumm"); Suggestion::create($suggestion_fake1); Suggestion::create($suggestion_fake2); Suggestion::create($suggestion_fake3); }
function __construct() { parent::__construct(); $this->main_block_id = "mod_network_content_result"; $title = 'Manage Suggestions'; if (!Suggestion::content_type_exists()) { $title .= ' (not installed)'; } $this->title = __($title); }
public function delete() { $success = false; try { $suggestion = Suggestion::find(Input::get("id")); $suggestion->delete(); $success = true; $response = "Registro eliminado correctamente."; } catch (Exception $ex) { $response = "No se ha podido eliminar el registro seleccionado. " . $ex->getMessage(); } return Response::json(array("response" => $response, "success" => $success)); }
public static function toggleProcessed($id) { if (self::get_user_admin() == null) { Redirect::to('/home'); } $suggestion = Suggestion::find($id); if (!$suggestion->processed) { $suggestion->processed = 1; } else { $suggestion->processed = 0; } $suggestion->update(); Redirect::to('/suggestions', array('message' => 'Updated!')); }
public function actionSatisfaction($id) { $suggestion = Suggestion::model()->findByPk($id); $model = new SatisfactionS(); if (isset($_POST['SatisfactionS'])) { $model->attributes = $_POST['SatisfactionS']; $model->suggestion_id = $suggestion->id; if ($model->save()) { $sat = SatisfactionS::model()->findByPk($model->primaryKey); $message = new YiiMailMessage(); $message->view = 'encuesta_s'; $message->setBody(array("satisfaction" => $sat), 'text/html'); $message->setSubject('Satisfacción del Prospecto Web.'); if ($sat->score < 10) { $message->setSubject('Satisfacción del Prospecto Web.'); } if ($sat->contact == "NO") { $message->setSubject('Prospecto No Contactado'); } $aux1 = strstr($suggestion->type, '-'); $aux = substr($aux1, 1, 1); foreach ($suggestion->concessioner->emails as $email) { if ($email->type == "SUGGESTION-{$aux}") { $message->addTo($email->description); // $message->addTo('*****@*****.**'); if ($email->type == "SUGGESTION-O") { $message->addTo("*****@*****.**"); } $message->setFrom(array(Yii::app()->params['adminEmail'] => 'El Equipo Nissan Ecuador')); } } //$message->addTo("*****@*****.**"); $message->setFrom(array(Yii::app()->params['adminEmail'] => 'El Equipo Nissan Ecuador')); Yii::app()->mail->send($message); $this->render('satisfaction_finished', array('suggestion' => $suggestion)); } } else { if ($suggestion) { $this->render('satisfaction', array('model' => $model, 'suggestion' => $suggestion)); } } }
public function getRelevantSuggestions(Translator $translators, $from, $to) { $dbw = Database::getConnection(DB_MASTER); $lists = array(); $suggestions = array(); $res = $dbw->select('cx_lists', '*', array('cxl_type' => SuggestionList::TYPE_FEATURED, 'cxl_public' => true), __METHOD__); foreach ($res as $row) { $list = SuggestionList::newFromRow($row); $lists[$list->getId()] = $list; } if (count($lists)) { $conds = array('cxs_list_id' => array_keys($lists), 'cxs_source_language' => $from, 'cxs_target_language' => array($to, '*')); $options = array('LIMIT' => '10', 'ORDER BY' => 'RAND()'); $res = $dbw->select('cx_suggestions', '*', $conds, __METHOD__, $options); foreach ($res as $row) { $suggestions[] = Suggestion::newFromRow($row); } } return array('lists' => $lists, 'suggestions' => $suggestions); }
public function changeState($args) { $suggestion = new Suggestion($args->post['suggestion-id']); $suggestion->state = $args->post['suggestion-state']; switch ($suggestion->state) { case self::SUGGESTIONS_VOTING: $suggestion->votingstart = date('Y-m-d'); $suggestion->votingend = date('Y-m-d', time() + self::DURATION_VOTING); break; } $suggestion->update(true); }
// posting the bulletin to the community blog if ($_POST['tags']) { $tags = explode(',', $_POST['tags']); foreach ($tags as $term) { $tr = trim($term); if ($tr) { $terms[] = $tr; } } } try { $post_subject = "Network's owner bulletin - " . $_POST['title']; $post_message = $_POST['bulletin_body']; switch ($type) { case 'Suggestion': $res = Suggestion::save_suggestion(0, $from, $post_subject, $post_message, '', $terms, 0, $is_active = ACTIVE, $user->email); break; case 'BlogPost': $res = BlogPost::save_blogpost(0, $from, $post_subject, $post_message, '', $terms, 0, $is_active = ACTIVE, $user->email); break; } } catch (PAException $e) { $error_msg .= $e->message; } if (!empty($res['cid'])) { $content_obj = Content::load_content((int) $res['cid']); PANotify::send("content_posted_to_comm_blog", PA::$network_info, $user, $content_obj); } } if ($no_reg_user == TRUE) { $error_msg .= "No registered member in this network";
function route2groups() { global $user, $is_edit; $extra = unserialize(PA::$network_info->extra); $tags = preg_split('/\\s*,\\s*/', strtolower($_POST['tags'])); $tags = array_unique($tags); $net_owner = new User(); $net_owner->load((int) PA::$network_info->owner_id); $valid_post_types = array('BlogPost', 'Contribution', 'Suggestion'); $type = isset($_POST) && isset($_POST['blog_type']) && in_array($_POST['blog_type'], $valid_post_types) ? $_POST['blog_type'] : 'BlogPost'; //find tag entry $terms = array(); foreach ($tags as $term) { $tr = trim($term); if ($tr) { $terms[] = $tr; } } if (!empty($_POST['route_to_pa_home']) && $_POST['route_to_pa_home'] == 1) { $display_on_homepage = DISPLAY_ON_HOMEPAGE; //its zero } else { $display_on_homepage = NO_DISPLAY_ON_HOMEPAGE; //This will not show up on homepage - flag has opposite values } if (is_array($_POST['route_targets_group'])) { if (in_array(-2, $_POST['route_targets_group'])) { //-2 means Select none of group // no need to post in any group } elseif (in_array(-1, $_POST['route_targets_group'])) { //-1 means select all the groups // post in all the groups $group_array = explode(',', $_POST['Allgroups']); foreach ($group_array as $gid) { // post to all the groups $_group = Group::load_group_by_id((int) $gid); $login_required_str = null; if ($_group->access_type == ACCESS_PRIVATE) { $login_required_str = '&login_required=true'; } switch ($type) { case 'BlogPost': default: $res = BlogPost::save_blogpost(0, PA::$login_uid, $_POST['blog_title'], $_POST['description'], NULL, $terms, $gid, $is_active = 1, $display_on_homepage); break; case 'Contribution': $res = Contribution::save_contribution(0, PA::$login_uid, $_POST['blog_title'], $_POST['description'], NULL, $terms, $gid, $is_active = 1, $display_on_homepage); break; case 'Suggestion': $res = Suggetion::save_suggestion(0, PA::$login_uid, $_POST['blog_title'], $_POST['description'], NULL, $terms, $gid, $is_active = 1, $display_on_homepage); break; } $permalink_cid = $res['cid']; // NOTE: would this notification message be sent for each group ??? $content_obj = Content::load_content((int) $permalink_cid); PANotify::send("content_posted", PA::$network_info, $user, $content_obj); // notify network owner (maybe group owner would be better?) if ($display_on_homepage == DISPLAY_ON_HOMEPAGE) { PANotify::send("content_posted_to_comm_blog", PA::$network_info, $user, $content_obj); } //------- //for rivers of people $activity = 'group_post_a_blog'; $activity_extra['info'] = $user->first_name . 'posted a new blog'; $activity_extra['blog_name'] = $_POST["blog_title"]; $activity_extra['blog_id'] = $permalink_cid; $activity_extra['blog_url'] = PA::$url . PA_ROUTE_CONTENT . '/cid=' . $permalink_cid . $login_required_str; $extra = serialize($activity_extra); $object = $gid; // update status to unverified $group = ContentCollection::load_collection((int) $gid, PA::$login_uid); if ($group->reg_type == REG_MODERATED) { Network::moderate_network_content((int) $gid, $permalink_cid); } else { if ($extra['network_content_moderation'] == NET_YES && $is_edit == 0 && PA::$network_info->owner_id != $user->user_id) { Network::moderate_network_content($gid, $permalink_cid); } } if (!PA::is_moderated_content() && $group->reg_type != REG_MODERATED) { //Write to activity log only when moderation is off Activities::save($user->user_id, $activity, $object, $extra); } } } else { // post in selected groups foreach ($_POST['route_targets_group'] as $gid) { //only send to selected groups $_group = Group::load_group_by_id((int) $gid); $login_required_str = null; if ($_group->access_type == ACCESS_PRIVATE) { $login_required_str = '&login_required=true'; } switch ($type) { case 'BlogPost': default: $res = BlogPost::save_blogpost(0, PA::$login_uid, $_POST['blog_title'], $_POST['description'], NULL, $terms, $gid, $is_active = 1, $display_on_homepage); break; case 'Contribution': $res = Contribution::save_contribution(0, PA::$login_uid, $_POST['blog_title'], $_POST['description'], NULL, $terms, $gid, $is_active = 1, $display_on_homepage); break; case 'Suggestion': $res = Suggestion::save_suggestion(0, PA::$login_uid, $_POST['blog_title'], $_POST['description'], NULL, $terms, $gid, $is_active = 1, $display_on_homepage); break; } $permalink_cid = $res['cid']; $content_obj = Content::load_content((int) $permalink_cid); PANotify::send("content_posted", PA::$network_info, $user, $content_obj); // notify network owner (maybe group owner would be better?) if ($display_on_homepage == DISPLAY_ON_HOMEPAGE) { PANotify::send("content_posted_to_comm_blog", PA::$network_info, $user, $content_obj); } //for rivers of people $activity = 'group_post_a_blog'; $activity_extra['info'] = $user->first_name . 'posted a new blog'; $activity_extra['blog_name'] = $_POST["blog_title"]; $activity_extra['blog_id'] = $permalink_cid; $activity_extra['blog_url'] = PA::$url . PA_ROUTE_CONTENT . '/cid=' . $permalink_cid . $login_required_str; $extra = serialize($activity_extra); $object = $gid; // update status to unverified $group = ContentCollection::load_collection((int) $gid, PA::$login_uid); if ($group->reg_type == REG_MODERATED) { Network::moderate_network_content((int) $gid, $permalink_cid); } else { if ($extra['network_content_moderation'] == NET_YES && $is_edit == 0 && PA::$network_info->owner_id != $user->user_id) { Network::moderate_network_content($gid, $permalink_cid); } } if (!PA::is_moderated_content() && $group->reg_type != REG_MODERATED) { //Write to activity log only when moderation is off Activities::save($user->user_id, $activity, $object, $extra); } } } } return TRUE; }
public function sugerenciasPapelera() { $user_id = Auth::user()->id; $colonia = Session::get("colonia"); $urbanism = Urbanism::where('colony_id', '=', $colonia)->first(); $neighbor = Neighbors::where('user_id', '=', $user_id)->first(); $neighbors = NeighborProperty::with('Neighbors')->where('urbanism_id', '=', $urbanism->id)->where('neighbors_id', '!=', $neighbor->id)->get(); $breadcrumbs = Neighbors::where('user_id', '=', $user_id)->first(); $breadcrumbs_data = $breadcrumbs->name . " " . $breadcrumbs->last_name . " [ " . $urbanism->Colony->name . " ]"; $suggestions = Suggestion::where('user_id', '=', $user_id)->where('tray', '=', 0)->where('bd_inbox', '=', 1)->orderBy('created_at', 'desc')->paginate(10); $count = Suggestion::where('id_receptor', '=', $user_id)->where('tray', '<>', 0)->where('bd_inbox', '=', 2)->where('mark', '<>', 'read')->count(); return View::make('dashboard.colonies.suggestions.suggestions_trash', ['usuario' => $breadcrumbs_data, 'urbanism' => $urbanism, 'admin' => $neighbor->id, 'suggestions' => $suggestions, 'count' => $count, 'contador' => 1, 'neighbor' => $neighbor]); }
public function suggestion() { $user_id = Auth::user()->id; $colonia = Session::get("colonia"); $urbanism = Urbanism::where('colony_id', '=', $colonia)->first(); $neighbor = Neighbors::where('user_id', '=', $user_id)->first(); $neighbors = NeighborProperty::with('Neighbors')->where('urbanism_id', '=', $urbanism->id)->where('neighbors_id', '!=', $neighbor->id)->get(); $breadcrumbs = Neighbors::where('user_id', '=', $user_id)->first(); $breadcrumbs_data = $breadcrumbs->name . " " . $breadcrumbs->last_name . " [ " . $urbanism->Colony->name . " ]"; $suggestions = DB::table('suggestions')->select('suggestions.id', 'suggestions.user_id', 'neighbors.name', 'neighbors.last_name', 'suggestions.asunto', 'suggestions.contenido', 'suggestions.id_mensaje', 'suggestions.mark', 'suggestions.created_at')->join('neighbors', 'neighbors.user_id', '=', 'suggestions.user_id')->where('id_receptor', '=', $user_id)->where('tray', '<>', 0)->orderBy('created_at', 'desc')->paginate(10); $count = Suggestion::where('id_receptor', '=', $user_id)->where('tray', '<>', 0)->where('mark', '<>', 'read')->count(); $suggestionsSent = Suggestion::where('user_id', '=', $user_id)->where('tray', '<>', 0)->get(); return View::make('dashboard.colonies.suggestions.suggestion', ['usuario' => $breadcrumbs_data, 'urbanism' => $urbanism->id, 'admin' => $neighbor->id, 'suggestions' => $suggestions, 'count' => $count, 'suggestionsSent' => $suggestionsSent, 'contador' => 1]); }
if (isset($contribution_id) && isset($contribution_type)) { $res = Dal::query("INSERT INTO {cc_contributions} (content_id, contribution_id, type, title) VALUES (?, ?, ?, ?)", array(intval($post_saved['cid']), $contribution_id, $contribution_type, $contribution_title)); } if (!isset($query_args['title'])) { $query_args['title'] = $_POST["blog_title"]; } if (!isset($query_args['link'])) { $query_args['link'] = PA::$url . '/content/cid=' . $post_saved['cid']; } $redirect = $url_parts['scheme'] . '://' . $url_parts['host']; $redirect .= isset($url_parts['port']) && $url_parts['port'] != '' && $url_parts['port'] != '80' ? ':' . $url_parts['port'] : ''; $redirect .= $url_parts['path'] . '?' . http_build_query($query_args); } break; case 'Suggestion': $post_saved = Suggestion::save_suggestion(0, PA::$login_uid, $_POST["blog_title"], $_POST["description"], NULL, $terms, $ccid, 1, $display_on_homepage); break; } $permalink_cid = $post_saved['cid']; if (PA::is_moderated_content() && PA::$network_info->owner_id != $user->user_id) { Network::moderate_network_content(-1, $permalink_cid); // -1 for contents; not a part of any collection $error_msg = "&err=" . urlencode(MessagesHandler::get_message(1004)); } $login_required_str = null; if (PA::is_moderated_content()) { $login_required_str = '&login_required=true'; } $content_obj = Content::load_content((int) $permalink_cid); PANotify::send("content_posted", PA::$network_info, $user, $content_obj); if ($display_on_homepage == DISPLAY_ON_HOMEPAGE) {
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(); } } } }
<img src="{{asset('assets/index/images/templatemo_logo.png')}}" alt="logo" class="logo"> </a> <!--Navigation Itself--> <div class="navbar-content"> <!--Sidebar Toggler--> <a href="#" class="btn btn-default left-toggler" title="Panel"><i class="fa fa-bars"></i></a> <div class="btn-group" > <a href="#" class="btn btn-default " title="Sugerencias" id="modalEmail"><i class="entypo-mail"></i><!--<span class="new"></span>--></a> </div> <?php $user_id = Auth::user()->id; $suggestions = Suggestion::where('id_receptor', '=', $user_id)->where('tray', '<>', 0)->where('mark', '<>', 'read')->orderBy('created_at', 'desc')->get(); $count = Suggestion::where('id_receptor', '=', $user_id)->where('tray', '<>', 0)->where('mark', '<>', 'read')->count(); $expiration_license = LicenseExpiration::where('colony_id', '=', Session::get("colonia"))->first(); ?> <div class="btn-group"> <button type="button" title="Notificaciones" class="btn btn-default dropdown-toggle" data-toggle="dropdown"> <i class="entypo-megaphone"></i>@if($count > 0)<span class="new"></span>@endif</button> <div id="notification-dropdown" class="dropdown-menu"> <div class="dropdown-header">Notificaciones <span class="badge pull-right">{{ $count }}</span></div> <div class="dropdown-container"> <div class="nano"> <div class="nano-content"> <ul class="notification-dropdown"> @foreach($suggestions as $suggestion) <li class="bg-info"><a href="{{ URL::route('config.colony.suggestions.view',$suggestion->id_mensaje) }}"> <span class="notification-icon"><i class="fa fa-bolt"></i></span> <h4>{{ $suggestion->asunto }}</h4> <p>{{ $suggestion->contenido }}</p> <span class="label label-default"></span> </a>