/htdocs/facture/fiche.php
PHP | 2112 lines | 1347 code | 296 blank | 469 comment | 509 complexity | 94663e3bcc9c51249c5cacfa1cbffb24 MD5 | raw file
Possible License(s): LGPL-3.0, LGPL-2.1, GPL-3.0, MIT
Large files files are truncated, but you can click here to view the full file
- <?php
- /* Copyright (C) 2002-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
- * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
- * Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
- * Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
- * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
- * Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
- * Copyright (C) 2010-2012 Juanjo Menent <jmenent@2byte.es>
- * Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
- * Copyright (C) 2011-2012 Herve Prot <herve.prot@symeos.com>
- *
- * 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 <http://www.gnu.org/licenses/>.
- */
- require '../main.inc.php';
- require DOL_DOCUMENT_ROOT . '/facture/class/facture.class.php';
- require DOL_DOCUMENT_ROOT . '/compta/paiement/class/paiement.class.php';
- require DOL_DOCUMENT_ROOT . '/facture/core/modules/facture/modules_facture.php';
- require DOL_DOCUMENT_ROOT . '/core/class/discount.class.php';
- require DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php';
- require DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php';
- require DOL_DOCUMENT_ROOT . '/core/lib/invoice.lib.php';
- require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php';
- require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
- /* Loading langs ************************************************************ */
- $langs->load('bills');
- $langs->load('orders');
- $langs->load('companies');
- $langs->load('products');
- $langs->load('main');
- if (!empty($conf->margin->enabled))
- $langs->load('margins');
- /* Parameters *************************************************************** */
- $sall = trim(GETPOST('sall'));
- $projectid = (GETPOST('projectid') ? GETPOST('projectid', 'int') : 0);
- $id = (GETPOST('id', 'alpha') ? GETPOST('id', 'alpha') : GETPOST('facid', 'alpha')); // For backward compatibility
- $ref = GETPOST('ref', 'alpha');
- $socid = GETPOST('socid', 'alpha');
- $action = GETPOST('action', 'alpha');
- $confirm = GETPOST('confirm', 'alpha');
- $lineid = GETPOST('lineid', 'alpha');
- $userid = GETPOST('userid', 'alpha');
- $search_ref = GETPOST('sf_ref') ? GETPOST('sf_ref', 'alpha') : GETPOST('search_ref', 'alpha');
- $search_societe = GETPOST('search_societe', 'alpha');
- $search_montant_ht = GETPOST('search_montant_ht', 'alpha');
- $search_montant_ttc = GETPOST('search_montant_ttc', 'alpha');
- $origin = GETPOST('origin', 'alpha');
- $originid = (GETPOST('originid', 'alpha') ? GETPOST('originid', 'alpha') : GETPOST('origin_id', 'alpha')); // For backward compatibility
- //PDF
- $hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0));
- $hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0));
- $hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0));
- $object = new Facture($db);
- $replacingInvoice = null;
- $societe = new Societe($db);
- if (!empty($socid)) {
- $societe->fetch($socid);
- } else {
- $result = $societe->getView('list');
- if (!empty($result->rows))
- $socid = $result->rows[0]->value->_id;
- }
- $title = $langs->trans("Bill");
- // Load object
- if (!empty($id)) {
- $object->fetch($id);
- $replacingInvoice = $object->getReplacingInvoice();
- }
- // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
- $hookmanager->initHooks(array('invoicecard'));
- if (!empty($_GET['json'])) {
- $output = array(
- "sEcho" => intval($_GET['sEcho']),
- "iTotalRecords" => 0,
- "iTotalDisplayRecords" => 0,
- "aaData" => array()
- );
- // $keystart[0] = $user->id;
- // $keyend[0] = $user->id;
- // $keyend[1] = new stdClass();
- /* $params = array('startkey' => array($user->id, mktime(0, 0, 0, date("m") - 1, date("d"), date("Y"))),
- 'endkey' => array($user->id, mktime(0, 0, 0, date("m") + 1, date("d"), date("Y")))); */
- try {
- $result = $object->getView($_GET["json"], array('key' => $id));
- } catch (Exception $exc) {
- print $exc->getMessage();
- }
- $iTotal = count($result->rows);
- $output["iTotalRecords"] = $iTotal;
- $output["iTotalDisplayRecords"] = $iTotal;
- $i = 0;
- foreach ($result->rows as $aRow) {
- $output["aaData"][] = $aRow->value;
- }
- header('Content-type: application/json');
- echo json_encode($output);
- exit;
- }
- /* Actions ****************************************************************** */
- if ($action == 'create') {
- $title = $langs->trans('NewBill');
- } else if ($action == 'add' && $user->rights->facture->creer) {
- // If creation from another object of another module (Example: origin=commande, originid=1)
- if ($_POST['origin'] && $_POST['originid']) {
- // Parse element/subelement (ex: project_task)
- $element = $subelement = $_POST['origin'];
- if (preg_match('/^([^_]+)_([^_]+)/i', $_POST['origin'], $regs)) {
- $element = $regs[1];
- $subelement = $regs[2];
- }
- // For compatibility
- if ($element == 'order') {
- $element = $subelement = 'commande';
- }
- if ($element == 'commande') {
- $element = 'commande';
- $subelement = 'commande';
- }
- if ($element == 'contract') {
- $element = $subelement = 'contrat';
- }
- $object->origin = $_POST['origin'];
- $object->origin_id = $_POST['originid'];
- // Possibility to add external linked objects with hooks
- // $object->linked_objects[$object->origin] = $object->origin_id;
- $object->linked_objects[] = array('type' => $object->origin, 'id' => $object->origin_id);
- if (is_array($_POST['other_linked_objects']) && !empty($_POST['other_linked_objects'])) {
- $object->linked_objects = array_merge($object->linked_objects, $_POST['other_linked_objects']);
- }
- }
- // Replacement invoice
- if ($_POST['type'] == "INVOICE_REPLACEMENT") {
- $datefacture = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']);
- if (empty($datefacture)) {
- $error++;
- $mesgs[] = '<div class="error">' . $langs->trans("ErrorFieldRequired", $langs->trans("Date")) . '</div>';
- }
- if (empty($_POST['fac_replacement'])) {
- $error++;
- $mesgs[] = '<div class="error">' . $langs->trans("ErrorFieldRequired", $langs->trans("ReplaceInvoice")) . '</div>';
- }
- if (!$error) {
- // This is a replacement invoice
- $result = $object->fetch($_POST['fac_replacement']);
- $object->fetch_thirdparty();
- $object->date = $datefacture;
- $object->note_public = trim($_POST['note_public']);
- $object->note = trim($_POST['note']);
- $object->ref_client = $_POST['ref_client'];
- $object->ref_int = $_POST['ref_int'];
- $object->modelpdf = $_POST['model'];
- $object->fk_project = $_POST['projectid'];
- $object->cond_reglement_code = $_POST['cond_reglement_code'];
- $object->mode_reglement_code = $_POST['mode_reglement_code'];
- $object->remise_absolue = $_POST['remise_absolue'];
- $object->remise_percent = $_POST['remise_percent'];
- // Proprietes particulieres a facture de remplacement
- $object->fk_facture_source = $_POST['fac_replacement'];
- $object->type = "INVOICE_REPLACEMENT";
- $id = $object->createFromCurrent($user);
- if (empty($id))
- $mesgs[] = $object->error;
- }
- }
- // Credit note invoice
- if ($_POST['type'] == "INVOICE_AVOIR") {
- if (empty($_POST['fac_avoir'])) {
- $error++;
- $mesgs[] = '<div class="error">' . $langs->trans("ErrorFieldRequired", $langs->trans("CorrectInvoice")) . '</div>';
- }
- $datefacture = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']);
- if (empty($datefacture)) {
- $error++;
- $mesgs[] = '<div class="error">' . $langs->trans("ErrorFieldRequired", $langs->trans("Date")) . '</div>';
- }
- if (!$error) {
- // Si facture avoir
- $datefacture = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']);
- //$result=$object->fetch($_POST['fac_avoir']);
- $object->socid = $_POST['socid'];
- $object->number = $_POST['facnumber'];
- $object->date = $datefacture;
- $object->note_public = trim($_POST['note_public']);
- $object->note = trim($_POST['note']);
- $object->ref_client = $_POST['ref_client'];
- $object->ref_int = $_POST['ref_int'];
- $object->modelpdf = $_POST['model'];
- $object->fk_project = $_POST['projectid'];
- $object->cond_reglement_code = null;
- $object->mode_reglement_code = $_POST['mode_reglement_code'];
- $object->remise_absolue = $_POST['remise_absolue'];
- $object->remise_percent = $_POST['remise_percent'];
- // Proprietes particulieres a facture avoir
- $object->fk_facture_source = $_POST['fac_avoir'];
- $object->type = "INVOICE_AVOIR";
- $id = $object->create($user);
- // Add predefined lines
- // for ($i = 1; $i <= $NBLINES; $i++) {
- // if ($_POST['idprod' . $i]) {
- // $product = new Product($db);
- // $product->fetch($_POST['idprod' . $i]);
- // $startday = dol_mktime(12, 0, 0, $_POST['date_start' . $i . 'month'], $_POST['date_start' . $i . 'day'], $_POST['date_start' . $i . 'year']);
- // $endday = dol_mktime(12, 0, 0, $_POST['date_end' . $i . 'month'], $_POST['date_end' . $i . 'day'], $_POST['date_end' . $i . 'year']);
- // $result = $object->addline($id, $product->description, $product->price, $_POST['qty' . $i], $product->tva_tx, $product->localtax1_tx, $product->localtax2_tx, $_POST['idprod' . $i], $_POST['remise_percent' . $i], $startday, $endday, 0, 0, '', $product->price_base_type, $product->price_ttc, $product->type);
- // }
- // }
- }
- }
- // Standard or deposit or proforma invoice
- if (($_POST['type'] == "INVOICE_STANDARD" || $_POST['type'] == "INVOICE_DEPOSIT" || $_POST['type'] == 4) && $_POST['fac_rec'] <= 0) {
- $datefacture = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']);
- if (empty($datefacture)) {
- $error++;
- $mesgs[] = '<div class="error">' . $langs->trans("ErrorFieldRequired", $langs->trans("Date")) . '</div>';
- }
- if (!$error) {
- // Si facture standard
- $object->socid = $_POST['socid'];
- $object->type = $_POST['type'];
- $object->number = $_POST['facnumber'];
- $object->date = $datefacture;
- $object->note_public = trim($_POST['note_public']);
- $object->note = trim($_POST['note']);
- $object->ref_client = $_POST['ref_client'];
- $object->ref_int = $_POST['ref_int'];
- $object->modelpdf = $_POST['model'];
- $object->fk_project = $_POST['projectid'];
- $object->cond_reglement_code = $_POST["cond_reglement_code"]; //($_POST['type'] == 3?1:$_POST['cond_reglement_id']);
- $object->mode_reglement_code = $_POST['mode_reglement_code'];
- $object->amount = $_POST['amount'];
- $object->remise_absolue = $_POST['remise_absolue'];
- $object->remise_percent = $_POST['remise_percent'];
- $id = $object->createStandardInvoice($user);
- } else
- $action = 'create';
- }
- if (!empty($id)) {
- // If creation from an order, copying lines
- if (!empty($_POST['origin'])) {
- dol_include_once('/' . $element . '/class/' . $subelement . '.class.php');
- $classname = ucfirst($subelement);
- $srcobject = new $classname($db);
- dol_syslog("Try to find source object origin=" . $object->origin . " originid=" . $object->origin_id . " to add lines");
- $result = $srcobject->fetch($object->origin_id);
- if (!empty($result)) {
- $lines = $srcobject->lines;
- if (empty($lines) && method_exists($srcobject, 'fetch_lines'))
- $lines = $srcobject->fetch_lines();
- $fk_parent_line = 0;
- $num = count($lines);
- for ($i = 0; $i < $num; $i++) {
- $desc = ($lines[$i]->description ? $lines[$i]->description : $lines[$i]->libelle);
- $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0);
- // Dates
- // TODO mutualiser
- $date_start = $lines[$i]->date_debut_prevue;
- if ($lines[$i]->date_debut_reel)
- $date_start = $lines[$i]->date_debut_reel;
- if ($lines[$i]->date_start)
- $date_start = $lines[$i]->date_start;
- $date_end = $lines[$i]->date_fin_prevue;
- if ($lines[$i]->date_fin_reel)
- $date_end = $lines[$i]->date_fin_reel;
- if ($lines[$i]->date_end)
- $date_end = $lines[$i]->date_end;
- // Reset fk_parent_line for no child products and special product
- if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) {
- $fk_parent_line = 0;
- }
- $result = $object->addline(
- $id, $desc, $lines[$i]->subprice, $lines[$i]->qty, $lines[$i]->tva_tx, $lines[$i]->localtax1_tx, $lines[$i]->localtax2_tx, $lines[$i]->fk_product, $lines[$i]->remise_percent, $datestart, $dateend, 0, $lines[$i]->info_bits, $lines[$i]->fk_remise_except, 'HT', 0, $product_type, $lines[$i]->rang, $lines[$i]->special_code, $fk_parent_line
- );
- if ($result < 0) {
- $error++;
- break;
- }
- // Defined the new fk_parent_line
- if ($result > 0 && $lines[$i]->product_type == 9) {
- $fk_parent_line = $result;
- }
- }
- // Hooks
- $parameters = array('objFrom' => $srcobject);
- $reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
- if ($reshook < 0)
- $error++;
- }
- else {
- $mesg = $srcobject->error;
- $error++;
- }
- }
- if ($error == 0)
- header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $id);
- exit;
- }
- }
- else if ($action == 'update' && $user->rights->facture->creer) {
- $datefacture = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']);
- $datelimite = dol_mktime(12, 0, 0, $_POST['limonth'], $_POST['liday'], $_POST['liyear']);
- if (empty($datefacture)) {
- $error++;
- $mesgs[] = '<div class="error">' . $langs->trans("ErrorFieldRequired", $langs->trans("Date")) . '</div>';
- }
- $object->date = $datefacture;
- if (!empty($object->date_lim_reglement))
- $object->date_lim_reglement = $datelimite;
- $object->cond_reglement_code = GETPOST('cond_reglement_code');
- $object->mode_reglement_code = GETPOST('mode_reglement_code');
- $res = $object->update($user);
- if ($res > 0) {
- header('Location: ' . $_SERVER['PHP_SELF'] . '?id=' . $id);
- exit;
- }
- }
- // Add a new line
- else if (($action == 'addline' || $action == 'addline_predef') && $user->rights->facture->creer) {
- $langs->load('errors');
- $error = false;
- $idprod = GETPOST('idprod', 'alpha');
- $product_desc = (GETPOST('product_desc') ? GETPOST('product_desc') : (GETPOST('np_desc') ? GETPOST('np_desc') : (GETPOST('dp_desc') ? GETPOST('dp_desc') : '')));
- $price_ht = GETPOST('price_ht');
- $tva_tx = GETPOST('tva_tx');
- if ((empty($idprod) || GETPOST('usenewaddlineform')) && ($price_ht < 0) && (GETPOST('qty') < 0)) {
- setEventMessage($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPriceHT'), $langs->transnoentitiesnoconv('Qty')), 'errors');
- $error = true;
- }
- if (empty($idprod) && GETPOST('type') < 0) {
- setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), 'errors');
- $error = true;
- }
- if ((empty($idprod) || GETPOST('usenewaddlineform')) && (!($price_ht >= 0) || $price_ht == '')) { // Unit price can be 0 but not ''
- setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), 'errors');
- $error = true;
- }
- if (!GETPOST('qty') && GETPOST('qty') == '') {
- setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), 'errors');
- $error = true;
- }
- if (empty($idprod) && empty($product_desc)) {
- setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Description')), 'errors');
- $error = true;
- }
- if (!$error && (GETPOST('qty') >= 0) && (!empty($product_desc) || !empty($idprod))) {
- $ret = $object->fetch_thirdparty();
- // Clean parameters
- $predef = ((!empty($idprod) && $conf->global->MAIN_FEATURES_LEVEL < 2) ? '_predef' : '');
- $date_start = dol_mktime(GETPOST('date_start' . $predef . 'hour'), GETPOST('date_start' . $predef . 'min'), GETPOST('date_start' . $predef . 'sec'), GETPOST('date_start' . $predef . 'month'), GETPOST('date_start' . $predef . 'day'), GETPOST('date_start' . $predef . 'year'));
- $date_end = dol_mktime(GETPOST('date_end' . $predef . 'hour'), GETPOST('date_end' . $predef . 'min'), GETPOST('date_end' . $predef . 'sec'), GETPOST('date_end' . $predef . 'month'), GETPOST('date_end' . $predef . 'day'), GETPOST('date_end' . $predef . 'year'));
- $price_base_type = (GETPOST('price_base_type', 'alpha') ? GETPOST('price_base_type', 'alpha') : 'HT');
- // Define special_code for special lines
- $special_code = 0;
- //if (empty($_POST['qty'])) $special_code=3; // Options should not exists on invoices
- // Ecrase $pu par celui du produit
- // Ecrase $desc par celui du produit
- // Ecrase $txtva par celui du produit
- // Ecrase $base_price_type par celui du produit
- if (!empty($idprod)) {
- $prod = new Product($db);
- $prod->fetch($idprod);
- $label = ((GETPOST('product_label') && GETPOST('product_label') != $prod->label) ? GETPOST('product_label') : '');
- // Update if prices fields are defined
- if (GETPOST('usenewaddlineform')) {
- $pu_ht = price2num($price_ht, 'MU');
- $pu_ttc = price2num(GETPOST('price_ttc'), 'MU');
- $tva_npr = (preg_match('/\*/', $tva_tx) ? 1 : 0);
- $tva_tx = str_replace('*', '', $tva_tx);
- $desc = $product_desc;
- } else {
- $tva_tx = get_default_tva($mysoc, $object->thirdparty, $prod->id);
- $tva_npr = get_default_npr($mysoc, $object->thirdparty, $prod->id);
- // We define price for product
- if (!empty($conf->global->PRODUIT_MULTIPRICES) && !empty($object->thirdparty->price_level)) {
- $pu_ht = $prod->multiprices[$object->thirdparty->price_level];
- $pu_ttc = $prod->multiprices_ttc[$object->thirdparty->price_level];
- $price_min = $prod->multiprices_min[$object->thirdparty->price_level];
- $price_base_type = $prod->multiprices_base_type[$object->thirdparty->price_level];
- } else {
- $pu_ht = $prod->price->price;
- $pu_ttc = $prod->price->price_ttc;
- $price_min = $prod->price->price_min;
- $price_base_type = $prod->price->price_base_type;
- }
- // On reevalue prix selon taux tva car taux tva transaction peut etre different
- // de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur).
- if ($tva_tx != $prod->tva_tx) {
- if ($price_base_type != 'HT') {
- $pu_ht = price2num($pu_ttc / (1 + ($tva_tx / 100)), 'MU');
- } else {
- $pu_ttc = price2num($pu_ht * (1 + ($tva_tx / 100)), 'MU');
- }
- }
- $desc = '';
- // Define output language
- if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) {
- $outputlangs = $langs;
- $newlang = '';
- if (empty($newlang) && GETPOST('lang_id'))
- $newlang = GETPOST('lang_id');
- if (empty($newlang))
- $newlang = $object->client->default_lang;
- if (!empty($newlang)) {
- $outputlangs = new Translate();
- $outputlangs->setDefaultLang($newlang);
- }
- $desc = (!empty($prod->multilangs[$outputlangs->defaultlang]["description"])) ? $prod->multilangs[$outputlangs->defaultlang]["description"] : $prod->description;
- } else {
- $desc = $prod->description;
- }
- $desc = dol_concatdesc($desc, $product_desc);
- }
- if (!empty($prod->customcode) || !empty($prod->country_id)) {
- $tmptxt = '(';
- if (!empty($prod->customcode))
- $tmptxt.=$langs->transnoentitiesnoconv("CustomCode") . ': ' . $prod->customcode;
- if (!empty($prod->customcode) && !empty($prod->country_id))
- $tmptxt.=' - ';
- if (!empty($prod->country_id))
- $tmptxt.=$langs->transnoentitiesnoconv("CountryOrigin") . ': ' . getCountry($prod->country_id, 0, $db, $langs, 0);
- $tmptxt.=')';
- $desc.= (dol_textishtml($desc) ? "<br>\n" : "\n") . $tmptxt;
- }
- $type = $prod->type;
- }
- else {
- $pu_ht = price2num($price_ht, 'MU');
- $pu_ttc = price2num(GETPOST('price_ttc'), 'MU');
- $tva_npr = (preg_match('/\*/', $tva_tx) ? 1 : 0);
- $tva_tx = str_replace('*', '', $tva_tx);
- $label = (GETPOST('product_label') ? GETPOST('product_label') : '');
- $desc = $product_desc;
- $type = GETPOST('type');
- }
- // Margin
- $fournprice = (GETPOST('fournprice') ? GETPOST('fournprice') : '');
- $buyingprice = (GETPOST('buying_price') ? GETPOST('buying_price') : '');
- // Local Taxes
- $localtax1_tx = get_localtax($tva_tx, 1, $object->thirdparty);
- $localtax2_tx = get_localtax($tva_tx, 2, $object->thirdparty);
- $info_bits = 0;
- if ($tva_npr)
- $info_bits |= 0x01;
- if (!empty($price_min) && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent')) / 100) < price2num($price_min))) {
- $mesg = $langs->trans("CantBeLessThanMinPrice", price2num($price_min, 'MU') . $langs->getCurrencySymbol($conf->currency));
- setEventMessage($mesg, 'errors');
- } else {
- // Insert line
- $result = $object->addline(
- $id, $desc, $pu_ht, GETPOST('qty'), $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, GETPOST('remise_percent'), $date_start, $date_end, 0, $info_bits, '', $price_base_type, $pu_ttc, $type, -1, $special_code, '', 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label
- );
- if ($result > 0) {
- if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
- // Define output language
- $outputlangs = $langs;
- $newlang = GETPOST('lang_id', 'alpha');
- if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang))
- $newlang = $object->client->default_lang;
- if (!empty($newlang)) {
- $outputlangs = new Translate();
- $outputlangs->setDefaultLang($newlang);
- }
- $ret = $object->fetch($id); // Reload to get new records
- facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
- }
- unset($_POST['qty']);
- unset($_POST['type']);
- unset($_POST['idprod']);
- unset($_POST['remise_percent']);
- unset($_POST['price_ht']);
- unset($_POST['price_ttc']);
- unset($_POST['tva_tx']);
- unset($_POST['product_ref']);
- unset($_POST['product_label']);
- unset($_POST['product_desc']);
- unset($_POST['fournprice']);
- unset($_POST['buying_price']);
- // old method
- unset($_POST['np_desc']);
- unset($_POST['dp_desc']);
- } else {
- setEventMessage($object->error, 'errors');
- }
- $action = '';
- }
- }
- } else if ($action == 'updateligne' && $user->rights->facture->creer && $_POST['save'] == $langs->trans('Save')) {
- if (!$object->fetch($id) > 0)
- dol_print_error($db);
- $object->fetch_thirdparty();
- // Clean parameters
- $date_start = '';
- $date_end = '';
- $date_start = dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear'));
- $date_end = dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear'));
- $description = dol_htmlcleanlastbr(GETPOST('product_desc'));
- $pu_ht = GETPOST('price_ht');
- // Define info_bits
- $info_bits = 0;
- if (preg_match('/\*/', GETPOST('tva_tx')))
- $info_bits |= 0x01;
- // Define vat_rate
- $vat_rate = $_POST['tva_tx'];
- $vat_rate = str_replace('*', '', $vat_rate);
- $localtax1_rate = get_localtax($vat_rate, 1, $object->client);
- $localtax2_rate = get_localtax($vat_rate, 2, $object->client);
- // Add buying price
- $fournprice = (GETPOST('fournprice') ? GETPOST('fournprice') : '');
- $buyingprice = (GETPOST('buying_price') ? GETPOST('buying_price') : '');
- // Check minimum price
- $productid = GETPOST('productid', 'int');
- if (!empty($productid)) {
- $product = new Product($db);
- $product->fetch($productid);
- $type = $product->type;
- $price_min = $product->price_min;
- if (!empty($conf->global->PRODUIT_MULTIPRICES) && !empty($object->client->price_level))
- $price_min = $product->multiprices_min[$object->client->price_level];
- $label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : '');
- if ($price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent')) / 100) < price2num($price_min))) {
- setEventMessage($langs->trans("CantBeLessThanMinPrice", price2num($price_min, 'MU')) . $langs->getCurrencySymbol($conf->currency), 'errors');
- $error++;
- }
- } else {
- $type = GETPOST('type');
- $label = (GETPOST('product_label') ? GETPOST('product_label') : '');
- // Check parameters
- if (GETPOST('type') < 0) {
- setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), 'errors');
- $error++;
- }
- }
- // Update line
- if (!$error) {
- $result = $object->updateline(
- GETPOST('lineid'), $description, $pu_ht, GETPOST('qty'), GETPOST('remise_percent'), $date_start, $date_end, $vat_rate, $localtax1_rate, $localtax2_rate, 'HT', $info_bits, $type, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label
- );
- if ($result >= 0) {
- if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
- // Define output language
- $outputlangs = $langs;
- $newlang = '';
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id'))
- $newlang = GETPOST('lang_id');
- if ($conf->global->MAIN_MULTILANGS && empty($newlang))
- $newlang = $object->client->default_lang;
- if (!empty($newlang)) {
- $outputlangs = new Translate();
- $outputlangs->setDefaultLang($newlang);
- }
- $ret = $object->fetch($id); // Reload to get new records
- facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
- }
- unset($_POST['qty']);
- unset($_POST['type']);
- unset($_POST['productid']);
- unset($_POST['remise_percent']);
- unset($_POST['price_ht']);
- unset($_POST['price_ttc']);
- unset($_POST['tva_tx']);
- unset($_POST['product_ref']);
- unset($_POST['product_label']);
- unset($_POST['product_desc']);
- unset($_POST['fournprice']);
- unset($_POST['buying_price']);
- } else {
- setEventMessage($object->error, 'errors');
- }
- }
- } else if ($action == 'confirm_delete' && $user->rights->facture->supprimer) {
- $res = $object->delete();
- if ($res > 0) {
- header('Location: list.php');
- exit;
- }
- }
- // Delete line
- else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->facture->creer) {
- // $object->fetch($id);
- // $object->fetch_thirdparty();
- $result = $object->deleteline($_GET['lineid'], $user);
- if ($result > 0) {
- // Define output language
- $outputlangs = $langs;
- $newlang = '';
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && !empty($_REQUEST['lang_id']))
- $newlang = $_REQUEST['lang_id'];
- if ($conf->global->MAIN_MULTILANGS && empty($newlang))
- $newlang = $object->client->default_lang;
- if (!empty($newlang)) {
- $outputlangs = new Translate();
- $outputlangs->setDefaultLang($newlang);
- }
- if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
- $ret = $object->fetch($id); // Reload to get new records
- $result = facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
- }
- if ($result >= 0) {
- header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $id);
- exit;
- }
- } else {
- $mesgs[] = '<div clas="error">' . $object->error . '</div>';
- $action = '';
- }
- }
- // Classify to validated
- else if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->facture->valider) {
- $idwarehouse = GETPOST('idwarehouse');
- $object->fetch($id);
- $object->fetch_thirdparty();
- // Check parameters
- if ($object->type != 3 && !empty($conf->global->STOCK_CALCULATE_ON_BILL) && $object->hasProductsOrServices(1)) {
- if (!$idwarehouse || $idwarehouse == -1) {
- $error++;
- $mesgs[] = $langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Warehouse"));
- $action = '';
- }
- }
- if (!$error) {
- $result = $object->validate($user, '', $idwarehouse);
- if ($result >= 0) {
- // Define output language
- $outputlangs = $langs;
- $newlang = '';
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && !empty($_REQUEST['lang_id']))
- $newlang = $_REQUEST['lang_id'];
- if ($conf->global->MAIN_MULTILANGS && empty($newlang))
- $newlang = $object->client->default_lang;
- if (!empty($newlang)) {
- $outputlangs = new Translate();
- $outputlangs->setDefaultLang($newlang);
- }
- if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
- $ret = $object->fetch($id); // Reload to get new records
- facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
- }
- } else {
- $mesgs[] = '<div class="error">' . $object->error . '</div>';
- }
- }
- }
- /*
- * Generate document
- */ else if ($action == 'builddoc') { // En get ou en post
- $object->fetch_thirdparty();
- if (GETPOST('model')) {
- $object->setDocModel($user, GETPOST('model'));
- }
- // Define output language
- $outputlangs = $langs;
- $newlang = '';
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id'))
- $newlang = GETPOST('lang_id');
- if ($conf->global->MAIN_MULTILANGS && empty($newlang))
- $newlang = $object->client->default_lang;
- if (!empty($newlang)) {
- $outputlangs = new Translate();
- $outputlangs->setDefaultLang($newlang);
- }
- $result = facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
- if ($result <= 0) {
- dol_print_error($db, $result);
- exit;
- } else {
- header('Location: ' . $_SERVER["PHP_SELF"] . '?facid=' . $object->id . (empty($conf->global->MAIN_JUMP_TAG) ? '' : '#builddoc'));
- exit;
- }
- } else if ($action == 'confirm_modif' && ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->facture->valider) || $user->rights->facture->invoice_advance->unvalidate)) {
- $idwarehouse = GETPOST('idwarehouse');
- $object->fetch($id);
- $object->fetch_thirdparty();
- // Check parameters
- if ($object->type != 3 && !empty($conf->global->STOCK_CALCULATE_ON_BILL) && $object->hasProductsOrServices(1)) {
- if (!$idwarehouse || $idwarehouse == -1) {
- $error++;
- $mesgs[] = $langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Warehouse"));
- $action = '';
- }
- }
- if (!$error) {
- // On verifie si aucun paiement n'a ete effectue
- if ($object->getSommePaiement() == 0 && $ventilExportCompta == 0) {
- $res = $object->set_draft($user, $idwarehouse);
- // Define output language
- $outputlangs = $langs;
- $newlang = '';
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && !empty($_REQUEST['lang_id']))
- $newlang = $_REQUEST['lang_id'];
- if ($conf->global->MAIN_MULTILANGS && empty($newlang))
- $newlang = $object->client->default_lang;
- if (!empty($newlang)) {
- $outputlangs = new Translate();
- $outputlangs->setDefaultLang($newlang);
- }
- if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
- $ret = $object->fetch($id); // Reload to get new records
- facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
- }
- }
- }
- }
- // Classify "abandoned"
- else if ($action == 'confirm_canceled' && $confirm == 'yes') {
- $object->fetch($id);
- $close_code = $_POST["close_code"];
- $close_note = $_POST["close_note"];
- if ($close_code) {
- $result = $object->set_canceled($user, $close_code, $close_note);
- } else {
- $mesgs[] = '<div class="error">' . $langs->trans("ErrorFieldRequired", $langs->trans("Reason")) . '</div>';
- }
- }
- // Change status of invoice
- else if ($action == 'reopen' && $user->rights->facture->creer) {
- $result = $object->fetch($id);
- if ($object->Status == "PAID" || $object->Status == "PAID_PARTIALLY" || ($object->Status == "CANCELED" && $object->close_code != 'replaced')) {
- $result = $object->set_unpaid($user);
- if ($result > 0) {
- header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $id);
- exit;
- } else {
- $mesgs[] = '<div class="error">' . $object->error . '</div>';
- }
- }
- }
- // Classify "paid"
- else if ($action == 'confirm_paid' && $confirm == 'yes' && $user->rights->facture->paiement) {
- $object->fetch($id);
- $result = $object->set_paid($user);
- }
- // Classif "paid partialy"
- else if ($action == 'confirm_paid_partially' && $confirm == 'yes' && $user->rights->facture->paiement) {
- $object->fetch($id);
- $close_code = $_POST["close_code"];
- $close_note = $_POST["close_note"];
- if ($close_code) {
- $result = $object->set_paid($user, $close_code, $close_note);
- } else {
- $mesgs[] = '<div class="error">' . $langs->trans("ErrorFieldRequired", $langs->trans("Reason")) . '</div>';
- }
- }
- // Convertir en reduc
- else if ($action == 'confirm_converttoreduc' && $confirm == 'yes' && $user->rights->facture->creer) {
- $object->fetch($id);
- $object->fetch_thirdparty();
- $object->getLinesArray();
- if ($object->Status != "PAID") { // protection against multiple submit
- // Boucle sur chaque taux de tva
- $i = 0;
- foreach ($object->lines as $line) {
- $amount_ht[$line->tva_tx]+=$line->total_ht;
- $amount_tva[$line->tva_tx]+=$line->total_tva;
- $amount_ttc[$line->tva_tx]+=$line->total_ttc;
- $i++;
- }
- // Insert one discount by VAT rate category
- $discount = new DiscountAbsolute($db);
- if ($object->type == "INVOICE_AVOIR")
- $discount->description = '(CREDIT_NOTE)';
- elseif ($object->type == "INVOICE_DEPOSIT")
- $discount->description = '(DEPOSIT)';
- else {
- $this->error = "CantConvertToReducAnInvoiceOfThisType";
- return -1;
- }
- $discount->tva_tx = abs($object->total_ttc);
- $discount->fk_soc = $object->client->id;
- $discount->fk_facture_source = $object->id;
- $error = 0;
- foreach ($amount_ht as $tva_tx => $xxx) {
- $discount->amount_ht = abs($amount_ht[$tva_tx]);
- $discount->amount_tva = abs($amount_tva[$tva_tx]);
- $discount->amount_ttc = abs($amount_ttc[$tva_tx]);
- $discount->tva_tx = abs($tva_tx);
- $result = $discount->create($user);
- if ($result < 0) {
- $error++;
- break;
- }
- }
- if (!$error) {
- // Classe facture
- //$result = $object->set_paid($user);
- $object->Status = 'CONVERTED_TO_REDUC';
- $object->record();
- } else {
- $mesgs[] = '<div class="error">' . $discount->error . '</div>';
- }
- }
- } else if ($action == "setabsolutediscount" && $user->rights->facture->creer) {
- // POST[remise_id] ou POST[remise_id_for_payment]
- if (!empty($_POST["remise_id"])) {
- $ret = $object->fetch($id);
- if (!empty($ret)) {
- $result = $object->insert_discount($_POST["remise_id"]);
- if ($result < 0) {
- $mesgs[] = '<div class="error">' . $object->error . '</div>';
- }
- } else {
- dol_print_error($db, $object->error);
- }
- }
- if (!empty($_POST["remise_id_for_payment"])) {
- require_once DOL_DOCUMENT_ROOT . '/core/class/discount.class.php';
- $discount = new DiscountAbsolute($db);
- $discount->fetch($_POST["remise_id_for_payment"]);
- $result = $discount->link_to_invoice(0, $id);
- if ($result < 0) {
- $mesgs[] = '<div class="error">' . $discount->error . '</div>';
- }
- }
- }
- /*
- * Add file in email form
- */
- if (GETPOST('addfile')) {
- require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
- // Set tmp user directory
- $vardir = $conf->user->dir_output . "/" . $user->id;
- $upload_dir_tmp = $vardir . '/temp';
- dol_add_file_process($upload_dir_tmp, 0, 0);
- $action = 'presend';
- }
- /*
- * Remove file in email form
- */
- if (!empty($_POST['removedfile'])) {
- require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
- // Set tmp user directory
- $vardir = $conf->user->dir_output . "/" . $user->id;
- $upload_dir_tmp = $vardir . '/temp';
- // TODO Delete only files that was uploaded from email form
- dol_remove_file_process($_POST['removedfile'], 0);
- $action = 'presend';
- }
- /*
- * Send mail
- */
- if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST['removedfile'] && !$_POST['cancel']) {
- $langs->load('mails');
- $actiontypecode = '';
- $subject = '';
- $actionmsg = '';
- $actionmsg2 = '';
- $result = $object->fetch($id);
- $result = $object->fetch_thirdparty();
- if ($result > 0) {
- // $ref = dol_sanitizeFileName($object->ref);
- // $file = $conf->facture->dir_output . '/' . $ref . '/' . $ref . '.pdf';
- // if (is_readable($file))
- // {
- if ($_POST['sendto']) {
- // Le destinataire a ete fourni via le champ libre
- $sendto = $_POST['sendto'];
- $sendtoid = 0;
- } elseif ($_POST['receiver'] != '-1') {
- // Recipient was provided from combo list
- if ($_POST['receiver'] == 'thirdparty') { // Id of third party
- $sendto = $object->client->email;
- $sendtoid = 0;
- } else { // Id du contact
- $sendto = $object->client->contact_get_property($_POST['receiver'], 'email');
- $sendtoid = $_POST['receiver'];
- }
- }
- if (dol_strlen($sendto)) {
- $langs->load("commercial");
- $from = $_POST['fromname'] . ' <' . $_POST['frommail'] . '>';
- $replyto = $_POST['replytoname'] . ' <' . $_POST['replytomail'] . '>';
- $message = $_POST['message'];
- $sendtocc = $_POST['sendtocc'];
- $deliveryreceipt = $_POST['deliveryreceipt'];
- if ($action == 'send') {
- if (dol_strlen($_POST['subject']))
- $subject = $_POST['subject'];
- else
- $subject = $langs->transnoentities('Bill') . ' ' . $object->ref;
- $actiontypecode = 'AC_FAC';
- $actionmsg = $langs->transnoentities('MailSentBy') . ' ' . $from . ' ' . $langs->transnoentities('To') . ' ' . $sendto . ".\n";
- if ($message) {
- $actionmsg.=$langs->transnoentities('MailTopic') . ": " . $subject . "\n";
- $actionmsg.=$langs->transnoentities('TextUsedInTheMessageBody') . ":\n";
- $actionmsg.=$message;
- }
- //$actionmsg2=$langs->transnoentities('Action'.$actiontypecode);
- }
- if ($action == 'relance') {
- if (dol_strlen($_POST['subject']))
- $subject = $_POST['subject'];
- else
- $subject = $langs->transnoentities('Relance facture ' . $object->ref);
- $actiontypecode = 'AC_FAC';
- $actionmsg = $langs->transnoentities('MailSentBy') . ' ' . $from . ' ' . $langs->transnoentities('To') . ' ' . $sendto . ".\n";
- if ($message) {
- $actionmsg.=$langs->transnoentities('MailTopic') . ": " . $subject . "\n";
- $actionmsg.=$langs->transnoentities('TextUsedInTheMessageBody') . ":\n";
- $actionmsg.=$message;
- }
- //$actionmsg2=$langs->transnoentities('Action'.$actiontypecode);
- }
- // Create form object
- include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
- $formmail = new FormMail($db);
- $attachedfiles = $formmail->get_attached_files();
- $filepath = $attachedfiles['paths'];
- $filename = $attachedfiles['names'];
- $mimetype = $attachedfiles['mimes'];
- // Send mail
- require_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php';
- $mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, -1);
- if ($mailfile->error) {
- $mesgs[] = '<div class="error">' . $mailfile->error . '</div>';
- } else {
- $result = $mailfile->sendfile();
- if ($result) {
- $error = 0;
- // Initialisation donnees
- $object->sendtoid = $sendtoid;
- $object->actiontypecode = $actiontypecode;
- $object->actionmsg = $actionmsg; // Long text
- $object->actionmsg2 = $actionmsg2; // Short text
- $object->fk_element = $object->id;
- $object->elementtype = $object->element;
- // Appel des triggers
- include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
- $interface = new Interfaces($db);
- $result = $interface->run_triggers('BILL_SENTBYMAIL', $object, $user, $langs, $conf);
- if ($result < 0) {
- $error++;
- $this->errors = $interface->errors;
- }
- // Fin appel triggers
- if ($error) {
- dol_print_error($db);
- } else {
- // Redirect here
- // This avoid sending mail twice if going out and then back to page
- $mesg = $langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($from, 2), $mailfile->getValidAddress($sendto, 2));
- setEventMessage($mesg);
- header('Location: ' . $_SERVER["PHP_SELF"] . '?facid=' . $object->id);
- exit;
- }
- } else {
- $langs->load("other");
- $mesg = '<div class="error">';
- if ($mailfile->error) {
- $mesg.=$langs->trans('ErrorFailedToSendMail', $from, $sendto);
- $mesg.='<br>' . $mailfile->error;
- } else {
- $mesg.='No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS';
- }
- $mesg.='</div>';
- $mesgs[] = $mesg;
- }
- }
- /* }
- else
- {
- $langs->load("other");
- $mesgs[]='<div class="error">'.$langs->trans('ErrorMailRecipientIsEmpty').'</div>';
- dol_syslog('Recipient email is empty');
- } */
- } else {
- $langs->load("errors");
- $mesgs[] = '<div class="error">' . $langs->trans('ErrorCantReadFile', $file) . '</div>';
- dol_syslog('Failed to read file: ' . $file);
- }
- } else {
- $langs->load("other");
- $mesgs[] = '<div class="error">' . $langs->trans('ErrorFailedToReadEntity', $langs->trans("Invoice")) . '</div>';
- dol_syslog('Impossible de lire les donnees de la facture. Le fichier facture n\'a peut-etre pas ete genere.');
- }
- $action = 'presend';
- }
- /* View ********************************************************************* */
- $form = new Form($db);
- $htmlother = new FormOther($db);
- $formfile = new FormFile($db);
- $bankaccountstatic = new Account($db);
- $now = dol_now();
- llxHeader('', $langs->trans('Bill'), 'EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes');
- print_fiche_titre($title);
- $formconfirm = '';
- // Confirmation to delete invoice
- if ($action == 'delete') {
- $text = $langs->trans('ConfirmDeleteBill');
- $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'] . '?id=' . $object->id, $langs->trans('DeleteBill'), $text, 'confirm_delete', '', 0, 1);
- }
- // Confirmation de la suppression d'une ligne produit
- if ($action == 'ask_deleteline') {
- $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?facid=' . $object->id . '&lineid=' . $lineid, $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline', '', 'no', 1);
- }
- // Confirmation de la validation
- if ($action == 'valid') {
- $text = $langs->trans('ConfirmValidateBill', $numref);
- if (!empty($conf->notification->enabled)) {
- require_once DOL_DOCUMENT_ROOT . '/core/class/notify.class.php';
- $notify = new Notify($db);
- $text.='<br>';
- $text.=$notify->confirmMessage('NOTIFY_VAL_FAC', $object->socid);
- }
- $formq…
Large files files are truncated, but you can click here to view the full file