Fix: Suite correction bug gestion avoirs
This commit is contained in:
parent
7960db1c3c
commit
5697f3c0de
@ -127,7 +127,7 @@ if ($_GET["action"] == 'create')
|
|||||||
print '<tr><td>'.$langs->trans('Discounts').'</td><td colspan="2">';
|
print '<tr><td>'.$langs->trans('Discounts').'</td><td colspan="2">';
|
||||||
if ($soc->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$soc->remise_client);
|
if ($soc->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$soc->remise_client);
|
||||||
else print $langs->trans("CompanyHasNoRelativeDiscount");
|
else print $langs->trans("CompanyHasNoRelativeDiscount");
|
||||||
$absolute_discount=$soc->getCurrentDiscount();
|
$absolute_discount=$soc->getAvailableDiscounts();
|
||||||
print '. ';
|
print '. ';
|
||||||
if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->trans("Currency".$conf->monnaie));
|
if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->trans("Currency".$conf->monnaie));
|
||||||
else print $langs->trans("CompanyHasNoAbsoluteDiscount");
|
else print $langs->trans("CompanyHasNoAbsoluteDiscount");
|
||||||
|
|||||||
@ -265,7 +265,7 @@ if ($socid > 0)
|
|||||||
print '</td></tr></table>';
|
print '</td></tr></table>';
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print '<td colspan="3">';
|
print '<td colspan="3">';
|
||||||
$amount_discount=$objsoc->getcurrentDiscount();
|
$amount_discount=$objsoc->getAvailableDiscounts();
|
||||||
if ($amount_discount < 0) dolibarr_print_error($db,$societe->error);
|
if ($amount_discount < 0) dolibarr_print_error($db,$societe->error);
|
||||||
if ($amount_discount > 0) print price($amount_discount).' '.$langs->trans("Currency".$conf->monnaie);
|
if ($amount_discount > 0) print price($amount_discount).' '.$langs->trans("Currency".$conf->monnaie);
|
||||||
else print $langs->trans("DiscountNone");
|
else print $langs->trans("DiscountNone");
|
||||||
|
|||||||
@ -823,8 +823,8 @@ if ($_GET['propalid'] > 0)
|
|||||||
print '<tr><td>'.$langs->trans('Discounts').'</td><td colspan="5">';
|
print '<tr><td>'.$langs->trans('Discounts').'</td><td colspan="5">';
|
||||||
if ($societe->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$societe->remise_client);
|
if ($societe->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$societe->remise_client);
|
||||||
else print $langs->trans("CompanyHasNoRelativeDiscount");
|
else print $langs->trans("CompanyHasNoRelativeDiscount");
|
||||||
$absolute_discount=$societe->getCurrentDiscount('','fk_facture_source IS NULL');
|
$absolute_discount=$societe->getAvailableDiscounts('','fk_facture_source IS NULL');
|
||||||
$absolute_creditnote=$societe->getCurrentDiscount('','fk_facture_source IS NOT NULL');
|
$absolute_creditnote=$societe->getAvailableDiscounts('','fk_facture_source IS NOT NULL');
|
||||||
print '. ';
|
print '. ';
|
||||||
if ($absolute_discount)
|
if ($absolute_discount)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -110,7 +110,7 @@ if ($_GET["propalid"] > 0)
|
|||||||
print '<tr><td>'.$langs->trans('Discounts').'</td><td colspan="5">';
|
print '<tr><td>'.$langs->trans('Discounts').'</td><td colspan="5">';
|
||||||
if ($societe->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$societe->remise_client);
|
if ($societe->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$societe->remise_client);
|
||||||
else print $langs->trans("CompanyHasNoRelativeDiscount");
|
else print $langs->trans("CompanyHasNoRelativeDiscount");
|
||||||
$absolute_discount=$societe->getCurrentDiscount();
|
$absolute_discount=$societe->getAvailableDiscounts();
|
||||||
print '. ';
|
print '. ';
|
||||||
if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount",$absolute_discount,$langs->trans("Currency".$conf->monnaie));
|
if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount",$absolute_discount,$langs->trans("Currency".$conf->monnaie));
|
||||||
else print $langs->trans("CompanyHasNoAbsoluteDiscount");
|
else print $langs->trans("CompanyHasNoAbsoluteDiscount");
|
||||||
|
|||||||
@ -118,7 +118,7 @@ if ($_GET['propalid'])
|
|||||||
print '<tr><td>'.$langs->trans('Discounts').'</td><td colspan="3">';
|
print '<tr><td>'.$langs->trans('Discounts').'</td><td colspan="3">';
|
||||||
if ($societe->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$societe->remise_client);
|
if ($societe->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$societe->remise_client);
|
||||||
else print $langs->trans("CompanyHasNoRelativeDiscount");
|
else print $langs->trans("CompanyHasNoRelativeDiscount");
|
||||||
$absolute_discount=$societe->getCurrentDiscount();
|
$absolute_discount=$societe->getAvailableDiscounts();
|
||||||
print '. ';
|
print '. ';
|
||||||
if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount",$absolute_discount,$langs->trans("Currency".$conf->monnaie));
|
if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount",$absolute_discount,$langs->trans("Currency".$conf->monnaie));
|
||||||
else print $langs->trans("CompanyHasNoAbsoluteDiscount");
|
else print $langs->trans("CompanyHasNoAbsoluteDiscount");
|
||||||
|
|||||||
@ -786,7 +786,7 @@ if ($_GET['action'] == 'create' && $user->rights->commande->creer)
|
|||||||
print '<tr><td>'.$langs->trans('Discounts').'</td><td>';
|
print '<tr><td>'.$langs->trans('Discounts').'</td><td>';
|
||||||
if ($soc->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$soc->remise_client);
|
if ($soc->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$soc->remise_client);
|
||||||
else print $langs->trans("CompanyHasNoRelativeDiscount");
|
else print $langs->trans("CompanyHasNoRelativeDiscount");
|
||||||
$absolute_discount=$soc->getCurrentDiscount();
|
$absolute_discount=$soc->getAvailableDiscounts();
|
||||||
print '. ';
|
print '. ';
|
||||||
if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->trans("Currency".$conf->monnaie));
|
if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->trans("Currency".$conf->monnaie));
|
||||||
else print $langs->trans("CompanyHasNoAbsoluteDiscount");
|
else print $langs->trans("CompanyHasNoAbsoluteDiscount");
|
||||||
@ -1111,8 +1111,8 @@ else
|
|||||||
print '<tr><td>'.$langs->trans('Discounts').'</td><td colspan="3">';
|
print '<tr><td>'.$langs->trans('Discounts').'</td><td colspan="3">';
|
||||||
if ($soc->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$soc->remise_client);
|
if ($soc->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$soc->remise_client);
|
||||||
else print $langs->trans("CompanyHasNoRelativeDiscount");
|
else print $langs->trans("CompanyHasNoRelativeDiscount");
|
||||||
$absolute_discount=$soc->getCurrentDiscount('','fk_facture_source IS NULL');
|
$absolute_discount=$soc->getAvailableDiscounts('','fk_facture_source IS NULL');
|
||||||
$absolute_creditnote=$soc->getCurrentDiscount('','fk_facture_source IS NOT NULL');
|
$absolute_creditnote=$soc->getAvailableDiscounts('','fk_facture_source IS NOT NULL');
|
||||||
print '. ';
|
print '. ';
|
||||||
if ($absolute_discount)
|
if ($absolute_discount)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -135,8 +135,8 @@ if ($_GET["id"] > 0)
|
|||||||
print '<tr><td>'.$langs->trans('Discounts').'</td><td colspan="3">';
|
print '<tr><td>'.$langs->trans('Discounts').'</td><td colspan="3">';
|
||||||
if ($soc->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$soc->remise_client);
|
if ($soc->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$soc->remise_client);
|
||||||
else print $langs->trans("CompanyHasNoRelativeDiscount");
|
else print $langs->trans("CompanyHasNoRelativeDiscount");
|
||||||
$absolute_discount=$soc->getCurrentDiscount('','fk_facture_source IS NULL');
|
$absolute_discount=$soc->getAvailableDiscounts('','fk_facture_source IS NULL');
|
||||||
$absolute_creditnote=$soc->getCurrentDiscount('','fk_facture_source IS NOT NULL');
|
$absolute_creditnote=$soc->getAvailableDiscounts('','fk_facture_source IS NOT NULL');
|
||||||
print '. ';
|
print '. ';
|
||||||
if ($absolute_discount)
|
if ($absolute_discount)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1138,7 +1138,7 @@ if ($_REQUEST['action'] == 'builddoc') // En get ou en post
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
llxHeader('',$langs->trans('Bill'),'Facture');
|
llxHeader('',$langs->trans('Bill'),'HelpInvoice');
|
||||||
|
|
||||||
$html = new Form($db);
|
$html = new Form($db);
|
||||||
|
|
||||||
@ -1693,8 +1693,11 @@ else
|
|||||||
/* *************************************************************************** */
|
/* *************************************************************************** */
|
||||||
if ($mesg) print $mesg.'<br>';
|
if ($mesg) print $mesg.'<br>';
|
||||||
|
|
||||||
$fac = New Facture($db);
|
$facstatic = new Facture($db);
|
||||||
if ($fac->fetch($_GET['facid']))
|
|
||||||
|
$fac = new Facture($db);
|
||||||
|
$result=$fac->fetch($_GET['facid']);
|
||||||
|
if ($result > 0)
|
||||||
{
|
{
|
||||||
if ($user->societe_id>0 && $user->societe_id!=$fac->socid) accessforbidden('',0);
|
if ($user->societe_id>0 && $user->societe_id!=$fac->socid) accessforbidden('',0);
|
||||||
|
|
||||||
@ -1702,12 +1705,14 @@ else
|
|||||||
|
|
||||||
$soc = new Societe($db, $fac->socid);
|
$soc = new Societe($db, $fac->socid);
|
||||||
$soc->fetch($fac->socid);
|
$soc->fetch($fac->socid);
|
||||||
$absolute_discount=$soc->getCurrentDiscount('','fk_facture_source IS NULL');
|
$absolute_discount=$soc->getAvailableDiscounts('','fk_facture_source IS NULL');
|
||||||
$absolute_creditnote=$soc->getCurrentDiscount('','fk_facture_source IS NOT NULL');
|
$absolute_creditnote=$soc->getAvailableDiscounts('','fk_facture_source IS NOT NULL');
|
||||||
|
|
||||||
$totalpaye = $fac->getSommePaiement();
|
$totalpaye = $fac->getSommePaiement();
|
||||||
$resteapayer = $fac->total_ttc - $totalpaye;
|
$totalavoir = $fac->getSommeCreditNote();
|
||||||
|
$resteapayer = $fac->total_ttc - $totalpaye - $totalavoir;
|
||||||
if ($fac->paye) $resteapayer=0;
|
if ($fac->paye) $resteapayer=0;
|
||||||
|
$resteapayeraffiche=$resteapayer;
|
||||||
|
|
||||||
$author = new User($db);
|
$author = new User($db);
|
||||||
if ($fac->user_author)
|
if ($fac->user_author)
|
||||||
@ -1873,6 +1878,7 @@ else
|
|||||||
/*
|
/*
|
||||||
* Facture
|
* Facture
|
||||||
*/
|
*/
|
||||||
|
|
||||||
print '<table class="border" width="100%">';
|
print '<table class="border" width="100%">';
|
||||||
|
|
||||||
// Reference
|
// Reference
|
||||||
@ -1942,7 +1948,7 @@ else
|
|||||||
$facreplaced->fetch($fac->fk_facture_source);
|
$facreplaced->fetch($fac->fk_facture_source);
|
||||||
print ' ('.$langs->transnoentities("CorrectInvoice",$facreplaced->getNomUrl(1)).')';
|
print ' ('.$langs->transnoentities("CorrectInvoice",$facreplaced->getNomUrl(1)).')';
|
||||||
}
|
}
|
||||||
$facidavoir=$fac->getIdAvoirInvoice();
|
$facidavoir=$fac->getListIdAvoirFromInvoice();
|
||||||
if (sizeof($facidavoir) > 0)
|
if (sizeof($facidavoir) > 0)
|
||||||
{
|
{
|
||||||
print ' ('.$langs->transnoentities("InvoiceHasAvoir");
|
print ' ('.$langs->transnoentities("InvoiceHasAvoir");
|
||||||
@ -2057,12 +2063,34 @@ else
|
|||||||
|
|
||||||
// Facturé
|
// Facturé
|
||||||
print '<tr><td colspan="2" align="right">'.$langs->trans("Billed").' :</td><td align="right" style="border: 1px solid;">'.price($fac->total_ttc).'</td><td>'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>';
|
print '<tr><td colspan="2" align="right">'.$langs->trans("Billed").' :</td><td align="right" style="border: 1px solid;">'.price($fac->total_ttc).'</td><td>'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>';
|
||||||
|
|
||||||
$resteapayeraffiche=$resteapayer;
|
$resteapayeraffiche=$resteapayer;
|
||||||
|
|
||||||
// Boucle sur chaque facture avoir appliquee
|
// Boucle sur chaque facture avoir appliquee
|
||||||
|
$sql = "SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,";
|
||||||
|
$sql.= " re.description, re.fk_facture_source, re.fk_facture_source";
|
||||||
|
$sql.= " FROM ".MAIN_DB_PREFIX ."societe_remise_except as re";
|
||||||
|
$sql.= " WHERE fk_facture = ".$fac->id;
|
||||||
|
$resql=$db->query($sql);
|
||||||
|
if ($resql)
|
||||||
|
{
|
||||||
|
$num = $db->num_rows($resql);
|
||||||
|
$i = 0;
|
||||||
|
$invoice=new Facture($db);
|
||||||
|
while ($i < $num)
|
||||||
|
{
|
||||||
|
$obj = $db->fetch_object($resql);
|
||||||
|
print '<tr><td colspan="2" align="right">'.$langs->trans("CreditNote").' ';
|
||||||
|
$invoice->fetch($obj->fk_facture_source);
|
||||||
|
print $invoice->getNomUrl(0);
|
||||||
|
print ' :</td>';
|
||||||
|
print '<td align="right" style="border: 1px solid;">'.price($obj->amount_ttc).'</td><td>'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>';
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dolibarr_print_error($db);
|
||||||
|
}
|
||||||
|
|
||||||
// Payé partiellement 'escompte'
|
// Payé partiellement 'escompte'
|
||||||
if (($fac->statut == 2 || $fac->statut == 3) && $fac->close_code == 'escompte')
|
if (($fac->statut == 2 || $fac->statut == 3) && $fac->close_code == 'escompte')
|
||||||
@ -2177,6 +2205,7 @@ else
|
|||||||
|
|
||||||
// Lit lignes de facture pour déterminer montant
|
// Lit lignes de facture pour déterminer montant
|
||||||
// On s'en sert pas mais ca sert pour debuggage
|
// On s'en sert pas mais ca sert pour debuggage
|
||||||
|
/*
|
||||||
$sql = 'SELECT l.price as price, l.qty, l.rowid, l.tva_taux,';
|
$sql = 'SELECT l.price as price, l.qty, l.rowid, l.tva_taux,';
|
||||||
$sql .= ' l.remise_percent, l.subprice';
|
$sql .= ' l.remise_percent, l.subprice';
|
||||||
$sql .= ' FROM '.MAIN_DB_PREFIX.'facturedet as l ';
|
$sql .= ' FROM '.MAIN_DB_PREFIX.'facturedet as l ';
|
||||||
@ -2201,6 +2230,7 @@ else
|
|||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
// Montants
|
// Montants
|
||||||
print '<tr><td>'.$langs->trans('AmountHT').'</td>';
|
print '<tr><td>'.$langs->trans('AmountHT').'</td>';
|
||||||
@ -2736,8 +2766,9 @@ else
|
|||||||
if ($fac->statut == 1 && $fac->paye == 0 && $resteapayer > 0
|
if ($fac->statut == 1 && $fac->paye == 0 && $resteapayer > 0
|
||||||
&& $user->rights->facture->paiement)
|
&& $user->rights->facture->paiement)
|
||||||
{
|
{
|
||||||
if ($totalpaye > 0)
|
if ($totalpaye > 0 || $totalavoir > 0)
|
||||||
{
|
{
|
||||||
|
// If one payment or one credit note was linked to this invoice
|
||||||
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?facid='.$fac->id.'&action=payed">'.$langs->trans('ClassifyPayedPartially').'</a>';
|
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?facid='.$fac->id.'&action=payed">'.$langs->trans('ClassifyPayedPartially').'</a>';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@ -204,7 +204,7 @@ if ($socid > 0)
|
|||||||
print '</td></tr></table>';
|
print '</td></tr></table>';
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print '<td colspan="3">';
|
print '<td colspan="3">';
|
||||||
$amount_discount=$societe->getCurrentDiscount();
|
$amount_discount=$societe->getAvailableDiscounts();
|
||||||
if ($amount_discount < 0) dolibarr_print_error($db,$societe->error);
|
if ($amount_discount < 0) dolibarr_print_error($db,$societe->error);
|
||||||
if ($amount_discount > 0) print price($amount_discount).' '.$langs->trans("Currency".$conf->monnaie);
|
if ($amount_discount > 0) print price($amount_discount).' '.$langs->trans("Currency".$conf->monnaie);
|
||||||
else print $langs->trans("DiscountNone");
|
else print $langs->trans("DiscountNone");
|
||||||
|
|||||||
@ -171,7 +171,7 @@ if ($_GET["propalid"] > 0)
|
|||||||
print '<tr><td>'.$langs->trans('Discounts').'</td><td colspan="5">';
|
print '<tr><td>'.$langs->trans('Discounts').'</td><td colspan="5">';
|
||||||
if ($societe->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$societe->remise_client);
|
if ($societe->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$societe->remise_client);
|
||||||
else print $langs->trans("CompanyHasNoRelativeDiscount");
|
else print $langs->trans("CompanyHasNoRelativeDiscount");
|
||||||
$absolute_discount=$societe->getCurrentDiscount();
|
$absolute_discount=$societe->getAvailableDiscounts();
|
||||||
print '. ';
|
print '. ';
|
||||||
if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount",$absolute_discount,$langs->trans("Currency".$conf->monnaie));
|
if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount",$absolute_discount,$langs->trans("Currency".$conf->monnaie));
|
||||||
else print $langs->trans("CompanyHasNoAbsoluteDiscount");
|
else print $langs->trans("CompanyHasNoAbsoluteDiscount");
|
||||||
|
|||||||
@ -191,7 +191,7 @@ if ($id > 0)
|
|||||||
print '<tr><td>'.$langs->trans('Discount').'</td><td>';
|
print '<tr><td>'.$langs->trans('Discount').'</td><td>';
|
||||||
if ($contrat->societe->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$contrat->societe->remise_client);
|
if ($contrat->societe->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$contrat->societe->remise_client);
|
||||||
else print $langs->trans("CompanyHasNoRelativeDiscount");
|
else print $langs->trans("CompanyHasNoRelativeDiscount");
|
||||||
$absolute_discount=$contrat->societe->getCurrentDiscount();
|
$absolute_discount=$contrat->societe->getAvailableDiscounts();
|
||||||
print '. ';
|
print '. ';
|
||||||
if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount",$absolute_discount,$langs->trans("Currency".$conf->monnaie));
|
if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount",$absolute_discount,$langs->trans("Currency".$conf->monnaie));
|
||||||
else print $langs->trans("CompanyHasNoAbsoluteDiscount");
|
else print $langs->trans("CompanyHasNoAbsoluteDiscount");
|
||||||
|
|||||||
@ -428,7 +428,7 @@ if ($_GET["action"] == 'create')
|
|||||||
print '<tr><td>'.$langs->trans('Discount').'</td><td>';
|
print '<tr><td>'.$langs->trans('Discount').'</td><td>';
|
||||||
if ($soc->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$soc->remise_client);
|
if ($soc->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$soc->remise_client);
|
||||||
else print $langs->trans("CompanyHasNoRelativeDiscount");
|
else print $langs->trans("CompanyHasNoRelativeDiscount");
|
||||||
$absolute_discount=$soc->getCurrentDiscount();
|
$absolute_discount=$soc->getAvailableDiscounts();
|
||||||
print '. ';
|
print '. ';
|
||||||
if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount",$absolute_discount,$langs->trans("Currency".$conf->monnaie));
|
if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount",$absolute_discount,$langs->trans("Currency".$conf->monnaie));
|
||||||
else print $langs->trans("CompanyHasNoAbsoluteDiscount");
|
else print $langs->trans("CompanyHasNoAbsoluteDiscount");
|
||||||
@ -679,7 +679,7 @@ else
|
|||||||
print '<tr><td>'.$langs->trans('Discount').'</td><td colspan="3">';
|
print '<tr><td>'.$langs->trans('Discount').'</td><td colspan="3">';
|
||||||
if ($contrat->societe->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$contrat->societe->remise_client);
|
if ($contrat->societe->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$contrat->societe->remise_client);
|
||||||
else print $langs->trans("CompanyHasNoRelativeDiscount");
|
else print $langs->trans("CompanyHasNoRelativeDiscount");
|
||||||
$absolute_discount=$contrat->societe->getCurrentDiscount();
|
$absolute_discount=$contrat->societe->getAvailableDiscounts();
|
||||||
print '. ';
|
print '. ';
|
||||||
if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount",$absolute_discount,$langs->trans("Currency".$conf->monnaie));
|
if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount",$absolute_discount,$langs->trans("Currency".$conf->monnaie));
|
||||||
else print $langs->trans("CompanyHasNoAbsoluteDiscount");
|
else print $langs->trans("CompanyHasNoAbsoluteDiscount");
|
||||||
|
|||||||
@ -176,7 +176,7 @@ if ($lineid > 0)
|
|||||||
print '<tr><td>'.$langs->trans('Discount').'</td><td>';
|
print '<tr><td>'.$langs->trans('Discount').'</td><td>';
|
||||||
if ($soc->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$soc->remise_client);
|
if ($soc->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$soc->remise_client);
|
||||||
else print $langs->trans("CompanyHasNoRelativeDiscount");
|
else print $langs->trans("CompanyHasNoRelativeDiscount");
|
||||||
$absolute_discount=$soc->getCurrentDiscount();
|
$absolute_discount=$soc->getAvailableDiscounts();
|
||||||
print '. ';
|
print '. ';
|
||||||
if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount",$absolute_discount,$langs->trans("Currency".$conf->monnaie));
|
if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount",$absolute_discount,$langs->trans("Currency".$conf->monnaie));
|
||||||
else print $langs->trans("CompanyHasNoAbsoluteDiscount");
|
else print $langs->trans("CompanyHasNoAbsoluteDiscount");
|
||||||
|
|||||||
@ -145,7 +145,7 @@ if ($_GET["id"])
|
|||||||
print '<tr><td>'.$langs->trans('Discount').'</td><td>';
|
print '<tr><td>'.$langs->trans('Discount').'</td><td>';
|
||||||
if ($contrat->societe->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$contrat->societe->remise_client);
|
if ($contrat->societe->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$contrat->societe->remise_client);
|
||||||
else print $langs->trans("CompanyHasNoRelativeDiscount");
|
else print $langs->trans("CompanyHasNoRelativeDiscount");
|
||||||
$absolute_discount=$contrat->societe->getCurrentDiscount();
|
$absolute_discount=$contrat->societe->getAvailableDiscounts();
|
||||||
print '. ';
|
print '. ';
|
||||||
if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount",$absolute_discount,$langs->trans("Currency".$conf->monnaie));
|
if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount",$absolute_discount,$langs->trans("Currency".$conf->monnaie));
|
||||||
else print $langs->trans("CompanyHasNoAbsoluteDiscount");
|
else print $langs->trans("CompanyHasNoAbsoluteDiscount");
|
||||||
|
|||||||
@ -271,7 +271,7 @@ class DiscountAbsolute
|
|||||||
* \param filter Filtre autre
|
* \param filter Filtre autre
|
||||||
* \return int <0 si ko, montant avoir sinon
|
* \return int <0 si ko, montant avoir sinon
|
||||||
*/
|
*/
|
||||||
function getCurrentDiscount($company='', $user='',$filter='')
|
function getAvailableDiscounts($company='', $user='',$filter='')
|
||||||
{
|
{
|
||||||
$sql = "SELECT SUM(rc.amount_ttc) as amount";
|
$sql = "SELECT SUM(rc.amount_ttc) as amount";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."societe_remise_except as rc";
|
$sql.= " FROM ".MAIN_DB_PREFIX."societe_remise_except as rc";
|
||||||
@ -280,7 +280,7 @@ class DiscountAbsolute
|
|||||||
if (is_object($user)) $sql.= " AND rc.fk_user = ".$user->id;
|
if (is_object($user)) $sql.= " AND rc.fk_user = ".$user->id;
|
||||||
if ($filter) $sql.=' AND '.$filter;
|
if ($filter) $sql.=' AND '.$filter;
|
||||||
|
|
||||||
dolibarr_syslog("Discount::getCurrentDiscount sql=".$sql,LOG_DEBUG);
|
dolibarr_syslog("Discount::getAvailableDiscounts sql=".$sql,LOG_DEBUG);
|
||||||
$resql=$this->db->query($sql);
|
$resql=$this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
@ -291,6 +291,30 @@ class DiscountAbsolute
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Renvoie montant TTC des avoirs utilises par la facture
|
||||||
|
* \return int <0 if KO, Credit note amount otherwise
|
||||||
|
*/
|
||||||
|
function getSommeCreditNote($invoice)
|
||||||
|
{
|
||||||
|
$sql = 'SELECT sum(rc.amount_ttc) as amount';
|
||||||
|
$sql.= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc';
|
||||||
|
$sql.= ' WHERE rc.fk_facture = '.$invoice->id;
|
||||||
|
|
||||||
|
dolibarr_syslog("Discount::getSommeCreditNote sql=".$sql,LOG_DEBUG);
|
||||||
|
$resql=$this->db->query($sql);
|
||||||
|
if ($resql)
|
||||||
|
{
|
||||||
|
$obj = $this->db->fetch_object($resql);
|
||||||
|
return $obj->amount;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\brief Renvoie nom clicable (avec eventuellement le picto)
|
\brief Renvoie nom clicable (avec eventuellement le picto)
|
||||||
\param withpicto 0=Pas de picto, 1=Inclut le picto dans le lien, 2=Picto seul
|
\param withpicto 0=Pas de picto, 1=Inclut le picto dans le lien, 2=Picto seul
|
||||||
|
|||||||
@ -1814,11 +1814,32 @@ class Facture extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Renvoie montant TTC des avoirs utilises par la facture
|
||||||
|
* \return int <0 if KO, Credit note amount otherwise
|
||||||
|
*/
|
||||||
|
function getSommeCreditNote()
|
||||||
|
{
|
||||||
|
require_once(DOL_DOCUMENT_ROOT.'/discount.class.php');
|
||||||
|
|
||||||
|
$discountstatic=new DiscountAbsolute($this->db);
|
||||||
|
$result=$discountstatic->getSommeCreditNote($this);
|
||||||
|
if ($result >= 0)
|
||||||
|
{
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->error=$discountstatic->error;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Renvoie tableau des ids de facture avoir issus de la facture
|
* \brief Renvoie tableau des ids de facture avoir issus de la facture
|
||||||
* \return array Tableau d'id de factures avoirs
|
* \return array Tableau d'id de factures avoirs
|
||||||
*/
|
*/
|
||||||
function getIdAvoirInvoice()
|
function getListIdAvoirFromInvoice()
|
||||||
{
|
{
|
||||||
$idarray=array();
|
$idarray=array();
|
||||||
|
|
||||||
@ -1829,11 +1850,11 @@ class Facture extends CommonObject
|
|||||||
$resql=$this->db->query($sql);
|
$resql=$this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
$num = $this->db->num_rows();
|
$num = $this->db->num_rows($resql);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
while ($i < $num)
|
while ($i < $num)
|
||||||
{
|
{
|
||||||
$row = $this->db->fetch_row($i);
|
$row = $this->db->fetch_row($resql);
|
||||||
$idarray[]=$row[0];
|
$idarray[]=$row[0];
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -745,7 +745,7 @@ class Form
|
|||||||
{
|
{
|
||||||
global $langs,$conf;
|
global $langs,$conf;
|
||||||
|
|
||||||
// On recherche les societes
|
// On recherche les remises
|
||||||
$sql = "SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,";
|
$sql = "SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,";
|
||||||
$sql.= " re.description, re.fk_facture_source";
|
$sql.= " re.description, re.fk_facture_source";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX ."societe_remise_except as re";
|
$sql.= " FROM ".MAIN_DB_PREFIX ."societe_remise_except as re";
|
||||||
|
|||||||
@ -843,10 +843,10 @@ function top_menu($head, $title="", $target="")
|
|||||||
/**
|
/**
|
||||||
* \brief Affiche barre de menu gauche
|
* \brief Affiche barre de menu gauche
|
||||||
* \param menu_array Tableau des entrees de menu
|
* \param menu_array Tableau des entrees de menu
|
||||||
* \param help_url Url pour le lien aide ('' par defaut)
|
* \param helppagename Url pour le lien aide ('' par defaut)
|
||||||
* \param form_search Formulaire de recherche permanant supplementaire
|
* \param form_search Formulaire de recherche permanant supplementaire
|
||||||
*/
|
*/
|
||||||
function left_menu($menu_array, $help_url='', $form_search='')
|
function left_menu($menu_array, $helppagename='', $form_search='')
|
||||||
{
|
{
|
||||||
global $user, $conf, $langs, $db;
|
global $user, $conf, $langs, $db;
|
||||||
|
|
||||||
@ -908,12 +908,23 @@ function left_menu($menu_array, $help_url='', $form_search='')
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Lien vers l'aide en ligne (uniquement si langue fr_FR)
|
// Lien vers l'aide en ligne (uniquement si langue fr_FR)
|
||||||
if ($help_url)
|
if ($helppagename)
|
||||||
{
|
{
|
||||||
|
$langs->load("help");
|
||||||
|
|
||||||
$helpbaseurl='';
|
$helpbaseurl='';
|
||||||
if ($langs->defaultlang == "fr_FR") $helpbaseurl='http://www.dolibarr.com/wikidev/index.php/%s';
|
if ($langs->defaultlang == "fr_FR") $helpbaseurl='http://www.dolibarr.com/wikidev/index.php/%s';
|
||||||
|
|
||||||
if ($helpbaseurl) print '<div class="help"><a class="help" target="_blank" href="'.sprintf($helpbaseurl,$help_url).'">'.$langs->trans("Help").'</a></div>';
|
$helppage=$langs->trans($helppagename);
|
||||||
|
|
||||||
|
if ($helpbaseurl)
|
||||||
|
{
|
||||||
|
print '<div class="help">';
|
||||||
|
print '<a class="help" target="_blank" href="';
|
||||||
|
print sprintf($helpbaseurl,$helppage);
|
||||||
|
print '">'.$langs->trans("Help").'</a>';
|
||||||
|
print '</div>';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($conf->global->MAIN_SHOW_BUGTRACK_LINK == 1)
|
if ($conf->global->MAIN_SHOW_BUGTRACK_LINK == 1)
|
||||||
|
|||||||
@ -1031,24 +1031,23 @@ class Societe
|
|||||||
* \param filter Filtre autre
|
* \param filter Filtre autre
|
||||||
* \return int <0 if KO, Credit note amount otherwise
|
* \return int <0 if KO, Credit note amount otherwise
|
||||||
*/
|
*/
|
||||||
function getCurrentDiscount($user='',$filter='')
|
function getAvailableDiscounts($user='',$filter='')
|
||||||
{
|
{
|
||||||
require_once(DOL_DOCUMENT_ROOT.'/discount.class.php');
|
require_once(DOL_DOCUMENT_ROOT.'/discount.class.php');
|
||||||
|
|
||||||
$discountstatic=new DiscountAbsolute($this->db);
|
$discountstatic=new DiscountAbsolute($this->db);
|
||||||
$result=$discountstatic->getCurrentDiscount($this,$user,$filter);
|
$result=$discountstatic->getAvailableDiscounts($this,$user,$filter);
|
||||||
if ($result >= 0)
|
if ($result >= 0)
|
||||||
{
|
{
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->error=$discount->error;
|
$this->error=$discountstatic->error;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function set_price_level($price_level, $user)
|
function set_price_level($price_level, $user)
|
||||||
{
|
{
|
||||||
if ($this->id)
|
if ($this->id)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user