Can split a discount into two lower discounts

This commit is contained in:
Laurent Destailleur
2009-08-07 00:49:43 +00:00
parent 51e13e1568
commit cdb05cf99b
17 changed files with 267 additions and 97 deletions

View File

@@ -346,7 +346,7 @@ else
foreach ($searchform as $key => $value)
{
$var=!$var;
print '<tr '.$bc[$var].'"><td width="35%">'.$searchformtitle[$key].'</td><td>' . ($searchformconst[$key]?$langs->trans("yes"):$langs->trans("no")).'</td>';
print '<tr '.$bc[$var].'"><td width="35%">'.$searchformtitle[$key].'</td><td>'.yn($searchformconst[$key]).'</td>';
print '<td align="left">'.$langs->trans("IfModuleEnabled",$langs->transnoentitiesnoconv($searchformmodule[$key]));
print '</td></tr>';
}
@@ -360,7 +360,7 @@ else
// Link to help center
$var=!$var;
print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("DisableLinkToHelpCenter").'</td><td>';
print yn($conf->global->MAIN_HELPCENTER_DISABLELINK);
print yn($conf->global->MAIN_HELPCENTER_DISABLELINK,1);
print '</td></tr>';
// Message login

View File

@@ -92,15 +92,6 @@ if ($_socid > 0)
dol_fiche_head($head, 'relativediscount', $langs->trans("ThirdParty"),0,'company');
/*
*
*
*/
print '<form method="POST" action="remise.php?id='.$objsoc->id.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="setremise">';
print '<table width="100%" border="0">';
print '<tr><td valign="top">';
print '<table class="border" width="100%">';
// Name
@@ -113,6 +104,17 @@ if ($_socid > 0)
print '<tr><td colspan="2" width="25%">';
print $langs->trans("CustomerRelativeDiscount").'</td><td colspan="2">'.$objsoc->remise_client."%</td></tr>";
print '</table>';
print '<br>';
print_fiche_titre($langs->trans("NewRelativeDiscount"),'','');
print '<form method="POST" action="remise.php?id='.$objsoc->id.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="setremise">';
print '<table class="border" width="100%">';
// Nouvelle valeur
print '<tr><td colspan="2">';
print $langs->trans("NewValue").'</td><td colspan="2"><input type="text" size="5" name="remise" value="'.$objsoc->remise_client.'">%</td></tr>';
@@ -124,8 +126,7 @@ if ($_socid > 0)
print '<tr><td colspan="4" align="center"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td></tr>';
print "</table>";
print "</td></tr>";
print '</table>';
print "</form>";
print "</div>\n";

View File

