unset($localtax1_tx); unset($localtax2_tx); } else if (empty($mesg)) { $mesg='<div class="error">'.$facfou->error.'</div>'; } $_GET['action'] = ''; } if ($_POST['action'] == 'classin') { $facture = new FactureFournisseur($db,'',$_GET['facid']); $facture->fetch($_GET['facid']); $result=$facture->setProject($_POST['projectid']); } // Repasse la facture en mode brouillon if ($_GET['action'] == 'edit' && $user->rights->fournisseur->facture->creer) { $fac = new FactureFournisseur($db); $fac->fetch($_GET['facid']); // On verifie si la facture a des paiements $sql = 'SELECT pf.amount'; $sql.= ' FROM '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf'; $sql.= ' WHERE pf.fk_facturefourn = '.$fac->id; $result = $db->query($sql);
unset($_POST['dp_desc']); unset($_POST['np_desc']); unset($_POST['pu']); unset($_POST['tva_tx']); unset($_POST['label']); unset($localtax1_tx); unset($localtax2_tx); } else { if (empty($mesg)) { $mesg = '<div class="error">' . $object->error . '</div>'; } } $action = ''; } elseif ($action == 'classin') { $object->fetch($id); $result = $object->setProject($_POST['projectid']); } elseif ($action == 'edit' && $user->rights->fournisseur->facture->creer) { $object->fetch($id); $totalpaye = $object->getSommePaiement(); $resteapayer = $object->total_ttc - $totalpaye; // On verifie si les lignes de factures ont ete exportees en compta et/ou ventilees //$ventilExportCompta = $object->getVentilExportCompta(); // On verifie si aucun paiement n'a ete effectue if ($resteapayer == $object->total_ttc && $object->paye == 0 && $ventilExportCompta == 0) { $object->set_draft($user); $outputlangs = $langs; if (!empty($_REQUEST['lang_id'])) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($_REQUEST['lang_id']); } //if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) supplier_invoice_pdf_create($db, $object->id, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);