diff --git a/htdocs/comm/remise.php b/htdocs/comm/remise.php index e51a1b6833f..2722ae7b426 100644 --- a/htdocs/comm/remise.php +++ b/htdocs/comm/remise.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2009 Laurent Destailleur + * Copyright (C) 2004-2011 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 @@ -30,11 +30,11 @@ $langs->load("companies"); $langs->load("orders"); $langs->load("bills"); -$_socid = GETPOST("id"); +$socid = GETPOST("id"); // Security check if ($user->societe_id > 0) { - $_socid = $user->societe_id; + $socid = $user->societe_id; } @@ -56,8 +56,16 @@ if (GETPOST("action") == 'setremise') if ($result > 0) { - Header("Location: remise.php?id=".$_GET["id"]); - exit; + if (GETPOST('backtopage')) + { + Header("Location: ".GETPOST('backtopage')); + exit; + } + else + { + Header("Location: remise.php?id=".$_GET["id"]); + exit; + } } else { @@ -80,21 +88,15 @@ llxHeader(); * Mode fiche * *********************************************************************************/ -if ($_socid > 0) +if ($socid > 0) { // On recupere les donnees societes par l'objet $objsoc = new Societe($db); - $objsoc->id=$_socid; - $objsoc->fetch($_socid,$to); + $objsoc->id=$socid; + $objsoc->fetch($socid); - if ($errmesg) - { - print '
'.$errmesg.'