@@ -28,12 +28,13 @@
require_once("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php");
require_once(DOL_DOCUMENT_ROOT."/facture.class.php");
require_once(DOL_DOCUMENT_ROOT."/discount.class.php");
$langs->load("orders");
$langs->load("bills");
$langs->load("companies");
// S<EFBFBD>curit<EFBFBD> si un client essaye d'acc<63>der <20> une autre fiche que la sienne
// Security check
$_socid = $_GET["id"];
if ($user->societe_id > 0)
{
@@ -44,9 +45,88 @@ if ($user->societe_id > 0)
/*
* Actions
*/
if ($_REQUEST["action"] == 'confirm_split' && $_REQUEST["confirm"] == 'yes')
{
//if ($user->rights->societe->creer)
//if ($user->rights->facture->creer)
$error=0;
$remid=isset($_REQUEST["remid"])?$_REQUEST["remid"]:0;
$discount=new DiscountAbsolute($db);
$res=$discount->fetch($remid);
if (! $res > 0)
{
$error++;
$mesg='<div class="error">'.$langs->trans("ErrorFailedToLoadDiscount").'</div>';
}
if (! $error && price2num($_POST["amount_ttc_1"]+$_POST["amount_ttc_2"]) != $discount->amount_ttc)
{
$error++;
$mesg='<div class="error">'.$langs->trans("TotalOfTwoDiscountMustEqualsOriginal").'</div>';
}
if (! $error && $discount->fk_facture_line)
{
$error++;
$mesg='<div class="error">'.$langs->trans("ErrorCantSplitAUsedDiscount").'</div>';
}
if (! $error)
{
$newdiscount1=new DiscountAbsolute($db);
$newdiscount2=new DiscountAbsolute($db);
$newdiscount1->fk_facture_source=$discount->fk_facture_source;
$newdiscount2->fk_facture_source=$discount->fk_facture_source;
$newdiscount1->fk_facture=$discount->fk_facture;
$newdiscount2->fk_facture=$discount->fk_facture;
$newdiscount1->fk_facture_line=$discount->fk_facture_line;
$newdiscount2->fk_facture_line=$discount->fk_facture_line;
if ($discount->description == '(CREDIT_NOTE)')
{
$newdiscount1->description=$discount->description;
$newdiscount2->description=$discount->description;
}
else
{
$newdiscount1->description=$discount->description.' (1)';
$newdiscount2->description=$discount->description.' (2)';
}
$newdiscount1->fk_user=$discount->fk_user;
$newdiscount2->fk_user=$discount->fk_user;
$newdiscount1->fk_soc=$discount->fk_soc;
$newdiscount2->fk_soc=$discount->fk_soc;
$newdiscount1->datec=$discount->datec;
$newdiscount2->datec=$discount->datec;
$newdiscount1->tva_tx=$discount->tva_tx;
$newdiscount2->tva_tx=$discount->tva_tx;
$newdiscount1->amount_ttc=$_POST["amount_ttc_1"];
$newdiscount2->amount_ttc=price2num($discount->amount_ttc-$newdiscount1->amount_ttc);
$newdiscount1->amount_ht=price2num($newdiscount1->amount_ttc/(1+$newdiscount1->tva_tx/100),'MT');
$newdiscount2->amount_ht=price2num($newdiscount2->amount_ttc/(1+$newdiscount2->tva_tx/100),'MT');
$newdiscount1->amount_tva=price2num($newdiscount1->amount_ttc-$newdiscount2->amount_ht);
$newdiscount2->amount_tva=price2num($newdiscount2->amount_ttc-$newdiscount2->amount_ht);
$db->begin();
$discount->fk_facture_source=0; // This is to delete only the require record (that we will recreate with two records) and not all family with same fk_facture_source
$res=$discount->delete($user);
$newid1=$newdiscount1->create($user);
$newid2=$newdiscount2->create($user);
if ($res > 0 && $newid1 > 0 && $newid2 > 0)
{
$db->commit();
header("Location: ".$_SERVER["PHP_SELF"].'?id='.$_REQUEST['id']); // To avoid pb whith back
exit;
}
else
{
$db->rollback();
}
}
}
if ($_POST["action"] == 'setremise')
{
//if ($user->rights->societe->creer)
//if ($user->rights->facture->creer)
if (price2num($_POST["amount_ht"]) > 0)
{
$error=0;
@@ -80,22 +160,26 @@ if ($_POST["action"] == 'setremise')
}
}
if ($_GET["action"] == 'remove')
if ($_REQUEST["action"] == 'confirm_remove' && $_REQUEST["confirm"]=='yes')
{
//if ($user->rights->societe->creer)
//if ($user->rights->facture->creer)
$db->begin();
$soc = new Societe($db);
$soc->fetch($_GET["id"]);
$result=$soc->del_remise_except($_GET["remid"]);
$discount = new DiscountAbsolute($db);
$result=$discount->fetch($_REQUEST["remid"]);
$result=$discount->delete($user);
if ($result > 0)
{
$db->commit();
header("Location: ".$_SERVER["PHP_SELF"].'?id='.$_REQUEST['id']); // To avoid pb whith back
exit;
}
else
{
$mesg='<div class="error">'.$discount->error.'</div>';
$db->rollback();
$mesg='<div class="error">'.$soc->error.'</div>';
}
}
@@ -126,7 +210,7 @@ if ($_socid > 0)
dol_fiche_head($head, 'absolutediscount', $langs->trans("ThirdParty"),0,'company');
print '<form method="POST" action="remx.php?id='.$objsoc->id.'">';
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'?id='.$objsoc->id.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="setremise">';
@@ -162,11 +246,12 @@ if ($_socid > 0)
print '<tr><td>'.$langs->trans("CustomerAbsoluteDiscountMy").'</td>';
print '<td>'.$remise_user.'&nbsp;'.$langs->trans("Currency".$conf->monnaie).'</td></tr>';
print "</table>";
print '</table>';
print '<br>';
print_fiche_titre($langs->trans("NewGlobalDiscount"),'','');
print '<table class="border" width="100%">';
print '<tr><td width="38%">'.$langs->trans("NewGlobalDiscount").'</td>';
print '<tr><td width="38%">'.$langs->trans("AmountHT").'</td>';
print '<td><input type="text" size="5" name="amount_ht" value="'.$_POST["amount_ht"].'">&nbsp;'.$langs->trans("Currency".$conf->monnaie).'</td></tr>';
print '<tr><td width="38%">'.$langs->trans("VAT").'</td>';
print '<td>';
@@ -183,6 +268,10 @@ if ($_socid > 0)
print '<br>';
if ($_GET['action'] == 'remove')
{
$ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$objsoc->id.'&remid='.$_GET["remid"], $langs->trans('RemoveDiscount'), $langs->trans('ConfirmRemoveDiscount'), 'confirm_remove', '', 0, 1);
}
/*
* Liste remises fixes restant en cours (= liees a acune facture ni ligne de facture)
@@ -255,9 +344,33 @@ if ($_socid > 0)
print '<td align="center">';
print '<a href="'.DOL_URL_ROOT.'/user/fiche.php?id='.$obj->user_id.'">'.img_object($langs->trans("ShowUser"),'user').' '.$obj->login.'</a>';
print '</td>';
if ($obj->user_id == $user->id) print '<td><a href="'.$_SERVER["PHP_SELF"].'?id='.$objsoc->id.'&amp;action=remove&amp;remid='.$obj->rowid.'">'.img_delete($langs->trans("RemoveDiscount")).'</a></td>';
if ($user->rights->societe->creer || $user->rights->facture->creer)
{
print '<td nowrap="nowrap">';
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$objsoc->id.'&amp;action=split&amp;remid='.$obj->rowid.'">'.img_picto($langs->trans("SplitDiscount"),'split').'</a>';
print ' &nbsp; ';
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$objsoc->id.'&amp;action=remove&amp;remid='.$obj->rowid.'">'.img_delete($langs->trans("RemoveDiscount")).'</a>';
print '</td>';
}
else print '<td>&nbsp;</td>';
print '</tr>';
if ($_GET["action"]=='split' && $_GET['remid'] == $obj->rowid)
{
print "<tr $bc[$var]>";
print '<td colspan="8">';
$amount1=price2num($obj->amount_ttc/2,'MT');
$amount2=($obj->amount_ttc-$amount1);
$formquestion=array(
'text' => $langs->trans('TypeAmountOfEachNewDiscount'),
array('type' => 'text', 'name' => 'amount_ttc_1', 'label' => $langs->trans("AmountTTC").' 1', 'value' => $amount1, 'size' => '5'),
array('type' => 'text', 'name' => 'amount_ttc_2', 'label' => $langs->trans("AmountTTC").' 2', 'value' => $amount2, 'size' => '5')
);
$langs->load("dict");
$ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$objsoc->id.'&remid='.$obj->rowid, $langs->trans('SplitDiscount'), $langs->trans('ConfirmSplitDiscount',price($obj->amount_ttc),$langs->transnoentities("Currency".$conf->monnaie)), 'confirm_split', $formquestion, 0, 0);
print '</td>';
print '</tr>';
}
$i++;
}
$db->free($resql);

View File

@@ -428,8 +428,8 @@ if ($_REQUEST['action'] == 'confirm_converttoreduc' && $_REQUEST['confirm'] == '
// Insert one discount by VAT rate category
$discount = new DiscountAbsolute($db);
if ($fac->type == 2) $discount->desc='(CREDIT_NOTE)';
elseif ($fac->type == 3) $discount->desc='(DEPOSIT)';
if ($fac->type == 2) $discount->description='(CREDIT_NOTE)';
elseif ($fac->type == 3) $discount->description='(DEPOSIT)';
else {
$this->error="CantConvertToReducAnInvoiceOfThisType";
return -1;
@@ -2284,9 +2284,18 @@ else
print $langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->transnoentities("Currency".$conf->monnaie)).'. ';
}
else
{
if ($fac->statut < 1 || $fac->type == 2 || $fac->type == 3)
{
$text=$langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->transnoentities("Currency".$conf->monnaie));
print $html->textwithpicto($text,$langs->trans("AbsoluteDiscountUse"));
print '<br>'.$text.'.<br>';
}
else
{
$text=$langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->transnoentities("Currency".$conf->monnaie));
$text2=$langs->trans("AbsoluteDiscountUse");
print $html->textwithpicto($text,$text2);
}
}
}
else

View File

@@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
*
* 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
@@ -44,8 +44,8 @@ class DiscountAbsolute
var $datec; // Date creation
var $fk_facture_line; // Id invoice line when a discount linked to invoice line
var $fk_facture; // Id invoice when a discoutn linked to invoice
var $fk_facture_source; // Id facture avoir <EFBFBD> l'origine de la remise
var $ref_facture_source; // Ref facture avoir <EFBFBD> l'origine de la remise
var $fk_facture_source; // Id facture avoir a l'origine de la remise
var $ref_facture_source; // Ref facture avoir a l'origine de la remise
/**
* \brief Constructeur de la classe
@@ -58,10 +58,10 @@ class DiscountAbsolute
/**
* \brief Charge objet remise depuis la base
* \param rowid id du projet <20> charger
* \brief Load object from database into memory
* \param rowid id discount to load
* \param fk_facture_source fk_facture_source
* \return int <0 si ko, =0 si non trouv<75>, >0 si ok
* \return int <0 if KO, =0 if not found, >0 if OK
*/
function fetch($rowid,$fk_facture_source=0)
{
@@ -76,7 +76,7 @@ class DiscountAbsolute
$sql.= " sr.fk_user,";
$sql.= " sr.amount_ht, sr.amount_tva, sr.amount_ttc, sr.tva_tx,";
$sql.= " sr.fk_facture_line, sr.fk_facture, sr.fk_facture_source, sr.description,";
$sql.= " ".$this->db->pdate("sr.datec")." as datec,";
$sql.= " sr.datec,";
$sql.= " f.facnumber as ref_facture_source";
$sql.= " FROM ".MAIN_DB_PREFIX."societe_remise_except as sr";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON sr.fk_facture_source = f.rowid";
@@ -104,7 +104,7 @@ class DiscountAbsolute
$this->fk_facture_source = $obj->fk_facture_source; // Id avoir source
$this->ref_facture_source = $obj->ref_facture_source; // Ref avoir source
$this->description = $obj->description;
$this->datec = $obj->datec;
$this->datec = $this->db->jdate($obj->datec);
$this->db->free($resql);
return 1;
@@ -132,19 +132,27 @@ class DiscountAbsolute
{
global $conf, $langs;
// Nettoyage parametres
// Clean parameters
$this->amount_ht=price2num($this->amount_ht);
$this->amount_tva=price2num($this->amount_tva);
$this->amount_ttc=price2num($this->amount_ttc);
$this->tva_tx=price2num($this->tva_tx);
// Check parameters
if (empty($this->description))
{
$this->error='BadValueForPropertyDescription';
dol_syslog("DiscountAbsolute::create ".$this->error, LOG_ERR);
return -1;
}
// Insert request
$sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_remise_except";
$sql.= " (datec, fk_soc, fk_user, description,";
$sql.= " amount_ht, amount_tva, amount_ttc, tva_tx,";
$sql.= " fk_facture_source";
$sql.= ")";
$sql.= " VALUES (".$this->db->idate(mktime()).", ".$this->fk_soc.", ".$user->id.", '".addslashes($this->desc)."',";
$sql.= " VALUES (".$this->db->idate($this->datec!=''?$this->datec:dol_now('tzserver')).", ".$this->fk_soc.", ".$user->id.", '".addslashes($this->description)."',";
$sql.= " ".$this->amount_ht.", ".$this->amount_tva.", ".$this->amount_ttc.", ".$this->tva_tx.",";
$sql.= " ".($this->fk_facture_source?"'".$this->fk_facture_source."'":"null");
$sql.= ")";
@@ -166,23 +174,56 @@ class DiscountAbsolute
/*
* \brief Delete object in database
* \brief Delete object in database. If fk_facture_source is defined, we delete all familiy with same fk_facture_source. If not, only with id is removed.
* \param user Object of user asking to delete
* \return int <0 if KO, >0 if OK
*/
function delete()
function delete($user)
{
global $conf, $langs;
// Check if we can remove the discount
if ($this->fk_facture_source)
{
$sql.="SELECT COUNT(rowid) as nb";
$sql.=" FROM ".MAIN_DB_PREFIX."societe_remise_except";
$sql.=" WHERE (fk_facture_line IS NOT NULL"; // Not used as absolute simple discount
$sql.=" OR fk_facture IS NOT NULL)"; // Not used as credit note and not used as deposit
$sql.=" AND fk_facture_source = ".$this->fk_facture_source;
//$sql.=" AND rowid != ".$this->id;
dol_syslog("DiscountAbsolute::delete Check if we can remove discount sql=".$sql);
$resql=$this->db->query($sql);
if ($resql)
{
$obj = $this->db->fetch_object($resql);
if ($obj->nb > 0)
{
$this->error='ErrorThisPartOrAnotherIsAlreadyUsedSoDiscountSerieCantBeRemoved';
return -2;
}
}
else
{
dol_print_error($db);
return -1;
}
}
$this->db->begin();
// Delete but only if not used
$sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_remise_except ";
$sql.= " WHERE rowid = ".$this->id." AND (fk_facture_line IS NULL or fk_facture IS NULL)";
if ($this->fk_facture_source) $sql.= " WHERE fk_facture_source = ".$this->fk_facture_source; // Delete all lines of same serie
else $sql.= " WHERE rowid = ".$this->id; // Delete only line
$sql.= " AND (fk_facture_line IS NULL"; // Not used as absolute simple discount
$sql.= " AND fk_facture IS NULL)"; // Not used as credit note and not used as deposit
dol_syslog("DiscountAbsolute::delete Delete discount sql=".$sql);
$result=$this->db->query($sql);
if ($result)
{
// If source of discount was a credit not, we change credit note statut.
// If source of discount was a credit note or deposit, we change source statut.
if ($this->fk_facture_source)
{
$sql = "UPDATE ".MAIN_DB_PREFIX."facture";
@@ -288,7 +329,7 @@ class DiscountAbsolute
/**
* \brief Renvoie montant TTC des reductions/avoirs en cours disponibles
* \brief Renvoie montant TTC des reductions/avoirs en cours disponibles pour une société, un user ou autre
* \param company Object third party for filter
* \param user Filtre sur un user auteur des remises
* \param filter Filtre autre

View File

@@ -2623,13 +2623,13 @@ class Form
$resultyesno = '<select class="flat" name="'.$htmlname.'">'."\n";
if (("$value" == 'yes') || ($value == 1))
{
$resultyesno .= '<option value="'.$yes.'" selected="true">'.$langs->trans("yes").'</option>'."\n";
$resultyesno .= '<option value="'.$no.'">'.$langs->trans("no").'</option>'."\n";
$resultyesno .= '<option value="'.$yes.'" selected="true">'.$langs->trans("Yes").'</option>'."\n";
$resultyesno .= '<option value="'.$no.'">'.$langs->trans("No").'</option>'."\n";
}
else
{
$resultyesno .= '<option value="'.$yes.'">'.$langs->trans("yes").'</option>'."\n";
$resultyesno .= '<option value="'.$no.'" selected="true">'.$langs->trans("no").'</option>'."\n";
$resultyesno .= '<option value="'.$yes.'">'.$langs->trans("Yes").'</option>'."\n";
$resultyesno .= '<option value="'.$no.'" selected="true">'.$langs->trans("No").'</option>'."\n";
}
$resultyesno .= '</select>'."\n";
return $resultyesno;

View File

@@ -241,7 +241,8 @@ DiscountFromCreditNote=Discount from credit note %s
DiscountFromDeposit=Payments from deposit invoice %s
AbsoluteDiscountUse=This kind of credit can be used on invoice before its validation
CreditNoteDepositUse=Invoice must be validated to use this king of credits
NewGlobalDiscount=New discount
NewGlobalDiscount=New fix discount
NewRelativeDiscount=New relative discount
NoteReason=Note/Reason
ReasonDiscount=Reason
AddGlobalDiscount=Add discount
@@ -268,6 +269,11 @@ ConfirmCloneInvoice=Are you sure you want to clone this invoice <b>%s</b> ?
DisabledBecauseReplacedInvoice=Action disabled because invoice has been replaced
DescTaxAndDividendsArea=This area presents a summary of all payments made for tax or social contributions. Only records with payment during the fixed year are included here.
NbOfPayments=Nb of payments
SplitDiscount=Split discount in two
ConfirmSplitDiscount=Are you sure you want to split this discount of <b>%s</b> %s into 2 lower discounts ?
TypeAmountOfEachNewDiscount=Input amount for each of two parts :
TotalOfTwoDiscountMustEqualsOriginal=Total of two new discount must be equal to original discount amount.
ConfirmRemoveDiscount=Are you sure you want to remove this discount ?
# PaymentConditions
PaymentConditionShortRECEP=Immediate

View File

@@ -241,6 +241,7 @@ DiscountFromDeposit=Paiements issue de l'acompte %s
AbsoluteDiscountUse=Ce type de crédit ne peut s'utiliser que sur une facture non validée
CreditNoteDepositUse=La facture doit être validée pour pouvoir utiliser ce type de crédits
NewGlobalDiscount=Nouvelle remise fixe
NewRelativeDiscount=Nouvelle remise relative
NoteReason=Note/Motif
ReasonDiscount=Motif
AddGlobalDiscount=Ajouter remise fixe
@@ -268,6 +269,11 @@ ConfirmCloneInvoice=Etes-vous sur de vouloir cloner cette facture <b>%s</b> ?
DisabledBecauseReplacedInvoice=Action désactivée car facture remplacée
DescTaxAndDividendsArea=Cet écran résumé la liste de toutes les taxes et charges sociales sociales exigées pour une année donnée. La date prise en compte est la période d'exigibilité.
NbOfPayments=Nb de payements
SplitDiscount=Scinder réduction en deux
ConfirmSplitDiscount=Etes-vous sur de vouloir scinder la réduction de <b>%s</b> %s en 2 réductions plus petites ?
TypeAmountOfEachNewDiscount=Saisissez le montant de chacune des deux parts :
TotalOfTwoDiscountMustEqualsOriginal=La somme du montant des 2 nouvelles réductions doit être équivalent au montant de la réduction à scinder.
ConfirmRemoveDiscount=Etes-vous sur de vouloir supprimer cette réduction ?
# PaymentConditions
PaymentConditionShortRECEP=A réception

View File

@@ -2367,8 +2367,8 @@ function get_default_npr($societe_vendeuse, $societe_acheteuse, $taux_produit)
/**
* \brief Renvoie oui ou non dans la langue choisie
* \param yesno Variable pour test si oui ou non
* \brief Return yes or no in current language
* \param yesno Value to test (1, 'yes', 'true' or 0, 'no', 'false')
* \param case 1=Yes/No, 0=yes/no
* \param color 0=texte only, 1=Text is formated with a color font style ('ok' or 'error'), 2=Text is formated with 'ok' color.
*/

View File

@@ -1048,7 +1048,7 @@ class Societe extends CommonObject
}
/**
* \brief Ajoute une remise fixe pour la societe
* \brief Add a discount for third party
* \param remise Montant de la remise
* \param user Utilisateur qui accorde la remise
* \param desc Motif de l'avoir
@@ -1084,7 +1084,7 @@ class Societe extends CommonObject
$discount->amount_tva=price2num($remise*$tva_tx/100,'MT');
$discount->amount_ttc=price2num($discount->amount_ht+$discount->amount_tva,'MT');
$discount->tva_tx=price2num($tva_tx,'MT');
$discount->desc=$desc;
$discount->description=$desc;
$result=$discount->create($user);
if ($result > 0)
{
@@ -1099,26 +1099,6 @@ class Societe extends CommonObject
else return 0;
}
/**
* \brief Supprime un avoir (a condition que non affecte a une facture)
* \param id Id de l'avoir a supprimer
* \return int <0 si ko, id de l'avoir si ok
*/
function del_remise_except($id)
{
if ($this->id)
{
require_once(DOL_DOCUMENT_ROOT.'/discount.class.php');
$discount = new DiscountAbsolute($this->db);
$result=$discount->fetch($id);
$result=$discount->delete();
return $result;
}
else return 0;
}
/**
* \brief Renvoie montant TTC des reductions/avoirs en cours disponibles de la societe
* \param user Filtre sur un user auteur des remises

Binary file not shown.

After

Width:  |  Height:  |  Size: 236 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 236 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 236 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 236 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 236 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 236 B

View File

@@ -333,6 +333,30 @@ class Translate {
}
function getTradFromKey($key)
{
global $db;
$newstr=$key;
if (eregi('CurrencyShort([A-Z]+)$',$key,$reg))
{
global $db;
//$newstr=$this->getLabelFromKey($db,$reg[1],'c_currencies','code_iso','labelshort');
$newstr=$this->getLabelFromKey($db,$reg[1],'c_currencies','code_iso','code');
}
else if (eregi('Currency([A-Z]+)$',$key,$reg))
{
global $db;
$newstr=$this->getLabelFromKey($db,$reg[1],'c_currencies','code_iso','label');
}
else if (eregi('SendingMethod([0-9A-Z]+)$',$key,$reg))
{
global $db;
$newstr=$this->getLabelFromKey($db,$reg[1],'expedition_methode','code','libelle');
}
return $newstr;
}
/**
* \brief Retourne la version traduite du texte passe en parametre en la codant en HTML
* Si il n'y a pas de correspondance pour ce texte, on cherche dans fichier alternatif
@@ -372,23 +396,7 @@ class Translate {
}
else // Translation is not available
{
$newstr=$key;
if (eregi('CurrencyShort([A-Z]+)$',$key,$reg))
{
global $db;
//$newstr=$this->getLabelFromKey($db,$reg[1],'c_currencies','code_iso','labelshort');
$newstr=$this->getLabelFromKey($db,$reg[1],'c_currencies','code_iso','code');
}
else if (eregi('Currency([A-Z]+)$',$key,$reg))
{
global $db;
$newstr=$this->getLabelFromKey($db,$reg[1],'c_currencies','code_iso','label');
}
else if (eregi('SendingMethod([0-9A-Z]+)$',$key,$reg))
{
global $db;
$newstr=$this->getLabelFromKey($db,$reg[1],'expedition_methode','code','libelle');
}
$newstr=$this->getTradFromKey($key);
return $this->convToOutputCharset($newstr);
}
}
@@ -408,11 +416,14 @@ class Translate {
*/
function transnoentities($key, $param1='', $param2='', $param3='', $param4='')
{
$newstr=$key;
if ($this->getTransFromTab($newstr))
if ($this->getTransFromTab($key))
{
// Si la traduction est disponible
$newstr=sprintf($this->tab_translate[$newstr],$param1,$param2,$param3,$param4);
$newstr=sprintf($this->tab_translate[$key],$param1,$param2,$param3,$param4);
}
else
{
$newstr=$this->getTradFromKey($key);
}
return $this->convToOutputCharset($newstr);
}
@@ -433,11 +444,14 @@ class Translate {
*/
function transnoentitiesnoconv($key, $param1='', $param2='', $param3='', $param4='')
{
$newstr=$key;
if ($this->getTransFromTab($newstr))
if ($this->getTransFromTab($key))
{
// Si la traduction est disponible
$newstr=sprintf($this->tab_translate[$newstr],$param1,$param2,$param3,$param4);
$newstr=sprintf($this->tab_translate[$key],$param1,$param2,$param3,$param4);
}
else
{
$newstr=$this->getTradFromKey($key);
}
return $newstr;
}