From 01a3787664d31b04b901488172d56f872847f81b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 31 Oct 2017 13:45:13 +0100 Subject: [PATCH 01/64] swap llxfooter() and $db->close() --- htdocs/compta/facture/document.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/facture/document.php b/htdocs/compta/facture/document.php index e4f9846309a..9159c13070c 100644 --- a/htdocs/compta/facture/document.php +++ b/htdocs/compta/facture/document.php @@ -4,6 +4,7 @@ * Copyright (C) 2005 Marc Barilley / Ocebo * Copyright (C) 2005-2011 Regis Houssin * Copyright (C) 2013 Cédric Salvador + * Copyright (C) 2017 Frédéric France * * 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 @@ -164,6 +165,6 @@ else print $langs->trans("ErrorUnknown"); } -$db->close(); - llxFooter(); + +$db->close(); From e195cf0b9566dc4fa2050cfad2f8651c230b6274 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Tue, 14 Nov 2017 09:53:06 +0100 Subject: [PATCH 02/64] fix : return vat code for supplier price --- htdocs/core/lib/functions.lib.php | 1 + htdocs/product/class/product.class.php | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 51eb070da91..b58d24ba028 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -4306,6 +4306,7 @@ function get_product_vat_for_country($idprod, $thirdparty_seller, $idprodfournpr { $product->get_buyprice($idprodfournprice,0,0,0); $ret=$product->vatrate_supplier; + if ($product->default_vat_code) $ret.=' ('.$product->default_vat_code.')'; } else { diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 05adfc1b5c5..b0985f6f2e8 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -1505,6 +1505,7 @@ class Product extends CommonObject // We do a first seach with a select by searching with couple prodfournprice and qty only (later we will search on triplet qty/product_id/fourn_ref) $sql = "SELECT pfp.rowid, pfp.price as price, pfp.quantity as quantity, pfp.remise_percent,"; $sql.= " pfp.fk_product, pfp.ref_fourn, pfp.fk_soc, pfp.tva_tx, pfp.fk_supplier_price_expression"; + $sql.= " ,pfp.default_vat_code"; $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; $sql.= " WHERE pfp.rowid = ".$prodfournprice; if ($qty > 0) $sql.= " AND pfp.quantity <= ".$qty; @@ -1540,6 +1541,7 @@ class Product extends CommonObject $this->ref_supplier = $obj->ref_fourn; // Ref supplier $this->remise_percent = $obj->remise_percent; // remise percent if present and not typed $this->vatrate_supplier = $obj->tva_tx; // Vat ref supplier + $this->default_vat_code = $obj->default_vat_code; // Vat code supplier $result=$obj->fk_product; return $result; } @@ -1548,6 +1550,7 @@ class Product extends CommonObject // We do a second search by doing a select again but searching with less reliable criteria: couple qty/id product, and if set fourn_ref or fk_soc. $sql = "SELECT pfp.rowid, pfp.price as price, pfp.quantity as quantity, pfp.fk_soc,"; $sql.= " pfp.fk_product, pfp.ref_fourn as ref_supplier, pfp.tva_tx, pfp.fk_supplier_price_expression"; + $sql.= " ,pfp.default_vat_code"; $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; $sql.= " WHERE pfp.fk_product = ".$product_id; if ($fourn_ref != 'none') $sql.= " AND pfp.ref_fourn = '".$fourn_ref."'"; @@ -1587,6 +1590,7 @@ class Product extends CommonObject $this->ref_supplier = $obj->ref_supplier; // Ref supplier $this->remise_percent = $obj->remise_percent; // remise percent if present and not typed $this->vatrate_supplier = $obj->tva_tx; // Vat ref supplier + $this->default_vat_code = $obj->default_vat_code; // Vat code supplier $result=$obj->fk_product; return $result; } From 4b90510b821cd84f9ee1d1c3f3c7804c56846f20 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 16 Nov 2017 22:35:55 +0100 Subject: [PATCH 03/64] Fix time assigned to wrong user --- htdocs/projet/activity/perday.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index b767c35e329..36b55ea79ff 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -237,7 +237,7 @@ if ($action == 'addtime' && $user->rights->projet->lire) $object->fetch($key); $object->progress = GETPOST($key.'progress', 'int'); $object->timespent_duration = $val; - $object->timespent_fk_user = $user->id; + $object->timespent_fk_user = $usertoprocess->id; $object->timespent_note = GETPOST($key.'note'); if (GETPOST($key."hour") != '' && GETPOST($key."hour") >= 0) // If hour was entered { From 57a6ada2a35bfee63d0e18178b913283bdf8148b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 17 Nov 2017 13:56:41 +0100 Subject: [PATCH 04/64] FIX #7824 --- htdocs/product/stock/replenishorders.php | 74 +++++++++++++++--------- 1 file changed, 48 insertions(+), 26 deletions(-) diff --git a/htdocs/product/stock/replenishorders.php b/htdocs/product/stock/replenishorders.php index 694f9cae1ad..b707b3f19a6 100644 --- a/htdocs/product/stock/replenishorders.php +++ b/htdocs/product/stock/replenishorders.php @@ -29,7 +29,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; -require_once './lib/replenishment.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/product/stock/lib/replenishment.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; $langs->load("products"); $langs->load("stocks"); @@ -44,9 +45,13 @@ $sref = GETPOST('search_ref', 'alpha'); $snom = GETPOST('search_nom', 'alpha'); $suser = GETPOST('search_user', 'alpha'); $sttc = GETPOST('search_ttc', 'alpha'); -$sdate = GETPOST('search_date', 'alpha'); $page = GETPOST('page', 'int'); $sproduct = GETPOST('sproduct', 'int'); +$search_dateyear = GETPOST('search_dateyear', 'int'); +$search_datemonth = GETPOST('search_datemonth', 'int'); +$search_dateday = GETPOST('search_dateday', 'int'); +$search_date = dol_mktime(0, 0, 0, $search_datemonth, $search_dateday, $search_dateyear); +if (GETPOST('search_date', 'alpha')) $search_date = dol_stringtotime(GETPOST('search_date', 'alpha')); // For backward compatibility $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield"); @@ -70,7 +75,10 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x', $snom=""; $suser=""; $sttc=""; - $sdate=''; + $search_date=''; + $search_datemonth=''; + $search_dateday=''; + $search_dateyear=''; $sproduct=0; } @@ -125,17 +133,19 @@ if ($sref) $sql .= natural_search('cf.ref', $sref); if ($snom) $sql .= natural_search('s.nom', $snom); if ($suser) $sql .= natural_search('u.login', $suser); if ($sttc) $sql .= natural_search('cf.total_ttc', $sttc, 1); -if ($sdate) + +if ($search_datemonth > 0) { - if (GETPOST('search_datemonth', 'int') && GETPOST('search_dateday', 'int') && GETPOST('search_dateyear', 'int')) - { - $date = dol_mktime(0, 0, 0, GETPOST('search_datemonth', 'int'), GETPOST('search_dateday', 'int'), GETPOST('search_dateyear', 'int')); - } - else - { - $date = dol_stringtotime($sdate); - } - $sql .= " AND cf.date_creation = '" . $db->idate($date) . "'"; + if ($search_dateyear > 0 && empty($search_dateday)) + $sql.= " AND cf.date_creation BETWEEN '".$db->idate(dol_get_first_day($search_dateyear,$search_datemonth,false))."' AND '".$db->idate(dol_get_last_day($search_dateyear,$search_datemonth,false))."'"; + else if ($search_dateyear > 0 && ! empty($search_dateday)) + $sql.= " AND cf.date_creation BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $search_datemonth, $search_dateday, $search_dateyear))."' AND '".$db->idate(dol_mktime(23, 59, 59, $search_datemonth, $search_dateday, $search_dateyear))."'"; + else + $sql.= " AND date_format(cf.date_creation, '%m') = '".$search_datemonth."'"; +} +else if ($search_dateyear > 0) +{ + $sql.= " AND cf.date_creation BETWEEN '".$db->idate(dol_get_first_day($search_dateyear,1,false))."' AND '".$db->idate(dol_get_last_day($search_dateyear,12,false))."'"; } if ($sall) $sql .= natural_search(array('cf.ref','cf.note'), $sall); if (!empty($socid)) $sql .= ' AND s.rowid = ' . $socid; @@ -146,7 +156,6 @@ $sql .= ' GROUP BY cf.rowid, cf.ref, cf.date_creation, cf.fk_statut'; $sql .= ', cf.total_ttc, cf.fk_user_author, u.login, s.rowid, s.nom'; $sql .= $db->order($sortfield, $sortorder); $sql .= $db->plimit($limit+1, $offset); -//print $sql; $resql = $db->query($sql); if ($resql) @@ -158,25 +167,38 @@ if ($resql) print_barre_liste('', $page, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', $num, 0, ''); + $param=''; + if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); + if ($sref) $param.='&search_ref='.urlencode($sref); + if ($snom) $param.='&search_nom='.urlencode($snom); + if ($suser) $param.='&search_user='.urlencode($suser); + if ($sttc) $param.='&search_ttc='.urlencode($sttc); + if ($search_dateyear) $param.='&search_dateyear='.urlencode($search_dateyear); + if ($search_datemonth) $param.='&search_datemonth='.urlencode($search_datemonth); + if ($search_dateday) $param.='&search_dateday='.urlencode($search_dateday); + if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); + + print '
'; print ''; - print ''. - ''; + print ''. ''. ''. ''. ''. ''; print ''; @@ -689,10 +690,12 @@ else { while ($objp = $db->fetch_object($resql)) { - $account_id = $objp->bid; - if (! isset($accounts[$objp->bid])) + //$account_id = $objp->bid; FIXME not used + + // FIXME $accounts[$objp->bid] is a label + /*if (! isset($accounts[$objp->bid])) $accounts[$objp->bid]=0; - $accounts[$objp->bid] += 1; + $accounts[$objp->bid] += 1;*/ print ''; print ''; From 04327189f756d476157af50e684679c48507c04e Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 8 Dec 2017 09:41:33 +0100 Subject: [PATCH 40/64] Fix: access error when user not right to view all customers --- htdocs/compta/paiement/cheque/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/paiement/cheque/card.php b/htdocs/compta/paiement/cheque/card.php index eb69a386719..c684e041660 100644 --- a/htdocs/compta/paiement/cheque/card.php +++ b/htdocs/compta/paiement/cheque/card.php @@ -46,7 +46,7 @@ $confirm=GETPOST('confirm', 'alpha'); // Security check $fieldname = (! empty($ref)?'ref':'rowid'); if ($user->societe_id) $socid=$user->societe_id; -$result = restrictedArea($user, 'cheque', $id, 'bordereau_cheque','','',$fieldname); +$result = restrictedArea($user, 'cheque', $id, 'bordereau_cheque','','fk_user_author',$fieldname); $sortfield=GETPOST('sortfield', 'alpha'); $sortorder=GETPOST('sortorder', 'alpha'); From 1bdffa961ffb110b28a3261e6df35b574ee63023 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 8 Dec 2017 10:41:14 +0100 Subject: [PATCH 41/64] Fix: wrong translation if multilang activated --- htdocs/comm/propal/card.php | 45 ++++++++++++++++++++--------- htdocs/commande/card.php | 56 +++++++++++++++++++++++++------------ htdocs/compta/facture.php | 32 +++++++++++++++++---- 3 files changed, 96 insertions(+), 37 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index e0f6b796826..a43fb982ee6 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -494,7 +494,7 @@ if (empty($reshook)) $tva_tx = $lines[$i]->tva_tx; if (! empty($lines[$i]->vat_src_code) && ! preg_match('/\(/', $tva_tx)) $tva_tx .= ' ('.$lines[$i]->vat_src_code.')'; - + $result = $object->addline($desc, $lines[$i]->subprice, $lines[$i]->qty, $tva_tx, $lines[$i]->localtax1_tx, $lines[$i]->localtax2_tx, $lines[$i]->fk_product, $lines[$i]->remise_percent, 'HT', 0, $lines[$i]->info_bits, $product_type, $lines[$i]->rang, $lines[$i]->special_code, $fk_parent_line, $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, $label, $date_start, $date_end, $array_options, $lines[$i]->fk_unit); if ($result > 0) { @@ -735,7 +735,7 @@ if (empty($reshook)) $db->begin(); // $tva_tx can be 'x.x (XXX)' - + // Ecrase $pu par celui du produit // Ecrase $desc par celui du produit // Ecrase $tva_tx par celui du produit @@ -750,7 +750,7 @@ if (empty($reshook)) $tva_tx = get_default_tva($mysoc, $object->thirdparty, $prod->id); $tva_npr = get_default_npr($mysoc, $object->thirdparty, $prod->id); if (empty($tva_tx)) $tva_npr=0; - + $pu_ht = $prod->price; $pu_ttc = $prod->price_ttc; $price_min = $prod->price_min; @@ -791,7 +791,7 @@ if (empty($reshook)) $tmpvat = price2num(preg_replace('/\s*\(.*\)/', '', $tva_tx)); $tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx)); - + // if price ht is forced (ie: calculated by margin rate and cost price). TODO Why this ? if (! empty($price_ht)) { $pu_ht = price2num($price_ht, 'MU'); @@ -844,13 +844,32 @@ if (empty($reshook)) // Add custom code and origin country into description if (empty($conf->global->MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE) && (! empty($prod->customcode) || ! empty($prod->country_code))) { - $tmptxt = '('; - if (! empty($prod->customcode)) - $tmptxt .= $langs->transnoentitiesnoconv("CustomCode") . ': ' . $prod->customcode; - if (! empty($prod->customcode) && ! empty($prod->country_code)) - $tmptxt .= ' - '; - if (! empty($prod->country_code)) - $tmptxt .= $langs->transnoentitiesnoconv("CountryOrigin") . ': ' . getCountry($prod->country_code, 0, $db, $langs, 0); + // Define output language + if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { + $outputlangs = $langs; + $newlang = ''; + if (empty($newlang) && GETPOST('lang_id','alpha')) + $newlang = GETPOST('lang_id','alpha'); + if (empty($newlang)) + $newlang = $object->thirdparty->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + if (! empty($prod->customcode)) + $tmptxt .= $outputlangs->transnoentitiesnoconv("CustomCode") . ': ' . $prod->customcode; + if (! empty($prod->customcode) && ! empty($prod->country_code)) + $tmptxt .= ' - '; + if (! empty($prod->country_code)) + $tmptxt .= $outputlangs->transnoentitiesnoconv("CountryOrigin") . ': ' . getCountry($prod->country_code, 0, $db, $outputlangs, 0); + } else { + if (! empty($prod->customcode)) + $tmptxt .= $langs->transnoentitiesnoconv("CustomCode") . ': ' . $prod->customcode; + if (! empty($prod->customcode) && ! empty($prod->country_code)) + $tmptxt .= ' - '; + if (! empty($prod->country_code)) + $tmptxt .= $langs->transnoentitiesnoconv("CountryOrigin") . ': ' . getCountry($prod->country_code, 0, $db, $langs, 0); + } $tmptxt .= ')'; $desc = dol_concatdesc($desc, $tmptxt); } @@ -969,7 +988,7 @@ if (empty($reshook)) // Add buying price $fournprice = price2num(GETPOST('fournprice') ? GETPOST('fournprice') : ''); $buyingprice = price2num(GETPOST('buying_price') != '' ? GETPOST('buying_price') : ''); // If buying_price is '0', we muste keep this value - + $pu_ht_devise = GETPOST('multicurrency_subprice'); $date_start = dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear')); @@ -1305,7 +1324,7 @@ if ($action == 'create') // Replicate extrafields $objectsrc->fetch_optionals($originid); $object->array_options = $objectsrc->array_options; - + if (!empty($conf->multicurrency->enabled)) { if (!empty($objectsrc->multicurrency_code)) $currency_code = $objectsrc->multicurrency_code; diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 67978ff99e8..cf3d5efde3d 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -49,7 +49,7 @@ if (! empty($conf->projet->enabled)) { require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php'; } - + require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; $langs->load('orders'); @@ -112,7 +112,7 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (empty($reshook)) { - if ($cancel) + if ($cancel) { if ($action != 'addlink' && $action != 'updateline') { @@ -126,7 +126,7 @@ if (empty($reshook)) } $action=''; } - + include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once @@ -375,7 +375,7 @@ if (empty($reshook)) $tva_tx = $lines[$i]->tva_tx; if (! empty($lines[$i]->vat_src_code) && ! preg_match('/\(/', $tva_tx)) $tva_tx .= ' ('.$lines[$i]->vat_src_code.')'; - + $result = $object->addline($desc, $lines[$i]->subprice, $lines[$i]->qty, $tva_tx, $lines[$i]->localtax1_tx, $lines[$i]->localtax2_tx, $lines[$i]->fk_product, $lines[$i]->remise_percent, $lines[$i]->info_bits, $lines[$i]->fk_remise_except, 'HT', 0, $date_start, $date_end, $product_type, $lines[$i]->rang, $lines[$i]->special_code, $fk_parent_line, $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, $label, $array_options, $lines[$i]->fk_unit, $object->origin, $lines[$i]->rowid); if ($result < 0) { @@ -760,7 +760,7 @@ if (empty($reshook)) $tmpvat = price2num(preg_replace('/\s*\(.*\)/', '', $tva_tx)); $tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx)); - + // if price ht is forced (ie: calculated by margin rate and cost price). TODO Why this ? if (! empty($price_ht)) { $pu_ht = price2num($price_ht, 'MU'); @@ -782,8 +782,8 @@ if (empty($reshook)) if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { $outputlangs = $langs; $newlang = ''; - if (empty($newlang) && GETPOST('lang_id')) - $newlang = GETPOST('lang_id'); + if (empty($newlang) && GETPOST('lang_id','alpha')) + $newlang = GETPOST('lang_id','alpha'); if (empty($newlang)) $newlang = $object->thirdparty->default_lang; if (! empty($newlang)) { @@ -801,12 +801,32 @@ if (empty($reshook)) // Add custom code and origin country into description if (empty($conf->global->MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE) && (! empty($prod->customcode) || ! empty($prod->country_code))) { $tmptxt = '('; - if (! empty($prod->customcode)) - $tmptxt .= $langs->transnoentitiesnoconv("CustomCode") . ': ' . $prod->customcode; - if (! empty($prod->customcode) && ! empty($prod->country_code)) - $tmptxt .= ' - '; - if (! empty($prod->country_code)) - $tmptxt .= $langs->transnoentitiesnoconv("CountryOrigin") . ': ' . getCountry($prod->country_code, 0, $db, $langs, 0); + // Define output language + if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { + $outputlangs = $langs; + $newlang = ''; + if (empty($newlang) && GETPOST('lang_id','alpha')) + $newlang = GETPOST('lang_id','alpha'); + if (empty($newlang)) + $newlang = $object->thirdparty->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + if (! empty($prod->customcode)) + $tmptxt .= $outputlangs->transnoentitiesnoconv("CustomCode") . ': ' . $prod->customcode; + if (! empty($prod->customcode) && ! empty($prod->country_code)) + $tmptxt .= ' - '; + if (! empty($prod->country_code)) + $tmptxt .= $outputlangs->transnoentitiesnoconv("CountryOrigin") . ': ' . getCountry($prod->country_code, 0, $db, $outputlangs, 0); + } else { + if (! empty($prod->customcode)) + $tmptxt .= $langs->transnoentitiesnoconv("CustomCode") . ': ' . $prod->customcode; + if (! empty($prod->customcode) && ! empty($prod->country_code)) + $tmptxt .= ' - '; + if (! empty($prod->country_code)) + $tmptxt .= $langs->transnoentitiesnoconv("CountryOrigin") . ': ' . getCountry($prod->country_code, 0, $db, $langs, 0); + } $tmptxt .= ')'; $desc = dol_concatdesc($desc, $tmptxt); } @@ -2285,7 +2305,7 @@ if ($action == 'create' && $user->rights->commande->creer) } print ''; */ - + $tmparray=$object->getTotalWeightVolume(); $totalWeight=$tmparray['weight']; $totalVolume=$tmparray['volume']; @@ -2365,18 +2385,18 @@ if ($action == 'create' && $user->rights->commande->creer) print ''; print ''; print ''; - + // Multicurrency Amount VAT print ''; print ''; print ''; - + // Multicurrency Amount TTC print ''; print ''; print ''; } - + // Total HT print ''; print ''; @@ -2471,7 +2491,7 @@ if ($action == 'create' && $user->rights->commande->creer) } print '
'. - ''. + print '
'. + ''. ''. - ''. + ''. ''. - ''. + ''. ''. - ''. + ''. ''. - $form->select_date('', 'search_date', 0, 0, 1, '', 1, 0, 1, 0, ''). + $form->select_date($search_date, 'search_date', 0, 0, 1, '', 1, 0, 1, 0, ''). ''; $searchpicto=$form->showFilterAndCheckAddButtons(0); @@ -190,7 +212,7 @@ if ($resql) $_SERVER['PHP_SELF'], 'cf.ref', '', - '', + $param, '', $sortfield, $sortorder @@ -200,7 +222,7 @@ if ($resql) $_SERVER['PHP_SELF'], 's.nom', '', - '', + $param, '', $sortfield, $sortorder @@ -220,7 +242,7 @@ if ($resql) $_SERVER['PHP_SELF'], 'cf.total_ttc', '', - '', + $param, '', $sortfield, $sortorder @@ -230,7 +252,7 @@ if ($resql) $_SERVER['PHP_SELF'], 'cf.date_creation', '', - '', + $param, '', $sortfield, $sortorder @@ -240,7 +262,7 @@ if ($resql) $_SERVER['PHP_SELF'], 'cf.fk_statut', '', - '', + $param, 'align="right"', $sortfield, $sortorder From 7f28c9fff6119b72e52fcd365ccd69aad7a1bd0c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 17 Nov 2017 13:56:41 +0100 Subject: [PATCH 05/64] FIX #7824 Conflicts: htdocs/product/stock/replenishorders.php --- htdocs/product/stock/replenishorders.php | 73 ++++++++++++++++-------- 1 file changed, 48 insertions(+), 25 deletions(-) diff --git a/htdocs/product/stock/replenishorders.php b/htdocs/product/stock/replenishorders.php index 5b1fda0371f..37d7bfd19f6 100644 --- a/htdocs/product/stock/replenishorders.php +++ b/htdocs/product/stock/replenishorders.php @@ -29,7 +29,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; -require_once './lib/replenishment.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/product/stock/lib/replenishment.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; $langs->load("products"); $langs->load("stocks"); @@ -44,9 +45,13 @@ $sref = GETPOST('search_ref', 'alpha'); $snom = GETPOST('search_nom', 'alpha'); $suser = GETPOST('search_user', 'alpha'); $sttc = GETPOST('search_ttc', 'alpha'); -$sdate = GETPOST('search_date', 'alpha'); $page = GETPOST('page', 'int'); $sproduct = GETPOST('sproduct', 'int'); +$search_dateyear = GETPOST('search_dateyear', 'int'); +$search_datemonth = GETPOST('search_datemonth', 'int'); +$search_dateday = GETPOST('search_dateday', 'int'); +$search_date = dol_mktime(0, 0, 0, $search_datemonth, $search_dateday, $search_dateyear); +if (GETPOST('search_date', 'alpha')) $search_date = dol_stringtotime(GETPOST('search_date', 'alpha')); // For backward compatibility $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield"); @@ -70,7 +75,10 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETP $snom=""; $suser=""; $sttc=""; - $sdate=''; + $search_date=''; + $search_datemonth=''; + $search_dateday=''; + $search_dateyear=''; $sproduct=0; } @@ -125,17 +133,19 @@ if ($sref) $sql .= natural_search('cf.ref', $sref); if ($snom) $sql .= natural_search('s.nom', $snom); if ($suser) $sql .= natural_search('u.login', $suser); if ($sttc) $sql .= natural_search('cf.total_ttc', $sttc, 1); -if ($sdate) + +if ($search_datemonth > 0) { - if (GETPOST('search_datemonth', 'int') && GETPOST('search_dateday', 'int') && GETPOST('search_dateyear', 'int')) - { - $date = dol_mktime(0, 0, 0, GETPOST('search_datemonth', 'int'), GETPOST('search_dateday', 'int'), GETPOST('search_dateyear', 'int')); - } - else - { - $date = dol_stringtotime($sdate); - } - $sql .= " AND cf.date_creation = '" . $db->idate($date) . "'"; + if ($search_dateyear > 0 && empty($search_dateday)) + $sql.= " AND cf.date_creation BETWEEN '".$db->idate(dol_get_first_day($search_dateyear,$search_datemonth,false))."' AND '".$db->idate(dol_get_last_day($search_dateyear,$search_datemonth,false))."'"; + else if ($search_dateyear > 0 && ! empty($search_dateday)) + $sql.= " AND cf.date_creation BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $search_datemonth, $search_dateday, $search_dateyear))."' AND '".$db->idate(dol_mktime(23, 59, 59, $search_datemonth, $search_dateday, $search_dateyear))."'"; + else + $sql.= " AND date_format(cf.date_creation, '%m') = '".$search_datemonth."'"; +} +else if ($search_dateyear > 0) +{ + $sql.= " AND cf.date_creation BETWEEN '".$db->idate(dol_get_first_day($search_dateyear,1,false))."' AND '".$db->idate(dol_get_last_day($search_dateyear,12,false))."'"; } if ($sall) $sql .= natural_search(array('cf.ref','cf.note'), $sall); if (!empty($socid)) $sql .= ' AND s.rowid = ' . $socid; @@ -146,7 +156,6 @@ $sql .= ' GROUP BY cf.rowid, cf.ref, cf.date_creation, cf.fk_statut'; $sql .= ', cf.total_ttc, cf.fk_user_author, u.login, s.rowid, s.nom'; $sql .= $db->order($sortfield, $sortorder); $sql .= $db->plimit($limit+1, $offset); -//print $sql; $resql = $db->query($sql); if ($resql) @@ -158,6 +167,19 @@ if ($resql) print_barre_liste('', $page, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', $num, 0, ''); + $param=''; + if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); + if ($sref) $param.='&search_ref='.urlencode($sref); + if ($snom) $param.='&search_nom='.urlencode($snom); + if ($suser) $param.='&search_user='.urlencode($suser); + if ($sttc) $param.='&search_ttc='.urlencode($sttc); + if ($search_dateyear) $param.='&search_dateyear='.urlencode($search_dateyear); + if ($search_datemonth) $param.='&search_datemonth='.urlencode($search_datemonth); + if ($search_dateday) $param.='&search_dateday='.urlencode($search_dateday); + if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); + + print ''; print ''. @@ -167,7 +189,7 @@ if ($resql) $_SERVER['PHP_SELF'], 'cf.ref', '', - '', + $param, '', $sortfield, $sortorder @@ -177,7 +199,7 @@ if ($resql) $_SERVER['PHP_SELF'], 's.nom', '', - '', + $param, '', $sortfield, $sortorder @@ -187,7 +209,7 @@ if ($resql) $_SERVER['PHP_SELF'], 'u.login', '', - '', + $param, '', $sortfield, $sortorder @@ -197,7 +219,7 @@ if ($resql) $_SERVER['PHP_SELF'], 'cf.total_ttc', '', - '', + $param, '', $sortfield, $sortorder @@ -207,7 +229,7 @@ if ($resql) $_SERVER['PHP_SELF'], 'cf.date_creation', '', - '', + $param, '', $sortfield, $sortorder @@ -217,7 +239,7 @@ if ($resql) $_SERVER['PHP_SELF'], 'cf.fk_statut', '', - '', + $param, 'align="right"', $sortfield, $sortorder @@ -226,19 +248,19 @@ if ($resql) ''. ''. ''. ''. ''. ''. ''; $var = true; + $userstatic = new User($db); while ($i < min($num,$conf->liste_limit)) From fde33594a2c0b87e756cbcc34ce1d02ea2265f53 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 17 Nov 2017 14:06:08 +0100 Subject: [PATCH 06/64] FIX #7824 --- htdocs/product/stock/replenishorders.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/product/stock/replenishorders.php b/htdocs/product/stock/replenishorders.php index 37d7bfd19f6..59a1a28ccf5 100644 --- a/htdocs/product/stock/replenishorders.php +++ b/htdocs/product/stock/replenishorders.php @@ -51,7 +51,6 @@ $search_dateyear = GETPOST('search_dateyear', 'int'); $search_datemonth = GETPOST('search_datemonth', 'int'); $search_dateday = GETPOST('search_dateday', 'int'); $search_date = dol_mktime(0, 0, 0, $search_datemonth, $search_dateday, $search_dateyear); -if (GETPOST('search_date', 'alpha')) $search_date = dol_stringtotime(GETPOST('search_date', 'alpha')); // For backward compatibility $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield"); @@ -63,7 +62,6 @@ if ($page < 0) $page = 0; $offset = $limit * $page; - /* * Actions */ @@ -244,6 +242,7 @@ if ($resql) $sortfield, $sortorder ); + print ''. ''. From 42b7d805675ad3ea3e34664c55b93d4b11be057f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 17 Nov 2017 14:06:08 +0100 Subject: [PATCH 07/64] FIX #7824 Conflicts: htdocs/product/stock/replenishorders.php --- htdocs/product/stock/replenishorders.php | 91 +++++++++++++++++++----- 1 file changed, 73 insertions(+), 18 deletions(-) diff --git a/htdocs/product/stock/replenishorders.php b/htdocs/product/stock/replenishorders.php index 785760ef511..c4a57d0475c 100644 --- a/htdocs/product/stock/replenishorders.php +++ b/htdocs/product/stock/replenishorders.php @@ -29,7 +29,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; -require_once './lib/replenishment.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/product/stock/lib/replenishment.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; $langs->load("products"); $langs->load("stocks"); @@ -39,6 +40,46 @@ $langs->load("orders"); if ($user->societe_id) $socid=$user->societe_id; $result=restrictedArea($user,'produit|service'); +$sall = GETPOST('search_all', 'alphanohtml'); +$sref = GETPOST('search_ref', 'alpha'); +$snom = GETPOST('search_nom', 'alpha'); +$suser = GETPOST('search_user', 'alpha'); +$sttc = GETPOST('search_ttc', 'alpha'); +$page = GETPOST('page', 'int'); +$sproduct = GETPOST('sproduct', 'int'); +$search_dateyear = GETPOST('search_dateyear', 'int'); +$search_datemonth = GETPOST('search_datemonth', 'int'); +$search_dateday = GETPOST('search_dateday', 'int'); +$search_date = dol_mktime(0, 0, 0, $search_datemonth, $search_dateday, $search_dateyear); + +$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$sortfield = GETPOST("sortfield"); +$sortorder = GETPOST("sortorder"); +if (!$sortorder) $sortorder = 'DESC'; +if (!$sortfield) $sortfield = 'cf.date_creation'; +$page = GETPOST("page"); +if ($page < 0) $page = 0; +$offset = $limit * $page; + + +/* + * Actions + */ + +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers +{ + $sall=""; + $sref=""; + $snom=""; + $suser=""; + $sttc=""; + $search_date=''; + $search_datemonth=''; + $search_dateday=''; + $search_dateyear=''; + $sproduct=0; +} + /* @@ -120,17 +161,18 @@ if ($suser) { if ($sttc) { $sql .= ' AND cf.total_ttc = ' . price2num($sttc); } -if ($sdate) +if ($search_datemonth > 0) { - if (GETPOST('search_datemonth', 'int') && GETPOST('search_dateday', 'int') && GETPOST('search_dateyear', 'int')) - { - $date = dol_mktime(0, 0, 0, GETPOST('search_datemonth', 'int'), GETPOST('search_dateday', 'int'), GETPOST('search_dateyear', 'int')); - } - else - { - $date = dol_stringtotime($sdate); - } - $sql .= " AND cf.date_creation = '" . $db->idate($date) . "'"; + if ($search_dateyear > 0 && empty($search_dateday)) + $sql.= " AND cf.date_creation BETWEEN '".$db->idate(dol_get_first_day($search_dateyear,$search_datemonth,false))."' AND '".$db->idate(dol_get_last_day($search_dateyear,$search_datemonth,false))."'"; + else if ($search_dateyear > 0 && ! empty($search_dateday)) + $sql.= " AND cf.date_creation BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $search_datemonth, $search_dateday, $search_dateyear))."' AND '".$db->idate(dol_mktime(23, 59, 59, $search_datemonth, $search_dateday, $search_dateyear))."'"; + else + $sql.= " AND date_format(cf.date_creation, '%m') = '".$search_datemonth."'"; +} +else if ($search_dateyear > 0) +{ + $sql.= " AND cf.date_creation BETWEEN '".$db->idate(dol_get_first_day($search_dateyear,1,false))."' AND '".$db->idate(dol_get_last_day($search_dateyear,12,false))."'"; } if ($sall) { $sql .= ' AND (cf.ref LIKE "%' . $db->escape($sall) . '%" '; @@ -159,6 +201,18 @@ if ($resql) print_barre_liste('', $page, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', $num, 0, ''); + $param=''; + if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); + if ($sref) $param.='&search_ref='.urlencode($sref); + if ($snom) $param.='&search_nom='.urlencode($snom); + if ($suser) $param.='&search_user='.urlencode($suser); + if ($sttc) $param.='&search_ttc='.urlencode($sttc); + if ($search_dateyear) $param.='&search_dateyear='.urlencode($search_dateyear); + if ($search_datemonth) $param.='&search_datemonth='.urlencode($search_datemonth); + if ($search_dateday) $param.='&search_dateday='.urlencode($search_dateday); + if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); + print ''; print '
'. - ''. + ''. ''. - ''. + ''. ''. - ''. + ''. ''. - ''. + ''. ''. - $form->select_date('', 'search_date', 0, 0, 1, '', 1, 0, 1, 0, ''). + $form->select_date($search_date, 'search_date', 0, 0, 1, '', 1, 0, 1, 0, ''). ''; $searchpitco=$form->showFilterAndCheckAddButtons(0); @@ -247,6 +269,7 @@ if ($resql) '
'. @@ -168,7 +222,7 @@ if ($resql) $_SERVER['PHP_SELF'], 'cf.ref', '', - '', + $param, '', $sortfield, $sortorder @@ -178,7 +232,7 @@ if ($resql) $_SERVER['PHP_SELF'], 's.nom', '', - '', + $param, '', $sortfield, $sortorder @@ -188,7 +242,7 @@ if ($resql) $_SERVER['PHP_SELF'], 'u.login', '', - '', + $param, '', $sortfield, $sortorder @@ -198,7 +252,7 @@ if ($resql) $_SERVER['PHP_SELF'], 'cf.total_ttc', '', - '', + $param, '', $sortfield, $sortorder @@ -208,7 +262,7 @@ if ($resql) $_SERVER['PHP_SELF'], 'cf.date_creation', '', - '', + $param, '', $sortfield, $sortorder @@ -218,11 +272,12 @@ if ($resql) $_SERVER['PHP_SELF'], 'cf.fk_statut', '', - '', + $param, 'align="right"', $sortfield, $sortorder ); + print ''. ''. @@ -239,7 +294,7 @@ if ($resql) ''. ''. ''. ''; From 314c30f4897c6ee30e18425af64b4ddfbd0b90bf Mon Sep 17 00:00:00 2001 From: atm-quentin Date: Thu, 23 Nov 2017 14:26:26 +0100 Subject: [PATCH 14/64] FIX too much users on holiday list --- htdocs/holiday/class/holiday.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 4815bee4b00..3bcd86774ba 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -1309,7 +1309,7 @@ class Holiday extends CommonObject // List for Dolibarr users if ($type) { - $sql = "SELECT u.rowid, u.lastname, u.firstname, u.gender, u.photo, u.employee, u.statut"; + $sql = "SELECT DISTINCT u.rowid, u.lastname, u.firstname, u.gender, u.photo, u.employee, u.statut"; $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) From c2f84309db4d9db474612b9521bd5ab8e0db1dab Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 24 Nov 2017 16:38:52 +0100 Subject: [PATCH 15/64] Update holiday.class.php --- htdocs/holiday/class/holiday.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 3bcd86774ba..6572d1836fa 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -1315,9 +1315,9 @@ class Holiday extends CommonObject if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { $sql.= ", ".MAIN_DB_PREFIX."usergroup_user as ug"; - $sql.= " WHERE (ug.fk_user = u.rowid"; + $sql.= " WHERE ((ug.fk_user = u.rowid"; $sql.= " AND ug.entity = ".$conf->entity.")"; - $sql.= " OR u.admin = 1"; + $sql.= " OR u.admin = 1)"; } else $sql.= " WHERE u.entity IN (0,".$conf->entity.")"; From 38c770ffb3eb90c7ecc49d916e2665b34632972b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 25 Nov 2017 01:16:12 +0100 Subject: [PATCH 16/64] FIX #7806 --- htdocs/user/class/api_users.class.php | 74 ++++++++++++++++----------- 1 file changed, 43 insertions(+), 31 deletions(-) diff --git a/htdocs/user/class/api_users.class.php b/htdocs/user/class/api_users.class.php index f119fa36ffa..6c06a1e2fea 100644 --- a/htdocs/user/class/api_users.class.php +++ b/htdocs/user/class/api_users.class.php @@ -22,14 +22,14 @@ use Luracast\Restler\RestException; /** * API class for users * - * @access protected + * @access protected * @class DolibarrApiAccess {@requires user,external} */ class Users extends DolibarrApi { /** * - * @var array $FIELDS Mandatory fields, checked when create and update object + * @var array $FIELDS Mandatory fields, checked when create and update object */ static $FIELDS = array( 'login' @@ -49,7 +49,7 @@ class Users extends DolibarrApi $this->useraccount = new User($this->db); } - + /** * List Users * @@ -65,22 +65,22 @@ class Users extends DolibarrApi */ function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 0, $page = 0, $user_ids = 0, $sqlfilters = '') { global $db, $conf; - + $obj_ret = array(); - + if(! DolibarrApiAccess::$user->rights->user->user->lire) { throw new RestException(401, "You are not allowed to read list of users"); } - + // case of external user, $societe param is ignored and replaced by user's socid //$socid = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $societe; - + $sql = "SELECT t.rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."user as t"; $sql.= ' WHERE t.entity IN ('.getEntity('user').')'; if ($user_ids) $sql.=" AND t.rowid IN (".$user_ids.")"; // Add sql filters - if ($sqlfilters) + if ($sqlfilters) { if (! DolibarrApi::_checkFilters($sqlfilters)) { @@ -89,7 +89,7 @@ class Users extends DolibarrApi $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } - + $sql.= $db->order($sortfield, $sortorder); if ($limit) { if ($page < 0) @@ -97,12 +97,12 @@ class Users extends DolibarrApi $page = 0; } $offset = $limit * $page; - + $sql.= $db->plimit($limit + 1, $offset); } - + $result = $db->query($sql); - + if ($result) { $num = $db->num_rows($result); @@ -125,7 +125,7 @@ class Users extends DolibarrApi } return $obj_ret; } - + /** * Get properties of an user object * @@ -133,7 +133,7 @@ class Users extends DolibarrApi * * @param int $id ID of user * @return array|mixed data without useless information - * + * * @throws RestException */ function get($id) { @@ -154,8 +154,8 @@ class Users extends DolibarrApi return $this->_cleanObjectDatas($this->useraccount); } - - + + /** * Create user account * @@ -185,14 +185,14 @@ class Users extends DolibarrApi } return $this->useraccount->id; } - - + + /** * Update account * * @param int $id Id of account to update - * @param array $request_data Datas - * @return int + * @param array $request_data Datas + * @return int */ function put($id, $request_data = NULL) { //if (!DolibarrApiAccess::$user->rights->user->user->creer) { @@ -228,7 +228,7 @@ class Users extends DolibarrApi * @param int $id User ID * @param int $group Group ID * @return int 1 if success - * + * * @url GET {id}/setGroup/{group} */ function setGroup($id, $group) { @@ -240,18 +240,18 @@ class Users extends DolibarrApi { throw new RestException(404, 'User not found'); } - + if (!DolibarrApi::_checkAccessToResource('user', $this->useraccount->id, 'user')) { throw new RestException(401, 'Access not allowed for login ' . DolibarrApiAccess::$user->login); } - + $result = $this->useraccount->SetInGroup($group,1); if (! ($result > 0)) { throw new RestException(500, $this->useraccount->error); } - + return 1; } @@ -286,25 +286,37 @@ class Users extends DolibarrApi * @return array Array of cleaned object properties */ function _cleanObjectDatas($object) { - + $object = parent::_cleanObjectDatas($object); - + unset($object->default_values); unset($object->lastsearch_values); unset($object->lastsearch_values_tmp); - + unset($object->total_ht); unset($object->total_tva); unset($object->total_localtax1); unset($object->total_localtax2); unset($object->total_ttc); - + + unset($object->fk_delivery_address); + unset($object->fk_incoterms); + unset($object->all_permissions_are_loaded); + + // List of properties never returned by API, whatever are permissions + unset($object->pass); + unset($object->pass_indatabase); + unset($object->pass_indatabase_crypted); + unset($object->pass_temp); + unset($object->api_key); + unset($object->clicktodial_password); + return $object; - } - + } + /** * Validate fields before create or update object - * + * * @param array|null $data Data to validate * @return array * @throws RestException From 4cbcf5189afbcfdc52e944f9288c456eee55e2f9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 25 Nov 2017 01:24:24 +0100 Subject: [PATCH 17/64] FIX #7806 --- htdocs/user/class/api_users.class.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/htdocs/user/class/api_users.class.php b/htdocs/user/class/api_users.class.php index 6c06a1e2fea..841f4d485bf 100644 --- a/htdocs/user/class/api_users.class.php +++ b/htdocs/user/class/api_users.class.php @@ -286,6 +286,7 @@ class Users extends DolibarrApi * @return array Array of cleaned object properties */ function _cleanObjectDatas($object) { + global $conf; $object = parent::_cleanObjectDatas($object); @@ -298,10 +299,16 @@ class Users extends DolibarrApi unset($object->total_localtax1); unset($object->total_localtax2); unset($object->total_ttc); + unset($object->libelle_incoterms); + unset($object->location_incoterms); unset($object->fk_delivery_address); unset($object->fk_incoterms); unset($object->all_permissions_are_loaded); + unset($object->shipping_method_id); + unset($object->nb_rights); + unset($object->search_sid); + unset($object->ldap_sid); // List of properties never returned by API, whatever are permissions unset($object->pass); @@ -310,6 +317,19 @@ class Users extends DolibarrApi unset($object->pass_temp); unset($object->api_key); unset($object->clicktodial_password); + unset($object->openid); + + + $canreadsalary = ((! empty($conf->salaries->enabled) && ! empty(DolibarrApiAccess::$user->rights->salaries->read)) + || (! empty($conf->hrm->enabled) && ! empty(DolibarrApiAccess::$user->rights->hrm->employee->read))); + + if (! $canreadsalary) + { + unset($object->salary); + unset($object->salaryextra); + unset($object->thm); + unset($object->tjm); + } return $object; } From 61798d1af007dfcdf1ef284d5e8546af479e3096 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 25 Nov 2017 02:32:25 +0100 Subject: [PATCH 18/64] FIX list of module not complete when module mb_strlen not available Conflicts: dev/dolibarr_changes.txt --- dev/dolibarr_changes.txt | 15 ++++++++++++++- htdocs/includes/parsedown/Parsedown.php | 10 +++++++--- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/dev/dolibarr_changes.txt b/dev/dolibarr_changes.txt index 3c2b7b3c932..0570525cdad 100644 --- a/dev/dolibarr_changes.txt +++ b/dev/dolibarr_changes.txt @@ -110,4 +110,17 @@ to get if ($className == 'Luracast\Restler\string') return; if ($className == 'Luracast\Restler\mixed') return; ... - \ No newline at end of file + + +PARSEDOWN +--------- + +* Fix to avoid fatal error when mb_strlen not available: + + // @CHANGE LDR Fix when mb_strlen is not available + //$shortage = 4 - mb_strlen($line, 'utf-8') % 4; + if (function_exists('mb_strlen')) $len = mb_strlen($line, 'utf-8'); + else $len = strlen($line); + $shortage = 4 - $len % 4; + + diff --git a/htdocs/includes/parsedown/Parsedown.php b/htdocs/includes/parsedown/Parsedown.php index 20863a7537a..a1ec563683f 100644 --- a/htdocs/includes/parsedown/Parsedown.php +++ b/htdocs/includes/parsedown/Parsedown.php @@ -141,7 +141,11 @@ class Parsedown foreach ($parts as $part) { - $shortage = 4 - mb_strlen($line, 'utf-8') % 4; + // @CHANGE LDR Fix when mb_strlen is not available + //$shortage = 4 - mb_strlen($line, 'utf-8') % 4; + if (function_exists('mb_strlen')) $len = mb_strlen($line, 'utf-8'); + else $len = strlen($line); + $shortage = 4 - $len % 4; $line .= str_repeat(' ', $shortage); $line .= $part; @@ -515,10 +519,10 @@ class Parsedown ), ); - if($name === 'ol') + if($name === 'ol') { $listStart = stristr($matches[0], '.', true); - + if($listStart !== '1') { $Block['element']['attributes'] = array('start' => $listStart); From 5fef6478a50ae7087214f12b03b274682ae1478a Mon Sep 17 00:00:00 2001 From: atm-ph Date: Mon, 27 Nov 2017 11:26:41 +0100 Subject: [PATCH 19/64] Fix wrong calcul_price_total() update --- htdocs/compta/facture/class/facture.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 3c60e0b6679..d1ede7cb41d 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2710,7 +2710,7 @@ class Facture extends CommonInvoice $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. } - $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, $type, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type, $situation_percent, $this->multicurrency_tx, $pu_ht_devise); + $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type, $situation_percent, $this->multicurrency_tx, $pu_ht_devise); $total_ht = $tabprice[0]; $total_tva = $tabprice[1]; @@ -2878,7 +2878,7 @@ class Facture extends CommonInvoice // Cap percentages to 100 if ($percent > 100) $percent = 100; $line->situation_percent = $percent; - $tabprice = calcul_price_total($line->qty, $line->subprice, $line->remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, $line->product_type, 'HT', 0, 0, $mysoc, '', $percent); + $tabprice = calcul_price_total($line->qty, $line->subprice, $line->remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 0, 'HT', 0, $line->product_type, $mysoc, '', $percent); $line->total_ht = $tabprice[0]; $line->total_tva = $tabprice[1]; $line->total_ttc = $tabprice[2]; From 2e9952439eda99508431da5ad0aa6e2054ad9ae5 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Mon, 27 Nov 2017 15:03:34 +0100 Subject: [PATCH 20/64] Fix stat don in multicompany --- htdocs/don/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/don/index.php b/htdocs/don/index.php index 4912b6d8f1a..8ccb6893a91 100644 --- a/htdocs/don/index.php +++ b/htdocs/don/index.php @@ -54,7 +54,7 @@ $nb=array(); $somme=array(); $sql = "SELECT count(d.rowid) as nb, sum(d.amount) as somme , d.fk_statut"; -$sql.= " FROM ".MAIN_DB_PREFIX."don as d"; +$sql.= " FROM ".MAIN_DB_PREFIX."don as d WHERE d.entity IN (".getEntity('donation').")"; $sql.= " GROUP BY d.fk_statut"; $sql.= " ORDER BY d.fk_statut"; From 780e8ce47005f4560e53ab963d1c099966eaa147 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Mon, 27 Nov 2017 15:13:14 +0100 Subject: [PATCH 21/64] fix for multicompany --- htdocs/core/modules/mailings/fraise.modules.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/htdocs/core/modules/mailings/fraise.modules.php b/htdocs/core/modules/mailings/fraise.modules.php index 05d9e525652..9fc82a2f952 100644 --- a/htdocs/core/modules/mailings/fraise.modules.php +++ b/htdocs/core/modules/mailings/fraise.modules.php @@ -65,7 +65,7 @@ class mailing_fraise extends MailingTargets */ function getSqlArrayForStats() { - global $langs; + global $conf, $langs; $langs->load("members"); @@ -73,7 +73,7 @@ class mailing_fraise extends MailingTargets $statssql=array(); $statssql[0] ="SELECT '".$this->db->escape($langs->trans("FundationMembers"))."' as label, count(*) as nb"; - $statssql[0].=" FROM ".MAIN_DB_PREFIX."adherent where statut = 1"; + $statssql[0].=" FROM ".MAIN_DB_PREFIX."adherent where statut = 1 and entity = ".$conf->entity; return $statssql; } @@ -89,9 +89,11 @@ class mailing_fraise extends MailingTargets */ function getNbOfRecipients($sql='') { + global $conf; + $sql = "SELECT count(distinct(a.email)) as nb"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent as a"; - $sql .= " WHERE (a.email IS NOT NULL AND a.email != '')"; + $sql .= " WHERE (a.email IS NOT NULL AND a.email != '') AND a.entity = ".$conf->entity; // La requete doit retourner un champ "nb" pour etre comprise // par parent::getNbOfRecipients From a9e4fcfdca6fa094e0115e215a728d36196f3874 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Mon, 27 Nov 2017 15:49:28 +0100 Subject: [PATCH 22/64] Update fraise.modules.php --- htdocs/core/modules/mailings/fraise.modules.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/mailings/fraise.modules.php b/htdocs/core/modules/mailings/fraise.modules.php index 9fc82a2f952..f0b834c53ba 100644 --- a/htdocs/core/modules/mailings/fraise.modules.php +++ b/htdocs/core/modules/mailings/fraise.modules.php @@ -73,7 +73,7 @@ class mailing_fraise extends MailingTargets $statssql=array(); $statssql[0] ="SELECT '".$this->db->escape($langs->trans("FundationMembers"))."' as label, count(*) as nb"; - $statssql[0].=" FROM ".MAIN_DB_PREFIX."adherent where statut = 1 and entity = ".$conf->entity; + $statssql[0].=" FROM ".MAIN_DB_PREFIX."adherent where statut = 1 and entity IN (".getEntity('member').")"; return $statssql; } @@ -93,7 +93,7 @@ class mailing_fraise extends MailingTargets $sql = "SELECT count(distinct(a.email)) as nb"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent as a"; - $sql .= " WHERE (a.email IS NOT NULL AND a.email != '') AND a.entity = ".$conf->entity; + $sql .= " WHERE (a.email IS NOT NULL AND a.email != '') AND a.entity IN (".getEntity('member').")"; // La requete doit retourner un champ "nb" pour etre comprise // par parent::getNbOfRecipients From d0ab117488163894396aa0b9e95cebce50fa7a8b Mon Sep 17 00:00:00 2001 From: jfefe Date: Tue, 28 Nov 2017 15:06:23 +0100 Subject: [PATCH 23/64] FIX : external user cannot be set as internal --- htdocs/user/card.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 846c9dffc9a..47ec64931d4 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -9,7 +9,7 @@ * Copyright (C) 2012 Juanjo Menent * Copyright (C) 2013 Florian Henry * Copyright (C) 2013-2016 Alexandre Spangaro - * Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2015-2017 Jean-François Ferry * Copyright (C) 2015 Ari Elbaz (elarifr) * Copyright (C) 2015 Charlie Benke * Copyright (C) 2016 Raphaël Doursenaud @@ -415,8 +415,8 @@ if (empty($reshook)) { } } - if (!$error && GETPOST('contactid', 'int')) { - $contactid = GETPOST('contactid', 'int'); + $contactid = GETPOST('contactid', 'int'); + if (!$error && $contactid >= 0) { if ($contactid > 0) { $contact = new Contact($db); From 883c9dbf99c28d099496c778d98eba69ad2e8c23 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Wed, 29 Nov 2017 09:28:03 +0100 Subject: [PATCH 24/64] Fix for multicompany last fix for multicompany compliance --- htdocs/core/modules/mailings/fraise.modules.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/mailings/fraise.modules.php b/htdocs/core/modules/mailings/fraise.modules.php index f0b834c53ba..be3c2702047 100644 --- a/htdocs/core/modules/mailings/fraise.modules.php +++ b/htdocs/core/modules/mailings/fraise.modules.php @@ -203,7 +203,7 @@ class mailing_fraise extends MailingTargets $sql.= " a.lastname, a.firstname,"; $sql.= " a.datefin, a.civility as civility_id, a.login, a.societe"; // Other fields $sql.= " FROM ".MAIN_DB_PREFIX."adherent as a, ".MAIN_DB_PREFIX."adherent_type as ta"; - $sql.= " WHERE a.email <> ''"; // Note that null != '' is false + $sql.= " WHERE a.email <> '' AND a.entity IN (".getEntity('member').")"; // Note that null != '' is false $sql.= " AND a.email NOT IN (SELECT email FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE fk_mailing=".$mailing_id.")"; if (isset($_POST["filter"]) && $_POST["filter"] == '-1') $sql.= " AND a.statut=-1"; if (isset($_POST["filter"]) && $_POST["filter"] == '1a') $sql.= " AND a.statut=1 AND a.datefin >= '".$this->db->idate($now)."'"; From c194538609eae4e167c3f5778e62aeb7dd9c886e Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Wed, 29 Nov 2017 10:45:16 +0100 Subject: [PATCH 25/64] Update fraise.modules.php --- htdocs/core/modules/mailings/fraise.modules.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/mailings/fraise.modules.php b/htdocs/core/modules/mailings/fraise.modules.php index be3c2702047..3ff5901f1b2 100644 --- a/htdocs/core/modules/mailings/fraise.modules.php +++ b/htdocs/core/modules/mailings/fraise.modules.php @@ -203,7 +203,7 @@ class mailing_fraise extends MailingTargets $sql.= " a.lastname, a.firstname,"; $sql.= " a.datefin, a.civility as civility_id, a.login, a.societe"; // Other fields $sql.= " FROM ".MAIN_DB_PREFIX."adherent as a, ".MAIN_DB_PREFIX."adherent_type as ta"; - $sql.= " WHERE a.email <> '' AND a.entity IN (".getEntity('member').")"; // Note that null != '' is false + $sql.= " WHERE a.entity IN (".getEntity('member').") AND a.email <> ''"; // Note that null != '' is false $sql.= " AND a.email NOT IN (SELECT email FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE fk_mailing=".$mailing_id.")"; if (isset($_POST["filter"]) && $_POST["filter"] == '-1') $sql.= " AND a.statut=-1"; if (isset($_POST["filter"]) && $_POST["filter"] == '1a') $sql.= " AND a.statut=1 AND a.datefin >= '".$this->db->idate($now)."'"; From f04af6c1b3a4e4b5014cd69ed72a7358b3d1f521 Mon Sep 17 00:00:00 2001 From: gauthier Date: Wed, 29 Nov 2017 11:06:33 +0100 Subject: [PATCH 26/64] FIX : test for filter fk_status --- htdocs/compta/facture/stats/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/stats/index.php b/htdocs/compta/facture/stats/index.php index 4d9fdebeb64..6670ed763e1 100644 --- a/htdocs/compta/facture/stats/index.php +++ b/htdocs/compta/facture/stats/index.php @@ -84,7 +84,7 @@ dol_mkdir($dir); $stats = new FactureStats($db, $socid, $mode, ($userid>0?$userid:0)); if ($mode == 'customer') { - if ($object_status != '' && $object_status >= -1) $stats->where .= ' AND f.fk_statut IN ('.$object_status.')'; + if ($object_status != '' && $object_status >= 0) $stats->where .= ' AND f.fk_statut IN ('.$object_status.')'; } if ($mode == 'supplier') { From dbde97f25f1f120ca042cb75fa337eca83328684 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 29 Nov 2017 15:07:09 +0100 Subject: [PATCH 27/64] Update card.php --- htdocs/user/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 47ec64931d4..1885740b489 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -415,8 +415,8 @@ if (empty($reshook)) { } } - $contactid = GETPOST('contactid', 'int'); - if (!$error && $contactid >= 0) { + if (!$error && GETPOSTISSET('contactid')) { + $contactid = GETPOST('contactid', 'int'); if ($contactid > 0) { $contact = new Contact($db); From 9fa6bfd1a597835cfb1f2dcd9350bbd47e6bd0b0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 29 Nov 2017 15:30:41 +0100 Subject: [PATCH 28/64] Fix edit external user or not --- htdocs/core/lib/functions.lib.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index b58d24ba028..4c6730500af 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -238,6 +238,17 @@ function dol_shutdown() } +/** + * Return true if we are in a context of submitting a parameter + * + * @param string $paramname Name or parameter to test + * @return boolean True if we have just submit a POST or GET request with the parameter provided (even if param is empty) + */ +function GETPOSTISSET($paramname) +{ + return (isset($_POST[$paramname]) || isset($_GET[$paramname])); +} + /** * Return value of a param into GET or POST supervariable. * Use the property $user->default_values[path]['creatform'] and/or $user->default_values[path]['filters'] and/or $user->default_values[path]['sortorder'] From b7f26ea788c49724069d0c244f9ec91224aed1d7 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 30 Nov 2017 11:10:01 +0100 Subject: [PATCH 29/64] FIX add line bad price and ref --- htdocs/fourn/commande/card.php | 2 +- htdocs/product/class/product.class.php | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 05bbc26e5fc..3af489e1ca5 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -390,7 +390,7 @@ if (empty($reshook)) $localtax1_tx, $localtax2_tx, $idprod, - $productsupplier->id, + $productsupplier->product_fourn_price_id , $productsupplier->fourn_ref, $remise_percent, 'HT', diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 2e2f3007540..07aaf32cbb3 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -1384,6 +1384,7 @@ class Product extends CommonObject $this->fourn_pu = $obj->price / $obj->quantity; // Unit price of product of supplier $this->fourn_price_base_type = 'HT'; // Price base type $this->ref_fourn = $obj->ref_fourn; // deprecated + $this->product_fourn_price_id = $obj->rowid; // supplier price id $this->ref_supplier = $obj->ref_fourn; // Ref supplier $this->vatrate_supplier = $obj->tva_tx; // Vat ref supplier $result=$obj->fk_product; @@ -1428,6 +1429,7 @@ class Product extends CommonObject $this->fourn_qty = $obj->quantity; // min quantity for price for a virtual supplier $this->fourn_pu = $obj->price / $obj->quantity; // Unit price of product for a virtual supplier $this->fourn_price_base_type = 'HT'; // Price base type for a virtual supplier + $this->product_fourn_price_id = $obj->rowid; // supplier price id $this->ref_fourn = $obj->ref_supplier; // deprecated $this->ref_supplier = $obj->ref_supplier; // Ref supplier $this->vatrate_supplier = $obj->tva_tx; // Vat ref supplier From b2effa7cc8c93b0495a6209a31bb9b967459fa49 Mon Sep 17 00:00:00 2001 From: Alexis ALGOUD Date: Thu, 30 Nov 2017 11:36:35 +0100 Subject: [PATCH 30/64] fix travis --- htdocs/fourn/commande/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 3af489e1ca5..c241b2a2ffa 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -390,7 +390,7 @@ if (empty($reshook)) $localtax1_tx, $localtax2_tx, $idprod, - $productsupplier->product_fourn_price_id , + $productsupplier->product_fourn_price_id, $productsupplier->fourn_ref, $remise_percent, 'HT', From 03fd69c3b9c840fd7274c622b5ddc87b879622e9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 1 Dec 2017 16:48:43 +0100 Subject: [PATCH 31/64] Fix missing lang --- htdocs/expedition/list.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/htdocs/expedition/list.php b/htdocs/expedition/list.php index ab5fa27b13f..1a712b66650 100644 --- a/htdocs/expedition/list.php +++ b/htdocs/expedition/list.php @@ -30,9 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; -$langs->load("sendings"); -$langs->load("deliveries"); -$langs->load('companies'); +$langs->loadLangs(array("sendings","deliveries",'companies','bills')); $socid=GETPOST('socid','int'); // Security check From 44e5566ee58d2e9b7543a669ea4323fb54e59f71 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 2 Dec 2017 14:17:49 +0100 Subject: [PATCH 32/64] Update changelog --- ChangeLog | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/ChangeLog b/ChangeLog index 541e7963d36..3c56559f8d0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,27 @@ English Dolibarr ChangeLog -------------------------------------------------------------- +***** ChangeLog for 6.0.4 compared to 6.0.3 ***** +FIX: #7737 +FIX: #7751 +FIX: #7756 Add better error message +FIX: #7786 +FIX: #7806 +FIX: #7824 +FIX: add line bad price and ref +FIX: A lot of several fix on local taxes and NPR tax +FIX: createfromorder +FIX: CSS for IE10 +FIX: external user cannot be set as internal +FIX: Filter type on actioncomm with multiselect doesn't work +FIX: list of donation not filtered on multicompany +FIX: list of module not complete when module mb_strlen not available +FIX: Locatax were not propagated when cloning order or proposal +FIX: Searching translation should not be case sensitive +FIX: Search into language is ok for file into external modules two. +FIX: test for filter fk_status +FIX: too much users on holiday list +FIX: Wrong alias sql ***** ChangeLog for 6.0.3 compared to 6.0.2 ***** FIX: #7211 Update qty dispatched on qty change From 365639a6c00422d79db569e75e46014a42e0b5f1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 5 Dec 2017 11:54:26 +0100 Subject: [PATCH 33/64] Prepare 6.0.5 --- htdocs/filefunc.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php index 7e7f2de8492..879205cb491 100644 --- a/htdocs/filefunc.inc.php +++ b/htdocs/filefunc.inc.php @@ -31,7 +31,7 @@ */ if (! defined('DOL_APPLICATION_TITLE')) define('DOL_APPLICATION_TITLE','Dolibarr'); -if (! defined('DOL_VERSION')) define('DOL_VERSION','6.0.4'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c +if (! defined('DOL_VERSION')) define('DOL_VERSION','6.0.5'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c if (! defined('EURO')) define('EURO',chr(128)); From 340287f073686ace946816efe8f89e9cf50654fc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 5 Dec 2017 11:53:19 +0100 Subject: [PATCH 34/64] FIX #7903 Conflicts: htdocs/holiday/class/holiday.class.php --- htdocs/holiday/class/holiday.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 6572d1836fa..5020684c8e0 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -989,7 +989,7 @@ class Holiday extends CommonObject while ($i < $nbUser) { $now_holiday = $this->getCPforUser($users[$i]['rowid'], $val['rowid']); - $new_solde = $now_holiday + $this->getConfCP('nbHolidayEveryMonth'); + $new_solde = $now_holiday + $nb_holiday; // We add a log for each user $this->addLogCP($user->id, $users[$i]['rowid'], $langs->trans('HolidaysMonthlyUpdate'), $new_solde, $val['rowid']); From c70dff89dde708b64ab4266754d5562454f75ebb Mon Sep 17 00:00:00 2001 From: atm-ph Date: Wed, 6 Dec 2017 12:13:15 +0100 Subject: [PATCH 35/64] Fix $boad instead of $board --- htdocs/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/index.php b/htdocs/index.php index ae4ec72a901..195d583046f 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -548,7 +548,7 @@ if (! empty($valid_dashboardlines)) $boxwork.=''; - print ''; - print '\n"; - print '\n"; - print '\n"; - print ''; + print ''; + print ''; + print '\n"; + print '\n"; + print '\n"; + print ''; - // Link to payment - print ''; - // Link to bank transaction - print ''; + // Link to payment + print ''; + // Link to bank transaction + print ''; - print '' ; - print ''; + print '' ; + print ''; - $i++; - } + $i++; + } } print "
'. - $form->select_date('', 'search_date', 0, 0, 1, '', 1, 0, 1, 0, ''). + $form->select_date($search_date, 'search_date', 0, 0, 1, '', 1, 0, 1, 0, ''). ''; $src = DOL_URL_ROOT . '/theme/' . $conf->theme . '/img/search.png'; From 35182066a8dcfd1686a24c1d75615d8575e89156 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sun, 19 Nov 2017 16:25:35 +0100 Subject: [PATCH 08/64] update createfromorder lack of 2 fields date_start and date_end not imported from order --- htdocs/compta/facture/class/facture.class.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index e704a5a229a..840bb93a49f 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -939,7 +939,8 @@ class Facture extends CommonInvoice { $this->db->commit(); return $this->id; - } + + } else { $this->db->rollback(); @@ -989,6 +990,8 @@ class Facture extends CommonInvoice $line->special_code = $object->lines[$i]->special_code; $line->fk_parent_line = $object->lines[$i]->fk_parent_line; $line->fk_unit = $object->lines[$i]->fk_unit; + $line->date_start = $object->lines[$i]->date_start; + $line->date_end = $object->lines[$i]->date_end; $line->fk_fournprice = $object->lines[$i]->fk_fournprice; $marginInfos = getMarginInfos($object->lines[$i]->subprice, $object->lines[$i]->remise_percent, $object->lines[$i]->tva_tx, $object->lines[$i]->localtax1_tx, $object->lines[$i]->localtax2_tx, $object->lines[$i]->fk_fournprice, $object->lines[$i]->pa_ht); From 3f360601affe69cd4b963cc41faa921c11d01e20 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sun, 19 Nov 2017 21:52:18 +0100 Subject: [PATCH 09/64] Fix entity Fix entity in list.php --- htdocs/don/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/don/list.php b/htdocs/don/list.php index 9602b69a615..c93dcad0224 100644 --- a/htdocs/don/list.php +++ b/htdocs/don/list.php @@ -89,7 +89,7 @@ $sql = "SELECT d.rowid, d.datedon, d.firstname, d.lastname, d.societe,"; $sql.= " d.amount, d.fk_statut as statut, "; $sql.= " p.rowid as pid, p.ref, p.title, p.public"; $sql.= " FROM ".MAIN_DB_PREFIX."don as d LEFT JOIN ".MAIN_DB_PREFIX."projet AS p"; -$sql.= " ON p.rowid = d.fk_projet WHERE 1 = 1"; +$sql.= " ON p.rowid = d.fk_projet WHERE d.entity = ".$conf->entity.""; if ($statut != '' && $statut != '-1') { $sql .= " AND d.fk_statut IN (".$db->escape($statut).")"; From 5d6555b9dd7a9bc19c1e2b098b81c599b105a578 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sun, 19 Nov 2017 21:54:14 +0100 Subject: [PATCH 10/64] Update list.php --- htdocs/don/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/don/list.php b/htdocs/don/list.php index c93dcad0224..cb5ab766ae9 100644 --- a/htdocs/don/list.php +++ b/htdocs/don/list.php @@ -89,7 +89,7 @@ $sql = "SELECT d.rowid, d.datedon, d.firstname, d.lastname, d.societe,"; $sql.= " d.amount, d.fk_statut as statut, "; $sql.= " p.rowid as pid, p.ref, p.title, p.public"; $sql.= " FROM ".MAIN_DB_PREFIX."don as d LEFT JOIN ".MAIN_DB_PREFIX."projet AS p"; -$sql.= " ON p.rowid = d.fk_projet WHERE d.entity = ".$conf->entity.""; +$sql.= " ON p.rowid = d.fk_projet WHERE d.entity IN (".getEntity('donation').")"; if ($statut != '' && $statut != '-1') { $sql .= " AND d.fk_statut IN (".$db->escape($statut).")"; From a9bfe0f48f2502ad3ee0c22a998c8b87292eec31 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 9 Sep 2017 17:48:04 +0200 Subject: [PATCH 11/64] Fix: some problems with medias in multicompany (backport 6.0 commit 762b4eb8768a0b09d69c06529566954f7efbc1c0) --- htdocs/core/class/conf.class.php | 5 +++++ htdocs/core/lib/files.lib.php | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 203d41571a9..da55a9f5668 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -88,6 +88,7 @@ class Conf $this->user = new stdClass(); $this->syslog = new stdClass(); $this->browser = new stdClass(); + $this->medias = new stdClass(); $this->multicompany = new stdClass(); //! Charset for HTML output and for storing data in memory @@ -328,6 +329,10 @@ class Conf $this->propal->dir_output=$rootfordata."/propale"; $this->propal->dir_temp=$rootfordata."/propale/temp"; + // For medias storage + $this->medias->multidir_output = array($this->entity => $rootfordata."/medias"); + $this->medias->multidir_temp = array($this->entity => $rootfordata."/medias/temp"); + // Exception: Some dir are not the name of module. So we keep exception here // for backward compatibility. diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 5d3c209bdc7..b573a9588ae 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1857,7 +1857,7 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$fu elseif ($modulepart == 'medias' && !empty($dolibarr_main_data_root)) { $accessallowed=1; - $original_file=$dolibarr_main_data_root.'/medias/'.$original_file; + $original_file=$conf->medias->multidir_output[$entity].'/'.$original_file; } // Wrapping for backups From 219e58d0e4e1294e952b89a86bbbb1ec766b30bd Mon Sep 17 00:00:00 2001 From: atm-ph Date: Wed, 22 Nov 2017 12:15:02 +0100 Subject: [PATCH 12/64] Fix product type is ignored and can generate a diffrent result with situation invoice --- htdocs/compta/facture/class/facture.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 60970b5b1e2..3c60e0b6679 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2710,7 +2710,7 @@ class Facture extends CommonInvoice $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. } - $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type, $situation_percent, $this->multicurrency_tx, $pu_ht_devise); + $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, $type, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type, $situation_percent, $this->multicurrency_tx, $pu_ht_devise); $total_ht = $tabprice[0]; $total_tva = $tabprice[1]; From e1344eb97cd12b745b29a2216b784633b022dd70 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 22 Nov 2017 17:25:31 +0100 Subject: [PATCH 13/64] Fix edit of time spent --- htdocs/projet/tasks/time.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 9a513a4bce6..33642d4d3b6 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -975,19 +975,19 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) print '
'; print ''; } - else if ($user->rights->projet->lire) // Read project and enter time consumed on assigned tasks + else if ($user->rights->projet->lire || $user->rights->projet->all->creer) // Read project and enter time consumed on assigned tasks { - if ($task_time->fk_user == $user->id || in_array($task_time->fk_user, $childids)) - { - print ' '; - print 'rowid.($withproject?'&withproject=1':'').'">'; - print img_edit(); - print ''; + if ($task_time->fk_user == $user->id || in_array($task_time->fk_user, $childids) || $user->rights->projet->all->creer) + { + print ' '; + print 'rowid.($withproject?'&withproject=1':'').'">'; + print img_edit(); + print ''; - print ' '; - print 'rowid.($withproject?'&withproject=1':'').'">'; - print img_delete(); - print ''; + print ' '; + print 'rowid.($withproject?'&withproject=1':'').'">'; + print img_delete(); + print ''; } } print '
'; foreach($valid_dashboardlines as $board) { - if (empty($boad->nbtodo)) $nbworkboardempty++; + if (empty($board->nbtodo)) $nbworkboardempty++; $textlate = $langs->trans("NActionsLate",$board->nbtodolate); $textlate.= ' ('.$langs->trans("Late").' = '.$langs->trans("DateReference").' > '.$langs->trans("DateToday").' '.(ceil($board->warning_delay) >= 0 ? '+' : '').ceil($board->warning_delay).' '.$langs->trans("days").')'; From c90ece118818aeae07004be094dced378bcd248b Mon Sep 17 00:00:00 2001 From: atm-ph Date: Wed, 6 Dec 2017 14:22:37 +0100 Subject: [PATCH 36/64] Fix include class WorkboardResponse --- htdocs/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/index.php b/htdocs/index.php index ee3c2490aeb..2df4365e227 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -383,7 +383,7 @@ if ($showweather) $boxwork.='agenda->enabled) && $user->rights->agenda->myactions->read) From 95fa183fac33b7ea8432ae213534b70502e50702 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 8 Dec 2017 08:49:03 +0100 Subject: [PATCH 37/64] Fix: Avoid warning "A non-numeric value encountered" --- htdocs/compta/paiement/cheque/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/paiement/cheque/card.php b/htdocs/compta/paiement/cheque/card.php index 01787ca3372..a9810396e0c 100644 --- a/htdocs/compta/paiement/cheque/card.php +++ b/htdocs/compta/paiement/cheque/card.php @@ -53,7 +53,7 @@ $sortorder=GETPOST('sortorder', 'alpha'); $page=GETPOST('page', 'int'); if (! $sortorder) $sortorder="ASC"; if (! $sortfield) $sortfield="b.dateo,b.rowid"; -if ($page < 0) { $page = 0 ; } +if (empty($page) || $page == -1) { $page = 0; } $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; $offset = $limit * $page ; From 8e1a9064cb053eebf4db0bacbc47d742c986f62f Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 8 Dec 2017 09:00:05 +0100 Subject: [PATCH 38/64] Fix: avoid warning again --- htdocs/compta/paiement/cheque/card.php | 87 +++++++++++++------------- 1 file changed, 44 insertions(+), 43 deletions(-) diff --git a/htdocs/compta/paiement/cheque/card.php b/htdocs/compta/paiement/cheque/card.php index a9810396e0c..7029bd6ec72 100644 --- a/htdocs/compta/paiement/cheque/card.php +++ b/htdocs/compta/paiement/cheque/card.php @@ -490,53 +490,54 @@ if ($action == 'new') if (count($lines[$bid])) { - foreach ($lines[$bid] as $lid => $value) - { - $account_id = $bid; - if (! isset($accounts[$bid])) - $accounts[$bid]=0; - $accounts[$bid] += 1; + foreach ($lines[$bid] as $lid => $value) + { + $account_id = $bid; + if (! isset($accounts[$bid]) || $accounts[$bid] == '') { + $accounts[$bid]=0; + } + $accounts[$bid] += 1; - print '
'.dol_print_date($value["date"],'day').''.$value["numero"]."'.$value["emetteur"]."'.$value["banque"]."'.price($value["amount"], 0, $langs, 1, -1, -1, $conf->currency).'
'.dol_print_date($value["date"],'day').''.$value["numero"]."'.$value["emetteur"]."'.$value["banque"]."'.price($value["amount"], 0, $langs, 1, -1, -1, $conf->currency).''; - $paymentstatic->id=$value["paymentid"]; - $paymentstatic->ref=$value["paymentid"]; - if ($paymentstatic->id) - { - print $paymentstatic->getNomUrl(1); - } - else - { - print ' '; - } - print ''; - $accountlinestatic->rowid=$value["id"]; - if ($accountlinestatic->rowid) - { - print $accountlinestatic->getNomUrl(1); - } - else - { - print ' '; - } - print ''; + $paymentstatic->id=$value["paymentid"]; + $paymentstatic->ref=$value["paymentid"]; + if ($paymentstatic->id) + { + print $paymentstatic->getNomUrl(1); + } + else + { + print ' '; + } + print ''; + $accountlinestatic->rowid=$value["id"]; + if ($accountlinestatic->rowid) + { + print $accountlinestatic->getNomUrl(1); + } + else + { + print ' '; + } + print ''; - print ''; - print '
'; + print ''; + print '
"; print ''; From c4b2c3e6976f98f5f3700ebe3b886f26979e8a04 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 8 Dec 2017 09:16:36 +0100 Subject: [PATCH 39/64] FIXME $accounts[$bid] is a label ! --- htdocs/compta/paiement/cheque/card.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/htdocs/compta/paiement/cheque/card.php b/htdocs/compta/paiement/cheque/card.php index 7029bd6ec72..eb69a386719 100644 --- a/htdocs/compta/paiement/cheque/card.php +++ b/htdocs/compta/paiement/cheque/card.php @@ -492,11 +492,12 @@ if ($action == 'new') { foreach ($lines[$bid] as $lid => $value) { - $account_id = $bid; - if (! isset($accounts[$bid]) || $accounts[$bid] == '') { + //$account_id = $bid; FIXME not used + + // FIXME $accounts[$bid] is a label ! + /*if (! isset($accounts[$bid])) $accounts[$bid]=0; - } - $accounts[$bid] += 1; + $accounts[$bid] += 1;*/ print '
'.dol_print_date($value["date"],'day').'
'.$i.'
' . fieldLabel('MulticurrencyAmountHT','multicurrency_total_ht') . '' . price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '
' . fieldLabel('MulticurrencyAmountVAT','multicurrency_total_tva') . '' . price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '
' . fieldLabel('MulticurrencyAmountTTC','multicurrency_total_ttc') . '' . price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '
' . $langs->trans('AmountHT') . '' . price($object->total_ht, 1, '', 1, - 1, - 1, $conf->currency) . '
'; print ''; - + print "
\n"; dol_fiche_end(); diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index ad5f69edfc0..7290881bd6e 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -1504,12 +1504,32 @@ if (empty($reshook)) // Add custom code and origin country into description if (empty($conf->global->MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE) && (! empty($prod->customcode) || ! empty($prod->country_code))) { $tmptxt = '('; - if (! empty($prod->customcode)) - $tmptxt .= $langs->transnoentitiesnoconv("CustomCode") . ': ' . $prod->customcode; - if (! empty($prod->customcode) && ! empty($prod->country_code)) - $tmptxt .= ' - '; - if (! empty($prod->country_code)) - $tmptxt .= $langs->transnoentitiesnoconv("CountryOrigin") . ': ' . getCountry($prod->country_code, 0, $db, $langs, 0); + // Define output language + if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { + $outputlangs = $langs; + $newlang = ''; + if (empty($newlang) && GETPOST('lang_id','alpha')) + $newlang = GETPOST('lang_id','alpha'); + if (empty($newlang)) + $newlang = $object->thirdparty->default_lang; + if (! empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + if (! empty($prod->customcode)) + $tmptxt .= $outputlangs->transnoentitiesnoconv("CustomCode") . ': ' . $prod->customcode; + if (! empty($prod->customcode) && ! empty($prod->country_code)) + $tmptxt .= ' - '; + if (! empty($prod->country_code)) + $tmptxt .= $outputlangs->transnoentitiesnoconv("CountryOrigin") . ': ' . getCountry($prod->country_code, 0, $db, $outputlangs, 0); + } else { + if (! empty($prod->customcode)) + $tmptxt .= $langs->transnoentitiesnoconv("CustomCode") . ': ' . $prod->customcode; + if (! empty($prod->customcode) && ! empty($prod->country_code)) + $tmptxt .= ' - '; + if (! empty($prod->country_code)) + $tmptxt .= $langs->transnoentitiesnoconv("CountryOrigin") . ': ' . getCountry($prod->country_code, 0, $db, $langs, 0); + } $tmptxt .= ')'; $desc = dol_concatdesc($desc, $tmptxt); } From 1b16eb731d88ed8f2af3ee44955fa4874b7c86e5 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 8 Dec 2017 11:00:23 +0100 Subject: [PATCH 42/64] Fix: missing load product translation file --- htdocs/comm/propal/card.php | 1 + htdocs/commande/card.php | 1 + htdocs/compta/facture.php | 1 + 3 files changed, 3 insertions(+) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index a43fb982ee6..e0a4c19c9cb 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -855,6 +855,7 @@ if (empty($reshook)) if (! empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); + $outputlangs->load('products'); } if (! empty($prod->customcode)) $tmptxt .= $outputlangs->transnoentitiesnoconv("CustomCode") . ': ' . $prod->customcode; diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index cf3d5efde3d..d84495da26a 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -812,6 +812,7 @@ if (empty($reshook)) if (! empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); + $outputlangs->load('products'); } if (! empty($prod->customcode)) $tmptxt .= $outputlangs->transnoentitiesnoconv("CustomCode") . ': ' . $prod->customcode; diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 7290881bd6e..b5b200aa540 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -1515,6 +1515,7 @@ if (empty($reshook)) if (! empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); + $outputlangs->load('products'); } if (! empty($prod->customcode)) $tmptxt .= $outputlangs->transnoentitiesnoconv("CustomCode") . ': ' . $prod->customcode; From eb03f8f08e35e7dfcb75be7f29cfe511ba58ed8b Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Fri, 8 Dec 2017 15:03:42 +0100 Subject: [PATCH 43/64] fix MAIN_COPY_FILE_IN_EVENT_AUTO --- htdocs/core/actions_sendmails.inc.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php index fca8ac511da..a888e4a7656 100644 --- a/htdocs/core/actions_sendmails.inc.php +++ b/htdocs/core/actions_sendmails.inc.php @@ -413,6 +413,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO $object->trackid = $trackid; $object->fk_element = $object->id; $object->elementtype = $object->element; + $object->attachedfiles = $attachedfiles; // Call of triggers if (! empty($trigger_name)) From 60fc500fa80365783becad9ffbcfee1b9736ab22 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sun, 10 Dec 2017 07:00:46 +0100 Subject: [PATCH 44/64] FIX : Edit accountancy account and warning message on loan --- htdocs/loan/card.php | 588 ++++++++++++------------ htdocs/loan/class/loan.class.php | 744 ++++++++++++++++--------------- 2 files changed, 671 insertions(+), 661 deletions(-) diff --git a/htdocs/loan/card.php b/htdocs/loan/card.php index 4f61aa833bf..f44316ba45d 100644 --- a/htdocs/loan/card.php +++ b/htdocs/loan/card.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2014-2017 Alexandre Spangaro * Copyright (C) 2015 Frederic France * Copyright (C) 2017 Laurent Destailleur * @@ -18,9 +18,9 @@ */ /** - * \file htdocs/loan/card.php - * \ingroup loan - * \brief Loan card + * \file htdocs/loan/card.php + * \ingroup loan + * \brief Loan card */ require '../main.inc.php'; @@ -61,129 +61,81 @@ $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if (empty($reshook)) { - // Classify paid - if ($action == 'confirm_paid' && $confirm == 'yes') - { - $object->fetch($id); - $result = $object->set_paid($user); - if ($result > 0) - { - setEventMessages($langs->trans('LoanPaid'), null, 'mesgs'); - } - else - { - setEventMessages($loan->error, null, 'errors'); - } - } + // Classify paid + if ($action == 'confirm_paid' && $confirm == 'yes') + { + $object->fetch($id); + $result = $object->set_paid($user); + if ($result > 0) + { + setEventMessages($langs->trans('LoanPaid'), null, 'mesgs'); + } + else + { + setEventMessages($loan->error, null, 'errors'); + } + } - // Delete loan - if ($action == 'confirm_delete' && $confirm == 'yes') - { - $object->fetch($id); - $result=$object->delete($user); - if ($result > 0) - { - setEventMessages($langs->trans('LoanDeleted'), null, 'mesgs'); - header("Location: index.php"); - exit; - } - else - { - setEventMessages($loan->error, null, 'errors'); - } - } + // Delete loan + if ($action == 'confirm_delete' && $confirm == 'yes') + { + $object->fetch($id); + $result=$object->delete($user); + if ($result > 0) + { + setEventMessages($langs->trans('LoanDeleted'), null, 'mesgs'); + header("Location: index.php"); + exit; + } + else + { + setEventMessages($loan->error, null, 'errors'); + } + } - // Add loan - if ($action == 'add' && $user->rights->loan->write) - { - if (! $cancel) - { - $datestart = dol_mktime(12, 0, 0, GETPOST('startmonth','int'), GETPOST('startday','int'), GETPOST('startyear','int')); - $dateend = dol_mktime(12, 0, 0, GETPOST('endmonth','int'), GETPOST('endday','int'), GETPOST('endyear','int')); - $capital = price2num(GETPOST('capital')); - $rate = GETPOST('rate'); + // Add loan + if ($action == 'add' && $user->rights->loan->write) + { + if (! $cancel) + { + $datestart = dol_mktime(12, 0, 0, GETPOST('startmonth','int'), GETPOST('startday','int'), GETPOST('startyear','int')); + $dateend = dol_mktime(12, 0, 0, GETPOST('endmonth','int'), GETPOST('endday','int'), GETPOST('endyear','int')); + $capital = price2num(GETPOST('capital')); + $rate = GETPOST('rate'); - if (! $capital) - { - $error++; $action = 'create'; - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("LoanCapital")), null, 'errors'); - } - if (! $datestart) - { - $error++; $action = 'create'; - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("DateStart")), null, 'errors'); - } - if (! $dateend) - { - $error++; $action = 'create'; - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("DateEnd")), null, 'errors'); - } - if ($rate == '') - { - $error++; $action = 'create'; - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Rate")), null, 'errors'); - } + if (! $capital) + { + $error++; $action = 'create'; + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("LoanCapital")), null, 'errors'); + } + if (! $datestart) + { + $error++; $action = 'create'; + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("DateStart")), null, 'errors'); + } + if (! $dateend) + { + $error++; $action = 'create'; + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("DateEnd")), null, 'errors'); + } + if ($rate == '') + { + $error++; $action = 'create'; + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Rate")), null, 'errors'); + } - if (! $error) - { - $object->label = GETPOST('label'); - $object->fk_bank = GETPOST('accountid'); - $object->capital = $capital; - $object->datestart = $datestart; - $object->dateend = $dateend; - $object->nbterm = GETPOST('nbterm'); - $object->rate = $rate; - $object->note_private = GETPOST('note_private'); - $object->note_public = GETPOST('note_public'); - $object->fk_project = GETPOST('projectid','int'); - - $accountancy_account_capital = GETPOST('accountancy_account_capital'); - $accountancy_account_insurance = GETPOST('accountancy_account_insurance'); - $accountancy_account_interest = GETPOST('accountancy_account_interest'); - - if ($accountancy_account_capital <= 0) { $object->account_capital = ''; } else { $object->account_capital = $accountancy_account_capital; } - if ($accountancy_account_insurance <= 0) { $object->account_insurance = ''; } else { $object->account_insurance = $accountancy_account_insurance; } - if ($accountancy_account_interest <= 0) { $object->account_interest = ''; } else { $object->account_interest = $accountancy_account_interest; } - - $id=$object->create($user); - if ($id <= 0) - { - $error++; - setEventMessages($object->error, $object->errors, 'errors'); - $action = 'create'; - } - } - } - else - { - header("Location: index.php"); - exit(); - } - } - - // Update record - else if ($action == 'update' && $user->rights->loan->write) - { - if (! $cancel) - { - $result = $object->fetch($id); - - $datestart = dol_mktime(12, 0, 0, GETPOST('startmonth','int'), GETPOST('startday','int'), GETPOST('startyear','int')); - $dateend = dol_mktime(12, 0, 0, GETPOST('endmonth','int'), GETPOST('endday','int'), GETPOST('endyear','int')); - $capital = price2num(GETPOST('capital')); - - if (! $capital) - { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("LoanCapital")), null, 'errors'); - $action = 'edit'; - } - else - { - $object->datestart = $datestart; - $object->dateend = $dateend; - $object->capital = $capital; - $object->nbterm = GETPOST("nbterm"); - $object->rate = GETPOST("rate"); + if (! $error) + { + $object->label = GETPOST('label'); + $object->fk_bank = GETPOST('accountid'); + $object->capital = $capital; + $object->datestart = $datestart; + $object->dateend = $dateend; + $object->nbterm = GETPOST('nbterm'); + $object->rate = $rate; + $object->note_private = GETPOST('note_private'); + $object->note_public = GETPOST('note_public'); + $object->fk_project = GETPOST('projectid','int'); $accountancy_account_capital = GETPOST('accountancy_account_capital'); $accountancy_account_insurance = GETPOST('accountancy_account_insurance'); @@ -192,43 +144,91 @@ if (empty($reshook)) if ($accountancy_account_capital <= 0) { $object->account_capital = ''; } else { $object->account_capital = $accountancy_account_capital; } if ($accountancy_account_insurance <= 0) { $object->account_insurance = ''; } else { $object->account_insurance = $accountancy_account_insurance; } if ($accountancy_account_interest <= 0) { $object->account_interest = ''; } else { $object->account_interest = $accountancy_account_interest; } - } - $result = $object->update($user); + $id=$object->create($user); + if ($id <= 0) + { + $error++; + setEventMessages($object->error, $object->errors, 'errors'); + $action = 'create'; + } + } + } + else + { + header("Location: index.php"); + exit(); + } + } - if ($result > 0) - { - header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id); - exit; - } - else - { - setEventMessages($object->error, $object->errors, 'errors'); - } - } - else - { - header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id); - exit; - } - } + // Update record + else if ($action == 'update' && $user->rights->loan->write) + { + if (! $cancel) + { + $result = $object->fetch($id); + + $datestart = dol_mktime(12, 0, 0, GETPOST('startmonth','int'), GETPOST('startday','int'), GETPOST('startyear','int')); + $dateend = dol_mktime(12, 0, 0, GETPOST('endmonth','int'), GETPOST('endday','int'), GETPOST('endyear','int')); + $capital = price2num(GETPOST('capital')); + + if (! $capital) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("LoanCapital")), null, 'errors'); + $action = 'edit'; + } + else + { + $object->datestart = $datestart; + $object->dateend = $dateend; + $object->capital = $capital; + $object->nbterm = GETPOST("nbterm"); + $object->rate = GETPOST("rate"); + + $accountancy_account_capital = GETPOST('accountancy_account_capital'); + $accountancy_account_insurance = GETPOST('accountancy_account_insurance'); + $accountancy_account_interest = GETPOST('accountancy_account_interest'); + + if ($accountancy_account_capital <= 0) { $object->account_capital = ''; } else { $object->account_capital = $accountancy_account_capital; } + if ($accountancy_account_insurance <= 0) { $object->account_insurance = ''; } else { $object->account_insurance = $accountancy_account_insurance; } + if ($accountancy_account_interest <= 0) { $object->account_interest = ''; } else { $object->account_interest = $accountancy_account_interest; } + } + + $result = $object->update($user); + + if ($result > 0) + { + header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id); + exit; + } + else + { + setEventMessages($object->error, $object->errors, 'errors'); + } + } + else + { + header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id); + exit; + } + } // Link to a project if ($action == 'classin' && $user->rights->loan->write) { - $object->fetch($id); - $result = $object->setProject($projectid); + $object->fetch($id); + $result = $object->setProject($projectid); if ($result < 0) - setEventMessages($object->error, $object->errors, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } - if ($action == 'setlabel' && $user->rights->loan->write) - { - $object->fetch($id); - $result = $object->setValueFrom('label', GETPOST('label'), '', '', 'text', '', $user, 'LOAN_MODIFY'); - if ($result < 0) - setEventMessages($object->error, $object->errors, 'errors'); - } + if ($action == 'setlabel' && $user->rights->loan->write) + { + $object->fetch($id); + $result = $object->setValueFrom('label', GETPOST('label'), '', '', 'text', '', $user, 'LOAN_MODIFY'); + if ($result < 0) + setEventMessages($object->error, $object->errors, 'errors'); + } } @@ -249,19 +249,19 @@ llxHeader("",$title,$help_url); if ($action == 'create') { //WYSIWYG Editor - require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - print load_fiche_titre($langs->trans("NewLoan"), '', 'title_accountancy.png'); + print load_fiche_titre($langs->trans("NewLoan"), '', 'title_accountancy.png'); - $datec = dol_mktime(12, 0, 0, GETPOST('remonth','int'), GETPOST('reday','int'), GETPOST('reyear','int')); + $datec = dol_mktime(12, 0, 0, GETPOST('remonth','int'), GETPOST('reday','int'), GETPOST('reyear','int')); - print '
' . "\n"; - print ''; - print ''; + print '' . "\n"; + print ''; + print ''; dol_fiche_head(); - print ''; + print '
'; // Label print ''; @@ -280,97 +280,97 @@ if ($action == 'create') print ''; } - // Capital - print ''; + // Capital + print ''; // Date Start print ""; - print ''; + print ''; // Date End print ""; - print ''; + print ''; // Number of terms print ''; // Rate - print ''; + print ''; - // Project - if (! empty($conf->projet->enabled)) - { + // Project + if (! empty($conf->projet->enabled)) + { $formproject=new FormProjets($db); // Projet associe $langs->load("projects"); - print ''; - } + print ''; + } - // Note Private - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; - // Note Public - print ''; - print ''; - print ''; + // Note Public + print ''; + print ''; + print ''; - // Accountancy + // Accountancy if (! empty($conf->accounting->enabled)) { // Accountancy_account_capital - print ''; - print ''; + print ''; + print ''; // Accountancy_account_insurance - print ''; - print ''; + print ''; + print ''; // Accountancy_account_interest - print ''; - print ''; + print ''; + print ''; } else // For external software { - // Accountancy_account_capital - print ''; - print ''; + // Accountancy_account_capital + print ''; + print ''; // Accountancy_account_insurance - print ''; - print ''; + print ''; + print ''; // Accountancy_account_interest - print ''; - print ''; + print ''; + print ''; } print '
'.$langs->trans("Label").'
'.$langs->trans("LoanCapital").'
'.$langs->trans("LoanCapital").'
'.$langs->trans("DateStart").''; - print $form->select_date($datestart?$datestart:-1,'start','','','','add',1,1,1); - print '
'.$langs->trans("DateStart").''; + print $form->select_date($datestart?$datestart:-1,'start','','','','add',1,1,1); + print '
'.$langs->trans("DateEnd").''; - print $form->select_date($dateend?$dateend:-1,'end','','','','add',1,1,1); - print '
'.$langs->trans("DateEnd").''; + print $form->select_date($dateend?$dateend:-1,'end','','','','add',1,1,1); + print '
'.$langs->trans("Nbterms").'
'.$langs->trans("Rate").' %
'.$langs->trans("Rate").' %
'.$langs->trans("Project").''; + print '
'.$langs->trans("Project").''; - $numproject=$formproject->select_projects(-1, $projectid, 'projectid', 16, 0, 1, 1); + $numproject=$formproject->select_projects(-1, $projectid, 'projectid', 16, 0, 1, 1); - print '
'.$langs->trans('NotePrivate').''; + // Note Private + print '
'.$langs->trans('NotePrivate').''; - $doleditor = new DolEditor('note_private', GETPOST('note_private', 'alpha'), '', 160, 'dolibarr_notes', 'In', false, true, true, ROWS_6, '90%'); - print $doleditor->Create(1); + $doleditor = new DolEditor('note_private', GETPOST('note_private', 'alpha'), '', 160, 'dolibarr_notes', 'In', false, true, true, ROWS_6, '90%'); + print $doleditor->Create(1); - print '
'.$langs->trans('NotePublic').''; - $doleditor = new DolEditor('note_public', GETPOST('note_public', 'alpha'), '', 160, 'dolibarr_notes', 'In', false, true, true, ROWS_6, '90%'); - print $doleditor->Create(1); - print '
'.$langs->trans('NotePublic').''; + $doleditor = new DolEditor('note_public', GETPOST('note_public', 'alpha'), '', 160, 'dolibarr_notes', 'In', false, true, true, ROWS_6, '90%'); + print $doleditor->Create(1); + print '
'.$langs->trans("LoanAccountancyCapitalCode").''; + print '
'.$langs->trans("LoanAccountancyCapitalCode").''; print $formaccounting->select_account($object->accountancy_account_capital, 'accountancy_account_capital', 1, '', 0, 1); - print '
'.$langs->trans("LoanAccountancyInsuranceCode").''; + print '
'.$langs->trans("LoanAccountancyInsuranceCode").''; print $formaccounting->select_account($object->accountancy_account_insurance, 'accountancy_account_insurance', 1, '', 0, 1); - print '
'.$langs->trans("LoanAccountancyInterestCode").''; + print '
'.$langs->trans("LoanAccountancyInterestCode").''; print $formaccounting->select_account($object->accountancy_account_interest, 'accountancy_account_interest', 1, '', 0, 1); - print '
'.$langs->trans("LoanAccountancyCapitalCode").''; - print '
'.$langs->trans("LoanAccountancyCapitalCode").''; + print '
'.$langs->trans("LoanAccountancyInsuranceCode").''; - print '
'.$langs->trans("LoanAccountancyInsuranceCode").''; + print '
'.$langs->trans("LoanAccountancyInterestCode").''; - print '
'.$langs->trans("LoanAccountancyInterestCode").''; + print '
'; @@ -382,14 +382,14 @@ if ($action == 'create') print ''; print ''; - print '
'; + print ''; } // View if ($id > 0) { $object = new Loan($db); - $result = $object->fetch($id); + $result = $object->fetch($id); if ($result > 0) { @@ -413,9 +413,9 @@ if ($id > 0) if ($action == 'edit') { print '
' . "\n"; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; } dol_fiche_head($head, 'card', $langs->trans("Loan"), -1, 'bill'); @@ -441,40 +441,40 @@ if ($id > 0) $morehtmlref.=$form->editfieldkey("Label", 'label', $object->label, $object, $user->rights->loan->write, 'string', '', 0, 1); $morehtmlref.=$form->editfieldval("Label", 'label', $object->label, $object, $user->rights->loan->write, 'string', '', null, null, '', 1); // Project - if (! empty($conf->projet->enabled)) - { - $langs->load("projects"); - $morehtmlref.='
'.$langs->trans('Project') . ' '; - if ($user->rights->loan->write) - { - if ($action != 'classify') - $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
'; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } - } else { - if (! empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref.=''; - $morehtmlref.=$proj->ref; - $morehtmlref.=''; - } else { - $morehtmlref.=''; - } - } - } - $morehtmlref.=''; + if (! empty($conf->projet->enabled)) + { + $langs->load("projects"); + $morehtmlref.='
'.$langs->trans('Project') . ' '; + if ($user->rights->loan->write) + { + if ($action != 'classify') + $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
'; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
'; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (! empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref.=''; + $morehtmlref.=$proj->ref; + $morehtmlref.=''; + } else { + $morehtmlref.=''; + } + } + } + $morehtmlref.=''; - $object->totalpaid = $totalpaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status + $object->totalpaid = $totalpaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright); @@ -496,7 +496,7 @@ if ($id > 0) print ''.$langs->trans("LoanCapital").''.price($object->capital,0,$outputlangs,1,-1,-1,$conf->currency).''; } - // Date start + // Date start print ''.$langs->trans("DateStart").""; print ""; if ($action == 'edit') @@ -548,15 +548,15 @@ if ($id > 0) } print ''; - // Accountancy account capital + // Accountancy account capital print ''; - print $langs->trans("LoanAccountancyCapitalCode"); - print ''; + print $langs->trans("LoanAccountancyCapitalCode"); + print ''; if ($action == 'edit') { if (! empty($conf->accounting->enabled)) { - print $formaccounting->select_account($object->account_capital, 'accountancy_account_capital', 1, '', 0, 1); + print $formaccounting->select_account($object->account_capital, 'accountancy_account_capital', 1, '', 1, 1); } else { @@ -573,15 +573,15 @@ if ($id > 0) } print ''; - // Accountancy account insurance + // Accountancy account insurance print ''; - print $langs->trans("LoanAccountancyInsuranceCode"); - print ''; + print $langs->trans("LoanAccountancyInsuranceCode"); + print ''; if ($action == 'edit') { if (! empty($conf->accounting->enabled)) { - print $formaccounting->select_account($object->account_insurance, 'accountancy_account_insurance', 1, '', 0, 1); + print $formaccounting->select_account($object->account_insurance, 'accountancy_account_insurance', 1, '', 1, 1); } else { @@ -600,13 +600,13 @@ if ($id > 0) // Accountancy account interest print ''; - print $langs->trans("LoanAccountancyInterestCode"); - print ''; + print $langs->trans("LoanAccountancyInterestCode"); + print ''; if ($action == 'edit') { if (! empty($conf->accounting->enabled)) { - print $formaccounting->select_account($object->account_interest, 'accountancy_account_interest', 1, '', 0, 1); + print $formaccounting->select_account($object->account_interest, 'accountancy_account_interest', 1, '', 1, 1); } else { @@ -650,9 +650,9 @@ if ($id > 0) { $num = $db->num_rows($resql); $i = 0; - $total_insurance = 0; - $total_interest = 0; - $total_capital = 0; + $total_insurance = 0; + $total_interest = 0; + $total_capital = 0; print ''; print ''; print ''; @@ -660,8 +660,8 @@ if ($id > 0) print ''; print ''; print ''; - print ''; - print ''; + print ''; + print ''; $var=True; while ($i < $num) @@ -672,11 +672,11 @@ if ($id > 0) print ''; print '\n"; print "\n"; - print '\n"; - print '\n"; - print '\n"; + print '\n"; + print '\n"; + print '\n"; print ""; - $total_capital += $objp->amount_capital; + $total_capital += $objp->amount_capital; $i++; } @@ -716,47 +716,47 @@ if ($id > 0) print ''; print ''; - print ''; + print ''; } /* - * Buttons actions + * Buttons actions */ if ($action != 'edit') { $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) - { - print '
'; + { + print '
'; - // Edit - if ($user->rights->loan->write) - { - print ''.$langs->trans('CreateCalcSchedule').''; + // Edit + if ($user->rights->loan->write) + { + print ''.$langs->trans('CreateCalcSchedule').''; - print ''.$langs->trans("Modify").''; - } + print ''.$langs->trans("Modify").''; + } - // Emit payment - if ($object->paid == 0 && ((price2num($object->capital) > 0 && round($staytopay) < 0) || (price2num($object->capital) > 0 && round($staytopay) > 0)) && $user->rights->loan->write) - { - print ''.$langs->trans("DoPayment").''; - } + // Emit payment + if ($object->paid == 0 && ((price2num($object->capital) > 0 && round($staytopay) < 0) || (price2num($object->capital) > 0 && round($staytopay) > 0)) && $user->rights->loan->write) + { + print ''.$langs->trans("DoPayment").''; + } - // Classify 'paid' - if ($object->paid == 0 && round($staytopay) <=0 && $user->rights->loan->write) - { - print ''.$langs->trans("ClassifyPaid").''; - } + // Classify 'paid' + if ($object->paid == 0 && round($staytopay) <=0 && $user->rights->loan->write) + { + print ''.$langs->trans("ClassifyPaid").''; + } - // Delete - if ($user->rights->loan->delete) - { - print ''.$langs->trans("Delete").''; - } + // Delete + if ($user->rights->loan->delete) + { + print ''.$langs->trans("Delete").''; + } - print "
"; - } + print "
"; + } } } else diff --git a/htdocs/loan/class/loan.class.php b/htdocs/loan/class/loan.class.php index 734c2356b3a..3d80bae8057 100644 --- a/htdocs/loan/class/loan.class.php +++ b/htdocs/loan/class/loan.class.php @@ -17,128 +17,128 @@ */ /** - * \file htdocs/loan/class/loan.class.php - * \ingroup loan - * \brief Class for loan module + * \file htdocs/loan/class/loan.class.php + * \ingroup loan + * \brief Class for loan module */ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; /** - * Loan + * Loan */ class Loan extends CommonObject { - public $element='loan'; - public $table='loan'; - public $table_element='loan'; + public $element='loan'; + public $table='loan'; + public $table_element='loan'; - public $picto = 'bill'; + public $picto = 'bill'; - public $rowid; - public $datestart; - public $dateend; - public $label; - public $capital; - public $nbterm; - public $rate; - public $paid; - public $account_capital; - public $account_insurance; - public $account_interest; - public $date_creation; - public $date_modification; - public $date_validation; - public $fk_bank; - public $fk_user_creat; - public $fk_user_modif; - public $fk_project; + public $rowid; + public $datestart; + public $dateend; + public $label; + public $capital; + public $nbterm; + public $rate; + public $paid; + public $account_capital; + public $account_insurance; + public $account_interest; + public $date_creation; + public $date_modification; + public $date_validation; + public $fk_bank; + public $fk_user_creat; + public $fk_user_modif; + public $fk_project; - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - function __construct($db) - { - $this->db = $db; - return 1; - } + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + function __construct($db) + { + $this->db = $db; + return 1; + } - /** - * Load object in memory from database - * - * @param int $id id object - * @return int <0 error , >=0 no error - */ - function fetch($id) - { - $sql = "SELECT l.rowid, l.label, l.capital, l.datestart, l.dateend, l.nbterm, l.rate, l.note_private, l.note_public,"; + /** + * Load object in memory from database + * + * @param int $id id object + * @return int <0 error , >=0 no error + */ + function fetch($id) + { + $sql = "SELECT l.rowid, l.label, l.capital, l.datestart, l.dateend, l.nbterm, l.rate, l.note_private, l.note_public,"; $sql.= " l.paid, l.accountancy_account_capital, l.accountancy_account_insurance, l.accountancy_account_interest, l.fk_projet as fk_project"; - $sql.= " FROM ".MAIN_DB_PREFIX."loan as l"; - $sql.= " WHERE l.rowid = ".$id; + $sql.= " FROM ".MAIN_DB_PREFIX."loan as l"; + $sql.= " WHERE l.rowid = ".$id; - dol_syslog(get_class($this)."::fetch", LOG_DEBUG); - $resql=$this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { - $obj = $this->db->fetch_object($resql); + dol_syslog(get_class($this)."::fetch", LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + if ($this->db->num_rows($resql)) + { + $obj = $this->db->fetch_object($resql); - $this->id = $obj->rowid; - $this->ref = $obj->rowid; - $this->datestart = $this->db->jdate($obj->datestart); - $this->dateend = $this->db->jdate($obj->dateend); - $this->label = $obj->label; - $this->capital = $obj->capital; - $this->nbterm = $obj->nbterm; - $this->rate = $obj->rate; - $this->note_private = $obj->note_private; - $this->note_public = $obj->note_public; - $this->paid = $obj->paid; + $this->id = $obj->rowid; + $this->ref = $obj->rowid; + $this->datestart = $this->db->jdate($obj->datestart); + $this->dateend = $this->db->jdate($obj->dateend); + $this->label = $obj->label; + $this->capital = $obj->capital; + $this->nbterm = $obj->nbterm; + $this->rate = $obj->rate; + $this->note_private = $obj->note_private; + $this->note_public = $obj->note_public; + $this->paid = $obj->paid; $this->account_capital = $obj->accountancy_account_capital; $this->account_insurance = $obj->accountancy_account_insurance; $this->account_interest = $obj->accountancy_account_interest; $this->fk_project = $obj->fk_project; - $this->db->free($resql); + $this->db->free($resql); return 1; - } - else - { - $this->db->free($resql); - return 0; - } - } - else - { - $this->error=$this->db->lasterror(); - return -1; - } - } + } + else + { + $this->db->free($resql); + return 0; + } + } + else + { + $this->error=$this->db->lasterror(); + return -1; + } + } - /** - * Create a loan into database - * - * @param User $user User making creation - * @return int <0 if KO, id if OK - */ - function create($user) - { - global $conf, $langs; + /** + * Create a loan into database + * + * @param User $user User making creation + * @return int <0 if KO, id if OK + */ + function create($user) + { + global $conf, $langs; $error=0; - $now=dol_now(); + $now=dol_now(); - // clean parameters - $newcapital=price2num($this->capital,'MT'); - if (isset($this->note_private)) $this->note_private = trim($this->note_private); - if (isset($this->note_public)) $this->note_public = trim($this->note_public); + // clean parameters + $newcapital=price2num($this->capital,'MT'); + if (isset($this->note_private)) $this->note_private = trim($this->note_private); + if (isset($this->note_public)) $this->note_public = trim($this->note_public); if (isset($this->account_capital)) $this->account_capital = trim($this->account_capital); if (isset($this->account_insurance)) $this->account_insurance = trim($this->account_insurance); if (isset($this->account_interest)) $this->account_interest = trim($this->account_interest); @@ -147,322 +147,332 @@ class Loan extends CommonObject if (isset($this->fk_user_modif)) $this->fk_user_modif=trim($this->fk_user_modif); if (isset($this->fk_project)) $this->fk_project=trim($this->fk_project); - // Check parameters - if (! $newcapital > 0 || empty($this->datestart) || empty($this->dateend)) - { - $this->error="ErrorBadParameter"; - return -2; - } - if (($conf->accounting->enabled) && empty($this->account_capital) && empty($this->account_insurance) && empty($this->account_interest)) + // Check parameters + if (! $newcapital > 0 || empty($this->datestart) || empty($this->dateend)) { - $this->error=$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Accounting")); - return -2; + $this->error="ErrorBadParameter"; + return -2; + } + if (($conf->accounting->enabled) && empty($this->account_capital)) + { + $this->error=$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("LoanAccountancyCapitalCode")); + return -2; + } + if (($conf->accounting->enabled) && empty($this->account_insurance)) + { + $this->error=$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("LoanAccountancyInsuranceCode")); + return -2; + } + if (($conf->accounting->enabled) && empty($this->account_interest)) + { + $this->error=$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("LoanAccountancyInterestCode")); + return -2; } - $this->db->begin(); + $this->db->begin(); - $sql = "INSERT INTO ".MAIN_DB_PREFIX."loan (label, fk_bank, capital, datestart, dateend, nbterm, rate, note_private, note_public,"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."loan (label, fk_bank, capital, datestart, dateend, nbterm, rate, note_private, note_public,"; $sql.= " accountancy_account_capital, accountancy_account_insurance, accountancy_account_interest, entity,"; $sql.= " datec, fk_projet, fk_user_author)"; $sql.= " VALUES ('".$this->db->escape($this->label)."',"; $sql.= " '".$this->db->escape($this->fk_bank)."',"; - $sql.= " '".price2num($newcapital)."',"; + $sql.= " '".price2num($newcapital)."',"; $sql.= " '".$this->db->idate($this->datestart)."',"; $sql.= " '".$this->db->idate($this->dateend)."',"; - $sql.= " '".$this->db->escape($this->nbterm)."',"; + $sql.= " '".$this->db->escape($this->nbterm)."',"; $sql.= " '".$this->db->escape($this->rate)."',"; $sql.= " '".$this->db->escape($this->note_private)."',"; $sql.= " '".$this->db->escape($this->note_public)."',"; $sql.= " '".$this->db->escape($this->account_capital)."',"; $sql.= " '".$this->db->escape($this->account_insurance)."',"; $sql.= " '".$this->db->escape($this->account_interest)."',"; - $sql.= " ".$conf->entity.","; + $sql.= " ".$conf->entity.","; $sql.= " '".$this->db->idate($now)."',"; $sql.= " ".(empty($this->fk_project)?'NULL':$this->fk_project).","; $sql.= " ".$user->id; - $sql.= ")"; + $sql.= ")"; - dol_syslog(get_class($this)."::create", LOG_DEBUG); - $resql=$this->db->query($sql); - if ($resql) - { - $this->id=$this->db->last_insert_id(MAIN_DB_PREFIX."loan"); + dol_syslog(get_class($this)."::create", LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + $this->id=$this->db->last_insert_id(MAIN_DB_PREFIX."loan"); - //dol_syslog("Loans::create this->id=".$this->id); - $this->db->commit(); - return $this->id; - } - else - { - $this->error=$this->db->error(); - $this->db->rollback(); - return -1; - } - } + //dol_syslog("Loans::create this->id=".$this->id); + $this->db->commit(); + return $this->id; + } + else + { + $this->error=$this->db->error(); + $this->db->rollback(); + return -1; + } + } - /** - * Delete a loan - * - * @param User $user Object user making delete - * @return int <0 if KO, >0 if OK - */ - function delete($user) - { - $error=0; + /** + * Delete a loan + * + * @param User $user Object user making delete + * @return int <0 if KO, >0 if OK + */ + function delete($user) + { + $error=0; - $this->db->begin(); + $this->db->begin(); - // Get bank transaction lines for this loan - include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; - $account=new Account($this->db); - $lines_url=$account->get_url('',$this->id,'loan'); + // Get bank transaction lines for this loan + include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; + $account=new Account($this->db); + $lines_url=$account->get_url('',$this->id,'loan'); - // Delete bank urls - foreach ($lines_url as $line_url) - { - if (! $error) - { - $accountline=new AccountLine($this->db); - $accountline->fetch($line_url['fk_bank']); - $result=$accountline->delete_urls($user); - if ($result < 0) - { - $error++; - } - } - } + // Delete bank urls + foreach ($lines_url as $line_url) + { + if (! $error) + { + $accountline=new AccountLine($this->db); + $accountline->fetch($line_url['fk_bank']); + $result=$accountline->delete_urls($user); + if ($result < 0) + { + $error++; + } + } + } - // Delete payments - if (! $error) - { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."payment_loan where fk_loan=".$this->id; - dol_syslog(get_class($this)."::delete", LOG_DEBUG); - $resql=$this->db->query($sql); - if (! $resql) - { - $error++; - $this->error=$this->db->lasterror(); - } - } + // Delete payments + if (! $error) + { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."payment_loan where fk_loan=".$this->id; + dol_syslog(get_class($this)."::delete", LOG_DEBUG); + $resql=$this->db->query($sql); + if (! $resql) + { + $error++; + $this->error=$this->db->lasterror(); + } + } - if (! $error) - { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."loan where rowid=".$this->id; - dol_syslog(get_class($this)."::delete", LOG_DEBUG); - $resql=$this->db->query($sql); - if (! $resql) - { - $error++; - $this->error=$this->db->lasterror(); - } - } + if (! $error) + { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."loan where rowid=".$this->id; + dol_syslog(get_class($this)."::delete", LOG_DEBUG); + $resql=$this->db->query($sql); + if (! $resql) + { + $error++; + $this->error=$this->db->lasterror(); + } + } - if (! $error) - { - $this->db->commit(); - return 1; - } - else - { - $this->db->rollback(); - return -1; - } + if (! $error) + { + $this->db->commit(); + return 1; + } + else + { + $this->db->rollback(); + return -1; + } - } + } - /** - * Update loan - * - * @param User $user User who modified - * @return int <0 if error, >0 if ok - */ - function update($user) - { - $this->db->begin(); + /** + * Update loan + * + * @param User $user User who modified + * @return int <0 if error, >0 if ok + */ + function update($user) + { + $this->db->begin(); - $sql = "UPDATE ".MAIN_DB_PREFIX."loan"; - $sql.= " SET label='".$this->db->escape($this->label)."',"; + $sql = "UPDATE ".MAIN_DB_PREFIX."loan"; + $sql.= " SET label='".$this->db->escape($this->label)."',"; $sql.= " capital='".price2num($this->db->escape($this->capital))."',"; - $sql.= " datestart='".$this->db->idate($this->datestart)."',"; - $sql.= " dateend='".$this->db->idate($this->dateend)."',"; - $sql.= " fk_projet=".(empty($this->fk_project)?'NULL':$this->fk_project).","; + $sql.= " datestart='".$this->db->idate($this->datestart)."',"; + $sql.= " dateend='".$this->db->idate($this->dateend)."',"; + $sql.= " fk_projet=".(empty($this->fk_project)?'NULL':$this->fk_project).","; $sql.= " fk_user_modif = ".$user->id; - $sql.= " WHERE rowid=".$this->id; + $sql.= " WHERE rowid=".$this->id; - dol_syslog(get_class($this)."::update", LOG_DEBUG); - $resql=$this->db->query($sql); - if ($resql) - { - $this->db->commit(); - return 1; - } - else - { - $this->error=$this->db->error(); - $this->db->rollback(); - return -1; - } - } + dol_syslog(get_class($this)."::update", LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + $this->db->commit(); + return 1; + } + else + { + $this->error=$this->db->error(); + $this->db->rollback(); + return -1; + } + } - /** - * Tag loan as payed completely - * - * @param User $user Object user making change - * @return int <0 if KO, >0 if OK - */ - function set_paid($user) - { - $sql = "UPDATE ".MAIN_DB_PREFIX."loan SET"; - $sql.= " paid = 1"; - $sql.= " WHERE rowid = ".$this->id; - $return = $this->db->query($sql); + /** + * Tag loan as payed completely + * + * @param User $user Object user making change + * @return int <0 if KO, >0 if OK + */ + function set_paid($user) + { + $sql = "UPDATE ".MAIN_DB_PREFIX."loan SET"; + $sql.= " paid = 1"; + $sql.= " WHERE rowid = ".$this->id; + $return = $this->db->query($sql); if ($return) { return 1; } else { $this->error=$this->db->lasterror(); return -1; } - } - - /** - * Return label of loan status (unpaid, paid) - * - * @param int $mode 0=label, 1=short label, 2=Picto + Short label, 3=Picto, 4=Picto + Label - * @param integer $alreadypaid 0=No payment already done, >0=Some payments were already done (we recommand to put here amount payed if you have it, 1 otherwise) - * @return string Label - */ - function getLibStatut($mode=0,$alreadypaid=-1) - { - return $this->LibStatut($this->paid,$mode,$alreadypaid); - } - - /** - * Return label for given status - * - * @param int $statut Id statut - * @param int $mode 0=Label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Label, 5=Short label + Picto - * @param integer $alreadypaid 0=No payment already done, >0=Some payments were already done (we recommand to put here amount payed if you have it, 1 otherwise) - * @return string Label - */ - function LibStatut($statut,$mode=0,$alreadypaid=-1) - { - global $langs; - $langs->load('customers'); - $langs->load('bills'); - - if ($mode == 0) - { - if ($statut == 0) return $langs->trans("Unpaid"); - if ($statut == 1) return $langs->trans("Paid"); - } - if ($mode == 1) - { - if ($statut == 0) return $langs->trans("Unpaid"); - if ($statut == 1) return $langs->trans("Paid"); - } - if ($mode == 2) - { - if ($statut == 0 && $alreadypaid <= 0) return img_picto($langs->trans("Unpaid"), 'statut1').' '.$langs->trans("Unpaid"); - if ($statut == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3').' '.$langs->trans("BillStatusStarted"); - if ($statut == 1) return img_picto($langs->trans("Paid"), 'statut6').' '.$langs->trans("Paid"); - } - if ($mode == 3) - { - if ($statut == 0 && $alreadypaid <= 0) return img_picto($langs->trans("Unpaid"), 'statut1'); - if ($statut == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3'); - if ($statut == 1) return img_picto($langs->trans("Paid"), 'statut6'); - } - if ($mode == 4) - { - if ($statut == 0 && $alreadypaid <= 0) return img_picto($langs->trans("Unpaid"), 'statut1').' '.$langs->trans("Unpaid"); - if ($statut == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3').' '.$langs->trans("BillStatusStarted"); - if ($statut == 1) return img_picto($langs->trans("Paid"), 'statut6').' '.$langs->trans("Paid"); - } - if ($mode == 5) - { - if ($statut == 0 && $alreadypaid <= 0) return $langs->trans("Unpaid").' '.img_picto($langs->trans("Unpaid"), 'statut1'); - if ($statut == 0 && $alreadypaid > 0) return $langs->trans("BillStatusStarted").' '.img_picto($langs->trans("BillStatusStarted"), 'statut3'); - if ($statut == 1) return $langs->trans("Paid").' '.img_picto($langs->trans("Paid"), 'statut6'); - } - if ($mode == 6) - { - if ($statut == 0 && $alreadypaid <= 0) return $langs->trans("Unpaid").' '.img_picto($langs->trans("Unpaid"), 'statut1'); - if ($statut == 0 && $alreadypaid > 0) return $langs->trans("BillStatusStarted").' '.img_picto($langs->trans("BillStatusStarted"), 'statut3'); - if ($statut == 1) return $langs->trans("Paid").' '.img_picto($langs->trans("Paid"), 'statut6'); - } - - return "Error, mode/status not found"; - } - - - /** - * Return clicable name (with eventually the picto) - * - * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto - * @param int $maxlen Label max length - * @return string Chaine with URL - */ - function getNomUrl($withpicto=0,$maxlen=0) - { - global $langs; - - $result=''; - - $tooltip = '' . $langs->trans("ShowLoan") . ''; - if (! empty($this->ref)) - $tooltip .= '
' . $langs->trans('Ref') . ': ' . $this->ref; - if (! empty($this->label)) - $tooltip .= '
' . $langs->trans('Label') . ': ' . $this->label; - $link = ''; - $linkend = ''; - - if ($withpicto) $result.=($link.$linkclose.img_object($langs->trans("ShowLoan").': '.$this->label,'bill', 'class="classfortooltip"').$linkend.' '); - if ($withpicto && $withpicto != 2) $result.=' '; - if ($withpicto != 2) $result.=$link.$linkclose.($maxlen?dol_trunc($this->label,$maxlen):$this->label).$linkend; - return $result; - } - - /** - * Return amount of payments already done - * - * @return int Amount of payment already done, <0 if KO - */ - function getSumPayment() - { - $table='payment_loan'; - $field='fk_loan'; - - $sql = 'SELECT sum(amount) as amount'; - $sql.= ' FROM '.MAIN_DB_PREFIX.$table; - $sql.= ' WHERE '.$field.' = '.$this->id; - - dol_syslog(get_class($this)."::getSumPayment", LOG_DEBUG); - $resql=$this->db->query($sql); - if ($resql) - { - $amount=0; - - $obj = $this->db->fetch_object($resql); - if ($obj) $amount=$obj->amount?$obj->amount:0; - - $this->db->free($resql); - return $amount; - } - else - { - $this->error=$this->db->lasterror(); - return -1; - } - } + } /** - * Information on record + * Return label of loan status (unpaid, paid) * - * @param int $id Id of record - * @return integer|null + * @param int $mode 0=label, 1=short label, 2=Picto + Short label, 3=Picto, 4=Picto + Label + * @param integer $alreadypaid 0=No payment already done, >0=Some payments were already done (we recommand to put here amount payed if you have it, 1 otherwise) + * @return string Label + */ + function getLibStatut($mode=0,$alreadypaid=-1) + { + return $this->LibStatut($this->paid,$mode,$alreadypaid); + } + + /** + * Return label for given status + * + * @param int $statut Id statut + * @param int $mode 0=Label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Label, 5=Short label + Picto + * @param integer $alreadypaid 0=No payment already done, >0=Some payments were already done (we recommand to put here amount payed if you have it, 1 otherwise) + * @return string Label + */ + function LibStatut($statut,$mode=0,$alreadypaid=-1) + { + global $langs; + $langs->load('customers'); + $langs->load('bills'); + + if ($mode == 0) + { + if ($statut == 0) return $langs->trans("Unpaid"); + if ($statut == 1) return $langs->trans("Paid"); + } + if ($mode == 1) + { + if ($statut == 0) return $langs->trans("Unpaid"); + if ($statut == 1) return $langs->trans("Paid"); + } + if ($mode == 2) + { + if ($statut == 0 && $alreadypaid <= 0) return img_picto($langs->trans("Unpaid"), 'statut1').' '.$langs->trans("Unpaid"); + if ($statut == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3').' '.$langs->trans("BillStatusStarted"); + if ($statut == 1) return img_picto($langs->trans("Paid"), 'statut6').' '.$langs->trans("Paid"); + } + if ($mode == 3) + { + if ($statut == 0 && $alreadypaid <= 0) return img_picto($langs->trans("Unpaid"), 'statut1'); + if ($statut == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3'); + if ($statut == 1) return img_picto($langs->trans("Paid"), 'statut6'); + } + if ($mode == 4) + { + if ($statut == 0 && $alreadypaid <= 0) return img_picto($langs->trans("Unpaid"), 'statut1').' '.$langs->trans("Unpaid"); + if ($statut == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3').' '.$langs->trans("BillStatusStarted"); + if ($statut == 1) return img_picto($langs->trans("Paid"), 'statut6').' '.$langs->trans("Paid"); + } + if ($mode == 5) + { + if ($statut == 0 && $alreadypaid <= 0) return $langs->trans("Unpaid").' '.img_picto($langs->trans("Unpaid"), 'statut1'); + if ($statut == 0 && $alreadypaid > 0) return $langs->trans("BillStatusStarted").' '.img_picto($langs->trans("BillStatusStarted"), 'statut3'); + if ($statut == 1) return $langs->trans("Paid").' '.img_picto($langs->trans("Paid"), 'statut6'); + } + if ($mode == 6) + { + if ($statut == 0 && $alreadypaid <= 0) return $langs->trans("Unpaid").' '.img_picto($langs->trans("Unpaid"), 'statut1'); + if ($statut == 0 && $alreadypaid > 0) return $langs->trans("BillStatusStarted").' '.img_picto($langs->trans("BillStatusStarted"), 'statut3'); + if ($statut == 1) return $langs->trans("Paid").' '.img_picto($langs->trans("Paid"), 'statut6'); + } + + return "Error, mode/status not found"; + } + + + /** + * Return clicable name (with eventually the picto) + * + * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto + * @param int $maxlen Label max length + * @return string Chaine with URL + */ + function getNomUrl($withpicto=0,$maxlen=0) + { + global $langs; + + $result=''; + + $tooltip = '' . $langs->trans("ShowLoan") . ''; + if (! empty($this->ref)) + $tooltip .= '
' . $langs->trans('Ref') . ': ' . $this->ref; + if (! empty($this->label)) + $tooltip .= '
' . $langs->trans('Label') . ': ' . $this->label; + $link = ''; + $linkend = ''; + + if ($withpicto) $result.=($link.$linkclose.img_object($langs->trans("ShowLoan").': '.$this->label,'bill', 'class="classfortooltip"').$linkend.' '); + if ($withpicto && $withpicto != 2) $result.=' '; + if ($withpicto != 2) $result.=$link.$linkclose.($maxlen?dol_trunc($this->label,$maxlen):$this->label).$linkend; + return $result; + } + + /** + * Return amount of payments already done + * + * @return int Amount of payment already done, <0 if KO + */ + function getSumPayment() + { + $table='payment_loan'; + $field='fk_loan'; + + $sql = 'SELECT sum(amount) as amount'; + $sql.= ' FROM '.MAIN_DB_PREFIX.$table; + $sql.= ' WHERE '.$field.' = '.$this->id; + + dol_syslog(get_class($this)."::getSumPayment", LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + $amount=0; + + $obj = $this->db->fetch_object($resql); + if ($obj) $amount=$obj->amount?$obj->amount:0; + + $this->db->free($resql); + return $amount; + } + else + { + $this->error=$this->db->lasterror(); + return -1; + } + } + + /** + * Information on record + * + * @param int $id Id of record + * @return integer|null */ function info($id) { @@ -492,17 +502,17 @@ class Loan extends CommonObject $muser->fetch($obj->fk_user_modif); $this->user_modification = $muser; } - $this->date_creation = $this->db->jdate($obj->datec); + $this->date_creation = $this->db->jdate($obj->datec); if (empty($obj->fk_user_modif)) $obj->tms = ""; $this->date_modification = $this->db->jdate($obj->tms); - $this->db->free($result); + $this->db->free($result); return 1; } else { - $this->db->free($result); - return 0; + $this->db->free($result); + return 0; } } else From 3db4d10fc084f6399d5ab2d0021ac206411035ab Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sun, 10 Dec 2017 08:12:49 +0100 Subject: [PATCH 45/64] Fix event late alert on third event list #7912 --- htdocs/core/lib/company.lib.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 96d43ee4e5f..3839c867df4 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -1275,10 +1275,10 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint= else $out.='-'.dol_print_date($histo[$key]['dateend'],'dayhour'); } $late=0; - if ($histo[$key]['percent'] == 0 && $histo[$key]['datestart'] && $db->jdate($histo[$key]['datestart']) < ($now - $delay_warning)) $late=1; - if ($histo[$key]['percent'] == 0 && ! $histo[$key]['datestart'] && $histo[$key]['dateend'] && $db->jdate($histo[$key]['datestart']) < ($now - $delay_warning)) $late=1; - if ($histo[$key]['percent'] > 0 && $histo[$key]['percent'] < 100 && $histo[$key]['dateend'] && $db->jdate($histo[$key]['dateend']) < ($now - $delay_warning)) $late=1; - if ($histo[$key]['percent'] > 0 && $histo[$key]['percent'] < 100 && ! $histo[$key]['dateend'] && $histo[$key]['datestart'] && $db->jdate($histo[$key]['datestart']) < ($now - $delay_warning)) $late=1; + if ($histo[$key]['percent'] == 0 && $histo[$key]['datestart'] && $histo[$key]['datestart'] < ($now - $delay_warning)) $late=1; + if ($histo[$key]['percent'] == 0 && ! $histo[$key]['datestart'] && $histo[$key]['dateend'] && $histo[$key]['datestart'] < ($now - $delay_warning)) $late=1; + if ($histo[$key]['percent'] > 0 && $histo[$key]['percent'] < 100 && $histo[$key]['dateend'] && $histo[$key]['dateend'] < ($now - $delay_warning)) $late=1; + if ($histo[$key]['percent'] > 0 && $histo[$key]['percent'] < 100 && ! $histo[$key]['dateend'] && $histo[$key]['datestart'] && $histo[$key]['datestart'] < ($now - $delay_warning)) $late=1; if ($late) $out.=img_warning($langs->trans("Late")).' '; $out.="\n"; From 12d09282448bf0eb4dfaf40540e0db89c78e2859 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sun, 10 Dec 2017 19:59:56 +0100 Subject: [PATCH 46/64] Fix display error message when stock not enough on invoice validation --- htdocs/compta/facture/class/facture.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 840bb93a49f..3c35a03f218 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2197,6 +2197,7 @@ class Facture extends CommonInvoice else $result=$mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarr",$num)); if ($result < 0) { $error++; + $this->error = $mouvP->error; } } } From 033016da7fd5de610089ec59ae18513c9192c66c Mon Sep 17 00:00:00 2001 From: patrick Delcroix Date: Sun, 10 Dec 2017 20:02:26 +0100 Subject: [PATCH 47/64] fix: unable to remove salaries, plus correct default rights management --- htdocs/core/lib/security.lib.php | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index e799579b181..c7d72e796ea 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -242,17 +242,17 @@ function restrictedArea($user, $features, $objectid=0, $tableandshare='', $featu { foreach($feature2 as $subfeature) { - if (empty($user->rights->$feature->$subfeature->creer) - && empty($user->rights->$feature->$subfeature->write) - && empty($user->rights->$feature->$subfeature->create)) { $createok=0; $nbko++; } + if (empty($user->rights->{$feature}->{$subfeature}->creer) + && empty($user->rights->{$feature}->{$subfeature}->write) + && empty($user->rights->{$feature}->{$subfeature}->create)) { $createok=0; $nbko++; } else { $createok=1; break; } // Break to bypass second test if the first is ok } } else if (! empty($feature)) // This is for old permissions ('creer' or 'write') { //print '
feature='.$feature.' creer='.$user->rights->$feature->creer.' write='.$user->rights->$feature->write; - if (empty($user->rights->$feature->creer) - && empty($user->rights->$feature->write)) { $createok=0; $nbko++; } + if (empty($user->rights->{$feature}->creer) + && empty($user->rights->{$feature}->write)) { $createok=0; $nbko++; } } } @@ -306,21 +306,24 @@ function restrictedArea($user, $features, $objectid=0, $tableandshare='', $featu else if ($feature == 'ftp') { if (! $user->rights->ftp->write) $deleteok=0; + }else if ($feature == 'salaries') + { + if (! $user->rights->salaries->delete) $deleteok=0; } else if (! empty($feature2)) // This should be used for future changes { foreach($feature2 as $subfeature) { - if (empty($user->rights->$feature->$subfeature->supprimer) && empty($user->rights->$feature->$subfeature->delete)) $deleteok=0; + if (empty($user->rights->{$feature}->{$subfeature}->supprimer) && empty($user->rights->$feature->$subfeature->delete)) $deleteok=0; else { $deleteok=1; break; } // For bypass the second test if the first is ok } } else if (! empty($feature)) // This is for old permissions { //print '
feature='.$feature.' creer='.$user->rights->$feature->supprimer.' write='.$user->rights->$feature->delete; - if (empty($user->rights->$feature->supprimer) - && empty($user->rights->$feature->delete) - && empty($user->rights->$feature->run)) $deleteok=0; + if (empty($user->rights->{$feature}->supprimer) + && empty($user->rights->{$feature}->delete) + && empty($user->rights->{$feature}->run)) $deleteok=0; } } From e4725f424889328034d2eed7b642b23ae15da7f2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 10 Dec 2017 20:55:51 +0100 Subject: [PATCH 48/64] FIX #7933 --- htdocs/societe/list.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index f3ef24d12d2..5a93495d230 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -489,7 +489,7 @@ foreach ($search_array_options as $key => $val) $crit=$val; $tmpkey=preg_replace('/search_options_/','',$key); if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); -} +} // Show delete result message if (GETPOST('delsoc')) @@ -599,9 +599,9 @@ if (! empty($arrayfields['s.fk_stcomm']['checked'])) print_liste_field_titr // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { - foreach($extrafields->attribute_label as $key => $val) + foreach($extrafields->attribute_label as $key => $val) { - if (! empty($arrayfields["ef.".$key]['checked'])) + if (! empty($arrayfields["ef.".$key]['checked'])) { $align=$extrafields->getAlignFlag($key); print_liste_field_titre($extralabels[$key],$_SERVER["PHP_SELF"],"ef.".$key,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder); @@ -797,9 +797,9 @@ if (! empty($arrayfields['s.fk_stcomm']['checked'])) // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { - foreach($extrafields->attribute_label as $key => $val) + foreach($extrafields->attribute_label as $key => $val) { - if (! empty($arrayfields["ef.".$key]['checked'])) + if (! empty($arrayfields["ef.".$key]['checked'])) { $align=$extrafields->getAlignFlag($key); $typeofextrafield=$extrafields->attribute_type[$key]; @@ -854,7 +854,7 @@ while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); $var=!$var; - + $companystatic->id=$obj->rowid; $companystatic->name=$obj->name; $companystatic->canvas=$obj->canvas; @@ -865,7 +865,7 @@ while ($i < min($num, $limit)) $companystatic->code_fournisseur=$obj->code_fournisseur; $companystatic->fk_prospectlevel=$obj->fk_prospectlevel; $companystatic->name_alias=$obj->name_alias; - + print "
"; if (! empty($arrayfields['s.nom']['checked'])) { @@ -907,12 +907,12 @@ while ($i < min($num, $limit)) if (! empty($arrayfields['s.zip']['checked'])) { print "\n"; - } + } // State if (! empty($arrayfields['state.nom']['checked'])) { print "\n"; - } + } // Country if (! empty($arrayfields['country.code_iso']['checked'])) { @@ -925,7 +925,7 @@ while ($i < min($num, $limit)) if (! empty($arrayfields['typent.code']['checked'])) { print ''; } From f18edd57879c83efee640a91464fe9d917d22eab Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 10 Dec 2017 21:08:13 +0100 Subject: [PATCH 49/64] Update security.lib.php --- htdocs/core/lib/security.lib.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index c7d72e796ea..0632f4d723f 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -242,17 +242,17 @@ function restrictedArea($user, $features, $objectid=0, $tableandshare='', $featu { foreach($feature2 as $subfeature) { - if (empty($user->rights->{$feature}->{$subfeature}->creer) - && empty($user->rights->{$feature}->{$subfeature}->write) - && empty($user->rights->{$feature}->{$subfeature}->create)) { $createok=0; $nbko++; } + if (empty($user->rights->$feature->$subfeature->creer) + && empty($user->rights->$feature->$subfeature->write) + && empty($user->rights->$feature->$subfeature->create)) { $createok=0; $nbko++; } else { $createok=1; break; } // Break to bypass second test if the first is ok } } else if (! empty($feature)) // This is for old permissions ('creer' or 'write') { //print '
feature='.$feature.' creer='.$user->rights->$feature->creer.' write='.$user->rights->$feature->write; - if (empty($user->rights->{$feature}->creer) - && empty($user->rights->{$feature}->write)) { $createok=0; $nbko++; } + if (empty($user->rights->$feature->creer) + && empty($user->rights->$feature->write)) { $createok=0; $nbko++; } } } @@ -314,16 +314,16 @@ function restrictedArea($user, $features, $objectid=0, $tableandshare='', $featu { foreach($feature2 as $subfeature) { - if (empty($user->rights->{$feature}->{$subfeature}->supprimer) && empty($user->rights->$feature->$subfeature->delete)) $deleteok=0; + if (empty($user->rights->$feature->$subfeature->supprimer) && empty($user->rights->$feature->$subfeature->delete)) $deleteok=0; else { $deleteok=1; break; } // For bypass the second test if the first is ok } } else if (! empty($feature)) // This is for old permissions { //print '
feature='.$feature.' creer='.$user->rights->$feature->supprimer.' write='.$user->rights->$feature->delete; - if (empty($user->rights->{$feature}->supprimer) - && empty($user->rights->{$feature}->delete) - && empty($user->rights->{$feature}->run)) $deleteok=0; + if (empty($user->rights->$feature->supprimer) + && empty($user->rights->$feature->delete) + && empty($user->rights->$feature->run)) $deleteok=0; } } From f2e429e28fb98160a9e8e5ce797ac24ca9b9f419 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 11 Dec 2017 15:03:34 +0100 Subject: [PATCH 50/64] Fix file integrity checker (exclude files excluded from package) --- build/generate_filelist_xml.php | 2 +- build/makepack-dolibarr.pl | 3 --- htdocs/admin/system/filecheck.php | 2 +- htdocs/core/lib/files.lib.php | 6 ++++-- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/build/generate_filelist_xml.php b/build/generate_filelist_xml.php index 0d3d90d54d4..e6336e30e97 100755 --- a/build/generate_filelist_xml.php +++ b/build/generate_filelist_xml.php @@ -131,7 +131,7 @@ $iterator1 = new RecursiveIteratorIterator($dir_iterator1); $files = new RegexIterator($iterator1, '#^(?:[A-Z]:)?(?:/(?!(?:'.($includecustom?'':'custom\/|').'documents\/|conf\/|install\/))[^/]+)+/[^/]+\.(?:php|css|html|js|json|tpl|jpg|png|gif|sql|lang)$#i'); */ $regextoinclude='\.(php|css|html|js|json|tpl|jpg|png|gif|sql|lang)$'; -$regextoexclude='('.($includecustom?'':'custom|').'documents|conf|install)$'; // Exclude dirs +$regextoexclude='('.($includecustom?'':'custom|').'documents|conf|install|public\/test|Shared\/PCLZip|nusoap\/lib\/Mail|php\/example|php\/test|geoip\/sample.*\.php|ckeditor\/samples|ckeditor\/adapters)$'; // Exclude dirs $files = dol_dir_list(DOL_DOCUMENT_ROOT, 'files', 1, $regextoinclude, $regextoexclude, 'fullname'); $dir=''; $needtoclose=0; diff --git a/build/makepack-dolibarr.pl b/build/makepack-dolibarr.pl index 2802e55c702..bc755ef52a3 100755 --- a/build/makepack-dolibarr.pl +++ b/build/makepack-dolibarr.pl @@ -556,9 +556,6 @@ if ($nboftargetok) { $ret=`rm -f $BUILDROOT/$PROJECT/.cvsignore $BUILDROOT/$PROJECT/*/.cvsignore $BUILDROOT/$PROJECT/*/*/.cvsignore $BUILDROOT/$PROJECT/*/*/*/.cvsignore $BUILDROOT/$PROJECT/*/*/*/*/.cvsignore $BUILDROOT/$PROJECT/*/*/*/*/*/.cvsignore $BUILDROOT/$PROJECT/*/*/*/*/*/*/.cvsignore`; $ret=`rm -f $BUILDROOT/$PROJECT/.gitignore $BUILDROOT/$PROJECT/*/.gitignore $BUILDROOT/$PROJECT/*/*/.gitignore $BUILDROOT/$PROJECT/*/*/*/.gitignore $BUILDROOT/$PROJECT/*/*/*/*/.gitignore $BUILDROOT/$PROJECT/*/*/*/*/*/.gitignore $BUILDROOT/$PROJECT/*/*/*/*/*/*/.gitignore`; $ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/geoip/sample*.*`; - $ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/jquery/plugins/jqueryFileTree/connectors/jqueryFileTree.pl`; # Avoid errors into rpmlint - $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/jquery/plugins/template`; # Package not valid for most linux distributions (errors reported into compile.js). Package should be embed by modules to avoid problems. - $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/phpmailer`; # Package not valid for most linux distributions (errors reported into file LICENSE). Package should be embed by modules to avoid problems. $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/ckeditor/ckeditor/adapters`; # Keep this removal in case we embed libraries $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/ckeditor/ckeditor/samples`; # Keep this removal in case we embed libraries #$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/ckeditor/_source`; # _source must be kept into tarball diff --git a/htdocs/admin/system/filecheck.php b/htdocs/admin/system/filecheck.php index 8ddae2a3d5b..8aed7d193f9 100644 --- a/htdocs/admin/system/filecheck.php +++ b/htdocs/admin/system/filecheck.php @@ -212,7 +212,7 @@ if ($xml) // Defined qualified files (must be same than into generate_filelist_xml.php) $regextoinclude='\.(php|css|html|js|json|tpl|jpg|png|gif|sql|lang)$'; - $regextoexclude='('.($includecustom?'':'custom|').'documents|conf|install)$'; // Exclude dirs + $regextoexclude='('.($includecustom?'':'custom|').'documents|conf|install|public\/test|Shared\/PCLZip|nusoap\/lib\/Mail|php\/example|php\/test|geoip\/sample.*\.php|ckeditor\/samples|ckeditor\/adapters)$'; // Exclude dirs $scanfiles = dol_dir_list(DOL_DOCUMENT_ROOT, 'files', 1, $regextoinclude, $regextoexclude); // Fill file_list with files in signature, new files, modified files diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 165480278e2..5bf386e1fac 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -46,7 +46,7 @@ function dol_basename($pathfile) * @param int $recursive Determines whether subdirectories are searched * @param string $filter Regex filter to restrict list. This regex value must be escaped for '/' by doing preg_quote($var,'/'), since this char is used for preg_match function, * but must not contains the start and end '/'. Filter is checked into basename only. - * @param array $excludefilter Array of Regex for exclude filter (example: array('(\.meta|_preview.*\.png)$','^\.')). Exclude is checked into fullpath. + * @param array $excludefilter Array of Regex for exclude filter (example: array('(\.meta|_preview.*\.png)$','^\.')). Exclude is checked both into fullpath and into basename (So '^xxx' may exclude 'xxx/dirscanned/...' and dirscanned/xxx'). * @param string $sortcriteria Sort criteria ("","fullname","relativename","name","date","size") * @param string $sortorder Sort order (SORT_ASC, SORT_DESC) * @param int $mode 0=Return array minimum keys loaded (faster), 1=Force all keys like date and size to be loaded (slower), 2=Force load of date only, 3=Force load of size only @@ -107,6 +107,7 @@ function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefil while (false !== ($file = readdir($dir))) // $file is always a basename (into directory $newpath) { if (! utf8_check($file)) $file=utf8_encode($file); // To be sure data is stored in utf8 in memory + $fullpathfile=($newpath?$newpath.'/':'').$file; $qualified=1; @@ -120,10 +121,11 @@ function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefil // Check if file is qualified foreach($excludefilterarray as $filt) { - if (preg_match('/'.$filt.'/i',$file)) { + if (preg_match('/'.$filt.'/i', $file) || preg_match('/'.$filt.'/i', $fullpathfile)) { $qualified=0; break; } } + //print $fullpathfile.' '.$file.' '.$qualified.'
'; if ($qualified) { From ef9468f78a87c77d5365b2d1654c1d9a91ba62f6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Dec 2017 11:48:51 +0100 Subject: [PATCH 51/64] Fix missing field label --- htdocs/webservices/server_supplier_invoice.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/webservices/server_supplier_invoice.php b/htdocs/webservices/server_supplier_invoice.php index ea162ef2a8b..fcfd73270aa 100644 --- a/htdocs/webservices/server_supplier_invoice.php +++ b/htdocs/webservices/server_supplier_invoice.php @@ -139,7 +139,8 @@ $server->wsdl->addComplexType( 'date_modification' => array('name'=>'date_modification','type'=>'xsd:dateTime'), 'date_invoice' => array('name'=>'date_invoice','type'=>'xsd:date'), 'date_term' => array('name'=>'date_modification','type'=>'xsd:date'), - 'type' => array('name'=>'type','type'=>'xsd:int'), + 'label' => array('name'=>'label','type'=>'xsd:date'), + 'type' => array('name'=>'type','type'=>'xsd:int'), 'total_net' => array('name'=>'type','type'=>'xsd:double'), 'total_vat' => array('name'=>'type','type'=>'xsd:double'), 'total' => array('name'=>'type','type'=>'xsd:double'), From 46770178d2320086ade6d5f85620b9e5e3dfb1c0 Mon Sep 17 00:00:00 2001 From: atm-ph Date: Wed, 13 Dec 2017 15:24:09 +0100 Subject: [PATCH 52/64] Fix since jquery 3 we can check all checkbox of credit note options --- htdocs/compta/facture/card.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 04965ddd13d..fd9386672e2 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -2534,11 +2534,11 @@ if ($action == 'create') $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceAvoirDesc"), 1, 'help', '', 0, 3); print $desc; - print '
'; - print '    0 ? 'checked':'').' /> "; - print '
    0 ? 'checked':'').' /> "; - print '
