update
This commit is contained in:
@@ -12,11 +12,11 @@ if ($_GET['key'] != $restConfig['e5Key']) {
|
||||
exit;
|
||||
}
|
||||
// Enable SugarCRM features
|
||||
if(!defined('sugarEntry'))define('sugarEntry', true);
|
||||
if (!defined('sugarEntry')) define('sugarEntry', true);
|
||||
require_once('./include/entryPoint.php');
|
||||
// Make action
|
||||
switch ($_GET["action"]) {
|
||||
case 'getInvoice':
|
||||
case 'getInvoice':
|
||||
sendInvoice($_GET['record']);
|
||||
break;
|
||||
case 'getProduct':
|
||||
@@ -25,5 +25,52 @@ switch ($_GET["action"]) {
|
||||
case 'copySaleFromTwinpol':
|
||||
copySaleFromTwinpol($_GET['record']);
|
||||
break;
|
||||
}
|
||||
?>
|
||||
case 'export.products.list':
|
||||
if ($_GET['since'] == null) {
|
||||
echo 'No since date';
|
||||
exit;
|
||||
}
|
||||
$products = [];
|
||||
$db = $GLOBALS['db'];
|
||||
$sixMonthsAgo = (new DateTime())->modify('-6 months')->format('Y-m-d H:i:s');
|
||||
$sinceDate = date('Y-m-d H:i:s', intval($_GET['since']));;
|
||||
$query = "
|
||||
SELECT
|
||||
p.id,
|
||||
p.name,
|
||||
p.code,
|
||||
p.ean,
|
||||
GROUP_CONCAT(s.stock_address SEPARATOR ', ') AS stock_addresses
|
||||
FROM ecmproducts p
|
||||
LEFT JOIN ecmproducts_stock_addresses s ON p.id = s.ecmproduct_id
|
||||
WHERE p.active = 1
|
||||
AND p.deleted = 0
|
||||
AND p.date_modified > '$sixMonthsAgo'
|
||||
AND (p.exportedAt IS NULL OR p.exportedAt > '$sinceDate')
|
||||
GROUP BY p.id, p.name, p.code
|
||||
";
|
||||
$r = $db->query($query);
|
||||
while ($row = $db->fetchByAssoc($r)) {
|
||||
$p = [];
|
||||
$p['id'] = $row['id'];
|
||||
$p['ean'] = $row['ean'];
|
||||
$p['name'] = $row['name'];
|
||||
$p['code'] = $row['code'];
|
||||
$p['stock_addresses'] = $row['stock_addresses'];
|
||||
array_push($products, $p);
|
||||
}
|
||||
echo json_encode($products);
|
||||
break;
|
||||
case 'export.products.setExportedAt':
|
||||
{
|
||||
if ($_GET['exportedAt'] == null || $_GET['id'] == null) {
|
||||
echo 'Wrong parameters';
|
||||
exit;
|
||||
}
|
||||
$db = $GLOBALS['db'];
|
||||
$exportedAt = date('Y-m-d H:i:s', intval($_GET['exportedAt']));;
|
||||
$id = $_GET['id'];
|
||||
$db->query("UPDATE ecmproducts SET exportedAt='$exportedAt' WHERE id='$id'");
|
||||
break;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user