?
Current Path : /home1/savoy/public_html/savoyglobal.net/rms/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/rms/application/models/projectmodel.php |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Projectmodel extends CI_Model { function __construct() { // Call the Model constructor parent::__construct(); } function search_project($pagenum) { $data=array(); $log_in_type=$_SESSION['login_type']; $this->db->select('*'); $this->db->from('project'); // $this->db->join('contracting_company','project_contractor_id=contracting_company.cc_id'); $this->db->join('master','master_id=project_id'); $this->db->where('master.login_type_id',$log_in_type); $this->db->order_by('project_id','desc'); $data['results']=$this->db->get(); return $data; } function insert_project($postdata) { $data=array(); $this->db->trans_begin(); $masterid = $this->mastermodel->insertmasterdata(); $code=$this->mastermodel->get_master_code('project','project','project_code','project_id'); $tblValues=array( 'project_id'=>$masterid, 'project_title'=>$postdata['project_title'], 'project_code'=> $code, 'project_location_risk'=>$postdata['project_location_risk'], 'project_contract_value'=>$postdata['project_contract_value'], 'project_start_date'=>$this->mastermodel->convertdateformat($postdata['project_start_date']), 'project_end_date'=>$this->mastermodel->convertdateformat($postdata['project_end_date']), 'project_bank_name'=>$postdata['project_bank_name'], 'project_consultant_name'=>$postdata['project_consultant_name'], 'project_municipality'=>$postdata['project_municipality'], 'project_kahrama'=>$postdata['project_kahrama'], 'project_civil_defence'=>$postdata['project_civil_defence'], 'project_qtel'=>$postdata['project_qtel'], ); $this->db->insert('project', $tblValues); $i=1; while(isset($postdata['project_contractor_id'.$i])) { if($postdata['project_contractor_id'.$i]!="") { $tblValues=array( 'project_id'=>$masterid, 'contracting_company_id'=>$postdata['project_contractor_id'.$i], 'scope_of_work'=>$postdata['scope_of_work'.$i], 'contracting_value'=>$postdata['contracting_value'.$i], 'paid_amount'=>$postdata['paid_amount'.$i], ); $this->db->insert('project_details',$tblValues); } $i++; } $data['resfunction']='search_project'; 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 update_project($postdata) { $data=array(); $this->db->trans_begin(); $this->mastermodel->updatemasterdata($postdata['project_id']); $tblValues=array( 'project_title'=>$postdata['project_title'], 'project_location_risk'=>$postdata['project_location_risk'], 'project_contract_value'=>$postdata['project_contract_value'], 'project_start_date'=>$this->mastermodel->convertdateformat($postdata['project_start_date']), 'project_end_date'=>$this->mastermodel->convertdateformat($postdata['project_end_date']), 'project_bank_name'=>$postdata['project_bank_name'], 'project_consultant_name'=>$postdata['project_consultant_name'], 'project_municipality'=>$postdata['project_municipality'], 'project_kahrama'=>$postdata['project_kahrama'], 'project_civil_defence'=>$postdata['project_civil_defence'], 'project_qtel'=>$postdata['project_qtel'], ); $this->db->where('project_id',$postdata['project_id']); $this->db->update('project', $tblValues); $this->db->where('project_id',$postdata['project_id']); $this->db->delete('project_details'); $i=1; while(isset($postdata['project_contractor_id'.$i])) { if($postdata['project_contractor_id'.$i]!="") { $tblValues=array( 'project_id'=>$postdata['project_id'], 'contracting_company_id'=>$postdata['project_contractor_id'.$i], 'scope_of_work'=>$postdata['scope_of_work'.$i], 'contracting_value'=>$postdata['contracting_value'.$i], 'paid_amount'=>$postdata['paid_amount'.$i], ); $this->db->insert('project_details',$tblValues); } $i++; } $data['resfunction']='search_project'; 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 search_project_payment($pagenum) { $data=array(); $log_in_type=$_SESSION['login_type']; $this->db->select('*'); $this->db->from('project_payment'); $this->db->join('master','master_id=project_payment_id'); $this->db->where('master.login_type_id',$log_in_type); $this->db->order_by('project_payment_id','desc'); $data['results']=$this->db->get(); return $data; } function insert_project_payment($postdata) { $data=array(); $this->db->trans_begin(); $masterid = $this->mastermodel->insertmasterdata(); $tblValues=array( 'project_payment_id'=>$masterid, 'project_id'=>$postdata['project_id'], 'project_payment_date'=>$this->mastermodel->convertdateformat($postdata['project_payment_date']), 'project_payment_amount'=>$postdata['project_payment_amount'], 'project_payment_type'=>$postdata['project_payment_type'], 'project_payment_remarks'=>$postdata['project_payment_remarks'], ); $this->db->insert('project_payment', $tblValues); $data['resfunction']='search_project_payment'; 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 update_project_payment($postdata) { $data=array(); $this->db->trans_begin(); $tblValues=array( 'project_payment_date'=>$this->mastermodel->convertdateformat($postdata['project_payment_date']), 'project_payment_amount'=>$postdata['project_payment_amount'], 'project_payment_type'=>$postdata['project_payment_type'], 'project_payment_remarks'=>$postdata['project_payment_remarks'], ); $this->db->where('project_payment_id',$postdata['project_payment_id']); $this->db->update('project_payment', $tblValues); $data['resfunction']='search_project_payment'; 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; } } }