PageRenderTime 27ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/application/models/cts_claim_note_preparation_model.php

https://gitlab.com/bipsahu/ptcs
PHP | 410 lines | 351 code | 31 blank | 28 comment | 22 complexity | 06c3ddae209aaf29b0fd219ec31ce496 MD5 | raw file
  1. <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  2. Class cts_claim_note_preparation_model extends CI_model
  3. {
  4. public function __construct(){
  5. parent::__construct();
  6. $config['upload_path'] = './uploads/';
  7. $config['allowed_types'] = 'gif|jpg|png|pdf|pptx|docx|doc|ppt';
  8. $config['max_size'] = '10000';
  9. $config['max_width'] = '10000';
  10. $config['max_height'] = '10000';
  11. $config['mailtype'] = 'html';
  12. $config['newline'] = "\r\n";
  13. $this->load->library('upload');
  14. $this->upload->initialize($config);
  15. }
  16. public function insert_claim_note_preparation_details($claim_id,$cn_status)
  17. {
  18. if($this->input->post('cn_prepared')!= null)
  19. {
  20. $data['cn_prepared'] = $this->input->post('cn_prepared');
  21. }
  22. $data['cn_prepared'] = $cn_status;
  23. $data['claim_id'] = $claim_id;
  24. $this->db->select('*');
  25. $this->db->where('claim_id',$claim_id);
  26. $cn_count = $this->db->get('claim_note_preparation')->num_rows();
  27. if($cn_count>=1){
  28. $this->db->where('claim_id',$claim_id);
  29. $result = $this->db->update('claim_note_preparation', $data);
  30. }
  31. else
  32. $result = $this->db->insert('claim_note_preparation', $data);
  33. if($this->db->_error_number()==1062)
  34. {
  35. return 0;
  36. }
  37. else
  38. {
  39. return $result;
  40. }
  41. }
  42. public function claim_note_checklist($claim_id)
  43. {
  44. if($this->input->post('claim_intimation_letter')=="on")
  45. {
  46. $data['claim_intimation_letter'] = '1';
  47. }
  48. else{
  49. $data['claim_intimation_letter'] = '0';
  50. }
  51. if($this->input->post('claim_form')=="on")
  52. {
  53. $data['claim_form'] = '1';
  54. }
  55. else{
  56. $data['claim_form'] = '0';
  57. }
  58. if($this->input->post('police_report')=="on")
  59. {
  60. $data['police_report'] = '1';
  61. }
  62. else{
  63. $data['police_report'] = '0';
  64. }
  65. if($this->input->post('license')=="on")
  66. {
  67. $data['license'] = '1';
  68. }
  69. else{
  70. $data['license'] = '0';
  71. }
  72. if($this->input->post('blue_book')=="on")
  73. {
  74. $data['blue_book'] = '1';
  75. }
  76. else{
  77. $data['blue_book'] = '0';
  78. }
  79. if($this->input->post('photographs')=="on")
  80. {
  81. $data['photographs'] = '1';
  82. }
  83. else{
  84. $data['photographs'] = '0';
  85. }
  86. if($this->input->post('invoice')=="on")
  87. {
  88. $data['invoice'] = '1';
  89. }
  90. else{
  91. $data['invoice'] = '0';
  92. }
  93. if($this->input->post('quotation')=="on")
  94. {
  95. $data['quotation'] = '1';
  96. }
  97. else{
  98. $data['quotation'] = '0';
  99. }
  100. if($this->input->post('vdc_reports')=="on")
  101. {
  102. $data['vdc_reports'] = '1';
  103. }
  104. else{
  105. $data['vdc_reports'] = '0';
  106. }
  107. if($this->input->post('survey_reports')=="on")
  108. {
  109. $data['survey_reports'] = '1';
  110. }
  111. else{
  112. $data['survey_reports'] = '0';
  113. }
  114. if($this->input->post('claim_access_amount'))
  115. {
  116. $data['claim_access_amount'] = $this->input->post('claim_access_amount');
  117. }
  118. if($this->input->post('surveyor_fee'))
  119. {
  120. $data['surveyor_fee'] = $this->input->post('surveyor_fee');
  121. }
  122. if($this->input->post('total_amount'))
  123. {
  124. $data['total_amount'] = $this->input->post('total_amount');
  125. }
  126. if($this->input->post('cnp_remarks'))
  127. {
  128. $data['cnp_remarks'] = $this->input->post('cnp_remarks');
  129. }
  130. $data['review_by'] = $this->session->userdata('user_id');
  131. //$data['claim_id'] = $claim_id;
  132. $this->db->select('*');
  133. $this->db->where('claim_id',$claim_id);
  134. $cn_count = $this->db->get('claim_note_preparation')->num_rows();
  135. if($cn_count>=1){
  136. $this->db->where('claim_id',$claim_id);
  137. $result = $this->db->update('claim_note_preparation', $data);
  138. }
  139. else
  140. $result = $this->db->insert('claim_note_preparation', $data);
  141. if($this->db->_error_number()==1062)
  142. {
  143. return 0;
  144. }
  145. else
  146. {
  147. return $result;
  148. }
  149. }
  150. public function insure_send_email(){
  151. $email_to = trim($this->input->post('email_address'));
  152. $email_cc = trim($this->input->post('email_cc'));
  153. $subject = $this->input->post('email_subject');
  154. $body = $this->input->post('email_body');
  155. //if($this->upload->do_multi_upload("email_attach")){
  156. //foreach($this->upload->get_multi_upload_data() as $multi_image){
  157. //$attachments[] = $multi_image['full_path'];
  158. //}
  159. //}
  160. //foreach($_FILES as $key=>$email_attach){
  161. //if($this->upload->do_upload('email_attach')){
  162. // $attachment[] = $upload_data['full_path'];
  163. //$this->email->attach($attachment[]);
  164. //}
  165. //}
  166. //if(isset($attachments)){
  167. //foreach($attachments as $attach){
  168. //$this->email->attach($attach);
  169. //}
  170. //}
  171. $count = count($_FILES['email_attach']['size']);
  172. foreach($_FILES as $key=>$value)
  173. for($s=0; $s<=$count-1; $s++) {
  174. $_FILES['userfile']['name']=$value['name'][$s];
  175. $_FILES['userfile']['type'] = $value['type'][$s];
  176. $_FILES['userfile']['tmp_name'] = $value['tmp_name'][$s];
  177. $_FILES['userfile']['error'] = $value['error'][$s];
  178. $_FILES['userfile']['size'] = $value['size'][$s];
  179. $config['upload_path'] = './uploads/';
  180. $config['allowed_types'] = 'gif|jpg|png';
  181. $config['max_size'] = '100';
  182. $config['max_width'] = '1024';
  183. $config['max_height'] = '768';
  184. $this->load->library('upload', $config);
  185. $this->upload->do_upload();
  186. $data = $this->upload->data();
  187. $name_array[] = $data['file_name'];
  188. $file_path = FCPATH.'uploads/'.$data['file_name'];
  189. $this->email->attach($file_path);
  190. }
  191. //$this->email->bcc('them@their-example.com');
  192. if(isset($email_cc))
  193. $this->email->cc($email_cc);
  194. $this->email->from('info@shikharinsurance.com', 'Shikhar Insurance');
  195. $this->email->to($email_to);
  196. $this->email->subject($subject);
  197. $this->email->message($body);
  198. //print_r($this->upload->display_errors());
  199. $this->email->set_mailtype("html");
  200. $this->email->send();
  201. $this->email->clear(TRUE);
  202. //echo $this->email->print_debugger();
  203. return true;
  204. }
  205. public function show_all_claim_note_preparation_details()
  206. {
  207. $this->db->group_by('claim_registration.claim_id');
  208. $this->db->select('*');
  209. $this->db->from('claim_registration');
  210. $this->db->join('surveyor_deportation', 'claim_registration.claim_id = surveyor_deportation.claim_id','left');
  211. $this->db->join('claim_note_preparation', 'claim_registration.claim_id = claim_note_preparation.claim_id','left');
  212. $this->db->join('insure', 'claim_registration.insure = insure.insure_name','left');
  213. $this->db->order_by("claim_registration.claim_id", "desc");
  214. $this->db->where('status','1');
  215. //$this->db->or_where('status',1);
  216. $result = $this->db->get();
  217. //$this->db->where('status', 1);
  218. //$this->db->update('claim_registration', array('status' => 2));
  219. return $result;
  220. }
  221. public function count_claim_note_preparation_details()
  222. {
  223. $this->db->group_by('claim_registration.claim_id');
  224. $this->db->select('*');
  225. $this->db->from('claim_registration');
  226. //$this->db->join('claim_note_preparation', 'claim_registration.claim_id = claim_note_preparation.claim_id');
  227. //$this->db->order_by("claim_note_preparation_id", "desc");
  228. $this->db->where('status','1');
  229. //$this->db->or_where('status',1);
  230. $result = $this->db->get()->num_rows();
  231. //$this->db->where('status', 1);
  232. //$this->db->update('claim_registration', array('status' => 2));
  233. return $result;
  234. }
  235. public function show_all_claim_note_preparation_details_for_claim()
  236. {
  237. $result = $this->db->get('claim_note_preparation');
  238. return $result->result_array();
  239. }
  240. public function get_details_of_claim_note_preparation_by_id ($claim_note_preparation_id)
  241. {
  242. $result = $this->db->get_where('claim_note_preparation', array('claim_note_preparation_id' => $claim_note_preparation_id));
  243. return $result->result_array();
  244. }
  245. public function delete_claim_note_preparation_by_id($claim_note_preparation_id)
  246. {
  247. $result = $this->db->delete('claim_note_preparation', array('claim_note_preparation_id' => $claim_note_preparation_id));
  248. return $result;
  249. }
  250. public function edit_claim_note_preparation_by_id($claim_note_preparation_id)
  251. {
  252. $data = array(
  253. 'egg_inoculation' => $this->input->post('egg_inoculation'),
  254. 'plate_aggluination' => $this->input->post('pa_result'),
  255. 'rapid_anitgen_test' => $this->input->post('rapid_anitgen_test'),
  256. 'negri_body' =>$this->input->post('negri_body'),
  257. 'penside_test' =>$this->input->post('penside_test'),
  258. 'ha' => $this->input->post('ha'),
  259. 'hi' => $this->input->post('hi'),
  260. 'cft' => $this->input->post('cft_result'),
  261. 'agid' => $this->input->post('agid_result'),
  262. 'elisa' => $this->input->post('elisa_result'),
  263. 'confirmative_diagnosis' => $this->input->post('cd_result'),
  264. 'fat' => $this->input->post('fat')
  265. );
  266. $this->db->where('claim_note_preparation_id',$claim_note_preparation_id);
  267. $result = $this->db->update('claim_note_preparation', $data);
  268. return $result;
  269. }
  270. public function check_new_customer()
  271. {
  272. $this->db->group_by('claim_registration.claim_id');
  273. $this->db->select('*');
  274. $this->db->from('claim_registration');
  275. $this->db->join('claim_note_preparation', 'claim_registration.claim_id = claim_note_preparation.claim_id');
  276. $this->db->order_by("claim_note_preparation_id", "desc");
  277. $this->db->where('status',0);
  278. $result = $this->db->get();
  279. $i = 0;
  280. $data_arr = array();
  281. foreach($result->result() as $row)
  282. {
  283. $data_arr[$i]["claim_note_preparation_id"] = $row->claim_note_preparation_id;
  284. $data_arr[$i]["labno"] = $row->labno;
  285. $data_arr[$i]["claim_id"] = $row->claim_id;
  286. $data_arr[$i]['customer_name'] = $row->customer_name;
  287. $data_arr[$i]['firm_name'] = $row->firm_name;
  288. $data_arr[$i]['animal'] = $row->animal;
  289. $data_arr[$i]['claim_type'] = $row->claim_type;
  290. $data_arr[$i]['no_of_claim'] = $row->no_of_claim;
  291. $data_arr[$i]['age'] = $row->age;
  292. $data_arr[$i]['sex'] = $row->sex;
  293. $data_arr[$i]['animal_type'] = $row->animal_type;
  294. $data_arr[$i]['species_type'] = $row->species_type;
  295. $data_arr[$i]['investigation_requested'] = $row->investigation_requested;
  296. $data_arr[$i]['egg_inoculation'] = $row->egg_inoculation;
  297. $data_arr[$i]['pa_result'] = $row->plate_aggluination;
  298. $data_arr[$i]['ha'] = $row->ha;
  299. $data_arr[$i]['hi'] = $row->hi;
  300. $data_arr[$i]['cft_result'] = $row->cft;
  301. $data_arr[$i]['agid_result'] = $row->agid;
  302. $data_arr[$i]['elisa_result'] = $row->elisa;
  303. $data_arr[$i]['cd_result'] = $row->confirmative_diagnosis;
  304. $this->db->where('claim_id',$row->claim_id);
  305. $this->db->update('claim_note_preparation',array('status'=>1));
  306. $i++;
  307. }
  308. echo json_encode($data_arr);
  309. }
  310. public function set_accept_on($claim_id)
  311. {
  312. $this->db->where('claim_id',$claim_id);
  313. $result = $this->db->update('claim_note_preparation',array('status' => 3));
  314. return $result;
  315. }
  316. public function search_pending_claim($offset)
  317. {
  318. $this->db->select('*');
  319. $this->db->from('claim_registration');
  320. $this->db->join('claim_note_preparation', 'claim_registration.claim_id = claim_note_preparation.claim_id');
  321. $this->db->order_by("claim_note_preparation_id", "desc");
  322. $this->db->where('status',5);
  323. $this->db->where('publish_bit',0);
  324. $data['count'] = $this->db->get()->num_rows();
  325. $query = $this->db->last_query();
  326. $offset = $offset*6;
  327. $data['result'] = $this->db->query($query.' LIMIT '.$offset.',6');
  328. return $data;
  329. }
  330. public function set_publish_on($claim_note_preparation_id)
  331. {
  332. $this->db->where('claim_note_preparation_id',$claim_note_preparation_id);
  333. $result = $this->db->update('claim_note_preparation',array('publish_bit' => 1));
  334. return $result;
  335. }
  336. public function search_on_progress_claim($offset)
  337. {
  338. $this->db->select('*');
  339. $this->db->from('claim_registration');
  340. $this->db->join('claim_note_preparation', 'claim_registration.claim_id = claim_note_preparation.claim_id');
  341. $this->db->order_by("claim_note_preparation_id", "desc");
  342. $this->db->where('status',3);
  343. $data['count'] = $this->db->get()->num_rows();
  344. $query = $this->db->last_query();
  345. $offset = $offset*6;
  346. $data['result'] = $this->db->query($query.' LIMIT '.$offset.',6');
  347. return $data;
  348. }
  349. public function set_completed_on($claim_note_preparation_id)
  350. {
  351. $this->db->where('claim_note_preparation_id',$claim_note_preparation_id);
  352. $result = $this->db->update('claim_note_preparation',array('status' => 4));
  353. return $result;
  354. }
  355. public function search_completed_claim($offset)
  356. {
  357. $this->db->select('*');
  358. $this->db->from('claim_registration');
  359. $this->db->join('claim_note_preparation', 'claim_registration.claim_id = claim_note_preparation.claim_id');
  360. $this->db->order_by("claim_note_preparation_id", "desc");
  361. $this->db->where('status',4);
  362. $this->db->or_where('status',5);
  363. $data['count'] = $this->db->get()->num_rows();
  364. $query = $this->db->last_query();
  365. $offset = $offset*6;
  366. $data['result'] = $this->db->query($query.' LIMIT '.$offset.',6');
  367. return $data;
  368. }
  369. public function generate_report($claim_note_preparation_id)
  370. {
  371. $this->db->select('*');
  372. $this->db->from('claim_registration');
  373. $this->db->join('claim_note_preparation', 'claim_registration.claim_id = claim_note_preparation.claim_id');
  374. $this->db->join('customer','claim_registration.customer_id = customer.cid');
  375. $this->db->where('claim_note_preparation_id',$claim_note_preparation_id);
  376. $result = $this->db->get();
  377. return $result;
  378. }
  379. }