CommonITILObject::getUsedSupplierBetween PHP Метод

getUsedSupplierBetween() публичный Метод

Get enterprises which have itil object assigned to between 2 dates
public getUsedSupplierBetween ( $date1 = '', $date2 = '' ) : array
$date1 date : begin date (default '')
$date2 date : end date (default '')
Результат array contains the distinct enterprises which have any tickets assigned to.
    function getUsedSupplierBetween($date1 = '', $date2 = '')
    {
        global $DB, $CFG_GLPI;
        $linkclass = new $this->supplierlinkclass();
        $linktable = $linkclass->getTable();
        $query = "SELECT DISTINCT `glpi_suppliers`.`id` AS suppliers_id_assign,\n                                `glpi_suppliers`.`name` AS name\n                FROM `" . $this->getTable() . "`\n                LEFT JOIN `{$linktable}`\n                  ON (`{$linktable}`.`" . $this->getForeignKeyField() . "` = `" . $this->getTable() . "`.`id`\n                      AND `{$linktable}`.`type` = '" . CommonITILActor::ASSIGN . "')\n                LEFT JOIN `glpi_suppliers`\n                     ON (`glpi_suppliers`.`id` = `{$linktable}`.`suppliers_id`)\n                WHERE NOT `" . $this->getTable() . "`.`is_deleted` " . getEntitiesRestrictRequest("AND", $this->getTable());
        if (!empty($date1) || !empty($date2)) {
            $query .= " AND (" . getDateRequest("`" . $this->getTable() . "`.`date`", $date1, $date2) . "\n                          OR " . getDateRequest("`" . $this->getTable() . "`.`closedate`", $date1, $date2) . ") ";
        }
        $query .= " ORDER BY name";
        $tab = array();
        $result = $DB->query($query);
        if ($DB->numrows($result) > 0) {
            while ($line = $DB->fetch_assoc($result)) {
                $tmp["id"] = $line["suppliers_id_assign"];
                $tmp["link"] = "<a href='" . $CFG_GLPI["root_doc"] . "/front/supplier.form.php?id=" . $line["suppliers_id_assign"] . "'>" . $line["name"] . "</a>";
                $tab[] = $tmp;
            }
        }
        return $tab;
    }
CommonITILObject