本文整理汇总了PHP中Infocom::getWarrantyExpir方法的典型用法代码示例。如果您正苦于以下问题:PHP Infocom::getWarrantyExpir方法的具体用法?PHP Infocom::getWarrantyExpir怎么用?PHP Infocom::getWarrantyExpir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Infocom
的用法示例。
在下文中一共展示了Infocom::getWarrantyExpir方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: pdfForItem
static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
{
global $CFG_GLPI;
$ID = $item->getField('id');
if (!Session::haveRight("infocom", "r")) {
return false;
}
$ic = new Infocom();
$pdf->setColumnsSize(100);
if ($ic->getFromDBforDevice(get_class($item), $ID)) {
$pdf->displayTitle("<b>" . __('Financial and administrative information') . "</b>");
$pdf->setColumnsSize(50, 50);
$pdf->displayLine("<b><i>" . sprintf(__('%1$s: %2$s'), __('Supplier') . "</i></b>", Html::clean(Dropdown::getDropdownName("glpi_suppliers", $ic->fields["suppliers_id"]))), "<b><i>" . sprintf(__('%1$s: %2$s'), __('Budget') . "</i></b>", Html::clean(Dropdown::getDropdownName("glpi_budgets", $ic->fields["budgets_id"]))));
$pdf->displayLine("<b><i>" . sprintf(__('%1$s: %2$s'), __('Order number') . "</i></b>", $ic->fields["order_number"]), "<b><i>" . sprintf(__('%1$s: %2$s'), __('Order date') . "</i></b>", Html::convDate($ic->fields["order_date"])));
$pdf->displayLine("<b><i>" . sprintf(__('%1$s: %2$s'), __('Immobilization number') . "</i></b>", $ic->fields["immo_number"]), "<b><i>" . sprintf(__('%1$s: %2$s'), __('Date of purchase') . "</i></b>", Html::convDate($ic->fields["buy_date"])));
$pdf->displayLine("<b><i>" . sprintf(__('%1$s: %2$s'), __('Invoice number') . "</i></b>", $ic->fields["bill"]), "<b><i>" . sprintf(__('%1$s: %2$s'), __('Delivery date') . "</i></b>", Html::convDate($ic->fields["delivery_date"])));
$pdf->displayLine("<b><i>" . sprintf(__('%1$s: %2$s'), __('Delivery form') . "</i></b>", $ic->fields["delivery_number"]), "<b><i>" . sprintf(__('%1$s: %2$s'), __('Startup date') . "</i></b>", Html::convDate($ic->fields["use_date"])));
$pdf->displayLine("<b><i>" . sprintf(__('%1$s: %2$s'), __('Value') . "</i></b>", Html::clean(Html::formatNumber($ic->fields["value"]))), "<b><i>" . sprintf(__('%1$s: %2$s'), _('Date of last physical inventory') . "</i></b>", Html::convDate($ic->fields["inventory_date"])));
$pdf->displayLine("<b><i>" . sprintf(__('%1$s: %2$s'), __('Warranty extension value') . "</i></b>", Html::clean(Html::formatNumber($ic->fields["warranty_value"]))), "<b><i>" . sprintf(__('%1$s: %2$s'), __('Amortization duration') . "</i></b>", sprintf(__('%1$s (%2$s)'), sprintf(_n('%d year', '%d years', $ic->fields["sink_time"]), $ic->fields["sink_time"]), Infocom::getAmortTypeName($ic->fields["sink_type"]))));
$pdf->displayLine("<b><i>" . sprintf(__('%1$s: %2$s'), __('Account net value') . "</i></b>", Infocom::Amort($ic->fields["sink_type"], $ic->fields["value"], $ic->fields["sink_time"], $ic->fields["sink_coeff"], $ic->fields["warranty_date"], $ic->fields["use_date"], $CFG_GLPI['date_tax'], "n")), "<b><i>" . sprintf(__('%1$s: %2$s'), __('Amortization coefficient') . "</i></b>", $ic->fields["sink_coeff"]));
$pdf->displayLine("<b><i>" . sprintf(__('%1$s: %2$s'), __('TCO (value + tracking cost)') . "</i></b>", Html::clean(Infocom::showTco($item->getField('ticket_tco'), $ic->fields["value"]))), "<b><i>" . sprintf(__('%1$s: %2$s'), __('Monthly TCO') . "</i></b>", Html::clean(Infocom::showTco($item->getField('ticket_tco'), $ic->fields["value"], $ic->fields["warranty_date"]))));
PluginPdfCommon::mainLine($pdf, $ic, 'comment');
$pdf->setColumnsSize(100);
$pdf->displayTitle("<b>" . __('Warranty information') . "</b>");
$pdf->setColumnsSize(50, 50);
$pdf->displayLine("<b><i>" . sprintf(__('%1$s: %2$s'), __('Start date of warranty') . "</i></b>", Html::convDate($ic->fields["warranty_date"])), "<b><i>" . sprintf(__('%1$s: %2$s'), __('Warranty duration') . "</i></b>", sprintf(__('%1$s - %2$s'), sprintf(_n('%d month', '%d months', $ic->fields["warranty_duration"]), $ic->fields["warranty_duration"]), sprintf(__('Valid to %s'), Infocom::getWarrantyExpir($ic->fields["buy_date"], $ic->fields["warranty_duration"])))));
$col1 = "<b><i>" . __('Alarms on financial and administrative information') . "</i></b>";
if ($ic->fields["alert"] == 0) {
$col1 = sprintf(__('%1$s: %2$s'), $col1, __('No'));
} else {
if ($ic->fields["alert"] == 4) {
$col1 = sprintf(__('%1$s: %2$s'), $col1, __('Warranty expiration date'));
}
}
$pdf->displayLine("<b><i>" . sprintf(__('%1$s: %2$s'), __('Warranty information') . "</i></b>", $ic->fields["warranty_info"]), $col1);
} else {
$pdf->displayTitle("<b>" . __('No financial information', 'pdf') . "</b>");
}
$pdf->displaySpace();
}
示例2: showForSupplier
/**
* Print an HTML array with contracts associated to the enterprise
*
* @since version 0.84
*
* @param $supplier Supplier object
*
* @return Nothing (display)
**/
static function showForSupplier(Supplier $supplier)
{
global $DB, $CFG_GLPI;
$ID = $supplier->fields['id'];
if (!Session::haveRight("contract", "r") || !$supplier->can($ID, 'r')) {
return false;
}
$canedit = $supplier->can($ID, 'w');
$rand = mt_rand();
$query = "SELECT `glpi_contracts`.*,\n `glpi_contracts_suppliers`.`id` AS assocID,\n `glpi_entities`.`id` AS entity\n FROM `glpi_contracts_suppliers`, `glpi_contracts`\n LEFT JOIN `glpi_entities` ON (`glpi_entities`.`id`=`glpi_contracts`.`entities_id`)\n WHERE `glpi_contracts_suppliers`.`suppliers_id` = '{$ID}'\n AND `glpi_contracts_suppliers`.`contracts_id`=`glpi_contracts`.`id`" . getEntitiesRestrictRequest(" AND", "glpi_contracts", '', '', true) . "\n ORDER BY `glpi_entities`.`completename`,\n `glpi_contracts`.`name`";
$result = $DB->query($query);
$contracts = array();
$used = array();
if ($number = $DB->numrows($result)) {
while ($data = $DB->fetch_assoc($result)) {
$contracts[$data['assocID']] = $data;
$used[$data['id']] = $data['id'];
}
}
if ($canedit) {
echo "<div class='firstbloc'>";
echo "<form name='contractsupplier_form{$rand}' id='contractsupplier_form{$rand}' method='post'\n action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
echo "<input type='hidden' name='suppliers_id' value='{$ID}'>";
echo "<table class='tab_cadre_fixe'>";
echo "<tr class='tab_bg_2'><th colspan='2'>" . __('Add a contract') . "</th></tr>";
echo "<tr class='tab_bg_1'><td class='right'>";
Contract::dropdown(array('used' => $used, 'entity' => $supplier->fields["entities_id"], 'entity_sons' => $supplier->fields["is_recursive"], 'nochecklimit' => true));
echo "</td><td class='center'>";
echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
echo "</td></tr>";
echo "</table>";
Html::closeForm();
echo "</div>";
}
echo "<div class='spaced'>";
if ($canedit && $number) {
Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
$massiveactionparams = array('num_displayed' => $number);
Html::showMassiveActions(__CLASS__, $massiveactionparams);
}
echo "<table class='tab_cadre_fixe'>";
echo "<tr>";
if ($canedit && $number) {
echo "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand) . "</th>";
}
echo "<th>" . __('Name') . "</th>";
echo "<th>" . __('Entity') . "</th>";
echo "<th>" . _x('phone', 'Number') . "</th>";
echo "<th>" . __('Contract type') . "</th>";
echo "<th>" . __('Start date') . "</th>";
echo "<th>" . __('Initial contract period') . "</th>";
echo "</tr>";
$used = array();
foreach ($contracts as $data) {
$cID = $data["id"];
$used[$cID] = $cID;
$assocID = $data["assocID"];
echo "<tr class='tab_bg_1" . ($data["is_deleted"] ? "_2" : "") . "'>";
if ($canedit) {
echo "<td>";
Html::showMassiveActionCheckBox(__CLASS__, $data["assocID"]);
echo "</td>";
}
$name = $data["name"];
if ($_SESSION["glpiis_ids_visible"] || empty($data["name"])) {
$name = sprintf(__('%1$s (%2$s)'), $name, $data["id"]);
}
echo "<td class='center b'>\n <a href='" . $CFG_GLPI["root_doc"] . "/front/contract.form.php?id={$cID}'>" . $name . "</a>";
echo "</td>";
echo "<td class='center'>" . Dropdown::getDropdownName("glpi_entities", $data["entity"]);
echo "</td><td class='center'>" . $data["num"] . "</td>";
echo "<td class='center'>" . Dropdown::getDropdownName("glpi_contracttypes", $data["contracttypes_id"]) . "</td>";
echo "<td class='center'>" . Html::convDate($data["begin_date"]) . "</td>";
echo "<td class='center'>";
sprintf(_n('%d month', '%d months', $data["duration"]), $data["duration"]);
if ($data["begin_date"] != '' && !empty($data["begin_date"])) {
echo " -> " . Infocom::getWarrantyExpir($data["begin_date"], $data["duration"], 0, true);
}
echo "</td>";
echo "</tr>";
}
echo "</table>";
if ($canedit && $number) {
$paramsma['ontop'] = false;
Html::showMassiveActions(__CLASS__, $paramsma);
Html::closeForm();
}
echo "</div>";
}
示例3:
echo "<td> " . Html::convDate($data['buy_date']) . " </td>";
if ($data["warranty_duration"]) {
echo "<td> " . Infocom::getWarrantyExpir($data["buy_date"], $data["warranty_duration"]) . " </td>";
} else {
echo "<td> " . NOT_AVAILABLE . " </td>";
}
} else {
echo "<td> " . NOT_AVAILABLE . " </td><td> " . NOT_AVAILABLE . " </td>";
}
if ($data['type']) {
echo "<td class='b'> " . $data['type'] . " </td>";
} else {
echo "<td> " . NOT_AVAILABLE . " </td>";
}
if ($data['begin_date']) {
echo "<td> " . Html::convDate($data['begin_date']) . " </td>";
if ($data["duration"]) {
echo "<td> " . Infocom::getWarrantyExpir($data["begin_date"], $data["duration"]) . " </td>";
} else {
echo "<td> " . NOT_AVAILABLE . " </td>";
}
} else {
echo "<td> " . NOT_AVAILABLE . " </td><td> " . NOT_AVAILABLE . " </td>";
}
echo "</tr>\n";
}
echo "</table><br><hr><br>";
}
}
}
Html::footer();
示例4: cronContract
/**
* Cron action on contracts : alert depending of the config : on notice and expire
*
* @param $task for log, if NULL display (default NULL)
**/
static function cronContract($task = NULL)
{
global $DB, $CFG_GLPI;
if (!$CFG_GLPI["use_mailing"]) {
return 0;
}
$message = array();
$items_notice = array();
$items_end = array();
$cron_status = 0;
$contract_infos[Alert::END] = array();
$contract_infos[Alert::NOTICE] = array();
$contract_messages = array();
foreach (Entity::getEntitiesToNotify('use_contracts_alert') as $entity => $value) {
$before = Entity::getUsedConfig('send_contracts_alert_before_delay', $entity);
$query_notice = "SELECT `glpi_contracts`.*\n FROM `glpi_contracts`\n LEFT JOIN `glpi_alerts`\n ON (`glpi_contracts`.`id` = `glpi_alerts`.`items_id`\n AND `glpi_alerts`.`itemtype` = 'Contract'\n AND `glpi_alerts`.`type`='" . Alert::NOTICE . "')\n WHERE (`glpi_contracts`.`alert` & " . pow(2, Alert::NOTICE) . ") >'0'\n AND `glpi_contracts`.`is_deleted` = '0'\n AND `glpi_contracts`.`begin_date` IS NOT NULL\n AND `glpi_contracts`.`duration` <> '0'\n AND `glpi_contracts`.`notice` <> '0'\n AND DATEDIFF(ADDDATE(`glpi_contracts`.`begin_date`,\n INTERVAL `glpi_contracts`.`duration` MONTH),\n CURDATE()) > '0'\n AND DATEDIFF(ADDDATE(`glpi_contracts`.`begin_date`,\n INTERVAL (`glpi_contracts`.`duration`\n -`glpi_contracts`.`notice`) MONTH),\n CURDATE()) < '{$before}'\n AND `glpi_alerts`.`date` IS NULL\n AND `glpi_contracts`.`entities_id` = '" . $entity . "'";
$query_end = "SELECT `glpi_contracts`.*\n FROM `glpi_contracts`\n LEFT JOIN `glpi_alerts`\n ON (`glpi_contracts`.`id` = `glpi_alerts`.`items_id`\n AND `glpi_alerts`.`itemtype` = 'Contract'\n AND `glpi_alerts`.`type`='" . Alert::END . "')\n WHERE (`glpi_contracts`.`alert` & " . pow(2, Alert::END) . ") > '0'\n AND `glpi_contracts`.`is_deleted` = '0'\n AND `glpi_contracts`.`begin_date` IS NOT NULL\n AND `glpi_contracts`.`duration` <> '0'\n AND DATEDIFF(ADDDATE(`glpi_contracts`.`begin_date`,\n INTERVAL (`glpi_contracts`.`duration`) MONTH),\n CURDATE()) < '{$before}'\n AND `glpi_alerts`.`date` IS NULL\n AND `glpi_contracts`.`entities_id` = '" . $entity . "'";
$querys = array('notice' => $query_notice, 'end' => $query_end);
foreach ($querys as $type => $query) {
foreach ($DB->request($query) as $data) {
$entity = $data['entities_id'];
$message = sprintf(__('%1$s: %2$s') . "<br>\n", $data["name"], Infocom::getWarrantyExpir($data["begin_date"], $data["duration"], $data["notice"]));
$contract_infos[$type][$entity][$data['id']] = $data;
if (!isset($contract_messages[$type][$entity])) {
switch ($type) {
case 'notice':
$contract_messages[$type][$entity] = __('Contract entered in notice time') . "<br>";
break;
case 'end':
$contract_messages[$type][$entity] = __('Contract ended') . "<br>";
break;
}
}
$contract_messages[$type][$entity] .= $message;
}
}
// Get contrats with periodicity alerts
$query_periodicity = "SELECT `glpi_contracts`.*\n FROM `glpi_contracts`\n WHERE `glpi_contracts`.`alert` & " . pow(2, Alert::PERIODICITY) . " > '0'\n AND `glpi_contracts`.`entities_id` = '" . $entity . "' ";
// Foreach ones :
foreach ($DB->request($query_periodicity) as $data) {
$entity = $data['entities_id'];
// Compute end date + 12 month : do not send alerts after
$end_alert = date('Y-m-d', strtotime($data['begin_date'] . " +" . ($data['duration'] + 12) . " month"));
if (!empty($data['begin_date']) && $data['periodicity'] && $end_alert > date('Y-m-d')) {
$todo = array('periodicity' => Alert::PERIODICITY);
if ($data['alert'] & pow(2, Alert::NOTICE)) {
$todo['periodicitynotice'] = Alert::NOTICE;
}
// Get previous alerts
foreach ($todo as $type => $event) {
$previous_alerts[$type] = Alert::getAlertDate(__CLASS__, $data['id'], $event);
}
// compute next alert date based on already send alerts (or not)
foreach ($todo as $type => $event) {
$next_alerts[$type] = date('Y-m-d', strtotime($data['begin_date'] . " -" . $before . " day"));
if ($type == Alert::NOTICE) {
$next_alerts[$type] = date('Y-m-d', strtotime($next_alerts[$type] . " -" . $data['notice'] . " month"));
}
$today_limit = date('Y-m-d', strtotime(date('Y-m-d') . " -" . $data['periodicity'] . " month"));
// Init previous by begin date if not set
if (empty($previous_alerts[$type])) {
$previous_alerts[$type] = $today_limit;
}
while ($next_alerts[$type] < $previous_alerts[$type] && $next_alerts[$type] < $end_alert) {
$next_alerts[$type] = date('Y-m-d', strtotime($next_alerts[$type] . " +" . $data['periodicity'] . " month"));
}
// If this date is passed : clean alerts and send again
if ($next_alerts[$type] <= date('Y-m-d')) {
$alert = new Alert();
$alert->clear(__CLASS__, $data['id'], $event);
$real_alert_date = date('Y-m-d', strtotime($next_alerts[$type] . " +" . $before . " day"));
$message = sprintf(__('%1$s: %2$s') . "<br>\n", $data["name"], Html::convDate($real_alert_date));
$data['alert_date'] = $real_alert_date;
$data['items'] = Contract_Item::getItemsForContract($data['id'], $entity);
$contract_infos[$type][$entity][$data['id']] = $data;
switch ($type) {
case 'periodicitynotice':
$contract_messages[$type][$entity] = __('Contract entered in notice time for period') . "<br>";
break;
case 'periodicity':
$contract_messages[$type][$entity] = __('Contract period ended') . "<br>";
break;
}
$contract_messages[$type][$entity] .= $message;
}
}
}
}
}
foreach (array('notice' => Alert::NOTICE, 'end' => Alert::END, 'periodicity' => Alert::PERIODICITY, 'periodicitynotice' => Alert::NOTICE) as $event => $type) {
if (isset($contract_infos[$event]) && count($contract_infos[$event])) {
foreach ($contract_infos[$event] as $entity => $contracts) {
if (NotificationEvent::raiseEvent($event, new self(), array('entities_id' => $entity, 'items' => $contracts))) {
$message = $contract_messages[$event][$entity];
$cron_status = 1;
//.........这里部分代码省略.........
示例5: getDatasForTemplate
/**
* Get all data needed for template processing
*
* @param $event
* @param $options array
**/
function getDatasForTemplate($event, $options = array())
{
$this->datas['##contract.entity##'] = Dropdown::getDropdownName('glpi_entities', $options['entities_id']);
$events = $this->getEvents();
$this->datas['##contract.action##'] = sprintf(__('%1$s - %2$s'), __('Contracts alarm'), $events[$event]);
foreach ($options['items'] as $id => $contract) {
$tmp = array();
$tmp['##contract.name##'] = $contract['name'];
$tmp['##contract.number##'] = $contract['num'];
if ($contract['contracttypes_id']) {
$tmp['##contract.type##'] = Dropdown::getDropdownName('glpi_contracttypes', $contract['contracttypes_id']);
} else {
$tmp['##contract.type##'] = "";
}
switch ($event) {
case 'end':
$tmp['##contract.time##'] = Infocom::getWarrantyExpir($contract["begin_date"], $contract["duration"]);
break;
case 'notice':
$tmp['##contract.time##'] = Infocom::getWarrantyExpir($contract["begin_date"], $contract["duration"], $contract["notice"]);
break;
case 'periodicity':
case 'periodicitynotice':
if (isset($contract["alert_date"])) {
$tmp['##contract.time##'] = Html::convDate($contract["alert_date"]);
} else {
if (isset($options['_debug'])) {
$tmp['##contract.time##'] = Html::convDate($_SESSION['glpi_currenttime']);
}
}
break;
}
$tmp['##contract.url##'] = $this->formatURL($options['additionnaloption']['usertype'], "Contract_" . $id);
$tmp['##contract.items.number##'] = 0;
$tmp['##contract.items##'] = '';
if (isset($contract['items']) && count($contract['items'])) {
$toadd = array();
foreach ($contract['items'] as $itemtype => $item) {
if ($type = getItemForItemtype($itemtype)) {
$typename = $type->getTypeName();
foreach ($item as $item_data) {
$toadd[] = sprintf(__('%1$s - %2$s'), $typename, $item_data['name']);
$tmp['##contract.items.number##']++;
}
}
}
if (count($toadd)) {
$tmp["##contract.items##"] = implode(', ', $toadd);
}
}
$this->datas['contracts'][] = $tmp;
}
switch ($event) {
case 'end':
$this->datas['##lang.contract.time##'] = __('Contract expired since the');
break;
case 'notice':
$this->datas['##lang.contract.time##'] = __('Contract with notice since the');
break;
case 'periodicity':
$this->datas['##lang.contract.time##'] = __('Contract reached the end of a period since the');
break;
case 'periodicitynotice':
$this->datas['##lang.contract.time##'] = __('Contract with notice for the current period since the');
break;
}
$this->getTags();
foreach ($this->tag_descriptions[NotificationTarget::TAG_LANGUAGE] as $tag => $values) {
if (!isset($this->datas[$tag])) {
$this->datas[$tag] = $values['label'];
}
}
}
示例6: display_infocoms_report
/** Display an infocom report
*
* @param $itemtype item type
* @param $begin begin date
* @param $end end date
**/
function display_infocoms_report($itemtype, $begin, $end)
{
global $DB, $valeurtot, $valeurnettetot, $valeurnettegraphtot, $valeurgraphtot, $CFG_GLPI;
$itemtable = getTableForItemType($itemtype);
$query = "SELECT `glpi_infocoms`.*,\n `{$itemtable}`.`name` AS name,\n `{$itemtable}`.`ticket_tco`,\n `glpi_entities`.`completename` AS entname,\n `glpi_entities`.`id` AS entID\n FROM `glpi_infocoms`\n INNER JOIN `{$itemtable}` ON (`{$itemtable}`.`id` = `glpi_infocoms`.`items_id`\n AND `glpi_infocoms`.`itemtype` = '{$itemtype}')\n LEFT JOIN `glpi_entities` ON (`{$itemtable}`.`entities_id` = `glpi_entities`.`id`)\n WHERE `{$itemtable}`.`is_template` = '0' " . getEntitiesRestrictRequest("AND", $itemtable);
if (!empty($begin)) {
$query .= " AND (`glpi_infocoms`.`buy_date` >= '{$begin}'\n OR `glpi_infocoms`.`use_date` >= '{$begin}') ";
}
if (!empty($end)) {
$query .= " AND (`glpi_infocoms`.`buy_date` <= '{$end}'\n OR `glpi_infocoms`.`use_date` <= '{$end}') ";
}
$query .= " ORDER BY entname ASC, `buy_date`, `use_date`";
$display_entity = Session::isMultiEntitiesMode();
$result = $DB->query($query);
if ($DB->numrows($result) > 0 && ($item = getItemForItemtype($itemtype))) {
echo "<h2>" . $item->getTypeName(1) . "</h2>";
echo "<table class='tab_cadre'><tr><th>" . __('Name') . "</th>";
if ($display_entity) {
echo "<th>" . __('Entity') . "</th>";
}
echo "<th>" . _x('price', 'Value') . "</th><th>" . __('ANV') . "</th>";
echo "<th>" . __('TCO') . "</th><th>" . __('Date of purchase') . "</th>";
echo "<th>" . __('Startup date') . "</th><th>" . __('Warranty expiration date') . "</th></tr>";
$valeursoustot = 0;
$valeurnettesoustot = 0;
$valeurnettegraph = array();
$valeurgraph = array();
while ($line = $DB->fetch_assoc($result)) {
if (isset($line["is_global"]) && $line["is_global"] && $item->getFromDB($line["items_id"])) {
$line["value"] *= Computer_Item::countForItem($item);
}
if ($line["value"] > 0) {
$valeursoustot += $line["value"];
}
$valeurnette = Infocom::Amort($line["sink_type"], $line["value"], $line["sink_time"], $line["sink_coeff"], $line["buy_date"], $line["use_date"], $CFG_GLPI["date_tax"], "n");
$tmp = Infocom::Amort($line["sink_type"], $line["value"], $line["sink_time"], $line["sink_coeff"], $line["buy_date"], $line["use_date"], $CFG_GLPI["date_tax"], "all");
if (is_array($tmp) && count($tmp) > 0) {
foreach ($tmp["annee"] as $key => $val) {
if ($tmp["vcnetfin"][$key] > 0) {
if (!isset($valeurnettegraph[$val])) {
$valeurnettegraph[$val] = 0;
}
$valeurnettegraph[$val] += $tmp["vcnetdeb"][$key];
}
}
}
if (!empty($line["buy_date"])) {
$year = substr($line["buy_date"], 0, 4);
if ($line["value"] > 0) {
if (!isset($valeurgraph[$year])) {
$valeurgraph[$year] = 0;
}
$valeurgraph[$year] += $line["value"];
}
}
$valeurnettesoustot += str_replace(" ", "", $valeurnette);
echo "<tr class='tab_bg_1'><td>" . $line["name"] . "</td>";
if ($display_entity) {
echo "<td>" . $line['entname'] . "</td>";
}
echo "<td class='right'>" . Html::formatNumber($line["value"]) . "</td>" . "<td class='right'>" . Html::formatNumber($valeurnette) . "</td>" . "<td class='right'>" . Infocom::showTco($line["ticket_tco"], $line["value"]) . "</td>" . "<td>" . Html::convDate($line["buy_date"]) . "</td>" . "<td>" . Html::convDate($line["use_date"]) . "</td>" . "<td>" . Infocom::getWarrantyExpir($line["buy_date"], $line["warranty_duration"]) . "</td></tr>";
}
$valeurtot += $valeursoustot;
$valeurnettetot += $valeurnettesoustot;
$tmpmsg = sprintf(__('Total: Value=%1$s - Account net value=%2$s'), Html::formatNumber($valeursoustot), Html::formatNumber($valeurnettesoustot));
echo "<tr><td colspan='6' class='center'><h3>{$tmpmsg}</h3></td></tr>";
if (count($valeurnettegraph) > 0) {
echo "<tr><td colspan='5' class='center'>";
ksort($valeurnettegraph);
$valeurnettegraphdisplay = array_map('round', $valeurnettegraph);
foreach ($valeurnettegraph as $key => $val) {
if (!isset($valeurnettegraphtot[$key])) {
$valeurnettegraphtot[$key] = 0;
}
$valeurnettegraphtot[$key] += $valeurnettegraph[$key];
}
Stat::showGraph(array(__('Account net value') => $valeurnettegraphdisplay), array('title' => __('Account net value'), 'width' => 400));
echo "</td></tr>";
}
if (count($valeurgraph) > 0) {
echo "<tr><td colspan='5' class='center'>";
ksort($valeurgraph);
$valeurgraphdisplay = array_map('round', $valeurgraph);
foreach ($valeurgraph as $key => $val) {
if (!isset($valeurgraphtot[$key])) {
$valeurgraphtot[$key] = 0;
}
$valeurgraphtot[$key] += $valeurgraph[$key];
}
Stat::showGraph(array(_x('price', 'Value') => $valeurgraphdisplay), array('title' => _x('price', 'Value'), 'width' => 400));
echo "</td></tr>";
}
echo "</table>";
return true;
//.........这里部分代码省略.........
示例7: showForItem
//.........这里部分代码省略.........
$query = "SELECT `glpi_contracts_items`.*\n FROM `glpi_contracts_items`,\n `glpi_contracts`\n LEFT JOIN `glpi_entities` ON (`glpi_contracts`.`entities_id`=`glpi_entities`.`id`)\n WHERE `glpi_contracts`.`id`=`glpi_contracts_items`.`contracts_id`\n AND `glpi_contracts_items`.`items_id` = '{$ID}'\n AND `glpi_contracts_items`.`itemtype` = '{$itemtype}'" . getEntitiesRestrictRequest(" AND", "glpi_contracts", '', '', true) . "\n ORDER BY `glpi_contracts`.`name`";
$result = $DB->query($query);
$contracts = array();
$used = array();
if ($number = $DB->numrows($result)) {
while ($data = $DB->fetch_assoc($result)) {
$contracts[$data['id']] = $data;
$used[$data['contracts_id']] = $data['contracts_id'];
}
}
if ($canedit && $withtemplate != 2) {
echo "<div class='firstbloc'>";
echo "<form name='contractitem_form{$rand}' id='contractitem_form{$rand}' method='post'\n action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
echo "<input type='hidden' name='items_id' value='{$ID}'>";
echo "<input type='hidden' name='itemtype' value='{$itemtype}'>";
echo "<table class='tab_cadre_fixe'>";
echo "<tr class='tab_bg_2'><th colspan='2'>" . __('Add a contract') . "</th></tr>";
echo "<tr class='tab_bg_1'><td>";
Contract::dropdown(array('entity' => $item->getEntityID(), 'used' => $used));
echo "</td><td class='center'>";
echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
echo "</td></tr>";
echo "</table>";
Html::closeForm();
echo "</div>";
}
echo "<div class='spaced'>";
if ($withtemplate != 2) {
if ($canedit && $number) {
Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
$massiveactionparams = array('num_displayed' => $number, 'container' => 'mass' . __CLASS__ . $rand);
Html::showMassiveActions($massiveactionparams);
}
}
echo "<table class='tab_cadre_fixehov'>";
$header_begin = "<tr>";
$header_top = '';
$header_bottom = '';
$header_end = '';
if ($canedit && $number && $withtemplate != 2) {
$header_top .= "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
$header_top .= "</th>";
$header_bottom .= "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
$header_bottom .= "</th>";
}
$header_end .= "<th>" . __('Name') . "</th>";
$header_end .= "<th>" . __('Entity') . "</th>";
$header_end .= "<th>" . _x('phone', 'Number') . "</th>";
$header_end .= "<th>" . __('Contract type') . "</th>";
$header_end .= "<th>" . __('Supplier') . "</th>";
$header_end .= "<th>" . __('Start date') . "</th>";
$header_end .= "<th>" . __('Initial contract period') . "</th>";
$header_end .= "</tr>";
echo $header_begin . $header_top . $header_end;
if ($number > 0) {
Session::initNavigateListItems(__CLASS__, sprintf(__('%1$s = %2$s'), $item->getTypeName(1), $item->getName()));
foreach ($contracts as $data) {
$cID = $data["contracts_id"];
Session::addToNavigateListItems(__CLASS__, $cID);
$contracts[] = $cID;
$assocID = $data["id"];
$con = new Contract();
$con->getFromDB($cID);
echo "<tr class='tab_bg_1" . ($con->fields["is_deleted"] ? "_2" : "") . "'>";
if ($canedit && $withtemplate != 2) {
echo "<td width='10'>";
Html::showMassiveActionCheckBox(__CLASS__, $data["id"]);
echo "</td>";
}
echo "<td class='center b'>";
$name = $con->fields["name"];
if ($_SESSION["glpiis_ids_visible"] || empty($con->fields["name"])) {
$name = sprintf(__('%1$s (%2$s)'), $name, $con->fields["id"]);
}
echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/contract.form.php?id={$cID}'>" . $name;
echo "</a></td>";
echo "<td class='center'>";
echo Dropdown::getDropdownName("glpi_entities", $con->fields["entities_id"]) . "</td>";
echo "<td class='center'>" . $con->fields["num"] . "</td>";
echo "<td class='center'>";
echo Dropdown::getDropdownName("glpi_contracttypes", $con->fields["contracttypes_id"]) . "</td>";
echo "<td class='center'>" . $con->getSuppliersNames() . "</td>";
echo "<td class='center'>" . Html::convDate($con->fields["begin_date"]) . "</td>";
echo "<td class='center'>" . sprintf(__('%1$s %2$s'), $con->fields["duration"], _n('month', 'months', $con->fields["duration"]));
if ($con->fields["begin_date"] != '' && !empty($con->fields["begin_date"])) {
echo " -> " . Infocom::getWarrantyExpir($con->fields["begin_date"], $con->fields["duration"], 0, true);
}
echo "</td>";
echo "</tr>";
}
echo $header_begin . $header_bottom . $header_end;
}
echo "</table>";
if ($canedit && $number && $withtemplate != 2) {
$massiveactionparams['ontop'] = false;
Html::showMassiveActions($massiveactionparams);
Html::closeForm();
}
echo "</div>";
}
示例8: methodgetItemInfocoms
/**
* Return Infocom for an object
*
* @param $protocol the commonication protocol used
* @param $params array
*
* @return a hasdtable, fields of glpi_infocoms
**/
static function methodgetItemInfocoms($params, $protocol)
{
if (isset($params['help'])) {
$params = array('itemtype' => 'string, mandatory', 'id' => 'integer, mandatory', 'id2name' => 'bool,optional', 'help' => 'bool,optional');
}
$check = self::checkStandardParameters($params, $protocol);
if (!$check == 1) {
exit;
}
if (!Session::haveRight("infocom", READ)) {
return array();
}
$infocom = new InfoCom();
$item = new $params['itemtype']();
$item->getTypeName();
if (!$infocom->getFromDBforDevice($params['itemtype'], $params['id']) || !$item->can($params['id'], READ)) {
return self::Error($protocol, WEBSERVICES_ERROR_NOTFOUND);
}
$resp = $infocom->fields;
$resp['warranty_expiration'] = Infocom::getWarrantyExpir($infocom->fields['buy_date'], $infocom->fields['warranty_duration']);
if ($id2name) {
// TODO : more dropdown value
$resp['suppliers_name'] = Html::clean(Dropdown::getDropdownName('glpi_suppliers', $infocom->fields['suppliers_id']));
$resp['budgets_names'] = Html::ml_clean(Dropdown::getDropdownName('glpi_budgets', $infocom->fields['budgets_id']));
}
return $resp;
}
示例9: getComments
/**
* Get comments of the Object
*
* @return String: comments of the object in the current language (HTML)
**/
function getComments()
{
$comment = "";
$toadd = array();
if ($this->isField('completename')) {
$toadd[] = array('name' => __('Complete name'), 'value' => nl2br($this->getField('completename')));
}
if ($this->isField('serial')) {
$toadd[] = array('name' => __('Serial number'), 'value' => nl2br($this->getField('serial')));
}
if ($this->isField('otherserial')) {
$toadd[] = array('name' => __('Inventory number'), 'value' => nl2br($this->getField('otherserial')));
}
if ($this->isField('states_id') && $this->getType() != 'State') {
$tmp = Dropdown::getDropdownName('glpi_states', $this->getField('states_id'));
if (strlen($tmp) != 0 && $tmp != ' ') {
$toadd[] = array('name' => __('Status'), 'value' => $tmp);
}
}
if ($this->isField('locations_id') && $this->getType() != 'Location') {
$tmp = Dropdown::getDropdownName("glpi_locations", $this->getField('locations_id'));
if (strlen($tmp) != 0 && $tmp != ' ') {
$toadd[] = array('name' => __('Location'), 'value' => $tmp);
}
}
if ($this->isField('users_id')) {
$tmp = getUserName($this->getField('users_id'));
if (strlen($tmp) != 0 && $tmp != ' ') {
$toadd[] = array('name' => __('User'), 'value' => $tmp);
}
}
if ($this->isField('groups_id') && $this->getType() != 'Group') {
$tmp = Dropdown::getDropdownName("glpi_groups", $this->getField('groups_id'));
if (strlen($tmp) != 0 && $tmp != ' ') {
$toadd[] = array('name' => __('Group'), 'value' => $tmp);
}
}
if ($this->isField('users_id_tech')) {
$tmp = getUserName($this->getField('users_id_tech'));
if (strlen($tmp) != 0 && $tmp != ' ') {
$toadd[] = array('name' => __('Technician in charge of the hardware'), 'value' => $tmp);
}
}
if ($this->isField('contact')) {
$toadd[] = array('name' => __('Alternate username'), 'value' => nl2br($this->getField('contact')));
}
if ($this->isField('contact_num')) {
$toadd[] = array('name' => __('Alternate username number'), 'value' => nl2br($this->getField('contact_num')));
}
if (InfoCom::canApplyOn($this)) {
$infocom = new Infocom();
if ($infocom->getFromDBforDevice($this->getType(), $this->fields['id'])) {
$toadd[] = array('name' => __('Warranty expiration date'), 'value' => Infocom::getWarrantyExpir($infocom->fields["warranty_date"], $infocom->fields["warranty_duration"], 0, true));
}
}
if ($this instanceof CommonDropdown && $this->isField('comment')) {
$toadd[] = array('name' => __('Comments'), 'value' => nl2br($this->getField('comment')));
}
if (count($toadd)) {
foreach ($toadd as $data) {
// Do not use SPAN here
$comment .= sprintf(__('%1$s: %2$s') . "<br>", "<strong>" . $data['name'], "</strong>" . $data['value']);
}
}
if (!empty($comment)) {
return Html::showToolTip($comment, array('display' => false));
}
return $comment;
}
示例10: showImport
static function showImport($row_num, $item_num, $line, $output_type, $configID, $status, $imported)
{
global $DB, $CFG_GLPI;
$infocom = new Infocom();
$canedit = Session::haveRight(static::$rightname, UPDATE) && $infocom->canUpdate();
$config = new PluginManufacturersimportsConfig();
$config->getFromDB($configID);
$suppliername = $config->fields["name"];
$supplierUrl = $config->fields["supplier_url"];
$supplierId = $config->fields["suppliers_id"];
$supplierWarranty = $config->fields["warranty_duration"];
$supplierkey = $config->fields["supplier_key"];
$supplierclass = "PluginManufacturersimports" . $suppliername;
$supplier = new $supplierclass();
$row_num++;
if ($suppliername) {
$model = new PluginManufacturersimportsModel();
$otherSerial = $model->checkIfModelNeeds($line["itemtype"], $line["id"]);
echo Search::showNewLine($output_type, $row_num % 2);
$ic = new Infocom();
$output_check = "";
if ($canedit && $output_type == Search::HTML_OUTPUT) {
$sel = "";
if (isset($_GET["select"]) && $_GET["select"] == "all") {
$sel = "checked";
}
$output_check = $supplier->showCheckbox($line["id"], $sel, $otherSerial);
}
echo Search::showItem($output_type, $output_check, $item_num, $row_num);
$link = Toolbox::getItemTypeFormURL($line["itemtype"]);
$ID = "";
if ($_SESSION["glpiis_ids_visible"] || empty($line["name"])) {
$ID .= " (" . $line["id"] . ")";
}
$output_link = "<a href='" . $link . "?id=" . $line["id"] . "'>" . $line["name"] . $ID . "</a><br>" . $line["model_name"];
echo Search::showItem($output_type, $output_link, $item_num, $row_num);
if (Session::isMultiEntitiesMode()) {
echo Search::showItem($output_type, Dropdown::getDropdownName("glpi_entities", $line['entities_id']), $item_num, $row_num);
}
$url = self::selectSupplier($suppliername, $line["serial"], $otherSerial, $supplierkey);
//serial
echo Search::showItem($output_type, $line["serial"], $item_num, $row_num);
//otherserial
echo $supplier->showItem($output_type, $otherSerial, $item_num, $row_num);
//display infocoms
$output_ic = "";
if ($ic->getfromDBforDevice($line["itemtype"], $line["id"])) {
$output_ic .= _n('Supplier', 'Suppliers', 1) . ":" . Dropdown::getDropdownName("glpi_suppliers", $ic->fields["suppliers_id"]) . "<br>";
$output_ic .= __('Date of purchase') . " : " . Html::convdate($ic->fields["buy_date"]) . "<br>";
$output_ic .= __('Start date of warranty') . ":" . Html::convdate($ic->fields["warranty_date"]) . "<br>";
if ($ic->fields["warranty_duration"] == -1) {
$output_ic .= __('Warranty duration') . ":" . __('Lifelong') . "<br>";
} else {
$output_ic .= __('Warranty duration') . ":" . $ic->fields["warranty_duration"] . " " . __('month') . "<br>";
}
$tmpdat = Infocom::getWarrantyExpir($ic->fields["warranty_date"], $ic->fields["warranty_duration"]);
$output_ic .= sprintf(__('Valid to %s'), $tmpdat);
} else {
$output_ic .= "";
}
echo Search::showItem($output_type, $output_ic, $item_num, $row_num);
if ($imported != self::IMPORTED) {
//display enterprise and warranty selection
echo "<td>";
if (Session::isMultiEntitiesMode() && $supplierId) {
$item = new Supplier();
$item->getFromDB($supplierId);
if ($item->fields["is_recursive"] || $item->fields["entities_id"] == $line['entities_id']) {
Dropdown::show('Supplier', array('name' => "to_suppliers_id" . $line["id"], 'value' => $supplierId, 'comments' => 0, 'entity' => $line['entities_id']));
} else {
echo "<span class='plugin_manufacturersimports_import_KO'>";
echo __('The choosen supplier is not recursive', 'manufacturersimports') . "</span>";
echo "<input type='hidden' name='to_suppliers_id" . $line["id"] . "' value='-1'>";
}
} else {
Dropdown::show('Supplier', array('name' => "to_suppliers_id" . $line["id"], 'value' => $supplierId, 'comments' => 0, 'entity' => $line['entities_id']));
}
echo "</td>";
$supplier->showWarrantyItem($line["id"], $supplierWarranty);
} else {
//display enterprise and warranty selection
echo "<td>" . Dropdown::getDropdownName("glpi_suppliers", $ic->fields["suppliers_id"]) . "</td>";
if ($ic->fields["warranty_duration"] == -1) {
echo "<td>" . __('Lifelong') . "</td>";
} else {
echo "<td>" . $ic->fields["warranty_duration"] . "</td>";
}
}
//supplier url
//url to supplier
$output_url = "<a href='" . $url . "' target='_blank'>" . __('Manufacturer information', 'manufacturersimports') . "</a>";
echo Search::showItem($output_type, $output_url, $item_num, $row_num);
//status
if ($imported != self::IMPORTED) {
if ($status != 2) {
$output_doc = __('Not yet imported', 'manufacturersimports');
} else {
$output_doc = "<span class='plugin_manufacturersimports_import_KO'>" . __('Problem during the importation', 'manufacturersimports');
if (!empty($data["date_import"])) {
$output_doc .= " (" . Html::convdate($data["date_import"]) . ")";
//.........这里部分代码省略.........