Fix: ajout vrification sur l'dition de facture, on pouvait diter une facture dont les lignes taient soit ventiles soit exportes en compta
This commit is contained in:
parent
1a5c8c8cb1
commit
cf571926a9
@ -168,7 +168,21 @@ if ($_GET['action'] == 'modif' && $user->rights->facture->modifier && $conf->glo
|
||||
*/
|
||||
$fac = new Facture($db);
|
||||
$fac->fetch($_GET['facid']);
|
||||
$fac->reopen($user);
|
||||
|
||||
// On vérifie si les lignes de factures ont été exportées en compta et/ou ventilées
|
||||
$ventilExportCompta = 0 ;
|
||||
for ($i = 0 ; $i < sizeof($fac->lignes) ; $i++)
|
||||
{
|
||||
if ($fac->lignes[$i]->export_compta <> 0 && $fac->lignes[$i]->code_ventilation <> 0)
|
||||
{
|
||||
$ventilExportCompta++;
|
||||
}
|
||||
}
|
||||
|
||||
if ($ventilExportCompta == 0)
|
||||
{
|
||||
$fac->reopen($user);
|
||||
}
|
||||
}
|
||||
|
||||
if ($_POST['action'] == 'confirm_deleteproductline' && $_POST['confirm'] == 'yes' && $conf->global->PRODUIT_CONFIRM_DELETE_LINE)
|
||||
@ -2093,11 +2107,21 @@ else
|
||||
{
|
||||
print '<div class="tabsAction">';
|
||||
|
||||
// Editer une facture déjà validée et sans paiement
|
||||
// Editer une facture déjà validée, sans paiement effectué et pas exporté en compta
|
||||
if ($fac->statut == 1)
|
||||
{
|
||||
// On vérifie si les lignes de factures ont été exportées en compta et/ou ventilées
|
||||
$ventilExportCompta = 0 ;
|
||||
for ($i = 0 ; $i < sizeof($fac->lignes) ; $i++)
|
||||
{
|
||||
if ($fac->lignes[$i]->export_compta <> 0 && $fac->lignes[$i]->code_ventilation <> 0)
|
||||
{
|
||||
$ventilExportCompta++;
|
||||
}
|
||||
}
|
||||
|
||||
if ($conf->global->FACTURE_ENABLE_EDITDELETE && $user->rights->facture->modifier
|
||||
&& ($resteapayer == $fac->total_ttc && $fac->paye == 0))
|
||||
&& ($resteapayer == $fac->total_ttc && $fac->paye == 0 && $ventilExportCompta == 0))
|
||||
{
|
||||
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?facid='.$fac->id.'&action=modif">'.$langs->trans('Edit').'</a>';
|
||||
}
|
||||
@ -2157,8 +2181,18 @@ else
|
||||
{
|
||||
$maxfacnumber = $db->fetch_row($resql);
|
||||
}
|
||||
|
||||
// On vérifie si les lignes de factures ont été exportées en compta et/ou ventilées
|
||||
$ventilExportCompta = 0 ;
|
||||
for ($i = 0 ; $i < sizeof($fac->lignes) ; $i++)
|
||||
{
|
||||
if ($fac->lignes[$i]->export_compta <> 0 && $fac->lignes[$i]->code_ventilation <> 0)
|
||||
{
|
||||
$ventilExportCompta++;
|
||||
}
|
||||
}
|
||||
|
||||
if ($maxfacnumber[0] == $fac->ref)
|
||||
if ($maxfacnumber[0] == $fac->ref && $ventilExportCompta == 0)
|
||||
{
|
||||
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?facid='.$fac->id.'&action=delete">'.$langs->trans('Delete').'</a>';
|
||||
}
|
||||
|
||||
@ -82,7 +82,10 @@ $form = new Form($db);
|
||||
|
||||
if($_GET["id"])
|
||||
{
|
||||
$sql = "SELECT f.facnumber, f.rowid as facid, l.fk_product, l.description, l.price, l.qty, l.rowid, l.tva_taux, l.remise_percent, l.subprice, ".$db->pdate("l.date_start")." as date_start, ".$db->pdate("l.date_end")." as date_end, l.fk_code_ventilation ";
|
||||
$sql = "SELECT f.facnumber, f.rowid as facid, l.fk_product, l.description, l.price,";
|
||||
$sql .= " l.qty, l.rowid, l.tva_taux, l.remise_percent, l.subprice,";
|
||||
$sql .= " ".$db->pdate("l.date_start")." as date_start, ".$db->pdate("l.date_end")." as date_end,";
|
||||
$sql .= " l.fk_code_ventilation ";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."facturedet as l";
|
||||
$sql .= " , ".MAIN_DB_PREFIX."facture as f";
|
||||
$sql .= " WHERE f.rowid = l.fk_facture AND f.fk_statut = 1 AND l.rowid = ".$_GET["id"];
|
||||
|
||||
@ -405,7 +405,7 @@ class Facture extends CommonObject
|
||||
*/
|
||||
$sql = 'SELECT l.rowid, l.fk_product, l.description, l.price, l.qty, l.tva_taux, l.remise, l.remise_percent, l.subprice,';
|
||||
$sql.= ' '.$this->db->pdate('l.date_start').' as date_start,'.$this->db->pdate('l.date_end').' as date_end,';
|
||||
$sql.= ' l.info_bits, l.total_ht, l.total_tva, l.total_ttc,';
|
||||
$sql.= ' l.info_bits, l.total_ht, l.total_tva, l.total_ttc, l.fk_code_ventilation, l.fk_export_compta,';
|
||||
$sql.= ' p.label as label, p.description as product_desc';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'facturedet as l';
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid';
|
||||
@ -420,25 +420,27 @@ class Facture extends CommonObject
|
||||
{
|
||||
$objp = $this->db->fetch_object($result2);
|
||||
$faclig = new FactureLigne($this->db);
|
||||
$faclig->rowid = $objp->rowid;
|
||||
$faclig->desc = $objp->description; // Description ligne
|
||||
$faclig->libelle = $objp->label; // Label produit
|
||||
$faclig->product_desc = $objp->product_desc; // Description produit
|
||||
$faclig->qty = $objp->qty;
|
||||
$faclig->price = $objp->price;
|
||||
$faclig->subprice = $objp->subprice;
|
||||
$faclig->tva_taux = $objp->tva_taux;
|
||||
$faclig->remise = $objp->remise;
|
||||
$faclig->remise_percent = $objp->remise_percent;
|
||||
$faclig->produit_id = $objp->fk_product;
|
||||
$faclig->date_start = $objp->date_start;
|
||||
$faclig->date_end = $objp->date_end;
|
||||
$faclig->date_start = $objp->date_start;
|
||||
$faclig->date_end = $objp->date_end;
|
||||
$faclig->info_bits = $objp->info_bits;
|
||||
$faclig->total_ht = $objp->total_ht;
|
||||
$faclig->total_tva = $objp->total_tva;
|
||||
$faclig->total_ttc = $objp->total_ttc;
|
||||
$faclig->rowid = $objp->rowid;
|
||||
$faclig->desc = $objp->description; // Description ligne
|
||||
$faclig->libelle = $objp->label; // Label produit
|
||||
$faclig->product_desc = $objp->product_desc; // Description produit
|
||||
$faclig->qty = $objp->qty;
|
||||
$faclig->price = $objp->price;
|
||||
$faclig->subprice = $objp->subprice;
|
||||
$faclig->tva_taux = $objp->tva_taux;
|
||||
$faclig->remise = $objp->remise;
|
||||
$faclig->remise_percent = $objp->remise_percent;
|
||||
$faclig->produit_id = $objp->fk_product;
|
||||
$faclig->date_start = $objp->date_start;
|
||||
$faclig->date_end = $objp->date_end;
|
||||
$faclig->date_start = $objp->date_start;
|
||||
$faclig->date_end = $objp->date_end;
|
||||
$faclig->info_bits = $objp->info_bits;
|
||||
$faclig->total_ht = $objp->total_ht;
|
||||
$faclig->total_tva = $objp->total_tva;
|
||||
$faclig->total_ttc = $objp->total_ttc;
|
||||
$faclig->export_compta = $objp->fk_export_compta;
|
||||
$faclig->code_ventilation = $objp->fk_code_ventilation;
|
||||
$this->lignes[$i] = $faclig;
|
||||
$i++;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user