* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program 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 this program. If not, see . */ /** * \file cfdixml/facturaglobal_card.php * \ingroup cfdixml * \brief Page to create/view factura global */ // Load Dolibarr environment $res = 0; // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"] . "/main.inc.php"; } // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME $tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { $i--; $j--; } if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1)) . "/main.inc.php")) { $res = @include substr($tmp, 0, ($i + 1)) . "/main.inc.php"; } if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1))) . "/main.inc.php")) { $res = @include dirname(substr($tmp, 0, ($i + 1))) . "/main.inc.php"; } // Try main.inc.php using relative path if (!$res && file_exists("../main.inc.php")) { $res = @include "../main.inc.php"; } if (!$res && file_exists("../../main.inc.php")) { $res = @include "../../main.inc.php"; } if (!$res && file_exists("../../../main.inc.php")) { $res = @include "../../../main.inc.php"; } if (!$res) { die("Include of main fails"); } require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; dol_include_once('/cfdixml/class/factureglobal.class.php'); dol_include_once('/cfdixml/lib/factureglobal.lib.php'); // Load translation files $langs->loadLangs(array("cfdixml@cfdixml", "bills", "companies")); // Get parameters $id = GETPOST('id', 'int'); $action = GETPOST('action', 'aZ09'); // Initialize objects $object = new FactureGlobal($db); $form = new Form($db); $formfile = new FormFile($db); $formother = new FormOther($db); // Fetch parameters $date_start = GETPOST('date_start') ? dol_mktime(0, 0, 0, GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear')) : ''; $date_end = GETPOST('date_end') ? dol_mktime(23, 59, 59, GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear')) : ''; $payment_mode = GETPOST('payment_mode', 'int'); /* * Actions */ if ($action == 'search') { // Here we'll process the search and display results } /* * View */ $title = $langs->trans("GlobalInvoice"); llxHeader('', $title); print load_fiche_titre($title, '', 'bill'); $head = cfdixmlInvoiceGlobalPrepareHead($object); print dol_get_fiche_head($head, 'card', $langs->trans("GlobalInvoice"), -1, 'bill'); // Filter form print '
'; print ''; print ''; print '
'; print ''; // Period print ''; print ''; print ''; print ''; // Payment mode print ''; print ''; print ''; print ''; print '
'.$langs->trans("Period").''; print $form->selectDate($date_start, 'date_start', 0, 0, 1, '', 1, 1); print ' - '; print $form->selectDate($date_end, 'date_end', 0, 0, 1, '', 1, 1); print '
'.$langs->trans("PaymentMode").''; $form->select_types_paiements($payment_mode, 'payment_mode', '', 0, 1, 1, 0, 1); print '
'; print '
'; // Buttons print '
'; print ''; print '
'; print '
'; // Results section if ($action == 'search_ticket' && !empty($date_start) && !empty($date_end)) { print '
'; // Build SQL query $sql = "SELECT f.rowid, f.ref, f.datef, f.total_ht, f.total_tva, f.total_ttc,"; $sql.= " f.fk_mode_reglement, cp.code as payment_code, cp.libelle as payment_label"; $sql.= " FROM ".MAIN_DB_PREFIX."facture as f"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON cp.id = f.fk_mode_reglement"; $sql.= " WHERE f.entity IN (".getEntity('invoice').")"; $sql.= " AND f.module_source = 'takepos'"; $sql.= " AND f.datef BETWEEN '".$db->idate($date_start)."' AND '".$db->idate($date_end)."'"; if ($payment_mode > 0) { $sql.= " AND f.fk_mode_reglement = ".$payment_mode; } $sql .= " AND f.fk_statut IN (2)"; // 2 = validated, 4 = partially paid $sql.= " ORDER BY f.datef ASC"; $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); print '
'; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; if ($num > 0) { $total_ht = $total_tva = $total_ttc = 0; while ($obj = $db->fetch_object($resql)) { print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; $total_ht += $obj->total_ht; $total_tva += $obj->total_tva; $total_ttc += $obj->total_ttc; } // Show totals print ''; print ''; print ''; print ''; print ''; print ''; print ''; } else { print ''; } print '
'.$langs->trans("Ref").''.$langs->trans("Date").''.$langs->trans("PaymentMode").''.$langs->trans("AmountHT").''.$langs->trans("AmountVAT").''.$langs->trans("AmountTTC").''.$langs->trans("Select").'
'.$obj->ref.''.dol_print_date($db->jdate($obj->datef), 'day').''.$obj->payment_label.''.price($obj->total_ht).''.price($obj->total_tva).''.price($obj->total_ttc).''; print ''; print '
'.$langs->trans("Total").''.price($total_ht).''.price($total_tva).''.price($total_ttc).'
'.$langs->trans("NoRecordFound").'
'; print '
'; if ($num > 0) { print '
'; print ''; print '
'; } } } // End of page llxFooter(); $db->close();