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 .= '