'; - } + dol_htmloutput_errors($errmesg); - /* - * Affichage onglets - */ $head = societe_prepare_head($objsoc); dol_fiche_head($head, 'relativediscount', $langs->trans("ThirdParty"),0,'company'); diff --git a/htdocs/comm/remx.php b/htdocs/comm/remx.php index 811bf19b42a..e6b79bc44bc 100644 --- a/htdocs/comm/remx.php +++ b/htdocs/comm/remx.php @@ -33,10 +33,10 @@ $langs->load("bills"); $langs->load("companies"); // Security check -$_socid = GETPOST("id"); +$socid = GETPOST("id"); if ($user->societe_id > 0) { - $_socid = $user->societe_id; + $socid = $user->societe_id; } @@ -204,16 +204,16 @@ if (GETPOST("action") == 'confirm_remove' && GETPOST("confirm")=='yes') $form=new Form($db); $facturestatic=new Facture($db); -llxHeader(); +llxHeader('',$langs->trans("GlobalDiscount")); -if ($_socid > 0) +if ($socid > 0) { dol_htmloutput_mesg($mesg); // On recupere les donnees societes par l'objet $objsoc = new Societe($db); - $objsoc->id=$_socid; - $objsoc->fetch($_socid,$to); + $objsoc->id=$socid; + $objsoc->fetch($socid); /* * Affichage onglets @@ -256,10 +256,10 @@ if ($_socid > 0) } print ''.$langs->trans("CustomerAbsoluteDiscountAllUsers").''; - print ''.$remise_all.' '.$langs->trans("Currency".$conf->monnaie).''; + print ''.$remise_all.' '.$langs->trans("Currency".$conf->monnaie).' '.$langs->trans("HT").''; print ''.$langs->trans("CustomerAbsoluteDiscountMy").''; - print ''.$remise_user.' '.$langs->trans("Currency".$conf->monnaie).''; + print ''.$remise_user.' '.$langs->trans("Currency".$conf->monnaie).' '.$langs->trans("HT").''; print ''; print '
'; @@ -269,7 +269,7 @@ if ($_socid > 0) print ' '.$langs->trans("Currency".$conf->monnaie).''; print ''.$langs->trans("VAT").''; print ''; - print $form->load_tva('tva_tx','0','',$mysoc,''); + print $form->load_tva('tva_tx',GETPOST('tva_tx'),'',$mysoc,''); print ''; print ''.$langs->trans("NoteReason").''; print ''; diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index e5d92528c58..57c3c59cf39 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -709,14 +709,33 @@ if ($action == 'add' && $user->rights->facture->creer) if (empty($lines) && method_exists($srcobject,'fetch_lines')) $lines = $srcobject->fetch_lines(); $fk_parent_line=0; - $num=sizeof($lines); + $num=count($lines); for ($i=0;$i<$num;$i++) { if ($lines[$i]->subprice < 0) { // Negative line, we create a discount line - // TODO + $discount = new DiscountAbsolute($db); + $discount->fk_soc=$object->socid; + $discount->amount_ht=abs($lines[$i]->total_ht); + $discount->amount_tva=abs($lines[$i]->total_tva); + $discount->amount_ttc=abs($lines[$i]->total_ttc); + $discount->tva_tx=$lines[$i]->tva_tx; + $discount->fk_user=$user->id; + $discount->description=$desc; + $discountid=$discount->create($user); + if ($discountid > 0) + { + $result=$object->insert_discount($discountid); + //$result=$discount->link_to_invoice($lineid,$id); + } + else + { + $mesg=$discount->error; + $error++; + break; + } } else { @@ -766,8 +785,13 @@ if ($action == 'add' && $user->rights->facture->creer) $fk_parent_line ); - if ($result < 0) + if ($result > 0) { + $lineid=$result; + } + else + { + $lineid=0; $error++; break; } @@ -1659,9 +1683,12 @@ if ($action == 'create') print ''.$langs->trans('Discounts').''; if ($soc->remise_client) print $langs->trans("CompanyHasRelativeDiscount",''.$soc->remise_client.''); else print $langs->trans("CompanyHasNoRelativeDiscount"); + print ' ('.$langs->trans("EditRelativeDiscount").')'; print '. '; + print '
'; if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount",''.price($absolute_discount).'',$langs->trans("Currency".$conf->monnaie)); else print $langs->trans("CompanyHasNoAbsoluteDiscount"); + print ' ('.$langs->trans("EditGlobalDiscounts").')'; print '.'; print ''; @@ -2127,13 +2154,15 @@ else print ''; // Relative and absolute discounts - $addabsolutediscount=' '.$langs->trans("AddGlobalDiscount").''; - $addcreditnote=' '.$langs->trans("AddCreditNote").''; + $addrelativediscount=''.$langs->trans("EditRelativeDiscounts").''; + $addabsolutediscount=''.$langs->trans("EditGlobalDiscounts").''; + $addcreditnote=''.$langs->trans("AddCreditNote").''; print ''.$langs->trans('Discounts'); print ''; if ($soc->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$soc->remise_client); else print $langs->trans("CompanyHasNoRelativeDiscount"); + //print ' ('.$addrelativediscount.')'; if ($absolute_discount > 0) { @@ -2165,14 +2194,14 @@ else // Remise dispo de type remise fixe (not credit note) $filter='fk_facture_source IS NULL'; print '
'; - $html->form_remise_dispo($_SERVER["PHP_SELF"].'?facid='.$object->id, 0, 'remise_id',$soc->id, $absolute_discount, $filter, $resteapayer, ' - '.$addabsolutediscount); + $html->form_remise_dispo($_SERVER["PHP_SELF"].'?facid='.$object->id, 0, 'remise_id',$soc->id, $absolute_discount, $filter, $resteapayer, ' ('.$addabsolutediscount.')'); } } else { if ($absolute_creditnote > 0) // If not linke will be added later { - if ($object->statut == 0 && $object->type != 2 && $object->type != 3) print ' - '.$addabsolutediscount.'
'; + if ($object->statut == 0 && $object->type != 2 && $object->type != 3) print ' ('.$addabsolutediscount.')
'; else print '.'; } else print '. '; @@ -2203,7 +2232,7 @@ else if (! $absolute_discount && ! $absolute_creditnote) { print $langs->trans("CompanyHasNoAbsoluteDiscount"); - if ($object->statut == 0 && $object->type != 2 && $object->type != 3) print ' - '.$addabsolutediscount.'
'; + if ($object->statut == 0 && $object->type != 2 && $object->type != 3) print ' ('.$addabsolutediscount.')
'; else print '. '; } /*if ($object->statut == 0 && $object->type != 2 && $object->type != 3) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index c68fbe5ab15..024d71f427e 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -621,6 +621,9 @@ class Facture extends CommonObject $line->desc = $object->lines[$i]->desc; $line->price = $object->lines[$i]->price; $line->subprice = $object->lines[$i]->subprice; + $line->total_ht = $object->lines[$i]->total_ht; + $line->total_tva = $object->lines[$i]->total_tva; + $line->total_ttc = $object->lines[$i]->total_ttc; $line->tva_tx = $object->lines[$i]->tva_tx; $line->localtax1_tx = $object->lines[$i]->localtax1_tx; $line->localtax2_tx = $object->lines[$i]->localtax2_tx; @@ -634,11 +637,6 @@ class Facture extends CommonObject $line->special_code = $object->lines[$i]->special_code; $line->fk_parent_line = $object->lines[$i]->fk_parent_line; - // TODO it's ok ? - $line->total_ht = $object->lines[$i]->total_ht; - $line->total_tva = $object->lines[$i]->total_tva; - $line->total_ttc = $object->lines[$i]->total_ttc; - $this->lines[$i] = $line; } @@ -1057,10 +1055,10 @@ class Facture extends CommonObject /** - * Ajout en base d'une ligne remise fixe en ligne de facture + * Add a discount line into invoice using an existing absolute discount * - * @param idremise Id de la remise fixe - * @return int >0 si ok, <0 si ko + * @param int $idremise Id of absolute discount + * @return int >0 if OK, <0 if KO */ function insert_discount($idremise) { @@ -1781,30 +1779,31 @@ class Facture extends CommonObject /** - * Add an invoice line into database (linked to product/service or not) - * \param facid Id de la facture - * \param desc Description de la ligne - * \param pu_ht Prix unitaire HT (> 0 even for credit note) - * \param qty Quantite - * \param txtva Taux de tva force, sinon -1 - * \param txlocaltax1 Local tax 1 rate - * \param txlocaltax2 Local tax 2 rate - * \param fk_product Id du produit/service predefini - * \param remise_percent Pourcentage de remise de la ligne - * \param date_start Date de debut de validite du service - * \param date_end Date de fin de validite du service - * \param ventil Code de ventilation comptable - * \param info_bits Bits de type de lignes - * \param fk_remise_except Id remise - * \param price_base_type HT or TTC - * \param pu_ttc Prix unitaire TTC (> 0 even for credit note) - * \param type Type of line (0=product, 1=service) - * \param rang Position of line - * \return int >0 if OK, <0 if KO - * \remarks Les parametres sont deja cense etre juste et avec valeurs finales a l'appel - * de cette methode. Aussi, pour le taux tva, il doit deja avoir ete defini - * par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,produit) - * et le desc doit deja avoir la bonne valeur (a l'appelant de gerer le multilangue) + * Add an invoice line into database (linked to product/service or not). + * Les parametres sont deja cense etre juste et avec valeurs finales a l'appel + * de cette methode. Aussi, pour le taux tva, il doit deja avoir ete defini + * par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,produit) + * et le desc doit deja avoir la bonne valeur (a l'appelant de gerer le multilangue) + * + * @param facid Id de la facture + * @param desc Description de la ligne + * @param pu_ht Prix unitaire HT (> 0 even for credit note) + * @param qty Quantite + * @param txtva Taux de tva force, sinon -1 + * @param txlocaltax1 Local tax 1 rate + * @param txlocaltax2 Local tax 2 rate + * @param fk_product Id du produit/service predefini + * @param remise_percent Pourcentage de remise de la ligne + * @param date_start Date de debut de validite du service + * @param date_end Date de fin de validite du service + * @param ventil Code de ventilation comptable + * @param info_bits Bits de type de lignes + * @param fk_remise_except Id remise + * @param price_base_type HT or TTC + * @param pu_ttc Prix unitaire TTC (> 0 even for credit note) + * @param type Type of line (0=product, 1=service) + * @param rang Position of line + * @return int <0 if KO, Id of line if OK */ function addline($facid, $desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits=0, $fk_remise_except='', $price_base_type='HT', $pu_ttc=0, $type=0, $rang=-1, $special_code=0, $origin='', $origin_id=0, $fk_parent_line=0) { diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 4bc8f476f9f..3602a8401e3 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -782,9 +782,10 @@ abstract class CommonObject /** - * Stocke un numero de rang pour toutes les lignes de detail d'un element qui n'en ont pas. + * Stocke un numero de rang pour toutes les lignes de detail d'un element qui n'en ont pas. * - * @param renum true to renum all already ordered lines, false to renum only not already ordered lines. + * @param boolean $renum true to renum all already ordered lines, false to renum only not already ordered lines. + * @param string $rowidorder ASC or DESC */ function line_order($renum=false, $rowidorder='ASC') { @@ -830,9 +831,9 @@ abstract class CommonObject } /** - * Update a line to have a lower rank + * Update a line to have a lower rank * - * @param $rowid + * @param int $rowid */ function line_up($rowid) { @@ -846,9 +847,9 @@ abstract class CommonObject } /** - * Update a line to have a higher rank + * Update a line to have a higher rank * - * @param $rowid + * @param int $rowid */ function line_down($rowid) { @@ -867,8 +868,8 @@ abstract class CommonObject /** * Update position of line (rang) * - * @param rowid - * @param rang + * @param int $rowid + * @param int $rang */ function updateRangOfLine($rowid,$rang) { @@ -881,9 +882,9 @@ abstract class CommonObject } /** - * Update position of line with ajax (rang) + * Update position of line with ajax (rang) * - * @param roworder + * @param int $roworder */ function line_ajaxorder($roworder) { @@ -897,10 +898,10 @@ abstract class CommonObject } /** - * Update position of line up (rang) + * Update position of line up (rang) * - * @param rowid - * @param rang + * @param int $rowid + * @param int $rang */ function updateLineUp($rowid,$rang) { @@ -926,11 +927,11 @@ abstract class CommonObject } /** - * Update position of line down (rang) + * Update position of line down (rang) * - * @param rowid - * @param rang - * @param max + * @param int $rowid + * @param int $rang + * @param int $max */ function updateLineDown($rowid,$rang,$max) { @@ -956,10 +957,10 @@ abstract class CommonObject } /** - * Get position of line (rang) + * Get position of line (rang) * - * @param rowid Id of line - * @return int Value of rang in table of lines + * @param int $rowid Id of line + * @return int Value of rang in table of lines */ function getRangOfLine($rowid) { @@ -974,9 +975,10 @@ abstract class CommonObject } /** - * Get rowid of the line relative to its position + * Get rowid of the line relative to its position * - * @return int Rowid of the line + * @param int $rang Rang value + * @return int Rowid of the line */ function getIdOfLine($rang) { @@ -992,10 +994,10 @@ abstract class CommonObject } /** - * Get max value used for position of line (rang) + * Get max value used for position of line (rang) * - * @param fk_parent_line - * @return int Max value of rang in table of lines + * @param int $fk_parent_line Parent line id + * @return int Max value of rang in table of lines */ function line_max($fk_parent_line=0) { @@ -1031,10 +1033,10 @@ abstract class CommonObject } /** - * Update private note of element + * Update private note of element * - * @param note New value for note - * @return int <0 if KO, >0 if OK + * @param string $note New value for note + * @return int <0 if KO, >0 if OK */ function update_note($note) { diff --git a/htdocs/core/class/discount.class.php b/htdocs/core/class/discount.class.php index 3853b075e24..14c2a29cb09 100644 --- a/htdocs/core/class/discount.class.php +++ b/htdocs/core/class/discount.class.php @@ -29,318 +29,324 @@ */ class DiscountAbsolute { - var $db; - var $error; - - var $id; // Id remise - var $amount_ht; // - var $amount_tva; // - var $amount_ttc; // - var $tva_tx; // - var $fk_user; // Id utilisateur qui accorde la remise - var $description; // Description libre - 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 a l'origine de la remise - var $ref_facture_source; // Ref facture avoir a l'origine de la remise - - /** - * Constructor - * @param DB Database handler - */ - function DiscountAbsolute($DB) - { - $this->db = $DB; - } - - - /** - * \brief Load object from database into memory - * \param rowid id discount to load - * \param fk_facture_source fk_facture_source - * \return int <0 if KO, =0 if not found, >0 if OK - */ - function fetch($rowid,$fk_facture_source=0) - { - // Check parameters - if (! $rowid && ! $fk_facture_source) - { - $this->error='ErrorBadParameters'; - return -1; - } - - $sql = "SELECT sr.rowid, sr.fk_soc,"; - $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.= " 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"; - $sql.= " WHERE"; - if ($rowid) $sql.= " sr.rowid=".$rowid; - if ($fk_facture_source) $sql.= " sr.fk_facture_source=".$fk_facture_source; - - dol_syslog("DiscountAbsolute::fetch sql=".$sql); - $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { - $obj = $this->db->fetch_object($resql); - - $this->id = $obj->rowid; - $this->fk_soc = $obj->fk_soc; - $this->amount_ht = $obj->amount_ht; - $this->amount_tva = $obj->amount_tva; - $this->amount_ttc = $obj->amount_ttc; - $this->tva_tx = $obj->tva_tx; - $this->fk_user = $obj->fk_user; - $this->fk_facture_line = $obj->fk_facture_line; - $this->fk_facture = $obj->fk_facture; - $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 = $this->db->jdate($obj->datec); - - $this->db->free($resql); - return 1; - } - else - { - $this->db->free($resql); - return 0; - } - } - else - { - $this->error=$this->db->error(); - return -1; - } - } + var $db; + var $error; + var $id; // Id remise + var $fk_soc; + var $amount_ht; // + var $amount_tva; // + var $amount_ttc; // + var $tva_tx; // + var $fk_user; // Id utilisateur qui accorde la remise + var $description; // Description libre + 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 a l'origine de la remise + var $ref_facture_source; // Ref facture avoir a l'origine de la remise /** - * \brief Create in database - * \param user User that create - * \return int <0 si ko, >0 si ok + * Constructor + * @param DB Database handler */ - function create($user) + function DiscountAbsolute($DB) { - global $conf, $langs; - - // 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($this->datec!=''?$this->datec:dol_now()).", ".$this->fk_soc.", ".$user->id.", '".$this->db->escape($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.= ")"; - - dol_syslog("DiscountAbsolute::create sql=".$sql); - $resql=$this->db->query($sql); - if ($resql) - { - $this->id=$this->db->last_insert_id(MAIN_DB_PREFIX."societe_remise_except"); - return $this->id; - } - else - { - $this->error=$this->db->lasterror().' - sql='.$sql; - dol_syslog("DiscountAbsolute::create ".$this->error, LOG_ERR); - return -1; - } + $this->db = $DB; } - /* - * \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($user) - { - global $conf, $langs; + /** + * \brief Load object from database into memory + * \param rowid id discount to load + * \param fk_facture_source fk_facture_source + * \return int <0 if KO, =0 if not found, >0 if OK + */ + function fetch($rowid,$fk_facture_source=0) + { + // Check parameters + if (! $rowid && ! $fk_facture_source) + { + $this->error='ErrorBadParameters'; + return -1; + } - // 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; + $sql = "SELECT sr.rowid, sr.fk_soc,"; + $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.= " 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"; + $sql.= " WHERE"; + if ($rowid) $sql.= " sr.rowid=".$rowid; + if ($fk_facture_source) $sql.= " sr.fk_facture_source=".$fk_facture_source; - 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; - } - } + dol_syslog("DiscountAbsolute::fetch sql=".$sql); + $resql = $this->db->query($sql); + if ($resql) + { + if ($this->db->num_rows($resql)) + { + $obj = $this->db->fetch_object($resql); - $this->db->begin(); + $this->id = $obj->rowid; + $this->fk_soc = $obj->fk_soc; + $this->amount_ht = $obj->amount_ht; + $this->amount_tva = $obj->amount_tva; + $this->amount_ttc = $obj->amount_ttc; + $this->tva_tx = $obj->tva_tx; + $this->fk_user = $obj->fk_user; + $this->fk_facture_line = $obj->fk_facture_line; + $this->fk_facture = $obj->fk_facture; + $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 = $this->db->jdate($obj->datec); - // Delete but only if not used - $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_remise_except "; - 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 + $this->db->free($resql); + return 1; + } + else + { + $this->db->free($resql); + return 0; + } + } + else + { + $this->error=$this->db->error(); + return -1; + } + } - dol_syslog("DiscountAbsolute::delete Delete discount sql=".$sql); - $result=$this->db->query($sql); - if ($result) - { - // 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"; - $sql.=" set paye=0, fk_statut=1"; - $sql.=" WHERE (type = 2 or type = 3) AND rowid=".$this->fk_facture_source; - dol_syslog("DiscountAbsolute::delete Update credit note or deposit invoice statut sql=".$sql); - $result=$this->db->query($sql); - if ($result) - { - $this->db->commit(); - return 1; - } - else - { - $this->error=$this->db->lasterror(); - $this->db->rollback(); - return -1; - } - } - else - { - $this->db->commit(); - return 1; - } - } - else - { - $this->error=$this->db->lasterror(); - $this->db->rollback(); - return -1; - } - } + /** + * Create a discount into database + * + * @param User $user User that create + * @return int <0 if KO, >0 if OK + */ + function create($user) + { + global $conf, $langs; + + // 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($this->datec!=''?$this->datec:dol_now()).", ".$this->fk_soc.", ".$user->id.", '".$this->db->escape($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.= ")"; + + dol_syslog("DiscountAbsolute::create sql=".$sql); + $resql=$this->db->query($sql); + if ($resql) + { + $this->id=$this->db->last_insert_id(MAIN_DB_PREFIX."societe_remise_except"); + return $this->id; + } + else + { + $this->error=$this->db->lasterror().' - sql='.$sql; + dol_syslog("DiscountAbsolute::create ".$this->error, LOG_ERR); + return -1; + } + } + + + /** + * 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 $user Object of user asking to delete + * @return int <0 if KO, >0 if OK + */ + 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 "; + 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 note or deposit, we change source statut. + if ($this->fk_facture_source) + { + $sql = "UPDATE ".MAIN_DB_PREFIX."facture"; + $sql.=" set paye=0, fk_statut=1"; + $sql.=" WHERE (type = 2 or type = 3) AND rowid=".$this->fk_facture_source; + + dol_syslog("DiscountAbsolute::delete Update credit note or deposit invoice statut sql=".$sql); + $result=$this->db->query($sql); + if ($result) + { + $this->db->commit(); + return 1; + } + else + { + $this->error=$this->db->lasterror(); + $this->db->rollback(); + return -1; + } + } + else + { + $this->db->commit(); + return 1; + } + } + else + { + $this->error=$this->db->lasterror(); + $this->db->rollback(); + return -1; + } + } - /** - * \brief Link the discount to a particular invoice line or a particular invoice - * \param rowidline Invoice line id - * \param rowidinvoice Invoice id - * \return int <0 ko, >0 ok - */ - function link_to_invoice($rowidline,$rowidinvoice) - { - // Check parameters - if (! $rowidline && ! $rowidinvoice) - { - $this->error='ErrorBadParameters'; - return -1; - } - if ($rowidline && $rowidinvoice) - { - $this->error='ErrorBadParameters'; - return -2; - } + /** + * Link the discount to a particular invoice line or a particular invoice + * + * @param int $rowidline Invoice line id + * @param int $rowidinvoice Invoice id + * @return int <0 if KO, >0 if OK + */ + function link_to_invoice($rowidline,$rowidinvoice) + { + // Check parameters + if (! $rowidline && ! $rowidinvoice) + { + $this->error='ErrorBadParameters'; + return -1; + } + if ($rowidline && $rowidinvoice) + { + $this->error='ErrorBadParameters'; + return -2; + } - $sql ="UPDATE ".MAIN_DB_PREFIX."societe_remise_except"; - if ($rowidline) $sql.=" SET fk_facture_line = ".$rowidline; - if ($rowidinvoice) $sql.=" SET fk_facture = ".$rowidinvoice; - $sql.=" WHERE rowid = ".$this->id; + $sql ="UPDATE ".MAIN_DB_PREFIX."societe_remise_except"; + if ($rowidline) $sql.=" SET fk_facture_line = ".$rowidline; + if ($rowidinvoice) $sql.=" SET fk_facture = ".$rowidinvoice; + $sql.=" WHERE rowid = ".$this->id; - dol_syslog("DiscountAbsolute::link_to_invoice sql=".$sql,LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - return 1; - } - else - { - $this->error=$this->db->error(); - dol_syslog("DiscountAbsolute::link_to_invoice ".$this->error,LOG_ERR); - return -3; - } - } + dol_syslog("DiscountAbsolute::link_to_invoice sql=".$sql,LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + $this->fk_facture_source=$rowidline; + $this->fk_facture=$rowidinvoice; + return 1; + } + else + { + $this->error=$this->db->error(); + dol_syslog("DiscountAbsolute::link_to_invoice ".$this->error,LOG_ERR); + return -3; + } + } - /** - * \brief Link the discount to a particular invoice line or a particular invoice - * \remarks Do not call this if discount is linked to a reconcialiated invoice - * \param rowidline Invoice line id - * \param rowidinvoice Invoice id - * \return int <0 if KO, >0 if OK - */ - function unlink_invoice() - { - $sql ="UPDATE ".MAIN_DB_PREFIX."societe_remise_except"; - $sql.=" SET fk_facture_line = NULL, fk_facture = NULL"; - $sql.=" WHERE rowid = ".$this->id; + /** + * \brief Link the discount to a particular invoice line or a particular invoice + * \remarks Do not call this if discount is linked to a reconcialiated invoice + * \param rowidline Invoice line id + * \param rowidinvoice Invoice id + * \return int <0 if KO, >0 if OK + */ + function unlink_invoice() + { + $sql ="UPDATE ".MAIN_DB_PREFIX."societe_remise_except"; + $sql.=" SET fk_facture_line = NULL, fk_facture = NULL"; + $sql.=" WHERE rowid = ".$this->id; - dol_syslog("DiscountAbsolute::unlink_invoice sql=".$sql,LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - return 1; - } - else - { - $this->error=$this->db->error(); - dol_syslog("DiscountAbsolute::link_to_invoice ".$this->error,LOG_ERR); - return -3; - } - } + dol_syslog("DiscountAbsolute::unlink_invoice sql=".$sql,LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + return 1; + } + else + { + $this->error=$this->db->error(); + dol_syslog("DiscountAbsolute::link_to_invoice ".$this->error,LOG_ERR); + return -3; + } + } - /** - * \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 - * \param maxvalue Filter on max value for discount - * \return int <0 si ko, montant avoir sinon - */ - function getAvailableDiscounts($company='', $user='',$filter='', $maxvalue=0) - { + /** + * \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 + * \param maxvalue Filter on max value for discount + * \return int <0 si ko, montant avoir sinon + */ + function getAvailableDiscounts($company='', $user='',$filter='', $maxvalue=0) + { $sql = "SELECT SUM(rc.amount_ttc) as amount"; -// $sql = "SELECT rc.amount_ttc as amount"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe_remise_except as rc"; + // $sql = "SELECT rc.amount_ttc as amount"; + $sql.= " FROM ".MAIN_DB_PREFIX."societe_remise_except as rc"; $sql.= " WHERE (rc.fk_facture IS NULL AND rc.fk_facture_line IS NULL)"; // Available - if (is_object($company)) $sql.= " AND rc.fk_soc = ".$company->id; + if (is_object($company)) $sql.= " AND rc.fk_soc = ".$company->id; if (is_object($user)) $sql.= " AND rc.fk_user = ".$user->id; if ($filter) $sql.=' AND '.$filter; if ($maxvalue) $sql.=' AND rc.amount_ttc <= '.price2num($maxvalue); @@ -350,100 +356,100 @@ class DiscountAbsolute if ($resql) { $obj = $this->db->fetch_object($resql); - //while ($obj) + //while ($obj) //{ - //print 'zz'.$obj->amount; - //$obj = $this->db->fetch_object($resql); + //print 'zz'.$obj->amount; + //$obj = $this->db->fetch_object($resql); //} return $obj->amount; } - return -1; - } + return -1; + } - /** - * \brief Return amount (with tax) of all credit notes and deposits invoices used by invoice - * \return int <0 if KO, Sum of credit notes and deposits amount otherwise - */ - function getSumCreditNotesUsed($invoice) - { - $sql = 'SELECT sum(rc.amount_ttc) as amount'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture as f'; - $sql.= ' WHERE rc.fk_facture_source=f.rowid AND rc.fk_facture = '.$invoice->id; - $sql.= ' AND f.type = 2'; + /** + * \brief Return amount (with tax) of all credit notes and deposits invoices used by invoice + * \return int <0 if KO, Sum of credit notes and deposits amount otherwise + */ + function getSumCreditNotesUsed($invoice) + { + $sql = 'SELECT sum(rc.amount_ttc) as amount'; + $sql.= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture as f'; + $sql.= ' WHERE rc.fk_facture_source=f.rowid AND rc.fk_facture = '.$invoice->id; + $sql.= ' AND f.type = 2'; dol_syslog("DiscountAbsolute::getSumCreditNotesUsed sql=".$sql,LOG_DEBUG); - $resql=$this->db->query($sql); - if ($resql) - { - $obj = $this->db->fetch_object($resql); - return $obj->amount; - } - else - { - return -1; - } - } + $resql=$this->db->query($sql); + if ($resql) + { + $obj = $this->db->fetch_object($resql); + return $obj->amount; + } + else + { + return -1; + } + } - /** - * \brief Return amount (with tax) of all deposits invoices used by invoice - * \return int <0 if KO, Sum of credit notes and deposits amount otherwise - */ - function getSumDepositsUsed($invoice) - { - $sql = 'SELECT sum(rc.amount_ttc) as amount'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture as f'; - $sql.= ' WHERE rc.fk_facture_source=f.rowid AND rc.fk_facture = '.$invoice->id; - $sql.= ' AND f.type = 3'; + /** + * \brief Return amount (with tax) of all deposits invoices used by invoice + * \return int <0 if KO, Sum of credit notes and deposits amount otherwise + */ + function getSumDepositsUsed($invoice) + { + $sql = 'SELECT sum(rc.amount_ttc) as amount'; + $sql.= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture as f'; + $sql.= ' WHERE rc.fk_facture_source=f.rowid AND rc.fk_facture = '.$invoice->id; + $sql.= ' AND f.type = 3'; dol_syslog("DiscountAbsolute::getSumDepositsUsed sql=".$sql,LOG_DEBUG); - $resql=$this->db->query($sql); - if ($resql) - { - $obj = $this->db->fetch_object($resql); - return $obj->amount; - } - else - { - return -1; - } - } + $resql=$this->db->query($sql); + if ($resql) + { + $obj = $this->db->fetch_object($resql); + return $obj->amount; + } + else + { + return -1; + } + } - /** - * \brief Return clicable ref of object (with picto or not) - * \param withpicto 0=Pas de picto, 1=Inclut le picto dans le lien, 2=Picto seul - * \param option Sur quoi pointe le lien - * \return string Chaine avec URL - */ - function getNomUrl($withpicto,$option='invoice') - { - global $langs; + /** + * \brief Return clicable ref of object (with picto or not) + * \param withpicto 0=Pas de picto, 1=Inclut le picto dans le lien, 2=Picto seul + * \param option Sur quoi pointe le lien + * \return string Chaine avec URL + */ + function getNomUrl($withpicto,$option='invoice') + { + global $langs; - $result=''; + $result=''; - if ($option == 'invoice') - { - $lien = ''; - $lienfin=''; - $label=$langs->trans("ShowDiscount").': '.$this->ref_facture_source; - $ref=$this->ref_facture_source; - $picto='bill'; - } - if ($option == 'discount') - { - $lien = ''; - $lienfin=''; - $label=$langs->trans("Discount"); - $ref=$langs->trans("Discount"); - $picto='generic'; - } + if ($option == 'invoice') + { + $lien = ''; + $lienfin=''; + $label=$langs->trans("ShowDiscount").': '.$this->ref_facture_source; + $ref=$this->ref_facture_source; + $picto='bill'; + } + if ($option == 'discount') + { + $lien = ''; + $lienfin=''; + $label=$langs->trans("Discount"); + $ref=$langs->trans("Discount"); + $picto='generic'; + } - if ($withpicto) $result.=($lien.img_object($label,$picto).$lienfin); - if ($withpicto && $withpicto != 2) $result.=' '; - $result.=$lien.$ref.$lienfin; - return $result; - } + if ($withpicto) $result.=($lien.img_object($label,$picto).$lienfin); + if ($withpicto && $withpicto != 2) $result.=' '; + $result.=$lien.$ref.$lienfin; + return $result; + } } ?> diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 0760bb93525..f31e67ca1d0 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -23,7 +23,6 @@ * \ingroup ficheinter * \brief Fichier de la classe des gestion des fiches interventions */ - require_once(DOL_DOCUMENT_ROOT ."/core/class/commonobject.class.php"); @@ -61,7 +60,8 @@ class Fichinter extends CommonObject /** * Class constructor - * @param DB Data base handler access + * + * @param DoliDB $DB Data base handler access */ function Fichinter($DB) { diff --git a/htdocs/langs/ar_SA/bills.lang b/htdocs/langs/ar_SA/bills.lang index 38d6293a5c8..f2cee2ac35b 100755 --- a/htdocs/langs/ar_SA/bills.lang +++ b/htdocs/langs/ar_SA/bills.lang @@ -221,6 +221,7 @@ NewGlobalDiscount=تحديد خصم جديد NewRelativeDiscount=خصم جديد النسبية NoteReason=ملاحظة / السبب ReasonDiscount=السبب +AddDiscount=إضافة الخصم AddGlobalDiscount=إضافة الخصم DiscountOfferedBy=التي تمنحها DiscountStillRemaining=خصم لا يزالون diff --git a/htdocs/langs/ca_ES/bills.lang b/htdocs/langs/ca_ES/bills.lang index a1e6f6b0c5f..f4c3c6c73f8 100644 --- a/htdocs/langs/ca_ES/bills.lang +++ b/htdocs/langs/ca_ES/bills.lang @@ -234,6 +234,7 @@ GlobalDiscount=Descompte fixe CreditNote=Abonament CreditNotes=Abonaments AddDiscount=Crear descompte fix +AddGlobalDiscount=Crear descompte fixe AddCreditNote=Crear factura de pagament Deposit=Bestreta Deposits=Bestretes @@ -245,7 +246,6 @@ NewGlobalDiscount=Nou descompte fixe NewRelativeDiscount=Nou descompte NoteReason=Nota/Motiu ReasonDiscount=Motiu -AddGlobalDiscount=Afegir descompte fixe DiscountOfferedBy=Acordat per DiscountStillRemaining=Descomptes fixes pendents DiscountAlreadyCounted=Descomptes fixes ja aplicats diff --git a/htdocs/langs/da_DK/bills.lang b/htdocs/langs/da_DK/bills.lang index 2e70ceff98b..c2c1dd2a0f2 100755 --- a/htdocs/langs/da_DK/bills.lang +++ b/htdocs/langs/da_DK/bills.lang @@ -219,6 +219,7 @@ DiscountFromCreditNote=Discount fra kreditnota %s NewGlobalDiscount=Ny discount NoteReason=Bemærk / Grund ReasonDiscount=Årsag +AddDiscount=Tilføj rabat AddGlobalDiscount=Tilføj rabat DiscountOfferedBy=Ydet af DiscountStillRemaining=Discount stadig resterende diff --git a/htdocs/langs/de_AT/bills.lang b/htdocs/langs/de_AT/bills.lang index c4ecb554f30..4ae1d7e3e95 100755 --- a/htdocs/langs/de_AT/bills.lang +++ b/htdocs/langs/de_AT/bills.lang @@ -215,6 +215,7 @@ DiscountFromCreditNote=Rabatt aus Gutschrift %s NewGlobalDiscount=Neue Rabattregel NoteReason=Anmerkung/Begründung ReasonDiscount=Rabattgrund +AddDiscount=Rabattregel hinzufügen AddGlobalDiscount=Rabattregel hinzufügen DiscountOfferedBy=Rabatt angeboten von DiscountStillRemaining=Noch verbleibender Rabatt diff --git a/htdocs/langs/de_DE/bills.lang b/htdocs/langs/de_DE/bills.lang index c4ecb554f30..4ae1d7e3e95 100644 --- a/htdocs/langs/de_DE/bills.lang +++ b/htdocs/langs/de_DE/bills.lang @@ -215,6 +215,7 @@ DiscountFromCreditNote=Rabatt aus Gutschrift %s NewGlobalDiscount=Neue Rabattregel NoteReason=Anmerkung/Begründung ReasonDiscount=Rabattgrund +AddDiscount=Rabattregel hinzufügen AddGlobalDiscount=Rabattregel hinzufügen DiscountOfferedBy=Rabatt angeboten von DiscountStillRemaining=Noch verbleibender Rabatt diff --git a/htdocs/langs/el_GR/bills.lang b/htdocs/langs/el_GR/bills.lang index 0f0dd9ab8b6..92c90ac7622 100755 --- a/htdocs/langs/el_GR/bills.lang +++ b/htdocs/langs/el_GR/bills.lang @@ -244,7 +244,6 @@ NewGlobalDiscount=Νέα απόλυτη έκπτωση NewRelativeDiscount=Νέα σχετική έκπτωση NoteReason=Σημείωση/Αιτία ReasonDiscount=Αιτία -AddGlobalDiscount=Προσθήκη έκπτωσης DiscountOfferedBy=Granted by DiscountStillRemaining=Η έκπτωση παραμένει DiscountAlreadyCounted=Η έκπτωση υπολογίστηκε ήδη @@ -426,6 +425,7 @@ DisabledBecauseNotErasable=Άτομα με ειδικές ανάγκες, επε NumberOfBillsByMonth=Nb των τιμολογίων ανά μήνα AmountOfBillsByMonthHT=Ποσό των τιμολογίων ανά μήνα (μετά από φόρους) AddDiscount=Δημιουργία απόλυτη έκπτωση +AddGlobalDiscount=Προσθήκη έκπτωσης AddCreditNote=Δημιουργία πιστωτικό σημείωμα InvoiceNotChecked=Δεν έχει επιλεγεί τιμολόγιο ShowUnpaidAll=Εμφάνιση όλων των απλήρωτων τιμολογίων diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index fbc8055a3cd..a66bd16a546 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -232,7 +232,11 @@ Reductions=Reductions ReductionsShort=Reduc. Discount=Discount Discounts=Discounts -AddDiscount=Create absolute discount +AddDiscount=Create discount +AddRelativeDiscount=Create relative discount +EditRelativelDiscount=Edit relatvie discount +AddGlobalDiscount=Create absolute discount +EditGlobalDiscounts=Edit absolute discounts AddCreditNote=Create credit note ShowDiscount=Show discount RelativeDiscount=Relative discount @@ -249,7 +253,6 @@ NewGlobalDiscount=New absolute discount NewRelativeDiscount=New relative discount NoteReason=Note/Reason ReasonDiscount=Reason -AddGlobalDiscount=Add discount DiscountOfferedBy=Granted by DiscountStillRemaining=Discounts still remaining DiscountAlreadyCounted=Discounts already counted diff --git a/htdocs/langs/es_ES/bills.lang b/htdocs/langs/es_ES/bills.lang index a67de2436d9..58400b44d62 100644 --- a/htdocs/langs/es_ES/bills.lang +++ b/htdocs/langs/es_ES/bills.lang @@ -234,6 +234,7 @@ GlobalDiscount=Descuento fijo CreditNote=Abono CreditNotes=Abonos AddDiscount=Crear descuento fijo +AddGlobalDiscount=Crear descuento fijo AddCreditNote=Crear factura de abono Deposit=Anticipo Deposits=Anticipos @@ -245,7 +246,6 @@ NewGlobalDiscount=Nuevo descuento fijo NewRelativeDiscount=Nuevo descuento NoteReason=Nota/Motivo ReasonDiscount=Motivo -AddGlobalDiscount=Añadir descuento fijo DiscountOfferedBy=Acordado por DiscountStillRemaining=Descuentos fijos pendientes DiscountAlreadyCounted=Descuentos fijos ya aplicados diff --git a/htdocs/langs/fa_IR/bills.lang b/htdocs/langs/fa_IR/bills.lang index 38d6293a5c8..f2cee2ac35b 100755 --- a/htdocs/langs/fa_IR/bills.lang +++ b/htdocs/langs/fa_IR/bills.lang @@ -221,6 +221,7 @@ NewGlobalDiscount=تحديد خصم جديد NewRelativeDiscount=خصم جديد النسبية NoteReason=ملاحظة / السبب ReasonDiscount=السبب +AddDiscount=إضافة الخصم AddGlobalDiscount=إضافة الخصم DiscountOfferedBy=التي تمنحها DiscountStillRemaining=خصم لا يزالون diff --git a/htdocs/langs/fi_FI/bills.lang b/htdocs/langs/fi_FI/bills.lang index 40e714e1ef5..5c6f7bef736 100644 --- a/htdocs/langs/fi_FI/bills.lang +++ b/htdocs/langs/fi_FI/bills.lang @@ -215,6 +215,7 @@ DiscountFromCreditNote=Alennus menoilmoitus %s NewGlobalDiscount=Uusi edullisista NoteReason=Huomautus / syy ReasonDiscount=Perustelu +AddDiscount=Lisää edullisista AddGlobalDiscount=Lisää edullisista DiscountOfferedBy=Myöntämä DiscountStillRemaining=Discount vielä jäljellä diff --git a/htdocs/langs/fr_FR/bills.lang b/htdocs/langs/fr_FR/bills.lang index 532c4ace51c..a44bfc49b47 100644 --- a/htdocs/langs/fr_FR/bills.lang +++ b/htdocs/langs/fr_FR/bills.lang @@ -233,7 +233,11 @@ RelativeDiscount=Remise relative GlobalDiscount=Remise fixe CreditNote=Avoir CreditNotes=Avoirs -AddDiscount=Créer remise fixe +AddDiscount=Editer remises +AddRelativeDiscount=Créer remise relative +EditRelativeDiscount=Editer remise relative +AddGlobalDiscount=Créer remise fixe +EditGlobalDiscounts=Editer remises fixes AddCreditNote=Créer facture avoir Deposit=Acompte Deposits=Acomptes @@ -245,7 +249,6 @@ NewGlobalDiscount=Nouvelle remise fixe NewRelativeDiscount=Nouvelle remise relative NoteReason=Note/Motif ReasonDiscount=Motif -AddGlobalDiscount=Ajouter remise fixe DiscountOfferedBy=Accordé par DiscountStillRemaining=Remises restant en cours DiscountAlreadyCounted=Remises déjà appliquées diff --git a/htdocs/langs/it_IT/bills.lang b/htdocs/langs/it_IT/bills.lang index ed31dbb7097..ea98f1fe26b 100644 --- a/htdocs/langs/it_IT/bills.lang +++ b/htdocs/langs/it_IT/bills.lang @@ -219,7 +219,6 @@ DiscountFromCreditNote =Sconto da nota di credito per %s NewGlobalDiscount =Nuovo sconto NoteReason =Note / Motivo ReasonDiscount =Motivo -AddGlobalDiscount =Aggiungi sconto DiscountOfferedBy =Concessi da DiscountStillRemaining =Sconto ancora disponibile DiscountAlreadyCounted =Sconto già applicato @@ -436,7 +435,8 @@ BillsSuppliersUnpaidForCompany=Fornitore di fatture non pagate per %s BillsLate=Ritardi nei pagamenti DisabledBecauseNotErasable=Disabili perché non possono essere cancellati AmountOfBillsByMonthHT=Importo delle fatture per mese (al netto delle imposte) -AddDiscount=Creare sconto assoluto +AddDiscount=Creare sconto +AddGlobalDiscount=Creare sconto assoluto AddCreditNote=Crea nota di credito InvoiceNotChecked=Fattura non selezionati ShowUnpaidAll=Mostra tutte le fatture non pagate diff --git a/htdocs/langs/nb_NO/bills.lang b/htdocs/langs/nb_NO/bills.lang index 2f05e9e9870..c6ef4e90b23 100644 --- a/htdocs/langs/nb_NO/bills.lang +++ b/htdocs/langs/nb_NO/bills.lang @@ -223,6 +223,7 @@ DiscountFromCreditNote=Rabatt fra kreditnota %s NewGlobalDiscount=Ny rabatt NoteReason=Notat/Årsak ReasonDiscount=Årsak +AddDiscount=Legg til rabatt AddGlobalDiscount=Legg til rabatt DiscountOfferedBy=Innrømmet av DiscountStillRemaining=Gjenstående rabatt diff --git a/htdocs/langs/nl_BE/bills.lang b/htdocs/langs/nl_BE/bills.lang index 58b759ae290..4a840ae1d24 100644 --- a/htdocs/langs/nl_BE/bills.lang +++ b/htdocs/langs/nl_BE/bills.lang @@ -188,6 +188,7 @@ CreditNotes=Creditnota's NewGlobalDiscount=Nieuwe korting NoteReason=Nota/Reden ReasonDiscount=Reden +AddDiscount=Korting toevoegen AddGlobalDiscount=Korting toevoegen DiscountOfferedBy=Verleend door DiscountStillRemaining=Korting nog steeds geldig / nog niet gerekend diff --git a/htdocs/langs/nl_NL/bills.lang b/htdocs/langs/nl_NL/bills.lang index 7bce48b254a..9569889b906 100644 --- a/htdocs/langs/nl_NL/bills.lang +++ b/htdocs/langs/nl_NL/bills.lang @@ -240,6 +240,7 @@ NewGlobalDiscount=Nieuwe korting NewRelativeDiscount=Nieuwe relatieve korting NoteReason=Opmerking/Reden ReasonDiscount=Reden +AddDiscount=Toevoegen korting AddGlobalDiscount=Toevoegen korting DiscountOfferedBy=Verleend door DiscountStillRemaining=Kortingen nog steeds vast diff --git a/htdocs/langs/pl_PL/bills.lang b/htdocs/langs/pl_PL/bills.lang index 1984296256d..a39303f3193 100644 --- a/htdocs/langs/pl_PL/bills.lang +++ b/htdocs/langs/pl_PL/bills.lang @@ -220,6 +220,7 @@ DiscountFromCreditNote=Rabat od kredytu pamiętać %s NewGlobalDiscount=Nowe zniżki NoteReason=Uwaga / Reason ReasonDiscount=Powód +AddDiscount=Dodaj zniżki AddGlobalDiscount=Dodaj zniżki DiscountOfferedBy=Przyznane przez DiscountStillRemaining=Rabat nadal pozostały diff --git a/htdocs/langs/pt_BR/bills.lang b/htdocs/langs/pt_BR/bills.lang index 13cf66753e9..235f2d3088f 100644 --- a/htdocs/langs/pt_BR/bills.lang +++ b/htdocs/langs/pt_BR/bills.lang @@ -242,6 +242,7 @@ CreditNoteDepositUse=O projeto deve ser validado para utilizar este tipo de cré NewGlobalDiscount=Novo Desconto fixo NoteReason=Nota/Motivo ReasonDiscount=Motivo +AddDiscount=Adicionar Desconto AddGlobalDiscount=Adicionar Desconto Fixo DiscountOfferedBy=Acordado por DiscountStillRemaining=Descontos fixos Pendentes diff --git a/htdocs/langs/pt_PT/bills.lang b/htdocs/langs/pt_PT/bills.lang index 92a2ab13db4..a4ff2696960 100644 --- a/htdocs/langs/pt_PT/bills.lang +++ b/htdocs/langs/pt_PT/bills.lang @@ -232,6 +232,7 @@ DiscountFromDeposit=Pagamentos a partir de depósito na factura %s NewGlobalDiscount=Novo Desconto fixo NoteReason=Nota/Motivo ReasonDiscount=Motivo +AddDiscount=Adicionar Desconto AddGlobalDiscount=Adicionar Desconto fixo DiscountOfferedBy=Acordado por DiscountStillRemaining=Descontos fixos Pendentes diff --git a/htdocs/langs/ro_RO/bills.lang b/htdocs/langs/ro_RO/bills.lang index 326ce6f3caf..5b296fa01ca 100644 --- a/htdocs/langs/ro_RO/bills.lang +++ b/htdocs/langs/ro_RO/bills.lang @@ -217,6 +217,7 @@ DiscountFromCreditNote=Reducere de la nota de credit %s NewGlobalDiscount=Noua reducere NoteReason=Notă / Motiv ReasonDiscount=Motiv +AddDiscount=Adauga discount AddGlobalDiscount=Adauga discount DiscountOfferedBy=Acordate de către DiscountStillRemaining=Reducere rămânând diff --git a/htdocs/langs/ru_RU/bills.lang b/htdocs/langs/ru_RU/bills.lang index 0feeb909c42..c1504bebdf5 100644 --- a/htdocs/langs/ru_RU/bills.lang +++ b/htdocs/langs/ru_RU/bills.lang @@ -216,7 +216,6 @@ DiscountFromCreditNote=Скидка из кредитового авизо %s NewGlobalDiscount=Новая фиксированная скидка NoteReason=Примечание / Основание ReasonDiscount=Основание -AddGlobalDiscount=Добавить скидку DiscountOfferedBy=Предоставлена DiscountStillRemaining=Остаток скидки DiscountAlreadyCounted=Скидка уже рассчитана @@ -418,6 +417,7 @@ ShowUnpaidAll=Показать все неоплаченные счета-фак NumberOfBillsByMonth=Кол-во счетов-фактур по месяцам AmountOfBillsByMonthHT=Сумма счетов-фактур за месяц (за вычетом налога) AddDiscount=Создать абсолютную скидку +AddGlobalDiscount=Добавить скидку AddCreditNote=Создать кредитовое авизо ClosePaidInvoicesAutomatically=Классифицировать как 'Оплачен' все полностью оплаченные счета-фактуры. AllCompletelyPayedInvoiceWillBeClosed=Все счета, без остатка к оплате будут автоматически закрыты со статусом "Оплачен". diff --git a/htdocs/langs/sl_SI/bills.lang b/htdocs/langs/sl_SI/bills.lang index b3a2744a7a0..6dc5ec4d18b 100755 --- a/htdocs/langs/sl_SI/bills.lang +++ b/htdocs/langs/sl_SI/bills.lang @@ -247,6 +247,7 @@ NewGlobalDiscount=Nov fiksni popust NewRelativeDiscount=Nov relativni popust NoteReason=Opomba/Razlog ReasonDiscount=Razlog +AddDiscount=Dodaj popust AddGlobalDiscount=Dodaj popust DiscountOfferedBy=Odobril DiscountStillRemaining=Popust še vedno ostaja diff --git a/htdocs/langs/sv_SE/bills.lang b/htdocs/langs/sv_SE/bills.lang index f5f431bbbaa..b5279c4ada1 100755 --- a/htdocs/langs/sv_SE/bills.lang +++ b/htdocs/langs/sv_SE/bills.lang @@ -252,6 +252,7 @@ NewGlobalDiscount=Ny fix rabatt NewRelativeDiscount=Nya relativa rabatt NoteReason=Not / Reason ReasonDiscount=Reason +AddDiscount=Lägg rabatt AddGlobalDiscount=Lägg rabatt DiscountOfferedBy=Beviljats av DiscountStillRemaining=Rabatt återstår fortfarande diff --git a/htdocs/langs/tr_TR/bills.lang b/htdocs/langs/tr_TR/bills.lang index a335c718fda..cf42fab5d0d 100644 --- a/htdocs/langs/tr_TR/bills.lang +++ b/htdocs/langs/tr_TR/bills.lang @@ -253,6 +253,7 @@ NewGlobalDiscount=Yeni düzeltme indirim NewRelativeDiscount=Yeni göreli indirim NoteReason=Not / Nedeni ReasonDiscount=Neden +AddDiscount=Indirimli ekle AddGlobalDiscount=Indirimli ekle DiscountOfferedBy=Tarafından verilen DiscountStillRemaining=Indirimli hareketsiz kalan diff --git a/htdocs/langs/zh_CN/bills.lang b/htdocs/langs/zh_CN/bills.lang index dae7cd3b1f9..ed97643e33d 100644 --- a/htdocs/langs/zh_CN/bills.lang +++ b/htdocs/langs/zh_CN/bills.lang @@ -251,6 +251,7 @@ NewGlobalDiscount=新的修补程序折扣 NewRelativeDiscount=新的相对折扣 NoteReason=备注/原因 ReasonDiscount=原因 +AddDiscount=添加折扣 AddGlobalDiscount=添加折扣 DiscountOfferedBy=获 DiscountStillRemaining=折扣尚存 diff --git a/htdocs/lib/functions.lib.php b/htdocs/lib/functions.lib.php index 4c247872bca..454502c4235 100644 --- a/htdocs/lib/functions.lib.php +++ b/htdocs/lib/functions.lib.php @@ -1625,7 +1625,8 @@ function img_object($alt, $picto, $options='', $pictoisfullpath=0) * Show picto whatever it's its name (generic function) * * @param alt Text on alt and title of image - * @param picto Name of image file to show (If no extension provided, we use '.png'). Image must be stored into img directory. + * @param picto Name of image file to show ('filenew', ...) + * If no extension provided, we use '.png'. Image must be stored into theme/xxx/img directory. * Example: picto.png if picto.png is stored into htdocs/theme/mytheme/img * Example: picto.png@mymodule if picto.png is stored into htdocs/mymodule/img * Example: /mydir/mysubdir/picto.png if picto.png is stored into htdocs/mydir/mysubdir (pictoisfullpath must be set to 1)