diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index be7756e5900..849916222dd 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -1013,14 +1013,14 @@ else print ''.$langs->trans("CalcLocaltax").': '; if($conf->global->MAIN_INFO_LOCALTAX_CALC1==0) { - print $langs->transcountry("CalcLocaltax1",$mysoc->country_code); + print $langs->trans("CalcLocaltax1").' - '.$langs->trans("CalcLocaltax1Desc"); } else if($conf->global->MAIN_INFO_LOCALTAX_CALC1==1) { - print $langs->transcountry("CalcLocaltax2",$mysoc->country_code); + print $langs->trans("CalcLocaltax2").' - '.$langs->trans("CalcLocaltax2Desc"); } else if($conf->global->MAIN_INFO_LOCALTAX_CALC1==2){ - print $langs->transcountry("CalcLocaltax3",$mysoc->country_code); + print $langs->trans("CalcLocaltax3").' - '.$langs->trans("CalcLocaltax3Desc"); } print ''; diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 5198da7efb2..1bd3c9cf655 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -236,7 +236,7 @@ class Categorie extends CommonObject $error=0; dol_syslog(get_class($this).'::create', LOG_DEBUG); - + // Clean parameters $this->label = trim($this->label); $this->description = trim($this->description); @@ -412,7 +412,7 @@ class Categorie extends CommonObject // End call triggers $this->db->commit(); - + return 1; } else @@ -578,12 +578,12 @@ class Categorie extends CommonObject if ($this->id == -1) return -2; // For backward compatibility - if ($type == 'societe') + if ($type == 'societe') { $type = 'customer'; dol_syslog(get_class($this) . "::add_type(): type 'societe' is deprecated, please use 'customer' instead", LOG_WARNING); } - elseif ($type == 'fournisseur') + elseif ($type == 'fournisseur') { $type = 'supplier'; dol_syslog(get_class($this) . "::add_type(): type 'fournisseur' is deprecated, please use 'supplier' instead", LOG_WARNING); @@ -1138,29 +1138,57 @@ class Categorie extends CommonObject * Retourne les chemin de la categorie, avec les noms des categories * separes par $sep (" >> " par defaut) * - * @param string $sep Separator - * @param string $url Url + * @param string $sep Separator + * @param string $url Url + * @param int $nocolor 0 * @return array */ - function print_all_ways($sep = " >> ", $url='') + function print_all_ways($sep = " >> ", $url='', $nocolor=0) { $ways = array(); - foreach ($this->get_all_ways() as $way) + $allways = $this->get_all_ways(); // Load array of categories + foreach ($allways as $way) { $w = array(); + $i = 0; foreach ($way as $cat) { + $i++; + + if (empty($nocolor)) + { + $forced_color='toreplace'; + if ($i == count($way)) + { + // Check contrast with background and correct text color + $forced_color='categtextwhite'; + if ($cat->color) + { + $hex=$cat->color; + $r = hexdec($hex[0].$hex[1]); + $g = hexdec($hex[2].$hex[3]); + $b = hexdec($hex[4].$hex[5]); + $bright = (max($r, $g, $b) + min($r, $g, $b)) / 510.0; // HSL algorithm + if ($bright >= 0.5) $forced_color='categtextblack'; // Higher than 60% + } + } + } + if ($url == '') { - $w[] = "".$cat->label.""; + $link = ''; + $linkend=''; + $w[] = $link.$cat->label.$linkend; } else { $w[] = "".$cat->label.""; } } - $ways[] = implode($sep, $w); + $newcategwithpath = preg_replace('/toreplace/', $forced_color, implode($sep, $w)); + + $ways[] = $newcategwithpath; } return $ways; @@ -1356,6 +1384,7 @@ class Categorie extends CommonObject /** * Return name and link of category (with picto) + * Use ->id, ->ref, ->label, ->color * * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto * @param string $option Sur quoi pointe le lien ('', 'xyz') @@ -1369,7 +1398,19 @@ class Categorie extends CommonObject $result=''; $label=$langs->trans("ShowCategory").': '. ($this->ref?$this->ref:$this->label); - $link = ''; + // Check contrast with background and correct text color + $forced_color='categtextwhite'; + if ($this->color) + { + $hex=$this->color; + $r = hexdec($hex[0].$hex[1]); + $g = hexdec($hex[2].$hex[3]); + $b = hexdec($hex[4].$hex[5]); + $bright = (max($r, $g, $b) + min($r, $g, $b)) / 510.0; // HSL algorithm + if ($bright >= 0.5) $forced_color='categtextblack'; // Higher than 60% + } + + $link = ''; $linkend=''; $picto='category'; diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index 3b5d0b64a86..a1486ff344f 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -189,7 +189,7 @@ print ''; // Path of category print ''; print ''; print ''; print ''; print ''; print ''; - print ''; print ''; $i ++; diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index fc8ee1c30d0..5af984ba659 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -595,13 +595,20 @@ class FormOther */ static function showColor($color, $textifnotdefined='') { + $textcolor='FFF'; + if ($color) + { + $hex=$color; + $r = hexdec($hex[0].$hex[1]); + $g = hexdec($hex[2].$hex[3]); + $b = hexdec($hex[4].$hex[5]); + $bright = (max($r, $g, $b) + min($r, $g, $b)) / 510.0; // HSL algorithm + if ($bright > 0.6) $textcolor='000'; + } + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - $color = colorArrayToHex(colorStringToArray($color,array()),''); - $textcolor='000'; - $tmpcolorweight=0; - foreach(colorStringToArray($color,array()) as $x) $tmpcolorweight+=$x; - if ($tmpcolorweight < 400) $textcolor='FFF'; + if ($color) print ''; else print $textifnotdefined; } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 3b25ffe3809..2538bf9d0b7 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3398,7 +3398,7 @@ function price2num($amount,$rounding='',$alreadysqlnb=0) * Return localtax rate for a particular vat, when selling a product with vat $vatrate, from a $thirdparty_buyer to a $thirdparty_seller * Note: This function applies same rules than get_default_tva * - * @param float $vatrate Vat rate + * @param float $vatrate Vat rate. Can be '8.5' or '8.5 (8.5NPR)' for example * @param int $local Local tax to search and return (1 or 2 return only tax rate 1 or tax rate 2) * @param Societe $thirdparty_buyer Object of buying third party * @param Societe $thirdparty_seller Object of selling third party @@ -3589,7 +3589,7 @@ function get_localtax_by_third($local) * Instead this function must be called when adding a line to get the array of localtax and type, and then * provide it to the function calcul_price_total. * - * @param float $vatrate VAT Rate + * @param float $vatrate VAT Rate. Value can be '8.5' or '8.5 (8.5NPR)'. * @param int $local Number of localtax (1 or 2, or 0 to return 1 & 2) * @param Societe $buyer Company object * @param Societe $seller Company object @@ -3740,7 +3740,7 @@ function get_product_vat_for_country($idprod, $thirdparty_seller, $idprodfournpr } else dol_print_error($db); } - else $ret=$conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS; + else $ret=$conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS; // Forced value if autodetect fails } dol_syslog("get_product_vat_for_country: ret=".$ret); diff --git a/htdocs/core/lib/price.lib.php b/htdocs/core/lib/price.lib.php index 4d7803474d8..52653fa7f4d 100644 --- a/htdocs/core/lib/price.lib.php +++ b/htdocs/core/lib/price.lib.php @@ -47,7 +47,7 @@ * @param int $info_bits Miscellaneous informations on line * @param int $type 0/1=Product/service * @param Societe $seller Thirdparty seller (we need $seller->country_id property). Provided only if seller is the supplier, otherwise $seller will be $mysoc. - * @param array $localtaxes_array Array with localtaxes info (loaded by getLocalTaxesFromRate(vatrate, 0, ...) function). + * @param array $localtaxes_array Array with localtaxes info array('0'=>type1,'1'=>rate1,'2'=>type2,'3'=>rate2) (loaded by getLocalTaxesFromRate(vatrate, 0, ...) function). * @param integer $progress Situation invoices progress (value from 0 to 100, 100 by default) * @param double $multicurrency_tx Currency rate (1 by default) * @return result[ 0=total_ht, @@ -117,7 +117,7 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt $localtax2_type = $localtaxes_array[2]; $localtax2_rate = $localtaxes_array[3]; } - else // deprecated method. values and type for localtaxes must be provided by caller and loade with getLocalTaxesFromRate + else // deprecated method. values and type for localtaxes must be provided by caller and loaded with getLocalTaxesFromRate { $sql = "SELECT taux, localtax1, localtax2, localtax1_type, localtax2_type"; $sql.= " FROM ".MAIN_DB_PREFIX."c_tva as cv"; diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php index 40a4fb104cb..1d3114f8819 100644 --- a/htdocs/core/lib/product.lib.php +++ b/htdocs/core/lib/product.lib.php @@ -101,7 +101,7 @@ function product_prepare_head($object) $head[$h][2] = 'stats'; $h++; - $head[$h][0] = DOL_URL_ROOT."/product/stats/facture.php?id=".$object->id; + $head[$h][0] = DOL_URL_ROOT."/product/stats/facture.php?showmessage=1&id=".$object->id; $head[$h][1] = $langs->trans('Referers'); $head[$h][2] = 'referers'; $h++; @@ -203,22 +203,25 @@ function product_admin_prepare_head() * * @param Product $product Product object * @param int $socid Thirdparty id - * @return integer + * @return integer NB of lines shown into array */ function show_stats_for_company($product,$socid) { global $conf,$langs,$user,$db; + $nblines = 0; + print ''; print ''; print ''; - print ''; + print ''; print ''; print ''; // Propals if (! empty($conf->propal->enabled) && $user->rights->propale->lire) { + $nblines++; $ret=$product->load_stats_propale($socid); if ($ret < 0) dol_print_error($db); $langs->load("propal"); @@ -236,6 +239,7 @@ function show_stats_for_company($product,$socid) // Commandes clients if (! empty($conf->commande->enabled) && $user->rights->commande->lire) { + $nblines++; $ret=$product->load_stats_commande($socid); if ($ret < 0) dol_print_error($db); $langs->load("orders"); @@ -253,6 +257,7 @@ function show_stats_for_company($product,$socid) // Commandes fournisseurs if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande->lire) { + $nblines++; $ret=$product->load_stats_commande_fournisseur($socid); if ($ret < 0) dol_print_error($db); $langs->load("orders"); @@ -270,6 +275,7 @@ function show_stats_for_company($product,$socid) // Contrats if (! empty($conf->contrat->enabled) && $user->rights->contrat->lire) { + $nblines++; $ret=$product->load_stats_contrat($socid); if ($ret < 0) dol_print_error($db); $langs->load("contracts"); @@ -287,6 +293,7 @@ function show_stats_for_company($product,$socid) // Factures clients if (! empty($conf->facture->enabled) && $user->rights->facture->lire) { + $nblines++; $ret=$product->load_stats_facture($socid); if ($ret < 0) dol_print_error($db); $langs->load("bills"); @@ -304,6 +311,7 @@ function show_stats_for_company($product,$socid) // Factures fournisseurs if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) { + $nblines++; $ret=$product->load_stats_facture_fournisseur($socid); if ($ret < 0) dol_print_error($db); $langs->load("bills"); @@ -319,7 +327,7 @@ function show_stats_for_company($product,$socid) print ''; } - return 0; + return $nblines++; } diff --git a/htdocs/core/menus/init_menu_auguria.sql b/htdocs/core/menus/init_menu_auguria.sql index 48463ee99eb..b578168cd24 100644 --- a/htdocs/core/menus/init_menu_auguria.sql +++ b/htdocs/core/menus/init_menu_auguria.sql @@ -114,7 +114,7 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->stock->enabled', __HANDLER__, 'left', 3102__+MAX_llx_menu__, 'products', '', 3100__+MAX_llx_menu__, '/product/stock/list.php', 'List', 1, 'stocks', '$user->rights->stock->lire', '', 2, 1, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->stock->enabled', __HANDLER__, 'left', 3104__+MAX_llx_menu__, 'products', '', 3100__+MAX_llx_menu__, '/product/stock/mouvement.php', 'Movements', 1, 'stocks', '$user->rights->stock->mouvement->lire', '', 2, 3, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->stock->enabled && $conf->supplier_order->enabled', __HANDLER__, 'left', 3105__+MAX_llx_menu__, 'products', '', 3100__+MAX_llx_menu__, '/product/stock/replenish.php', 'Replenishments', 1, 'stocks', '$user->rights->stock->mouvement->creer && $user->rights->fournisseur->lire', '', 2, 4, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->stock->enabled', __HANDLER__, 'left', 3106__+MAX_llx_menu__, 'products', '', 3100__+MAX_llx_menu__, '/product/stock/massstockmove.php', 'StockTransfer', 1, 'stocks', '$user->rights->stock->mouvement->creer', '', 2, 5, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->stock->enabled', __HANDLER__, 'left', 3106__+MAX_llx_menu__, 'products', '', 3100__+MAX_llx_menu__, '/product/stock/massstockmove.php', 'MassStockTransferShort', 1, 'stocks', '$user->rights->stock->mouvement->creer', '', 2, 5, __ENTITY__); -- Product - Categories insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->categorie->enabled', __HANDLER__, 'left', 3200__+MAX_llx_menu__, 'products', 'cat', 3__+MAX_llx_menu__, '/categories/index.php?leftmenu=cat&type=0', 'Categories', 0, 'categories', '$user->rights->categorie->lire', '', 2, 4, __ENTITY__); @@ -222,9 +222,9 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left -- Journals -- insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2420__+MAX_llx_menu__, 'accountancy', 'journal', 2400__+MAX_llx_menu__, '/accountancy/journal/index.php?leftmenu=journal', 'Journaux', 1, 'accountancy', '$user->rights->accounting->comptarapport->lire', '', 0, 7, __ENTITY__); -- General Ledger - insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2430__+MAX_llx_menu__, 'accountancy', 'bookkeeping', 2400__+MAX_llx_menu__, '/accountancy/bookkeeping/list.php?leftmenu=bookkeeping', 'Bookkeeping', 1, 'accountancy', '$user->rights->accounting->mouvements->lire', '', 0, 15, __ENTITY__); - insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="bookkeeping"', __HANDLER__, 'left', 2431__+MAX_llx_menu__, 'accountancy', '', 2430__+MAX_llx_menu__, '/accountancy/bookkeeping/listbyyear.php', 'ByYear', 2, 'accountancy', '$user->rights->accounting->mouvements->lire', '', 0, 16, __ENTITY__); - insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="bookkeeping"', __HANDLER__, 'left', 2432__+MAX_llx_menu__, 'accountancy', '', 2430__+MAX_llx_menu__, '/accountancy/bookkeeping/balancebymonth.php', 'AccountBalanceByMonth', 2, 'accountancy', '$user->rights->accounting->mouvements->lire', '', 0, 16, __ENTITY__); + insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2430__+MAX_llx_menu__, 'accountancy', 'bookkeeping', 2400__+MAX_llx_menu__, '/accountancy/bookkeeping/list.php', 'Bookkeeping', 1, 'accountancy', '$user->rights->accounting->mouvements->lire', '', 0, 15, __ENTITY__); + -- Balance + insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2435__+MAX_llx_menu__, 'accountancy', 'balance', 2400__+MAX_llx_menu__, '/accountancy/bookkeeping/balance.php', 'AccountBalance', 1, 'accountancy', '$user->rights->accounting->mouvements->lire', '', 0, 16, __ENTITY__); -- Reports insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2440__+MAX_llx_menu__, 'accountancy', 'report', 2400__+MAX_llx_menu__, '/compta/resultat/index.php?leftmenu=ca&mainmenu=accountancy', 'Reportings', 1, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 17, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="ca"', __HANDLER__, 'left', 2441__+MAX_llx_menu__, 'accountancy', '', 2440__+MAX_llx_menu__, '/compta/resultat/index.php?leftmenu=ca', 'ReportInOut', 2, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 18, __ENTITY__); diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 6a6e0304e7e..a849d9ac40a 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -976,10 +976,10 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu } // General Ledger - if (preg_match('/accountancy/',$leftmenu)) $newmenu->add("/accountancy/bookkeeping/list.php?leftmenu=accountancy_bookkeeping",$langs->trans("Bookkeeping"),1,$user->rights->accounting->mouvements->lire, '', $mainmenu, 'bookkeeping'); - if (preg_match('/accountancy_bookkeeping/',$leftmenu)) $newmenu->add("/accountancy/bookkeeping/balance.php?leftmenu=accountancy_bookkeeping",$langs->trans("AccountBalance"),2,$user->rights->accounting->mouvements->lire); - if (preg_match('/accountancy_bookkeeping/',$leftmenu)) $newmenu->add("/accountancy/bookkeeping/listbyyear.php?leftmenu=accountancy_bookkeeping",$langs->trans("ByYear"),2,$user->rights->accounting->mouvements->lire); - if (preg_match('/accountancy_bookkeeping/',$leftmenu)) $newmenu->add("/accountancy/bookkeeping/balancebymonth.php?leftmenu=accountancy_bookkeeping",$langs->trans("AccountBalanceByMonth"),2,$user->rights->accounting->mouvements->lire); + $newmenu->add("/accountancy/bookkeeping/list.php",$langs->trans("Bookkeeping"),1,$user->rights->accounting->mouvements->lire); + + // Balance + $newmenu->add("/accountancy/bookkeeping/balance.php",$langs->trans("AccountBalance"),1,$user->rights->accounting->mouvements->lire); // Reports $langs->load("compta"); @@ -1140,8 +1140,9 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu $newmenu->add("/product/stock/card.php?action=create", $langs->trans("MenuNewWarehouse"), 1, $user->rights->stock->creer); $newmenu->add("/product/stock/list.php", $langs->trans("List"), 1, $user->rights->stock->lire); $newmenu->add("/product/stock/mouvement.php", $langs->trans("Movements"), 1, $user->rights->stock->mouvement->lire); + if ($conf->supplier_order->enabled) $newmenu->add("/product/stock/replenish.php", $langs->trans("Replenishment"), 1, $user->rights->stock->mouvement->creer && $user->rights->fournisseur->lire); - $newmenu->add("/product/stock/massstockmove.php", $langs->trans("StockTransfer"), 1, $user->rights->stock->mouvement->creer); + $newmenu->add("/product/stock/massstockmove.php", $langs->trans("MassStockTransferShort"), 1, $user->rights->stock->mouvement->creer); } // Expeditions diff --git a/htdocs/core/modules/rapport/pdf_paiement.class.php b/htdocs/core/modules/rapport/pdf_paiement.class.php index 83bbb0a59b4..cc47c9570a6 100644 --- a/htdocs/core/modules/rapport/pdf_paiement.class.php +++ b/htdocs/core/modules/rapport/pdf_paiement.class.php @@ -146,10 +146,11 @@ class pdf_paiement $num=0; $lines=array(); - // count number of ligne of payement + // count number of lines of payment $sql = "SELECT p.rowid as prowid"; $sql.= " FROM ".MAIN_DB_PREFIX."paiement as p"; $sql.= " WHERE p.datep BETWEEN '".$this->db->idate(dol_get_first_day($year,$month))."' AND '".$this->db->idate(dol_get_last_day($year,$month))."'"; + $sql.= " AND p.entity = " . $conf->entity; $result = $this->db->query($sql); if ($result) { @@ -160,19 +161,23 @@ class pdf_paiement $sql = "SELECT p.datep as dp, f.facnumber"; //$sql .= ", c.libelle as paiement_type, p.num_paiement"; $sql.= ", c.code as paiement_code, p.num_paiement"; - $sql.= ", p.amount as paiement_amount, f.total_ttc as facture_amount "; - $sql.= ", pf.amount as pf_amount , ba.ref as bankaccount "; + $sql.= ", p.amount as paiement_amount, f.total_ttc as facture_amount"; + $sql.= ", pf.amount as pf_amount"; + if (! empty($conf->banque->enabled)) + $sql.= ", ba.ref as bankaccount"; $sql.= ", p.rowid as prowid"; $sql.= " FROM ".MAIN_DB_PREFIX."paiement as p, ".MAIN_DB_PREFIX."facture as f,"; $sql.= " ".MAIN_DB_PREFIX."c_paiement as c, ".MAIN_DB_PREFIX."paiement_facture as pf,"; - $sql.= " ".MAIN_DB_PREFIX."bank as b, ".MAIN_DB_PREFIX."bank_account as ba,"; + if (! empty($conf->banque->enabled)) + $sql.= " ".MAIN_DB_PREFIX."bank as b, ".MAIN_DB_PREFIX."bank_account as ba,"; $sql.= " ".MAIN_DB_PREFIX."societe as s"; if (! $user->rights->societe->client->voir && ! $socid) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } $sql.= " WHERE f.fk_soc = s.rowid AND pf.fk_facture = f.rowid AND pf.fk_paiement = p.rowid"; - $sql.= " AND p.fk_bank = b.rowid AND b.fk_account = ba.rowid "; + if (! empty($conf->banque->enabled)) + $sql.= " AND p.fk_bank = b.rowid AND b.fk_account = ba.rowid "; $sql.= " AND f.entity = ".$conf->entity; $sql.= " AND p.fk_paiement = c.id "; $sql.= " AND p.datep BETWEEN '".$this->db->idate(dol_get_first_day($year,$month))."' AND '".$this->db->idate(dol_get_last_day($year,$month))."'"; diff --git a/htdocs/expedition/tpl/linkedobjectblock.tpl.php b/htdocs/expedition/tpl/linkedobjectblock.tpl.php index f18ed1ea80f..aea4127b50a 100644 --- a/htdocs/expedition/tpl/linkedobjectblock.tpl.php +++ b/htdocs/expedition/tpl/linkedobjectblock.tpl.php @@ -74,7 +74,7 @@ foreach($linkedObjectBlock as $key => $objectlink) +-->
'; -$ways = $object->print_all_ways(); +$ways = $object->print_all_ways(" >> ", '', 1); print $langs->trans("Ref").''; print ''.$langs->trans("Root").' >> '; foreach ($ways as $way) diff --git a/htdocs/comm/multiprix.php b/htdocs/comm/multiprix.php index fbaf00e53db..7510c0a5b96 100644 --- a/htdocs/comm/multiprix.php +++ b/htdocs/comm/multiprix.php @@ -84,12 +84,12 @@ if ($_socid > 0) if ($objsoc->client == 1) $tabchoice='customer'; if ($objsoc->client == 2) $tabchoice='prospect'; - dol_fiche_head($head, $tabchoice, $langs->trans("ThirdParty"), 0, 'company'); - - print '
'; print ''; print ''; + + dol_fiche_head($head, $tabchoice, $langs->trans("ThirdParty"), 0, 'company'); + print ''; print ''; print ''; print ''; print ''; print ''; print ''; - print ''; print ''; $i ++; } print '
'; print ''; @@ -121,12 +121,14 @@ if ($_socid > 0) print ""; print "
"; - print '

