/** * add * * Carga la vista html para capturar y crear un miembro * * @access public * @author Guillermo Lucio <*****@*****.**> * @copyright * * @return void */ public function add() { if (!$this->auth->is_auth($this->router->class, CREATE)) { redirect("errores/no_authorized"); } $this->load->library('form_validation'); $param_view = array(); $errors = array(); if ($_POST) { $member = $this->input->post('member'); $contact = $this->input->post('contact'); $address = $this->input->post('address'); $member['type'] = MEMBER; $validate_empty_fields = array('first_name', 'last_name'); foreach ($validate_empty_fields as $field) { if (!$this->form_validation->required(trim($member[$field]))) { $errors[] = lang($field . '-empty'); } } // Validamos correo electronico $is_unique_email = $this->form_validation->is_unique(trim($member['email']), 'entities.email'); $is_valid_email = $this->form_validation->valid_email(trim($member['email'])); if ($is_unique_email and $is_valid_email) { $member['email'] = trim($member['email']); } else { // El correo ya existe, mandamos error $errors[] = !$is_valid_email ? lang('email-not-valid') : lang('email-not-unique'); } // Validamos el nombre de usuario $username = $member['username']; if ($username != '') { $username_unique = $this->form_validation->is_unique($username, 'entities.username'); } else { $username_unique = false; } if ($username_unique) { $member['username'] = $username; } else { // El nombre de usuario ya existe en nuestra base de datos $errors[] = $username != '' ? lang('username-not-unique') : lang('username-empty'); } // Verificamos que la clave y la confirmacion de la clave sean iguales $password = $member['password']; $password_confirmation = $this->input->post('password_confirmation'); if (isset($password) and $password != '' and $password == $password_confirmation) { $member['password'] = md5($password); } else { if ($password == '') { $errors[] = lang('password-empty'); } else { $errors[] = lang('password-confirmation-not-match'); } } if (count($errors) == 0) { //guardamos contacto $id_contact = $this->contact->save($contact); $member['id_contact'] = $id_contact; $member['breadcrumb'] = $this->session->id; //guardamos miembro con estatus registrado para que el active su cuenta $member['status_row'] = REGISTERED; $id_member = $this->entity->save($member); $address['id_entity'] = $id_member; //guardamos direccion $this->address->save($address); if ($id_member) { //creamos un token $this->load->model("Token_model", "token"); $this->load->model("Mailing_model", "mailing"); $token = array("id_entity" => $id_member, 'token' => md5(time()), 'expires_at' => add_days_to_date(date('Y-m-d H:i:s'), 7)); $this->token->save($token); //agregamos el token al miembro $member['token'] = $token; //mandar mail al correo del miembro para que active su cuenta $param_email = array('to' => $member['email'], 'from' => $this->config->item('noreply_email'), 'subject' => lang('activa_tu_cuenta'), 'msg' => $this->load->view('mailing/activa_cuenta', array('member' => $member), true)); $this->mailing->send($param_email); redirect('admin/member/show_list'); } } // echo '<pre>'. print_r($errors, true) .'</pre>'; $param_view['errors'] = $errors; } $param_header['title'] = lang('member_add'); $this->load->view('includes/header', $param_header); $param_menu['back_btn'] = base_url("admin/member"); $this->load->view('includes/menu-extended-' . strtolower(SUPERADMIN), $param_menu); $this->load->view('users/member/new', $param_view); $this->load->view('includes/footer'); }
public function get_guest_calendar_table($selected_date, $days_to_display, $status) { $start_date = format_date($selected_date, 'j'); $end_date = add_days_to_date($selected_date, $days_to_display); $calendar = array(); $rooms = get_all_rooms(); foreach ($rooms as $i => $r) { $calendar[get_the_title($r) . ':' . get_room_type($r)->post_title] = get_guest_calendar_by_room_ID($r, $selected_date, $end_date, $status); } $total_day = count_days_gap($selected_date, $end_date, $end_date); $end_date = minus_days_to_date($end_date, 1); $monthHTML = $dateHTML = $dayHTML = $tdHTML = $output = ''; $date = $selected_date; while (strtotime($date) <= strtotime($end_date)) { $monthHTML .= '<th colspan="' . ($date != $selected_date && $date != $end_date ? '2' : '') . '">' . format_date($date, 'M') . '</th>'; $dateHTML .= '<th colspan="' . ($date != $selected_date && $date != $end_date ? '2' : '') . '">' . format_date($date, 'j') . '</th>'; $dayHTML .= '<th colspan="' . ($date != $selected_date && $date != $end_date ? '2' : '') . '">' . format_date($date, 'D') . '</th>'; $date = add_days_to_date($date, 1); } $date = $selected_date; $tdHTML .= '<tr>'; while (strtotime($date) < strtotime($end_date)) { $tdHTML .= '<td colspan="2" class="' . strtolower(format_date($date, 'D')) . '"></td>'; $date = add_days_to_date($date, 1); } $tdHTML .= '</tr>'; $output .= '<table class="widefat">'; $output .= '<thead>'; $output .= '<tr>'; $output .= '<th width="10%"></th>'; $output .= $monthHTML; $output .= '</tr>'; $output .= '<tr>'; $output .= '<th width="10%"></th>'; $output .= $dateHTML; $output .= '</tr>'; $output .= '<tr>'; $output .= '<th width="10%"></th>'; $output .= $dayHTML; $output .= '</tr>'; $output .= '</thead>'; $output .= '<tbody>'; foreach ($calendar as $k => $c) { usort($c, function ($a, $b) { return strtotime($a['from']) - strtotime($b['from']); }); $output .= '<tr>'; $output .= '<td class="room">' . $k . '</td>'; $output .= '<td colspan="' . ($total_day * 2 - 2) . '" class="calendar_row">'; $output .= '<div class="row_data">'; $output .= '<div class="bg_row">'; $output .= '<table>'; $output .= '<tbody>'; $output .= $tdHTML; $output .= '</tbody>'; $output .= '</table>'; $output .= '</div>'; $output .= '<div class="bg-content">'; $output .= '<table>'; $output .= '<tbody>'; $b = $selected_date; foreach ($c as $indx => $cal) { if (strtotime($cal['from']) > strtotime($end_date) || strtotime($cal['from']) < strtotime($selected_date) && strtotime($cal['to']) < strtotime($selected_date)) { continue; } $cal['from'] = strtotime($cal['from']) < strtotime($selected_date) ? $selected_date : $cal['from']; if (($f = count_days_gap($b, $cal['from'], $end_date)) > 0) { $output .= '<td colspan="' . $f . '"></td>'; $b = add_days_to_date($b, $f); } $f = count_days_gap($cal['from'], $cal['to'], $end_date); if ($f != 0 && $indx < count($c)) { $output .= '<td class="not-available" colspan="' . $f . '"><div class="text bdr-tooltip ' . strtolower($cal['status']) . '" title="' . $cal['guest'] . ' : ' . format_date($cal['from']) . ' to ' . format_date($cal['to']) . '">' . $cal['guest'] . '</div></td>'; } $b = $cal['to'] > $end_date ? $end_date : $cal['to']; } if (strtotime($end_date) > strtotime($b) && ($f = count_days_gap($b, $end_date, $end_date)) > 0) { $output .= '<td colspan="' . $f . '"></td>'; } $output .= '</tbody>'; $output .= '</table>'; $output .= '</div>'; $output .= '</div>'; $output .= '</td>'; $output .= '</tr>'; } $output .= '</tbody>'; $output .= '</table>'; return $output; }