225 lines
8.2 KiB
PHP
225 lines
8.2 KiB
PHP
<?php
|
|
|
|
namespace App\Controllers;
|
|
|
|
use App\Controllers\BaseController;
|
|
|
|
use App\Models\Companydetails_model;
|
|
use App\Models\Supplier_model;
|
|
|
|
/**
|
|
* Module : Company
|
|
* Companycontroller Class to control all Company related operations.
|
|
* @author : Gandhimathi
|
|
* @version : 1.1
|
|
* @since : 07 Apr 2017
|
|
* @example : Revised at 15th april 2024
|
|
*/
|
|
class Companycontroller extends BaseController
|
|
{
|
|
protected $companydetailsmodel;
|
|
protected $supplier_model;
|
|
protected $session;
|
|
|
|
/**
|
|
* This is default constructor of the class
|
|
*/
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->companydetailsmodel = new Companydetails_model();
|
|
$this->supplier_model = new Supplier_model();
|
|
$this->session = session();
|
|
$this->isLoggedIn();
|
|
|
|
}
|
|
/**
|
|
* This function used to load the first screen of the user
|
|
*/
|
|
public function index()
|
|
{
|
|
|
|
$this->global['pageTitle'] = '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->request->getPost('id1');
|
|
//$ifsccode = $this->request->getPost('id2');
|
|
//$bankaddress = $this->request->getPost('id3');
|
|
//$isactive = $this->request->getPost('');
|
|
|
|
$id = $this->request->getPost('id');
|
|
$tablevalue = json_decode((string)$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'] = 'Company Details';
|
|
$this->loadViews("companyadd", $this->global, NULL);
|
|
}
|
|
|
|
|
|
function checkPanValidate()
|
|
{
|
|
$PanNo = $this->request->getPost('panno');
|
|
$query = $this->supplier_model->checkPAN($PanNo);
|
|
if (count($query) > 0) {
|
|
// $this->validator->setMessage('checkPanValidate', 'The Entered PAN Number is already exists in the Database.');
|
|
return false;
|
|
} else {
|
|
return true;
|
|
}
|
|
}
|
|
function deletefile()
|
|
{
|
|
|
|
$ID = $this->request->getPost('id');
|
|
|
|
$updatedDate = get_current_date_time();
|
|
$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->request->getPost('Image');
|
|
|
|
$ModifyPictureName = $this->request->getPost('ModifyImage');
|
|
$Picture = "";
|
|
$file = $this->request->getFile('ModifyImage');
|
|
|
|
|
|
if ($PictureName != '') {
|
|
if ($file !== null && $file->isValid() && !$file->hasMoved()) {
|
|
$path = ROOTPATH.'public/uploads/images/';
|
|
if(!is_dir($path)) { mkdir($path, 0777, true); }
|
|
$Picture = $file->getName();
|
|
$file->move($path,$Picture);
|
|
}else{
|
|
$Picture = $PictureName;
|
|
}
|
|
}
|
|
else {
|
|
if ($file !== null && $file->isValid() && !$file->hasMoved()) {
|
|
$path = ROOTPATH.'public/uploads/images/';
|
|
if(!is_dir($path)) { mkdir($path, 0777, true); }
|
|
$Picture = $file->getName();
|
|
$file->move($path,$Picture);
|
|
}
|
|
}
|
|
|
|
$CompID = $this->request->getPost('CompanyID');
|
|
$CompanyName = $this->request->getPost('CompanyName');
|
|
$Address = $this->request->getPost('Address');
|
|
$ContactNumber = $this->request->getPost('ContactNumber');
|
|
$AlternateContactNumber = $this->request->getPost('AlternateContactNumber');
|
|
$EmailAddress = $this->request->getPost('EmailAddress');
|
|
$Exiseregistration = $this->request->getPost('Exiseregistration1');
|
|
$TIN = $this->request->getPost('TIN');
|
|
$PAN = $this->request->getPost('PAN');
|
|
$MSME = $this->request->getPost('MSME');
|
|
$GSTNO = $this->request->getPost('GSTNO');
|
|
$GSTRange = $this->request->getPost('GSTRange');
|
|
$CollectrateAddress = $this->request->getPost('CollectrateAddress');
|
|
$UANumber = $this->request->getPost('UANumber');
|
|
$PaymentId = $this->request->getPost('paymentid');
|
|
//$Payment = $this->request->getPost('PaymentTerms');
|
|
//$PaymentDays = $this->request->getPost('PaymentDays');
|
|
//$PayableAT = $this->request->getPost('PayableAT');
|
|
$createdby = $this->session->get('userId');
|
|
$createddt = get_current_date_time();
|
|
$updatedby = $this->session->get('userId');
|
|
$updateddt = get_current_date_time();
|
|
//$UpdatedBY = $this->session->get ( 'Userid' );
|
|
//$companywebsite = $this->request->getPost('companywebsite');
|
|
//$ceoname = $this->request->getPost('ceoname');
|
|
//$mdname = $this->request->getPost('mdname');
|
|
//$companystartedon = $this->request->getPost('companystartedon');
|
|
//$partnerdetails = $this->request->getPost ('partnerdetails');
|
|
$companywebsite = $this->request->getPost('companywebsite');
|
|
//$ProfilePic = $this->request->getPost ('ProfilePic');
|
|
//$files = $this->request->getPost('files');
|
|
$filedescription1 = $this->request->getPost('filedescription');
|
|
//$files = $this->request->getPost('filename');
|
|
//$financialstart=$this->request->getPost('financialstart');
|
|
//$financialend=$this->request->getPost('financialend');
|
|
$date = $this->request->getPost('financialstart');
|
|
$financialstart = get_date_time_format($date);
|
|
|
|
$date2 = $this->request->getPost('financialend');
|
|
$financialend = get_date_time_format($date2);
|
|
|
|
$ID = $this->request->getPost('ID');
|
|
//$createdDate=$this->request->getPost('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, 'MSME' => $MSME , '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) {
|
|
$this->session->setFlashdata('success', 'You Have Successfully updated the company Record!');
|
|
}else{
|
|
$this->session->setFlashdata('error', 'Company Record Not Updated!');
|
|
}
|
|
return redirect()->route('companyview');
|
|
|
|
//}
|
|
}
|
|
}
|