Created
May 1, 2018 04:45
-
-
Save aguileraq/15d99a4727e7edf1ff0b4d54a934b84c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function createMemberPost(){ | |
if( $this->session->userdata("login",TRUE) ){ | |
$submit = $this->input->post('submit',TRUE); | |
//$upload = $this->upload(); | |
//echo json_encode($upload);die(); | |
$input_date = $this->input->post('admission_date'); | |
$date = (empty($this->input->post('admission_date')) ? date('Y-m-d H:i:s') : $this->input->post('admission_date')); | |
if( $this->input->is_ajax_request() ){ | |
if( $this->form_validation->run('create_member') === FALSE ){ | |
$errors = $this->form_validation->error_array(); | |
$data = array( | |
"response" => $errors, | |
"res" => "error" | |
); | |
}else{ | |
/*$config['upload_path'] = './uploads/images/'; | |
$config['remove_spaces'] = true; | |
$config['encrypt_name'] = true; | |
$config['allowed_types'] = 'gif|jpg|png|pdf|jpeg'; | |
$this->load->library('upload', $config); | |
if (!$this->upload->do_upload('picture')){ | |
echo json_encode(array('upload_error' => $this->upload->display_errors())); | |
//$this->set_flashdata('uploadError', $uploadError, $urlYouWantToReturn); | |
exit; | |
} | |
$image_info = $this->upload->data(); | |
$img_name = $image_info['file_name']; | |
//echo json_encode($file_name);die(); | |
if (!$this->upload->do_upload('curp')){ | |
echo json_encode(array('upload_error' => $this->upload->display_errors())); | |
//$this->set_flashdata('uploadError', $uploadError, $urlYouWantToReturn); | |
exit; | |
} | |
$pdf_info = $this->upload->data(); | |
$pdf_name = $pdf_info['file_name'];*/ | |
$base64file = base64_encode(file_get_contents(addslashes($_FILES["picture"]["tmp_name"]))); | |
$birthdate = $this->input->post("birthday_year")."-".$this->input->post("birthday_month")."-".$this->input->post("birthday_day"); | |
$discharge_date = $this->input->post("discharge_date_year")."-".$this->input->post("discharge_date_month")."-".$this->input->post("discharge_date_day"); | |
$values = array( | |
"name" => $this->input->post("name"), | |
"first_lastname" => $this->input->post("first_lastname"), | |
"second_lastname" => $this->input->post("second_lastname"), | |
"birthdate" => $birthdate, | |
"registration_number" => $this->input->post("registration_number"), | |
"rfc" => $this->input->post("rfc"), | |
"discharge_date" => $this->input->post("discharge_date"), | |
"discharge_place" => $this->input->post("discharge_place"), | |
"street" => $this->input->post("street"), | |
"number" => $this->input->post("number"), | |
"between_streets" => $this->input->post("between_streets"), | |
"suburb" => $this->input->post('suburb'), | |
"city" => $this->input->post('city'), | |
"zipcode" => $this->input->post('zipcode'), | |
"municipality" => $this->input->post('municipality'), | |
"phone" => $this->input->post('phone'), | |
"mobile" => $this->input->post('mobile'), | |
"additional_phone" => $this->input->post('additional_phone'), | |
"picture" => $base64file, | |
//"curp" => $pdf_name, | |
"created_at" => $date | |
); | |
//var_dump($this->input->post("speciality"));die; | |
$valuesB = array( | |
"rank_id" => (empty($this->input->post("rank")) ? NULL : intval($this->input->post("rank"))), | |
"service_id" => (empty($this->input->post("service")) ? NULL : intval($this->input->post("service"))), | |
"speciality_id" => (empty($this->input->post("speciality")) ? NULL : intval($this->input->post("speciality"))), | |
"subspeciality_id" => (empty($this->input->post("subspeciality")) ? NULL : intval($this->input->post("subspeciality"))), | |
"course_id" => (empty($this->input->post("course")) ? NULL : intval($this->input->post("course"))) | |
); | |
$array = '["member"]'; | |
$ret = $this->member_model->getAssignTypePayment($array); | |
$response = $this->member_model->addMilitaryUser($values,$valuesB,$ret); | |
//var_dump($response);exit(); | |
if( $response['status'] === TRUE ){ | |
$id = $this->db->insert_id(); | |
$data = array( | |
"res" => "success", | |
"response" => "Registro realizado.", | |
"pdf" => base_url("panel/asociados/descargar-contrato/".$response['id']), | |
"redirect" => base_url("/panel/asociados/alta/conyuge/referencia/".$response['id']) | |
); | |
}else{ | |
$data = array( | |
"res" => "error", | |
"response" => "Registro incorrecto." | |
); | |
} | |
} | |
echo json_encode($data, JSON_NUMERIC_CHECK); | |
}elseif ( $this->input->post('cancel') === "cancel" ){ | |
redirect(base_url("panel/principal"),"refresh"); | |
}else{ | |
show_404(); | |
} | |
}else{ | |
redirect(base_url(), "refresh"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment