NEW: supplier relative discounts
This commit is contained in:
parent
239e834913
commit
9cf45266f5
@ -56,7 +56,14 @@ if (GETPOST('action','aZ09') == 'setremise')
|
|||||||
{
|
{
|
||||||
$object = new Societe($db);
|
$object = new Societe($db);
|
||||||
$object->fetch($id);
|
$object->fetch($id);
|
||||||
|
|
||||||
|
$discount_type = GETPOST('discount_type', 'int');
|
||||||
|
|
||||||
|
if(! empty($discount_type)) {
|
||||||
|
$result=$object->set_remise_supplier(price2num(GETPOST("remise")),GETPOST("note"),$user);
|
||||||
|
} else {
|
||||||
$result=$object->set_remise_client(price2num(GETPOST("remise")),GETPOST("note"),$user);
|
$result=$object->set_remise_client(price2num(GETPOST("remise")),GETPOST("note"),$user);
|
||||||
|
}
|
||||||
|
|
||||||
if ($result > 0)
|
if ($result > 0)
|
||||||
{
|
{
|
||||||
@ -100,6 +107,11 @@ if ($socid > 0)
|
|||||||
|
|
||||||
$head = societe_prepare_head($object);
|
$head = societe_prepare_head($object);
|
||||||
|
|
||||||
|
$isCustomer = $object->client == 1 || $object->client == 3;
|
||||||
|
$isSupplier = $object->fournisseur == 1;
|
||||||
|
|
||||||
|
$displayCustomer = $conf->global->MAIN_FEATURES_LEVEL <= 0 || $isCustomer;
|
||||||
|
$displaySupplier = $conf->global->MAIN_FEATURES_LEVEL > 0 && $isSupplier;
|
||||||
|
|
||||||
|
|
||||||
print '<form method="POST" action="remise.php?id='.$object->id.'">';
|
print '<form method="POST" action="remise.php?id='.$object->id.'">';
|
||||||
@ -114,11 +126,33 @@ if ($socid > 0)
|
|||||||
print '<div class="fichecenter">';
|
print '<div class="fichecenter">';
|
||||||
|
|
||||||
print '<div class="underbanner clearboth"></div>';
|
print '<div class="underbanner clearboth"></div>';
|
||||||
|
|
||||||
|
if(! $displayCustomer && ! $displaySupplier) {
|
||||||
|
print '<p class="opacitymedium">'.$langs->trans('ThirdpartyIsNeitherCustomerNorClientSoCannotHaveDiscounts').'</p>';
|
||||||
|
|
||||||
|
dol_fiche_end();
|
||||||
|
|
||||||
|
print '</form>';
|
||||||
|
|
||||||
|
llxFooter();
|
||||||
|
$db->close();
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
print '<table class="border centpercent">';
|
print '<table class="border centpercent">';
|
||||||
|
|
||||||
// Discount
|
if($displayCustomer) {
|
||||||
|
// Customer discount
|
||||||
print '<tr><td class="titlefield">';
|
print '<tr><td class="titlefield">';
|
||||||
print $langs->trans("CustomerRelativeDiscount").'</td><td>'.price2num($object->remise_percent)."%</td></tr>";
|
print $langs->trans("CustomerRelativeDiscount").'</td><td>'.price2num($object->remise_percent)."%</td></tr>";
|
||||||
|
}
|
||||||
|
|
||||||
|
if($displaySupplier) {
|
||||||
|
// Supplier discount
|
||||||
|
print '<tr><td class="titlefield">';
|
||||||
|
print $langs->trans("SupplierRelativeDiscount").'</td><td>'.price2num($object->remise_supplier_percent)."%</td></tr>";
|
||||||
|
}
|
||||||
|
|
||||||
print '</table>';
|
print '</table>';
|
||||||
print '<br>';
|
print '<br>';
|
||||||
|
|
||||||
@ -126,8 +160,24 @@ if ($socid > 0)
|
|||||||
|
|
||||||
print '<div class="underbanner clearboth"></div>';
|
print '<div class="underbanner clearboth"></div>';
|
||||||
|
|
||||||
|
if($conf->global->MAIN_FEATURES_LEVEL <= 0 || ($isCustomer && ! $isSupplier)) {
|
||||||
|
print '<input type="hidden" name="discount_type" value="0" />';
|
||||||
|
}
|
||||||
|
|
||||||
|
if($conf->global->MAIN_FEATURES_LEVEL > 0 && (! $isCustomer && $isSupplier)) {
|
||||||
|
print '<input type="hidden" name="discount_type" value="1" />';
|
||||||
|
}
|
||||||
|
|
||||||
print '<table class="border centpercent">';
|
print '<table class="border centpercent">';
|
||||||
|
|
||||||
|
if($conf->global->MAIN_FEATURES_LEVEL > 0 && $isCustomer && $isSupplier) {
|
||||||
|
// Discount type
|
||||||
|
print '<tr><td class="titlefield fieldrequired">'.$langs->trans('DiscountType').'</td>';
|
||||||
|
print '<td><input type="radio" name="discount_type" id="discount_type_0" selected value="0"/> <label for="discount_type_0">'.$langs->trans('Customer').'</label>';
|
||||||
|
print ' <input type="radio" name="discount_type" id="discount_type_1" selected value="1"/> <label for="discount_type_1">'.$langs->trans('Supplier').'</label>';
|
||||||
|
print '</td></tr>';
|
||||||
|
}
|
||||||
|
|
||||||
// New value
|
// New value
|
||||||
print '<tr><td class="titlefield fieldrequired">';
|
print '<tr><td class="titlefield fieldrequired">';
|
||||||
print $langs->trans("NewValue").'</td><td><input type="text" size="5" name="remise" value="'.dol_escape_htmltag(GETPOST("remise")).'">%</td></tr>';
|
print $langs->trans("NewValue").'</td><td><input type="text" size="5" name="remise" value="'.dol_escape_htmltag(GETPOST("remise")).'">%</td></tr>';
|
||||||
@ -155,9 +205,15 @@ if ($socid > 0)
|
|||||||
|
|
||||||
print '<br>';
|
print '<br>';
|
||||||
|
|
||||||
|
if($displayCustomer) {
|
||||||
|
if($displaySupplier) {
|
||||||
|
print '<div class="fichecenter">';
|
||||||
|
print '<div class="fichehalfleft">';
|
||||||
|
print load_fiche_titre($langs->trans("CustomerDiscounts"), '', '');
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* List log of all percent discounts
|
* List log of all customer percent discounts
|
||||||
*/
|
*/
|
||||||
$sql = "SELECT rc.rowid, rc.remise_client as remise_percent, rc.note, rc.datec as dc,";
|
$sql = "SELECT rc.rowid, rc.remise_client as remise_percent, rc.note, rc.datec as dc,";
|
||||||
$sql.= " u.login, u.rowid as user_id";
|
$sql.= " u.login, u.rowid as user_id";
|
||||||
@ -205,7 +261,72 @@ if ($socid > 0)
|
|||||||
{
|
{
|
||||||
dol_print_error($db);
|
dol_print_error($db);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if($displaySupplier) {
|
||||||
|
if($displayCustomer) {
|
||||||
|
print '</div>'; // class="fichehalfleft"
|
||||||
|
print '<div class="fichehalfright">';
|
||||||
|
print '<div class="ficheaddleft">';
|
||||||
|
print load_fiche_titre($langs->trans("SupplierDiscounts"), '', '');
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* List log of all supplier percent discounts
|
||||||
|
*/
|
||||||
|
$sql = "SELECT rc.rowid, rc.remise_supplier as remise_percent, rc.note, rc.datec as dc,";
|
||||||
|
$sql.= " u.login, u.rowid as user_id";
|
||||||
|
$sql.= " FROM ".MAIN_DB_PREFIX."societe_remise_supplier as rc, ".MAIN_DB_PREFIX."user as u";
|
||||||
|
$sql.= " WHERE rc.fk_soc = " . $object->id;
|
||||||
|
$sql.= " AND rc.entity = " . $conf->entity;
|
||||||
|
$sql.= " AND u.rowid = rc.fk_user_author";
|
||||||
|
$sql.= " ORDER BY rc.datec DESC";
|
||||||
|
|
||||||
|
$resql=$db->query($sql);
|
||||||
|
if ($resql)
|
||||||
|
{
|
||||||
|
print '<table class="noborder" width="100%">';
|
||||||
|
$tag = !$tag;
|
||||||
|
print '<tr class="liste_titre">';
|
||||||
|
print '<td width="160">'.$langs->trans("Date").'</td>';
|
||||||
|
print '<td width="160" align="center">'.$langs->trans("CustomerRelativeDiscountShort").'</td>';
|
||||||
|
print '<td align="left">'.$langs->trans("NoteReason").'</td>';
|
||||||
|
print '<td align="center">'.$langs->trans("User").'</td>';
|
||||||
|
print '</tr>';
|
||||||
|
$num = $db->num_rows($resql);
|
||||||
|
if ($num > 0)
|
||||||
|
{
|
||||||
|
$i = 0;
|
||||||
|
while ($i < $num)
|
||||||
|
{
|
||||||
|
$obj = $db->fetch_object($resql);
|
||||||
|
print '<tr class="oddeven">';
|
||||||
|
print '<td>'.dol_print_date($db->jdate($obj->dc),"dayhour").'</td>';
|
||||||
|
print '<td align="center">'.price2num($obj->remise_percent).'%</td>';
|
||||||
|
print '<td align="left">'.$obj->note.'</td>';
|
||||||
|
print '<td align="center"><a href="'.DOL_URL_ROOT.'/user/card.php?id='.$obj->user_id.'">'.img_object($langs->trans("ShowUser"),'user').' '.$obj->login.'</a></td>';
|
||||||
|
print '</tr>';
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print '<tr><td colspan="8" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
|
||||||
|
}
|
||||||
|
$db->free($resql);
|
||||||
|
print "</table>";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dol_print_error($db);
|
||||||
|
}
|
||||||
|
|
||||||
|
if($displayCustomer) {
|
||||||
|
print '</div>'; // class="ficheaddleft"
|
||||||
|
print '</div>'; // class="fichehalfright"
|
||||||
|
print '</div>'; // class="fichecenter"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
llxFooter();
|
llxFooter();
|
||||||
|
|||||||
@ -322,8 +322,12 @@ else {
|
|||||||
print $form->selectUnits($line->fk_unit, "units");
|
print $form->selectUnits($line->fk_unit, "units");
|
||||||
print '</td>';
|
print '</td>';
|
||||||
}
|
}
|
||||||
|
$remise_percent = $buyer->remise_percent;
|
||||||
|
if($object->element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier') {
|
||||||
|
$remise_percent = $seller->remise_supplier_percent;
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
<td class="nobottom nowrap linecoldiscount" align="right"><input type="text" size="1" name="remise_percent" id="remise_percent" class="flat right" value="<?php echo (isset($_POST["remise_percent"])?GETPOST("remise_percent",'alpha',2):$buyer->remise_percent); ?>"><span class="hideonsmartphone">%</span></td>
|
<td class="nobottom nowrap linecoldiscount" align="right"><input type="text" size="1" name="remise_percent" id="remise_percent" class="flat right" value="<?php echo (isset($_POST["remise_percent"])?GETPOST("remise_percent",'alpha',2):$remise_percent); ?>"><span class="hideonsmartphone">%</span></td>
|
||||||
<?php
|
<?php
|
||||||
if ($this->situation_cycle_ref) {
|
if ($this->situation_cycle_ref) {
|
||||||
$coldisplay++;
|
$coldisplay++;
|
||||||
|
|||||||
@ -257,6 +257,19 @@ if ($object->id > 0)
|
|||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
if($conf->global->MAIN_FEATURES_LEVEL > 0) {
|
if($conf->global->MAIN_FEATURES_LEVEL > 0) {
|
||||||
|
// Relative discounts (Discounts-Drawbacks-Rebates)
|
||||||
|
print '<tr><td class="nowrap">';
|
||||||
|
print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
|
||||||
|
print $langs->trans("CustomerRelativeDiscountShort");
|
||||||
|
print '<td><td align="right">';
|
||||||
|
if ($user->rights->societe->creer && !$user->societe_id > 0)
|
||||||
|
{
|
||||||
|
print '<a href="'.DOL_URL_ROOT.'/comm/remise.php?id='.$object->id.'">'.img_edit($langs->trans("Modify")).'</a>';
|
||||||
|
}
|
||||||
|
print '</td></tr></table>';
|
||||||
|
print '</td><td>'.($object->remise_supplier_percent?'<a href="'.DOL_URL_ROOT.'/comm/remise.php?id='.$object->id.'">'.$object->remise_supplier_percent.'%</a>':'').'</td>';
|
||||||
|
print '</tr>';
|
||||||
|
|
||||||
// Absolute discounts (Discounts-Drawbacks-Rebates)
|
// Absolute discounts (Discounts-Drawbacks-Rebates)
|
||||||
print '<tr><td class="nowrap">';
|
print '<tr><td class="nowrap">';
|
||||||
print '<table width="100%" class="nobordernopadding">';
|
print '<table width="100%" class="nobordernopadding">';
|
||||||
|
|||||||
@ -1398,7 +1398,7 @@ if ($action=='create')
|
|||||||
$availability_id = (!empty($objectsrc->availability_id)?$objectsrc->availability_id:(!empty($soc->availability_id)?$soc->availability_id:0));
|
$availability_id = (!empty($objectsrc->availability_id)?$objectsrc->availability_id:(!empty($soc->availability_id)?$soc->availability_id:0));
|
||||||
$shipping_method_id = (! empty($objectsrc->shipping_method_id)?$objectsrc->shipping_method_id:(! empty($soc->shipping_method_id)?$soc->shipping_method_id:0));
|
$shipping_method_id = (! empty($objectsrc->shipping_method_id)?$objectsrc->shipping_method_id:(! empty($soc->shipping_method_id)?$soc->shipping_method_id:0));
|
||||||
$demand_reason_id = (!empty($objectsrc->demand_reason_id)?$objectsrc->demand_reason_id:(!empty($soc->demand_reason_id)?$soc->demand_reason_id:0));
|
$demand_reason_id = (!empty($objectsrc->demand_reason_id)?$objectsrc->demand_reason_id:(!empty($soc->demand_reason_id)?$soc->demand_reason_id:0));
|
||||||
$remise_percent = (!empty($objectsrc->remise_percent)?$objectsrc->remise_percent:(!empty($soc->remise_percent)?$soc->remise_percent:0));
|
$remise_percent = (!empty($objectsrc->remise_percent)?$objectsrc->remise_percent:(!empty($soc->remise_supplier_percent)?$soc->remise_supplier_percent:0));
|
||||||
$remise_absolue = (!empty($objectsrc->remise_absolue)?$objectsrc->remise_absolue:(!empty($soc->remise_absolue)?$soc->remise_absolue:0));
|
$remise_absolue = (!empty($objectsrc->remise_absolue)?$objectsrc->remise_absolue:(!empty($soc->remise_absolue)?$soc->remise_absolue:0));
|
||||||
$dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE)?-1:'';
|
$dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE)?-1:'';
|
||||||
|
|
||||||
@ -1436,7 +1436,7 @@ if ($action=='create')
|
|||||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||||
print '<input type="hidden" name="action" value="add">';
|
print '<input type="hidden" name="action" value="add">';
|
||||||
print '<input type="hidden" name="socid" value="' . $soc->id . '">' . "\n";
|
print '<input type="hidden" name="socid" value="' . $soc->id . '">' . "\n";
|
||||||
print '<input type="hidden" name="remise_percent" value="' . $soc->remise_percent . '">';
|
print '<input type="hidden" name="remise_percent" value="' . $soc->remise_supplier_percent . '">';
|
||||||
print '<input type="hidden" name="origin" value="' . $origin . '">';
|
print '<input type="hidden" name="origin" value="' . $origin . '">';
|
||||||
print '<input type="hidden" name="originid" value="' . $originid . '">';
|
print '<input type="hidden" name="originid" value="' . $originid . '">';
|
||||||
if (!empty($currency_tx)) print '<input type="hidden" name="originmulticurrency_tx" value="' . $currency_tx . '">';
|
if (!empty($currency_tx)) print '<input type="hidden" name="originmulticurrency_tx" value="' . $currency_tx . '">';
|
||||||
@ -1479,17 +1479,16 @@ if ($action=='create')
|
|||||||
|
|
||||||
if ($conf->global->MAIN_FEATURES_LEVEL > 0 && $societe->id > 0)
|
if ($conf->global->MAIN_FEATURES_LEVEL > 0 && $societe->id > 0)
|
||||||
{
|
{
|
||||||
/* // TODO handle supplier relative discount
|
|
||||||
// Discounts for third party
|
// Discounts for third party
|
||||||
print '<tr><td>' . $langs->trans('Discounts') . '</td><td>';
|
print '<tr><td>' . $langs->trans('Discounts') . '</td><td>';
|
||||||
if ($societe->remise_percent)
|
if ($societe->remise_supplier_percent)
|
||||||
print $langs->trans("CompanyHasRelativeDiscount", '<a href="' . DOL_URL_ROOT . '/comm/remise.php?id=' . $societe->id . '&backtopage=' . urlencode($_SERVER["PHP_SELF"] . '?socid=' . $societe->id . '&action=' . $action . '&origin=' . GETPOST('origin') . '&originid=' . GETPOST('originid')) . '">' . $societe->remise_percent . '</a>');
|
print $langs->trans("HasRelativeDiscountFromSupplier", '<a href="' . DOL_URL_ROOT . '/comm/remise.php?id=' . $societe->id . '&backtopage=' . urlencode($_SERVER["PHP_SELF"] . '?socid=' . $societe->id . '&action=' . $action . '&origin=' . GETPOST('origin') . '&originid=' . GETPOST('originid')) . '">' . $societe->remise_supplier_percent . '</a>');
|
||||||
else
|
else
|
||||||
print $langs->trans("CompanyHasNoRelativeDiscount");
|
print $langs->trans("HasNoRelativeDiscountFromSupplier");
|
||||||
print ' <a href="' . DOL_URL_ROOT . '/comm/remise.php?id=' . $societe->id . '&backtopage=' . urlencode($_SERVER["PHP_SELF"] . '?socid=' . $societe->id . '&action=' . $action . '&origin=' . GETPOST('origin') . '&originid=' . GETPOST('originid')) . '">(' . $langs->trans("EditRelativeDiscount") . ')</a>';
|
print ' <a href="' . DOL_URL_ROOT . '/comm/remise.php?id=' . $societe->id . '&backtopage=' . urlencode($_SERVER["PHP_SELF"] . '?socid=' . $societe->id . '&action=' . $action . '&origin=' . GETPOST('origin') . '&originid=' . GETPOST('originid')) . '">(' . $langs->trans("EditRelativeDiscount") . ')</a>';
|
||||||
print '. ';
|
print '. ';
|
||||||
print '<br>';
|
print '<br>';
|
||||||
*/
|
|
||||||
$absolute_discount = $societe->getAvailableDiscounts('', '', 0, 1);
|
$absolute_discount = $societe->getAvailableDiscounts('', '', 0, 1);
|
||||||
|
|
||||||
if ($absolute_discount)
|
if ($absolute_discount)
|
||||||
@ -1897,13 +1896,13 @@ elseif (! empty($object->id))
|
|||||||
$addcreditnote = '<a href="' . DOL_URL_ROOT . '/fourn/facture/card.php?action=create&socid=' . $societe->id . '&type=2&backtopage=' . urlencode($_SERVER["PHP_SELF"]) . '?facid=' . $object->id . '">' . $langs->trans("AddCreditNote") . '</a>';
|
$addcreditnote = '<a href="' . DOL_URL_ROOT . '/fourn/facture/card.php?action=create&socid=' . $societe->id . '&type=2&backtopage=' . urlencode($_SERVER["PHP_SELF"]) . '?facid=' . $object->id . '">' . $langs->trans("AddCreditNote") . '</a>';
|
||||||
|
|
||||||
print '<tr><td class="titlefield">' . $langs->trans('Discounts') . '</td><td>';
|
print '<tr><td class="titlefield">' . $langs->trans('Discounts') . '</td><td>';
|
||||||
/* // TODO handle supplier relative discount
|
|
||||||
if ($societe->remise_percent)
|
if ($societe->remise_supplier_percent)
|
||||||
print $langs->trans("CompanyHasRelativeDiscount", $societe->remise_percent);
|
print $langs->trans("HasRelativeDiscountFromSupplier", $societe->remise_supplier_percent);
|
||||||
else
|
else
|
||||||
print $langs->trans("CompanyHasNoRelativeDiscount");
|
print $langs->trans("HasNoRelativeDiscountFromSupplier");
|
||||||
print '. ';
|
print '. ';
|
||||||
*/
|
|
||||||
$absolute_discount = $societe->getAvailableDiscounts('', $filterabsolutediscount, 0, 1);
|
$absolute_discount = $societe->getAvailableDiscounts('', $filterabsolutediscount, 0, 1);
|
||||||
$absolute_creditnote = $societe->getAvailableDiscounts('', $filtercreditnote, 0, 1);
|
$absolute_creditnote = $societe->getAvailableDiscounts('', $filtercreditnote, 0, 1);
|
||||||
$absolute_discount = price2num($absolute_discount, 'MT');
|
$absolute_discount = price2num($absolute_discount, 'MT');
|
||||||
@ -1913,7 +1912,7 @@ elseif (! empty($object->id))
|
|||||||
print $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount), $langs->transnoentities("Currency" . $conf->currency));
|
print $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount), $langs->transnoentities("Currency" . $conf->currency));
|
||||||
} else {
|
} else {
|
||||||
// Remise dispo de type remise fixe (not credit note)
|
// Remise dispo de type remise fixe (not credit note)
|
||||||
// print '<br>';
|
print '<br>';
|
||||||
$form->form_remise_dispo($_SERVER["PHP_SELF"] . '?id=' . $object->id, 0, 'remise_id', $societe->id, $absolute_discount, $filterabsolutediscount, 0, '', 1, 1);
|
$form->form_remise_dispo($_SERVER["PHP_SELF"] . '?id=' . $object->id, 0, 'remise_id', $societe->id, $absolute_discount, $filterabsolutediscount, 0, '', 1, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1625,7 +1625,7 @@ if ($action == 'create')
|
|||||||
$cond_reglement_id = (!empty($objectsrc->cond_reglement_id)?$objectsrc->cond_reglement_id:(!empty($soc->cond_reglement_supplier_id)?$soc->cond_reglement_supplier_id:1));
|
$cond_reglement_id = (!empty($objectsrc->cond_reglement_id)?$objectsrc->cond_reglement_id:(!empty($soc->cond_reglement_supplier_id)?$soc->cond_reglement_supplier_id:1));
|
||||||
$mode_reglement_id = (!empty($objectsrc->mode_reglement_id)?$objectsrc->mode_reglement_id:(!empty($soc->mode_reglement_supplier_id)?$soc->mode_reglement_supplier_id:0));
|
$mode_reglement_id = (!empty($objectsrc->mode_reglement_id)?$objectsrc->mode_reglement_id:(!empty($soc->mode_reglement_supplier_id)?$soc->mode_reglement_supplier_id:0));
|
||||||
$fk_account = (! empty($objectsrc->fk_account)?$objectsrc->fk_account:(! empty($soc->fk_account)?$soc->fk_account:0));
|
$fk_account = (! empty($objectsrc->fk_account)?$objectsrc->fk_account:(! empty($soc->fk_account)?$soc->fk_account:0));
|
||||||
$remise_percent = (!empty($objectsrc->remise_percent)?$objectsrc->remise_percent:(!empty($soc->remise_percent)?$soc->remise_percent:0));
|
$remise_percent = (!empty($objectsrc->remise_percent)?$objectsrc->remise_percent:(!empty($soc->remise_supplier_percent)?$soc->remise_supplier_percent:0));
|
||||||
$remise_absolue = (!empty($objectsrc->remise_absolue)?$objectsrc->remise_absolue:(!empty($soc->remise_absolue)?$soc->remise_absolue:0));
|
$remise_absolue = (!empty($objectsrc->remise_absolue)?$objectsrc->remise_absolue:(!empty($soc->remise_absolue)?$soc->remise_absolue:0));
|
||||||
$dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE)?-1:'';
|
$dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE)?-1:'';
|
||||||
|
|
||||||
@ -1917,15 +1917,15 @@ if ($action == 'create')
|
|||||||
{
|
{
|
||||||
// Discounts for third party
|
// Discounts for third party
|
||||||
print '<tr><td>' . $langs->trans('Discounts') . '</td><td>';
|
print '<tr><td>' . $langs->trans('Discounts') . '</td><td>';
|
||||||
/* // TODO handle supplier relative discount
|
|
||||||
if ($societe->remise_percent)
|
if ($societe->remise_supplier_percent)
|
||||||
print $langs->trans("CompanyHasRelativeDiscount", '<a href="' . DOL_URL_ROOT . '/comm/remise.php?id=' . $societe->id . '&backtopage=' . urlencode($_SERVER["PHP_SELF"] . '?socid=' . $societe->id . '&action=' . $action . '&origin=' . GETPOST('origin') . '&originid=' . GETPOST('originid')) . '">' . $societe->remise_percent . '</a>');
|
print $langs->trans("HasRelativeDiscountFromSupplier", '<a href="' . DOL_URL_ROOT . '/comm/remise.php?id=' . $societe->id . '&backtopage=' . urlencode($_SERVER["PHP_SELF"] . '?socid=' . $societe->id . '&action=' . $action . '&origin=' . GETPOST('origin') . '&originid=' . GETPOST('originid')) . '">' . $societe->remise_supplier_percent . '</a>');
|
||||||
else
|
else
|
||||||
print $langs->trans("CompanyHasNoRelativeDiscount");
|
print $langs->trans("HasNoRelativeDiscountFromSupplier");
|
||||||
print ' <a href="' . DOL_URL_ROOT . '/comm/remise.php?id=' . $societe->id . '&backtopage=' . urlencode($_SERVER["PHP_SELF"] . '?socid=' . $societe->id . '&action=' . $action . '&origin=' . GETPOST('origin') . '&originid=' . GETPOST('originid')) . '">(' . $langs->trans("EditRelativeDiscount") . ')</a>';
|
print ' <a href="' . DOL_URL_ROOT . '/comm/remise.php?id=' . $societe->id . '&backtopage=' . urlencode($_SERVER["PHP_SELF"] . '?socid=' . $societe->id . '&action=' . $action . '&origin=' . GETPOST('origin') . '&originid=' . GETPOST('originid')) . '">(' . $langs->trans("EditRelativeDiscount") . ')</a>';
|
||||||
print '. ';
|
print '. ';
|
||||||
print '<br>';
|
print '<br>';
|
||||||
*/
|
|
||||||
if ($absolute_discount)
|
if ($absolute_discount)
|
||||||
print $langs->trans("CompanyHasAbsoluteDiscount", '<a href="' . DOL_URL_ROOT . '/comm/remx.php?id=' . $societe->id . '&backtopage=' . urlencode($_SERVER["PHP_SELF"] . '?socid=' . $societe->id . '&action=' . $action . '&origin=' . GETPOST('origin') . '&originid=' . GETPOST('originid')) . '">' . price($absolute_discount) . '</a>', $langs->trans("Currency" . $conf->currency));
|
print $langs->trans("CompanyHasAbsoluteDiscount", '<a href="' . DOL_URL_ROOT . '/comm/remx.php?id=' . $societe->id . '&backtopage=' . urlencode($_SERVER["PHP_SELF"] . '?socid=' . $societe->id . '&action=' . $action . '&origin=' . GETPOST('origin') . '&originid=' . GETPOST('originid')) . '">' . price($absolute_discount) . '</a>', $langs->trans("Currency" . $conf->currency));
|
||||||
else
|
else
|
||||||
@ -2428,17 +2428,17 @@ else
|
|||||||
|
|
||||||
print '<!-- Discounts --><tr><td>' . $langs->trans('Discounts');
|
print '<!-- Discounts --><tr><td>' . $langs->trans('Discounts');
|
||||||
print '</td><td>';
|
print '</td><td>';
|
||||||
/* // TODO handle supplier relative discount
|
|
||||||
if ($societe->remise_percent)
|
if ($societe->remise_supplier_percent)
|
||||||
print $langs->trans("CompanyHasRelativeDiscount", $societe->remise_percent);
|
print $langs->trans("HasRelativeDiscountFromSupplier", $societe->remise_supplier_percent);
|
||||||
else
|
else
|
||||||
print $langs->trans("CompanyHasNoRelativeDiscount");
|
print $langs->trans("HasNoRelativeDiscountFromSupplier");
|
||||||
print ' ('.$addrelativediscount.')';
|
// print ' ('.$addrelativediscount.')';
|
||||||
*/
|
|
||||||
|
|
||||||
// Is there is commercial discount or down payment available ?
|
// Is there is commercial discount or down payment available ?
|
||||||
if ($absolute_discount > 0) {
|
if ($absolute_discount > 0) {
|
||||||
// print '. ';
|
print '. ';
|
||||||
if ($object->statut > 0 || $object->type == FactureFournisseur::TYPE_CREDIT_NOTE || $object->type == FactureFournisseur::TYPE_DEPOSIT) {
|
if ($object->statut > 0 || $object->type == FactureFournisseur::TYPE_CREDIT_NOTE || $object->type == FactureFournisseur::TYPE_DEPOSIT) {
|
||||||
if ($object->statut == 0) {
|
if ($object->statut == 0) {
|
||||||
print $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount), $langs->transnoentities("Currency" . $conf->currency));
|
print $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount), $langs->transnoentities("Currency" . $conf->currency));
|
||||||
@ -2446,7 +2446,7 @@ else
|
|||||||
} else {
|
} else {
|
||||||
if ($object->statut < 1 || $object->type == FactureFournisseur::TYPE_CREDIT_NOTE || $object->type == FactureFournisseur::TYPE_DEPOSIT) {
|
if ($object->statut < 1 || $object->type == FactureFournisseur::TYPE_CREDIT_NOTE || $object->type == FactureFournisseur::TYPE_DEPOSIT) {
|
||||||
$text = $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount), $langs->transnoentities("Currency" . $conf->currency));
|
$text = $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount), $langs->transnoentities("Currency" . $conf->currency));
|
||||||
print '<!--<br>-->' . $text . '.<br>';
|
print '<br>' . $text . '.<br>';
|
||||||
} else {
|
} else {
|
||||||
$text = $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount), $langs->transnoentities("Currency" . $conf->currency));
|
$text = $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount), $langs->transnoentities("Currency" . $conf->currency));
|
||||||
$text2 = $langs->trans("AbsoluteDiscountUse");
|
$text2 = $langs->trans("AbsoluteDiscountUse");
|
||||||
@ -2455,7 +2455,7 @@ else
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Discount available of type fixed amount (not credit note)
|
// Discount available of type fixed amount (not credit note)
|
||||||
// print '<br>';
|
print '<br>';
|
||||||
$form->form_remise_dispo($_SERVER["PHP_SELF"] . '?facid=' . $object->id, GETPOST('discountid'), 'remise_id', $societe->id, $absolute_discount, $filterabsolutediscount, $resteapayer, ' (' . $addabsolutediscount . ')', 0, 1);
|
$form->form_remise_dispo($_SERVER["PHP_SELF"] . '?facid=' . $object->id, GETPOST('discountid'), 'remise_id', $societe->id, $absolute_discount, $filterabsolutediscount, $resteapayer, ' (' . $addabsolutediscount . ')', 0, 1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -2463,9 +2463,10 @@ else
|
|||||||
{
|
{
|
||||||
if ($object->statut == FactureFournisseur::STATUS_DRAFT && $object->type != FactureFournisseur::TYPE_CREDIT_NOTE && $object->type != FactureFournisseur::TYPE_DEPOSIT)
|
if ($object->statut == FactureFournisseur::STATUS_DRAFT && $object->type != FactureFournisseur::TYPE_CREDIT_NOTE && $object->type != FactureFournisseur::TYPE_DEPOSIT)
|
||||||
print ' (' . $addabsolutediscount . ')<br>';
|
print ' (' . $addabsolutediscount . ')<br>';
|
||||||
// else
|
else
|
||||||
// print '. ';
|
print '. ';
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
print '. ';
|
print '. ';
|
||||||
}
|
}
|
||||||
// Is there credit notes availables ?
|
// Is there credit notes availables ?
|
||||||
@ -2481,7 +2482,7 @@ else
|
|||||||
}
|
}
|
||||||
} else { // We can add a credit note on a down payment or standard invoice or situation invoice
|
} else { // We can add a credit note on a down payment or standard invoice or situation invoice
|
||||||
// There is credit notes discounts available
|
// There is credit notes discounts available
|
||||||
// if (! $absolute_discount) print '<br>';
|
if (! $absolute_discount) print '<br>';
|
||||||
// $form->form_remise_dispo($_SERVER["PHP_SELF"].'?facid='.$object->id, 0, 'remise_id_for_payment', $societe->id, $absolute_creditnote, $filtercreditnote, $resteapayer, '', 0, 1);
|
// $form->form_remise_dispo($_SERVER["PHP_SELF"].'?facid='.$object->id, 0, 'remise_id_for_payment', $societe->id, $absolute_creditnote, $filtercreditnote, $resteapayer, '', 0, 1);
|
||||||
$more=' ('.$addcreditnote. (($addcreditnote && $viewabsolutediscount) ? ' - ' : '') . $viewabsolutediscount . ')';
|
$more=' ('.$addcreditnote. (($addcreditnote && $viewabsolutediscount) ? ' - ' : '') . $viewabsolutediscount . ')';
|
||||||
$form->form_remise_dispo($_SERVER["PHP_SELF"] . '?facid=' . $object->id, 0, 'remise_id_for_payment', $societe->id, $absolute_creditnote, $filtercreditnote, 0, $more, 0, 1); // We allow credit note even if amount is higher
|
$form->form_remise_dispo($_SERVER["PHP_SELF"] . '?facid=' . $object->id, 0, 'remise_id_for_payment', $societe->id, $absolute_creditnote, $filtercreditnote, 0, $more, 0, 1); // We allow credit note even if amount is higher
|
||||||
|
|||||||
@ -36,3 +36,16 @@ ALTER TABLE llx_societe ADD COLUMN order_min_amount double(24,8) DEFAULT NULL AF
|
|||||||
ALTER TABLE llx_societe ADD COLUMN supplier_order_min_amount double(24,8) DEFAULT NULL AFTER order_min_amount;
|
ALTER TABLE llx_societe ADD COLUMN supplier_order_min_amount double(24,8) DEFAULT NULL AFTER order_min_amount;
|
||||||
|
|
||||||
ALTER TABLE llx_societe_remise_except ADD COLUMN discount_type integer DEFAULT 0 NOT NULL AFTER fk_soc;
|
ALTER TABLE llx_societe_remise_except ADD COLUMN discount_type integer DEFAULT 0 NOT NULL AFTER fk_soc;
|
||||||
|
ALTER TABLE llx_societe ADD COLUMN remise_supplier real DEFAULT 0 AFTER remise_client;
|
||||||
|
CREATE TABLE llx_societe_remise_supplier
|
||||||
|
(
|
||||||
|
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
entity integer DEFAULT 1 NOT NULL, -- multi company id
|
||||||
|
fk_soc integer NOT NULL,
|
||||||
|
tms timestamp,
|
||||||
|
datec datetime, -- creation date
|
||||||
|
fk_user_author integer, -- creation user
|
||||||
|
remise_supplier double(6,3) DEFAULT 0 NOT NULL, -- discount
|
||||||
|
note text
|
||||||
|
|
||||||
|
)ENGINE=innodb;
|
||||||
@ -78,6 +78,7 @@ create table llx_societe
|
|||||||
customer_rate real DEFAULT 0, -- taux fiabilite client (0 a 1)
|
customer_rate real DEFAULT 0, -- taux fiabilite client (0 a 1)
|
||||||
supplier_rate real DEFAULT 0, -- taux fiabilite fournisseur (0 a 1)
|
supplier_rate real DEFAULT 0, -- taux fiabilite fournisseur (0 a 1)
|
||||||
remise_client real DEFAULT 0, -- remise systematique pour le client
|
remise_client real DEFAULT 0, -- remise systematique pour le client
|
||||||
|
remise_supplier real DEFAULT 0, -- remise systematique auprès du fournisseur
|
||||||
mode_reglement tinyint, -- mode de reglement
|
mode_reglement tinyint, -- mode de reglement
|
||||||
cond_reglement tinyint, -- condition de reglement
|
cond_reglement tinyint, -- condition de reglement
|
||||||
mode_reglement_supplier tinyint, -- mode de reglement fournisseur
|
mode_reglement_supplier tinyint, -- mode de reglement fournisseur
|
||||||
|
|||||||
34
htdocs/install/mysql/tables/llx_societe_remise_supplier.sql
Normal file
34
htdocs/install/mysql/tables/llx_societe_remise_supplier.sql
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
-- ========================================================================
|
||||||
|
-- Copyright (C) 2000-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
|
-- Copyright (C) 2011-2016 Regis Houssin <regis.houssin@capnetworks.com>
|
||||||
|
--
|
||||||
|
-- This program is free software; you can redistribute it and/or modify
|
||||||
|
-- it under the terms of the GNU General Public License as published by
|
||||||
|
-- the Free Software Foundation; either version 3 of the License, or
|
||||||
|
-- (at your option) any later version.
|
||||||
|
--
|
||||||
|
-- This program is distributed in the hope that it will be useful,
|
||||||
|
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
-- GNU General Public License for more details.
|
||||||
|
--
|
||||||
|
-- You should have received a copy of the GNU General Public License
|
||||||
|
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
--
|
||||||
|
--
|
||||||
|
-- Historique evolution de la remise relative des tiers
|
||||||
|
-- ========================================================================
|
||||||
|
|
||||||
|
create table llx_societe_remise_supplier
|
||||||
|
(
|
||||||
|
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
entity integer DEFAULT 1 NOT NULL, -- multi company id
|
||||||
|
fk_soc integer NOT NULL,
|
||||||
|
tms timestamp,
|
||||||
|
datec datetime, -- creation date
|
||||||
|
fk_user_author integer, -- creation user
|
||||||
|
remise_supplier double(6,3) DEFAULT 0 NOT NULL, -- discount
|
||||||
|
note text
|
||||||
|
|
||||||
|
)ENGINE=innodb;
|
||||||
|
|
||||||
@ -268,6 +268,8 @@ CustomerRelativeDiscountShort=Relative discount
|
|||||||
CustomerAbsoluteDiscountShort=Absolute discount
|
CustomerAbsoluteDiscountShort=Absolute discount
|
||||||
CompanyHasRelativeDiscount=This customer has a default discount of <b>%s%%</b>
|
CompanyHasRelativeDiscount=This customer has a default discount of <b>%s%%</b>
|
||||||
CompanyHasNoRelativeDiscount=This customer has no relative discount by default
|
CompanyHasNoRelativeDiscount=This customer has no relative discount by default
|
||||||
|
HasRelativeDiscountFromSupplier=You have a default discount of <b>%s%%</b> from this supplier
|
||||||
|
HasNoRelativeDiscountFromSupplier=You have no default relative discount from this supplier
|
||||||
CompanyHasAbsoluteDiscount=This customer has discount available (credits notes or down payments) for <b>%s</b> %s
|
CompanyHasAbsoluteDiscount=This customer has discount available (credits notes or down payments) for <b>%s</b> %s
|
||||||
CompanyHasDownPaymentOrCommercialDiscount=This customer has discount available (commercial, down payments) for <b>%s</b> %s
|
CompanyHasDownPaymentOrCommercialDiscount=This customer has discount available (commercial, down payments) for <b>%s</b> %s
|
||||||
CompanyHasCreditNote=This customer still has credit notes for <b>%s</b> %s
|
CompanyHasCreditNote=This customer still has credit notes for <b>%s</b> %s
|
||||||
|
|||||||
@ -149,7 +149,7 @@ if (empty($reshook))
|
|||||||
$listofproperties=array(
|
$listofproperties=array(
|
||||||
'address', 'zip', 'town', 'state_id', 'country_id', 'phone', 'phone_pro', 'fax', 'email', 'skype', 'url', 'barcode',
|
'address', 'zip', 'town', 'state_id', 'country_id', 'phone', 'phone_pro', 'fax', 'email', 'skype', 'url', 'barcode',
|
||||||
'idprof1', 'idprof2', 'idprof3', 'idprof4', 'idprof5', 'idprof6',
|
'idprof1', 'idprof2', 'idprof3', 'idprof4', 'idprof5', 'idprof6',
|
||||||
'tva_intra', 'effectif_id', 'forme_juridique', 'remise_percent', 'mode_reglement_supplier_id', 'cond_reglement_supplier_id', 'name_bis',
|
'tva_intra', 'effectif_id', 'forme_juridique', 'remise_percent', 'remise_supplier_percent', 'mode_reglement_supplier_id', 'cond_reglement_supplier_id', 'name_bis',
|
||||||
'stcomm_id', 'outstanding_limit', 'price_level', 'parent', 'default_lang', 'ref', 'ref_ext', 'import_key', 'fk_incoterms', 'fk_multicurrency',
|
'stcomm_id', 'outstanding_limit', 'price_level', 'parent', 'default_lang', 'ref', 'ref_ext', 'import_key', 'fk_incoterms', 'fk_multicurrency',
|
||||||
'code_client', 'code_fournisseur', 'code_compta', 'code_compta_fournisseur',
|
'code_client', 'code_fournisseur', 'code_compta', 'code_compta_fournisseur',
|
||||||
'model_pdf', 'fk_projet'
|
'model_pdf', 'fk_projet'
|
||||||
|
|||||||
@ -314,7 +314,7 @@ class Thirdparties extends DolibarrApi
|
|||||||
$listofproperties=array(
|
$listofproperties=array(
|
||||||
'address', 'zip', 'town', 'state_id', 'country_id', 'phone', 'phone_pro', 'fax', 'email', 'skype', 'url', 'barcode',
|
'address', 'zip', 'town', 'state_id', 'country_id', 'phone', 'phone_pro', 'fax', 'email', 'skype', 'url', 'barcode',
|
||||||
'idprof1', 'idprof2', 'idprof3', 'idprof4', 'idprof5', 'idprof6',
|
'idprof1', 'idprof2', 'idprof3', 'idprof4', 'idprof5', 'idprof6',
|
||||||
'tva_intra', 'effectif_id', 'forme_juridique', 'remise_percent', 'mode_reglement_supplier_id', 'cond_reglement_supplier_id', 'name_bis',
|
'tva_intra', 'effectif_id', 'forme_juridique', 'remise_percent', 'remise_supplier_percent', 'mode_reglement_supplier_id', 'cond_reglement_supplier_id', 'name_bis',
|
||||||
'stcomm_id', 'outstanding_limit', 'price_level', 'parent', 'default_lang', 'ref', 'ref_ext', 'import_key', 'fk_incoterms', 'fk_multicurrency',
|
'stcomm_id', 'outstanding_limit', 'price_level', 'parent', 'default_lang', 'ref', 'ref_ext', 'import_key', 'fk_incoterms', 'fk_multicurrency',
|
||||||
'code_client', 'code_fournisseur', 'code_compta', 'code_compta_fournisseur',
|
'code_client', 'code_fournisseur', 'code_compta', 'code_compta_fournisseur',
|
||||||
'model_pdf', 'fk_projet'
|
'model_pdf', 'fk_projet'
|
||||||
|
|||||||
@ -234,6 +234,7 @@ class Societe extends CommonObject
|
|||||||
var $forme_juridique;
|
var $forme_juridique;
|
||||||
|
|
||||||
var $remise_percent;
|
var $remise_percent;
|
||||||
|
var $remise_supplier_percent;
|
||||||
var $mode_reglement_supplier_id;
|
var $mode_reglement_supplier_id;
|
||||||
var $cond_reglement_supplier_id;
|
var $cond_reglement_supplier_id;
|
||||||
var $fk_prospectlevel;
|
var $fk_prospectlevel;
|
||||||
@ -1143,7 +1144,7 @@ class Societe extends CommonObject
|
|||||||
$sql .= ', s.fk_forme_juridique as forme_juridique_code';
|
$sql .= ', s.fk_forme_juridique as forme_juridique_code';
|
||||||
$sql .= ', s.webservices_url, s.webservices_key';
|
$sql .= ', s.webservices_url, s.webservices_key';
|
||||||
$sql .= ', s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur, s.parent, s.barcode';
|
$sql .= ', s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur, s.parent, s.barcode';
|
||||||
$sql .= ', s.fk_departement, s.fk_pays as country_id, s.fk_stcomm, s.remise_client, s.mode_reglement, s.cond_reglement, s.fk_account, s.tva_assuj';
|
$sql .= ', s.fk_departement, s.fk_pays as country_id, s.fk_stcomm, s.remise_client, s.remise_supplier, s.mode_reglement, s.cond_reglement, s.fk_account, s.tva_assuj';
|
||||||
$sql .= ', s.mode_reglement_supplier, s.cond_reglement_supplier, s.localtax1_assuj, s.localtax1_value, s.localtax2_assuj, s.localtax2_value, s.fk_prospectlevel, s.default_lang, s.logo';
|
$sql .= ', s.mode_reglement_supplier, s.cond_reglement_supplier, s.localtax1_assuj, s.localtax1_value, s.localtax2_assuj, s.localtax2_value, s.fk_prospectlevel, s.default_lang, s.logo';
|
||||||
$sql .= ', s.fk_shipping_method';
|
$sql .= ', s.fk_shipping_method';
|
||||||
$sql .= ', s.outstanding_limit, s.import_key, s.canvas, s.fk_incoterms, s.location_incoterms';
|
$sql .= ', s.outstanding_limit, s.import_key, s.canvas, s.fk_incoterms, s.location_incoterms';
|
||||||
@ -1275,6 +1276,7 @@ class Societe extends CommonObject
|
|||||||
$this->prefix_comm = $obj->prefix_comm;
|
$this->prefix_comm = $obj->prefix_comm;
|
||||||
|
|
||||||
$this->remise_percent = $obj->remise_client;
|
$this->remise_percent = $obj->remise_client;
|
||||||
|
$this->remise_supplier_percent = $obj->remise_supplier;
|
||||||
$this->mode_reglement_id = $obj->mode_reglement;
|
$this->mode_reglement_id = $obj->mode_reglement;
|
||||||
$this->cond_reglement_id = $obj->cond_reglement;
|
$this->cond_reglement_id = $obj->cond_reglement;
|
||||||
$this->mode_reglement_supplier_id = $obj->mode_reglement_supplier;
|
$this->mode_reglement_supplier_id = $obj->mode_reglement_supplier;
|
||||||
@ -1658,6 +1660,67 @@ class Societe extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Definit la societe comme un client
|
||||||
|
*
|
||||||
|
* @param float $remise Valeur en % de la remise
|
||||||
|
* @param string $note Note/Motif de modification de la remise
|
||||||
|
* @param User $user Utilisateur qui definie la remise
|
||||||
|
* @return int <0 if KO, >0 if OK
|
||||||
|
*/
|
||||||
|
function set_remise_supplier($remise, $note, User $user)
|
||||||
|
{
|
||||||
|
global $conf, $langs;
|
||||||
|
|
||||||
|
// Nettoyage parametres
|
||||||
|
$note=trim($note);
|
||||||
|
if (! $note)
|
||||||
|
{
|
||||||
|
$this->error=$langs->trans("ErrorFieldRequired",$langs->trans("NoteReason"));
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
|
||||||
|
dol_syslog(get_class($this)."::set_remise_supplier ".$remise.", ".$note.", ".$user->id);
|
||||||
|
|
||||||
|
if ($this->id)
|
||||||
|
{
|
||||||
|
$this->db->begin();
|
||||||
|
|
||||||
|
$now=dol_now();
|
||||||
|
|
||||||
|
// Positionne remise courante
|
||||||
|
$sql = "UPDATE ".MAIN_DB_PREFIX."societe ";
|
||||||
|
$sql.= " SET remise_supplier = '".$this->db->escape($remise)."'";
|
||||||
|
$sql.= " WHERE rowid = " . $this->id;
|
||||||
|
$resql=$this->db->query($sql);
|
||||||
|
if (! $resql)
|
||||||
|
{
|
||||||
|
$this->db->rollback();
|
||||||
|
$this->error=$this->db->error();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ecrit trace dans historique des remises
|
||||||
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_remise_supplier";
|
||||||
|
$sql.= " (entity, datec, fk_soc, remise_supplier, note, fk_user_author)";
|
||||||
|
$sql.= " VALUES (".$conf->entity.", '".$this->db->idate($now)."', ".$this->id.", '".$this->db->escape($remise)."',";
|
||||||
|
$sql.= " '".$this->db->escape($note)."',";
|
||||||
|
$sql.= " ".$user->id;
|
||||||
|
$sql.= ")";
|
||||||
|
|
||||||
|
$resql=$this->db->query($sql);
|
||||||
|
if (! $resql)
|
||||||
|
{
|
||||||
|
$this->db->rollback();
|
||||||
|
$this->error=$this->db->lasterror();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->db->commit();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a discount for third party
|
* Add a discount for third party
|
||||||
*
|
*
|
||||||
|
|||||||
@ -995,7 +995,7 @@ if ($action == 'create')
|
|||||||
|
|
||||||
$cond_reglement_id = (! empty($objectsrc->cond_reglement_id)?$objectsrc->cond_reglement_id:(! empty($soc->cond_reglement_id)?$soc->cond_reglement_id:1));
|
$cond_reglement_id = (! empty($objectsrc->cond_reglement_id)?$objectsrc->cond_reglement_id:(! empty($soc->cond_reglement_id)?$soc->cond_reglement_id:1));
|
||||||
$mode_reglement_id = (! empty($objectsrc->mode_reglement_id)?$objectsrc->mode_reglement_id:(! empty($soc->mode_reglement_id)?$soc->mode_reglement_id:0));
|
$mode_reglement_id = (! empty($objectsrc->mode_reglement_id)?$objectsrc->mode_reglement_id:(! empty($soc->mode_reglement_id)?$soc->mode_reglement_id:0));
|
||||||
$remise_percent = (! empty($objectsrc->remise_percent)?$objectsrc->remise_percent:(! empty($soc->remise_percent)?$soc->remise_percent:0));
|
$remise_percent = (! empty($objectsrc->remise_percent)?$objectsrc->remise_percent:(! empty($soc->remise_supplier_percent)?$soc->remise_supplier_percent:0));
|
||||||
$remise_absolue = (! empty($objectsrc->remise_absolue)?$objectsrc->remise_absolue:(! empty($soc->remise_absolue)?$soc->remise_absolue:0));
|
$remise_absolue = (! empty($objectsrc->remise_absolue)?$objectsrc->remise_absolue:(! empty($soc->remise_absolue)?$soc->remise_absolue:0));
|
||||||
|
|
||||||
// Replicate extrafields
|
// Replicate extrafields
|
||||||
@ -1052,15 +1052,15 @@ if ($action == 'create')
|
|||||||
{
|
{
|
||||||
// Discounts for third party
|
// Discounts for third party
|
||||||
print '<tr><td>' . $langs->trans('Discounts') . '</td><td>';
|
print '<tr><td>' . $langs->trans('Discounts') . '</td><td>';
|
||||||
/* // TODO handle supplier relative discount
|
|
||||||
if ($soc->remise_percent)
|
if ($soc->remise_supplier_percent)
|
||||||
print $langs->trans("CompanyHasRelativeDiscount", '<a href="' . DOL_URL_ROOT . '/comm/remise.php?id=' . $soc->id . '&backtopage=' . urlencode($_SERVER["PHP_SELF"] . '?socid=' . $soc->id . '&action=' . $action . '&origin=' . GETPOST('origin') . '&originid=' . GETPOST('originid')) . '">' . $soc->remise_percent . '</a>');
|
print $langs->trans("HasRelativeDiscountFromSupplier", '<a href="' . DOL_URL_ROOT . '/comm/remise.php?id=' . $soc->id . '&backtopage=' . urlencode($_SERVER["PHP_SELF"] . '?socid=' . $soc->id . '&action=' . $action . '&origin=' . GETPOST('origin') . '&originid=' . GETPOST('originid')) . '">' . $soc->remise_supplier_percent . '</a>');
|
||||||
else
|
else
|
||||||
print $langs->trans("CompanyHasNoRelativeDiscount");
|
print $langs->trans("HasNoRelativeDiscountFromSupplier");
|
||||||
print ' <a href="' . DOL_URL_ROOT . '/comm/remise.php?id=' . $soc->id . '&backtopage=' . urlencode($_SERVER["PHP_SELF"] . '?socid=' . $soc->id . '&action=' . $action . '&origin=' . GETPOST('origin') . '&originid=' . GETPOST('originid')) . '">(' . $langs->trans("EditRelativeDiscount") . ')</a>';
|
print ' <a href="' . DOL_URL_ROOT . '/comm/remise.php?id=' . $soc->id . '&backtopage=' . urlencode($_SERVER["PHP_SELF"] . '?socid=' . $soc->id . '&action=' . $action . '&origin=' . GETPOST('origin') . '&originid=' . GETPOST('originid')) . '">(' . $langs->trans("EditRelativeDiscount") . ')</a>';
|
||||||
print '. ';
|
print '. ';
|
||||||
print '<br>';
|
print '<br>';
|
||||||
*/
|
|
||||||
$absolute_discount = $soc->getAvailableDiscounts('', '', 0, 1);
|
$absolute_discount = $soc->getAvailableDiscounts('', '', 0, 1);
|
||||||
|
|
||||||
if ($absolute_discount)
|
if ($absolute_discount)
|
||||||
@ -1427,13 +1427,13 @@ if ($action == 'create')
|
|||||||
$addcreditnote = '<a href="' . DOL_URL_ROOT . '/fourn/facture/card.php?action=create&socid=' . $soc->id . '&type=2&backtopage=' . urlencode($_SERVER["PHP_SELF"]) . '?facid=' . $object->id . '">' . $langs->trans("AddCreditNote") . '</a>';
|
$addcreditnote = '<a href="' . DOL_URL_ROOT . '/fourn/facture/card.php?action=create&socid=' . $soc->id . '&type=2&backtopage=' . urlencode($_SERVER["PHP_SELF"]) . '?facid=' . $object->id . '">' . $langs->trans("AddCreditNote") . '</a>';
|
||||||
|
|
||||||
print '<tr><td class="titlefield">' . $langs->trans('Discounts') . '</td><td>';
|
print '<tr><td class="titlefield">' . $langs->trans('Discounts') . '</td><td>';
|
||||||
/* // TODO handle supplier relative discount
|
|
||||||
if ($soc->remise_percent)
|
if ($soc->remise_supplier_percent)
|
||||||
print $langs->trans("CompanyHasRelativeDiscount", $soc->remise_percent);
|
print $langs->trans("HasRelativeDiscountFromSupplier", $soc->remise_supplier_percent);
|
||||||
else
|
else
|
||||||
print $langs->trans("CompanyHasNoRelativeDiscount");
|
print $langs->trans("HasNoRelativeDiscountFromSupplier");
|
||||||
print '. ';
|
print '. ';
|
||||||
*/
|
|
||||||
$absolute_discount = $soc->getAvailableDiscounts('', $filterabsolutediscount, 0, 1);
|
$absolute_discount = $soc->getAvailableDiscounts('', $filterabsolutediscount, 0, 1);
|
||||||
$absolute_creditnote = $soc->getAvailableDiscounts('', $filtercreditnote, 0, 1);
|
$absolute_creditnote = $soc->getAvailableDiscounts('', $filtercreditnote, 0, 1);
|
||||||
$absolute_discount = price2num($absolute_discount, 'MT');
|
$absolute_discount = price2num($absolute_discount, 'MT');
|
||||||
@ -1443,7 +1443,7 @@ if ($action == 'create')
|
|||||||
print $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount), $langs->transnoentities("Currency" . $conf->currency));
|
print $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount), $langs->transnoentities("Currency" . $conf->currency));
|
||||||
} else {
|
} else {
|
||||||
// Remise dispo de type remise fixe (not credit note)
|
// Remise dispo de type remise fixe (not credit note)
|
||||||
// print '<br>';
|
print '<br>';
|
||||||
$form->form_remise_dispo($_SERVER["PHP_SELF"] . '?id=' . $object->id, 0, 'remise_id', $soc->id, $absolute_discount, $filterabsolutediscount, 0, '', 1, 1);
|
$form->form_remise_dispo($_SERVER["PHP_SELF"] . '?id=' . $object->id, 0, 'remise_id', $soc->id, $absolute_discount, $filterabsolutediscount, 0, '', 1, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user