forked from Wavyzz/dolibarr
New: Ajout gestion remise/avoirs sur les propales
This commit is contained in:
@@ -650,9 +650,12 @@ if ($_GET['action'] == 'create')
|
||||
$propal->fetch($_GET['propalid']);
|
||||
$societe_id = $propal->soc_id;
|
||||
$projet=$propal->projetidp;
|
||||
|
||||
$soc->fetch($societe_id);
|
||||
$cond_reglement_id = $propal->cond_reglement_id;
|
||||
$mode_reglement_id = $propal->mode_reglement_id;
|
||||
$soc->fetch($societe_id);
|
||||
$remise_percent = $propal->remise_percent;
|
||||
$remise_absolue = $propal->remise_absolue;
|
||||
}
|
||||
elseif ($_GET['commandeid'])
|
||||
{
|
||||
@@ -661,9 +664,12 @@ if ($_GET['action'] == 'create')
|
||||
$societe_id = $commande->soc_id;
|
||||
$projet=$commande-> projet_id;
|
||||
$ref_client=$commande->ref_client;
|
||||
|
||||
$soc->fetch($societe_id);
|
||||
$cond_reglement_id = $commande->cond_reglement_id;
|
||||
$mode_reglement_id = $commande->mode_reglement_id;
|
||||
$soc->fetch($societe_id);
|
||||
$remise_percent = $commande->remise_percent;
|
||||
$remise_absolue = $commande->remise_absolue;
|
||||
}
|
||||
elseif ($_GET['contratid'])
|
||||
{
|
||||
@@ -671,14 +677,22 @@ if ($_GET['action'] == 'create')
|
||||
$contrat->fetch($_GET['contratid']);
|
||||
$societe_id = $contrat->societe->id;
|
||||
$projet=$contrat->fk_projet;
|
||||
|
||||
$soc=$contrat->societe;
|
||||
$cond_reglement_id = $soc->cond_reglement;
|
||||
$mode_reglement_id = $soc->mod_reglement;
|
||||
$remise_percent = $soc->remise_client;
|
||||
$remise_absolue = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$societe_id=$socidp;
|
||||
|
||||
$soc->fetch($societe_id);
|
||||
$cond_reglement_id = $soc->cond_reglement;
|
||||
$mode_reglement_id = $soc->mode_reglement;
|
||||
$remise_percent = $soc->remise_client;
|
||||
$remise_absolue = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -712,11 +726,14 @@ if ($_GET['action'] == 'create')
|
||||
print '</td></tr>';
|
||||
|
||||
// Remise relative
|
||||
$relative_discount=$soc->remise_client;
|
||||
print '<tr><td>'.$langs->trans("CustomerRelativeDiscount").'</td>';
|
||||
print '<td>';
|
||||
print '<input type="text" name="remise_percent" size="1" value="'.$relative_discount.'"> %';
|
||||
if (! $_GET['propalid'] && ! $_GET['commandeid'] && ! $_GET['contratid']) print '<input type="text" name="remise_percent" size="1" value="';
|
||||
print $remise_percent;
|
||||
if (! $_GET['propalid'] && ! $_GET['commandeid'] && ! $_GET['contratid']) print '">';
|
||||
print ' %';
|
||||
print '</td><td>'.img_info().' ';
|
||||
$relative_discount=$soc->remise_client;
|
||||
if ($relative_discount)
|
||||
{
|
||||
print $langs->trans("CompanyHasRelativeDiscount",$relative_discount);
|
||||
@@ -728,11 +745,14 @@ if ($_GET['action'] == 'create')
|
||||
print '</td></tr>';
|
||||
|
||||
// Remise avoirs
|
||||
$absolute_discount=$soc->getCurrentDiscount();
|
||||
print '<tr><td>'.$langs->trans("CustomerAbsoluteDiscount").'</td>';
|
||||
print '<td>';
|
||||
print '<input type="text" name="remise_absolue" size="1" value="0"> '.$langs->trans("Currency".$conf->monnaie);
|
||||
if (! $_GET['propalid'] && ! $_GET['commandeid'] && ! $_GET['contratid']) print '<input type="text" name="remise_absolue" size="1" value="';
|
||||
print $remise_absolue;
|
||||
if (! $_GET['propalid'] && ! $_GET['commandeid'] && ! $_GET['contratid']) print '">';
|
||||
print ' '.$langs->trans("Currency".$conf->monnaie);
|
||||
print '</td><td>'.img_info().' ';
|
||||
$absolute_discount=$soc->getCurrentDiscount();
|
||||
if ($absolute_discount)
|
||||
{
|
||||
print $langs->trans("CompanyHasAbsoluteDiscount",$absolute_discount,$langs->trans("Currency".$conf->monnaie));
|
||||
@@ -813,7 +833,6 @@ if ($_GET['action'] == 'create')
|
||||
print '<input type="hidden" name="propalid" value="'.$propal->id.'">';
|
||||
|
||||
print '<tr><td>'.$langs->trans('Proposal').'</td><td colspan="2">'.$propal->ref.'</td></tr>';
|
||||
print '<tr><td>'.$langs->trans('GlobalDiscount').'</td><td colspan="2">'.$propal->remise_percent.'%</td></tr>';
|
||||
print '<tr><td>'.$langs->trans('TotalHT').'</td><td colspan="2">'.price($propal->price).'</td></tr>';
|
||||
print '<tr><td>'.$langs->trans('TotalVAT').'</td><td colspan="2">'.price($propal->tva)."</td></tr>";
|
||||
print '<tr><td>'.$langs->trans('TotalTTC').'</td><td colspan="2">'.price($propal->total)."</td></tr>";
|
||||
@@ -835,8 +854,8 @@ if ($_GET['action'] == 'create')
|
||||
elseif ($_GET['contratid'] > 0)
|
||||
{
|
||||
// Calcul contrat->price (HT), contrat->total (TTC), contrat->tva
|
||||
$contrat->remise_absolue=0;
|
||||
$contrat->remise_percent=$soc->remise_client;
|
||||
$contrat->remise_absolue=$remise_absolue;
|
||||
$contrat->remise_percent=$remise_percent;
|
||||
$contrat->update_price();
|
||||
|
||||
print '<input type="hidden" name="amount" value="'.$contrat->total_ht.'">'."\n";
|
||||
|
||||
@@ -229,7 +229,7 @@ if ($_GET["propalid"] > 0)
|
||||
print '</td><td colspan="3">';
|
||||
if ($_GET['action'] == 'editconditions')
|
||||
{
|
||||
$html->form_conditions_reglement($_SERVER['PHP_SELF'].'?facid='.$propal->id,$propal->cond_reglement_id,'cond_reglement_id');
|
||||
$html->form_conditions_reglement($_SERVER['PHP_SELF'].'?propalid='.$propal->id,$propal->cond_reglement_id,'cond_reglement_id');
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -321,20 +321,7 @@ if ($_GET["propalid"] > 0)
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
// Remise globale
|
||||
/* TODO Remise a mettre sur meme principe que factures
|
||||
print '<tr><td height="10" nowrap>'.$langs->trans('GlobalDiscount').'</td>';
|
||||
if ($propal->brouillon == 1 && $user->rights->propale->creer)
|
||||
{
|
||||
print '<td colspan="3">'.$propal->remise_percent.'%';
|
||||
print '</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td colspan="3">'.$propal->remise_percent.'%</td>';
|
||||
}
|
||||
print '</tr>';
|
||||
*/
|
||||
// Amount
|
||||
print '<tr><td height="10">'.$langs->trans('AmountHT').'</td>';
|
||||
print '<td align="right" colspan="2"><b>'.price($propal->price).'</b></td>';
|
||||
print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td></tr>';
|
||||
@@ -374,7 +361,9 @@ if ($_GET["propalid"] > 0)
|
||||
print '<td align="right" width="50">'.$langs->trans('Qty').'</td>';
|
||||
print '<td align="right" width="50">'.$langs->trans('Discount').'</td>';
|
||||
print '<td align="right" width="50">'.$langs->trans('AmountHT').'</td>';
|
||||
print '<td> </td><td> </td>';
|
||||
print '<td width="16"> </td>';
|
||||
print '<td width="16"> </td>';
|
||||
print '<td width="16"> </td>';
|
||||
print "</tr>\n";
|
||||
}
|
||||
$var=true;
|
||||
@@ -405,7 +394,7 @@ if ($_GET["propalid"] > 0)
|
||||
{
|
||||
print " (Jusqu'au ".dolibarr_print_date($objp->date_end).')';
|
||||
}
|
||||
print $objp->description?'<br>'.stripslashes(nl2br($objp->description)):'';
|
||||
print ($objp->description && $objp->description!=$objp->product)?'<br>'.stripslashes(nl2br($objp->description)):'';
|
||||
print '</td>';
|
||||
}
|
||||
else
|
||||
@@ -438,7 +427,7 @@ if ($_GET["propalid"] > 0)
|
||||
}
|
||||
print '<td align="right">'.price($objp->subprice*$objp->qty*(100-$objp->remise_percent)/100)."</td>\n";
|
||||
|
||||
print '<td> </td><td> </td>';
|
||||
print '<td colspan="3"> </td>';
|
||||
|
||||
print '</tr>';
|
||||
}
|
||||
@@ -455,6 +444,117 @@ if ($_GET["propalid"] > 0)
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
|
||||
/*
|
||||
* Lignes de remise
|
||||
*/
|
||||
|
||||
// Remise relative
|
||||
$var=!$var;
|
||||
print '<form name="updateligne" action="'.$_SERVER["PHP_SELF"].'" method="post">';
|
||||
print '<input type="hidden" name="action" value="setremisepercent">';
|
||||
print '<input type="hidden" name="propalid" value="'.$propal->id.'">';
|
||||
print '<tr class="liste_total"><td>';
|
||||
print $langs->trans('CustomerRelativeDiscount');
|
||||
if ($propal->brouillon) print ' <font style="font-weight: normal">('.($soc->remise_client?$langs->trans("CompanyHasRelativeDiscount",$soc->remise_client):$langs->trans("CompanyHasNoRelativeDiscount")).')</font>';
|
||||
print '</td>';
|
||||
print '<td> </td>';
|
||||
print '<td> </td>';
|
||||
print '<td> </td>';
|
||||
print '<td align="right"><font style="font-weight: normal">';
|
||||
if ($_GET['action'] == 'editrelativediscount')
|
||||
{
|
||||
print '<input type="text" name="remise_percent" size="2" value="'.$propal->remise_percent.'">%';
|
||||
}
|
||||
else
|
||||
{
|
||||
print $propal->remise_percent?$propal->remise_percent.'%':' ';
|
||||
}
|
||||
print '</font></td>';
|
||||
print '<td align="right"><font style="font-weight: normal">';
|
||||
if ($_GET['action'] != 'editrelativediscount') print $propal->remise_percent?'-'.price($propal->remise_percent*$total/100):$langs->trans("DiscountNone");
|
||||
else print ' ';
|
||||
print '</font></td>';
|
||||
if ($_GET['action'] != 'editrelativediscount')
|
||||
{
|
||||
if ($propal->brouillon && $user->rights->propale->creer)
|
||||
{
|
||||
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editrelativediscount&propalid='.$propal->id.'">'.img_edit($langs->trans('SetRelativeDiscount'),1).'</a></td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td> </td>';
|
||||
}
|
||||
if ($propal->brouillon && $user->rights->propale->creer && $propal->remise_percent)
|
||||
{
|
||||
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?propalid='.$propal->id.'&action=setremisepercent&rowid='.$objp->rowid.'">';
|
||||
print img_delete();
|
||||
print '</a></td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td> </td>';
|
||||
}
|
||||
print '<td> </td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td colspan="3"><input type="submit" class="button" value="'.$langs->trans("Save").'"></td>';
|
||||
}
|
||||
print '</tr>';
|
||||
print '</form>';
|
||||
|
||||
// Remise absolue
|
||||
$var=!$var;
|
||||
print '<form name="updateligne" action="'.$_SERVER["PHP_SELF"].'" method="post">';
|
||||
print '<input type="hidden" name="action" value="setremiseabsolue">';
|
||||
print '<input type="hidden" name="propalid" value="'.$propal->id.'">';
|
||||
print '<tr class="liste_total"><td>';
|
||||
print $langs->trans('CustomerAbsoluteDiscount');
|
||||
if ($propal->brouillon) print ' <font style="font-weight: normal">('.($avoir_en_cours?$langs->trans("CompanyHasAbsoluteDiscount",$avoir_en_cours,$langs->trans("Currency".$conf->monnaie)):$langs->trans("CompanyHasNoAbsoluteDiscount")).')</font>';
|
||||
print '</td>';
|
||||
print '<td> </td>';
|
||||
print '<td> </td>';
|
||||
print '<td> </td>';
|
||||
print '<td> </td>';
|
||||
print '<td align="right"><font style="font-weight: normal">';
|
||||
if ($_GET['action'] == 'editabsolutediscount')
|
||||
{
|
||||
print '-<input type="text" name="remise_absolue" size="2" value="'.$propal->remise_absolue.'">';
|
||||
}
|
||||
else
|
||||
{
|
||||
print $propal->remise_absolue?'-'.price($propal->remise_absolue):$langs->trans("DiscountNone");
|
||||
}
|
||||
print '</font></td>';
|
||||
if ($_GET['action'] != 'editabsolutediscount')
|
||||
{
|
||||
if ($propal->brouillon && $user->rights->propale->creer)
|
||||
{
|
||||
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editabsolutediscount&propalid='.$propal->id.'">'.img_edit($langs->trans('SetAbsoluteDiscount'),1).'</a></td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td> </td>';
|
||||
}
|
||||
if ($propal->brouillon && $user->rights->propale->creer && $propal->remise_absolue)
|
||||
{
|
||||
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?propalid='.$propal->id.'&action=setremiseabsolue&rowid='.$objp->rowid.'">';
|
||||
print img_delete();
|
||||
print '</a></td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td> </td>';
|
||||
}
|
||||
print '<td> </td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td colspan="3"><input type="submit" class="button" value="'.$langs->trans("Save").'"></td>';
|
||||
}
|
||||
print '</tr>';
|
||||
print '</form>';
|
||||
|
||||
print '</table>';
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user