'; - + print '
'; + print '    0 ? 'checked':'').' /> "; + print '
    0 ? 'checked':'').' /> "; + print '
'; + print ''; } } From a2f4afbf88a44b94c236561e04a5d4b10523a92c Mon Sep 17 00:00:00 2001 From: atm-ph Date: Wed, 13 Dec 2017 16:17:22 +0100 Subject: [PATCH 53/64] Fix wrong or missing char for url --- htdocs/compta/facture/list.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 8563572da7c..4b734a5e7d9 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -552,14 +552,14 @@ if ($resql) if ($search_societe) $param.='&search_societe=' .urlencode($search_societe); if ($search_sale > 0) $param.='&search_sale=' .urlencode($search_sale); if ($search_user > 0) $param.='&search_user=' .urlencode($search_user); - if ($search_product_category > 0) $param.='$search_product_category=' .urlencode($search_product_category); + if ($search_product_category > 0) $param.='&search_product_category=' .urlencode($search_product_category); if ($search_montant_ht != '') $param.='&search_montant_ht='.urlencode($search_montant_ht); if ($search_montant_vat != '') $param.='&search_montant_vat='.urlencode($search_montant_vat); if ($search_montant_localtax1 != '') $param.='&search_montant_localtax1='.urlencode($search_montant_localtax1); if ($search_montant_localtax2 != '') $param.='&search_montant_localtax2='.urlencode($search_montant_localtax2); if ($search_montant_ttc != '') $param.='&search_montant_ttc='.urlencode($search_montant_ttc); if ($search_status != '') $param.='&search_status='.urlencode($search_status); - if ($search_paymentmode > 0) $param.='search_paymentmode='.urlencode($search_paymentmode); + if ($search_paymentmode > 0) $param.='&search_paymentmode='.urlencode($search_paymentmode); if ($show_files) $param.='&show_files=' .$show_files; if ($option) $param.="&option=".$option; if ($optioncss != '') $param.='&optioncss='.$optioncss; From 28214598943d0bbb46013fb661448954e5a584d0 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 20 Dec 2017 11:36:51 +0100 Subject: [PATCH 54/64] Fix: avoid php warning --- htdocs/compta/paiement.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index 7a494113090..fc65c6f05c3 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -102,7 +102,7 @@ if (empty($reshook)) $tmpinvoice=new Facture($db); foreach ($_POST as $key => $value) { - if (substr($key,0,7) == 'amount_') + if (substr($key,0,7) == 'amount_' && GETPOST($key) != '') { $cursorfacid = substr($key,7); $amounts[$cursorfacid] = price2num(trim(GETPOST($key))); From b1f98b5903cdc46a83345420963ef0ac6c483835 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 20 Dec 2017 12:45:38 +0100 Subject: [PATCH 55/64] Fix inline edit --- htdocs/core/ajax/saveinplace.php | 19 +++++++++++++++---- htdocs/expedition/card.php | 14 +++++++------- htdocs/theme/eldy/style.css.php | 5 ++++- htdocs/theme/md/style.css.php | 4 +++- 4 files changed, 29 insertions(+), 13 deletions(-) diff --git a/htdocs/core/ajax/saveinplace.php b/htdocs/core/ajax/saveinplace.php index eb04379a778..4c46ab43e23 100644 --- a/htdocs/core/ajax/saveinplace.php +++ b/htdocs/core/ajax/saveinplace.php @@ -94,10 +94,21 @@ if (! empty($field) && ! empty($element) && ! empty($table_element) && ! empty($ } else $newelement = $element; - if (! empty($user->rights->$newelement->creer) || ! empty($user->rights->$newelement->create) || ! empty($user->rights->$newelement->write) - || (isset($subelement) && (! empty($user->rights->$newelement->$subelement->creer) || ! empty($user->rights->$newelement->$subelement->write))) - || ($element == 'payment' && $user->rights->facture->paiement) - || ($element == 'payment_supplier' && $user->rights->fournisseur->facture->creer)) + $_POST['action']='update'; // Hack so restrictarea can test permission on write too + $feature = $newelement; + $object_id = $fk_element; + if ($feature == 'expedition' || $feature == 'shipping') + { + $feature = 'commande'; + $object_id = 0; + } + if ($feature == 'shipping') $feature = 'commande'; + //var_dump(GETPOST('action','aZ09')); + //var_dump($newelement.'-'.$subelement."-".$feature."-".$object_id); + $check_access = restrictedArea($user, $feature, $object_id, '', $subelement); + //var_dump($user->rights); + + if ($check_access) { // Clean parameters $newvalue = trim($value); diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 81b6ed455a7..15caab8a1ee 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -127,7 +127,7 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once - // Set incoterm + // Reopen if ($action == 'reopen' && $user->rights->expedition->creer) { $object->fetch($id); @@ -503,8 +503,8 @@ if (empty($reshook)) } } - // Action update description of emailing - else if ($action == 'settrackingnumber' || $action == 'settrackingurl' + // Action update + else if ($action == 'settracking_number' || $action == 'settracking_url' || $action == 'settrueWeight' || $action == 'settrueWidth' || $action == 'settrueHeight' @@ -513,8 +513,8 @@ if (empty($reshook)) { $error=0; - if ($action == 'settrackingnumber') $object->tracking_number = trim(GETPOST('trackingnumber','alpha')); - if ($action == 'settrackingurl') $object->tracking_url = trim(GETPOST('trackingurl','int')); + if ($action == 'settracking_number') $object->tracking_number = trim(GETPOST('tracking_number','alpha')); + if ($action == 'settracking_url') $object->tracking_url = trim(GETPOST('tracking_url','int')); if ($action == 'settrueWeight') { $object->trueWeight = trim(GETPOST('trueWeight','int')); $object->weight_units = GETPOST('weight_units','int'); @@ -1692,8 +1692,8 @@ else if ($id || $ref) print '
'; // Tracking Number - print ''; // Incoterms diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index e809f800bb5..7f294d78e4e 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -3472,17 +3472,20 @@ td.gtaskname { /* ============================================================================== */ -/* jQuery - jeditable */ +/* jQuery - jeditable for inline edit */ /* ============================================================================== */ .editkey_textarea, .editkey_ckeditor, .editkey_string, .editkey_email, .editkey_numeric, .editkey_select, .editkey_autocomplete { background: url() right top no-repeat; cursor: pointer; + margin-right: 3px; } .editkey_datepicker { background: url() right center no-repeat; + margin-right: 3px; cursor: pointer; + margin-right: 3px; } .editval_textarea.active:hover, .editval_ckeditor.active:hover, .editval_string.active:hover, .editval_email.active:hover, .editval_numeric.active:hover, .editval_select.active:hover, .editval_autocomplete.active:hover, .editval_datepicker.active:hover { diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index f4966a105b7..5a56d027b15 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -3542,17 +3542,19 @@ td.gtaskname { /* ============================================================================== */ -/* jQuery - jeditable */ +/* jQuery - jeditable for inline edit */ /* ============================================================================== */ .editkey_textarea, .editkey_ckeditor, .editkey_string, .editkey_email, .editkey_numeric, .editkey_select, .editkey_autocomplete { background: url() right top no-repeat; cursor: pointer; + margin-right: 3px; } .editkey_datepicker { background: url() right center no-repeat; cursor: pointer; + margin-right: 3px; } .editval_textarea.active:hover, .editval_ckeditor.active:hover, .editval_string.active:hover, .editval_email.active:hover, .editval_numeric.active:hover, .editval_select.active:hover, .editval_autocomplete.active:hover, .editval_datepicker.active:hover { From ca8ae3c7230aea9f8414e50f6a2b437f01b39bd8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 20 Dec 2017 13:17:21 +0100 Subject: [PATCH 56/64] Fix option MAIN_USE_JQUERY_JEDITABLE --- dev/dolibarr_changes.txt | 10 ++- htdocs/core/ajax/saveinplace.php | 13 ++- htdocs/core/js/editinplace.js | 89 ++++++++++--------- .../plugins/jeditable/jquery.jeditable.js | 4 +- htdocs/main.inc.php | 2 +- 5 files changed, 68 insertions(+), 50 deletions(-) diff --git a/dev/dolibarr_changes.txt b/dev/dolibarr_changes.txt index 0570525cdad..53f58c6790e 100644 --- a/dev/dolibarr_changes.txt +++ b/dev/dolibarr_changes.txt @@ -123,4 +123,12 @@ PARSEDOWN else $len = strlen($line); $shortage = 4 - $len % 4; - + + +JEDITABLE.JS +------------ + +* '; print "\n"; print "\n"; @@ -77,7 +85,7 @@ else { $colspan=9; if (! empty($conf->global->MAIN_CAN_HIDE_EXTRAFIELDS)) $colspan++; - + print ''; print ' - diff --git a/htdocs/expensereport/tpl/linkedobjectblock.tpl.php b/htdocs/expensereport/tpl/linkedobjectblock.tpl.php index 7fec53bf3d8..95894a8987e 100644 --- a/htdocs/expensereport/tpl/linkedobjectblock.tpl.php +++ b/htdocs/expensereport/tpl/linkedobjectblock.tpl.php @@ -15,8 +15,15 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see . - * */ + +// Protection to avoid direct call of template +if (empty($conf) || ! is_object($conf)) +{ + print "Error, template page can't be called as URL"; + exit; +} + ?> @@ -32,7 +39,7 @@ $var=true; $total=0; foreach($linkedObjectBlock as $key => $objectlink) { - + ?> > diff --git a/htdocs/fichinter/tpl/linkedobjectblock.tpl.php b/htdocs/fichinter/tpl/linkedobjectblock.tpl.php index 455f383fd4a..5d180f0aa82 100644 --- a/htdocs/fichinter/tpl/linkedobjectblock.tpl.php +++ b/htdocs/fichinter/tpl/linkedobjectblock.tpl.php @@ -13,8 +13,15 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see . - * */ + +// Protection to avoid direct call of template +if (empty($conf) || ! is_object($conf)) +{ + print "Error, template page can't be called as URL"; + exit; +} + ?> @@ -33,7 +40,7 @@ $var=true; foreach($linkedObjectBlock as $key => $objectlink) { $ilink++; - + $trclass=($var?'pair':'impair'); if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass.=' liste_sub_total'; ?> diff --git a/htdocs/fourn/commande/tpl/linkedobjectblock.tpl.php b/htdocs/fourn/commande/tpl/linkedobjectblock.tpl.php index 232d12fad3d..113115f9ff8 100644 --- a/htdocs/fourn/commande/tpl/linkedobjectblock.tpl.php +++ b/htdocs/fourn/commande/tpl/linkedobjectblock.tpl.php @@ -14,8 +14,15 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see . - * */ + +// Protection to avoid direct call of template +if (empty($conf) || ! is_object($conf)) +{ + print "Error, template page can't be called as URL"; + exit; +} + ?> @@ -35,7 +42,7 @@ $var=true; foreach($linkedObjectBlock as $key => $objectlink) { $ilink++; - + $trclass=($var?'pair':'impair'); if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass.=' liste_sub_total'; ?> @@ -66,7 +73,7 @@ if (count($linkedObjectBlock) > 1) - diff --git a/htdocs/fourn/facture/tpl/linkedobjectblock.tpl.php b/htdocs/fourn/facture/tpl/linkedobjectblock.tpl.php index e8154cd8259..ce72f5be42e 100644 --- a/htdocs/fourn/facture/tpl/linkedobjectblock.tpl.php +++ b/htdocs/fourn/facture/tpl/linkedobjectblock.tpl.php @@ -17,6 +17,14 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ + +// Protection to avoid direct call of template +if (empty($conf) || ! is_object($conf)) +{ + print "Error, template page can't be called as URL"; + exit; +} + ?> @@ -36,7 +44,7 @@ $var=true; foreach($linkedObjectBlock as $key => $objectlink) { $ilink++; - + $trclass=($var?'pair':'impair'); if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass.=' liste_sub_total'; ?> @@ -54,7 +62,7 @@ foreach($linkedObjectBlock as $key => $objectlink) $total = $total + $sign * $objectlink->total_ht; echo price($objectlink->total_ht); } - else + else { echo ''.price($objectlink->total_ht).''; } @@ -62,7 +70,7 @@ foreach($linkedObjectBlock as $key => $objectlink) - 1) { @@ -76,7 +84,7 @@ if (count($linkedObjectBlock) > 1) - diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index d5a692ca86e..2b4ad4de3c5 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -81,7 +81,7 @@ function test_sql_and_script_inject($val, $type) // For SQL Injection (only GET and POST are used to be included into bad escaped SQL requests) if ($type != 2) { - $inj += preg_match('/updatexml^(/i', $val); + $inj += preg_match('/updatexml\(/i', $val); $inj += preg_match('/delete\s+from/i', $val); $inj += preg_match('/create\s+table/i', $val); $inj += preg_match('/update.+set.+=/i', $val); diff --git a/htdocs/modulebuilder/template/core/tpl/mytemplate.tpl.php b/htdocs/modulebuilder/template/core/tpl/mytemplate.tpl.php index 9d399c44e85..3684ded0092 100644 --- a/htdocs/modulebuilder/template/core/tpl/mytemplate.tpl.php +++ b/htdocs/modulebuilder/template/core/tpl/mytemplate.tpl.php @@ -23,5 +23,13 @@ * Put detailed description here. */ +// Protection to avoid direct call of template +if (empty($conf) || ! is_object($conf)) +{ + print "Error, template page can't be called as URL"; + exit; +} + + /** Your code here. */ echo "Hello world!"; diff --git a/htdocs/product/canvas/product/tpl/card_create.tpl.php b/htdocs/product/canvas/product/tpl/card_create.tpl.php index 514c5d213d5..e763605f701 100644 --- a/htdocs/product/canvas/product/tpl/card_create.tpl.php +++ b/htdocs/product/canvas/product/tpl/card_create.tpl.php @@ -15,6 +15,14 @@ * along with this program. If not, see . */ +// Protection to avoid direct call of template +if (empty($conf) || ! is_object($conf)) +{ + print "Error, template page can't be called as URL"; + exit; +} + + $object=$GLOBALS['object']; $statutarray=array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSell")); diff --git a/htdocs/product/canvas/product/tpl/card_edit.tpl.php b/htdocs/product/canvas/product/tpl/card_edit.tpl.php index 686ad7217b7..c64c5dbe1e4 100644 --- a/htdocs/product/canvas/product/tpl/card_edit.tpl.php +++ b/htdocs/product/canvas/product/tpl/card_edit.tpl.php @@ -15,6 +15,14 @@ * along with this program. If not, see . */ +// Protection to avoid direct call of template +if (empty($conf) || ! is_object($conf)) +{ + print "Error, template page can't be called as URL"; + exit; +} + + $object=$GLOBALS['object']; $statutarray=array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSell")); diff --git a/htdocs/product/canvas/product/tpl/card_view.tpl.php b/htdocs/product/canvas/product/tpl/card_view.tpl.php index 771005781cd..44b1f96203b 100644 --- a/htdocs/product/canvas/product/tpl/card_view.tpl.php +++ b/htdocs/product/canvas/product/tpl/card_view.tpl.php @@ -15,6 +15,14 @@ * along with this program. If not, see . */ +// Protection to avoid direct call of template +if (empty($conf) || ! is_object($conf)) +{ + print "Error, template page can't be called as URL"; + exit; +} + + $object=$GLOBALS['object']; ?> diff --git a/htdocs/product/canvas/product/tpl/list.tpl.php b/htdocs/product/canvas/product/tpl/list.tpl.php index db7cac7e51c..e5c315e8148 100644 --- a/htdocs/product/canvas/product/tpl/list.tpl.php +++ b/htdocs/product/canvas/product/tpl/list.tpl.php @@ -13,8 +13,15 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see . - * */ + +// Protection to avoid direct call of template +if (empty($conf) || ! is_object($conf)) +{ + print "Error, template page can't be called as URL"; + exit; +} + ?> @@ -69,7 +76,7 @@ if ($searchfield['enabled']) { if ($searchfield['search']) { ?> - '; $searchpicto=$form->showFilterAndCheckAddButtons(0); print $searchpicto; diff --git a/htdocs/product/canvas/service/tpl/card_create.tpl.php b/htdocs/product/canvas/service/tpl/card_create.tpl.php index e25f69d8848..46db54d63b8 100644 --- a/htdocs/product/canvas/service/tpl/card_create.tpl.php +++ b/htdocs/product/canvas/service/tpl/card_create.tpl.php @@ -13,9 +13,16 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see . - * */ +// Protection to avoid direct call of template +if (empty($conf) || ! is_object($conf)) +{ + print "Error, template page can't be called as URL"; + exit; +} + + $object=$GLOBALS['object']; $statutarray=array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSell")); diff --git a/htdocs/product/canvas/service/tpl/card_edit.tpl.php b/htdocs/product/canvas/service/tpl/card_edit.tpl.php index 27348b7820d..06d1b3ff612 100644 --- a/htdocs/product/canvas/service/tpl/card_edit.tpl.php +++ b/htdocs/product/canvas/service/tpl/card_edit.tpl.php @@ -15,6 +15,14 @@ * along with this program. If not, see . */ +// Protection to avoid direct call of template +if (empty($conf) || ! is_object($conf)) +{ + print "Error, template page can't be called as URL"; + exit; +} + + $object=$GLOBALS['object']; $statutarray=array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSell")); diff --git a/htdocs/product/canvas/service/tpl/card_view.tpl.php b/htdocs/product/canvas/service/tpl/card_view.tpl.php index fd5d9ad73bf..fc129132dee 100644 --- a/htdocs/product/canvas/service/tpl/card_view.tpl.php +++ b/htdocs/product/canvas/service/tpl/card_view.tpl.php @@ -15,6 +15,14 @@ * along with this program. If not, see . */ +// Protection to avoid direct call of template +if (empty($conf) || ! is_object($conf)) +{ + print "Error, template page can't be called as URL"; + exit; +} + + $object=$GLOBALS['object']; ?> diff --git a/htdocs/product/canvas/service/tpl/list.tpl.php b/htdocs/product/canvas/service/tpl/list.tpl.php index ee2a894de98..9951c71fcc3 100644 --- a/htdocs/product/canvas/service/tpl/list.tpl.php +++ b/htdocs/product/canvas/service/tpl/list.tpl.php @@ -13,8 +13,15 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see . - * */ + +// Protection to avoid direct call of template +if (empty($conf) || ! is_object($conf)) +{ + print "Error, template page can't be called as URL"; + exit; +} + ?> @@ -69,7 +76,7 @@ if ($searchfield['enabled']) { if ($searchfield['search']) { ?> - '; $searchpicto=$form->showFilterAndCheckAddButtons(0); print $searchpicto; diff --git a/htdocs/product/inventory/tpl/inventory.tpl.php b/htdocs/product/inventory/tpl/inventory.tpl.php index 05de0f4c002..cf74aa21bdc 100644 --- a/htdocs/product/inventory/tpl/inventory.tpl.php +++ b/htdocs/product/inventory/tpl/inventory.tpl.php @@ -1,12 +1,22 @@ + @@ -76,37 +86,37 @@ - + - +
- +
Cet inventaire est validé
- + - +
'.$langs->trans("RefPayment").''.$langs->trans("Type").''.$langs->trans("Insurance").''.$langs->trans("Interest").''.$langs->trans("LoanCapital").'
'.$langs->trans("LoanCapital").'
'.img_object($langs->trans("Payment"),"payment").' '.$objp->rowid.''.dol_print_date($db->jdate($objp->dp),'day')."".$objp->paiement_type.' '.$objp->num_payment."'.price($objp->amount_insurance, 0, $langs, 0, 0, -1, $conf->currency)."'.price($objp->amount_interest, 0, $langs, 0, 0, -1, $conf->currency)."'.price($objp->amount_capital, 0, $langs, 0, 0, -1, $conf->currency)."'.price($objp->amount_insurance, 0, $langs, 0, 0, -1, $conf->currency)."'.price($objp->amount_interest, 0, $langs, 0, 0, -1, $conf->currency)."'.price($objp->amount_capital, 0, $langs, 0, 0, -1, $conf->currency)."
".$obj->zip."".$obj->state_name."'; - if (count($typenArray)==0) $typenArray = $formcompany->typent_array(1); + if (! is_array($typenArray) || count($typenArray)==0) $typenArray = $formcompany->typent_array(1); print $typenArray[$obj->typent_code]; print '
'.$form->editfieldkey("TrackingNumber",'trackingnumber',$object->tracking_number,$object,$user->rights->expedition->creer).''; - print $form->editfieldval("TrackingNumber",'trackingnumber',$object->tracking_url,$object,$user->rights->expedition->creer,'string',$object->tracking_number); + print '
'.$form->editfieldkey("TrackingNumber",'tracking_number',$object->tracking_number,$object,$user->rights->expedition->creer).''; + print $form->editfieldval("TrackingNumber",'tracking_number',$object->tracking_url,$object,$user->rights->expedition->creer,'string',$object->tracking_number); print '
".$extrafields->attribute_pos[$key]."".$extrafields->attribute_label[$key]."
'; print $langs->trans("None"); diff --git a/htdocs/core/tpl/ajax/fileupload_main.tpl.php b/htdocs/core/tpl/ajax/fileupload_main.tpl.php index 034e9ebc3fc..93f0826e160 100644 --- a/htdocs/core/tpl/ajax/fileupload_main.tpl.php +++ b/htdocs/core/tpl/ajax/fileupload_main.tpl.php @@ -13,8 +13,15 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see . - * */ + +// Protection to avoid direct call of template +if (empty($conf) || ! is_object($conf)) +{ + print "Error, template page can't be called as URL"; + exit; +} + ?> diff --git a/htdocs/core/tpl/ajax/fileupload_view.tpl.php b/htdocs/core/tpl/ajax/fileupload_view.tpl.php index 0c048933473..482a3aef8e4 100644 --- a/htdocs/core/tpl/ajax/fileupload_view.tpl.php +++ b/htdocs/core/tpl/ajax/fileupload_view.tpl.php @@ -13,8 +13,15 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see . - * */ + +// Protection to avoid direct call of template +if (empty($conf) || ! is_object($conf)) +{ + print "Error, template page can't be called as URL"; + exit; +} + ?> diff --git a/htdocs/core/tpl/ajaxrow.tpl.php b/htdocs/core/tpl/ajaxrow.tpl.php index a5d8ab039b8..af300528111 100644 --- a/htdocs/core/tpl/ajaxrow.tpl.php +++ b/htdocs/core/tpl/ajaxrow.tpl.php @@ -19,6 +19,14 @@ * You can use this if you want to be abale to drag and drop rows of a table. * You must add id="tablelines" on table level tag and have ($nboflines or count($object->lines) or count($taskarray) > 0) */ + +// Protection to avoid direct call of template +if (empty($object) || ! is_object($object)) +{ + print "Error, template page can't be called as URL"; + exit; +} + ?> diff --git a/htdocs/core/tpl/bloc_showhide.tpl.php b/htdocs/core/tpl/bloc_showhide.tpl.php index 2c5d71c79d5..c572012ca60 100644 --- a/htdocs/core/tpl/bloc_showhide.tpl.php +++ b/htdocs/core/tpl/bloc_showhide.tpl.php @@ -16,6 +16,13 @@ * along with this program. If not, see . */ +// Protection to avoid direct call of template +if (empty($blocname)) +{ + print "Error, template page can't be called as URL"; + exit; +} + $hide = true; // Hide by default if (isset($parameters['showblocbydefault'])) $hide=(empty($parameters['showblocbydefault']) ? true : false); if (isset($object->extraparams[$blocname]['showhide'])) $hide = (empty($object->extraparams[$blocname]['showhide']) ? true : false); diff --git a/htdocs/core/tpl/contacts.tpl.php b/htdocs/core/tpl/contacts.tpl.php index c7b3ea7342f..27d57d3e48a 100644 --- a/htdocs/core/tpl/contacts.tpl.php +++ b/htdocs/core/tpl/contacts.tpl.php @@ -21,6 +21,14 @@ * $withproject (if we are on task contact) */ +// Protection to avoid direct call of template +if (empty($object) || ! is_object($object)) +{ + print "Error, template page can't be called as URL"; + exit; +} + + require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; diff --git a/htdocs/core/tpl/document_actions_post_headers.tpl.php b/htdocs/core/tpl/document_actions_post_headers.tpl.php index e613c479ee0..63046fefa3f 100644 --- a/htdocs/core/tpl/document_actions_post_headers.tpl.php +++ b/htdocs/core/tpl/document_actions_post_headers.tpl.php @@ -24,6 +24,14 @@ // $modulepart = for download // $param = param to add to download links +// Protection to avoid direct call of template +if (empty($langs) || ! is_object($langs)) +{ + print "Error, template page can't be called as URL"; + exit; +} + + $langs->load("link"); if (empty($relativepathwithnofile)) $relativepathwithnofile=''; if (empty($permtoedit)) $permtoedit=-1; diff --git a/htdocs/core/tpl/extrafields_view.tpl.php b/htdocs/core/tpl/extrafields_view.tpl.php index 0f1d581c99f..433e8d07094 100644 --- a/htdocs/core/tpl/extrafields_view.tpl.php +++ b/htdocs/core/tpl/extrafields_view.tpl.php @@ -24,6 +24,14 @@ * $parameters * $cols */ + +// Protection to avoid direct call of template +if (empty($object) || ! is_object($object)) +{ + print "Error, template page can't be called as URL"; + exit; +} + ?> array('js'=>..., 'table'=>...); +// Protection to avoid direct call of template +if (empty($conf) || ! is_object($conf)) +{ + print "Error, template page can't be called as URL"; + exit; +} + + header('Cache-Control: Public, must-revalidate'); header("Content-type: text/html; charset=".$conf->file->character_set_client); diff --git a/htdocs/core/tpl/notes.tpl.php b/htdocs/core/tpl/notes.tpl.php index 2538e052ae4..da3ad8fb234 100644 --- a/htdocs/core/tpl/notes.tpl.php +++ b/htdocs/core/tpl/notes.tpl.php @@ -17,6 +17,14 @@ * along with this program. If not, see . */ +// Protection to avoid direct call of template +if (empty($object) || ! is_object($object)) +{ + print "Error, template page can't be called as URL"; + exit; +} + + // $cssclass must be defined by caller. For example cssclass='fieldtitle" $module = $object->element; $note_public = 'note_public'; diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index b123a6e91c2..d44008704be 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -30,6 +30,13 @@ * $inputalsopricewithtax (0 by default, 1 to also show column with unit price including tax) */ +// Protection to avoid direct call of template +if (empty($object) || ! is_object($object)) +{ + print "Error, template page can't be called as URL"; + exit; +} + $usemargins=0; if (! empty($conf->margin->enabled) && ! empty($object->element) && in_array($object->element,array('facture','propal','commande'))) diff --git a/htdocs/core/tpl/objectline_edit.tpl.php b/htdocs/core/tpl/objectline_edit.tpl.php index 2f839e06281..3b62c0e7814 100644 --- a/htdocs/core/tpl/objectline_edit.tpl.php +++ b/htdocs/core/tpl/objectline_edit.tpl.php @@ -30,6 +30,13 @@ * $inputalsopricewithtax (0 by default, 1 to also show column with unit price including tax) */ +// Protection to avoid direct call of template +if (empty($object) || ! is_object($object)) +{ + print "Error, template page can't be called as URL"; + exit; +} + $usemargins=0; if (! empty($conf->margin->enabled) && ! empty($object->element) && in_array($object->element,array('facture','propal','commande'))) $usemargins=1; @@ -266,21 +273,21 @@ jQuery(document).ready(function() if (event.which != 9 && (event.which < 37 ||event.which > 40) && jQuery("#price_ht").val() != '') { jQuery("#price_ttc").val(''); jQuery("#multicurrency_subprice").val(''); - } + } }); jQuery("#price_ttc").keyup(function(event) { // console.log(event.which); // discard event tag and arrows if (event.which != 9 && (event.which < 37 || event.which > 40) && jQuery("#price_ttc").val() != '') { jQuery("#price_ht").val(''); jQuery("#multicurrency_subprice").val(''); - } + } }); jQuery("#multicurrency_subprice").keyup(function(event) { // console.log(event.which); // discard event tag and arrows if (event.which != 9 && (event.which < 37 || event.which > 40) && jQuery("#price_ttc").val() != '') { jQuery("#price_ht").val(''); jQuery("#price_ttc").val(''); - } + } }); . - * */ + +// Protection to avoid direct call of template +if (empty($conf) || ! is_object($conf)) +{ + print "Error, template page can't be called as URL"; + exit; +} + ?> diff --git a/htdocs/core/tpl/passwordforgotten.tpl.php b/htdocs/core/tpl/passwordforgotten.tpl.php index 9e155be88c9..bdcca51b4e7 100644 --- a/htdocs/core/tpl/passwordforgotten.tpl.php +++ b/htdocs/core/tpl/passwordforgotten.tpl.php @@ -16,6 +16,14 @@ * along with this program. If not, see . */ +// Protection to avoid direct call of template +if (empty($conf) || ! is_object($conf)) +{ + print "Error, template page can't be called as URL"; + exit; +} + + header('Cache-Control: Public, must-revalidate'); header("Content-type: text/html; charset=".$conf->file->character_set_client); diff --git a/htdocs/core/tpl/resource_add.tpl.php b/htdocs/core/tpl/resource_add.tpl.php index 28c42c85b71..af1d25aaee1 100644 --- a/htdocs/core/tpl/resource_add.tpl.php +++ b/htdocs/core/tpl/resource_add.tpl.php @@ -1,6 +1,14 @@ 0) foreach ($linked_resources as $linked_resource) { - + $object_resource = fetchObjectByElement($linked_resource['resource_id'],$linked_resource['resource_type']); - + //$element_id = $linked_resource['rowid']; - + if ($mode == 'edit' && $linked_resource['rowid'] == GETPOST('lineid')) { diff --git a/htdocs/ecm/tpl/enablefiletreeajax.tpl.php b/htdocs/ecm/tpl/enablefiletreeajax.tpl.php index bbcbb7090a4..d002281ae34 100644 --- a/htdocs/ecm/tpl/enablefiletreeajax.tpl.php +++ b/htdocs/ecm/tpl/enablefiletreeajax.tpl.php @@ -16,6 +16,14 @@ * * Output javascript for interactions code of ecm module */ + +// Protection to avoid direct call of template +if (empty($conf) || ! is_object($conf)) +{ + print "Error, template page can't be called as URL"; + exit; +} + ?> diff --git a/htdocs/expedition/tpl/linkedobjectblock.tpl.php b/htdocs/expedition/tpl/linkedobjectblock.tpl.php index b55654f4786..88811da2eab 100644 --- a/htdocs/expedition/tpl/linkedobjectblock.tpl.php +++ b/htdocs/expedition/tpl/linkedobjectblock.tpl.php @@ -14,8 +14,15 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see . - * */ + +// Protection to avoid direct call of template +if (empty($conf) || ! is_object($conf)) +{ + print "Error, template page can't be called as URL"; + exit; +} + ?> @@ -34,7 +41,7 @@ $var=true; foreach($linkedObjectBlock as $key => $objectlink) { $ilink++; - + $trclass=($var?'pair':'impair'); if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass.=' liste_sub_total'; ?> @@ -73,7 +80,7 @@ if (count($linkedObjectBlock) > 1)
trans("ExpenseReport"); ?>
getLibStatut(3); ?> ">transnoentitiesnoconv("RemoveLink")); ?>
$row) { - + + foreach ($lines as $k=>$row) { + $total_pmp+=$row['pmp_stock']; $total_pa+=$row['pa_stock']; $total_pmp_actual+=$row['pmp_actual']; $total_pa_actual+=$row['pa_actual']; - + if($i%20 === 0) { _headerList($view); @@ -126,18 +136,18 @@ if(!empty($conf->global->INVENTORY_USE_MIN_PA_IF_NO_LAST_PA)){ echo ''; $total_current_pa+=$row['current_pa_stock']; - } - + } + ?> rights->stock->changePMP)) { - echo ''; + echo ''; } ?> @@ -145,8 +155,8 @@ if(!empty($conf->global->INVENTORY_USE_MIN_PA_IF_NO_LAST_PA)){ echo ''; $total_current_pa_actual+=$row['current_pa_actual']; - } - + } + ?> @@ -154,25 +164,25 @@ -
'.price($row['current_pa_stock']).'    - + '.$row['pmp_new'].''.$row['pmp_new'].''.price($row['current_pa_actual']).'
- + status != 1) { ?>
trans('Modify') ?> - rights->stock->changePMP)) { echo ''.$langs->trans('ApplyPMP').''; } - + if ($can_validate == 1) { ?> trans('RegulateStock') ?> @@ -193,13 +203,13 @@ trans('Delete') ?> - +

Date de création : getDate('datec') ?>
Dernière mise à jour : getDate('tms') ?>

- - + + diff --git a/htdocs/product/stock/tpl/stockcorrection.tpl.php b/htdocs/product/stock/tpl/stockcorrection.tpl.php index 4242121177c..732fa8c889d 100644 --- a/htdocs/product/stock/tpl/stockcorrection.tpl.php +++ b/htdocs/product/stock/tpl/stockcorrection.tpl.php @@ -17,6 +17,14 @@ * $object must be defined * $backtopage */ + +// Protection to avoid direct call of template +if (empty($conf) || ! is_object($conf)) +{ + print "Error, template page can't be called as URL"; + exit; +} + ?> diff --git a/htdocs/product/stock/tpl/stocktransfer.tpl.php b/htdocs/product/stock/tpl/stocktransfer.tpl.php index 6d028da5663..18f6b831cf2 100644 --- a/htdocs/product/stock/tpl/stocktransfer.tpl.php +++ b/htdocs/product/stock/tpl/stocktransfer.tpl.php @@ -17,6 +17,14 @@ * $object must be defined * $backtopage */ + +// Protection to avoid direct call of template +if (empty($conf) || ! is_object($conf)) +{ + print "Error, template page can't be called as URL"; + exit; +} + ?> diff --git a/htdocs/societe/canvas/company/tpl/card_create.tpl.php b/htdocs/societe/canvas/company/tpl/card_create.tpl.php index d542f0553ba..80740381e05 100644 --- a/htdocs/societe/canvas/company/tpl/card_create.tpl.php +++ b/htdocs/societe/canvas/company/tpl/card_create.tpl.php @@ -14,8 +14,15 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see . - * */ + +// Protection to avoid direct call of template +if (empty($conf) || ! is_object($conf)) +{ + print "Error, template page can't be called as URL"; + exit; +} + ?> diff --git a/htdocs/societe/canvas/company/tpl/card_edit.tpl.php b/htdocs/societe/canvas/company/tpl/card_edit.tpl.php index 1f6201ec829..82474ae405f 100644 --- a/htdocs/societe/canvas/company/tpl/card_edit.tpl.php +++ b/htdocs/societe/canvas/company/tpl/card_edit.tpl.php @@ -14,9 +14,16 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see . - * */ +// Protection to avoid direct call of template +if (empty($conf) || ! is_object($conf)) +{ + print "Error, template page can't be called as URL"; + exit; +} + + $contact = $GLOBALS['objcanvas']->control->object; ?> diff --git a/htdocs/societe/canvas/company/tpl/card_view.tpl.php b/htdocs/societe/canvas/company/tpl/card_view.tpl.php index 21645f14d00..3865e9b95a0 100644 --- a/htdocs/societe/canvas/company/tpl/card_view.tpl.php +++ b/htdocs/societe/canvas/company/tpl/card_view.tpl.php @@ -13,9 +13,16 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see . - * */ +// Protection to avoid direct call of template +if (empty($conf) || ! is_object($conf)) +{ + print "Error, template page can't be called as URL"; + exit; +} + + $soc = $GLOBALS['objcanvas']->control->object; ?> diff --git a/htdocs/societe/canvas/individual/tpl/card_create.tpl.php b/htdocs/societe/canvas/individual/tpl/card_create.tpl.php index 1be20214c35..ba5aaf68e44 100644 --- a/htdocs/societe/canvas/individual/tpl/card_create.tpl.php +++ b/htdocs/societe/canvas/individual/tpl/card_create.tpl.php @@ -14,8 +14,15 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see . - * */ + +// Protection to avoid direct call of template +if (empty($conf) || ! is_object($conf)) +{ + print "Error, template page can't be called as URL"; + exit; +} + ?> diff --git a/htdocs/societe/canvas/individual/tpl/card_edit.tpl.php b/htdocs/societe/canvas/individual/tpl/card_edit.tpl.php index 90543958902..76db85282db 100644 --- a/htdocs/societe/canvas/individual/tpl/card_edit.tpl.php +++ b/htdocs/societe/canvas/individual/tpl/card_edit.tpl.php @@ -14,8 +14,15 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see . - * */ + +// Protection to avoid direct call of template +if (empty($conf) || ! is_object($conf)) +{ + print "Error, template page can't be called as URL"; + exit; +} + ?> diff --git a/htdocs/societe/canvas/individual/tpl/card_view.tpl.php b/htdocs/societe/canvas/individual/tpl/card_view.tpl.php index 10136048ae6..359f4ec7b44 100644 --- a/htdocs/societe/canvas/individual/tpl/card_view.tpl.php +++ b/htdocs/societe/canvas/individual/tpl/card_view.tpl.php @@ -13,9 +13,16 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see . - * */ +// Protection to avoid direct call of template +if (empty($conf) || ! is_object($conf)) +{ + print "Error, template page can't be called as URL"; + exit; +} + + $object = $GLOBALS['objcanvas']->control->object; ?> diff --git a/htdocs/societe/tpl/linesalesrepresentative.tpl.php b/htdocs/societe/tpl/linesalesrepresentative.tpl.php index 3ec07697ec7..dc6d6ec4d08 100644 --- a/htdocs/societe/tpl/linesalesrepresentative.tpl.php +++ b/htdocs/societe/tpl/linesalesrepresentative.tpl.php @@ -1,5 +1,12 @@ '; print ' - From b70dd36ffa485888c08cc6c7b8eb32a9f8379001 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 24 Dec 2017 12:16:48 +0100 Subject: [PATCH 64/64] Better js comment --- htdocs/core/tpl/login.tpl.php | 2 +- htdocs/core/tpl/passwordforgotten.tpl.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/tpl/login.tpl.php b/htdocs/core/tpl/login.tpl.php index d2c18e6f92f..14bdd8e4d9d 100644 --- a/htdocs/core/tpl/login.tpl.php +++ b/htdocs/core/tpl/login.tpl.php @@ -62,7 +62,7 @@ print top_htmlhead('', $titleofloginpage, 0, 0, $arrayofjs, array(), 0, $disable dol_use_jmobile)) { ?> diff --git a/htdocs/core/tpl/passwordforgotten.tpl.php b/htdocs/core/tpl/passwordforgotten.tpl.php index bdcca51b4e7..30bc70b72cc 100644 --- a/htdocs/core/tpl/passwordforgotten.tpl.php +++ b/htdocs/core/tpl/passwordforgotten.tpl.php @@ -48,7 +48,7 @@ print top_htmlhead('',$langs->trans('SendNewPassword')); dol_use_jmobile)) { ?>
'; print $langs->trans('SalesRepresentatives'); diff --git a/htdocs/supplier_proposal/tpl/linkedobjectblock.tpl.php b/htdocs/supplier_proposal/tpl/linkedobjectblock.tpl.php index d313eca10bd..8c49e42f557 100644 --- a/htdocs/supplier_proposal/tpl/linkedobjectblock.tpl.php +++ b/htdocs/supplier_proposal/tpl/linkedobjectblock.tpl.php @@ -17,6 +17,13 @@ * along with this program. If not, see . */ +// Protection to avoid direct call of template +if (empty($conf) || ! is_object($conf)) +{ + print "Error, template page can't be called as URL"; + exit; +} + ?> @@ -33,7 +40,7 @@ $var=true; foreach($linkedObjectBlock as $key => $objectlink) { $ilink++; - + $trclass=($var?'pair':'impair'); if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass.=' liste_sub_total'; ?> @@ -64,7 +71,7 @@ if (count($linkedObjectBlock) > 1)