diff --git a/htdocs/admin/ihm.php b/htdocs/admin/ihm.php index b08dde639f3..9e633ec60d7 100644 --- a/htdocs/admin/ihm.php +++ b/htdocs/admin/ihm.php @@ -346,7 +346,7 @@ else foreach ($searchform as $key => $value) { $var=!$var; - print ''.$searchformtitle[$key].'' . ($searchformconst[$key]?$langs->trans("yes"):$langs->trans("no")).''; + print ''.$searchformtitle[$key].''.yn($searchformconst[$key]).''; print ''.$langs->trans("IfModuleEnabled",$langs->transnoentitiesnoconv($searchformmodule[$key])); print ''; } @@ -360,7 +360,7 @@ else // Link to help center $var=!$var; print ''.$langs->trans("DisableLinkToHelpCenter").''; - print yn($conf->global->MAIN_HELPCENTER_DISABLELINK); + print yn($conf->global->MAIN_HELPCENTER_DISABLELINK,1); print ''; // Message login diff --git a/htdocs/comm/remise.php b/htdocs/comm/remise.php index 46c602d5641..31833b711e5 100644 --- a/htdocs/comm/remise.php +++ b/htdocs/comm/remise.php @@ -92,15 +92,6 @@ if ($_socid > 0) dol_fiche_head($head, 'relativediscount', $langs->trans("ThirdParty"),0,'company'); - /* - * - * - */ - print '
'; - print ''; - print ''; - print ''; - print '"; - print '
'; print ''; // Name @@ -113,6 +104,17 @@ if ($_socid > 0) print '"; + print '
'; print $langs->trans("CustomerRelativeDiscount").''.$objsoc->remise_client."%
'; + print '
'; + + print_fiche_titre($langs->trans("NewRelativeDiscount"),'',''); + + print ''; + print ''; + print ''; + + print ''; + // Nouvelle valeur print ''; @@ -124,8 +126,7 @@ if ($_socid > 0) print ''; print "
'; print $langs->trans("NewValue").'%
"; - print "
'; + print "
"; print "\n"; diff --git a/htdocs/comm/remx.php b/htdocs/comm/remx.php index 56c7079960e..2d29eee1638 100644 --- a/htdocs/comm/remx.php +++ b/htdocs/comm/remx.php @@ -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�curit� si un client essaye d'acc�der � 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='
'.$langs->trans("ErrorFailedToLoadDiscount").'
'; + } + if (! $error && price2num($_POST["amount_ttc_1"]+$_POST["amount_ttc_2"]) != $discount->amount_ttc) + { + $error++; + $mesg='
'.$langs->trans("TotalOfTwoDiscountMustEqualsOriginal").'
'; + } + if (! $error && $discount->fk_facture_line) + { + $error++; + $mesg='
'.$langs->trans("ErrorCantSplitAUsedDiscount").'
'; + } + 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='
'.$discount->error.'
'; $db->rollback(); - $mesg='
'.$soc->error.'
'; } } @@ -126,7 +210,7 @@ if ($_socid > 0) dol_fiche_head($head, 'absolutediscount', $langs->trans("ThirdParty"),0,'company'); - print '
'; + print ''; print ''; print ''; @@ -162,11 +246,12 @@ if ($_socid > 0) print ''.$langs->trans("CustomerAbsoluteDiscountMy").''; print ''.$remise_user.' '.$langs->trans("Currency".$conf->monnaie).''; - print ""; + print ''; print '
'; + print_fiche_titre($langs->trans("NewGlobalDiscount"),'',''); print ''; - print ''; + print ''; print ''; print ''; print ''; - if ($obj->user_id == $user->id) print ''; + if ($user->rights->societe->creer || $user->rights->facture->creer) + { + print ''; + } else print ''; print ''; + + if ($_GET["action"]=='split' && $_GET['remid'] == $obj->rowid) + { + print ""; + print ''; + print ''; + } $i++; } $db->free($resql); diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 010d8aad094..f68a4c13bd4 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -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; @@ -2285,8 +2285,17 @@ else } else { - $text=$langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->transnoentities("Currency".$conf->monnaie)); - print $html->textwithpicto($text,$langs->trans("AbsoluteDiscountUse")); + if ($fac->statut < 1 || $fac->type == 2 || $fac->type == 3) + { + $text=$langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->transnoentities("Currency".$conf->monnaie)); + print '
'.$text.'.
'; + } + else + { + $text=$langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->transnoentities("Currency".$conf->monnaie)); + $text2=$langs->trans("AbsoluteDiscountUse"); + print $html->textwithpicto($text,$text2); + } } } else diff --git a/htdocs/discount.class.php b/htdocs/discount.class.php index d01fdfd4dff..d606fb08024 100644 --- a/htdocs/discount.class.php +++ b/htdocs/discount.class.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2007 Laurent Destailleur + * Copyright (C) 2004-2009 Laurent Destailleur * * 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 � l'origine de la remise - var $ref_facture_source; // Ref facture avoir � 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 � 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�, >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"; @@ -191,7 +232,7 @@ class DiscountAbsolute dol_syslog("DiscountAbsolute::delete Update credit note or deposit invoice statut sql=".$sql); $result=$this->db->query($sql); - if ($result) + if ($result) { $this->db->commit(); return 1; @@ -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 diff --git a/htdocs/html.form.class.php b/htdocs/html.form.class.php index 3bc2e0b6385..5178e3a5fe0 100644 --- a/htdocs/html.form.class.php +++ b/htdocs/html.form.class.php @@ -2623,13 +2623,13 @@ class Form $resultyesno = ''."\n"; return $resultyesno; diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index b2876c8faaa..de0d47793f0 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -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 %s ? 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 %s %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 diff --git a/htdocs/langs/fr_FR/bills.lang b/htdocs/langs/fr_FR/bills.lang index 99792e8aa20..12bec3b336e 100644 --- a/htdocs/langs/fr_FR/bills.lang +++ b/htdocs/langs/fr_FR/bills.lang @@ -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 %s ? 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 %s %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 diff --git a/htdocs/lib/functions.lib.php b/htdocs/lib/functions.lib.php index 0d11ca143f6..84c502023d0 100644 --- a/htdocs/lib/functions.lib.php +++ b/htdocs/lib/functions.lib.php @@ -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. */ @@ -2640,7 +2640,7 @@ function dol_nboflines($s,$maxchar=0) */ function dol_nboflines_bis($texte,$maxlinesize=0,$charset='UTF-8') { - //print $texte; + //print $texte; $repTable = array("\t" => " ", "\n" => "
", "\r" => " ", "\0" => " ", "\x0B" => " "); $texte = strtr($texte, $repTable); if ($charset == 'UTF-8') { $pattern = '/(<[^>]+>)/Uu'; } // /U is to have UNGREEDY regex to limit to one html tag. /u is for UTF8 support diff --git a/htdocs/societe.class.php b/htdocs/societe.class.php index 3e2f622082e..295212191f4 100644 --- a/htdocs/societe.class.php +++ b/htdocs/societe.class.php @@ -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 diff --git a/htdocs/theme/auguria/img/split.png b/htdocs/theme/auguria/img/split.png new file mode 100644 index 00000000000..008557d7341 Binary files /dev/null and b/htdocs/theme/auguria/img/split.png differ diff --git a/htdocs/theme/bluelagoon/img/split.png b/htdocs/theme/bluelagoon/img/split.png new file mode 100644 index 00000000000..008557d7341 Binary files /dev/null and b/htdocs/theme/bluelagoon/img/split.png differ diff --git a/htdocs/theme/eldy/img/split.png b/htdocs/theme/eldy/img/split.png new file mode 100644 index 00000000000..008557d7341 Binary files /dev/null and b/htdocs/theme/eldy/img/split.png differ diff --git a/htdocs/theme/freelug/img/split.png b/htdocs/theme/freelug/img/split.png new file mode 100644 index 00000000000..008557d7341 Binary files /dev/null and b/htdocs/theme/freelug/img/split.png differ diff --git a/htdocs/theme/rodolphe/img/split.png b/htdocs/theme/rodolphe/img/split.png new file mode 100644 index 00000000000..008557d7341 Binary files /dev/null and b/htdocs/theme/rodolphe/img/split.png differ diff --git a/htdocs/theme/yellow/img/split.png b/htdocs/theme/yellow/img/split.png new file mode 100644 index 00000000000..008557d7341 Binary files /dev/null and b/htdocs/theme/yellow/img/split.png differ diff --git a/htdocs/translate.class.php b/htdocs/translate.class.php index 189d193bf67..1e4cac11a90 100644 --- a/htdocs/translate.class.php +++ b/htdocs/translate.class.php @@ -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; }
'.$langs->trans("NewGlobalDiscount").'
'.$langs->trans("AmountHT").' '.$langs->trans("Currency".$conf->monnaie).'
'.$langs->trans("VAT").''; @@ -183,6 +268,10 @@ if ($_socid > 0) print '
'; + 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 '
'; print ''.img_object($langs->trans("ShowUser"),'user').' '.$obj->login.''; print 'rowid.'">'.img_delete($langs->trans("RemoveDiscount")).''; + print 'rowid.'">'.img_picto($langs->trans("SplitDiscount"),'split').''; + print '   '; + print 'rowid.'">'.img_delete($langs->trans("RemoveDiscount")).''; + print ' 
'; + $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 '