예제 #1
0
 function display($values, $display)
 {
     global $PDF, $DB, $CFG_GLPI;
     $default_values["date"] = date("Y-m-d");
     $default_values["locations_id"] = 0;
     $default_values["start"] = 0;
     $default_values["id"] = 0;
     $default_values["export"] = false;
     foreach ($default_values as $key => $val) {
         if (isset($values[$key])) {
             ${$key} = $values[$key];
         }
     }
     $output_type = Search::HTML_OUTPUT;
     if (isset($values["display_type"])) {
         $output_type = $values["display_type"];
     }
     if ($output_type == Search::PDF_OUTPUT_LANDSCAPE) {
         $PDF = new PluginFinancialreportsPdf('L', 'mm', 'A4');
         $PDF->setDate($date);
         $PDF->AddPage();
     }
     $param = new PluginFinancialreportsParameter();
     $param->getFromDB('1');
     $first = false;
     $deleted = 0;
     $master_total = 0;
     $title_report = __('Asset situation ended on', 'financialreports') . " " . Html::convdate($date);
     $start = 0;
     $numrows = 0;
     $end_display = $start + $_SESSION["glpilist_limit"];
     $nbcols = 7;
     $parameters = "date=" . $date . "&locations_id=" . $locations_id;
     foreach ($display as $key => $val) {
         ${$key} = $key;
     }
     if ($output_type == Search::HTML_OUTPUT) {
         // HTML display
         echo "<div align='center'><b>" . $title_report . "</b></div><br>";
         self::printPager($start, 0, '', $parameters, 1);
     }
     echo Search::showHeader($output_type, $end_display - $start + 1, $nbcols, 1);
     //table + div
     if (!empty($param->fields["computers_otherserial"]) || !empty($param->fields["notebooks_otherserial"]) || !empty($param->fields["servers_otherserial"])) {
         $itemtable = getTableForItemType('Computer');
         //////////////////////COMPUTERS///////////////
         $total = $this->getItemsTotal('Computer', $param, "computers_otherserial", $date, 0, "", $locations_id);
         $items = $this->getItems('Computer', $param, "computers_otherserial", $date, 0, "", $locations_id);
         $master_total += $total;
         if ($output_type == Search::PDF_OUTPUT_LANDSCAPE) {
             $PDF->affiche_tableau($total, $items, _n('Computer', 'Computers', 2));
         } else {
             $this->afficheTableau($date, $displaypc, $output_type, $itemtable, $end_display, $start, $nbcols, _n('Computer', 'Computers', 2), $total, $items, $locations_id);
         }
         if ($total != 0 && $output_type == Search::PDF_OUTPUT_LANDSCAPE) {
             $PDF->AddPage();
         }
         //////////////////////PORTABLES///////////////
         $total = $this->getItemsTotal('Computer', $param, "notebooks_otherserial", $date, 0, "", $locations_id);
         $items = $this->getItems('Computer', $param, "notebooks_otherserial", $date, 0, "", $locations_id);
         $master_total += $total;
         if ($output_type == Search::PDF_OUTPUT_LANDSCAPE) {
             $PDF->affiche_tableau($total, $items, _n('Notebook', 'Notebooks', 2, 'financialreports'));
         } else {
             $this->afficheTableau($date, $displaynotebook, $output_type, $itemtable, $end_display, $start, $nbcols, _n('Notebook', 'Notebooks', 2, 'financialreports'), $total, $items, $locations_id);
         }
         if ($total != 0 && $output_type == Search::PDF_OUTPUT_LANDSCAPE) {
             $PDF->AddPage();
         }
         //////////////////////SERVERS///////////////
         $total = $this->getItemsTotal('Computer', $param, "servers_otherserial", $date, 0, "", $locations_id);
         $items = $this->getItems('Computer', $param, "servers_otherserial", $date, 0, "", $locations_id);
         $master_total += $total;
         if ($output_type == Search::PDF_OUTPUT_LANDSCAPE) {
             $PDF->affiche_tableau($total, $items, _n('Server', 'Servers', 2, 'financialreports'));
         } else {
             $this->afficheTableau($date, $displayserver, $output_type, $itemtable, $end_display, $start, $nbcols, _n('Server', 'Servers', 2, 'financialreports'), $total, $items, $locations_id);
         }
         if ($total != 0 && $output_type == Search::PDF_OUTPUT_LANDSCAPE) {
             $PDF->AddPage();
         }
         //No config
     } else {
         $itemtable = getTableForItemType('Computer');
         //////////////////////ALL COMPUTERS///////////////
         $total = $this->getItemsTotal('Computer', $param, "no_value", $date, 0, "", $locations_id);
         $items = $this->getItems('Computer', $param, "no_value", $date, 0, "", $locations_id);
         $master_total += $total;
         if ($total > 1) {
             if ($output_type == Search::PDF_OUTPUT_LANDSCAPE) {
                 $PDF->affiche_tableau($total, $items, _n('Computer', 'Computers', 2));
             } else {
                 $this->afficheTableau($date, $displaypc, $output_type, $itemtable, $end_display, $start, $nbcols, _n('Computer', 'Computers', 2), $total, $items, $locations_id);
             }
         }
         if ($total != 0 && $output_type == Search::PDF_OUTPUT_LANDSCAPE) {
             $PDF->AddPage();
         }
     }
     //////////////////////MONITORS///////////////
     $itemtable = getTableForItemType('Monitor');
     $total = $this->getItemsTotal('Monitor', $param, "monitors_otherserial", $date, 0, "", $locations_id);
     $items = $this->getItems('Monitor', $param, "monitors_otherserial", $date, 0, "", $locations_id);
     $master_total += $total;
     if ($output_type == Search::PDF_OUTPUT_LANDSCAPE) {
         $PDF->affiche_tableau($total, $items, _n('Monitor', 'Monitors', 2));
     } else {
         $this->afficheTableau($date, $displaymonitor, $output_type, $itemtable, $end_display, $start, $nbcols, _n('Monitor', 'Monitors', 2), $total, $items, $locations_id);
     }
     if ($total != 0 && $output_type == Search::PDF_OUTPUT_LANDSCAPE) {
         $PDF->AddPage();
     }
     //////////////////////PRINTERS///////////////
     $itemtable = getTableForItemType('Printer');
     $total = $this->getItemsTotal('Printer', $param, "printers_otherserial", $date, 0, "", $locations_id);
     $items = $this->getItems('Printer', $param, "printers_otherserial", $date, 0, "", $locations_id);
     $master_total += $total;
     if ($output_type == Search::PDF_OUTPUT_LANDSCAPE) {
         $PDF->affiche_tableau($total, $items, _n('Printer', 'Printers', 2));
     } else {
         $this->afficheTableau($date, $displayprinter, $output_type, $itemtable, $end_display, $start, $nbcols, _n('Printer', 'Printers', 2), $total, $items, $locations_id);
     }
     if ($total != 0 && $output_type == Search::PDF_OUTPUT_LANDSCAPE) {
         $PDF->AddPage();
     }
     //////////////////////NETWORK///////////////
     $itemtable = getTableForItemType('NetworkEquipment');
     $total = $this->getItemsTotal('NetworkEquipment', $param, "networkequipments_otherserial", $date, 0, "", $locations_id);
     $items = $this->getItems('NetworkEquipment', $param, "networkequipments_otherserial", $date, 0, "", $locations_id);
     $master_total += $total;
     if ($output_type == Search::PDF_OUTPUT_LANDSCAPE) {
         $PDF->affiche_tableau($total, $items, _n('Network device', 'Network devices', 2));
     } else {
         $this->afficheTableau($date, $displaynetworking, $output_type, $itemtable, $end_display, $start, $nbcols, _n('Network device', 'Network devices', 2), $total, $items, $locations_id);
     }
     if ($total != 0 && $output_type == Search::PDF_OUTPUT_LANDSCAPE) {
         $PDF->AddPage();
     }
     //////////////////////PERIPHERIQUES///////////////
     $itemtable = getTableForItemType('Peripheral');
     $total = $this->getItemsTotal('Peripheral', $param, "peripherals_otherserial", $date, 0, "", $locations_id);
     $items = $this->getItems('Peripheral', $param, "peripherals_otherserial", $date, 0, "", $locations_id);
     $master_total += $total;
     if ($output_type == Search::PDF_OUTPUT_LANDSCAPE) {
         $PDF->affiche_tableau($total, $items, _n('Device', 'Devices', 2));
     } else {
         $this->afficheTableau($date, $displayperipheral, $output_type, $itemtable, $end_display, $start, $nbcols, _n('Device', 'Devices', 2), $total, $items, $locations_id);
     }
     if ($total != 0 && $output_type == Search::PDF_OUTPUT_LANDSCAPE) {
         $PDF->AddPage();
     }
     //////////////////////PHONES///////////////
     $itemtable = getTableForItemType('Phone');
     $total = $this->getItemsTotal('Phone', $param, "phones_otherserial", $date, 0, "", $locations_id);
     $items = $this->getItems('Phone', $param, "phones_otherserial", $date, 0, "", $locations_id);
     $master_total += $total;
     if ($output_type == Search::PDF_OUTPUT_LANDSCAPE) {
         $PDF->affiche_tableau($total, $items, _n('Phone', 'Phones', 2));
     } else {
         $this->afficheTableau($date, $displayphone, $output_type, $itemtable, $end_display, $start, $nbcols, _n('Phone', 'Phones', 2), $total, $items, $locations_id);
     }
     if ($total != 0 && $output_type == Search::PDF_OUTPUT_LANDSCAPE) {
         $PDF->AddPage();
     }
     //////////////////////SORTIS///////////////
     $total = -1;
     $items = "";
     $items = $this->selectItemsForDisposalQuery($locations_id);
     if ($output_type == Search::PDF_OUTPUT_LANDSCAPE) {
         $PDF->affiche_tableau($total, $items, _n('Element out', 'Elements out', 2, 'financialreports'), 1);
     } else {
         $this->afficheTableau($date, $displaydisposal, $output_type, "disposal", $end_display, $start, $nbcols, _n('Element out', 'Elements out', 2, 'financialreports'), $total, $items, $locations_id);
     }
     if ($total != 0 && $output_type == Search::PDF_OUTPUT_LANDSCAPE) {
         $PDF->AddPage();
     }
     //////////END////////////////
     if ($output_type == Search::PDF_OUTPUT_LANDSCAPE) {
         //////////Total général////////////////
         $PDF->affiche_tableau_fin($master_total);
         //////////END////////////////
         $PDF->Output();
     }
     if ($output_type == Search::HTML_OUTPUT) {
         echo "<br>";
         echo Search::showHeader($output_type, 1, 1, 1);
     } else {
         echo Search::showNewLine($output_type);
         echo Search::showEndLine($output_type);
     }
     $row_num = 6000;
     $item_num = 1;
     echo Search::showNewLine($output_type, $row_num % 2);
     echo Search::showItem($output_type, __('General Total', 'financialreports'), $item_num, $row_num);
     echo Search::showItem($output_type, Html::formatNumber($master_total) . " " . _n('Euro', 'Euros', 2, 'financialreports'), $item_num, $row_num);
     echo Search::showEndLine($output_type);
     $title = "";
     // Create title
     if ($output_type == Search::PDF_OUTPUT_LANDSCAPE) {
         $title .= $title_report;
     }
     // Display footer
     if ($output_type == Search::HTML_OUTPUT) {
         echo "</table></div>";
     }
 }
(at your option) any later version.

Financialreports is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Financialreports. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
include '../../../inc/includes.php';
$plugin = new Plugin();
if ($plugin->isActivated("financialreports")) {
    Session::checkRight("config", UPDATE);
    $param = new PluginFinancialreportsParameter();
    $config = new PluginFinancialreportsConfig();
    if (isset($_POST["add_state"])) {
        $config->add($_POST);
        Html::back();
    } else {
        if (isset($_POST["delete_state"])) {
            foreach ($_POST["item"] as $ID => $value) {
                $config->delete(array("id" => $ID), 1);
            }
            Html::back();
        } else {
            if (isset($_POST["update_parameters"])) {
                $param->update($_POST);
                Html::back();
            } else {