Ver Mensaje Individual
  #4 (permalink)  
Antiguo 14/09/2015, 14:34
Avatar de joseherran
joseherran
 
Fecha de Ingreso: septiembre-2015
Ubicación: cali valle
Mensajes: 23
Antigüedad: 8 años, 8 meses
Puntos: 0
Respuesta: formulario validación Jquery y ajax

continuacion del controlador

Código PHP:
Ver original
  1. //Validate sendmail
  2.             if ($this->contact_us_emails_m->insert($data['post'])) {
  3.                 // si estan separados por , mandamos los correos si no mandamos 1 solo                
  4.                 $id_email = $this->db->insert_id();
  5.                 $products_contact = $this->session->userdata('products_contact');
  6.  
  7.                 if (count($products_contact) > 0) {
  8.                     foreach ($products_contact as $item => $value) {
  9.                         $quote_array = array('id_product' => $item, 'id_email' => $id_email, 'pagina' => $products_contact[$item]['pagina']);
  10.                         $this->db->insert('contact_us_email_products', $quote_array);
  11.                     }
  12.                 }
  13.                 $array = array();
  14.                 $products = '';
  15.                 foreach ($products_contact AS $row => $value) {
  16.                     array_push($array, $row);
  17.                 }
  18.  
  19.  
  20.                 if (count($array) > 0) {
  21.                     $products = $this->db->select('pr.*')->from('products AS pr')->where_in('pr.id', $array)->get()->result();
  22.                 }
  23.                 $this->session->set_userdata(array('products_contact' => array()));
  24.  
  25.                 if (strpos($email, ',') !== false && !empty($emails) && count($emails) > 0) {
  26.                     foreach ($emails AS $row => $value) {
  27.                         $this->send_email_to_user($data['post'], $value, $products);
  28.                     }
  29.                 } else {
  30.                     $send = $this->send_email_to_user($data['post'], $email, $products);
  31.                 }
  32.  
  33.  
  34.                 if($send){
  35.                     $statusJson = '';
  36.                     $msgJson = 'Su mensaje ha sido enviado';
  37.                 }else{
  38.                     $statusJson = 'error';
  39.                     $msgJson = 'Error Mailing, Contact the Webmaster. x2020';
  40.                 }
  41.                
  42.             } else {
  43.                 $statusJson = 'error';
  44.                 $msgJson = 'Error Mailing, Contact the Webmaster';
  45.             }
  46.         } else {
  47.             $statusJson = 'error';
  48.             $msgJson = validation_errors();
  49.         }
  50.         echo json_encode(array('status' => $statusJson, 'msg' => $msgJson));
  51.     }
  52.  
  53.     public function detail($slug) {
  54.  
  55.         $return = $this->google_map_model->get_many_by('slug', $slug);
  56.         $return = $return[0];
  57.  
  58.         if (!$return)
  59.             redirect('google_maps');
  60.  
  61.         // Se convierten algunas variables necesarias para usar como slugs
  62.         $setter = array(
  63.             'image' => val_image($return->image),
  64.         );
  65.  
  66.         $google_map = array_merge((array) $return, $setter);
  67.  
  68.         $relation = $this->db->where('google_map_id', $google_map['id'])->get('google_maps_categories')->result();
  69.         $categories = array();
  70.         foreach ($relation as $item) {
  71.             $category = $this->google_map_category_model->get_many_by('id', $item->category_id);
  72.             $category = $category[0];
  73.             $categories[] = array(
  74.                 "title" => $category->title,
  75.                 "slug" => $category->slug
  76.             );
  77.         }
  78.  
  79.         // imagenes para slider
  80.         $images = $this->google_map_image_model->get_many_by('google_map_id', $google_map['id']);
  81.  
  82.         // datos para el mapa de google
  83.         // mandamos los puntos
  84.         $json_markers = json_encode(array(array($google_map['adress'] . ', Prueba-Cali', (double) $google_map['coordinate1'], (double) $google_map['coordinate2'])));
  85.  
  86.         // sacamos solo el nombre de la imagen
  87.         $imageTogoogle = str_replace(site_url() . 'uploads/default/' . $this->moduleName . '/', "", $google_map['image']);
  88.  
  89.         // mandamos los datos para el modal dentro del mapa
  90.         $json_info_content = json_encode(array(array('image' => $imageTogoogle, 'adress' => $google_map['adress'], 'title' => $google_map['name'], 'moduleName' => $this->moduleName, 'schedule' => $google_map['schedule'], 'description' => $google_map['description'])));
  91.  
  92.         $this->template
  93.                 ->append_js('module::google_maps.js')
  94.                 ->set('json_info_content', $json_info_content)
  95.                 ->set('json_markers', $json_markers)
  96.                 ->set('google_map', (object) $google_map)
  97.                 ->set('categories', $categories)
  98.                 ->set('images', $images)
  99.                 ->build('detail');
  100.     }