From d213fbae08f9d4ca049898bc261c84a2319211ca Mon Sep 17 00:00:00 2001 From: phf Date: Wed, 13 Jan 2016 13:42:58 +0100 Subject: [PATCH] FIX invoice situation --- htdocs/compta/facture.php | 112 +- htdocs/compta/facture/class/facture.class.php | 160 +- htdocs/core/class/commonobject.class.php | 3 +- .../facture/doc/pdf_crevette.modules.php | 2040 +++++++++++++++++ htdocs/langs/en_US/bills.lang | 12 + htdocs/langs/fr_FR/bills.lang | 12 + 6 files changed, 2328 insertions(+), 11 deletions(-) create mode 100644 htdocs/core/modules/facture/doc/pdf_crevette.modules.php diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index de1cba15e17..c933482f98e 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -103,7 +103,7 @@ $extrafields = new ExtraFields($db); // Load object if ($id > 0 || ! empty($ref)) { - $ret = $object->fetch($id, $ref); + $ret = $object->fetch($id, $ref, '', '', $conf->global->INVOICE_USE_SITUATION); } // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array @@ -1163,6 +1163,18 @@ if (empty($reshook)) $object->fk_facture_source = $_POST['situations']; $object->type = Facture::TYPE_SITUATION; + if (!empty($origin) && !empty($originid)) + { + $object->origin = $origin; + $object->origin_id = $originid; + + foreach ($object->lines as &$line) + { + $line->origin = $object->origin; + $line->origin_id = $line->id; + } + } + $object->fetch_thirdparty(); $object->date = $datefacture; $object->note_public = trim($_POST['note_public']); @@ -1492,11 +1504,11 @@ if (empty($reshook)) $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')); + $description = dol_htmlcleanlastbr(GETPOST('product_desc') ? GETPOST('product_desc') : GETPOST('desc')); $pu_ht = GETPOST('price_ht'); $vat_rate = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); $qty = GETPOST('qty'); - + // Define info_bits $info_bits = 0; if (preg_match('/\*/', $vat_rate)) @@ -2131,7 +2143,7 @@ if ($action == 'create') $opt = $form->selectSituationInvoices(GETPOST('originid'), $socid); print '
'; $tmp='' . $langs->trans('NoSituations') . '') || (GETPOST('origin') && GETPOST('origin') != 'facture')) $tmp.=' disabled'; + if ($opt == ('') || (GETPOST('origin') && GETPOST('origin') != 'facture' && GETPOST('origin') != 'commande')) $tmp.=' disabled'; $tmp.= '> '; $text = $tmp.$langs->trans("InvoiceSituationAsk") . ' '; $text .= '