当前位置: 首页>>代码示例>>PHP>>正文


PHP Printer::getField方法代码示例

本文整理汇总了PHP中Printer::getField方法的典型用法代码示例。如果您正苦于以下问题:PHP Printer::getField方法的具体用法?PHP Printer::getField怎么用?PHP Printer::getField使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Printer的用法示例。


在下文中一共展示了Printer::getField方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testDelete

 /**
  * @covers Printer::delete
  * @covers Printer::restore
  */
 public function testDelete()
 {
     $obj = new Printer();
     $this->assertTrue($obj->maybeDeleted());
     // Add
     $id = $obj->add(['name' => __METHOD__]);
     $this->assertGreaterThan(0, $id);
     $this->assertTrue($obj->getFromDB($id));
     $this->assertEquals(0, $obj->getField('is_deleted'));
     $this->assertEquals(0, $obj->isDeleted());
     // Delete
     $this->assertTrue($obj->delete(['id' => $id], 0));
     $this->assertTrue($obj->getFromDB($id));
     $this->assertEquals(1, $obj->getField('is_deleted'));
     $this->assertEquals(1, $obj->isDeleted());
     // Restore
     $this->assertTrue($obj->restore(['id' => $id], 0));
     $this->assertTrue($obj->getFromDB($id));
     $this->assertEquals(0, $obj->getField('is_deleted'));
     $this->assertEquals(0, $obj->isDeleted());
     // Purge
     $this->assertTrue($obj->delete(['id' => $id], 1));
     $this->assertFalse($obj->getFromDB($id));
 }
开发者ID:btry,项目名称:glpi,代码行数:28,代码来源:PrinterTest.php

示例2: pdfForPrinter

 /**
  * @param $pdf                PluginPdfSimplePDF object
  * @param $p                  Printer object
  * @param $old
  **/
 static function pdfForPrinter(PluginPdfSimplePDF $pdf, Printer $p, $old = false)
 {
     global $DB, $CFG_GLPI;
     $instID = $p->getField('id');
     if (!Session::haveRight("cartridge", "r")) {
         return false;
     }
     $dateout = "IS NULL ";
     if ($old) {
         $dateout = " IS NOT NULL ";
     }
     $query = "SELECT `glpi_cartridgeitems`.`id` AS tid,\n                       `glpi_cartridgeitems`.`ref`,\n                       `glpi_cartridgeitems`.`name`,\n                       `glpi_cartridges`.`id`,\n                       `glpi_cartridges`.`pages`,\n                       `glpi_cartridges`.`date_use`,\n                       `glpi_cartridges`.`date_out`,\n                       `glpi_cartridges`.`date_in`\n                FROM `glpi_cartridges`, `glpi_cartridgeitems`\n                WHERE `glpi_cartridges`.`date_out` " . $dateout . "\n                      AND `glpi_cartridges`.`printers_id` = '" . $instID . "'\n                      AND `glpi_cartridges`.`cartridgeitems_id` = `glpi_cartridgeitems`.`id`\n                ORDER BY `glpi_cartridges`.`date_out` ASC,\n                         `glpi_cartridges`.`date_use` DESC,\n                         `glpi_cartridges`.`date_in`";
     $result = $DB->query($query);
     $number = $DB->numrows($result);
     $i = 0;
     $pages = $p->fields['init_pages_counter'];
     $pdf->setColumnsSize(100);
     $pdf->displayTitle("<b>" . ($old ? __('Worn cartridges') : __('Used cartridges')) . "</b>");
     if (!$number) {
         $pdf->displayLine(__('No item found'));
     } else {
         $pdf->setColumnsSize(25, 13, 12, 12, 12, 26);
         $pdf->displayTitle('<b><i>' . __('Cartridge type'), __('State'), __('Add date'), __('Use date'), __('End date'), __('Printer counter') . '</b></i>');
         $stock_time = 0;
         $use_time = 0;
         $pages_printed = 0;
         $nb_pages_printed = 0;
         while ($data = $DB->fetch_array($result)) {
             $date_in = Html::convDate($data["date_in"]);
             $date_use = Html::convDate($data["date_use"]);
             $date_out = Html::convDate($data["date_out"]);
             $col1 = sprintf(__('%1$s - %2$s'), $data["name"], $data["ref"]);
             $col2 = Cartridge::getStatus($data["date_use"], $data["date_out"]);
             $col6 = '';
             $tmp_dbeg = explode("-", $data["date_in"]);
             $tmp_dend = explode("-", $data["date_use"]);
             $stock_time_tmp = mktime(0, 0, 0, $tmp_dend[1], $tmp_dend[2], $tmp_dend[0]) - mktime(0, 0, 0, $tmp_dbeg[1], $tmp_dbeg[2], $tmp_dbeg[0]);
             $stock_time += $stock_time_tmp;
             if ($old) {
                 $tmp_dbeg = explode("-", $data["date_use"]);
                 $tmp_dend = explode("-", $data["date_out"]);
                 $use_time_tmp = mktime(0, 0, 0, $tmp_dend[1], $tmp_dend[2], $tmp_dend[0]) - mktime(0, 0, 0, $tmp_dbeg[1], $tmp_dbeg[2], $tmp_dbeg[0]);
                 $use_time += $use_time_tmp;
                 $col6 = $data['pages'];
                 if ($pages < $data['pages']) {
                     $pages_printed += $data['pages'] - $pages;
                     $nb_pages_printed++;
                     $col6 = sprintf(__('%1$s (%2$s)'), $col6, __('%d printed pages'), $data['pages'] - $pages);
                     $pages = $data['pages'];
                 }
             }
             $pdf->displayLine($col1, $col2, $date_in, $date_use, $date_out, $col6);
         }
         // Each cartridge
     }
     if ($old) {
         if ($number > 0) {
             if ($nb_pages_printed == 0) {
                 $nb_pages_printed = 1;
             }
             $nbstock = round($stock_time / $number / 60 / 60 / 24 / 30.5, 1);
             $nbuse = round($use_time / $number / 60 / 60 / 24 / 30.5, 1);
             $pdf->setColumnsSize(33, 33, 34);
             $pdf->displayTitle("<b><i>" . sprintf(__('%1$s: %2$s'), __('Average time in stock') . "</i></b>", _n('%d month', '%d months', $nbstock), $nbstock), "<b><i>" . sprintf(__('%1$s: %2$s'), __('Average time in use') . "</i></b>", _n('%d month', '%d months', $nbuse), $nbuse), "<b><i>" . sprintf(__('%1$s: %2$s'), __('Average number of printed pages') . "</i></b>", round($pages_printed / $nb_pages_printed)));
         }
         $pdf->displaySpace();
     }
 }
