?
Current Path : /home1/savoy/public_html/savoyglobal.net/sgms/application/models/ |
Linux gator3171.hostgator.com 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64 |
Current File : /home1/savoy/public_html/savoyglobal.net/sgms/application/models/trainingmodel.php |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Trainingmodel extends CI_Model { function __construct() { // Call the Model constructor parent::__construct(); } /*Common function starts here*/ function add($postdata) { $data=array(); $data['resfunction']=$postdata['resfunction']; $table = $postdata['tab_name']; unset ($postdata['tab_name']); unset ($postdata['resfunction']); $res=$this->db->insert($table,$postdata); $cnt=$this->db->insert_id(); if($res>0) { $data['res']=1; $data['msg']='Record Added Successfully'; } else { $data['res']=0; $data['msg']='Error On Adding Record'; } return $data; } function update($postdata) { $data=array(); $data['resfunction']=$postdata['resfunction']; $table = $postdata['tab_name']; $field = $postdata['tab_field']; $id= $postdata['tab_id']; unset ($postdata['resfunction']); unset ($postdata['tab_name']); unset ($postdata['tab_field']); unset ($postdata['tab_id']); $this->db->where($field, $id); $res=$this->db->update($table,$postdata); if($res>0) { $data['res']=1; $data['msg']='Record Updated Successfully'; } else { $data['res']=0; $data['msg']='Error On updating Record'; } return $data; } /*Common function ends here*/ /*Search function starts here*/ function search_document($pagenum) { $data=array(); if($this->mastermodel->check_private()) { $flag=1; } else { $flag=0; } $this->db->from('document'); $postdata=$_SESSION['searchdata']; if(!empty($postdata)) { $searchtext=$postdata['searchtext']; $searchfield=$postdata['searchopt']; $this->db->like($searchfield, $searchtext); } $count= $this->db->count_all_results(); $arr=$this->fpaginate->paginate($pagenum,$count); $data['startpage']=$arr[0]; $data['endpage']=$arr[1]; $start=$arr[2]; $perpage=$arr[3]; $data['count']=$count; if(!empty($postdata)) { $searchtext=$postdata['searchtext']; $searchfield=$postdata['searchopt']; $this->db->like($searchfield, $searchtext); } $this->db->select('*'); $this->db->from('document'); $this->db->join('document_category','document_category.document_category_id=document.document_category_id'); if($flag==1) { $this->db->join('master','master.masterid=document.document_id'); $this->db->where('`master`.`owner_id` IN ('.$_SESSION['employees'].')', NULL, FALSE); } $this->db->limit($perpage, $start); $this->db->order_by('document_id','desc'); $data['results']=$this->db->get(); return $data; } function search_calendar($pagenum) { $data=array(); if($this->mastermodel->check_private()) { $flag=1; } else { $flag=0; } $this->db->from('calendar'); $postdata=$_SESSION['searchdata']; if(!empty($postdata)) { $searchtext=$postdata['searchtext']; $searchfield=$postdata['searchopt']; if($searchfield == 'event_start_date') { $searchtext=$this->mastermodel->convdatformat($searchtext); } $this->db->like($searchfield, $searchtext); } $count= $this->db->count_all_results(); $arr=$this->fpaginate->paginate($pagenum,$count); $data['startpage']=$arr[0]; $data['endpage']=$arr[1]; $start=$arr[2]; $perpage=$arr[3]; $data['count']=$count; if(!empty($postdata)) { $searchtext=$postdata['searchtext']; $searchfield=$postdata['searchopt']; if($searchfield == 'event_start_date') { $searchtext=$this->mastermodel->convdatformat($searchtext); } $this->db->like($searchfield, $searchtext); } $this->db->select('*'); $this->db->from('calendar'); if($flag==1) { $this->db->join('master','master.masterid=calendar.event_id'); $this->db->where('`master`.`owner_id` IN ('.$_SESSION['employees'].')', NULL, FALSE); } $this->db->limit($perpage, $start); $this->db->order_by('event_start_date','desc'); $data['results']=$this->db->get(); return $data; } function search_training_proposal($pagenum) { $data=array(); if($this->mastermodel->check_private()) { $flag=1; } else { $flag=0; } $this->db->from('training_proposal'); $this->db->join('activity','activity.activity_id=training_proposal.activity_id'); $postdata=$_SESSION['searchdata']; if(!empty($postdata)) { $searchtext=$postdata['searchtext']; $searchfield=$postdata['searchopt']; if($searchfield == 'training_date') { $searchtext=$this->mastermodel->convdatformat($searchtext); } $this->db->like($searchfield, $searchtext); } $count= $this->db->count_all_results(); $arr=$this->fpaginate->paginate($pagenum,$count); $data['startpage']=$arr[0]; $data['endpage']=$arr[1]; $start=$arr[2]; $perpage=$arr[3]; $data['count']=$count; if(!empty($postdata)) { $searchtext=$postdata['searchtext']; $searchfield=$postdata['searchopt']; if($searchfield == 'training_date') { $searchtext=$this->mastermodel->convdatformat($searchtext); } $this->db->like($searchfield, $searchtext); } $this->db->select('*'); $this->db->from('training_proposal'); $this->db->join('activity','activity.activity_id=training_proposal.activity_id'); if($flag==1) { $this->db->join('master','master.masterid=training_proposal.training_id'); $this->db->where('`master`.`owner_id` IN ('.$_SESSION['employees'].')', NULL, FALSE); } $this->db->limit($perpage, $start); $this->db->order_by('training_id','desc'); $data['results']=$this->db->get(); return $data; } function search_quotation_training($pagenum) { $data=array(); if($this->mastermodel->check_private()) { $flag=1; } else { $flag=0; } $this->db->from('training_quotation'); $this->db->join('training_proposal_details','training_proposal_details.id=training_quotation.customer_training_id'); $this->db->join('training_proposal','training_proposal.training_id=training_proposal_details.training_id'); $this->db->join('customer','customer.customer_id=training_proposal_details.customer_id'); $this->db->join('activity','activity.activity_id=training_proposal.activity_id'); $postdata=$_SESSION['searchdata']; if(!empty($postdata)) { $searchtext=$postdata['searchtext']; $searchfield=$postdata['searchopt']; if($searchfield == 'quotation_date') { $searchtext=$this->mastermodel->convdatformat($searchtext); } $this->db->like($searchfield, $searchtext); } $count= $this->db->count_all_results(); $arr=$this->fpaginate->paginate($pagenum,$count); $data['startpage']=$arr[0]; $data['endpage']=$arr[1]; $start=$arr[2]; $perpage=$arr[3]; $data['count']=$count; if(!empty($postdata)) { $searchtext=$postdata['searchtext']; $searchfield=$postdata['searchopt']; if($searchfield == 'quotation_date') { $searchtext=$this->mastermodel->convdatformat($searchtext); } $this->db->like($searchfield, $searchtext); } $this->db->select('*'); $this->db->from('training_quotation'); $this->db->join('training_proposal_details','training_proposal_details.id=training_quotation.customer_training_id'); $this->db->join('training_proposal','training_proposal.training_id=training_proposal_details.training_id'); $this->db->join('customer','customer.customer_id=training_proposal_details.customer_id'); $this->db->join('activity','activity.activity_id=training_proposal.activity_id'); if($flag==1) { $this->db->join('master','master.masterid=training_quotation.training_quotation_id'); $this->db->where('`master`.`owner_id` IN ('.$_SESSION['employees'].')', NULL, FALSE); } $this->db->limit($perpage, $start); $this->db->order_by('training_quotation_id','desc'); $data['results']=$this->db->get(); return $data; } function search_registration_training($pagenum) { $data=array(); if($this->mastermodel->check_private()) { $flag=1; } else { $flag=0; } $this->db->from('training_registration'); $this->db->join('training_quotation','training_quotation.training_quotation_id=training_registration.training_quotation_id'); $this->db->join('training_proposal_details','training_proposal_details.id=training_quotation.customer_training_id'); $this->db->join('customer','customer.customer_id=training_proposal_details.customer_id'); $this->db->join('training_proposal','training_proposal.training_id=training_proposal_details.training_id'); $this->db->join('activity','activity.activity_id=training_proposal.activity_id'); $postdata=$_SESSION['searchdata']; if(!empty($postdata)) { $searchtext=$postdata['searchtext']; $searchfield=$postdata['searchopt']; if($searchfield == 'training_registration_date') { $searchtext=$this->mastermodel->convdatformat($searchtext); } $this->db->like($searchfield, $searchtext); } $count= $this->db->count_all_results(); $arr=$this->fpaginate->paginate($pagenum,$count); $data['startpage']=$arr[0]; $data['endpage']=$arr[1]; $start=$arr[2]; $perpage=$arr[3]; $data['count']=$count; if(!empty($postdata)) { $searchtext=$postdata['searchtext']; $searchfield=$postdata['searchopt']; if($searchfield == 'training_registration_date') { $searchtext=$this->mastermodel->convdatformat($searchtext); } $this->db->like($searchfield, $searchtext); } $this->db->select('*'); $this->db->from('training_registration'); $this->db->join('training_quotation','training_quotation.training_quotation_id=training_registration.training_quotation_id'); $this->db->join('training_proposal_details','training_proposal_details.id=training_quotation.customer_training_id'); $this->db->join('customer','customer.customer_id=training_proposal_details.customer_id'); $this->db->join('training_proposal','training_proposal.training_id=training_proposal_details.training_id'); $this->db->join('activity','activity.activity_id=training_proposal.activity_id'); if($flag==1) { $this->db->join('master','master.masterid=training_registration.training_registration_id'); $this->db->where('`master`.`owner_id` IN ('.$_SESSION['employees'].')', NULL, FALSE); } $this->db->limit($perpage, $start); $this->db->order_by('training_registration_id','desc'); $data['results']=$this->db->get(); return $data; } function search_cancellation_training($pagenum) { $data=array(); if($this->mastermodel->check_private()) { $flag=1; } else { $flag=0; } $this->db->from('training_cancellation'); $this->db->join('training_registration','training_registration.training_registration_id=training_cancellation.training_registration_id'); $this->db->join('training_quotation','training_quotation.training_quotation_id=training_registration.training_quotation_id'); $this->db->join('training_proposal_details','training_proposal_details.id=training_quotation.customer_training_id'); $this->db->join('customer','customer.customer_id=training_proposal_details.customer_id'); $this->db->join('training_proposal','training_proposal.training_id=training_proposal_details.training_id'); $this->db->join('activity','activity.activity_id=training_proposal.activity_id'); $postdata=$_SESSION['searchdata']; if(!empty($postdata)) { $searchtext=$postdata['searchtext']; $searchfield=$postdata['searchopt']; if($searchfield == 'training_registration_date') { $searchtext=$this->mastermodel->convdatformat($searchtext); } $this->db->like($searchfield, $searchtext); } $count= $this->db->count_all_results(); $arr=$this->fpaginate->paginate($pagenum,$count); $data['startpage']=$arr[0]; $data['endpage']=$arr[1]; $start=$arr[2]; $perpage=$arr[3]; $data['count']=$count; if(!empty($postdata)) { $searchtext=$postdata['searchtext']; $searchfield=$postdata['searchopt']; if($searchfield == 'training_registration_date') { $searchtext=$this->mastermodel->convdatformat($searchtext); } $this->db->like($searchfield, $searchtext); } $this->db->select('*'); $this->db->from('training_cancellation'); $this->db->join('training_registration','training_registration.training_registration_id=training_cancellation.training_registration_id'); $this->db->join('training_quotation','training_quotation.training_quotation_id=training_registration.training_quotation_id'); $this->db->join('training_proposal_details','training_proposal_details.id=training_quotation.customer_training_id'); $this->db->join('customer','customer.customer_id=training_proposal_details.customer_id'); $this->db->join('training_proposal','training_proposal.training_id=training_proposal_details.training_id'); $this->db->join('activity','activity.activity_id=training_proposal.activity_id'); if($flag==1) { $this->db->join('master','master.masterid=training_cancellation.training_cancellation_id'); $this->db->where('`master`.`owner_id` IN ('.$_SESSION['employees'].')', NULL, FALSE); } $this->db->limit($perpage, $start); $this->db->order_by('training_cancellation_id','desc'); $data['results']=$this->db->get(); return $data; } /*Search function ends here*/ /*Add function starts here*/ function insert_document($postdata) { $data=array(); $this->db->trans_begin(); $masterid = $this->mastermodel->insertmasterdata(); $tblValues=array('document_id'=>$masterid, 'document_category_id'=> $postdata['document_category_id'], 'document_name'=> $postdata['document_name'], 'description'=> $postdata['description'], 'file_path'=> $postdata['file_path']); $this->db->insert('document', $tblValues); $data['resfunction']='search_document'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res']=0; $data['msg']='Error On Adding Record'; return $data; } else { $this->db->trans_commit(); $data['res']=1; $data['msg']='Record Added Successfully'; return $data; } } function insert_event($postdata) { $data=array(); $this->db->trans_begin(); $startdate = $this->mastermodel->convertdateformat($postdata['event_start_date']); $enddate = $this->mastermodel->convertdateformat($postdata['event_end_date']); $masterid = $this->mastermodel->insertmasterdata(); $tblValues=array('event_id'=>$masterid, 'event_title'=> $postdata['event_title'], 'trainer_name'=> $postdata['trainer_name'], 'event_start_date'=> $startdate, 'event_end_date'=> $enddate, 'event_location'=> $postdata['event_location'], 'event_description'=> $postdata['event_description']); $this->db->insert('calendar', $tblValues); $data['resfunction']='search_calendar'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res']=0; $data['msg']='Error On Adding Record'; return $data; } else { $this->db->trans_commit(); $data['res']=1; $data['msg']='Record Added Successfully'; return $data; } } function insertcalevent($title,$start,$end) { $start_date=$this->mastermodel->convertdateformat($start); $end_date=$this->mastermodel->convertdateformat($end); $data=array(); $this->db->trans_begin(); $masterid = $this->mastermodel->insertmasterdata(); $tbl1Values=array( 'event_id'=>$masterid, 'event_title'=>$title, 'event_start_date'=>$start_date, 'event_end_date'=>$end_date); $this->db->insert('calendar', $tbl1Values); $data['resfunction']='search_calendar'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); return 0; } else { $this->db->trans_commit(); $data['res']=1; return $data; } } function insert_training_proposal($postdata) { $data=array(); $this->db->trans_begin(); $training_date = $this->mastermodel->convertdateformat($postdata['training_date']); $masterid = $this->mastermodel->insertmasterdata(); $tblValues=array('training_id'=>$masterid, 'training_title'=> $postdata['training_title'], 'training_date'=> $training_date, 'activity_id'=> $postdata['activity_id'], 'training_code'=> $postdata['training_code'], 'trainer'=> $postdata['trainer'], 'venue'=> $postdata['venue'], 'remarks'=> $postdata['remarks']); $this->db->insert('training_proposal', $tblValues); $i=1; while(isset($postdata['description'.$i])) { if($postdata['expense_category_id'.$i]!="") { $tblValues=array('training_proposal_id'=>$masterid, 'expense_category_id'=>$postdata['expense_category_id'.$i], 'amount'=>$postdata['amount'.$i], 'description'=>$postdata['description'.$i]); $this->db->insert('training_proposal_expense', $tblValues); } $i++; } $data['resfunction']='search_training_proposal'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res']=0; $data['msg']='Error On Adding Record'; return $data; } else { $this->db->trans_commit(); $data['res']=1; $data['msg']='Record Added Successfully'; return $data; } } function insert_training_proposal_customer($postdata) { $data=array(); $communication_date = $this->mastermodel->convertdateformat($postdata['communication_date']); $tblValues=array( 'training_id'=>$postdata['training_id'], 'customer_id'=>$postdata['customer_id'], 'communication_date'=>$communication_date, 'source_id'=>$postdata['source_id'], 'no_pax'=>$postdata['no_pax'], 'fee_head'=>$postdata['fee_head'], 'total'=>$postdata['total'], 'discount'=>$postdata['discount'], 'remarks'=>$postdata['remarks'], ); $this->db->insert('training_proposal_details', $tblValues); $data['resfunction']='search_training_proposal'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res']=0; $data['msg']='Error On Adding Record'; return $data; } else { $this->db->trans_commit(); $data['res']=1; $data['msg']='Record Added Successfully'; return $data; } } function insert_quotation_training($postdata) { $data=array(); $this->db->trans_begin(); $owner_id=$this->mastermodel->getsinglejoinedvalue('owner_id','master','training_proposal_details','masterid','customer_id','id',$postdata['customer_training_id']); $quotation_date = $this->mastermodel->convertdateformat($postdata['quotation_date']); $masterid = $this->mastermodel->insertmasterdata($owner_id); $tblValues=array('training_quotation_id'=>$masterid, 'customer_training_id'=>$postdata['customer_training_id'], 'quotation_code'=> $postdata['quotation_code'], 'quotation_date'=> $quotation_date, 'remarks'=>$postdata['remarks'], 'terms_conditions'=> $postdata['terms_conditions'] ); $this->db->insert('training_quotation', $tblValues); $tblValues=array( 'training_quotation_id'=>$masterid, 'description'=>$postdata['description'], 'no_pax'=>$postdata['no_pax'], 'fee_head'=>$postdata['fee_head'], 'total'=>$postdata['total'], 'discount'=>$postdata['discount']); $this->db->insert('training_quotation_details', $tblValues); $i=1; while(isset($postdata['participant_name'.$i])) { if($postdata['participant_name'.$i]!="") { $tblValues=array('training_quotation_id'=>$masterid, 'participant_name'=>$postdata['participant_name'.$i], 'participant_designation'=>$postdata['participant_designation'.$i]); $this->db->insert('training_quotation_participant', $tblValues); } $i++; } $data['resfunction']='search_quotation_training'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res']=0; $data['msg']='Error On Adding Record'; return $data; } else { $this->db->trans_commit(); $data['res']=1; $data['msg']='Record Added Successfully'; return $data; } } function insert_registration_training($postdata) { $data=array(); $this->db->trans_begin(); $customer_id=$this->mastermodel->getsinglejoinedvalue('customer_id','training_proposal_details','training_quotation','id','customer_training_id','training_quotation_id',$postdata['training_quotation_id']); $owner_id=$this->mastermodel->getSingleFieldValue('master','owner_id','masterid',$customer_id); $training_registration_date = $this->mastermodel->convertdateformat($postdata['training_registration_date']); $masterid = $this->mastermodel->insertmasterdata($owner_id); $tblValues=array('training_registration_id'=>$masterid, 'training_quotation_id'=> $postdata['training_quotation_id'], 'training_registration_date'=> $training_registration_date, 'remarks'=> $postdata['remarks'], 'terms_conditions'=> $postdata['terms_conditions'] ); $this->db->insert('training_registration', $tblValues); $tblValues=array( 'training_registration_id'=>$masterid, 'description'=>$postdata['description'], 'no_pax'=>$postdata['no_pax'], 'fee_head'=>$postdata['fee_head'], 'total'=>$postdata['total'], 'discount'=>$postdata['discount']); $this->db->insert('training_registration_details', $tblValues); $i=1; while(isset($postdata['participant_name'.$i])) { if($postdata['participant_name'.$i]!="") { $tblValues=array('training_registration_id'=>$masterid, 'participant_name'=>$postdata['participant_name'.$i], 'participant_designation'=>$postdata['participant_designation'.$i]); $this->db->insert('training_registration_participant', $tblValues); } $i++; } $data['training_registration_id']=$masterid; $data['resfunction']='search_registration_training'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res']=0; $data['msg']='Error On Adding Record'; return $data; } else { $this->db->trans_commit(); $data['res']=1; $data['msg']='Registration Details Added Successfully.. Please enter payment details'; return $data; } } function insert_cancellation_training($postdata) { $data=array(); $this->db->trans_begin(); if(isset($postdata['training_cancellation_id'])) { $refs=$this->mastermodel->get_data('refs_records',$postdata['training_cancellation_id'],'record_id'); if(count($refs) != 0) { foreach($refs as $list) { $ref_id=$list['ref_id']; $this->db->where('ref_id',$ref_id); $this->db->delete('gl_trans'); $this->db->where('ref_id',$ref_id); $this->db->delete('audit_trail'); $this->db->where('ref_id',$ref_id); $this->db->delete('refs'); } $this->db->where('training_cancellation_id',$postdata['training_cancellation_id']); $this->db->delete('training_cancellation'); $this->db->where('record_id',$postdata['training_cancellation_id']); $this->db->delete('refs_records'); } } $customer_training_id=$this->mastermodel->getsinglejoinedvalue('customer_training_id','training_quotation','training_registration','training_quotation_id','training_quotation_id','training_registration_id',$postdata['training_registration_id']); $owner_id=$this->mastermodel->getsinglejoinedvalue('owner_id','master','training_proposal_details','masterid','customer_id','id',$customer_training_id); $masterid = $this->mastermodel->insertmasterdata($owner_id); $tblValues=array('training_cancellation_id'=>$masterid, 'training_registration_id'=> $postdata['training_registration_id'], 'training_cancellation_code'=> $postdata['training_cancellation_code'], 'training_cancellation_date'=> $this->mastermodel->convertdateformat($postdata['training_cancellation_date']), 'training_cancellation_amount'=> $postdata['training_cancellation_amount'], 'remarks'=> $postdata['remarks']); $this->db->insert('training_cancellation', $tblValues); $reference_code= $this->accountingmodel->getreferencecode(5); $ref_id = $this->mastermodel->insertmasterdata(); $refdata=array('ref_id'=>$ref_id, 'ref_transaction_type_id'=>'5', 'ref_code'=>$reference_code); $this->db->insert('refs', $refdata); $refdata=array('ref_id'=>$ref_id, 'record_id'=>$masterid, 'type'=>'cancellation'); $this->db->insert('refs_records', $refdata); $fiscal_year_id=$this->mastermodel->getSingleFieldValue('company','fiscal_year_id','company_id','1'); $audittraildata=array('ref_id'=>$ref_id, 'transaction_date'=>date("Y-m-d"), 'fiscal_year'=>$fiscal_year_id, ); $this->db->insert('audit_trail', $audittraildata); $gldata=array('ref_id'=>$ref_id, 'transaction_date'=>date("Y-m-d"), 'account_code'=>$postdata['customer_account'], 'amount'=>-$postdata['training_cancellation_amount'], ); $this->db->insert('gl_trans', $gldata); $gldata=array('ref_id'=>$ref_id, 'transaction_date'=>date("Y-m-d"), 'account_code'=>$postdata['project_account'], 'amount'=>$postdata['training_cancellation_amount'], ); $this->db->insert('gl_trans', $gldata); $data['resfunction']='search_cancellation_training'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res']=0; $data['msg']='Error On Updating Record'; return $data; } else { $this->db->trans_commit(); $data['res']=1; $data['msg']='Cancellation details added'; return $data; } } /*Add function ends here*/ /*Update function starts here*/ function update_event($postdata) { $data=array(); $this->db->trans_begin(); $startdate = $this->mastermodel->convertdateformat($postdata['event_start_date']); $enddate = $this->mastermodel->convertdateformat($postdata['event_end_date']); $this->mastermodel->updatemasterdata($postdata['event_id']); $tblValues=array( 'event_title'=> $postdata['event_title'], 'trainer_name'=> $postdata['trainer_name'], 'event_start_date'=> $startdate, 'event_end_date'=> $enddate, 'event_location'=> $postdata['event_location'], 'event_description'=> $postdata['event_description']); $this->db->where('event_id', $postdata['event_id']); $this->db->update('calendar', $tblValues); $data['resfunction']='search_calendar'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res']=0; $data['msg']='Error On Updating Record'; return $data; } else { $this->db->trans_commit(); $data['res']=1; $data['msg']='Record Updated Successfully'; return $data; } } function update_document($postdata) { $data=array(); $this->db->trans_begin(); $this->mastermodel->updatemasterdata($postdata['document_id']); $tblValues=array( 'document_category_id'=> $postdata['document_category_id'], 'document_name'=> $postdata['document_name'], 'description'=> $postdata['description'], 'file_path'=> $postdata['file_path']); $this->db->where('document_id', $postdata['document_id']); $this->db->update('document', $tblValues); if($postdata['file_path']!='') { $tblValues=array( 'file_path'=>$postdata['file_path']); $this->db->where('document_id', $postdata['document_id']); $this->db->update('document', $tblValues); } $data['resfunction']='search_document'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res']=0; $data['msg']='Error On Updating Record'; return $data; } else { $this->db->trans_commit(); $data['res']=1; $data['msg']='Record Updated Successfully'; return $data; } } function update_training_proposal($postdata) { $data=array(); $this->db->trans_begin(); $training_date = $this->mastermodel->convertdateformat($postdata['training_date']); $this->mastermodel->updatemasterdata($postdata['training_id']); $tblValues=array( 'training_title'=> $postdata['training_title'], 'training_date'=> $training_date, 'trainer'=> $postdata['trainer'], 'venue'=> $postdata['venue'], 'remarks'=> $postdata['remarks']); $this->db->where('training_id', $postdata['training_id']); $this->db->update('training_proposal', $tblValues); $this->db->where('training_proposal_id', $postdata['training_id']); $this->db->delete('training_proposal_expense'); $i=1; while(isset($postdata['expense_category_id'.$i])) { if($postdata['expense_category_id'.$i]!='') { $tblValues=array('training_proposal_id'=>$postdata['training_id'], 'expense_category_id'=>$postdata['expense_category_id'.$i], 'amount'=>$postdata['amount'.$i], 'description'=>$postdata['description'.$i]); $this->db->insert('training_proposal_expense', $tblValues); } $i++; } $data['resfunction']='search_training_proposal'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res']=0; $data['msg']='Error On Updating Record'; return $data; } else { $this->db->trans_commit(); $data['res']=1; $data['msg']='Record Updated Successfully'; return $data; } } function update_training_proposal_customer($postdata) { $data=array(); $communication_date = $this->mastermodel->convertdateformat($postdata['communication_date']); $tblValues=array( 'communication_date'=>$communication_date, 'source_id'=>$postdata['source_id'], 'no_pax'=>$postdata['no_pax'], 'fee_head'=>$postdata['fee_head'], 'discount'=>$postdata['discount'], 'total'=>$postdata['total'], 'remarks'=>$postdata['remarks'] ); $this->db->where('id', $postdata['id']); $this->db->update('training_proposal_details', $tblValues); // if($postdata['proposal_file_location']!='') // { // $tblValues=array( // 'proposal_file_location'=>$postdata['proposal_file_location'], // ); // $this->db->where('id', $postdata['id']); // $this->db->update('training_proposal_details', $tblValues); // } $data['resfunction']='search_training_proposal'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res']=0; $data['msg']='Error On Adding Record'; return $data; } else { $this->db->trans_commit(); $data['res']=1; $data['msg']='Record Updated Successfully'; return $data; } } function update_quotation_training($postdata) { $data=array(); $this->db->trans_begin(); $quotation_date = $this->mastermodel->convertdateformat($postdata['quotation_date']); $this->mastermodel->updatemasterdata($postdata['training_quotation_id']); $tblValues=array( 'quotation_date'=> $quotation_date, 'remarks'=>$postdata['remarks'], 'terms_conditions'=> $postdata['terms_conditions']); $this->db->where('training_quotation_id', $postdata['training_quotation_id']); $this->db->update('training_quotation', $tblValues); $tblValues=array( 'description'=>$postdata['description'], 'no_pax'=>$postdata['no_pax'], 'fee_head'=>$postdata['fee_head'], 'total'=>$postdata['total'], 'discount'=>$postdata['discount']); $this->db->where('training_quotation_id', $postdata['training_quotation_id']); $this->db->update('training_quotation_details', $tblValues); $this->db->where('training_quotation_id', $postdata['training_quotation_id']); $this->db->delete('training_quotation_participant'); $i=1; while(isset($postdata['participant_name'.$i])) { if($postdata['participant_name'.$i]!="") { $tblValues=array('training_quotation_id'=>$postdata['training_quotation_id'], 'participant_name'=>$postdata['participant_name'.$i], 'participant_designation'=>$postdata['participant_designation'.$i]); $this->db->insert('training_quotation_participant', $tblValues); } $i++; } $data['resfunction']='search_quotation_training'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res']=0; $data['msg']='Error On Updating Record'; return $data; } else { $this->db->trans_commit(); $data['res']=1; $data['msg']='Record Updated Successfully'; return $data; } } function update_registration_training($postdata) { $data=array(); $this->db->trans_begin(); $training_registration_date = $this->mastermodel->convertdateformat($postdata['training_registration_date']); $this->mastermodel->updatemasterdata($postdata['training_registration_id']); $tblValues=array( 'training_registration_date'=> $training_registration_date, 'remarks'=> $postdata['remarks'], 'terms_conditions'=> $postdata['terms_conditions']); $this->db->where('training_registration_id', $postdata['training_registration_id']); $this->db->update('training_registration', $tblValues); $tblValues=array( 'description'=>$postdata['description'], 'no_pax'=>$postdata['no_pax'], 'fee_head'=>$postdata['fee_head'], 'total'=>$postdata['total'], 'discount'=>$postdata['discount']); $this->db->where('training_registration_id', $postdata['training_registration_id']); $this->db->update('training_registration_details', $tblValues); $this->db->where('training_registration_id', $postdata['training_registration_id']); $this->db->delete('training_registration_participant'); $i=1; while(isset($postdata['participant_name'.$i])) { if($postdata['participant_name'.$i]!="") { $tblValues=array('training_registration_id'=>$postdata['training_registration_id'], 'participant_name'=>$postdata['participant_name'.$i], 'participant_designation'=>$postdata['participant_designation'.$i]); $this->db->insert('training_registration_participant', $tblValues); } $i++; } $data['resfunction']='search_registration_training'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res']=0; $data['msg']='Error On Updating Record'; return $data; } else { $this->db->trans_commit(); $data['res']=1; $data['msg']='Record Updated Successfully'; return $data; } } function update_registration_training_payment($postdata) { $data=array(); $this->db->trans_begin(); $refs=$this->mastermodel->get_data('refs_records',$postdata['training_registration_id'],'record_id'); if(count($refs) != 0) { foreach($refs as $list) { $ref_id=$list['ref_id']; $this->db->where('ref_id',$ref_id); $this->db->delete('gl_trans'); $this->db->where('ref_id',$ref_id); $this->db->delete('audit_trail'); $this->db->where('ref_id',$ref_id); $this->db->delete('refs'); } $this->db->where('training_registration_id',$postdata['training_registration_id']); $this->db->delete('training_registration_payment'); $this->db->where('record_id',$postdata['training_registration_id']); $this->db->delete('refs_records'); } $tblValues=array('training_registration_id'=> $postdata['training_registration_id'], 'payment_method'=> $postdata['payment_method'], 'amount'=> $postdata['amount']); $this->db->insert('training_registration_payment', $tblValues); $reference_code= $this->accountingmodel->getreferencecode(6); $ref_id = $this->mastermodel->insertmasterdata(); $refdata=array('ref_id'=>$ref_id, 'ref_transaction_type_id'=>'6', 'ref_code'=>$reference_code); $this->db->insert('refs', $refdata); $refdata=array('ref_id'=>$ref_id, 'record_id'=>$_POST['training_registration_id'], 'type'=>'registration'); $this->db->insert('refs_records', $refdata); $fiscal_year_id=$this->mastermodel->getSingleFieldValue('company','fiscal_year_id','company_id','1'); $audittraildata=array('ref_id'=>$ref_id, 'transaction_date'=>date("Y-m-d"), 'fiscal_year'=>$fiscal_year_id, ); $this->db->insert('audit_trail', $audittraildata); $gldata=array('ref_id'=>$ref_id, 'transaction_date'=>date("Y-m-d"), 'account_code'=>$postdata['customer_account'], 'amount'=>$postdata['amount'], ); $this->db->insert('gl_trans', $gldata); $gldata=array('ref_id'=>$ref_id, 'transaction_date'=>date("Y-m-d"), 'account_code'=>$postdata['project_account'], 'amount'=>-$postdata['amount'], ); $this->db->insert('gl_trans', $gldata); $data['resfunction']='search_registration_training'; if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $data['res']=0; $data['msg']='Error On Updating Record'; return $data; } else { $this->db->trans_commit(); $data['res']=1; $data['msg']='Payment Details Added Successfully'; return $data; } } function uploadfile($postdata) { $this->db->trans_begin(); $tbl1Values=array('training_id'=>$postdata['training_id'], 'file_name'=>$postdata['file_name'], 'file_location'=>$postdata['file_location']); $this->db->insert('training_proposal_file', $tbl1Values); $this->db->trans_commit(); } function get_registration_details($training_id) { $data = array(); $this->db->select('training_registration.training_registration_date,customer.customer_name,training_registration_details.no_pax,training_registration_details.fee_head,training_registration_details.discount,training_registration_details.total'); $this->db->where('training_proposal_details.training_id',$training_id); $this->db->join('training_quotation',"training_quotation.training_quotation_id=training_registration.training_quotation_id"); $this->db->join('training_proposal_details',"training_quotation.customer_training_id=training_proposal_details.id"); $this->db->join('customer',"customer.customer_id=training_proposal_details.customer_id"); $this->db->join('training_registration_details',"training_registration_details.training_registration_id=training_registration.training_registration_id"); $this->db->group_by('training_registration.training_registration_id'); $this->db->order_by('training_registration.training_registration_id','asc'); $Q=$this->db->get('training_registration'); if ($Q->num_rows() > 0) { foreach ($Q->result_array() as $row) { $data[] = $row; } } $Q->free_result(); return $data; } function get_participant_details($training_id) { $data = array(); $this->db->select('training_registration_participant.participant_name,training_registration_participant.participant_designation,customer.customer_name'); $this->db->where('training_proposal_details.training_id',$training_id); $this->db->join('training_registration',"training_registration.training_registration_id=training_registration_participant.training_registration_id"); $this->db->join('training_quotation',"training_quotation.training_quotation_id=training_registration.training_quotation_id"); $this->db->join('training_proposal_details',"training_quotation.customer_training_id=training_proposal_details.id"); $this->db->join('customer',"customer.customer_id=training_proposal_details.customer_id"); $this->db->join('training_registration_details',"training_registration_details.training_registration_id=training_registration.training_registration_id"); $this->db->group_by('training_registration_participant.id'); $this->db->order_by('training_registration.training_registration_id','asc'); $Q=$this->db->get('training_registration_participant'); if ($Q->num_rows() > 0) { foreach ($Q->result_array() as $row) { $data[] = $row; } } $Q->free_result(); return $data; } function get_proposal_details($training_id) { $data = array(); $sql =("SELECT training_proposal_details.* , IFNULL(`training_quotation`.`customer_training_id`,'9999999999999') as customer_training_id FROM (`training_proposal_details`) LEFT JOIN training_quotation ON `training_proposal_details`.`id` = `training_quotation`.`customer_training_id` where training_proposal_details.training_id = '$training_id' ORDER BY customer_training_id"); $Q=$this->db->query($sql); if ($Q->num_rows() > 0) { foreach ($Q->result_array() as $row) { $data[] = $row; } } $Q->free_result(); return $data; } /*Update function ends here*/ }