diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 33bc631f..30f04bf9 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -74,6 +74,7 @@ $routes->get('exportcost', 'CostCenter::exportcost'); $routes->get('assetListing', 'Assetdetails::assetListing'); $routes->get('addasset', 'Assetdetails::addasset'); $routes->get('assetdetails/editOldasset', 'Assetdetails::editOldasset'); +$routes->post('assetdetails/getpodetails', 'Assetdetails::getpodetails'); // $routes->post('addNewasset', 'Assetdetails::addNewasset'); $routes->match(['GET', 'POST', 'PUT', 'DELETE'],'editOldasset', 'Assetdetails::editasset'); $routes->match(['GET', 'POST', 'PUT', 'DELETE'],'editOldasset/(:num)', 'Assetdetails::editasset/$1'); @@ -376,6 +377,7 @@ $routes->get('inprocess', 'Inprocess::index'); // Sales Controller $routes->get('sales_dashboard', 'Sales::sales_dashboard'); $routes->get('invoicedetails/ViewInvoice', 'Sales::ViewInvoice'); +$routes->get('getInvoiceAttachment', 'Sales::getInvoiceAttachments'); $routes->get('getInvoiceAttachments', 'Sales::getInvoiceAttachments'); $routes->get('deleteAttachment', 'Sales::deleteAttachment'); $routes->post('saveAttachment', 'Sales::saveAttachment'); diff --git a/app/Controllers/Employeedetails.php b/app/Controllers/Employeedetails.php index 0ab265e6..5769a066 100644 --- a/app/Controllers/Employeedetails.php +++ b/app/Controllers/Employeedetails.php @@ -201,11 +201,9 @@ class Employeedetails extends BaseController function AddNewEmployee() { - // print_r($this->request->getPost());die; - $photo = $this->request->getFile('photo'); $Picture = ""; - if(isset($photoan)){ + if (isset($photo)) { if ($photo->isValid() && !$photo->hasMoved()) { $uploadDir = ROOTPATH . 'public/uploads/images/'; $allowedTypes = ['jpg', 'jpeg', 'png', 'gif']; @@ -603,8 +601,7 @@ class Employeedetails extends BaseController /* To Update the employee details*/ function UpdateEmployee() { - // echo "
";
- // print_r($this->request->getPost());die;
+
$EmpId = $this->request->getPost('employeeid');
//$mail = $this->this->.post('emailid');
@@ -637,33 +634,43 @@ class Employeedetails extends BaseController
$ModifyPictureName = $this->request->getPost('ModifyImage');
$Picture = "";
if ($PictureName != '') {
+
//echo 'Exists';
//$Picture = $PictureName;
if (strlen((string)$ModifyPictureName) == 0) {
//echo 'Exists But Not replace';
$Picture = $PictureName;
} else {
+ // echo "";
+ // // print_r($this->request->getPost());
+ // print_r($this->request->getFile('photo'));
+ // die;
//echo 'Exists But Replace';
//$Picture = $ModifyPictureName;
//$Picture = $this->editimage($ModifyPictureName);
$photo = $this->request->getFile('ModifyImage');
- if ($photo->isValid() && !$photo->hasMoved()) {
- $uploadDir = ROOTPATH . 'public/uploads/images/';
- $allowedTypes = ['jpg', 'jpeg', 'png', 'gif'];
- if (in_array($photo->getExtension(), $allowedTypes)) {
- $newName = $photo->getRandomName();
- if (!is_dir($uploadDir)) {
- mkdir($uploadDir, 0777, true);
+ if (!$photo || !$photo->isValid()) {
+ $photo = $this->request->getFile('photo');
+ }
+ if (isset($photo)) {
+ if ($photo->isValid() && !$photo->hasMoved()) {
+ $uploadDir = ROOTPATH . 'public/uploads/images/';
+ $allowedTypes = ['jpg', 'jpeg', 'png', 'gif'];
+ if (in_array($photo->getExtension(), $allowedTypes)) {
+ $newName = $photo->getRandomName();
+ if (!is_dir($uploadDir)) {
+ mkdir($uploadDir, 0777, true);
+ }
+ $photo->move($uploadDir, $newName);
+ $Picture = $newName;
}
- $photo->move($uploadDir, $newName);
- $Picture = $newName;
}
}
}
} else {
//echo 'Not Exists';
$photo = $this->request->getFile('photo');
- if(isset($photo)){
+ if (isset($photo)) {
if ($photo->isValid() && !$photo->hasMoved()) {
$uploadDir = ROOTPATH . 'public/uploads/images/';
$allowedTypes = ['jpg', 'jpeg', 'png', 'gif'];
diff --git a/app/Controllers/Login.php b/app/Controllers/Login.php
index 410c9767..683ac74c 100644
--- a/app/Controllers/Login.php
+++ b/app/Controllers/Login.php
@@ -37,7 +37,9 @@ class Login extends BaseController
return view('login');
} else {
// redirect('/dashboard');
- return redirect()->to('/dashboard');
+ // return redirect()->to('/dashboard');
+ return redirect()->to('/sales_dashboard');
+
}
}
@@ -53,7 +55,9 @@ class Login extends BaseController
return view('login');
} else {
// return view('login');
- return redirect()->to('/dashboard');
+ // return redirect()->to('/dashboard');
+ return redirect()->to('/sales_dashboard');
+
}
}
@@ -107,9 +111,11 @@ class Login extends BaseController
$DEPCode = $res->DEPCode;
if ($DEPCode == SECURITY) {
- return redirect()->to(site_url('/dashboard'));
+ // return redirect()->to(site_url('/dashboard'));
+ return redirect()->to(site_url('/sales_dashboard'));
} else {
- return redirect()->to(site_url('/dashboard'));
+ return redirect()->to(site_url('/sales_dashboard'));
+ // return redirect()->to(site_url('/dashboard'));
}
}
} else {
diff --git a/app/Controllers/Sales.php b/app/Controllers/Sales.php
index 01c0cf1a..a7f60b98 100644
--- a/app/Controllers/Sales.php
+++ b/app/Controllers/Sales.php
@@ -5,18 +5,21 @@ namespace App\Controllers;
use App\Controllers\BaseController;
use App\Models\Ipinvoice_model;
+use App\Models\Ipattachment_model;
require_once 'vendor/autoload.php';
class Sales extends BaseController
{
protected $ipinvoice_model;
+ protected $ipattachment_model;
protected $session;
public function __construct()
{
parent::__construct();
$this->ipinvoice_model = new Ipinvoice_model();
+ $this->ipattachment_model = new Ipattachment_model();
$this->session = session();
$this->isLoggedIn();
}
@@ -91,8 +94,7 @@ class Sales extends BaseController
// Invoice Attachments
function getInvoiceAttachments(){
- $data['invoiceAttachment'] = $this->ipinvoice_model->getinvoiceAttachment($this->request->getGet('invoice_id'));
-
+ $data['invoiceAttachment'] = $this->ipinvoice_model->getinvoiceAttachment($this->request->getGet('invoice_number'));
return json_encode($data);
}
diff --git a/app/Controllers/User.php b/app/Controllers/User.php
index 34702d83..b0640664 100644
--- a/app/Controllers/User.php
+++ b/app/Controllers/User.php
@@ -14,6 +14,7 @@ use App\Models\User_model;
use App\Models\Ipinvoice_model;
use App\Models\Ipattachment_model;
use App\Models\Zohobooks_api_model;
+
require_once 'vendor/autoload.php';
/**
@@ -41,7 +42,7 @@ class User extends BaseController
public function __construct()
{
parent::__construct();
-
+
$this->dahsboard_Model = new Dashboard_model();
$this->costcenter_model = new Costcenter_model();
$this->department_model = new Department_model();
@@ -62,7 +63,7 @@ class User extends BaseController
$this->global['pageTitle'] = 'Dashboard';
log_message('error', '#####Dashboard session name : ' . $this->session->get('name'));
-
+
$data['EmpCount'] = $this->employeedetails_model->getEmployeeCount();
$data['UserCount'] = $this->dahsboard_Model->getUserCount();
@@ -107,20 +108,20 @@ class User extends BaseController
$data['capitalbud'] = $this->dahsboard_Model->capitalbud();
- $data['typebal'] = [];// $this->dahsboard_Model->typebal();
+ $data['typebal'] = []; // $this->dahsboard_Model->typebal();
/* HR DASHBOARD Controller Start*/
$data['totemp'] = $this->dahsboard_Model->totemp();
-
+
$data['totloan'] = $this->dahsboard_Model->totloan();
-
+
$data['totpay'] = $this->dahsboard_Model->totpay();
-
+
$data['totrec'] = $this->dahsboard_Model->totrec();
-
+
$data['emplist'] = $this->dahsboard_Model->emplist();
-
+
$date = $this->request->getPost("id");
$dates = date('Y-m');
@@ -253,13 +254,12 @@ class User extends BaseController
$working = array();
$overtime = array();
//$holid = array();
- for ($i = 1; $i <= $dat; $i++)
- {
+ for ($i = 1; $i <= $dat; $i++) {
$Working[] = 'WH' . $i;
$overtime[] = 'OT' . $i;
$CUR_month = date('t');
-
+
// foreach ($holiday as $value)
// {
// //$holid []= 'WH'.$value;
@@ -269,7 +269,7 @@ class User extends BaseController
// }
}
-
+
$WH = implode(",", $Working);
$OT = implode(",", $overtime);
@@ -315,19 +315,19 @@ class User extends BaseController
/**one hour salay ot calculation**/
$totSalayOT = ($totalothour != 0) ? $totalothour * $onehoursSalary : 0;
/** if ot not equal zero **/
-
+
$currentDaySalary = $daySalary * $values;
/** current day salary working days calculation**/
$currentDayHra = $dayHra * $values;
/** total working days hra calculations**/
-
+
$currentDatePF = $currentDaySalary + $currentDayHra + $totSalayOT;
/** current date pf calculation**/
-
+
$esiAmount = ($totalsalary <= 20000) ? $currentDatePF * 1.75 / 100 : 0;
/** esiamount not elgiable for 20000 **/
-
+
$pfAmount = $currentDaySalary * 12 / 100;
/** pf amount per day**/
@@ -338,7 +338,7 @@ class User extends BaseController
$totalSalary = round($totalSalarys);
// $salarycurrentdate[] = $salaryInCurrentday;;
-
+
}
}
}
@@ -363,7 +363,7 @@ class User extends BaseController
$WH = 'WH' . date('j', strtotime("-1 days"));
$yesterday = $this->dahsboard_Model->attyesterday($WH, $date);
-
+
$values = 0;
foreach ($yesterday as $weekda => $value) {
@@ -372,28 +372,28 @@ class User extends BaseController
$values++;
}
}
-
+
$data['values'] = $values;
$date = $this->request->getPost("id");
-
- $daydate = format_date($date,0,'Y-m');
-
+
+ $daydate = format_date($date, 0, 'Y-m');
+
$daydate = $daydate . '-01';
-
- $WH = 'WH' . format_date($date,0,'j');
-
+
+ $WH = 'WH' . format_date($date, 0, 'j');
+
$yesterday = $this->dahsboard_Model->attyesterday($WH, $daydate);
//$absEmp =array($absEmp);
$values = 0;
$absEmp = array();
-
+
foreach ($yesterday as $weekda => $value) {
-
+
if ($value[$WH] == 0) {
$values++;
@@ -403,14 +403,14 @@ class User extends BaseController
}
}
-
+
$data['today'] = $values;
$data['absname'] = $absEmp;
- $OT = 'OT' .format_date($date,0,'j');
+ $OT = 'OT' . format_date($date, 0, 'j');
$CUR_month = date('t');
-
+
$toDayEmployee = $this->dahsboard_Model->dayAllPersentEmpSalary($WH, $OT, $daydate);
//$EmpID = $toDayEmployee[0]->EmpID;
@@ -466,14 +466,14 @@ class User extends BaseController
$currentDatePF = $currentDaySalary + $currentDayHra + $totSalayOT;
/** current date pf calculation**/
-
+
$esiAmount = ($totalsalary <= 20000) ? $currentDatePF * 1.75 / 100 : 0;
/** esiamount not elgiable for 20000 **/
-
+
$pfAmount = $currentDaySalary * 12 / 100;
/** pf amount per day**/
-
+
$salaryInCurrentdays = $currentDaySalary + $totSalayOT + $currentDayHra + $Food_Allowances;
$salaryInCurrentday = $salaryInCurrentdays - ($esiAmount + $pfAmount);
$employeeSalary += round($salaryInCurrentday);
@@ -488,7 +488,7 @@ class User extends BaseController
$working = array();
$overtime = array();
//$holid = array();
- $len = format_date($date,0,'d');
+ $len = format_date($date, 0, 'd');
for ($i = 1; $i <= $len; $i++) //echo $dat; die;
{
@@ -525,7 +525,7 @@ class User extends BaseController
if ($value[$work] != 0 || $value['OT' . substr($work, 2)] != 0) {
$totalothour = $value['OT' . substr($work, 2)];
-
+
$values = 1;
$Empid = $value['EmpID'];
@@ -551,10 +551,10 @@ class User extends BaseController
$onehoursSalary = ($daySalary + $dayHra) / 8;
/**one hour salay ot calculation**/
-
+
$totSalayOT = ($totalothour != 0) ? $totalothour * $onehoursSalary : 0;
/** if ot not equal zero **/
-
+
$currentDaySalary = $daySalary * $values;
/** current day salary working days calculation**/
@@ -563,10 +563,10 @@ class User extends BaseController
$currentDatePF = $currentDaySalary + $currentDayHra + $totSalayOT;
/** current date pf calculation**/
-
+
$esiAmount = ($totalsalary <= 20000) ? $currentDatePF * 1.75 / 100 : 0;
/** esiamount not elgiable for 20000 **/
-
+
$pfAmount = $currentDaySalary * 12 / 100;
/** pf amount per day**/
@@ -633,7 +633,7 @@ class User extends BaseController
{
$date = date('Y-m');
-
+
$dates = $date . '-01';
$EmpID = '';
if (empty($empID)) {
@@ -641,7 +641,7 @@ class User extends BaseController
} else {
$EmpID = $empID;
}
-
+
$monthabs = $this->dahsboard_Model->attendance($EmpID, $dates);
$persent_month = date('t'); //current month of days 31
$values = array();
@@ -700,11 +700,10 @@ class User extends BaseController
$totalwhhours = array_sum($values);
$totalwhhour = $totalwhhours / 8;
-
+
if ($CURMONTH == $doj_month && $CURYEAR == $doj_year) {
-
+
$data['CUR_month'] = $CURDATE - $doj_day + 1;
-
} else {
$data['CUR_month'] = $date;
}
@@ -871,7 +870,7 @@ class User extends BaseController
$TotalNoofDays = $TotalNoofDays + $CURDATE;
$DaysWorked = $DaysWorked + $values;
$final_res = round(($DaysWorked / $TotalNoofDays) * 100);
-
+
$data['workeds'] = $DaysWorked;
$data['yeardata'] = $final_res;
$data['totaldays'] = $TotalNoofDays;
@@ -926,7 +925,7 @@ class User extends BaseController
// echo "";
// print_r($data['Department']);
// die;
-
+
// echo "";
// print_r($data['Department']);die;
$this->global['pageTitle'] = 'Add New User';
@@ -1009,7 +1008,7 @@ class User extends BaseController
$email = $this->request->getPost('MailID');
$SelectedDepartment = (string)$this->request->getPost('txtSelectedDepartment');
$comma_separated = explode(':', $SelectedDepartment);
- if(count($comma_separated)== 1 && in_array('DEP27', $comma_separated)){
+ if (count($comma_separated) == 1 && in_array('DEP27', $comma_separated)) {
$roleId = '6';
}
$userInfo = [
@@ -1125,27 +1124,27 @@ class User extends BaseController
// if ($this->validator->run() == FALSE) {
// $this->editOld($userId);
// } else {
- $EmpID = $this->request->getPost('EmpList');
- $role = $this->request->getPost('role');
- $password = $this->request->getPost('password');
-
- $updatedDate = get_current_date_time();
+ $EmpID = $this->request->getPost('EmpList');
+ $role = $this->request->getPost('role');
+ $password = $this->request->getPost('password');
- // echo $EmpID;
+ $updatedDate = get_current_date_time();
- $userInfo = array();
+ // echo $EmpID;
- $userInfo = array('password' => getHashedPassword($password), 'roleId' => $role, 'EmpId' => $EmpID, 'updatedDtm' => $updatedDate);
+ $userInfo = array();
- $result = $this->user_model->editUser($userInfo, $EmpID);
+ $userInfo = array('password' => getHashedPassword($password), 'roleId' => $role, 'EmpId' => $EmpID, 'updatedDtm' => $updatedDate);
- if ($result == true) {
- $this->session->setFlashdata('success', 'User updated successfully');
- } else {
- $this->session->setFlashdata('error', 'User updation failed');
- }
+ $result = $this->user_model->editUser($userInfo, $EmpID);
- return redirect()->route('userListing');
+ if ($result == true) {
+ $this->session->setFlashdata('success', 'User updated successfully');
+ } else {
+ $this->session->setFlashdata('error', 'User updation failed');
+ }
+
+ return redirect()->route('userListing');
// }
//}
}
@@ -1159,7 +1158,7 @@ class User extends BaseController
{
echo 'Delete';
$Uid = $this->request->getPost('id');
-
+
$updatedDate = get_current_date_time();
$userInfo = array('isDeleted' => 1, 'updatedBy' => $this->vendorId, 'updatedDtm' => $updatedDate);
@@ -1176,7 +1175,7 @@ class User extends BaseController
{
$this->global['pageTitle'] = 'Change Password';
- $this->loadViews("changePassword", $this->global, NULL, NULL);
+ $this->loadViews("changePassword", $this->global, [], NULL);
}
@@ -1187,29 +1186,27 @@ class User extends BaseController
{
helper('form'); //$this->load->library('form_validation');
- $this->validator->setRules(['oldPassword', 'Old password'=> 'required|max_length[20]']);
- $this->validator->setRules(['newPassword', 'New password'=> 'required|max_length[20]']);
- $this->validator->setRules(['cNewPassword', 'Confirm new password'=> 'required|matches[newPassword]|max_length[20]']);
+ // $this->validator->setRules(['oldPassword', 'Old password'=> 'required|max_length[20]']);
+ // $this->validator->setRules(['newPassword', 'New password'=> 'required|max_length[20]']);
+ // $this->validator->setRules(['cNewPassword', 'Confirm new password'=> 'required|matches[newPassword]|max_length[20]']);
- if ($this->validator->run() == FALSE) {
- $this->loadChangePass();
- } else {
+ // if ($this->validator->run() == FALSE) {
$oldPassword = $this->request->getPost('oldPassword');
$newPassword = $this->request->getPost('newPassword');
-
+ $cNewPassword = $this->request->getPost('newPassword');
+ if($newPassword === $cNewPassword && $oldPassword != $newPassword) {
$resultPas = $this->user_model->matchOldPassword($this->vendorId, $oldPassword);
-
if (empty($resultPas)) {
$this->session->setFlashdata('nomatch', 'Your old password not correct');
return redirect()->route('loadChangePass');
} else {
$usersData = array(
- 'password' => getHashedPassword($newPassword), 'updatedBy' => $this->vendorId,
+ 'password' => getHashedPassword($newPassword),
+ 'updatedBy' => $this->vendorId,
'updatedDtm' => date('Y-m-d H:i:sa')
);
-
+ $this->session->setFlashdata('error', 'Password updation failed');
$result = $this->user_model->changePassword($this->vendorId, $usersData);
-
if ($result > 0) {
$this->session->setFlashdata('success', 'Password updation successful');
} else {
@@ -1236,7 +1233,6 @@ class User extends BaseController
$data['fy'] = $this->user_model->fincalYear();
$data['per'] = $this->user_model->deliver_perform($fa, $aa, $m);
-
}
$data['fy'] = $this->user_model->fincalYear();
@@ -1265,7 +1261,7 @@ class User extends BaseController
$status = $this->request->getPost('status');
$CreateBy = $this->session->get('userId');
-
+
$createddt = get_current_date_time();
$menu = $this->request->getPost('menu');
// $RowCount = $this->request->getPost('txtRowCount');
@@ -1273,7 +1269,7 @@ class User extends BaseController
// $comma_separated = explode(':', $DeletedRow);
$favourite = array('Menu_Name' => $name, 'Menu_URL' => $url, 'Status' => $status, 'Created_BY' => $CreateBy, 'Created_ON' => $createddt, 'Menu_ID' => $menu);
$getdata = $this->user_model->favouriteadd($favourite);
-
+
if ($getdata == 1) {
echo "success";
} else {
@@ -1281,380 +1277,358 @@ class User extends BaseController
}
}
- function zohobooks_api_fetch_all(){
+ function zohobooks_api_fetch_all()
+ {
// print_r($_GET);
// echo isset($_GET['from']) ? $_GET['from'] : 'n';
// echo isset($_GET['to']) ? $_GET['to'] : 'n';
// die();
- try{
+ try {
// if (isset($_POST['sync']) || $_GET['from'] != null && $_GET['to'] != null)
// {
- // $ch=curl_init();
- //$this->load->helper('zohobooks_fetch_api_helper');
- helper('zohobook');
- $Zohobook_model = model('Zohobook_api_model');
- if(isset($_GET['from']) && $_GET['from'] != null && isset($_GET['to']) && $_GET['to'] != null)
- {
- $date_today = $_GET['to'];
- $date_yesterday = $_GET['from'];
+ // $ch=curl_init();
+ //$this->load->helper('zohobooks_fetch_api_helper');
+ helper('zohobook');
+ $Zohobook_model = model('Zohobook_api_model');
+ if (isset($_GET['from']) && $_GET['from'] != null && isset($_GET['to']) && $_GET['to'] != null) {
+ $date_today = $_GET['to'];
+ $date_yesterday = $_GET['from'];
+ } else {
+ $date_today = date('Y-m-d');
+ $date_yesterday = date('Y-m-d', strtotime('-3 day', strtotime($date_today)));
+ }
+ // echo $date_today.'--'.$date_yesterday;die;
+ $chk_acc_token_val = $Zohobook_model->get_data('zohobook_accesstoken', 'id', 1);
+ // print_r($chk_acc_token_val);//die();
+ $date = new \DateTime($chk_acc_token_val[0]['created_at']);
+ //print_r($date);
+ $date->add(new \DateInterval('PT1H'));
+ //print_r($date);
+ //echo '****************';
+ //print_r(date('Y-m-d h:i:s'));
+ $token = 0;
+ if ($date->format('Y-m-d H:i:s') > date('Y-m-d H:i:s')) {
+ $token = $chk_acc_token_val[0]['token'];
+ } else {
+ $token = generateNewToken();
+ $tokendata['token'] = $token;
+ $Zohobook_model->customUpdate($tokendata, 1, 'zohobook_accesstoken');
+ }
+ // $token = generateNewToken(); $tokendata['token'] = $token;
+ //$Zohobook_model->update($tokendata , 1,'zohobook_accesstoken');
+ $result = getheringInvoiceDetails($date_today, $date_yesterday, $token);
+ $headers_new = $result['headers_new'];
+ $res = json_decode($result['data'], true);
+ $inv_array = $res['invoices'];
+ // print_r($inv_array);
+ // echo "rrrr";
+ // die();
+ foreach ($inv_array as $inv) {
+ $invoice_id = $inv['invoice_id'];
+ //filter only einvoice status pushed invoices only
+ //&& isset($inv['einvoice_details']) && isset($inv['einvoice_details']['status']) && ($inv['einvoice_details']['status'] == 'pushed')
+ if ($invoice_id !== "") {
+ $organization_id = '776847408';
+ $result2 = getheringInvoiceSubDetails($invoice_id, $organization_id, $headers_new);
+ $resall = json_decode($result2, true);
+ $res2[] = $resall['invoice'];
}
- else
- {
- $date_today = date('Y-m-d');
- $date_yesterday = date('Y-m-d',strtotime('-3 day',strtotime($date_today)));
- }
- // echo $date_today.'--'.$date_yesterday;die;
- $chk_acc_token_val = $Zohobook_model->get_data('zohobook_accesstoken','id' , 1);
- // print_r($chk_acc_token_val);//die();
- $date = new \DateTime($chk_acc_token_val[0]['created_at']);
- //print_r($date);
- $date->add(new \DateInterval('PT1H'));
- //print_r($date);
- //echo '****************';
- //print_r(date('Y-m-d h:i:s'));
- $token = 0;
- if ($date->format('Y-m-d H:i:s') > date('Y-m-d H:i:s')) { $token = $chk_acc_token_val[0]['token']; }
- else { $token = generateNewToken(); $tokendata['token'] = $token; $Zohobook_model->customUpdate($tokendata , 1,'zohobook_accesstoken'); }
- // $token = generateNewToken(); $tokendata['token'] = $token;
- //$Zohobook_model->update($tokendata , 1,'zohobook_accesstoken');
- $result = getheringInvoiceDetails($date_today , $date_yesterday , $token);
- $headers_new = $result['headers_new'];
- $res = json_decode($result['data'],true);
- $inv_array = $res['invoices'];
- // print_r($inv_array);
- // echo "rrrr";
- // die();
- foreach($inv_array as $inv){
- $invoice_id = $inv['invoice_id'];
- //filter only einvoice status pushed invoices only
- //&& isset($inv['einvoice_details']) && isset($inv['einvoice_details']['status']) && ($inv['einvoice_details']['status'] == 'pushed')
- if($invoice_id !== "" ){
- $organization_id = '776847408';
- $result2=getheringInvoiceSubDetails($invoice_id,$organization_id,$headers_new);
- $resall = json_decode($result2,true);
- $res2[] = $resall['invoice'];
- }
+ }
+ $insert_count = 0;
+ $update_count = 0;
+ foreach ($res2 as $rs) {
+ $gst_no = $rs['gst_no'];
+ $invoice_number = $rs['invoice_number'];
+ $invoice_date = $rs['date'];
+ $status = $rs['status'];
+ $due_date = $rs['due_date'];
+ $invoice_url = $rs['invoice_url'];
+ $einvoice_number = $rs['einvoice_details']['inv_ref_num'];
+
+ $invoice_time = $rs['created_time'];
+ $time_array = explode("T", $invoice_time);
+ $time_array = explode("+", $time_array[1]);
+ $invoice_time = $time_array[0];
+
+ $sql_invoice_chk = $Zohobook_model->ip_invoices($invoice_number, $invoice_date);
+ if ($sql_invoice_chk <= 0) {
+
+ $gst_sql = $Zohobook_model->ip_clients($gst_no);
+ if ($gst_sql) {
+ $client_id = $gst_sql[0]['client_id'];
+ log_message('error', 'Data fetch success DB : ip_clients , client_id : ' . $client_id);
+ } else {
+ log_message('error', 'No data => Data fetch failed DB : ip_clients ' . $gst_no);
+ $gst_no_data['client_tax_code'] = $gst_no;
+ $gst_inserted_id = $Zohobook_model->customInsert($gst_no_data, 'ip_clients');
+ $client_id = $gst_inserted_id;
+ log_message('error', 'New Data Created : DB : ip_clients , client_id : ' . $client_id);
}
- $insert_count = 0;
- $update_count = 0;
- foreach($res2 as $rs)
- {
- $gst_no = $rs['gst_no'];
- $invoice_number = $rs['invoice_number'];
- $invoice_date = $rs['date'];
- $status = $rs['status'];
- $due_date = $rs['due_date'];
- $invoice_url = $rs['invoice_url'];
- $einvoice_number = $rs['einvoice_details']['inv_ref_num'];
- $invoice_time=$rs['created_time'];
- $time_array = explode("T", $invoice_time);
- $time_array = explode("+",$time_array[1]);
- $invoice_time = $time_array[0];
-
- $sql_invoice_chk = $Zohobook_model->ip_invoices($invoice_number , $invoice_date);
- if($sql_invoice_chk <= 0)
- {
- $gst_sql = $Zohobook_model->ip_clients($gst_no);
- if($gst_sql)
- {
- $client_id = $gst_sql[0]['client_id'];
- log_message('error', 'Data fetch success DB : ip_clients , client_id : '.$client_id);
+ $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
+ $charactersLength = strlen($characters);
+ $randomString = '';
+ for ($i = 0; $i < 16; $i++) {
+ $randomString .= $characters[rand(0, $charactersLength - 1)];
+ }
+ $url_key = $randomString;
+
+ $ip_invoices['user_id'] = 1;
+ $ip_invoices['client_id'] = $client_id;
+ $ip_invoices['invoice_group_id'] = 6;
+ $ip_invoices['invoice_status_id'] = ($status == 'draft' ? 1 : (($status == 'sent' || $status == 'overdue') ? 2 : 5));
+ $ip_invoices['invoice_date_created'] = $invoice_date;
+ $ip_invoices['invoice_time_created'] = $invoice_time;
+ $ip_invoices['invoice_date_due'] = $due_date;
+ $ip_invoices['invoice_number'] = $invoice_number;
+ $ip_invoices['invoice_url_key'] = $url_key;
+ $ip_invoices['receivedstatus'] = 'ST066';
+ $ip_invoices['credit_status'] = 0;
+ $ip_invoices['status'] = $status;
+ $ip_invoices['e_invoice_number'] = $einvoice_number;
+ $ip_invoices['invoice_url'] = $invoice_url;
+ $invoice_insert_id = $Zohobook_model->customInsert($ip_invoices, 'ip_invoices');
+ if ($invoice_insert_id) {
+ log_message('error', 'Data insert success DB : ip_invoices client id :' . $client_id);
+ $insert_count = $insert_count + 1;
+ //start invoice level custom fields
+
+ //custom fields insert
+
+ $batch_no = isset($rs['custom_fields'][5]['value']) ? $rs['custom_fields'][5]['value'] : "";
+ // $batch_no = "";
+ $vehicle_number = isset($rs['custom_field_hash']['cf_vehicle_number']) ? $rs['custom_field_hash']['cf_vehicle_number'] : '';
+ $transport_mode = isset($rs['custom_field_hash']['cf_transport_mode']) ? $rs['custom_field_hash']['cf_transport_mode'] : '';
+ $purchase_order_date = isset($rs['custom_field_hash']['cf_purchase_order_date']) ? $rs['custom_field_hash']['cf_purchase_order_date'] : '';
+ $driver = isset($rs['custom_field_hash']['cf_driver']) ? $rs['custom_field_hash']['cf_driver'] : '';
+ $place_of_supply = isset($rs['custom_field_hash']['cf_place_of_supply']) ? $rs['custom_field_hash']['cf_place_of_supply'] : '';
+ // batch_no
+ $ip_invoice_custom_b['invoice_id'] = $invoice_insert_id;
+ $ip_invoice_custom_b['invoice_custom_fieldid'] = 62;
+ $ip_invoice_custom_b['invoice_custom_fieldvalue'] = $batch_no;
+ $result_invoice_custom_insert = $Zohobook_model->customInsert($ip_invoice_custom_b, 'ip_invoice_custom');
+ if ($result_invoice_custom_insert)
+ log_message('error', 'Data insert success DB : ip_invoice_custom ');
+ else
+ log_message('error', 'Data insert failed DB : ip_invoice_custom ');
+ // vehicle_number
+ $ip_invoice_custom_v['invoice_id'] = $invoice_insert_id;
+ $ip_invoice_custom_v['invoice_custom_fieldid'] = 8;
+ $ip_invoice_custom_v['invoice_custom_fieldvalue'] = $vehicle_number;
+ $res_vehicle = $Zohobook_model->customInsert($ip_invoice_custom_v, 'ip_invoice_custom');
+ if ($res_vehicle)
+ log_message('error', 'Data insert success DB : ip_invoice_custom ');
+ else
+ log_message('error', 'Data insert failed DB : ip_invoice_custom ');
+ // transport_mode
+ $ip_invoice_custom_t['invoice_id'] = $invoice_insert_id;
+ $ip_invoice_custom_t['invoice_custom_fieldid'] = 7;
+ $ip_invoice_custom_t['invoice_custom_fieldvalue'] = $transport_mode;
+ $res_transport_mode = $Zohobook_model->customInsert($ip_invoice_custom_t, 'ip_invoice_custom');
+ if ($res_transport_mode)
+ log_message('error', 'Data insert success DB : ip_invoice_custom ');
+ else
+ log_message('error', 'Data insert failed DB : ip_invoice_custom ');
+ // purchase_order_date
+ $ip_invoice_custom_p['invoice_id'] = $invoice_insert_id;
+ $ip_invoice_custom_p['invoice_custom_fieldid'] = 15;
+ $ip_invoice_custom_p['invoice_custom_fieldvalue'] = $purchase_order_date;
+ $res_purchase_order_date = $Zohobook_model->customInsert($ip_invoice_custom_p, 'ip_invoice_custom');
+ if ($res_purchase_order_date)
+ log_message('error', 'Data insert success DB : ip_invoice_custom ');
+ else
+ log_message('error', 'Data insert failed DB : ip_invoice_custom ');
+ // driver
+ $ip_invoice_custom_d['invoice_id'] = $invoice_insert_id;
+ $ip_invoice_custom_d['invoice_custom_fieldid'] = 58;
+ $ip_invoice_custom_d['invoice_custom_fieldvalue'] = $driver;
+ $res_driver = $Zohobook_model->customInsert($ip_invoice_custom_d, 'ip_invoice_custom');
+ if ($res_driver)
+ log_message('error', 'Data insert success DB : ip_invoice_custom ');
+ else
+ log_message('error', 'Data insert failed DB : ip_invoice_custom ');
+ // place_of_supply
+ $ip_invoice_custom_d['invoice_id'] = $invoice_insert_id;
+ $ip_invoice_custom_d['invoice_custom_fieldid'] = 10;
+ $ip_invoice_custom_d['invoice_custom_fieldvalue'] = $place_of_supply;
+ $res_place = $Zohobook_model->customInsert($ip_invoice_custom_d, 'ip_invoice_custom');
+ if ($res_place)
+ log_message('error', 'Data insert success DB : ip_invoice_custom ');
+ else
+ log_message('error', 'Data insert failed DB : ip_invoice_custom ');
+ //end invoice level custom fields
+
+ //if line items available
+ if (isset($rs['line_items']) && count($rs['line_items']) > 0) {
+ log_message('error', 'Processing line items' . count($rs['line_items']));
+
+ for ($i = 0; $i < count($rs['line_items']); $i++) { //start insert line items
+ $sku = $rs['line_items'][$i]['sku'];
+
+
+ $item_price = $rs['line_items'][$i]['rate'];
+ $item_order = $rs['line_items'][$i]['item_order'];
+ $item_product_unit = $rs['line_items'][$i]['unit'];
+ $item_name = $rs['line_items'][$i]['name'];
+ $item_description = $rs['line_items'][$i]['description'];
+ $item_quantity = $rs['line_items'][$i]['quantity'];
+ $cgst = $rs['line_items'][$i]['line_item_taxes'][1]['tax_name'];
+ $sgst = $rs['line_items'][$i]['line_item_taxes'][0]['tax_name'];
+ $cgst = $cgst[4];
+ $sgst = $sgst[4];
+ $cgst = $cgst . '.000';
+ $getcgsttax = $Zohobook_model->ip_tax_rates($cgst);
+ if ($getcgsttax) {
+ $cgsttaxid = $getcgsttax[0]['tax_rate_id'];
+ log_message('error', 'Data fetch success DB : ip_tax_rates cgst' . $cgst);
+ } else {
+ log_message('error', 'No data => Data fetch failed DB : ip_tax_rates ' . $cgst);
+ $cgst_data['tax_rate_percent'] = $cgst;
+ $getcgsttax = $Zohobook_model->customInsert($cgst_data, 'ip_tax_rates');
+ $cgsttaxid = $getcgsttax;
+ log_message('error', 'New Data Created : DB : ip_tax_rates , tax_rate_id : ' . $cgsttaxid);
}
+
+ $sgst = $sgst . '.000';
+ $getsgsttax = $Zohobook_model->ip_tax_rates($sgst);
+ if ($getsgsttax) {
+ $sgsttaxid = $getsgsttax[0]['tax_rate_id'];
+ log_message('error', 'Data fetch success DB : ip_tax_rates sgst' . $sgst);
+ } else {
+ log_message('error', 'No data => Data fetch failed DB : ip_tax_rates ' . $sgst);
+ $sgst_data['tax_rate_percent'] = $sgst;
+ $getsgsttax = $Zohobook_model->customInsert($sgst_data, 'ip_tax_rates');
+ $sgsttaxid = $getsgsttax;
+ log_message('error', 'New Data Created : DB : ip_tax_rates , tax_rate_id : ' . $sgsttaxid);
+ }
+
+ $item_subtotal = $rs['line_items'][$i]['item_total'];
+
+
+ $item_sgst_amt = $rs['line_items'][$i]['line_item_taxes'][0]['tax_amount'];
+ $item_cgst_amt = $rs['line_items'][$i]['line_item_taxes'][1]['tax_amount'];
+ $item_tax_total = ($item_sgst_amt + $item_cgst_amt);
+ $item_total = ($item_subtotal + $item_tax_total);
+
+ $item_discount = 0.00;
+ $item_igst_amt = 0.00;
+ // if($batch_no==""){ $batch_no = "";}
+
+
+ $sku_sql = $Zohobook_model->ip_products($sku);
+ if (!empty($sku_sql)) {
+ $product_id = $sku_sql[0]['product_id'];
+ log_message('error', 'Data fetch success DB : ip_products , product_id : ' . $product_id);
+ } else {
+ log_message('error', 'No data => Data fetch failed DB : ip_products ' . $sku);
+ $sku_data['product_name'] = $item_name;
+ $sku_data['product_description'] = $item_description;
+ $sku_data['sku'] = $sku;
+ $sku_inserted_id = $Zohobook_model->customInsert($sku_data, 'ip_products');
+ $product_id = $sku_inserted_id;
+ log_message('error', '$sku_sql => Data fetch failed DB : ip_products ' . $sku_sql);
+
+ log_message('error', 'sku' . $sku);
+ log_message('error', 'New Data Created : DB : product_id , product_id : ' . $product_id);
+ }
+
+ //#1
+
+ $ip_invoice_items['invoice_id'] = $invoice_insert_id;
+ $ip_invoice_items['item_product_id'] = $product_id;
+ $ip_invoice_items['item_date_added'] = $invoice_date;
+ $ip_invoice_items['item_name'] = $item_name;
+ $ip_invoice_items['item_description'] = $item_description;
+ $ip_invoice_items['item_quantity'] = $item_quantity;
+ $ip_invoice_items['item_price'] = $item_price;
+ $ip_invoice_items['item_order'] = $item_order;
+ $ip_invoice_items['item_product_unit'] = $item_product_unit;
+ $ip_invoice_items['Sgst_item_tax_rate_id'] = $sgsttaxid;
+ $ip_invoice_items['Cgst_item_tax_rate_id'] = $cgsttaxid;
+ $item_insert_id = $Zohobook_model->customInsert($ip_invoice_items, 'ip_invoice_items');
+ if ($item_insert_id)
+ log_message('error', 'Data insert success DB : ip_invoice_items => Sgst_item_tax_rate_id :' . $sgsttaxid);
else
- {
- log_message('error', 'No data => Data fetch failed DB : ip_clients '.$gst_no);
- $gst_no_data['client_tax_code'] = $gst_no;
- $gst_inserted_id = $Zohobook_model->customInsert($gst_no_data,'ip_clients');
- $client_id = $gst_inserted_id;
- log_message('error', 'New Data Created : DB : ip_clients , client_id : '.$client_id);
- }
+ log_message('error', 'Data insert failed DB : ip_invoice_items => Sgst_item_tax_rate_id :' . $sgsttaxid);
-
- $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
- $charactersLength = strlen($characters);
- $randomString = '';
- for ($i = 0; $i < 16; $i++) { $randomString .= $characters[rand(0, $charactersLength - 1)]; }
- $url_key = $randomString;
-
- $ip_invoices['user_id'] = 1;
- $ip_invoices['client_id'] = $client_id;
- $ip_invoices['invoice_group_id'] = 6;
- $ip_invoices['invoice_status_id'] = ($status == 'draft' ? 1 : (($status == 'sent' || $status == 'overdue') ? 2 : 5));
- $ip_invoices['invoice_date_created'] = $invoice_date;
- $ip_invoices['invoice_time_created'] = $invoice_time;
- $ip_invoices['invoice_date_due'] = $due_date;
- $ip_invoices['invoice_number'] = $invoice_number;
- $ip_invoices['invoice_url_key'] = $url_key;
- $ip_invoices['receivedstatus'] = 'ST066';
- $ip_invoices['credit_status'] = 0;
- $ip_invoices['status'] = $status;
- $ip_invoices['e_invoice_number'] = $einvoice_number;
- $ip_invoices['invoice_url'] = $invoice_url;
- $invoice_insert_id = $Zohobook_model->customInsert($ip_invoices,'ip_invoices');
- if($invoice_insert_id)
- {
- log_message('error', 'Data insert success DB : ip_invoices client id :'. $client_id);
- $insert_count = $insert_count + 1;
- //start invoice level custom fields
-
- //custom fields insert
-
- $batch_no = isset($rs['custom_fields'][5]['value']) ? $rs['custom_fields'][5]['value'] : "";
- // $batch_no = "";
- $vehicle_number = isset($rs['custom_field_hash']['cf_vehicle_number']) ? $rs['custom_field_hash']['cf_vehicle_number']: '';
- $transport_mode =isset($rs['custom_field_hash']['cf_transport_mode']) ? $rs['custom_field_hash']['cf_transport_mode'] : '';
- $purchase_order_date = isset($rs['custom_field_hash']['cf_purchase_order_date'])?$rs['custom_field_hash']['cf_purchase_order_date']:'';
- $driver = isset($rs['custom_field_hash']['cf_driver']) ? $rs['custom_field_hash']['cf_driver'] : '';
- $place_of_supply = isset($rs['custom_field_hash']['cf_place_of_supply']) ? $rs['custom_field_hash']['cf_place_of_supply']:'';
- // batch_no
- $ip_invoice_custom_b['invoice_id'] = $invoice_insert_id;
- $ip_invoice_custom_b['invoice_custom_fieldid'] = 62;
- $ip_invoice_custom_b['invoice_custom_fieldvalue'] = $batch_no;
- $result_invoice_custom_insert = $Zohobook_model->customInsert($ip_invoice_custom_b,'ip_invoice_custom');
- if($result_invoice_custom_insert)
- log_message('error', 'Data insert success DB : ip_invoice_custom ');
- else
- log_message('error', 'Data insert failed DB : ip_invoice_custom ');
- // vehicle_number
- $ip_invoice_custom_v['invoice_id'] = $invoice_insert_id;
- $ip_invoice_custom_v['invoice_custom_fieldid'] = 8;
- $ip_invoice_custom_v['invoice_custom_fieldvalue'] = $vehicle_number;
- $res_vehicle = $Zohobook_model->customInsert($ip_invoice_custom_v,'ip_invoice_custom');
- if($res_vehicle)
- log_message('error', 'Data insert success DB : ip_invoice_custom ');
- else
- log_message('error', 'Data insert failed DB : ip_invoice_custom ');
- // transport_mode
- $ip_invoice_custom_t['invoice_id'] = $invoice_insert_id;
- $ip_invoice_custom_t['invoice_custom_fieldid'] = 7;
- $ip_invoice_custom_t['invoice_custom_fieldvalue'] = $transport_mode;
- $res_transport_mode = $Zohobook_model->customInsert($ip_invoice_custom_t,'ip_invoice_custom');
- if($res_transport_mode)
- log_message('error', 'Data insert success DB : ip_invoice_custom ');
- else
- log_message('error', 'Data insert failed DB : ip_invoice_custom ');
- // purchase_order_date
- $ip_invoice_custom_p['invoice_id'] = $invoice_insert_id;
- $ip_invoice_custom_p['invoice_custom_fieldid'] = 15;
- $ip_invoice_custom_p['invoice_custom_fieldvalue'] = $purchase_order_date;
- $res_purchase_order_date =$Zohobook_model->customInsert($ip_invoice_custom_p,'ip_invoice_custom');
- if($res_purchase_order_date)
- log_message('error', 'Data insert success DB : ip_invoice_custom ');
- else
- log_message('error', 'Data insert failed DB : ip_invoice_custom ');
- // driver
- $ip_invoice_custom_d['invoice_id'] = $invoice_insert_id;
- $ip_invoice_custom_d['invoice_custom_fieldid'] = 58;
- $ip_invoice_custom_d['invoice_custom_fieldvalue'] = $driver;
- $res_driver = $Zohobook_model->customInsert($ip_invoice_custom_d,'ip_invoice_custom');
- if($res_driver)
- log_message('error', 'Data insert success DB : ip_invoice_custom ');
- else
- log_message('error', 'Data insert failed DB : ip_invoice_custom ');
- // place_of_supply
- $ip_invoice_custom_d['invoice_id'] = $invoice_insert_id;
- $ip_invoice_custom_d['invoice_custom_fieldid'] = 10;
- $ip_invoice_custom_d['invoice_custom_fieldvalue'] = $place_of_supply;
- $res_place = $Zohobook_model->customInsert($ip_invoice_custom_d,'ip_invoice_custom');
- if($res_place)
- log_message('error', 'Data insert success DB : ip_invoice_custom ');
- else
- log_message('error', 'Data insert failed DB : ip_invoice_custom ');
- //end invoice level custom fields
-
- //if line items available
- if(isset($rs['line_items']) && count($rs['line_items']) > 0)
- {
- log_message('error', 'Processing line items'.count($rs['line_items']));
-
- for($i = 0; $i< count($rs['line_items']);$i++)
- { //start insert line items
- $sku = $rs['line_items'][$i]['sku'];
-
-
- $item_price = $rs['line_items'][$i]['rate'];
- $item_order = $rs['line_items'][$i]['item_order'];
- $item_product_unit = $rs['line_items'][$i]['unit'];
- $item_name = $rs['line_items'][$i]['name'];
- $item_description = $rs['line_items'][$i]['description'];
- $item_quantity = $rs['line_items'][$i]['quantity'];
- $cgst = $rs['line_items'][$i]['line_item_taxes'][1]['tax_name'];
- $sgst = $rs['line_items'][$i]['line_item_taxes'][0]['tax_name'];
- $cgst = $cgst[4];
- $sgst = $sgst[4];
- $cgst = $cgst.'.000';
- $getcgsttax = $Zohobook_model->ip_tax_rates($cgst);
- if($getcgsttax)
- {
- $cgsttaxid = $getcgsttax[0]['tax_rate_id'];
- log_message('error', 'Data fetch success DB : ip_tax_rates cgst'. $cgst);
- }
- else
- {
- log_message('error', 'No data => Data fetch failed DB : ip_tax_rates '. $cgst);
- $cgst_data['tax_rate_percent'] = $cgst;
- $getcgsttax = $Zohobook_model->customInsert($cgst_data,'ip_tax_rates');
- $cgsttaxid = $getcgsttax;
- log_message('error', 'New Data Created : DB : ip_tax_rates , tax_rate_id : '.$cgsttaxid);
- }
-
- $sgst = $sgst.'.000';
- $getsgsttax = $Zohobook_model->ip_tax_rates($sgst);
- if($getsgsttax)
- {
- $sgsttaxid = $getsgsttax[0]['tax_rate_id'];
- log_message('error', 'Data fetch success DB : ip_tax_rates sgst'. $sgst);
- }
- else
- {
- log_message('error', 'No data => Data fetch failed DB : ip_tax_rates '. $sgst);
- $sgst_data['tax_rate_percent'] = $sgst;
- $getsgsttax = $Zohobook_model->customInsert($sgst_data,'ip_tax_rates');
- $sgsttaxid = $getsgsttax;
- log_message('error', 'New Data Created : DB : ip_tax_rates , tax_rate_id : '.$sgsttaxid);
- }
-
- $item_subtotal = $rs['line_items'][$i]['item_total'];
-
-
- $item_sgst_amt = $rs['line_items'][$i]['line_item_taxes'][0]['tax_amount'];
- $item_cgst_amt = $rs['line_items'][$i]['line_item_taxes'][1]['tax_amount'];
- $item_tax_total = ($item_sgst_amt + $item_cgst_amt);
- $item_total = ($item_subtotal + $item_tax_total);
-
- $item_discount = 0.00;
- $item_igst_amt = 0.00;
- // if($batch_no==""){ $batch_no = "";}
-
-
- $sku_sql = $Zohobook_model->ip_products($sku);
- if(!empty($sku_sql))
- {
- $product_id = $sku_sql[0]['product_id'];
- log_message('error', 'Data fetch success DB : ip_products , product_id : '.$product_id);
- }
- else
- {
- log_message('error', 'No data => Data fetch failed DB : ip_products '. $sku);
- $sku_data['product_name'] = $item_name;
- $sku_data['product_description'] = $item_description;
- $sku_data['sku'] = $sku;
- $sku_inserted_id = $Zohobook_model->customInsert($sku_data,'ip_products');
- $product_id = $sku_inserted_id;
- log_message('error', '$sku_sql => Data fetch failed DB : ip_products '. $sku_sql);
-
- log_message('error', 'sku'.$sku);
- log_message('error', 'New Data Created : DB : product_id , product_id : '.$product_id);
- }
-
- //#1
-
- $ip_invoice_items['invoice_id'] = $invoice_insert_id;
- $ip_invoice_items['item_product_id'] = $product_id;
- $ip_invoice_items['item_date_added'] = $invoice_date;
- $ip_invoice_items['item_name'] = $item_name;
- $ip_invoice_items['item_description'] = $item_description;
- $ip_invoice_items['item_quantity'] = $item_quantity;
- $ip_invoice_items['item_price'] = $item_price;
- $ip_invoice_items['item_order'] = $item_order;
- $ip_invoice_items['item_product_unit'] = $item_product_unit;
- $ip_invoice_items['Sgst_item_tax_rate_id'] = $sgsttaxid;
- $ip_invoice_items['Cgst_item_tax_rate_id'] = $cgsttaxid;
- $item_insert_id = $Zohobook_model->customInsert($ip_invoice_items,'ip_invoice_items');
- if($item_insert_id)
- log_message('error', 'Data insert success DB : ip_invoice_items => Sgst_item_tax_rate_id :'. $sgsttaxid);
- else
- log_message('error', 'Data insert failed DB : ip_invoice_items => Sgst_item_tax_rate_id :'. $sgsttaxid);
-
- //tax amount -- ip_invoice_item_amounts - table
- $ip_invoice_item_amounts['item_id'] = $item_insert_id;
- $ip_invoice_item_amounts['item_subtotal'] = $item_subtotal;
- $ip_invoice_item_amounts['item_tax_total'] = $item_tax_total;
- $ip_invoice_item_amounts['item_total'] = $item_total;
- $ip_invoice_item_amounts['item_sgst_amt'] = $item_sgst_amt;
- $ip_invoice_item_amounts['item_cgst_amt'] = $item_cgst_amt;
- $ip_invoice_item_amounts['item_discount'] = $item_discount;
- $ip_invoice_item_amounts['item_igst_amt'] = $item_igst_amt;
- $result_tax_amount_insert = $Zohobook_model->customInsert($ip_invoice_item_amounts,'ip_invoice_item_amounts');
- if($result_tax_amount_insert)
- log_message('error', 'Data insert success DB : ip_invoice_item_amounts ');
- else
- log_message('error', 'Data insert failed DB : ip_invoice_item_amounts ');
-
- } //end line items insert
-
- }
- else
- {
- log_message('error', 'Line Items not found in API result');
- }
- }
+ //tax amount -- ip_invoice_item_amounts - table
+ $ip_invoice_item_amounts['item_id'] = $item_insert_id;
+ $ip_invoice_item_amounts['item_subtotal'] = $item_subtotal;
+ $ip_invoice_item_amounts['item_tax_total'] = $item_tax_total;
+ $ip_invoice_item_amounts['item_total'] = $item_total;
+ $ip_invoice_item_amounts['item_sgst_amt'] = $item_sgst_amt;
+ $ip_invoice_item_amounts['item_cgst_amt'] = $item_cgst_amt;
+ $ip_invoice_item_amounts['item_discount'] = $item_discount;
+ $ip_invoice_item_amounts['item_igst_amt'] = $item_igst_amt;
+ $result_tax_amount_insert = $Zohobook_model->customInsert($ip_invoice_item_amounts, 'ip_invoice_item_amounts');
+ if ($result_tax_amount_insert)
+ log_message('error', 'Data insert success DB : ip_invoice_item_amounts ');
else
- {
- log_message('error', 'Data insert failed DB : ip_invoice_items client id :'. $client_id);
- }
-
-
- }
- else // update invoice status, especially for cancelled invoices
- {
- // if($status == "void" || $status == "sent" || $status == "overdue")
- // {
- $sql_invoice_update = array();
- $sql_invoice_update['invoice_status_id'] = (($status == "sent" || $status == "overdue") ? 2 : 5);
- // echo 'script' . $invoice_number. $status;
- // print_r( $sql_invoice_update);
- // echo '
';
- $sql_invoice_update = $Zohobook_model->sql_invoice_update($sql_invoice_update,$invoice_number,$invoice_date,'ip_invoices');
- if($sql_invoice_update)
- {
- log_message('error', 'Data update success DB : ip_invoices ');
- }
- else
- {
- log_message('error', 'Data update failed DB : ip_invoices ');
- }
- $update_count = $update_count + 1;
- // }
+ log_message('error', 'Data insert failed DB : ip_invoice_item_amounts ');
+ } //end line items insert
+
+ } else {
+ log_message('error', 'Line Items not found in API result');
}
+ } else {
+ log_message('error', 'Data insert failed DB : ip_invoice_items client id :' . $client_id);
+ }
+ } else // update invoice status, especially for cancelled invoices
+ {
+ // if($status == "void" || $status == "sent" || $status == "overdue")
+ // {
+ $sql_invoice_update = array();
+ $sql_invoice_update['invoice_status_id'] = (($status == "sent" || $status == "overdue") ? 2 : 5);
+ // echo 'script' . $invoice_number. $status;
+ // print_r( $sql_invoice_update);
+ // echo '
';
+ $sql_invoice_update = $Zohobook_model->sql_invoice_update($sql_invoice_update, $invoice_number, $invoice_date, 'ip_invoices');
+ if ($sql_invoice_update) {
+ log_message('error', 'Data update success DB : ip_invoices ');
+ } else {
+ log_message('error', 'Data update failed DB : ip_invoices ');
+ }
+ $update_count = $update_count + 1;
+ // }
+ }
// echo 'new invoice inserted count- ' . $insert_count . '/' . 'status updated count - ' . $update_count;
- }$response = [
- 'status' => true,
- 'message' => "Successfully data inserted. Total inserted: " . $insert_count . ", Total Updated: " . $update_count
- ];
- return json_encode($response);
-
- // curl_close($ch);
+ }
+ $response = [
+ 'status' => true,
+ 'message' => "Successfully data inserted. Total inserted: " . $insert_count . ", Total Updated: " . $update_count
+ ];
+ return json_encode($response);
+
+ // curl_close($ch);
// }
- }
- catch (\Exception $e) {
+ } catch (\Exception $e) {
$data['err'] = $e->getMessage();
// $db = \Config\Database::connect();
// $data['last_query'] = $db->getLastQuery();;
- $Zohobook_model->customInsert($data,'zohobook_api_err');
+ $Zohobook_model->customInsert($data, 'zohobook_api_err');
log_message('error', "Data insertion failed : " . $e->getMessage());
-
+
return json_encode("Data insertion failed : " . $e->getMessage());
}
}
// END zoho API
- function fetchEmployeeDetails() {
+ function fetchEmployeeDetails()
+ {
$EmpID = $this->request->getPost('EmpID');
-
+
if (!$EmpID) {
return $this->response->setJSON(['success' => false, 'message' => 'Employee ID not provided']);
}
-
+
$userInfo = $this->user_model->findEmp($EmpID);
-
+
if ($userInfo) {
return $this->response->setJSON(['success' => true, 'userInfo' => $userInfo]);
} else {
return $this->response->setJSON(['success' => false, 'message' => 'Employee not found']);
}
}
-}
\ No newline at end of file
+}
diff --git a/app/Helpers/cias_helper.php b/app/Helpers/cias_helper.php
index c48c5d5c..f3f5b341 100755
--- a/app/Helpers/cias_helper.php
+++ b/app/Helpers/cias_helper.php
@@ -48,9 +48,9 @@ if (!function_exists('generateCopyrightNotice')) {
{
$current_year = date('Y');
if ($current_year > 2024) {
- return " Copyright © 2024 - $current_year ";
+ return " © 2024 - $current_year ";
} else {
- return " Copyright © $current_year ";
+ return " © $current_year ";
}
}
}
diff --git a/app/Models/User_model.php b/app/Models/User_model.php
index 2cd57b27..8098fd00 100644
--- a/app/Models/User_model.php
+++ b/app/Models/User_model.php
@@ -160,7 +160,6 @@ class User_model extends Model
$query = $builder->get();
$user = $query->getResult();
-
if (!empty($user)) {
if (password_verify($oldPassword, $user[0]->password)) {
diff --git a/app/Views/addEmployeenew.php b/app/Views/addEmployeenew.php
index d0e47df9..50414640 100644
--- a/app/Views/addEmployeenew.php
+++ b/app/Views/addEmployeenew.php
@@ -493,7 +493,7 @@
class="badge">*
+ onchange="getAge();" class="form-control " data-provide="datepicker" data-date-format="dd-mm-yyyy">
@@ -638,7 +638,7 @@
class="badge">*
+ class="form-control" data-provide="datepicker" data-date-format="dd-mm-yyyy">
Previous Years of Experience
-
@@ -1347,7 +1347,7 @@
e.preventDefault(); // Prevent default form submission
var isValid = true;
- var combinedFormData = '';
+ var combinedFormData = new FormData(); // Use FormData to handle files
// List of form IDs you want to combine
var formIds = ['#accountForm', '#profileForm', '#bankForm', '#proofForm', '#fileForm']; // Add all your form IDs here
@@ -1362,8 +1362,19 @@
return false; // Break the loop if any form is invalid
}
- // Serialize and combine the form data
- combinedFormData += $form.serialize() + '&'; // Append each form's serialized data
+ // Serialize and append the form data
+ $form.find(':input').each(function() {
+ var input = $(this);
+ if (input.attr('type') === 'file') {
+ // If the input is a file, append it to FormData
+ $.each(input[0].files, function(i, file) {
+ combinedFormData.append(input.attr('name'), file);
+ });
+ } else {
+ // Otherwise, append other form data
+ combinedFormData.append(input.attr('name'), input.val());
+ }
+ });
});
if (!isValid) {
@@ -1371,22 +1382,21 @@
return; // Stop the submission if validation fails
}
- // Remove the trailing '&' from the combined form data
- combinedFormData = combinedFormData.slice(0, -1);
+ console.log('Combined Form Data:', combinedFormData); // Log the combined form data for debugging
- console.log('Combined Form Data:', combinedFormData); // Log the combined form data
-
- // Now you can send the combined data via AJAX or perform your desired action
+ // Now you can send the combined data via AJAX
$.ajax({
type: 'POST',
url: 'addNewEmployee', // Replace with your form submission URL
data: combinedFormData,
+ processData: false, // Don't process the data
+ contentType: false, // Don't set content type
success: function(response) {
console.log('Form submitted successfully:', response);
// Handle the success scenario
- if(response){
+ if (response) {
window.location.href = '';
- }else{
+ } else {
alert('Employee details Not Update...');
}
},
@@ -1398,6 +1408,7 @@
});
+
// Function to navigate to the next tab
function goToNextTab() {
var $activeTab = $('#rootwizard').find('ul.nav li.nav-item a.active');
diff --git a/app/Views/addasset.php b/app/Views/addasset.php
index d22c5c4c..48ea12e1 100644
--- a/app/Views/addasset.php
+++ b/app/Views/addasset.php
@@ -229,7 +229,8 @@
dataType: 'json',
success: function(data) {
//alert(data);
-
+ console.log(data);
+
var line = '';
$('#SelectMaterialCode').empty();
//alert('before');
diff --git a/app/Views/changePassword.php b/app/Views/changePassword.php
index 804d2b2f..2b8f424b 100644
--- a/app/Views/changePassword.php
+++ b/app/Views/changePassword.php
@@ -1,96 +1,96 @@
-
-
-
-
- Change Password
- Set new password for your account
-
-
-
-
-
-
-
-
- Enter Details
-
-
-
-
-
-
- getFlashdata('error');
- if($error)
- {
- ?>
-
-
- getFlashdata('error'); ?>
-
-
- getFlashdata('success');
- if($success)
- {
- ?>
-
-
- getFlashdata('success'); ?>
-
-
-
- getFlashdata('nomatch');
- if($noMatch)
- {
- ?>
-
-
- getFlashdata('nomatch'); ?>
-
-
-
+
+
+
+
+
+
-
- ', ' '); ?>
+
+
+ Change Password
+ Set new password for your account
+
+ getFlashdata('error');
+ if ($error) {
+ ?>
+
+
+ getFlashdata('error'); ?>
+
+
+ getFlashdata('success');
+ if ($success) {
+ ?>
+
+
+ getFlashdata('success'); ?>
+
+
+
+ getFlashdata('nomatch');
+ if ($noMatch) {
+ ?>
+
+
+ getFlashdata('nomatch'); ?>
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
\ No newline at end of file
diff --git a/app/Views/companyview.php b/app/Views/companyview.php
index 2692f508..1a887da5 100644
--- a/app/Views/companyview.php
+++ b/app/Views/companyview.php
@@ -481,7 +481,7 @@ function ValidateUA() {
- Company Profile
+ Business Settings
@@ -498,7 +498,7 @@ function ValidateUA() {