Add php files
This commit is contained in:
40
modules/EcmServiceNews/ajax.php
Executable file
40
modules/EcmServiceNews/ajax.php
Executable file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
if(!defined('sugarEntry') || !sugarEntry) die('-1');
|
||||
if (!$_POST['job'] || $_POST['job']=='') die ('-1');
|
||||
|
||||
switch ($_POST['job']) {
|
||||
case 'getItems': getItems($_POST['record']); break;
|
||||
}
|
||||
|
||||
function getItems($record,$type) {
|
||||
global $db, $app_list_strings;
|
||||
$EcmServiceNew = new EcmServiceNew();
|
||||
$EcmServiceNew->retrieve($record);
|
||||
foreach($EcmServiceNew->items_list as $key => $row){
|
||||
$product_query = "SELECT code,vat_id,vat_name,vat_value FROM ecmproducts WHERE id='" . $row['ecmproduct_id'] ."'";
|
||||
$product_result = $db->query($product_query);
|
||||
$product_row = $db->fetchByAssoc($product_result);
|
||||
|
||||
$tmpRow['product_code'] = $product_row['code'];
|
||||
$tmpRow['product_id'] = $row['ecmproduct_id'];
|
||||
$tmpRow['name'] = $row['ecmproduct_name'];
|
||||
$tmpRow['id'] = $row['id'];
|
||||
$tmpRow['item_id'] = $row[''];
|
||||
$tmpRow['unit_id'] = $row['ecmproduct_unit_id'];
|
||||
$tmpRow['unit_name'] = $app_list_strings['ecmproducts_unit_dom'][$row['ecmproduct_unit_id']];
|
||||
$tmpRow['price_start'] = $row['price'];
|
||||
$tmpRow['price_netto'] = $row ['price'];
|
||||
$tmpRow['ecmvat_id'] = $product_row ['vat_id'];
|
||||
$tmpRow['ecmvat_name'] = $product_row ['vat_name'];
|
||||
$tmpRow['ecmvat_value'] = $product_row ['vat_value'];
|
||||
$tmpRow['quantity'] = $row ['quantity'];
|
||||
$tmpRow['total_vat'] = $row ['total'] * $product_row ['vat_value'] / 100;
|
||||
$tmpRow['total_brutto'] = $row ['total'] + $tmpRow['total_vat'];
|
||||
$tmpRow['total_netto'] = $row ['total'];
|
||||
$tmpRow['product_precision'] = $app_list_strings['ecmproducts_unit_dom_precision'][$row['ecmproduct_unit_id']];
|
||||
$return[] = $tmpRow;
|
||||
}
|
||||
|
||||
echo json_encode($return);
|
||||
return;
|
||||
}
|
||||
Reference in New Issue
Block a user