'; + dol_fiche_end(); + + print '
'; print ""; - print "\n"; - print '
'; + + print '

'; /* diff --git a/htdocs/compta/charges/index.php b/htdocs/compta/charges/index.php index 3b38cb10e9c..1a0760d1fd3 100644 --- a/htdocs/compta/charges/index.php +++ b/htdocs/compta/charges/index.php @@ -2,7 +2,7 @@ /* Copyright (C) 2001-2003 Rodolphe Quiedeville * Copyright (C) 2004-2014 Laurent Destailleur * Copyright (C) 2005-2010 Regis Houssin - * Copyright (C) 2011-2014 Alexandre Spangaro + * Copyright (C) 2011-2016 Alexandre Spangaro * Copyright (C) 2011-2014 Juanjo Menent * Copyright (C) 2015 Jean-François Ferry * @@ -104,8 +104,7 @@ if ($mode != 'sconly') print "
"; } - -if ($conf->tax->enabled) +if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) { // Social contributions only if ($mode != 'sconly') @@ -216,7 +215,7 @@ if ($conf->tax->enabled) } // VAT -if ($conf->tax->enabled) +if (! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) { if (! $mode || $mode != 'sconly') { @@ -399,16 +398,16 @@ while($j<$numlt) } - // Payment Salary -if ($conf->salaries->enabled) +if (! empty($conf->salaries->enabled) && $user->rights->salaries->read) { if (! $mode || $mode != 'sconly') { $sal = new PaymentSalary($db); - print '
'; - print load_fiche_titre($langs->trans("SalariesPayments").($year?' ('.$langs->trans("Year").' '.$year.')':''), '', ''); + print "
"; + + print_fiche_titre($langs->trans("SalariesPayments").($year?' ('.$langs->trans("Year").' '.$year.')':''), '', ''); $sql = "SELECT s.rowid, s.amount, s.label, s.datep as datep, s.datev as datev, s.datesp, s.dateep, s.salary, u.salary as current_salary"; $sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as s, ".MAIN_DB_PREFIX."user as u"; diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 32c0c1156b7..6fe648b375f 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -343,7 +343,7 @@ if (empty($reshook)) } } - $object->oldcopy = clone$object; + $object->oldcopy = clone $object; $object->old_lastname = GETPOST("old_lastname"); $object->old_firstname = GETPOST("old_firstname"); diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index fc0e960f168..defc9a88e3f 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -5206,17 +5206,18 @@ class Form print '
'; print ''; + print '' . $objp->ref . '' . $objp->ref_client . '' . price($objp->total_ht) . '' . $objp->name . '
'; print '
     
