From 8199ac9f89600273b91fe20a118b466c0f1d3381 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 22 Mar 2017 19:49:58 +0100 Subject: [PATCH 01/13] FIX Can't download delivery receipts (function dol_check_secure_access_document) --- htdocs/core/lib/files.lib.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 59e5a3426a2..586622538e9 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1725,9 +1725,8 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$fu } $original_file=$conf->expedition->dir_output."/sending/".$original_file; } - // Wrapping pour les bons de livraison - else if ($modulepart == 'livraison' && !empty($conf->livraison->dir_output)) + if ($modulepart == 'livraison' && !empty($conf->expedition->dir_output)) { if ($fuser->rights->expedition->livraison->lire || preg_match('/^specimen/i',$original_file)) { From 9b42177bd5c47079a030053bef0ad37caad06d53 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 23 Mar 2017 10:52:09 +0100 Subject: [PATCH 02/13] Fix half day for leave request. --- htdocs/hrm/index.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/hrm/index.php b/htdocs/hrm/index.php index 30d0c911ba1..714f329add3 100644 --- a/htdocs/hrm/index.php +++ b/htdocs/hrm/index.php @@ -148,7 +148,7 @@ $langs->load("boxes"); -// Last leave requests +// Latest leave requests if (! empty($conf->holiday->enabled) && $user->rights->holiday->read) { $sql = "SELECT u.rowid as uid, u.lastname, u.firstname, u.login, u.photo, u.statut, x.rowid, x.rowid as ref, x.fk_type, x.date_debut as date_start, x.date_fin as date_end, x.halfday, x.tms as dm, x.statut as status"; @@ -204,7 +204,7 @@ if (! empty($conf->holiday->enabled) && $user->rights->holiday->read) $starthalfday=($obj->halfday == -1 || $obj->halfday == 2)?'afternoon':'morning'; $endhalfday=($obj->halfday == 1 || $obj->halfday == 2)?'morning':'afternoon'; - print ''.dol_print_date($obj->date_start,'day').' '.$langs->trans($listhalfday[$endhalfday]); + print ''.dol_print_date($obj->date_start,'day').' '.$langs->trans($listhalfday[$starthalfday]); print ''.dol_print_date($obj->date_end,'day').' '.$langs->trans($listhalfday[$endhalfday]); print ''.dol_print_date($db->jdate($obj->dm),'day').''; print ''.$holidaystatic->LibStatut($obj->status,3).''; From aa9d991923ba17f675c883472d953501f21bd90f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 25 Mar 2017 01:03:02 +0100 Subject: [PATCH 03/13] Fix css --- htdocs/comm/index.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index 4e99b7072fc..7ea7b840d6b 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -158,10 +158,10 @@ if (! empty($conf->propal->enabled) && $user->rights->propal->lire) print ''; print ''.$langs->trans("ProposalsDraft").($num?' '.$num.'':'').''; + $var=true; if ($num > 0) { $i = 0; - $var=true; while ($i < $num) { $obj = $db->fetch_object($resql); @@ -239,10 +239,10 @@ if (! empty($conf->supplier_proposal->enabled) && $user->rights->supplier_propos print ''; print ''.$langs->trans("SupplierProposalsDraft").($num?' '.$num.'':'').''; + $var=true; if ($num > 0) { $i = 0; - $var=true; while ($i < $num) { $obj = $db->fetch_object($resql); @@ -318,10 +318,10 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire) print ''; print ''.$langs->trans("DraftOrders").($num?' '.$num.'':'').''; - if ($num) + $var = true; + if ($num > 0) { $i = 0; - $var = true; while ($i < $num) { $var=!$var; @@ -399,10 +399,10 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande print ''; print ''.$langs->trans("DraftSuppliersOrders").($num?' '.$num.'':'').''; - if ($num) + $var = true; + if ($num > 0) { $i = 0; - $var = true; while ($i < $num) { $var=!$var; From df59a595de716f16a3c7aa2ca75debf1c355f7af Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 25 Mar 2017 01:29:19 +0100 Subject: [PATCH 04/13] Fix link to files --- htdocs/core/lib/files.lib.php | 2 +- htdocs/core/tpl/ajaxrow.tpl.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 586622538e9..d27d6c1cdb1 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1726,7 +1726,7 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$fu $original_file=$conf->expedition->dir_output."/sending/".$original_file; } // Wrapping pour les bons de livraison - if ($modulepart == 'livraison' && !empty($conf->expedition->dir_output)) + else if ($modulepart == 'livraison' && !empty($conf->expedition->dir_output)) { if ($fuser->rights->expedition->livraison->lire || preg_match('/^specimen/i',$original_file)) { diff --git a/htdocs/core/tpl/ajaxrow.tpl.php b/htdocs/core/tpl/ajaxrow.tpl.php index 123fcef662c..a28bbac5e5a 100644 --- a/htdocs/core/tpl/ajaxrow.tpl.php +++ b/htdocs/core/tpl/ajaxrow.tpl.php @@ -40,6 +40,7 @@ $(document).ready(function(){ $(".tdlineupdown").css("background-repeat","no-repeat"); $(".tdlineupdown").css("background-position","center center"); + console.log("Prepare tableDnd for #"); $("#").tableDnD({ onDrop: function(table, row) { var reloadpage = ""; From 2f4a4f493e4a04507ce96748d15e81ace1afd4bc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 25 Mar 2017 01:47:52 +0100 Subject: [PATCH 05/13] Missin translation --- htdocs/product/fournisseurs.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index 69a9344832b..6ff8d9deca0 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -39,7 +39,7 @@ require_once DOL_DOCUMENT_ROOT.'/product/dynamic_price/class/price_parser.class. $langs->load("products"); $langs->load("suppliers"); $langs->load("bills"); -if (! empty($conf->margin->enabled)) $langs->load("margins"); +$langs->load("margins"); $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); From 106d19a8af74db6cc24c0862cdd4138e106a6ea3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 25 Mar 2017 03:53:11 +0100 Subject: [PATCH 06/13] FIX #6468 + Fix missing translation --- htdocs/comm/action/card.php | 15 +--------- .../class/fournisseur.commande.class.php | 27 ++++++++++------- htdocs/fourn/commande/dispatch.php | 30 ++++--------------- htdocs/langs/en_US/errors.lang | 1 + 4 files changed, 25 insertions(+), 48 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 7378e35db80..90596b54197 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -1208,20 +1208,12 @@ if ($id > 0) // Affichage fiche action en mode visu print ''; - // Ref - /*print '';*/ - // Type if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) { print ''; } - // Title - //print ''; - // Full day event print ''; @@ -1243,11 +1235,6 @@ if ($id > 0) if ($object->percentage > 0 && $object->percentage < 100 && $object->datef && $object->datef < ($now- $delay_warning)) print img_warning($langs->trans("Late")); print ''; - // Status - /*print '';*/ - // Location if (empty($conf->global->AGENDA_DISABLE_LOCATION)) { @@ -1281,7 +1268,7 @@ if ($id > 0) print '
'; print $form->select_dolusers_forevent('view', 'assignedtouser', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); print '
'; - if (in_array($user->id,array_keys($listofuserid))) + if ($object->datep != $object->datef && in_array($user->id,array_keys($listofuserid))) { print '
'; print $langs->trans("MyAvailability").': '.(($object->userassigned[$user->id]['transparency'] > 0)?$langs->trans("Busy"):$langs->trans("Available")); // We show nothing if event is assigned to nobody diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 98939ee01f2..676ca9f23ab 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1949,7 +1949,7 @@ class CommandeFournisseur extends CommonOrder } } - if (! $error && ! empty($conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS_NEED_APPROVE) && ($type == 'tot')) // Accept to move to rception done, only if status of all line are ok (refuse denied) + if (! $error && ! empty($conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS_NEED_APPROVE) && ($type == 'tot')) // Accept to move to reception done, only if status of all line are ok (refuse denied) { $dispatcheddenied=$this->getDispachedLines(2); if (count($dispatchedlinearray) > 0) @@ -1988,7 +1988,8 @@ class CommandeFournisseur extends CommonOrder $result = 0; $old_statut = $this->statut; $this->statut = $statut; - + $this->actionmsg2 = $comment; + // Call trigger $result=$this->call_trigger('ORDER_SUPPLIER_RECEIVE',$user); if ($result < 0) $error++; @@ -2810,13 +2811,14 @@ class CommandeFournisseur extends CommonOrder * * @param User $user User action * @param int $closeopenorder Close if received + * @param string $comment Comment * @return int <0 if KO, 0 if not applicable, >0 if OK */ - public function calcAndSetStatusDispatch(User $user, $closeopenorder=1) + public function calcAndSetStatusDispatch(User $user, $closeopenorder=1, $comment='') { - global $conf; + global $conf, $langs; - if (! empty($conf->commande->enabled) && ! empty($conf->fournisseur->enabled)) + if (! empty($conf->fournisseur->enabled)) { require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.dispatch.class.php'; @@ -2845,14 +2847,18 @@ class CommandeFournisseur extends CommonOrder foreach($this->lines as $line) { $qtywished[$line->fk_product]+=$line->qty; } + + $date_liv = dol_now(); + //Compare array $diff_array=array_diff_assoc($qtydelivered,$qtywished); - if (count($diff_array)==0) + + if (count($diff_array)==0) //No diff => mean everythings is received { - //No diff => mean everythings is received if ($closeopenorder) { - $ret=$this->setStatus($user,5); + //$ret=$this->setStatus($user,5); + $ret = $this->Livraison($user, $date_liv, 'tot', $comment); // GETPOST("type") is 'tot', 'par', 'nev', 'can' if ($ret<0) { return -1; } @@ -2861,7 +2867,8 @@ class CommandeFournisseur extends CommonOrder else { //Diff => received partially - $ret=$this->setStatus($user,4); + //$ret=$this->setStatus($user,4); + $ret = $this->Livraison($user, $date_liv, 'par', $comment); // GETPOST("type") is 'tot', 'par', 'nev', 'can' if ($ret<0) { return -1; } @@ -2871,7 +2878,7 @@ class CommandeFournisseur extends CommonOrder else { //Diff => received partially - $ret=$this->setStatus($user,4); + $ret = $this->Livraison($user, $date_liv, 'par', $comment); // GETPOST("type") is 'tot', 'par', 'nev', 'can' if ($ret<0) { return -1; } diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php index dc34686361f..c87b3a62bed 100644 --- a/htdocs/fourn/commande/dispatch.php +++ b/htdocs/fourn/commande/dispatch.php @@ -230,7 +230,7 @@ if ($action == 'dispatch' && $user->rights->fournisseur->commande->receptionner) } if (! $error) { - $result = $object->calcAndSetStatusDispatch($user, GETPOST('closeopenorder')?1:0); + $result = $object->calcAndSetStatusDispatch($user, GETPOST('closeopenorder')?1:0, GETPOST('comment')); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); $error ++; @@ -340,26 +340,7 @@ if ($id > 0 || ! empty($ref)) { print '
'; print '
'.$langs->trans("Ref").''; - print $form->showrefnav($object, 'id', $linkback, ($user->societe_id?0:1), 'id', 'ref', ''); - print '
'.$langs->trans("Type").''.$object->type.'
'.$langs->trans("Title").''.dol_htmlentities($object->label).'
'.$langs->trans("EventOnFullDay").''.yn($object->fulldayevent, 3).'
'.$langs->trans("Status").' / '.$langs->trans("Percentage").''; - print $object->getLibStatut(4); - print '
'; -/* - // Ref - print ''; - print ''; - print ''; - // Fournisseur - print '"; - print ''; - print ''; - - // Statut - print ''; - print ''; - print '"; -*/ // Date if ($object->methode_commande_id > 0) { print '\n"; @@ -609,7 +591,7 @@ if ($id > 0 || ! empty($ref)) { print '
'; print $langs->trans("Comment") . ' : '; - print 'trans("DispatchSupplierOrder", $object->ref); // print ' / '.$object->ref_supplier; // Not yet available print '" class="flat">
'; @@ -662,7 +644,7 @@ if ($id > 0 || ! empty($ref)) { print '
' . $langs->trans("Ref") . ''; - print $form->showrefnav($object, 'ref', '', 1, 'ref', 'ref'); - print '
' . $langs->trans("Supplier") . "' . $soc->getNomUrl(1, 'supplier') . '
' . $langs->trans("Status") . ''; - print $object->getLibStatut(4); - print "
' . $langs->trans("Date") . ''; @@ -585,7 +566,8 @@ if ($id > 0 || ! empty($ref)) { } elseif (count($listwarehouses) == 1) { print $formproduct->selectWarehouses(GETPOST("entrepot" . $suffix), "entrepot" . $suffix, '', 0, 0, $objp->fk_product); } else { - print $langs->trans("NoWarehouseDefined"); + $langs->load("errors"); + print $langs->trans("ErrorNoWarehouseDefined"); } print "
'; print ''; - print ''; + print ''; if (! empty($conf->productbatch->enabled)) { print ''; print ''; @@ -705,7 +687,7 @@ if ($id > 0 || ! empty($ref)) { print ''; // Comment - print ''; + print ''; // Status if (! empty($conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS)) { diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index 77a99994fef..af18693f9d4 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -184,6 +184,7 @@ ErrorTaskAlreadyAssigned=Task already assigned to user ErrorModuleFileSeemsToHaveAWrongFormat=The module package seems to have a wrong format. ErrorFilenameDosNotMatchDolibarrPackageRules=The name of the module package (%s) does not match expected name syntax: %s ErrorDuplicateTrigger=Error, duplicate trigger name %s. Already loaded from %s. +ErrorNoWarehouseDefined=Error, no warehouses defined. # Warnings WarningPasswordSetWithNoAccount=A password was set for this member. However, no user account was created. So this password is stored but can't be used to login to Dolibarr. It may be used by an external module/interface but if you don't need to define any login nor password for a member, you can disable option "Manage a login for each member" from Member module setup. If you need to manage a login but don't need any password, you can keep this field empty to avoid this warning. Note: Email can also be used as a login if the member is linked to a user. From 4012aeff908e0ecaf158275713feeb9dbda55056 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 25 Mar 2017 18:35:17 +0100 Subject: [PATCH 07/13] Fix translation --- dev/translation/sanity_check_en_langfiles.php | 2 ++ htdocs/core/boxes/box_graph_product_distribution.php | 2 ++ htdocs/langs/en_US/mails.lang | 4 ++++ 3 files changed, 8 insertions(+) diff --git a/dev/translation/sanity_check_en_langfiles.php b/dev/translation/sanity_check_en_langfiles.php index f566938d7e0..bb3430eb22c 100755 --- a/dev/translation/sanity_check_en_langfiles.php +++ b/dev/translation/sanity_check_en_langfiles.php @@ -300,6 +300,8 @@ if ((! empty($_REQUEST['unused']) && $_REQUEST['unused'] == 'true') || (isset($a if (preg_match('/^BoxTitleLatest/', $value)) $qualifiedforclean=0; // install.lang if (preg_match('/^KeepDefaultValues/', $value)) $qualifiedforclean=0; + // mail.lang + if (preg_match('/MailingModuleDesc/i', $value)) $qualifiedforclean=0; // main.lang if (preg_match('/^Duration/', $value)) $qualifiedforclean=0; if (preg_match('/^FormatDate/', $value)) $qualifiedforclean=0; diff --git a/htdocs/core/boxes/box_graph_product_distribution.php b/htdocs/core/boxes/box_graph_product_distribution.php index a709a7aef3a..2b3c69a9e15 100644 --- a/htdocs/core/boxes/box_graph_product_distribution.php +++ b/htdocs/core/boxes/box_graph_product_distribution.php @@ -249,6 +249,8 @@ class box_graph_product_distribution extends ModeleBoxes if (! empty($conf->commande->enabled) && ! empty($user->rights->commande->lire)) { + $langs->load("orders"); + // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) if ($showordernb) { diff --git a/htdocs/langs/en_US/mails.lang b/htdocs/langs/en_US/mails.lang index 897085ec423..61dddb46691 100644 --- a/htdocs/langs/en_US/mails.lang +++ b/htdocs/langs/en_US/mails.lang @@ -79,6 +79,10 @@ MailingModuleDescContactsWithThirdpartyFilter=Contact with customer filters MailingModuleDescContactsByCompanyCategory=Contacts by third party category MailingModuleDescContactsByCategory=Contacts by categories MailingModuleDescContactsByFunction=Contacts by position +MailingModuleDescEmailsFromFile=Emails from file +MailingModuleDescEmailsFromUser=Emails input by user +MailingModuleDescDolibarrUsers=Users with Emails +MailingModuleDescThirdPartiesByCategories=Third parties (by categories) # Libelle des modules de liste de destinataires mailing LineInFile=Line %s in file From 68656dd29cb8e4df78cfc199b3ca087310d13b1b Mon Sep 17 00:00:00 2001 From: BENKE Charlie Date: Sat, 25 Mar 2017 12:06:02 +0100 Subject: [PATCH 08/13] FIX : supplier default condition not retrived on create --- htdocs/supplier_proposal/card.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index 050e0186444..6a34a5ddd61 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -1050,7 +1050,9 @@ if ($action == 'create') } else { - if (!empty($conf->multicurrency->enabled) && !empty($soc->multicurrency_code)) $currency_code = $soc->multicurrency_code; + $cond_reglement_id = $soc->cond_reglement_supplier_id; + $mode_reglement_id = $soc->mode_reglement_supplier_id; + if (!empty($conf->multicurrency->enabled) && !empty($soc->multicurrency_code)) $currency_code = $soc->multicurrency_code; } $object = new SupplierProposal($db); @@ -1087,12 +1089,12 @@ if ($action == 'create') // Terms of payment print ''; // Mode of payment print ''; // Bank Account From f4a7217f20382e39fc29265d5a10fd4f41a97d04 Mon Sep 17 00:00:00 2001 From: BENKE Charlie Date: Fri, 24 Mar 2017 23:39:25 +0100 Subject: [PATCH 09/13] display total line for all total line --- htdocs/comm/propal/list.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index aa6df1afb2b..44a2b9356e8 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -977,7 +977,12 @@ if ($resql) } // Show total line - if (isset($totalarray['totalhtfield'])) + if (isset($totalarray['totalhtfield']) + || isset($totalarray['totalvatfield']) + || isset($totalarray['totalttcfield']) + || isset($totalarray['totalamfield']) + || isset($totalarray['totalrtpfield']) + ) { print ''; $i=0; From afefb475984ae29ef30e014e3c3f50da3b75e096 Mon Sep 17 00:00:00 2001 From: BENKE Charlie Date: Fri, 24 Mar 2017 23:40:34 +0100 Subject: [PATCH 10/13] Update list.php --- htdocs/commande/list.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index c72671319bc..073a20bc391 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -1398,7 +1398,12 @@ if ($resql) } // Show total line - if (isset($totalarray['totalhtfield'])) + if (isset($totalarray['totalhtfield']) + || isset($totalarray['totalvatfield']) + || isset($totalarray['totalttcfield']) + || isset($totalarray['totalamfield']) + || isset($totalarray['totalrtpfield']) + ) { print ''; $i=0; From 8d6819c6642e976c0e9235e72a06474f3785c334 Mon Sep 17 00:00:00 2001 From: BENKE Charlie Date: Fri, 24 Mar 2017 23:53:32 +0100 Subject: [PATCH 11/13] Update list.php --- htdocs/fourn/facture/list.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index bff5c773cfc..3afb97c5fb1 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -956,7 +956,12 @@ if ($resql) } // Show total line - if (isset($totalarray['totalhtfield'])) + if (isset($totalarray['totalhtfield']) + || isset($totalarray['totalvatfield']) + || isset($totalarray['totalttcfield']) + || isset($totalarray['totalamfield']) + || isset($totalarray['totalrtpfield']) + ) { print ''; $i=0; From 6e133e5bf6f3c03083cefaa5355a65015ad8d97d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 26 Mar 2017 01:57:09 +0100 Subject: [PATCH 12/13] Fix security escapment --- htdocs/loan/card.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/loan/card.php b/htdocs/loan/card.php index 8ef8e09eba9..d0ab75127ab 100644 --- a/htdocs/loan/card.php +++ b/htdocs/loan/card.php @@ -230,7 +230,7 @@ if ($action == 'create') } // Capital - print ''; + print ''; // Date Start print ""; @@ -245,10 +245,10 @@ if ($action == 'create') print ''; // Number of terms - print ''; + print ''; // Rate - print ''; + print ''; // Note Private print ''; From e38ad37ce33df734439f73ab4df49d7393a2659c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 26 Mar 2017 05:02:06 +0200 Subject: [PATCH 13/13] FIX #6517 #6525 Autocompletion of thirdparty after n chars not implemented --- htdocs/core/class/html.form.class.php | 86 ++++++++++++++------------- htdocs/core/lib/agenda.lib.php | 2 +- htdocs/societe/ajax/company.php | 32 ++++------ 3 files changed, 59 insertions(+), 61 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 60ff30c6433..664997129df 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -931,36 +931,40 @@ class Form /** * Output html form to select a third party * - * @param string $selected Preselected type - * @param string $htmlname Name of field in form - * @param string $filter optional filters criteras (example: 's.rowid <> x', 's.client IN (1,3)') - * @param string $showempty Add an empty field (Can be '1' or text key to use on empty line like 'SelectThirdParty') - * @param int $showtype Show third party type in combolist (customer, prospect or supplier) - * @param int $forcecombo Force to use combo box - * @param array $events Ajax event options to run on change. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled'))) - * @param int $limit Maximum number of elements - * @param string $morecss Add more css styles to the SELECT component - * @param string $moreparam Add more parameters onto the select tag. For example 'style="width: 95%"' to avoid select2 component to go over parent container - * @return string HTML string with select box for thirdparty. + * @param string $selected Preselected type + * @param string $htmlname Name of field in form + * @param string $filter optional filters criteras (example: 's.rowid <> x', 's.client IN (1,3)') + * @param string $showempty Add an empty field (Can be '1' or text key to use on empty line like 'SelectThirdParty') + * @param int $showtype Show third party type in combolist (customer, prospect or supplier) + * @param int $forcecombo Force to use combo box + * @param array $events Ajax event options to run on change. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled'))) + * @param int $limit Maximum number of elements + * @param string $morecss Add more css styles to the SELECT component + * @param string $moreparam Add more parameters onto the select tag. For example 'style="width: 95%"' to avoid select2 component to go over parent container + * @param string $selected_input_value Value of preselected input text (for use with ajax) + * @param int $hidelabel Hide label (0=no, 1=yes, 2=show search icon (before) and placeholder, 3 search icon after) + * @param array $ajaxoptions Options for ajax_autocompleter + * @return string HTML string with select box for thirdparty. */ - function select_company($selected='', $htmlname='socid', $filter='', $showempty='', $showtype=0, $forcecombo=0, $events=array(), $limit=0, $morecss='minwidth100', $moreparam='') + function select_company($selected='', $htmlname='socid', $filter='', $showempty='', $showtype=0, $forcecombo=0, $events=array(), $limit=0, $morecss='minwidth100', $moreparam='', $selected_input_value='', $hidelabel=1, $ajaxoptions=array()) { + global $conf,$user,$langs; + $out=''; - /* TODO Use ajax_autocompleter like for products (not finished) if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->COMPANY_USE_SEARCH_TO_SELECT) && ! $forcecombo) { $placeholder=''; - if ($selected && empty($selected_input_value)) { - require_once DOL_DOCUMENT_ROOT.'/societe/ajaxcompanies.php'; - $societe = new Societe($this->db); - $societe->fetch($selected); - $selected_input_value=$societe->ref; + require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; + $societetmp = new Societe($this->db); + $societetmp->fetch($selected); + $selected_input_value=$societetmp->name; + unset($societetmp); } - // mode=1 means customers products - $urloption='htmlname='.$htmlname.'&outjson=1&price_level='.$price_level.'&type='.$filtertype.'&mode=1&status='.$status.'&finished='.$finished; + // mode 1 + $urloption='htmlname='.$htmlname.'&outjson=1&filter='.$filter; print ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/societe/ajax/company.php', $urloption, $conf->global->COMPANY_USE_SEARCH_TO_SELECT, 0, $ajaxoptions); if (empty($hidelabel)) print $langs->trans("RefOrLabel").' : '; else if ($hidelabel > 1) { @@ -970,15 +974,15 @@ class Form print img_picto($langs->trans("Search"), 'search'); } } - print ''; + print 'global->THIRDPARTY_SEARCH_AUTOFOCUS) ? 'autofocus' : '').' />'; if ($hidelabel == 3) { print img_picto($langs->trans("Search"), 'search'); } } else - {*/ + { $out.=$this->select_thirdparty_list($selected, $htmlname, $filter, $showempty, $showtype, $forcecombo, $events, '', 0, $limit, $morecss, $moreparam); - //} + } return $out; } @@ -1004,7 +1008,8 @@ class Form { global $conf,$user,$langs; - $out=''; $num=0; + $out=''; + $num=0; $outarray=array(); // On recherche les societes @@ -1020,19 +1025,18 @@ class Form if ($filterkey && $filterkey != '') { $sql.=" AND ("; - if (! empty($conf->global->COMPANY_DONOTSEARCH_ANYWHERE)) // Can use index - { - $sql.="(s.name LIKE '".$this->db->escape($filterkey)."%')"; + $prefix=empty($conf->global->COMPANY_DONOTSEARCH_ANYWHERE)?'%':''; // Can use index if COMPANY_DONOTSEARCH_ANYWHERE is on + // For natural search + $scrit = explode(' ', $filterkey); + $i=0; + if (count($scrit) > 1) $sql.="("; + foreach ($scrit as $crit) { + if ($i > 0) $sql.=" AND "; + $sql.="(s.nom LIKE '".$this->db->escape($prefix.$crit)."%')"; + $i++; } - else - { - // For natural search - $scrit = explode(' ', $filterkey); - foreach ($scrit as $crit) { - $sql.=" AND (s.name LIKE '%".$this->db->escape($crit)."%')"; - } - } - if (! empty($conf->barcode->enabled)) + if (count($scrit) > 1) $sql.=")"; + if (! empty($conf->barcode->enabled)) { $sql .= " OR s.barcode LIKE '".$this->db->escape($filterkey)."%'"; } @@ -1041,20 +1045,22 @@ class Form $sql.=$this->db->order("nom","ASC"); if ($limit > 0) $sql.=$this->db->plimit($limit); + // Build output string dol_syslog(get_class($this)."::select_thirdparty_list", LOG_DEBUG); $resql=$this->db->query($sql); if ($resql) { + $events = null; + if ($conf->use_javascript_ajax && ! $forcecombo) { include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; $comboenhancement =ajax_combobox($htmlname, $events, $conf->global->COMPANY_USE_SEARCH_TO_SELECT); $out.= $comboenhancement; - $nodatarole=($comboenhancement?' data-role="none"':''); } // Construct $out and $outarray - $out.= ''."\n"; $textifempty=''; // Do not use textifempty = ' ' or ' ' here, or search on key will search on ' key'. @@ -1066,7 +1072,7 @@ class Form } if ($showempty) $out.= ''."\n"; - $num = $this->db->num_rows($resql); + $num = $this->db->num_rows($resql); $i = 0; if ($num) { @@ -1109,7 +1115,7 @@ class Form $out.= ''; } - array_push($outarray, array('key'=>$obj->rowid, 'value'=>$obj->rowid, 'label'=>$label)); + array_push($outarray, array('key'=>$obj->rowid, 'value'=>$label, 'label'=>$label)); $i++; if (($i % 10) == 0) $out.="\n"; diff --git a/htdocs/core/lib/agenda.lib.php b/htdocs/core/lib/agenda.lib.php index 09f89ba0c3f..b16792a0235 100644 --- a/htdocs/core/lib/agenda.lib.php +++ b/htdocs/core/lib/agenda.lib.php @@ -118,7 +118,7 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh print ''; } diff --git a/htdocs/societe/ajax/company.php b/htdocs/societe/ajax/company.php index d2a244f9444..32f57f73c25 100644 --- a/htdocs/societe/ajax/company.php +++ b/htdocs/societe/ajax/company.php @@ -18,8 +18,8 @@ */ /** - * \file htdocs/product/ajax/company.php - * \brief File to return Ajax response on product list request + * \file htdocs/societe/ajax/company.php + * \brief File to return Ajax response on thirdparty list request */ if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); // Disables token renewal @@ -33,15 +33,11 @@ if (empty($_GET['keysearch']) && ! defined('NOREQUIREHTML')) define('NOREQUIREH require '../../main.inc.php'; $htmlname=GETPOST('htmlname','alpha'); -$socid=GETPOST('socid','int'); -$type=GETPOST('type','int'); -$mode=GETPOST('mode','int'); -$status=((GETPOST('status','int') >= 0) ? GETPOST('status','int') : -1); +$filter=GETPOST('filter','alpha'); $outjson=(GETPOST('outjson','int') ? GETPOST('outjson','int') : 0); -$price_level=GETPOST('price_level','int'); $action=GETPOST('action', 'alpha'); $id=GETPOST('id', 'int'); -$price_by_qty_rowid=GETPOST('pbq', 'int'); + /* * View @@ -49,7 +45,7 @@ $price_by_qty_rowid=GETPOST('pbq', 'int'); //print ''."\n"; -dol_syslog(join(',',$_GET)); +dol_syslog(join(',', $_GET)); //print_r($_GET); if (! empty($action) && $action == 'fetch' && ! empty($id)) @@ -63,8 +59,11 @@ if (! empty($action) && $action == 'fetch' && ! empty($id)) if ($ret > 0) { $outname=$object->name; - - $outjson = array('name'=>$outname); + $outlabel = ''; + $outdesc = ''; + $outtype = $object->type; + + $outjson = array('ref' => $outref,'name' => $outname,'desc' => $outdesc,'type' => $outtype); } echo json_encode($outjson); @@ -73,7 +72,7 @@ else { require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; - $langs->load("products"); + $langs->load("companies"); $langs->load("main"); top_httphead(); @@ -90,14 +89,7 @@ else $searchkey=(GETPOST($id)?GETPOST($id):(GETPOST($htmlname)?GETPOST($htmlname):'')); $form = new Form($db); - if (empty($mode) || $mode == 'customer') - { - $arrayresult=$form->select_company_html($socid,$htmlname,"client IN (1,3)",0,0,0,null,$searchkey,$outjson); - } - elseif ($mode == 'supplier') - { - $arrayresult=$form->select_company_html($socid,$htmlname,"fournisseur=1",0,0,0,null,$searchkey,$outjson); - } + $arrayresult=$form->select_thirdparty_list(0,$htmlname,$filter,1,0,0,null,$searchkey,$outjson); $db->close();
' . $langs->trans("Description") . '' . $langs->trans("Product") . '' . $langs->trans("batch_number") . '' . $langs->trans("EatByDate") . '' . dol_trunc($objp->comment) . '' . $objp->comment . '
' . $langs->trans('PaymentConditionsShort') . ''; - $form->select_conditions_paiements(GETPOST('cond_reglement_id') > 0 ? GETPOST('cond_reglement_id') : $soc->cond_reglement_id, 'cond_reglement_id', -1, 1); + $form->select_conditions_paiements(GETPOST('cond_reglement_id') > 0 ? GETPOST('cond_reglement_id') : $cond_reglement_id, 'cond_reglement_id', -1, 1); print '
' . $langs->trans('PaymentMode') . ''; - $form->select_types_paiements(GETPOST('mode_reglement_id') > 0 ? GETPOST('mode_reglement_id') : $soc->mode_reglement_id, 'mode_reglement_id'); + $form->select_types_paiements(GETPOST('mode_reglement_id') > 0 ? GETPOST('mode_reglement_id') : $mode_reglement_id, 'mode_reglement_id'); print '
'.$langs->trans("LoanCapital").'
'.$langs->trans("LoanCapital").'
'.$langs->trans("Nbterms").'
'.$langs->trans("Nbterms").'
'.$langs->trans("Rate").' %
'.$langs->trans("Rate").' %
'; print $langs->trans("ThirdParty").'   '; print ''; - print $form->select_company($socid, 'socid', '', 1); + print $form->select_company($socid, 'socid', '', 'SelectThirdParty', 0, 0, null, 0); print '