diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index adecacd40ef..56a8ed25c44 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -593,7 +593,8 @@ else if ($action == 'confirm_converttoreduc' && $confirm == 'yes' && $user->righ */ else if ($action == 'add' && $user->rights->facture->creer) { - $object->socid=GETPOST('socid','int'); + if ($socid>0) + $object->socid=GETPOST('socid','int'); $db->begin(); @@ -732,6 +733,12 @@ else if ($action == 'add' && $user->rights->facture->creer) // Standard or deposit or proforma invoice if (($_POST['type'] == 0 || $_POST['type'] == 3 || $_POST['type'] == 4) && $_POST['fac_rec'] <= 0) { + if (GETPOST('socid','int')<1) + { + $error++; + setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Customer")),'errors'); + } + $datefacture = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); if (empty($datefacture)) { @@ -1727,7 +1734,7 @@ if ($action == 'create') print_fiche_titre($langs->trans('NewBill')); $soc = new Societe($db); - if ($socid) $res=$soc->fetch($socid); + if ($socid>1) $res=$soc->fetch($socid); if (! empty($origin) && ! empty($originid)) { @@ -1804,7 +1811,7 @@ if ($action == 'create') print '