'; + print ''; $this->db->free($resqlorderlist); } else { @@ -5333,11 +5334,11 @@ class Form print '
'; print ''; + print '' . $objp->ref . '' . $objp->ref_supplier . '' . price($objp->total_ht) . '' . $objp->name . '
'.$langs->trans("Referers").''.$langs->trans("NbOfThirdParties").''.$langs->trans("NbOfReferers").''.$langs->trans("NbOfObjectReferers").''.$langs->trans("TotalQuantity").'
- --> - + diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 273d947c6e7..06b2f8372a6 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -4,7 +4,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2007 Franky Van Liedekerke * Copyright (C) 2010-2014 Juanjo Menent - * Copyright (C) 2010-2014 Philippe Grand + * Copyright (C) 2010-2016 Philippe Grand * Copyright (C) 2012-2015 Marcos García * Copyright (C) 2013 Florian Henry * Copyright (C) 2013 Cédric Salvador @@ -53,7 +53,7 @@ class CommandeFournisseur extends CommonOrder var $id; /** - * Supplier invoice reference + * Supplier order reference * @var string */ var $ref; @@ -103,7 +103,7 @@ class CommandeFournisseur extends CommonOrder var $user_approve_id; var $user_approve_id2; // Used when SUPPLIER_ORDER_DOUBLE_APPROVAL is set - //Incorterms + //Incoterms var $fk_incoterms; var $location_incoterms; var $libelle_incoterms; //Used into tooltip @@ -114,7 +114,7 @@ class CommandeFournisseur extends CommonOrder * @var CommandeFournisseurLigne[] */ public $lines = array(); - //Ajout pour supplier_proposal + //Add for supplier_proposal var $origin; var $origin_id; var $linked_objects=array(); @@ -260,7 +260,7 @@ class CommandeFournisseur extends CommonOrder $this->db->free($resql); - // Retreive all extrafield + // Retrieve all extrafields // fetch optionals attributes and labels require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'); $extrafields=new ExtraFields($this->db); @@ -416,7 +416,7 @@ class CommandeFournisseur extends CommonOrder { $this->db->begin(); - // Definition du nom de modele de numerotation de commande + // Definition of supplier order numbering model name $soc = new Societe($this->db); $soc->fetch($this->fourn_id); @@ -461,7 +461,7 @@ class CommandeFournisseur extends CommonOrder // Rename directory if dir was a temporary ref if (preg_match('/^[\(]?PROV/i', $this->ref)) { - // On renomme repertoire ($this->ref = ancienne ref, $num = nouvelle ref) + // We rename directory ($this->ref = ancienne ref, $num = nouvelle ref) // in order not to lose the attached files $oldref = dol_sanitizeFileName($this->ref); $newref = dol_sanitizeFileName($num); @@ -644,8 +644,8 @@ class CommandeFournisseur extends CommonOrder /** - * Renvoie la reference de commande suivante non utilisee en fonction du modele - * de numerotation actif defini dans COMMANDE_SUPPLIER_ADDON_NUMBER + * Returns the following order reference not used depending on the numbering model activated + * defined within COMMANDE_SUPPLIER_ADDON_NUMBER * * @param Societe $soc objet societe * @return string reference libre pour la facture diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php index 80e584efc4d..124693ed6da 100644 --- a/htdocs/fourn/facture/paiement.php +++ b/htdocs/fourn/facture/paiement.php @@ -527,7 +527,7 @@ if (empty($action)) $paramlist.=($search_payment_num?"&search_payment_num=".urlencode($search_payment_num):""); if ($optioncss != '') $paramlist.='&optioncss='.urlencode($optioncss); - print_barre_liste($langs->trans('SupplierPayments'), $page, $_SERVER["PHP_SELF"],$paramlist,$sortfield,$sortorder,'',$num); + print_barre_liste($langs->trans('SupplierPayments'), $page, $_SERVER["PHP_SELF"],$paramlist,$sortfield,$sortorder,'',$num, 0, 'title_accountancy.png'); print '
'; if ($optioncss != '') print ''; diff --git a/htdocs/install/mysql/migration/3.8.0-3.9.0.sql b/htdocs/install/mysql/migration/3.8.0-3.9.0.sql index c55654a0873..034d2765fbc 100644 --- a/htdocs/install/mysql/migration/3.8.0-3.9.0.sql +++ b/htdocs/install/mysql/migration/3.8.0-3.9.0.sql @@ -26,6 +26,16 @@ ALTER TABLE llx_don ADD COLUMN fk_country integer NOT NULL DEFAULT 0 after country; +ALTER TABLE llx_product ADD COLUMN localtax1_type varchar(10) NOT NULL DEFAULT '0' after localtax1_tx; +ALTER TABLE llx_product ADD COLUMN localtax2_type varchar(10) NOT NULL DEFAULT '0' after localtax2_tx; +ALTER TABLE llx_product_price ADD COLUMN localtax1_type varchar(10) NOT NULL DEFAULT '0' after localtax1_tx; +ALTER TABLE llx_product_price ADD COLUMN localtax2_type varchar(10) NOT NULL DEFAULT '0' after localtax2_tx; +ALTER TABLE llx_product_customer_price ADD COLUMN localtax1_type varchar(10) NOT NULL DEFAULT '0' after localtax1_tx; +ALTER TABLE llx_product_customer_price ADD COLUMN localtax2_type varchar(10) NOT NULL DEFAULT '0' after localtax2_tx; +ALTER TABLE llx_product_customer_price_log ADD COLUMN localtax1_type varchar(10) NOT NULL DEFAULT '0' after localtax1_tx; +ALTER TABLE llx_product_customer_price_log ADD COLUMN localtax2_type varchar(10) NOT NULL DEFAULT '0' after localtax2_tx; + + UPDATE llx_user set api_key = null where api_key = ''; diff --git a/htdocs/install/mysql/tables/llx_product.sql b/htdocs/install/mysql/tables/llx_product.sql index f42f18b8e46..1f7b7da3c0d 100755 --- a/htdocs/install/mysql/tables/llx_product.sql +++ b/htdocs/install/mysql/tables/llx_product.sql @@ -46,8 +46,10 @@ create table llx_product cost_price double(24,8) DEFAULT NULL, -- Cost price without tax. Can be used for margin calculation. tva_tx double(6,3), -- Default VAT rate of product recuperableonly integer NOT NULL DEFAULT '0', -- French NPR VAT - localtax1_tx double(6,3) DEFAULT 0, -- Spanish local VAT 1 - localtax2_tx double(6,3) DEFAULT 0, -- Spanish local VAT 2 + localtax1_tx double(6,3) DEFAULT 0, -- + localtax1_type varchar(10) NOT NULL DEFAULT '0', -- + localtax2_tx double(6,3) DEFAULT 0, -- + localtax2_type varchar(10) NOT NULL DEFAULT '0', -- fk_user_author integer DEFAULT NULL, -- user making creation fk_user_modif integer, -- user making last change tosell tinyint DEFAULT 1, -- Product you sell diff --git a/htdocs/install/mysql/tables/llx_product_customer_price.sql b/htdocs/install/mysql/tables/llx_product_customer_price.sql index 0dd37358682..8098ae5f028 100644 --- a/htdocs/install/mysql/tables/llx_product_customer_price.sql +++ b/htdocs/install/mysql/tables/llx_product_customer_price.sql @@ -36,7 +36,9 @@ create table llx_product_customer_price tva_tx double(6,3), recuperableonly integer NOT NULL DEFAULT '0', -- Other NPR VAT localtax1_tx double(6,3) DEFAULT 0, -- Other local VAT 1 + localtax1_type varchar(10) NOT NULL DEFAULT '0', localtax2_tx double(6,3) DEFAULT 0, -- Other local VAT 2 + localtax2_type varchar(10) NOT NULL DEFAULT '0', fk_user integer, import_key varchar(14) -- Import key )ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_product_customer_price_log.sql b/htdocs/install/mysql/tables/llx_product_customer_price_log.sql index b25bd982aab..699060cdc98 100644 --- a/htdocs/install/mysql/tables/llx_product_customer_price_log.sql +++ b/htdocs/install/mysql/tables/llx_product_customer_price_log.sql @@ -21,7 +21,7 @@ create table llx_product_customer_price_log ( rowid integer AUTO_INCREMENT PRIMARY KEY, - entity integer DEFAULT 1 NOT NULL, -- multi company id + entity integer DEFAULT 1 NOT NULL, -- multi company id datec datetime, fk_product integer NOT NULL, fk_soc integer NOT NULL, @@ -33,7 +33,9 @@ create table llx_product_customer_price_log tva_tx double(6,3), recuperableonly integer NOT NULL DEFAULT '0', -- Other NPR VAT localtax1_tx double(6,3) DEFAULT 0, -- Other local VAT 1 + localtax1_type varchar(10) NOT NULL DEFAULT '0', localtax2_tx double(6,3) DEFAULT 0, -- Other local VAT 2 + localtax2_type varchar(10) NOT NULL DEFAULT '0', fk_user integer, import_key varchar(14) -- Import key )ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_product_price.sql b/htdocs/install/mysql/tables/llx_product_price.sql index b101b8b0250..9c3869f1e35 100755 --- a/htdocs/install/mysql/tables/llx_product_price.sql +++ b/htdocs/install/mysql/tables/llx_product_price.sql @@ -34,7 +34,9 @@ create table llx_product_price tva_tx double(6,3) NOT NULL, recuperableonly integer NOT NULL DEFAULT '0', localtax1_tx double(6,3) DEFAULT 0, + localtax1_type varchar(10) NOT NULL DEFAULT '0', localtax2_tx double(6,3) DEFAULT 0, + localtax2_type varchar(10) NOT NULL DEFAULT '0', fk_user_author integer, tosell tinyint DEFAULT 1, price_by_qty integer NOT NULL DEFAULT 0, diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index 383adb93f47..d0d13aa35fc 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -47,7 +47,7 @@ UpdateAccount=Modification of an accounting account UpdateMvts=Modification of a movement WriteBookKeeping=Record accounts in general ledger Bookkeeping=General ledger -AccountBalanceByMonth=Account balance by month +AccountBalance=Account balance AccountingVentilation=Breakdown accounting AccountingVentilationSupplier=Breakdown accounting supplier diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index a24b608a955..d7ba4a29678 100755 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1666,7 +1666,7 @@ BackupDumpWizard=Wizard to build database backup dump file SomethingMakeInstallFromWebNotPossible=Installation of external module is not possible from the web interface for the following reason: SomethingMakeInstallFromWebNotPossible2=For this reason, process to upgrade described here is only manual steps a privileged user can do. InstallModuleFromWebHasBeenDisabledByFile=Install of external module from application has been disabled by your administrator. You must ask him to remove the file %s to allow this feature. -ConfFileMuseContainCustom=Installing an external module from application save the module files into directory %s. To have this directory processed by Dolibarr, you must setup your conf/conf.php to have option
- $dolibarr_main_url_root_alt enabled to value $dolibarr_main_url_root_alt="/custom"
- $dolibarr_main_document_root_alt enabled to value "%s/custom" +ConfFileMuseContainCustom=Installing an external module from application save the module files into directory %s. To have this directory processed by Dolibarr, you must setup your conf/conf.php to have option
$dolibarr_main_url_root_alt='/custom';
$dolibarr_main_document_root_alt='%s/custom'; HighlightLinesOnMouseHover=Highlight table lines when mouse move passes over HighlightLinesColor=Highlight color of the line when the mouse passes over (keep empty for no highlight) TextTitleColor=Color of page title diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 219ab597f38..e5f7e54e191 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -545,6 +545,7 @@ NbOfCustomers=Number of customers NbOfLines=Number of lines NbOfObjects=Number of objects NbOfReferers=Number of referrers +NbOfObjectReferers=Number of refering objects Referers=Refering objects TotalQuantity=Total quantity DateFromTo=From %s to %s diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang index bf223e0e33e..b00701a6314 100644 --- a/htdocs/langs/en_US/products.lang +++ b/htdocs/langs/en_US/products.lang @@ -317,3 +317,4 @@ DefaultPriceRealPriceMayDependOnCustomer=Default price, real price may depend on WarningSelectOneDocument=Please select at least one document DefaultUnitToShow=Unit NbOfQtyInProposals=Qty in proposals +ClinkOnALinkOfColumn=Click on a link of column %s to get a detailed view... diff --git a/htdocs/langs/en_US/stocks.lang b/htdocs/langs/en_US/stocks.lang index 943e988b2f7..e6b9f82730c 100644 --- a/htdocs/langs/en_US/stocks.lang +++ b/htdocs/langs/en_US/stocks.lang @@ -34,7 +34,8 @@ LastMovements=Last movements Units=Units Unit=Unit StockCorrection=Correct stock -StockTransfer=Stock movement +StockTransfer=Transfer stock +MassStockTransferShort=Mass stock transfer StockMovement=Stock movement StockMovements=Stock movements LabelMovement=Movement label diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 721f3c38759..c725d2c4420 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -101,10 +101,12 @@ class Product extends CommonObject var $tva_tx; //! French VAT NPR (0 or 1) var $tva_npr=0; - //! Spanish local taxes + //! Other local taxes var $localtax1_tx; var $localtax2_tx; - + var $localtax1_type; + var $localtax2_type; + //! Stock var $stock_reel; //! Cost price @@ -296,7 +298,9 @@ class Product extends CommonObject //Local taxes if (empty($this->localtax1_tx)) $this->localtax1_tx = 0; if (empty($this->localtax2_tx)) $this->localtax2_tx = 0; - + if (empty($this->localtax1_type)) $this->localtax1_type = '0'; + if (empty($this->localtax2_type)) $this->localtax2_type = '0'; + if (empty($this->price)) $this->price = 0; if (empty($this->price_min)) $this->price_min = 0; @@ -633,6 +637,8 @@ class Product extends CommonObject if (empty($this->tva_npr)) $this->tva_npr = 0; if (empty($this->localtax1_tx)) $this->localtax1_tx = 0; if (empty($this->localtax2_tx)) $this->localtax2_tx = 0; + if (empty($this->localtax1_type)) $this->localtax1_type = '0'; + if (empty($this->localtax2_type)) $this->localtax2_type = '0'; if (empty($this->status)) $this->status = 0; if (empty($this->status_buy)) $this->status_buy = 0; @@ -700,7 +706,9 @@ class Product extends CommonObject $sql.= ", recuperableonly = " . $this->tva_npr; $sql.= ", localtax1_tx = " . $this->localtax1_tx; $sql.= ", localtax2_tx = " . $this->localtax2_tx; - + $sql.= ", localtax1_type = " . ($this->localtax1_type!=''?"'".$this->localtax1_type."'":"'0'"); + $sql.= ", localtax2_type = " . ($this->localtax2_type!=''?"'".$this->localtax2_type."'":"'0'"); + $sql.= ", barcode = ". (empty($this->barcode)?"null":"'".$this->db->escape($this->barcode)."'"); $sql.= ", fk_barcode_type = ". (empty($this->barcode_type)?"null":$this->db->escape($this->barcode_type)); @@ -1218,10 +1226,10 @@ class Product extends CommonObject if (empty($this->price_by_qty)) $this->price_by_qty=0; // Add new price - $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_price(price_level,date_price,fk_product,fk_user_author,price,price_ttc,price_base_type,tosell,tva_tx,recuperableonly,"; - $sql.= " localtax1_tx, localtax2_tx, price_min,price_min_ttc,price_by_qty,entity,fk_price_expression) "; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_price(price_level,date_price,fk_product,fk_user_author,price,price_ttc,price_base_type,tosell, tva_tx, recuperableonly,"; + $sql.= " localtax1_tx, localtax2_tx, localtax1_type, localtax2_type, price_min,price_min_ttc,price_by_qty,entity,fk_price_expression) "; $sql.= " VALUES(".($level?$level:1).", '".$this->db->idate($now)."',".$this->id.",".$user->id.",".$this->price.",".$this->price_ttc.",'".$this->price_base_type."',".$this->status.",".$this->tva_tx.",".$this->tva_npr.","; - $sql.= " ".$this->localtax1_tx.",".$this->localtax2_tx.",".$this->price_min.",".$this->price_min_ttc.",".$this->price_by_qty.",".$conf->entity.",".($this->fk_price_expression > 0?$this->fk_price_expression:'null'); + $sql.= " ".$this->localtax1_tx.", ".$this->localtax2_tx.", '".$this->localtax1_type."', '".$this->localtax2_type."', ".$this->price_min.",".$this->price_min_ttc.",".$this->price_by_qty.",".$conf->entity.",".($this->fk_price_expression > 0?$this->fk_price_expression:'null'); $sql.= ")"; dol_syslog(get_class($this)."::_log_price", LOG_DEBUG); @@ -1386,15 +1394,16 @@ class Product extends CommonObject * @param double $newprice New price * @param string $newpricebase HT or TTC * @param User $user Object user that make change - * @param double $newvat New VAT Rate + * @param double $newvat New VAT Rate (For example 8.5. Should not be a string) * @param double $newminprice New price min * @param int $level 0=standard, >0 = level if multilevel prices * @param int $newnpr 0=Standard vat rate, 1=Special vat rate for French NPR VAT * @param int $newpsq 1 if it has price by quantity * @param int $ignore_autogen Used to avoid infinite loops - * @return int <0 if KO, >0 if OK + * @param array $localtaxes_array Array with localtaxes info array('0'=>type1,'1'=>rate1,'2'=>type2,'3'=>rate2) (loaded by getLocalTaxesFromRate(vatrate, 0, ...) function). + * @return int <0 if KO, >0 if OK */ - function updatePrice($newprice, $newpricebase, $user, $newvat='',$newminprice='', $level=0, $newnpr=0, $newpsq=0, $ignore_autogen=0) + function updatePrice($newprice, $newpricebase, $user, $newvat='',$newminprice='', $level=0, $newnpr=0, $newpsq=0, $ignore_autogen=0, $localtaxes_array=array()) { global $conf,$langs; @@ -1463,13 +1472,23 @@ class Product extends CommonObject } //print 'x'.$id.'-'.$newprice.'-'.$newpricebase.'-'.$price.'-'.$price_ttc.'-'.$price_min.'-'.$price_min_ttc; - - //Local taxes - $localtax1=get_localtax($newvat,1); - $localtax2=get_localtax($newvat,2); + if (count($localtaxes_array) > 0) + { + $localtaxtype1=$localtaxes_array['0']; + $localtax1=$localtaxes_array['1']; + $localtaxtype2=$localtaxes_array['2']; + $localtax2=$localtaxes_array['3']; + } + else // old method. deprecated because ot can't retreive type + { + $localtaxtype1='0'; + $localtax1=get_localtax($newvat,1); + $localtaxtype2='0'; + $localtax2=get_localtax($newvat,2); + } if (empty($localtax1)) $localtax1=0; // If = '' then = 0 if (empty($localtax2)) $localtax2=0; // If = '' then = 0 - + $this->db->begin(); // Ne pas mettre de quote sur les numeriques decimaux. @@ -1482,6 +1501,8 @@ class Product extends CommonObject $sql.= " price_min_ttc=".$price_min_ttc.","; $sql.= " localtax1_tx=".($localtax1>=0?$localtax1:'NULL').","; $sql.= " localtax2_tx=".($localtax2>=0?$localtax2:'NULL').","; + $sql.= " localtax1_type=".($localtaxtype1!=''?"'".$localtaxtype1."'":"'0'").","; + $sql.= " localtax2_type=".($localtaxtype2!=''?"'".$localtaxtype2."'":"'0'").","; $sql.= " tva_tx='".price2num($newvat)."',"; $sql.= " recuperableonly='".$newnpr."'"; $sql.= " WHERE rowid = ".$id; @@ -1508,7 +1529,9 @@ class Product extends CommonObject //Local taxes $this->localtax1_tx = $localtax1; $this->localtax2_tx = $localtax2; - + $this->localtax1_type = $localtaxtype1; + $this->localtax2_type = $localtaxtype2; + // Price by quantity $this->price_by_qty = $newpsq; @@ -1579,12 +1602,12 @@ class Product extends CommonObject } $sql = "SELECT rowid, ref, ref_ext, label, description, url, note, customcode, fk_country, price, price_ttc,"; - $sql.= " price_min, price_min_ttc, price_base_type, cost_price, tva_tx, recuperableonly as tva_npr, localtax1_tx, localtax2_tx, tosell,"; + $sql.= " price_min, price_min_ttc, price_base_type, cost_price, tva_tx, recuperableonly as tva_npr, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type, tosell,"; $sql.= " tobuy, fk_product_type, duration, seuil_stock_alerte, canvas,"; $sql.= " weight, weight_units, length, length_units, surface, surface_units, volume, volume_units, barcode, fk_barcode_type, finished,"; $sql.= " accountancy_code_buy, accountancy_code_sell, stock, pmp,"; - $sql.= " datec, tms, import_key, entity, desiredstock, tobatch, fk_unit"; - $sql.= " , fk_price_expression, price_autogen"; + $sql.= " datec, tms, import_key, entity, desiredstock, tobatch, fk_unit,"; + $sql.= " fk_price_expression, price_autogen"; $sql.= " FROM ".MAIN_DB_PREFIX."product"; if ($id) $sql.= " WHERE rowid = ".$this->db->escape($id); else @@ -1626,10 +1649,12 @@ class Product extends CommonObject $this->tva_tx = $obj->tva_tx; //! French VAT NPR $this->tva_npr = $obj->tva_npr; - //! Spanish local taxes + //! Local taxes $this->localtax1_tx = $obj->localtax1_tx; $this->localtax2_tx = $obj->localtax2_tx; - + $this->localtax1_type = $obj->localtax1_type; + $this->localtax2_type = $obj->localtax2_type; + $this->finished = $obj->finished; $this->duration = $obj->duration; $this->duration_value = substr($obj->duration,0,dol_strlen($obj->duration)-1); diff --git a/htdocs/product/class/productcustomerprice.class.php b/htdocs/product/class/productcustomerprice.class.php index 41eb7ffb2c5..fd36c55dcf9 100644 --- a/htdocs/product/class/productcustomerprice.class.php +++ b/htdocs/product/class/productcustomerprice.class.php @@ -42,7 +42,9 @@ class Productcustomerprice extends CommonObject var $price_base_type; var $tva_tx; var $recuperableonly; + var $localtax1_type; var $localtax1_tx; + var $localtax2_type; var $localtax2_tx; var $fk_user; var $lines = array (); @@ -150,7 +152,9 @@ class Productcustomerprice extends CommonObject $sql .= "price_base_type,"; $sql .= "tva_tx,"; $sql .= "recuperableonly,"; + $sql .= "localtax1_type,"; $sql .= "localtax1_tx,"; + $sql .= "localtax2_type,"; $sql .= "localtax2_tx,"; $sql .= "fk_user,"; $sql .= "import_key"; @@ -168,7 +172,9 @@ class Productcustomerprice extends CommonObject $sql .= " " . (! isset($this->price_base_type) ? 'NULL' : "'" . $this->db->escape($this->price_base_type) . "'") . ","; $sql .= " " . (! isset($this->tva_tx) ? 'NULL' : "'" . $this->tva_tx . "'") . ","; $sql .= " " . (! isset($this->recuperableonly) ? 'NULL' : "'" . $this->recuperableonly . "'") . ","; + $sql .= " " . (empty($this->localtax1_type) ? "'0'" : "'" . $this->localtax1_type . "'") . ","; $sql .= " " . (! isset($this->localtax1_tx) ? 'NULL' : "'" . $this->localtax1_tx . "'") . ","; + $sql .= " " . (empty($this->localtax2_type) ? "'0'" : "'" . $this->localtax2_type . "'") . ","; $sql .= " " . (! isset($this->localtax2_tx) ? 'NULL' : "'" . $this->localtax2_tx . "'") . ","; $sql .= " " . $user->id . ","; $sql .= " " . (! isset($this->import_key) ? 'NULL' : "'" . $this->db->escape($this->import_key) . "'") . ""; @@ -593,6 +599,8 @@ class Productcustomerprice extends CommonObject $sql .= "recuperableonly,"; $sql .= "localtax1_tx,"; $sql .= "localtax2_tx,"; + $sql .= "localtax1_type,"; + $sql .= "localtax2_type,"; $sql .= "fk_user,"; $sql .= "import_key"; @@ -612,6 +620,8 @@ class Productcustomerprice extends CommonObject $sql .= " t.recuperableonly,"; $sql .= " t.localtax1_tx,"; $sql .= " t.localtax2_tx,"; + $sql .= " t.localtax1_type,"; + $sql .= " t.localtax2_type,"; $sql .= " t.fk_user,"; $sql .= " t.import_key"; @@ -643,6 +653,8 @@ class Productcustomerprice extends CommonObject $sql .= " recuperableonly=" . (isset($this->recuperableonly) ? $this->recuperableonly : "null") . ","; $sql .= " localtax1_tx=" . (isset($this->localtax1_tx) ? $this->localtax1_tx : "null") . ","; $sql .= " localtax2_tx=" . (isset($this->localtax2_tx) ? $this->localtax2_tx : "null") . ","; + $sql .= " localtax1_type=" . (! empty($this->localtax1_type) ? "'".$this->localtax1_type."'": "'0'") . ","; + $sql .= " localtax2_type=" . (! empty($this->localtax2_type) ? "'".$this->localtax2_type."'": "'0'") . ","; $sql .= " fk_user=" . $user->id . ","; $sql .= " import_key=" . (isset($this->import_key) ? "'" . $this->db->escape($this->import_key) . "'" : "null") . ""; diff --git a/htdocs/product/price.php b/htdocs/product/price.php index 5537de7480f..c9023447307 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -94,7 +94,43 @@ if (empty($reshook)) if (($action == 'update_vat') && !$cancel && ($user->rights->produit->creer || $user->rights->service->creer)) { - $object->tva_tx = GETPOST('tva_tx'); + $tva_tx_txt = GETPOST('tva_tx', 'alpha'); // tva_tx can be '8.5' or '8.5*' or '8.5 + + $tva_tx_txt; + + // We must define tva_tx, npr and local taxes + $tva_tx = preg_replace('/[^0-9\.].*$/', '', $tva_tx_txt); // keep remove all after the numbers and dot + $npr = preg_match('/\*/', $tva_tx_txt) ? 1 : 0; + $localtax1 = 0; $localtax2 = 0; $localtax1_type = '0'; $localtax2_type = '0'; + // If value contains the unique code of vat line (new recommanded method), we use it to find npr and local taxes + if (preg_match('/\((.*)\)/', $tva_tx_txt, $reg)) + { + // We look into database using code + $vatratecode=$reg[1]; + // Get record from code + $sql = "SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type"; + $sql.= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c"; + $sql.= " WHERE t.fk_pays = c.rowid AND c.code = '".$mysoc->country_code."'"; + $sql.= " AND t.taux = ".((float) $tva_tx)." AND t.active = 1"; + $sql.= " AND t.code ='".$vatratecode."'"; + $resql=$db->query($sql); + if ($resql) + { + $obj = $db->fetch_object($resql); + $npr = $obj->recuperableonly; + $localtax1 = $obj->localtax1; + $localtax2 = $obj->localtax2; + $localtax1_type = $obj->localtax1_type; + $localtax2_type = $obj->localtax2_type; + } + } + + $object->tva_tx = $tva_tx; + $object->tva_npr = $npr; + $object->localtax1_tx = $localtax1; + $object->localtax2_tx = $localtax2; + $object->localtax1_type = $localtax1_type; + $object->localtax2_type = $localtax2_type; $db->begin(); @@ -106,7 +142,7 @@ if (empty($reshook)) if ($error) { - $object->updatePrice($newprice, $newpricebase, $user, $newvat, $newprice_min, $level, $newnpr, $newpsq); + $object->updatePrice($newprice, $newpricebase, $user, $newvat, $newprice_min, $level, $newnpr, $newpsq); // FIXME Bug $newvat and $newnpr not defined } if (! $error) @@ -145,31 +181,41 @@ if (empty($reshook)) } // Multiprices - if (!$error && !empty($conf->global->PRODUIT_MULTIPRICES)) { + if (! $error && ! empty($conf->global->PRODUIT_MULTIPRICES)) { $newprice = GETPOST('price', 'array'); $newprice_min = GETPOST('price_min', 'array'); $newpricebase = GETPOST('multiprices_base_type', 'array'); $newvattx = GETPOST('tva_tx', 'array'); + $newvatnpr = GETPOST('tva_npr', 'array'); + $newlocaltax1_tx = GETPOST('localtax1_tx', 'array'); + $newlocaltax1_type = GETPOST('localtax1_type', 'array'); + $newlocaltax2_tx = GETPOST('localtax2_tx', 'array'); + $newlocaltax2_type = GETPOST('localtax2_type', 'array'); //Shall we generate prices using price rules? $object->price_autogen = GETPOST('usePriceRules') == 'on' ? true : false; - for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i ++) { - + for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i ++) + { if (!isset($newprice[$i])) { continue; } - $newnpr = (preg_match('/\*/', $newvattx[$i] ? 1 : 0)); - $newvat = str_replace('*', '', $newvattx[$i]); - + $tva_tx_txt = $newvattx[$i]; + $npr = $newvatnpr[$i]; + $localtax1 = $newlocaltax1_tx[$i]; + $localtax1_type = $newlocaltax1_type[$i]; + $localtax2 = $newlocaltax2_tx[$i]; + $localtax2_type = $newlocaltax2_type[$i]; + $pricestoupdate[$i] = array( 'price' => $newprice[$i], 'price_min' => $newprice_min[$i], 'price_base_type' => $newpricebase[$i], - 'vat_tx' => $newvat, - 'npr' => $newnpr + 'vat_tx' => $tva_tx, + 'npr' => $npr, + 'localtaxes_array' => array('0'=>$localtax1_type, '1'=>$localtax1, '2'=>$localtax2_type, '3'=>$localtax2) ); //If autogeneration is enabled, then we only set the first level @@ -178,12 +224,41 @@ if (empty($reshook)) } } } else { + $tva_tx_txt = GETPOST('tva_tx', 'alpha'); // tva_tx can be '8.5' , '8.5*', '8.5 (8.5NPR) *' for example. + + // We must define tva_tx, npr and local taxes + $tva_tx = preg_replace('/[^0-9\.].*$/', '', $tva_tx_txt); // keep remove all after the numbers and dot + $npr = preg_match('/\*/', $tva_tx_txt) ? 1 : 0; + $localtax1 = 0; $localtax2 = 0; $localtax1_type = '0'; $localtax2_type = '0'; + // If value contains the unique code of vat line (new recommanded method), we use it to find npr and local taxes + if (preg_match('/\((.*)\)/', $tva_tx_txt, $reg)) + { + // We look into database using code + $vatratecode=$reg[1]; + // Get record from code + $sql = "SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type"; + $sql.= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c"; + $sql.= " WHERE t.fk_pays = c.rowid AND c.code = '".$mysoc->country_code."'"; + $sql.= " AND t.taux = ".((float) $tva_tx)." AND t.active = 1"; + $sql.= " AND t.code ='".$vatratecode."'"; + $resql=$db->query($sql); + if ($resql) + { + $obj = $db->fetch_object($resql); + $npr = $obj->recuperableonly; + $localtax1 = $obj->localtax1; + $localtax2 = $obj->localtax2; + $localtax1_type = $obj->localtax1_type; + $localtax2_type = $obj->localtax2_type; + } + } $pricestoupdate[0] = array( - 'price' => $_POST ["price"], - 'price_min' => $_POST ["price_min"], - 'price_base_type' => $_POST ["price_base_type"], - 'vat_tx' => str_replace('*', '', $_POST ["tva_tx"]), - 'npr' => preg_match('/\*/', $_POST ["tva_tx"]) ? 1 : 0 + 'price' => $_POST["price"], + 'price_min' => $_POST["price_min"], + 'price_base_type' => $_POST["price_base_type"], + 'vat_tx' => $tva_tx, + 'npr' => $npr, + 'localtaxes_array' => array('0'=>$localtax1_type, '1'=>$localtax1, '2'=>$localtax2_type, '3'=>$localtax2) ); } @@ -207,7 +282,7 @@ if (empty($reshook)) break; } - $res = $object->updatePrice($newprice, $val['price_base_type'], $user, $val['vat_tx'], $newprice_min, $key, $val['npr'], $psq); + $res = $object->updatePrice($newprice, $val['price_base_type'], $user, $val['vat_tx'], $newprice_min, $key, $val['npr'], $psq, 0, $val['localtaxes_array']); if ($res < 0) { $error ++; @@ -344,9 +419,43 @@ if (empty($reshook)) $prodcustprice->price = price2num(GETPOST("price"), 'MU'); $prodcustprice->price_min = price2num(GETPOST("price_min"), 'MU'); $prodcustprice->price_base_type = GETPOST("price_base_type", 'alpha'); - $prodcustprice->tva_tx = str_replace('*', '', GETPOST("tva_tx")); - $prodcustprice->recuperableonly = (preg_match('/\*/', GETPOST("tva_tx")) ? 1 : 0); + $tva_tx_txt = GETPOST("tva_tx"); + + // We must define tva_tx, npr and local taxes + $tva_tx = preg_replace('/[^0-9\.].*$/', '', $tva_tx_txt); // keep remove all after the numbers and dot + $npr = preg_match('/\*/', $tva_tx_txt) ? 1 : 0; + $localtax1 = 0; $localtax2 = 0; $localtax1_type = '0'; $localtax2_type = '0'; + // If value contains the unique code of vat line (new recommanded method), we use it to find npr and local taxes + if (preg_match('/\((.*)\)/', $tva_tx_txt, $reg)) + { + // We look into database using code + $vatratecode=$reg[1]; + // Get record from code + $sql = "SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type"; + $sql.= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c"; + $sql.= " WHERE t.fk_pays = c.rowid AND c.code = '".$mysoc->country_code."'"; + $sql.= " AND t.taux = ".((float) $tva_tx)." AND t.active = 1"; + $sql.= " AND t.code ='".$vatratecode."'"; + $resql=$db->query($sql); + if ($resql) + { + $obj = $db->fetch_object($resql); + $npr = $obj->recuperableonly; + $localtax1 = $obj->localtax1; + $localtax2 = $obj->localtax2; + $localtax1_type = $obj->localtax1_type; + $localtax2_type = $obj->localtax2_type; + } + } + + $prodcustprice->tva_tx = $tva_tx; + $prodcustprice->recuperableonly = $npr; + $prodcustprice->localtax1_tx = $localtax1; + $prodcustprice->localtax2_tx = $localtax2; + $prodcustprice->localtax1_type = $localtax1_type; + $prodcustprice->localtax2_type = $localtax2_type; + if (! ($prodcustprice->fk_soc > 0)) { $langs->load("errors"); @@ -383,9 +492,9 @@ if (empty($reshook)) $result = $prodcustprice->delete($user); if ($result < 0) { - setEventMessages($prodcustprice->error, $prodcustprice->errors, 'mesgs'); + setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors'); } else { - setEventMessages($langs->trans('RecordDeleted'), null, 'errors'); + setEventMessages($langs->trans('RecordDeleted'), null, 'mesgs'); } $action = ''; } @@ -402,9 +511,43 @@ if (empty($reshook)) $prodcustprice->price = price2num(GETPOST("price"), 'MU'); $prodcustprice->price_min = price2num(GETPOST("price_min"), 'MU'); $prodcustprice->price_base_type = GETPOST("price_base_type", 'alpha'); - $prodcustprice->tva_tx = str_replace('*', '', GETPOST("tva_tx")); - $prodcustprice->recuperableonly = (preg_match('/\*/', GETPOST("tva_tx")) ? 1 : 0); - + + $tva_tx_txt = GETPOST("tva_tx"); + + // We must define tva_tx, npr and local taxes + $tva_tx = preg_replace('/[^0-9\.].*$/', '', $tva_tx_txt); // keep remove all after the numbers and dot + $npr = preg_match('/\*/', $tva_tx_txt) ? 1 : 0; + $localtax1 = 0; $localtax2 = 0; $localtax1_type = '0'; $localtax2_type = '0'; + // If value contains the unique code of vat line (new recommanded method), we use it to find npr and local taxes + if (preg_match('/\((.*)\)/', $tva_tx_txt, $reg)) + { + // We look into database using code + $vatratecode=$reg[1]; + // Get record from code + $sql = "SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type"; + $sql.= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c"; + $sql.= " WHERE t.fk_pays = c.rowid AND c.code = '".$mysoc->country_code."'"; + $sql.= " AND t.taux = ".((float) $tva_tx)." AND t.active = 1"; + $sql.= " AND t.code ='".$vatratecode."'"; + $resql=$db->query($sql); + if ($resql) + { + $obj = $db->fetch_object($resql); + $npr = $obj->recuperableonly; + $localtax1 = $obj->localtax1; + $localtax2 = $obj->localtax2; + $localtax1_type = $obj->localtax1_type; + $localtax2_type = $obj->localtax2_type; + } + } + + $prodcustprice->tva_tx = $tva_tx; + $prodcustprice->recuperableonly = $npr; + $prodcustprice->localtax1_tx = $localtax1; + $prodcustprice->localtax2_tx = $localtax2; + $prodcustprice->localtax1_type = $localtax1_type; + $prodcustprice->localtax2_type = $localtax2_type; + if ($prodcustprice->price_min<$maxpricesupplier && !empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE)) { setEventMessages($langs->trans("MinimumPriceLimit",price($maxpricesupplier,0,'',1,-1,-1,'auto')), null, 'errors'); @@ -792,7 +935,7 @@ if ($action == 'edit_vat' && ($user->rights->produit->creer || $user->rights->se // VAT print '' . $langs->trans("VATRate") . ''; - print $form->load_tva("tva_tx", $object->tva_tx, $mysoc, '', $object->id, $object->tva_npr); + print $form->load_tva("tva_tx", $object->tva_tx, $mysoc, '', $object->id, $object->tva_npr, $object->type, false, 1); print ''; print ''; @@ -825,7 +968,7 @@ if ($action == 'edit_price' && $object->getRights()->creer) // VAT print '' . $langs->trans("VATRate") . ''; - print $form->load_tva("tva_tx", $object->tva_tx, $mysoc, '', $object->id, $object->tva_npr); + print $form->load_tva("tva_tx", $object->tva_tx, $mysoc, '', $object->id, $object->tva_npr, $object->type, false, 1); print ''; // Price base @@ -981,11 +1124,16 @@ if ($action == 'edit_price' && $object->getRights()->creer) // VAT if (empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) { - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; } else { // This option is kept for backward compatibility but has no sense print ''; - print $form->load_tva("tva_tx[" . $i.']', $object->multiprices_tva_tx[$i], $mysoc, '', $object->id); + print $form->load_tva("tva_tx[" . $i.']', $object->multiprices_tva_tx[$i], $mysoc, '', $object->id, false, $object->type, false, 1); print ''; } @@ -1205,7 +1353,7 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) // VAT print '' . $langs->trans("VATRate") . ''; - print $form->load_tva("tva_tx", $object->tva_tx, $mysoc, '', $object->id, $object->tva_npr); + print $form->load_tva("tva_tx", $object->tva_tx, $mysoc, '', $object->id, $object->tva_npr, $object->type, false, 1); print ''; // Price base @@ -1289,7 +1437,7 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) // VAT print '' . $langs->trans("VATRate") . ''; - print $form->load_tva("tva_tx", $prodcustprice->tva_tx, $mysoc, '', $object->id, $prodcustprice->recuperableonly); + print $form->load_tva("tva_tx", $prodcustprice->tva_tx, $mysoc, '', $object->id, $prodcustprice->recuperableonly, $object->type, false, 1); print ''; // Price base diff --git a/htdocs/product/stats/facture.php b/htdocs/product/stats/facture.php index 590830702bb..57c426dc3a1 100644 --- a/htdocs/product/stats/facture.php +++ b/htdocs/product/stats/facture.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2010 Laurent Destailleur + * Copyright (C) 2004-2016 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2014 Juanjo Menent * Copyright (C) 2014 Florian Henry @@ -48,7 +48,7 @@ $result=restrictedArea($user,'produit|service',$fieldvalue,'product&product','', // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array $hookmanager->initHooks(array('productstatsinvoice')); -$mesg = ''; +$showmessage=GETPOST('showmessage'); $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); @@ -67,6 +67,8 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) { $search_year=''; } + + /* * View */ @@ -107,7 +109,7 @@ if ($id > 0 || ! empty($ref)) print '
'; print ''; - show_stats_for_company($product,$socid); + $nboflines = show_stats_for_company($product,$socid); print "
"; @@ -116,8 +118,11 @@ if ($id > 0 || ! empty($ref)) dol_fiche_end(); - - if ($user->rights->facture->lire) + if ($showmessage && $nboflines > 1) + { + print $langs->trans("ClinkOnALinkOfColumn", $langs->transnoentitiesnoconv("Referers")); + } + elseif ($user->rights->facture->lire) { $sql = "SELECT DISTINCT s.nom as name, s.rowid as socid, s.code_client,"; $sql.= " f.facnumber, f.datef, f.paye, f.fk_statut as statut, f.rowid as facid,"; diff --git a/htdocs/product/stock/massstockmove.php b/htdocs/product/stock/massstockmove.php index 652ec947a37..7d62699b425 100644 --- a/htdocs/product/stock/massstockmove.php +++ b/htdocs/product/stock/massstockmove.php @@ -325,7 +325,7 @@ $title = $langs->trans('MassMovement'); llxHeader('', $title); -print load_fiche_titre($langs->trans("MassStockMovement")); +print load_fiche_titre($langs->trans("MassStockTransferShort")); $titletoadd=$langs->trans("Select"); $titletoaddnoent=$langs->transnoentitiesnoconv("Select"); diff --git a/htdocs/product/stock/mouvement.php b/htdocs/product/stock/mouvement.php index 32edd0b4e9d..190bf676c8a 100644 --- a/htdocs/product/stock/mouvement.php +++ b/htdocs/product/stock/mouvement.php @@ -54,16 +54,18 @@ $search_warehouse = trim(GETPOST("search_warehouse")); $search_inventorycode = trim(GETPOST("search_inventorycode")); $search_user = trim(GETPOST("search_user")); $search_batch = trim(GETPOST("search_batch")); + $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; $page = GETPOST("page",'int'); $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); if ($page < 0) $page = 0; $offset = $limit * $page; - if (! $sortfield) $sortfield="m.datem"; if (! $sortorder) $sortorder="DESC"; +$pdluoid=GETPOST('pdluoid','int'); + if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers { $year=''; @@ -152,6 +154,171 @@ if ($action == "correct_stock") if (! $error) $action=''; } +// Transfer stock from a warehouse to another warehouse +if ($action == "transfert_stock" && ! $cancel) +{ + $product = new Product($db); + if (! empty($product_id)) $result=$product->fetch($product_id); + + if (! (GETPOST("id_entrepot_destination",'int') > 0)) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Warehouse")), null, 'errors'); + $error++; + $action='transfert'; + } + if (empty($product_id)) + { + $error++; + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Product")), null, 'errors'); + $action='transfert'; + } + if (! GETPOST("nbpiece",'int')) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NumberOfUnit")), null, 'errors'); + $error++; + $action='transfert'; + } + if ($id == GETPOST("id_entrepot_destination",'int')) + { + setEventMessages($langs->trans("ErrorSrcAndTargetWarehouseMustDiffers"), null, 'errors'); + $error++; + $action='transfert'; + } + + if (! empty($conf->productbatch->enabled)) + { + $product = new Product($db); + $result=$product->fetch($product_id); + + if ($product->hasbatch() && ! GETPOST("batch_number")) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("batch_number")), null, 'errors'); + $error++; + $action='transfert'; + } + } + + if (! $error) + { + if ($id) + { + $object = new Entrepot($db); + $result=$object->fetch($id); + + $db->begin(); + + $product->load_stock(); // Load array product->stock_warehouse + + // Define value of products moved + $pricesrc=0; + //if (isset($product->stock_warehouse[GETPOST("id_entrepot_source")]->pmp)) $pricesrc=$product->stock_warehouse[GETPOST("id_entrepot_source")]->pmp; + if (isset($product->pmp)) $pricesrc=$product->pmp; + $pricedest=$pricesrc; + + if ($product->hasbatch()) + { + $pdluo = new Productbatch($db); + + if ($pdluoid > 0) + { + $result=$pdluo->fetch($pdluoid); + if ($result) + { + $srcwarehouseid=$pdluo->warehouseid; + $batch=$pdluo->batch; + $eatby=$pdluo->eatby; + $sellby=$pdluo->sellby; + } + else + { + setEventMessages($pdluo->error, $pdluo->errors, 'errors'); + $error++; + } + } + else + { + $srcwarehouseid=$id; + $batch=GETPOST('batch_number'); + $eatby=$d_eatby; + $sellby=$d_sellby; + } + + if (! $error) + { + // Remove stock + $result1=$product->correct_stock_batch( + $user, + $srcwarehouseid, + GETPOST("nbpiece",'int'), + 1, + GETPOST("label",'san_alpha'), + $pricesrc, + $eatby,$sellby,$batch, + GETPOST('inventorycode') + ); + // Add stock + $result2=$product->correct_stock_batch( + $user, + GETPOST("id_entrepot_destination",'int'), + GETPOST("nbpiece",'int'), + 0, + GETPOST("label",'san_alpha'), + $pricedest, + $eatby,$sellby,$batch, + GETPOST('inventorycode') + ); + } + } + else + { + // Remove stock + $result1=$product->correct_stock( + $user, + $id, + GETPOST("nbpiece"), + 1, + GETPOST("label"), + $pricesrc, + GETPOST('inventorycode') + ); + + // Add stock + $result2=$product->correct_stock( + $user, + GETPOST("id_entrepot_destination"), + GETPOST("nbpiece"), + 0, + GETPOST("label"), + $pricedest, + GETPOST('inventorycode') + ); + } + if (! $error && $result1 >= 0 && $result2 >= 0) + { + $db->commit(); + + if ($backtopage) + { + header("Location: ".$backtopage); + exit; + } + else + { + header("Location: mouvement.php?id=".$object->id); + exit; + } + } + else + { + setEventMessages($product->error, $product->errors, 'errors'); + $db->rollback(); + $action='transfert'; + } + } + } +} + + /* * View @@ -451,7 +618,7 @@ if ($resql) /* */ /* ************************************************************************** */ - if (empty($action) && $id) + if (empty($action) && $id > 0) { print "
\n"; @@ -460,16 +627,17 @@ if ($resql) print ''.$langs->trans("StockCorrection").''; } - /*if ($user->rights->stock->mouvement->creer) + if ($user->rights->stock->mouvement->creer) { - print ''.$langs->trans("StockMovement").''; - }*/ + print ''.$langs->trans("StockTransfer").''; + } + print '

'; } $param=''; - if ($id) $param.='&id='.$id; + if ($id > 0) $param.='&id='.$id; if ($search_movement) $param.='&search_movement='.urlencode($search_movement); if ($search_inventorycode) $param.='&search_inventorycode='.urlencode($search_inventorycode); if ($search_product_ref) $param.='&search_product_ref='.urlencode($search_product_ref); @@ -479,11 +647,11 @@ if ($resql) if (!empty($snom)) $param.='&snom='.urlencode($snom); // FIXME $snom is not defined if ($search_user) $param.='&search_user='.urlencode($search_user); if ($idproduct > 0) $param.='&idproduct='.$idproduct; - if ($id) print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder,'',$num, $nbtotalofrecords,''); + if ($id > 0) print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder,'',$num, $nbtotalofrecords,''); else print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder,'',$num, $nbtotalofrecords); print ''; - if ($id) print ''; + if ($id > 0) print ''; print ''; print ""; @@ -498,7 +666,7 @@ if ($resql) print_liste_field_titre($langs->trans("l_eatby"),$_SERVER["PHP_SELF"],'m.eatby','',$param,'align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("l_sellby"),$_SERVER["PHP_SELF"],'m.sellby','',$param,'align="center"',$sortfield,$sortorder); } - print_liste_field_titre($langs->trans("Warehouse"),$_SERVER["PHP_SELF"], "","",$param,"",$sortfield,$sortorder); // We are on a specific warehouse card, no filter on other should be possible + if (! $id > 0) print_liste_field_titre($langs->trans("Warehouse"),$_SERVER["PHP_SELF"], "","",$param,"",$sortfield,$sortorder); // We are on a specific warehouse card, no filter on other should be possible print_liste_field_titre($langs->trans("Author"),$_SERVER["PHP_SELF"], "m.fk_user_author","",$param,"",$sortfield,$sortorder); print_liste_field_titre($langs->trans("InventoryCodeShort"),$_SERVER["PHP_SELF"], "m.inventorycode","",$param,"",$sortfield,$sortorder); print_liste_field_titre($langs->trans("LabelMovement"),$_SERVER["PHP_SELF"], "m.label","",$param,"",$sortfield,$sortorder); @@ -532,9 +700,12 @@ if ($resql) print ''; } // Warehouse - print ''; + if (! $id > 0) + { + print ''; + } // Author print ''; - print ''; - print ''; + print ''; + print ''; + print ''; } // Warehouse - print '\n"; + if (! $id > 0) + { + print '\n"; + } // Author print ''; // Serial / Eat-by date - if ((! empty($conf->productbatch->enabled)) && is_object($product) && $product->hasbatch()) + if (! empty($conf->productbatch->enabled) && + (($object->element == 'product' && $object->hasbatch()) + || ($object->element == 'stock')) + ) { print ''; - print ''; print ''; @@ -101,7 +104,7 @@ } // Label of mouvement of id of inventory - $valformovementlabel=((GETPOST("label") && (GETPOST('label') != $langs->trans("MovementCorrectStock",''))) ? GETPOST("label") : $langs->trans("MovementCorrectStock", $product->ref)); + $valformovementlabel=((GETPOST("label") && (GETPOST('label') != $langs->trans("MovementCorrectStock",''))) ? GETPOST("label") : $langs->trans("MovementCorrectStock", $productref)); print ''; print ''; print '
'; - print ''; - print ''; + print ''; + print ''; print ''; @@ -598,17 +769,20 @@ if ($resql) // Batch if (! empty($conf->productbatch->enabled)) { - print ''.$objp->batch.''. dol_print_date($objp->eatby,'day') .''. dol_print_date($objp->sellby,'day') .''.$objp->batch.''. dol_print_date($objp->eatby,'day') .''. dol_print_date($objp->sellby,'day') .''; - $warehousestatic->id=$objp->entrepot_id; - $warehousestatic->libelle=$objp->stock; - $warehousestatic->lieu=$objp->lieu; - print $warehousestatic->getNomUrl(1); - print "'; + $warehousestatic->id=$objp->entrepot_id; + $warehousestatic->libelle=$objp->stock; + $warehousestatic->lieu=$objp->lieu; + print $warehousestatic->getNomUrl(1); + print "'; $userstatic->id=$objp->fk_user_author; diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index ba083cc1527..5b26f215adb 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -648,7 +648,7 @@ if (empty($action) && $object->id) //if (($user->rights->stock->mouvement->creer) && ! $object->hasbatch()) if ($user->rights->stock->mouvement->creer) { - print ''.$langs->trans("StockMovement").''; + print ''.$langs->trans("StockTransfer").''; } print ''; @@ -753,7 +753,7 @@ if ($resql) { print "\n".'
'; print img_picto($langs->trans("Tranfer"),'uparrow','class="hideonsmartphone"').' '; - print 'id.'">'.$langs->trans("StockMovement").''; + print 'id.'">'.$langs->trans("StockTransfer").''; // Disabled, because edition of stock content must use the "Correct stock menu". // Do not use this, or data will be wrong (bad tracking of movement label, inventory code, ... //print 'id.'#'.$pdluo->id.'">'; diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index d29ee366bb0..c31699a12ef 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -372,6 +372,8 @@ $head[1][1] = $langs->trans("ReplenishmentOrders"); $head[1][2] = 'replenishorders'; +print load_fiche_titre($langs->trans('Replenishment'), '', 'title_generic.png'); + print ''. ''. @@ -382,7 +384,7 @@ print '' ''. ''; -dol_fiche_head($head, 'replenish', $langs->trans('Replenishment'), 0, 'stock'); +dol_fiche_head($head, 'replenish', '', 0, ''); print $langs->trans("ReplenishmentStatusDesc").'
'."\n"; if ($usevirtualstock == 1) diff --git a/htdocs/product/stock/replenishorders.php b/htdocs/product/stock/replenishorders.php index 303180c2cb7..785760ef511 100644 --- a/htdocs/product/stock/replenishorders.php +++ b/htdocs/product/stock/replenishorders.php @@ -52,6 +52,8 @@ $texte = $langs->trans('ReplenishmentOrders'); llxHeader('', $texte, $helpurl, ''); +print load_fiche_titre($langs->trans('Replenishment'), '', 'title_generic.png'); + $head = array(); $head[0][0] = DOL_URL_ROOT.'/product/stock/replenish.php'; $head[0][1] = $langs->trans('Status'); @@ -60,7 +62,7 @@ $head[1][0] = DOL_URL_ROOT.'/product/stock/replenishorders.php'; $head[1][1] = $texte; $head[1][2] = 'replenishorders'; -dol_fiche_head($head, 'replenishorders', $langs->trans('Replenishment'), 0, 'stock'); +dol_fiche_head($head, 'replenishorders', '', 0, ''); $commandestatic = new CommandeFournisseur($db); $sref = GETPOST('search_ref', 'alpha'); diff --git a/htdocs/product/stock/tpl/stockcorrection.tpl.php b/htdocs/product/stock/tpl/stockcorrection.tpl.php index 90a7468a351..d9f02781fd5 100644 --- a/htdocs/product/stock/tpl/stockcorrection.tpl.php +++ b/htdocs/product/stock/tpl/stockcorrection.tpl.php @@ -15,13 +15,13 @@ * along with this program. If not, see . * * $object must be defined - * $product can be defined */ ?> element == 'product') $productref = $object->ref; $langs->load("productbatch"); @@ -81,10 +81,13 @@ print '
'.$langs->trans("batch_number").''; + print 'element == 'stock'?'': ' class="fieldrequired"').'>'.$langs->trans("batch_number").''; print ''; print '
'.$langs->trans("MovementLabel").''; diff --git a/htdocs/product/stock/tpl/stocktransfer.tpl.php b/htdocs/product/stock/tpl/stocktransfer.tpl.php index 0f13a5452da..1c0448192f1 100644 --- a/htdocs/product/stock/tpl/stocktransfer.tpl.php +++ b/htdocs/product/stock/tpl/stocktransfer.tpl.php @@ -14,17 +14,20 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . * - * $product must be defined + * $object must be defined * $backtopage */ ?> element == 'product') $productref = $object->ref; $langs->load("productbatch"); + if (empty($id)) $id = $object->id; + $pdluoid=GETPOST('pdluoid','int'); $pdluo = new Productbatch($db); @@ -44,7 +47,7 @@ print load_fiche_titre($langs->trans("StockTransfer"),'','title_generic.png'); - print ''."\n"; + print ''."\n"; print ''; print ''; print ''; @@ -54,28 +57,37 @@ } print ''; + // Source warehouse or product print ''; - print ''; + print ''; } - else + if ($object->element == 'stock') { - print $formproduct->selectWarehouses((GETPOST("dwid")?GETPOST("dwid",'int'):(GETPOST('id_entrepot_source')?GETPOST('id_entrepot_source','int'):'ifone')),'id_entrepot_source','',1); + print ''; + print ''; } - print ''; + print ''; print ''; print ''; - // Eat-by date - if ((! empty($conf->productbatch->enabled)) && $product->hasbatch()) + // Serial / Eat-by date + if (! empty($conf->productbatch->enabled) && + (($object->element == 'product' && $object->hasbatch()) + || ($object->element == 'stock')) + ) { print ''; - print ''; print ''; @@ -90,7 +102,7 @@ } // Label - $valformovementlabel=(GETPOST("label")?GETPOST("label"):$langs->trans("MovementTransferStock", $product->ref)); + $valformovementlabel=(GETPOST("label")?GETPOST("label"):$langs->trans("MovementTransferStock", $productref)); print ''; print ''; print '
'.$langs->trans("WarehouseSource").''; - if ($pdluoid > 0) + if ($object->element == 'product') { - print $formproduct->selectWarehouses($pdluo->warehouseid,'id_entrepot_source','',1,1); + print ''.$langs->trans("WarehouseSource").''; + print $formproduct->selectWarehouses((GETPOST("dwid")?GETPOST("dwid",'int'):(GETPOST('id_entrepot')?GETPOST('id_entrepot','int'):'ifone')),'id_entrepot','',1); + print ''.$langs->trans("Product").''; + print $form->select_produits(GETPOST('product_id'),'product_id',(empty($conf->global->STOCK_SUPPORTS_SERVICES)?'0':'')); + print ''.$langs->trans("WarehouseTarget").''; print $formproduct->selectWarehouses(GETPOST('id_entrepot_destination'),'id_entrepot_destination','',1); print ''.$langs->trans("NumberOfUnit").'
'.$langs->trans("batch_number").''; + print 'element == 'stock'?'': ' class="fieldrequired"').'>'.$langs->trans("batch_number").''; print ' 0 ? ' disabled':'').' value="'.(GETPOST('batch_number')?GETPOST('batch_number'):$pdluo->batch).'">'; // If form was opened for a specific pdluoid, field is disabled print '
'.$langs->trans("MovementLabel").''; diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 57f6497b681..889dd32584d 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -672,7 +672,7 @@ div.arearef { margin-bottom: 10px; } div.heightref { - min-height: 80px; + min-height: 80px; } div.divphotoref { padding-right: 20px; @@ -1196,8 +1196,8 @@ div.vmenu, td.vmenu { width: 188px; } -.menu_contenu { - padding-top: 5px; +.menu_contenu { + padding-top: 5px; padding-bottom: 2px; overflow: hidden; text-overflow: ellipsis; @@ -1268,7 +1268,7 @@ div.blockvmenupair, div.blockvmenuimpair, div.blockvmenubookmarks, div.blockvmen -moz-box-shadow: 3px 3px 4px #DDD; -webkit-box-shadow: 3px 3px 4px #DDD; box-shadow: 3px 3px 4px #DDD; - */ + */ } div.blockvmenusearch @@ -2099,7 +2099,7 @@ table.liste, table.noborder, table.formdoc, div.noborder { border-bottom-width: 1px; border-bottom-color: #BBB; border-bottom-style: solid; - + margin: 0px 0px 5px 0px; -moz-box-shadow: 2px 2px 4px #CCC; @@ -3687,22 +3687,31 @@ a span.select2-chosen overflow: hidden; } + +/* ============================================================================== */ +/* For categories */ +/* ============================================================================== */ + .noborderoncategories { border: none !important; border-radius: 5px !important; box-shadow: none; -webkit-box-shadow: none !important; box-shadow: none !important; - color: #fff !important; } span.noborderoncategories a, li.noborderoncategories a { - color: #fff !important; line-height: normal; vertical-align: top; } span.noborderoncategories { padding: 3px 5px 0px 5px; } +.categtextwhite, .treeview .categtextwhite.hover { + color: #fff !important; +} +.categtextblack { + color: #000 !important; +} /* ============================================================================== */ @@ -3804,10 +3813,10 @@ a.ui-link, a.ui-link:hover, .ui-btn:hover, span.ui-btn-text:hover, span.ui-btn-i } select { /* display: inline-block; */ /* We can't set this. This disable ability to make */ - /* TODO added by jmobile, replace jmobile with pure css*/ + /* TODO added by jmobile, replace jmobile with pure css*/ overflow:hidden; white-space: nowrap; - text-overflow: ellipsis; + text-overflow: ellipsis; } .fiche .ui-controlgroup { margin: 0px; @@ -3985,11 +3994,11 @@ border-top-right-radius: 6px; @media only screen and (max-width: 767px) { .imgopensurveywizard { width:95%; height: auto; } - + #tooltip { position: absolute; width: px; - } + } } @@ -4029,14 +4038,14 @@ border-top-right-radius: 6px; top: 4px; max-width: 82px; } - + div.mainmenu { min-width: 20px; } .topmenuimage { background-size: 20px auto; } - + #tooltip { position: absolute; width: px; diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index af2b770b1f4..f6e366f01d6 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -2816,6 +2816,14 @@ table.dp { color: rgb(); } +.categtextwhite, .treeview .categtextwhite.hover { + color: #fff !important; +} +.categtextblack { + color: #000 !important; +} + + /* ============================================================================== */ /* Afficher/cacher */ /* ============================================================================== */ @@ -3525,22 +3533,30 @@ a span.select2-chosen overflow: hidden; } + +/* ============================================================================== */ +/* For categories */ +/* ============================================================================== */ + .noborderoncategories { border: none !important; border-radius: 5px !important; box-shadow: none; -webkit-box-shadow: none !important; box-shadow: none !important; - color: #fff !important; } span.noborderoncategories a, li.noborderoncategories a { - color: #fff !important; line-height: normal; } span.noborderoncategories { padding: 5px 5px 0px 5px; } - +.categtextwhite, .treeview .categtextwhite.hover { + color: #fff !important; +} +.categtextblack { + color: #000 !important; +} /* ============================================================================== */