Files
crm.twinpol.com/modules/EcmReportsBackUp20151106/AnalysisEcmQuoteInclude.php
2025-05-12 15:44:39 +00:00

65 lines
1.9 KiB
PHP
Executable File

<?php
if (!defined('sugarEntry') || !sugarEntry)
die('Not A Valid Entry Point');
/**
*
* @param array $where Tablica typu: klucz=> wartosc gdzie klucz to
*/
function AnalysisEcmQuote($where) {
global $db;
$query = "SELECT status, register_date FROM ecmquotes WHERE deleted=0 ";
//die(1);
if (isset($where) && is_array($where) && count($where) > 0) {
$wherereturn = array();
foreach ($where as $key => $value) {
switch ($key) {
case 'register_date_from':
$wherereturn[] = "register_date>='" . $value . "'";
break;
case 'register_date_to':
$wherereturn[] = "register_date<='" . $value . "'";
break;
case 'accountName':
$wherereturn[] = "parent_name LIKE '%" . trim($value) . "%'";
$wherereturn[] = "parent_type ='Accounts'";
break;
case 'accountId':
$wherereturn[] = "parent_id = '" . trim($value) . "'";
break;
}
}
if (count($wherereturn) > 0) {
$query .= " AND " . implode(" AND ", $wherereturn);
}
}
$query .= " ORDER BY register_date";
$result = $db->query($query);
if ($result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
$return[substr($row['register_date'], 0, 7)][$row['status']] += 1;
}
} else {
$return = NULL;
}
return $return;
}
function getProductCategoryList() {
global $db;
$resultArray = NULL;
$query = "SELECT id, name FROM ecmproductcategories WHERE deleted=0 ORDER BY name, date_entered";
$result = $db->query($query);
if ($result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
$resultArray[$row['id']] = $row['name'];
};
}
return $resultArray;
}
?>