开发者ID:geldarr,项目名称:hack-space,代码行数:73,代码来源:cartridge.class.php

示例3: showGraph

    /**
     * Show printer graph form
     **/
    function showGraph($id, $options = array())
    {
        global $DB, $CFG_GLPI;
        $printer = new Printer();
        $where = '';
        $begin = '';
        $end = '';
        $timeUnit = 'day';
        $graphField = 'pages_total';
        $pagecounters = array();
        $graphType = 'day';
        if (isset($_SESSION['glpi_plugin_fusioninventory_graph_begin'])) {
            $begin = $_SESSION['glpi_plugin_fusioninventory_graph_begin'];
        }
        if ($begin == 'NULL' or $begin == '') {
            $begin = date("Y-m-01");
            // first day of current month
        }
        if (isset($_SESSION['glpi_plugin_fusioninventory_graph_end'])) {
            $end = $_SESSION['glpi_plugin_fusioninventory_graph_end'];
        }
        if (isset($_SESSION['glpi_plugin_fusioninventory_graph_type'])) {
            $graphType = $_SESSION['glpi_plugin_fusioninventory_graph_type'];
        }
        if ($end == 'NULL' or $end == '') {
            $end = date("Y-m-d");
            // today
        }
        if (isset($_SESSION['glpi_plugin_fusioninventory_graph_timeUnit'])) {
            $timeUnit = $_SESSION['glpi_plugin_fusioninventory_graph_timeUnit'];
        }
        if (!isset($_SESSION['glpi_plugin_fusioninventory_graph_printersComp'])) {
            $_SESSION['glpi_plugin_fusioninventory_graph_printersComp'] = array();
        }
        if (isset($_SESSION['glpi_plugin_fusioninventory_graph_printerCompAdd'])) {
            $printerCompAdd = $_SESSION['glpi_plugin_fusioninventory_graph_printerCompAdd'];
            if (!key_exists($printerCompAdd, $_SESSION['glpi_plugin_fusioninventory_graph_printersComp'])) {
                $oPrinter = new Printer();
                if ($oPrinter->getFromDB($printerCompAdd)) {
                    $_SESSION['glpi_plugin_fusioninventory_graph_printersComp'][$printerCompAdd] = $oPrinter->getField('name');
                }
            }
        } elseif (isset($_SESSION['glpi_plugin_fusioninventory_graph_printerCompRemove'])) {
            unset($_SESSION['glpi_plugin_fusioninventory_graph_printersComp'][$_SESSION['glpi_plugin_fusioninventory_graph_printerCompRemove']]);
        }
        $oPrinter = new Printer();
        $printers = $_SESSION['glpi_plugin_fusioninventory_graph_printersComp'];
        $printersView = $printers;
        // printers without the current printer
        if (isset($printersView[$id])) {
            unset($printersView[$id]);
        } else {
            if ($oPrinter->getFromDB($id)) {
                $printers[$id] = $oPrinter->getField('name');
            }
        }
        $printersList = '';
        foreach ($printers as $printers_id => $printername) {
            if ($printersList != '') {
                $printersList .= '<br/>';
            }
            if ($printers_id == $id) {
                $printersList .= $printername;
            } else {
                $oPrinter->getFromDB($printers_id);
                $printersList .= $oPrinter->getLink(1);
            }
        }
        $printersIds = "";
        foreach (array_keys($printers) as $printerId) {
            if ($printersIds != '') {
                $printersIds .= ', ';
            }
            $printersIds .= $printerId;
        }
        $where = " WHERE `printers_id` IN(" . $printersIds . ")";
        if ($begin != '' || $end != '') {
            $where .= " AND " . getDateRequest("`date`", $begin, $end);
        }
        $group = '';
        switch ($timeUnit) {
            case 'day':
                $group = "GROUP BY `printers_id`, `year`, `month`, `day`";
                break;
            case 'week':
                $group = "GROUP BY `printers_id`, `year`, `month`, `week`";
                break;
            case 'month':
                $group = "GROUP BY `printers_id`, `year`, `month`";
                break;
            case 'year':
                $group = "GROUP BY `printers_id`, `year`";
                break;
        }
        echo "<form method='post' name='snmp_form' id='snmp_form' action='" . $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/front/printer_info.form.php'>";
        echo "<table class='tab_cadre' cellpadding='5' width='950'>";
        $mapping = new PluginFusioninventoryMapping();
//.........这里部分代码省略.........
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:101,代码来源:printerlog.class.php

示例4: countForPrinter

 /**
  * @param $item Printer object
  **/
 static function countForPrinter(Printer $item)
 {
     $restrict = "`glpi_cartridges`.`printers_id` = '" . $item->getField('id') . "'";
     return countElementsInTable(array('glpi_cartridges'), $restrict);
 }
开发者ID:JULIO8,项目名称:respaldo_glpi,代码行数:8,代码来源:cartridge.class.php

示例5: countForPrinter

 /**
  * @param $item Printer object
  **/
 static function countForPrinter(Printer $item)
 {
     return countElementsInTable(array('glpi_cartridges'), ['glpi_cartridges.printers_id' => $item->getField('id')]);
 }
开发者ID:glpi-project,项目名称:glpi,代码行数:7,代码来源:cartridge.class.php

示例6: purgePrinter

 /**
  * if Printer purged
  *
  * @param $print   Printer object
  **/
 static function purgePrinter(Printer $print)
 {
     $snmp = new self();
     $snmp->deleteByCriteria(array('items_id' => $print->getField("id"), 'itemtype' => $print->getType()));
     $ipdiscover = new PluginOcsinventoryngIpdiscoverOcslink();
     $ipdiscover->deleteByCriteria(array('items_id' => $print->getField("id"), 'itemtype' => $print->getType()));
 }
开发者ID:pluginsGLPI,项目名称:ocsinventoryng,代码行数:12,代码来源:snmpocslink.class.php

示例7: testDeleteByCriteria

 /**
  * @covers Printer::deleteByCriteria
  * @covers Printer::restore
  */
 public function testDeleteByCriteria()
 {
     $obj = new Printer();
     $this->assertTrue($obj->maybeDeleted());
     // Add
     $id = $obj->add(['name' => __METHOD__, 'entities_id' => getItemByTypeName('Entity', '_test_root_entity', true)]);
     $this->assertGreaterThan(0, $id);
     $this->assertTrue($obj->getFromDB($id));
     $this->assertEquals(0, $obj->getField('is_deleted'));
     $this->assertEquals(0, $obj->isDeleted());
     $nb_before = countElementsInTable('glpi_logs', "itemtype = 'Printer'\n                                          AND items_id = '{$id}'");
     // DeleteByCriteria without history
     $this->assertTrue($obj->deleteByCriteria(['name' => __METHOD__], 0, 0));
     $this->assertTrue($obj->getFromDB($id));
     $this->assertEquals(1, $obj->getField('is_deleted'));
     $this->assertEquals(1, $obj->isDeleted());
     $nb_after = countElementsInTable('glpi_logs', "itemtype = 'Printer'\n                                          AND items_id = '{$id}'");
     $this->assertEquals($nb_before, $nb_after);
     // Restore
     $this->assertTrue($obj->restore(['id' => $id], 0));
     $this->assertTrue($obj->getFromDB($id));
     $this->assertEquals(0, $obj->getField('is_deleted'));
     $this->assertEquals(0, $obj->isDeleted());
     $nb_before = countElementsInTable('glpi_logs', "itemtype = 'Printer'\n                                          AND items_id = '{$id}'");
     // DeleteByCriteria with history
     $this->assertTrue($obj->deleteByCriteria(['name' => __METHOD__], 0, 1));
     $this->assertTrue($obj->getFromDB($id));
     $this->assertEquals(1, $obj->getField('is_deleted'));
     $this->assertEquals(1, $obj->isDeleted());
     $nb_after = countElementsInTable('glpi_logs', "itemtype = 'Printer'\n                                          AND items_id = '{$id}'");
     $this->assertEquals($nb_before + 1, $nb_after);
 }
开发者ID:glpi-project,项目名称:glpi,代码行数:36,代码来源:PrinterTest.php

示例8: showInstalled

 /**
  * Show installed cartridges
  *
  *@param $printer object Printer
  *@param $old boolean : old cartridges or not ?
  *
  *@return nothing (display)
  **/
 static function showInstalled(Printer $printer, $old = 0)
 {
     global $DB, $CFG_GLPI, $LANG;
     $instID = $printer->getField('id');
     if (!haveRight("cartridge", "r")) {
         return false;
     }
     $canedit = haveRight("cartridge", "w");
     $query = "SELECT `glpi_cartridgeitems`.`id` AS tID,\n                       `glpi_cartridgeitems`.`is_deleted`,\n                       `glpi_cartridgeitems`.`ref` AS ref,\n                       `glpi_cartridgeitems`.`name` AS type,\n                       `glpi_cartridges`.`id`,\n                       `glpi_cartridges`.`pages` AS pages,\n                       `glpi_cartridges`.`date_use` AS date_use,\n                       `glpi_cartridges`.`date_out` AS date_out,\n                       `glpi_cartridges`.`date_in` AS date_in\n                FROM `glpi_cartridges`,\n                     `glpi_cartridgeitems`\n                WHERE (`glpi_cartridges`.`date_out` IS " . ($old ? "NOT" : "") . " NULL\n                       AND `glpi_cartridges`.`printers_id` = '{$instID}'\n                       AND `glpi_cartridges`.`cartridgeitems_id` = `glpi_cartridgeitems`.`id`)\n                ORDER BY `glpi_cartridges`.`date_out` ASC,\n                         `glpi_cartridges`.`date_use` DESC,\n                         `glpi_cartridges`.`date_in`";
     $result = $DB->query($query);
     $number = $DB->numrows($result);
     $i = 0;
     $pages = $printer->fields['init_pages_counter'];
     echo "<div class='spaced'><table class='tab_cadre_fixe'>";
     if ($old == 0) {
         echo "<tr><th colspan='5'>" . $LANG['cartridges'][33] . "&nbsp;:</th></tr>";
     } else {
         echo "<tr><th colspan='7'>" . $LANG['cartridges'][35] . "&nbsp;:</th></tr>";
     }
     echo "<tr><th>" . $LANG['common'][2] . "</th><th>" . $LANG['cartridges'][12] . "</th>";
     echo "<th>" . $LANG['cartridges'][24] . "</th>";
     echo "<th>" . $LANG['consumables'][26] . "</th>";
     if ($old != 0) {
         echo "<th>" . $LANG['search'][9] . "</th><th>" . $LANG['cartridges'][39] . "</th>";
     }
     echo "<th>&nbsp;</th></tr>";
     $stock_time = 0;
     $use_time = 0;
     $pages_printed = 0;
     $nb_pages_printed = 0;
     while ($data = $DB->fetch_array($result)) {
         $date_in = convDate($data["date_in"]);
         $date_use = convDate($data["date_use"]);
         $date_out = convDate($data["date_out"]);
         echo "<tr class='tab_bg_1" . ($data["is_deleted"] ? "_2" : "") . "'>";
         echo "<td class='center'>" . $data["id"] . "</td>";
         echo "<td class='center b'>";
         echo "<a href=\"" . $CFG_GLPI["root_doc"] . "/front/cartridgeitem.form.php?id=" . $data["tID"] . "\">" . $data["type"] . " - " . $data["ref"] . "</a></td>";
         echo "<td class='center'>" . $date_in . "</td>";
         echo "<td class='center'>" . $date_use;
         $tmp_dbeg = explode("-", $data["date_in"]);
         $tmp_dend = explode("-", $data["date_use"]);
         $stock_time_tmp = mktime(0, 0, 0, $tmp_dend[1], $tmp_dend[2], $tmp_dend[0]) - mktime(0, 0, 0, $tmp_dbeg[1], $tmp_dbeg[2], $tmp_dbeg[0]);
         $stock_time += $stock_time_tmp;
         if ($old != 0) {
             echo "</td>";
             echo "<td class='center'>" . $date_out;
         }
         if ($old != 0) {
             $tmp_dbeg = explode("-", $data["date_use"]);
             $tmp_dend = explode("-", $data["date_out"]);
             $use_time_tmp = mktime(0, 0, 0, $tmp_dend[1], $tmp_dend[2], $tmp_dend[0]) - mktime(0, 0, 0, $tmp_dbeg[1], $tmp_dbeg[2], $tmp_dbeg[0]);
             $use_time += $use_time_tmp;
         }
         echo "</td><td class='center'>";
         if ($old != 0) {
             if ($canedit) {
                 echo "<form method='post' action=\"" . $CFG_GLPI["root_doc"] . "/front/cartridge.form.php\">";
                 echo "<input type='hidden' name='cID' value='" . $data['id'] . "'>";
                 echo "<input type='text' name='pages' value=\"" . $data['pages'] . "\" size='10'>";
                 echo "<input type='image' name='update_pages' value='update_pages'\n                      src='" . $CFG_GLPI["root_doc"] . "/pics/actualiser.png' class='calendrier'>";
                 echo "</form>";
             } else {
                 echo "<input type='text' name='pages' value=\"" . $data['pages'] . "\" size='10'>";
             }
             if ($pages < $data['pages']) {
                 $pages_printed += $data['pages'] - $pages;
                 $nb_pages_printed++;
                 echo $data['pages'] - $pages . " " . $LANG['printers'][31];
                 $pages = $data['pages'];
             }
             echo "</td><td class='center'>";
         }
         if ($canedit) {
             echo "<span class='small_space'>";
             if (is_null($date_out)) {
                 echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/cartridge.form.php?uninstall=uninstall&amp;id=" . $data["id"] . "&amp;tID=" . $data["tID"] . "'>" . $LANG['cartridges'][29] . "</a>";
             } else {
                 echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/cartridge.form.php?delete=delete&amp;id=" . $data["id"] . "&amp;tID=" . $data["tID"] . "'>" . $LANG['buttons'][6] . "</a>";
             }
             echo "</span></td></tr>";
         }
     }
     if ($old == 0 && $canedit) {
         echo "<tr class='tab_bg_1'><td>&nbsp;</td><td class='center' colspan='3'>";
         echo "<form method='post' action=\"" . $CFG_GLPI["root_doc"] . "/front/cartridge.form.php\">";
         echo "<input type='hidden' name='pID' value='{$instID}'>";
         if (CartridgeItem::dropdownForPrinter($printer)) {
             echo "&nbsp;<input type='submit' name='install' value=\"" . $LANG['buttons'][4] . "\"\n                         class='submit'>";
         }
         echo "</form></td><td class='tab_bg_2 center'>&nbsp;";
         echo "</td></tr>";
//.........这里部分代码省略.........
开发者ID:ryukansent,项目名称:Thesis-SideB,代码行数:101,代码来源:cartridge.class.php


注:本文中的Printer::getField方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。