Exemplo n.º 1
0
             // Reload to get new records
             $result = $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
         }
         if ($result >= 0) {
             header('Location: ' . $_SERVER["PHP_SELF"] . '?facid=' . $id);
             exit;
         }
     } else {
         setEventMessages($object->error, $object->errors, 'errors');
         $action = '';
     }
 } else {
     if ($action == 'unlinkdiscount' && $user->rights->facture->creer) {
         $discount = new DiscountAbsolute($db);
         $result = $discount->fetch(GETPOST("discountid"));
         $discount->unlink_invoice();
     } else {
         if ($action == 'valid' && $user->rights->facture->creer) {
             $object->fetch($id);
             // On verifie signe facture
             if ($object->type == Facture::TYPE_CREDIT_NOTE) {
                 // Si avoir, le signe doit etre negatif
                 if ($object->total_ht >= 0) {
                     setEventMessages($langs->trans("ErrorInvoiceAvoirMustBeNegative"), null, 'errors');
                     $action = '';
                 }
             } else {
                 // Si non avoir, le signe doit etre positif
                 if (empty($conf->global->FACTURE_ENABLE_NEGATIVE) && $object->total_ht < 0) {
                     setEventMessages($langs->trans("ErrorInvoiceOfThisTypeMustBePositive"), null, 'errors');
                     $action = '';