327 lines
11 KiB
PHP
327 lines
11 KiB
PHP
<?php if(!defined('BASEPATH')) exit('No direct script access allowed');
|
|
|
|
require APPPATH . '/libraries/BaseController.php';
|
|
|
|
/**
|
|
* Class : Employee (Employee Controller)
|
|
* User Class to control all user related operations.
|
|
* @author : Gandhimathi
|
|
* @version : 1.1
|
|
* @since : 07 Apr 2017
|
|
*/
|
|
class companycontroller extends BaseController
|
|
{
|
|
/**
|
|
* This is default constructor of the class
|
|
*/
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->load->model('companydetailsmodel');
|
|
$this->isLoggedIn();
|
|
}
|
|
/**
|
|
* This function used to load the first screen of the user
|
|
*/
|
|
public function index()
|
|
{
|
|
$this->global['pageTitle'] = 'Siddharth : Company Details';
|
|
|
|
//$this->loadViews("companyadd", $this->global, NULL , NULL);
|
|
|
|
//$this->loadViews("Updatecompany", $this->global,NULL,NULL);
|
|
}
|
|
|
|
public function companyview()
|
|
{
|
|
$this->global['pageTitle'] = 'Siddharth : 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();
|
|
$data['filetype']=$this->companydetailsmodel->getfilename();
|
|
$this->loadViews("companyview", $this->global,$data, NULL);
|
|
}
|
|
|
|
/* this function used to add and update the bank details*/
|
|
public function bankdtl()
|
|
{
|
|
|
|
//$bankname = $this->input->post('id1');
|
|
//$ifsccode = $this->input->post('id2');
|
|
//$bankaddress = $this->input->post('id3');
|
|
//$isactive = $this->input->post('');
|
|
|
|
$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'];
|
|
//echo $bankstate;
|
|
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);
|
|
|
|
}
|
|
echo " Bank Details Successfully Saved !";
|
|
|
|
//$Bank = array('Bank_name'=>$bankname,'IFSC'=>$ifsccode,'Address'=>$bankaddress);
|
|
//$result = $this->companydetailsmodel->AddBankDetails($Bank);
|
|
|
|
|
|
}
|
|
|
|
|
|
function companyadd(){
|
|
|
|
$this->global['pageTitle'] = 'Siddharth : Company Details';
|
|
$this->loadViews("companyadd", $this->global, NULL);
|
|
}
|
|
|
|
|
|
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 ;
|
|
}
|
|
function editimage($ModifyPictureName)
|
|
{
|
|
//$picture = $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 ;
|
|
}
|
|
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 ;
|
|
}
|
|
|
|
|
|
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;
|
|
}
|
|
}
|
|
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';
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function UpdateCompany()
|
|
{
|
|
//die();
|
|
// $data['payment'] = $this->companydetailsmodel->getpayment();
|
|
// if($this->isAdmin() == TRUE)
|
|
// {
|
|
// $this->loadThis();
|
|
// }
|
|
// else
|
|
// {
|
|
|
|
|
|
$PictureName = $this->input->post('Image');
|
|
$ModifyPictureName = $this->input->post('ModifyImage');
|
|
if ($PictureName != '')
|
|
{ //echo 'Exists';
|
|
if(strlen($ModifyPictureName) == 0)
|
|
{
|
|
//echo 'Exists But Not replace';
|
|
$Picture = $PictureName;
|
|
}
|
|
else
|
|
{
|
|
//echo 'Exists But Replace';
|
|
//$Picture = $this->editimage($ModifyPictureName);
|
|
$Picture = $this->add($ModifyPictureName);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//echo 'Not Exists';
|
|
$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');
|
|
//$Payment = $this->input->post('PaymentTerms');
|
|
//$PaymentDays = $this->input->post('PaymentDays');
|
|
//$PayableAT = $this->input->post('PayableAT');
|
|
$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');
|
|
//$UpdatedBY = $this->session->userdata ( 'Userid' );
|
|
//$companywebsite = $this->input->post('companywebsite');
|
|
//$ceoname = $this->input->post('ceoname');
|
|
//$mdname = $this->input->post('mdname');
|
|
//$companystartedon = $this->input->post('companystartedon');
|
|
//$partnerdetails = $this->input->post ('partnerdetails');
|
|
$companywebsite = $this->input->post('companywebsite');
|
|
//$ProfilePic = $this->input->post ('ProfilePic');
|
|
//$files = $this->input->post('files');
|
|
$filedescription1= $this->input->post('filedescription');
|
|
//$files = $this->input->post('filename');
|
|
//$financialstart=$this->input->post('financialstart');
|
|
//$financialend=$this->input->post('financialend');
|
|
$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');
|
|
//$createdDate=$this->input->post('createdDate');
|
|
|
|
//$Company = array('CompID'=>$CompID,'CompanyName'=>$CompanyName,'Address'=>$Address,'ContactNumber'=>$ContactNumber,'AlternateContactNumber'=>$AlternateContactNumber,'EmailAddress'=>$EmailAddress,'TIN'=>$TIN,'PAN'=>$PAN,'GSTNO'=>$GSTNO,'GSTRange'=>$GSTRange,'UANumber'=>$UANumber,'PaymentTerms'=>$Payment ,'PaymentDays'=>$PaymentDays ,'PayableAT'=>$PayableAT ,'Createdby'=>$createdby,'ProfilePic'=>$Picture,'Exiseregistration'=>$Exiseregistration,'CollectrateAddress'=>$CollectrateAddress,'FiscalYearStartOn'=>$financialstart,'FiscalYearEndsOn'=> $financialend);
|
|
$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');
|
|
}
|
|
|
|
|
|
// redirect('companyview');
|
|
//}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
?>
|