ria/application/controllers/companycontroller.php
venbatechnologies@gmail.com 3dda02f2a0 QAD files merged in resico
2017-12-09 18:15:28 +05:30

318 lines
9.6 KiB
PHP

<?php if(!defined('BASEPATH')) exit('No direct script access allowed');
require APPPATH . '/libraries/BaseController.php';
/**
* Class : companycontroller (Company Details - Controller)
* companycontoller Class to control all company details related operations.
* @author :Venba Info Tech - Gandhimathi
* @version : 1.1
* @since : 18 November 2017
*/
class companycontroller extends BaseController
{
/**
* default constructor of the class
*/
public function __construct()
{
parent::__construct();
$this->load->model('companydetailsmodel');
$this->isLoggedIn();
}
/**
* default function of the companycontroller
*/
public function index()
{
$this->global['pageTitle'] = 'Resico : Company Details';
//$this->loadViews("companyadd", $this->global, NULL , NULL);
//$this->loadViews("Updatecompany", $this->global,NULL,NULL);
}
/**
* To load update company
*/
public function companyview()
{
$this->global['pageTitle'] = 'Resico : Company Details';
$data['userRecords'] = $this->companydetailsmodel->companylisting();
$data['payment'] = $this->companydetailsmodel->getPaymentTerms();
$data['filenames']=$this->companydetailsmodel->filelist();
$data['bankdetails']=$this->companydetailsmodel->getBankDetails();
$data['filetype']=$this->companydetailsmodel->getfilename();
$this->loadViews("companyview", $this->global,$data, NULL);
}
/**
* To add and update the bank details
*/
public function bankdtl()
{
$id = $this->input->post('id');
$tablevalue = json_decode($id,true);
foreach($tablevalue as $tv)
{
$bankname = $tv['BankName'];
$ifsccode = $tv['IFSC'];
$bankaddress = $tv['BankAddress'];
$bankaccno = $tv['BankAccountNumber'];
$bankstate = $tv['IsActive'];
if(strtoupper($bankstate) == 'YES' )
{
$isactive = 1;
}
else{
$isactive = 0;
}
$Bank = array('Bank_name'=>$bankname,'IFSC'=>$ifsccode,'Address'=>$bankaddress,'Is_Active'=>$isactive,'Bank_Accno'=>$bankaccno);
$result = $this->companydetailsmodel->BankDetails($Bank);
}
}
/**
* To load add company
*
* Note : this function Temporary not in use
*/
function companyadd(){
$this->global['pageTitle'] = 'Resico : Company Details';
$this->loadViews("companyadd", $this->global, NULL);
}
/**
* To add company revalant files
*/
function add()
{
$picture = '';
if(!empty($_FILES['photo']['name']))
{
$config['upload_path'] = 'uploads/images/';
$config['allowed_types'] = 'jpg|jpeg|png|gif';
$config['file_name'] = $_FILES['photo']['name'];
//Load upload library and initialize configuration
$this->load->library('upload',$config);
$this->upload->initialize($config);
if($this->upload->do_upload('photo'))
{
$uploadData = $this->upload->data();
$picture = $uploadData['file_name'];
}
else
{
$error = array('error' => $this->upload->display_errors());
$picture = '';
}
}
else
{
$picture = '';
}
return $picture ;
}
/**
* To Edit company revalant Images
*/
function editimage($ModifyPictureName)
{
if(!empty($_FILES['photo']['name']))
{
$config['upload_path'] = 'uploads/images/';
$config['allowed_types'] = 'jpg|jpeg|png|gif';
$config['file_name'] = $_FILES['photo']['name'];
//Load upload library and initialize configuration
$this->load->library('upload',$config);
$this->upload->initialize($config);
if($this->upload->do_upload('photo'))
{
$uploadData = $this->upload->data();
$picture = $uploadData['file_name'];
}
else
{
$error = array('error' => $this->upload->display_errors());
$picture = '';
}
}
else
{
$picture = '';
}
return $picture ;
}
/**
* To add company revalant files
*/
function addfile()
{
$file = '';
//Check whether user upload picture
if(!empty($_FILES['images']['name']))
{
$config['upload_path'] = 'uploads/files/';
$config['allowed_types'] = 'docx|pdf|doc|png|jpg';
$config['file_name'] = $_FILES['images']['name'];
//Load upload library and initialize configuration
$this->load->library('upload',$config);
$this->upload->initialize($config);
if($this->upload->do_upload('images'))
{
$uploadData = $this->upload->data();
$file = $uploadData['file_name'];
}
else
{
$error = array('error' => $this->upload->display_errors());
$file = '';
}
}
else
{
$file = '';
}
return $file ;
}
/**
* To check whether PAN already exist or not
*/
function checkPanValidate()
{
$PanNo = $this->input->post('panno');
$query = $this->supplier_model->checkPAN($PanNo);
if (count($query)> 0)
{
$this->form_validation->set_message('checkPanValidate', 'The Entered PAN Number is already exists in the Database.');
return false;
}
else
{
return true;
}
}
/**
* To delete company revalant files
*/
function deletefile()
{
$ID = $this->input->post('id');
$dt = new DateTime('now', new DateTimeZone('Asia/Kolkata'));
$updatedDate = $dt->format('Y-m-d H:i:s');
$userInfo = array('isDeleted'=>1);
$result = $this->companydetailsmodel->deletefile($ID, $userInfo);
echo 'Succssfully change the user status to InActive';
}
/**
* To edit exists Company details
*/
function UpdateCompany()
{
if($this->isAdmin() == TRUE)
{
$this->loadThis();
}
else
{
$PictureName = $this->input->post('Image');
$ModifyPictureName = $this->input->post('ModifyImage');
if ($PictureName != '')
{
if(strlen($ModifyPictureName) == 0)
{
$Picture = $PictureName;
}
else
{
$Picture = $this->add($ModifyPictureName);
}
}
else
{
$Picture = $this->add();
}
$file =$this->addfile();
$CompID = $this->input->post('CompanyID');
$CompanyName = $this->input->post('CompanyName');
$Address = $this->input->post('Address');
$ContactNumber = $this->input->post('ContactNumber');
$AlternateContactNumber = $this->input->post('AlternateContactNumber');
$EmailAddress = $this->input->post('EmailAddress');
$Exiseregistration = $this->input->post('Exiseregistration1');
$TIN = $this->input->post('TIN');
$PAN = $this->input->post('PAN');
$GSTNO = $this->input->post('GSTNO');
$GSTRange = $this->input->post('GSTRange');
$CollectrateAddress = $this->input->post('CollectrateAddress');
$UANumber = $this->input->post('UANumber');
$PaymentId = $this->input->post('paymentid');
$createdby = $this->session->userdata ( 'userId' );
$dt = new DateTime('now', new DateTimeZone('Asia/Kolkata'));
$createddt = $dt->format('Y-m-d H:i:s');
$updatedby = $this->session->userdata ( 'userId' );
$date = new DateTime('now', new DateTimeZone('Asia/Kolkata'));
$updateddt = $date->format('Y-m-d H:i:s');
$companywebsite = $this->input->post('companywebsite');
$filedescription1= $this->input->post('filedescription');
$date = new DateTime($this->input->post('financialstart'));
$financialstart = $date->format('Y-m-d H:i:s');
$date2 = new DateTime($this->input->post('financialend'));
$financialend = $date2->format('Y-m-d H:i:s');
$ID= $this->input->post('ID');
$Company = array('CompID'=>$CompID,'CompanyName'=>$CompanyName,'Address'=>$Address,'ContactNumber'=>$ContactNumber,'AlternateContactNumber'=>$AlternateContactNumber,'EmailAddress'=>$EmailAddress,'TIN'=>$TIN,'PAN'=>$PAN,'GSTNO'=>$GSTNO,'GSTRange'=>$GSTRange,'UANumber'=>$UANumber,'Createdby'=>$createdby,'ProfilePic'=>$Picture,'Exiseregistration'=>$Exiseregistration,'CollectrateAddress'=>$CollectrateAddress,'FiscalYearStartOn'=>$financialstart,'FiscalYearEndsOn'=> $financialend,'paymentID'=>$PaymentId,'companyWebsite'=>$companywebsite,'UpdatedBY'=>$updatedby,'Updatedon'=>$updateddt);
if(!empty($file))
{
$myfile = array('CompID'=>$CompID,'filename'=>$file,'ID'=>$ID,'filedescription'=>$filedescription1,'createdDate'=>$createddt);
$result2 = $this->companydetailsmodel->filedetails($myfile);
}
$result = $this->companydetailsmodel->Updatecompany($Company,$CompID);
if($result > 0)
{
echo "<script>alert('You Have Successfully updated the company Record!');</script>";
redirect('companyview','refresh');
}
}
}
}
?>