|
@@ -220,9 +220,9 @@ class CompanyHelper {
|
|
|
* @see POKAZ_OFERTY_AKTUALNE_FUNC: PokazOfertyHelper::get_deals_active_by_user($ID_BILLING_USERS, $only_active = true)
|
|
* @see POKAZ_OFERTY_AKTUALNE_FUNC: PokazOfertyHelper::get_deals_active_by_user($ID_BILLING_USERS, $only_active = true)
|
|
|
*/
|
|
*/
|
|
|
public function getDealsFull($ID_BILLING_USERS, $only_active = true) {
|
|
public function getDealsFull($ID_BILLING_USERS, $only_active = true) {
|
|
|
- $active_deals_by_id = $this->getDealsActive(array('ID_BILLING_USERS'=>$ID_BILLING_USERS, 'return_by'=>'ID', 'P_DEALNUMBER'=>true));
|
|
|
|
|
- $this->addDealsActiveInfo($active_deals_by_id, $ID_BILLING_USERS, $only_active);
|
|
|
|
|
- return $active_deals_by_id;
|
|
|
|
|
|
|
+ $deals = $this->getDealsAll(array('ID_BILLING_USERS'=>$ID_BILLING_USERS, 'return_by'=>'ID', 'P_DEALNUMBER'=>true));
|
|
|
|
|
+ $this->addDealsActiveInfo($deals, $ID_BILLING_USERS, $only_active);
|
|
|
|
|
+ return $deals;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -403,6 +403,59 @@ class CompanyHelper {
|
|
|
return $ses_x_a;
|
|
return $ses_x_a;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public function getDealsAll($params = array()) {
|
|
|
|
|
+ if (!$this->_db) return false;
|
|
|
|
|
+ $sqlReturnBy = V::get('return_by', '', $params);
|
|
|
|
|
+
|
|
|
|
|
+ $forceUpdate = false;
|
|
|
|
|
+ Lib::loadClass('ColumnDealsStatus');
|
|
|
|
|
+ ColumnDealsStatus::run_update($forceUpdate, $dbg_msgs);
|
|
|
|
|
+
|
|
|
|
|
+ $dealsActive = array();
|
|
|
|
|
+ $sql_left_join = "";
|
|
|
|
|
+ $sql_select_arr = array();
|
|
|
|
|
+ $sql_select_arr[] = "ds.`ID_DEALS`";
|
|
|
|
|
+ $sql_select_arr[] = "ds.`ID_BILLING_USERS`";
|
|
|
|
|
+ $sql_select_arr[] = "ds.`SERVICES_S_ADDRESS_STREET`";
|
|
|
|
|
+ $sql_select_arr[] = "concat(c.`P_NAME`, ' ', c.`P_NAME_SECOND`) as P_NAME";
|
|
|
|
|
+ if ('' != V::get('ID_BILLING_USERS', '', $params)) {
|
|
|
|
|
+ $sql_left_join .= "\n left join `DEALS_TABLE` as d on (d.`ID`=ds.`ID_DEALS`)";
|
|
|
|
|
+ $sql_select_arr[] = "d.`P_DEALNUMBER`";
|
|
|
|
|
+ $sql_select_arr[] = "d.`P_DEALDATE`";
|
|
|
|
|
+ $sql_select_arr[] = "d.`P_DEALDATE_TERM`";
|
|
|
|
|
+ $sql_select_arr[] = "d.`ID_OFFERS_GROUP`";
|
|
|
|
|
+ $sql_select_arr[] = "d.`ID_OFFERS_ON`";
|
|
|
|
|
+ $sql_select_arr[] = "d.`ID_OFFERS_OFF`";
|
|
|
|
|
+ $sql_select_arr[] = "d.`S_ADDRESS_STREET`";
|
|
|
|
|
+ }
|
|
|
|
|
+ $sql_where_arr = array();
|
|
|
|
|
+ //$sql_where_arr[] = "ds.`DEALS_ACTIVE`=1";
|
|
|
|
|
+ if ('' != ($user_id = V::get('ID_BILLING_USERS', '', $params))) {
|
|
|
|
|
+ $sql_where_arr[] = "ds.`ID_BILLING_USERS`='{$user_id}'";
|
|
|
|
|
+ }
|
|
|
|
|
+ if ('' != ($street = V::get('S_ADDRESS_STREET', '', $params))) {
|
|
|
|
|
+ $sql_where_arr[] = "(ds.`SERVICES_S_ADDRESS_STREET`='{$street}' or concat(',', ds.`SERVICES_S_ADDRESS_STREET`, ',') like '%,{$street},%')";
|
|
|
|
|
+ }
|
|
|
|
|
+ $sql_where_arr = implode("\n and ", $sql_where_arr);
|
|
|
|
|
+ $sql = "select " . implode("\n, ", $sql_select_arr) . "
|
|
|
|
|
+ from `temp_DEALS_STATUS` as ds
|
|
|
|
|
+ left join `{$this->_tbl}` as c on (c.`ID`=ds.`ID_BILLING_USERS`)
|
|
|
|
|
+ {$sql_left_join}
|
|
|
|
|
+ where {$sql_where_arr}
|
|
|
|
|
+ order by ds.`ID_DEALS` DESC
|
|
|
|
|
+ ";
|
|
|
|
|
+ if(V::get('DBG_SQL', 0, $_GET, 'int') > 0){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">sql (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($sql);echo'</pre>';}
|
|
|
|
|
+ $res = $this->_db->query($sql);
|
|
|
|
|
+ while ($r = $this->_db->fetch($res)) {
|
|
|
|
|
+ if ($sqlReturnBy == 'ID') {
|
|
|
|
|
+ $dealsActive[$r->ID_DEALS]= $r;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ $dealsActive[$r->ID_BILLING_USERS][] = $r;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return $dealsActive;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* @see POKAZ_OFERTY_AKTUALNE_FUNC: PokazOfertyHelper::get_deals_active($params)
|
|
* @see POKAZ_OFERTY_AKTUALNE_FUNC: PokazOfertyHelper::get_deals_active($params)
|
|
|
*/
|
|
*/
|