From 45bef65fc9ea75786b1dd371c408883348aae42f Mon Sep 17 00:00:00 2001 From: atm-greg Date: Tue, 25 Sep 2018 14:47:13 +0200 Subject: [PATCH 01/46] add hook on commongeneratedocument --- htdocs/core/class/commonobject.class.php | 462 ++++++++++++----------- 1 file changed, 234 insertions(+), 228 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index b99c2f8ccd8..7e18e208173 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4057,236 +4057,242 @@ abstract class CommonObject */ protected function commonGenerateDocument($modelspath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams=null) { - global $conf, $langs, $user; - + global $conf, $langs, $user, $hookmanager; + $srctemplatepath=''; - - // Increase limit for PDF build - $err=error_reporting(); - error_reporting(0); - @set_time_limit(120); - error_reporting($err); - - // If selected model is a filename template (then $modele="modelname" or "modelname:filename") - $tmp=explode(':',$modele,2); - if (! empty($tmp[1])) + + $parameters = array('modelspath'=>$modelspath,'modele'=>$modele,'outputlangs'=>$outputlangs,'hidedetails'=>$hidedetails,'hidedesc'=>$hidedesc,'hideref'=>$hideref, 'moreparams'=>$moreparams); + $reshook = $hookmanager->executeHooks('commonGenerateDocument', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + + if(empty($reshook)) { - $modele=$tmp[0]; - $srctemplatepath=$tmp[1]; - } - - // Search template files - $file=''; $classname=''; $filefound=0; - $dirmodels=array('/'); - if (is_array($conf->modules_parts['models'])) $dirmodels=array_merge($dirmodels,$conf->modules_parts['models']); - foreach($dirmodels as $reldir) - { - foreach(array('doc','pdf') as $prefix) - { - if (in_array(get_class($this), array('Adherent'))) $file = $prefix."_".$modele.".class.php"; // Member module use prefix_module.class.php - else $file = $prefix."_".$modele.".modules.php"; - - // On verifie l'emplacement du modele - $file=dol_buildpath($reldir.$modelspath.$file,0); - if (file_exists($file)) - { - $filefound=1; - $classname=$prefix.'_'.$modele; - break; - } - } - if ($filefound) break; - } - - // If generator was found - if ($filefound) - { - global $db; // Required to solve a conception default in commonstickergenerator.class.php making an include of code using $db - - require_once $file; - - $obj = new $classname($this->db); - - // If generator is ODT, we must have srctemplatepath defined, if not we set it. - if ($obj->type == 'odt' && empty($srctemplatepath)) - { - $varfortemplatedir=$obj->scandir; - if ($varfortemplatedir && ! empty($conf->global->$varfortemplatedir)) - { - $dirtoscan=$conf->global->$varfortemplatedir; - - $listoffiles=array(); - - // Now we add first model found in directories scanned - $listofdir=explode(',',$dirtoscan); - foreach($listofdir as $key => $tmpdir) - { - $tmpdir=trim($tmpdir); - $tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir); - if (! $tmpdir) { unset($listofdir[$key]); continue; } - if (is_dir($tmpdir)) - { - $tmpfiles=dol_dir_list($tmpdir,'files',0,'\.od(s|t)$','','name',SORT_ASC,0); - if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles); - } - } - - if (count($listoffiles)) - { - foreach($listoffiles as $record) - { - $srctemplatepath=$record['fullname']; - break; - } - } - } - - if (empty($srctemplatepath)) - { - $this->error='ErrorGenerationAskedForOdtTemplateWithSrcFileNotDefined'; - return -1; - } - } - - if ($obj->type == 'odt' && ! empty($srctemplatepath)) - { - if (! dol_is_file($srctemplatepath)) - { - $this->error='ErrorGenerationAskedForOdtTemplateWithSrcFileNotFound'; - return -1; - } - } - - // We save charset_output to restore it because write_file can change it if needed for - // output format that does not support UTF8. - $sav_charset_output=$outputlangs->charset_output; - - if (in_array(get_class($this), array('Adherent'))) - { - $arrayofrecords = array(); // The write_file of templates of adherent class need this var - $resultwritefile = $obj->write_file($this, $outputlangs, $srctemplatepath, 'member', 1, $moreparams); - } - else - { - $resultwritefile = $obj->write_file($this, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref, $moreparams); - } - // After call of write_file $obj->result['fullpath'] is set with generated file. It will be used to update the ECM database index. - - if ($resultwritefile > 0) - { - $outputlangs->charset_output=$sav_charset_output; - - // We delete old preview - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - dol_delete_preview($this); - - // Index file in database - if (! empty($obj->result['fullpath'])) - { - $destfull = $obj->result['fullpath']; - $upload_dir = dirname($destfull); - $destfile = basename($destfull); - $rel_dir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $upload_dir); - - if (! preg_match('/[\\/]temp[\\/]|[\\/]thumbs|\.meta$/', $rel_dir)) // If not a tmp dir - { - $filename = basename($destfile); - $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir); - $rel_dir = preg_replace('/^[\\/]/', '', $rel_dir); - - include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; - $ecmfile=new EcmFiles($this->db); - $result = $ecmfile->fetch(0, '', ($rel_dir?$rel_dir.'/':'').$filename); - - // Set the public "share" key - $setsharekey = false; - if ($this->element == 'propal') - { - $useonlinesignature = $conf->global->MAIN_FEATURES_LEVEL; // Replace this with 1 when feature to make online signature is ok - if ($useonlinesignature) $setsharekey=true; - if (! empty($conf->global->PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD)) $setsharekey=true; - } - if ($this->element == 'commande' && ! empty($conf->global->ORDER_ALLOW_EXTERNAL_DOWNLOAD)) $setsharekey=true; - if ($this->element == 'facture' && ! empty($conf->global->INVOICE_ALLOW_EXTERNAL_DOWNLOAD)) $setsharekey=true; - if ($setsharekey) - { - if (empty($ecmfile->share)) // Because object not found or share not set yet - { - require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; - $ecmfile->share = getRandomPassword(true); - } - } - - if ($result > 0) - { - $ecmfile->label = md5_file(dol_osencode($destfull)); // hash of file content - $ecmfile->fullpath_orig = ''; - $ecmfile->gen_or_uploaded = 'generated'; - $ecmfile->description = ''; // indexed content - $ecmfile->keyword = ''; // keyword content - $result = $ecmfile->update($user); - if ($result < 0) - { - setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings'); - } - } - else - { - $ecmfile->entity = $conf->entity; - $ecmfile->filepath = $rel_dir; - $ecmfile->filename = $filename; - $ecmfile->label = md5_file(dol_osencode($destfull)); // hash of file content - $ecmfile->fullpath_orig = ''; - $ecmfile->gen_or_uploaded = 'generated'; - $ecmfile->description = ''; // indexed content - $ecmfile->keyword = ''; // keyword content - $result = $ecmfile->create($user); - if ($result < 0) - { - setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings'); - } - } - - /*$this->result['fullname']=$destfull; - $this->result['filepath']=$ecmfile->filepath; - $this->result['filename']=$ecmfile->filename;*/ - //var_dump($obj->update_main_doc_field);exit; - - // Update the last_main_doc field into main object (if documenent generator has property ->update_main_doc_field set) - $update_main_doc_field=0; - if (! empty($obj->update_main_doc_field)) $update_main_doc_field=1; - if ($update_main_doc_field && ! empty($this->table_element)) - { - $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element." SET last_main_doc = '".($ecmfile->filepath.'/'.$ecmfile->filename)."'"; - $sql.= ' WHERE rowid = '.$this->id; - $resql = $this->db->query($sql); - if (! $resql) dol_print_error($this->db); - } - } - } - else - { - dol_syslog('Method ->write_file was called on object '.get_class($obj).' and return a success but the return array ->result["fullpath"] was not set.', LOG_WARNING); - } - - // Success in building document. We build meta file. - dol_meta_create($this); - - return 1; - } - else - { - $outputlangs->charset_output=$sav_charset_output; - dol_print_error($this->db, "Error generating document for ".__CLASS__.". Error: ".$obj->error, $obj->errors); - return -1; - } - - } - else - { - $this->error=$langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists",$file); - dol_print_error('',$this->error); - return -1; + // Increase limit for PDF build + $err=error_reporting(); + error_reporting(0); + @set_time_limit(120); + error_reporting($err); + + // If selected model is a filename template (then $modele="modelname" or "modelname:filename") + $tmp=explode(':',$modele,2); + if (! empty($tmp[1])) + { + $modele=$tmp[0]; + $srctemplatepath=$tmp[1]; + } + + // Search template files + $file=''; $classname=''; $filefound=0; + $dirmodels=array('/'); + if (is_array($conf->modules_parts['models'])) $dirmodels=array_merge($dirmodels,$conf->modules_parts['models']); + foreach($dirmodels as $reldir) + { + foreach(array('doc','pdf') as $prefix) + { + if (in_array(get_class($this), array('Adherent'))) $file = $prefix."_".$modele.".class.php"; // Member module use prefix_module.class.php + else $file = $prefix."_".$modele.".modules.php"; + + // On verifie l'emplacement du modele + $file=dol_buildpath($reldir.$modelspath.$file,0); + if (file_exists($file)) + { + $filefound=1; + $classname=$prefix.'_'.$modele; + break; + } + } + if ($filefound) break; + } + + // If generator was found + if ($filefound) + { + global $db; // Required to solve a conception default in commonstickergenerator.class.php making an include of code using $db + + require_once $file; + + $obj = new $classname($this->db); + + // If generator is ODT, we must have srctemplatepath defined, if not we set it. + if ($obj->type == 'odt' && empty($srctemplatepath)) + { + $varfortemplatedir=$obj->scandir; + if ($varfortemplatedir && ! empty($conf->global->$varfortemplatedir)) + { + $dirtoscan=$conf->global->$varfortemplatedir; + + $listoffiles=array(); + + // Now we add first model found in directories scanned + $listofdir=explode(',',$dirtoscan); + foreach($listofdir as $key => $tmpdir) + { + $tmpdir=trim($tmpdir); + $tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir); + if (! $tmpdir) { unset($listofdir[$key]); continue; } + if (is_dir($tmpdir)) + { + $tmpfiles=dol_dir_list($tmpdir,'files',0,'\.od(s|t)$','','name',SORT_ASC,0); + if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles); + } + } + + if (count($listoffiles)) + { + foreach($listoffiles as $record) + { + $srctemplatepath=$record['fullname']; + break; + } + } + } + + if (empty($srctemplatepath)) + { + $this->error='ErrorGenerationAskedForOdtTemplateWithSrcFileNotDefined'; + return -1; + } + } + + if ($obj->type == 'odt' && ! empty($srctemplatepath)) + { + if (! dol_is_file($srctemplatepath)) + { + $this->error='ErrorGenerationAskedForOdtTemplateWithSrcFileNotFound'; + return -1; + } + } + + // We save charset_output to restore it because write_file can change it if needed for + // output format that does not support UTF8. + $sav_charset_output=$outputlangs->charset_output; + + if (in_array(get_class($this), array('Adherent'))) + { + $arrayofrecords = array(); // The write_file of templates of adherent class need this var + $resultwritefile = $obj->write_file($this, $outputlangs, $srctemplatepath, 'member', 1, $moreparams); + } + else + { + $resultwritefile = $obj->write_file($this, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref, $moreparams); + } + // After call of write_file $obj->result['fullpath'] is set with generated file. It will be used to update the ECM database index. + + if ($resultwritefile > 0) + { + $outputlangs->charset_output=$sav_charset_output; + + // We delete old preview + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + dol_delete_preview($this); + + // Index file in database + if (! empty($obj->result['fullpath'])) + { + $destfull = $obj->result['fullpath']; + $upload_dir = dirname($destfull); + $destfile = basename($destfull); + $rel_dir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $upload_dir); + + if (! preg_match('/[\\/]temp[\\/]|[\\/]thumbs|\.meta$/', $rel_dir)) // If not a tmp dir + { + $filename = basename($destfile); + $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir); + $rel_dir = preg_replace('/^[\\/]/', '', $rel_dir); + + include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; + $ecmfile=new EcmFiles($this->db); + $result = $ecmfile->fetch(0, '', ($rel_dir?$rel_dir.'/':'').$filename); + + // Set the public "share" key + $setsharekey = false; + if ($this->element == 'propal') + { + $useonlinesignature = $conf->global->MAIN_FEATURES_LEVEL; // Replace this with 1 when feature to make online signature is ok + if ($useonlinesignature) $setsharekey=true; + if (! empty($conf->global->PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD)) $setsharekey=true; + } + if ($this->element == 'commande' && ! empty($conf->global->ORDER_ALLOW_EXTERNAL_DOWNLOAD)) $setsharekey=true; + if ($this->element == 'facture' && ! empty($conf->global->INVOICE_ALLOW_EXTERNAL_DOWNLOAD)) $setsharekey=true; + if ($setsharekey) + { + if (empty($ecmfile->share)) // Because object not found or share not set yet + { + require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; + $ecmfile->share = getRandomPassword(true); + } + } + + if ($result > 0) + { + $ecmfile->label = md5_file(dol_osencode($destfull)); // hash of file content + $ecmfile->fullpath_orig = ''; + $ecmfile->gen_or_uploaded = 'generated'; + $ecmfile->description = ''; // indexed content + $ecmfile->keyword = ''; // keyword content + $result = $ecmfile->update($user); + if ($result < 0) + { + setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings'); + } + } + else + { + $ecmfile->entity = $conf->entity; + $ecmfile->filepath = $rel_dir; + $ecmfile->filename = $filename; + $ecmfile->label = md5_file(dol_osencode($destfull)); // hash of file content + $ecmfile->fullpath_orig = ''; + $ecmfile->gen_or_uploaded = 'generated'; + $ecmfile->description = ''; // indexed content + $ecmfile->keyword = ''; // keyword content + $result = $ecmfile->create($user); + if ($result < 0) + { + setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings'); + } + } + + /*$this->result['fullname']=$destfull; + $this->result['filepath']=$ecmfile->filepath; + $this->result['filename']=$ecmfile->filename;*/ + //var_dump($obj->update_main_doc_field);exit; + + // Update the last_main_doc field into main object (if documenent generator has property ->update_main_doc_field set) + $update_main_doc_field=0; + if (! empty($obj->update_main_doc_field)) $update_main_doc_field=1; + if ($update_main_doc_field && ! empty($this->table_element)) + { + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element." SET last_main_doc = '".($ecmfile->filepath.'/'.$ecmfile->filename)."'"; + $sql.= ' WHERE rowid = '.$this->id; + $resql = $this->db->query($sql); + if (! $resql) dol_print_error($this->db); + } + } + } + else + { + dol_syslog('Method ->write_file was called on object '.get_class($obj).' and return a success but the return array ->result["fullpath"] was not set.', LOG_WARNING); + } + + // Success in building document. We build meta file. + dol_meta_create($this); + + return 1; + } + else + { + $outputlangs->charset_output=$sav_charset_output; + dol_print_error($this->db, "Error generating document for ".__CLASS__.". Error: ".$obj->error, $obj->errors); + return -1; + } + + } + else + { + $this->error=$langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists",$file); + dol_print_error('',$this->error); + return -1; + } } } From 4e4a6294f698f7497aa88f6b6eba6ceb378be0d5 Mon Sep 17 00:00:00 2001 From: atm-greg Date: Tue, 25 Sep 2018 15:18:10 +0200 Subject: [PATCH 02/46] missing return --- htdocs/core/class/commonobject.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 7e18e208173..a5c92d07d86 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4294,6 +4294,7 @@ abstract class CommonObject return -1; } } + else return $reshook; } /** From 9f890c28ddbb052551bb78e14bd56ffcec23e57b Mon Sep 17 00:00:00 2001 From: atm-greg Date: Mon, 29 Oct 2018 15:37:17 +0100 Subject: [PATCH 03/46] add ability to edit price ht before adding a line --- htdocs/core/tpl/objectline_create.tpl.php | 18 ++++++++++++++++-- htdocs/langs/en_US/admin.lang | 1 + htdocs/product/admin/product.php | 11 +++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index 23640216cd9..5430eb0ad46 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -646,8 +646,19 @@ jQuery(document).ready(function() { setforpredef(); // TODO Keep vat combo visible and set it to first entry into list that match result of get_default_tva jQuery('#trlinefordates').show(); - + global->EDIT_PREDEF_PRICEHT)) + { + ?> + // get the HT price for the product and display it + $.post('/product/ajax/products.php?action=fetch', { 'id': $(this).val(), 'socid' : socid; ?> }, function(data) { + jQuery("#price_ht").val(data.price_ht); + }, + 'json'); + rights->margins->creer) { $langs->load('stocks'); @@ -831,7 +842,10 @@ function setforpredef() { jQuery("#prod_entry_mode_free").prop('checked',false).change(); jQuery("#prod_entry_mode_predef").prop('checked',true).change(); - jQuery("#price_ht").val('').hide(); + global->EDIT_PREDEF_PRICEHT)) + {?> + jQuery("#price_ht").val('').hide(); + jQuery("#multicurrency_price_ht").hide(); jQuery("#price_ttc").hide(); // May no exists jQuery("#fourn_ref").hide(); diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 190b7cded97..ba6989d6288 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1447,6 +1447,7 @@ ServiceSetup=Services module setup ProductServiceSetup=Products and Services modules setup NumberOfProductShowInSelect=Max number of products in combos select lists (0=no limit) ViewProductDescInFormAbility=Display product descriptions in forms (otherwise as popup tooltip) +EditPredifinedPriceHTAbility=Add the ability to edit price ht before adding a line on documents MergePropalProductCard=Activate in product/service Attached Files tab an option to merge product PDF document to proposal PDF azur if product/service is in the proposal ViewProductDescInThirdpartyLanguageAbility=Display products descriptions in the language of the third party UseSearchToSelectProductTooltip=Also if you have a large number of products (> 100 000), you can increase speed by setting constant PRODUCT_DONOTSEARCH_ANYWHERE to 1 in Setup->Other. Search will then be limited to start of string. diff --git a/htdocs/product/admin/product.php b/htdocs/product/admin/product.php index 45f938431c3..a8116314dda 100644 --- a/htdocs/product/admin/product.php +++ b/htdocs/product/admin/product.php @@ -155,6 +155,9 @@ if ($action == 'other') $resql_new = $db->query($sql_new); } } + + $value = GETPOST('activate_EditPredifinedPriceHT','alpha'); + $res = dolibarr_set_const($db, "EDIT_PREDEF_PRICEHT", $value,'chaine',0,'',$conf->entity); } if ($action == 'specimen') // For products @@ -675,6 +678,14 @@ if (! empty($conf->fournisseur->enabled)) print ''; } +// Activate price ht edition for predefined product on line add +print ''; +print ''.$langs->trans("EditPredifinedPriceHTAbility").''; +print ''; +print $form->selectyesno("activate_EditPredifinedPriceHT",$conf->global->EDIT_PREDEF_PRICEHT,1); +print ''; +print ''; + if (! empty($conf->global->PRODUCT_CANVAS_ABILITY)) { // Add canvas feature From 3bd1563052243ccd7552fe4ff6876366913abf1e Mon Sep 17 00:00:00 2001 From: atm-greg Date: Mon, 29 Oct 2018 16:46:06 +0100 Subject: [PATCH 04/46] fix travis white_space error --- htdocs/core/tpl/objectline_create.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index 5430eb0ad46..458872cf99b 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -646,7 +646,7 @@ jQuery(document).ready(function() { setforpredef(); // TODO Keep vat combo visible and set it to first entry into list that match result of get_default_tva jQuery('#trlinefordates').show(); - global->EDIT_PREDEF_PRICEHT)) { ?> From b06bfef6320286b1c4294f13d0ce054698c25209 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sun, 11 Aug 2019 13:08:17 +0200 Subject: [PATCH 05/46] NEW display supplier in objectline if defined --- htdocs/core/tpl/objectline_view.tpl.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index d048b6f7c9d..988df55b61c 100644 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -163,6 +163,23 @@ $domData .= ' data-product_type="'.$line->product_type.'"'; print (! empty($line->description) && $line->description!=$line->product_label)?'
'.dol_htmlentitiesbr($line->description):''; } } + + if ($user->rights->fournisseur->lire && $line->fk_fournprice > 0) + { + require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; + $productfourn = new ProductFournisseur($this->db); + $productfourn->fetch_product_fournisseur_price($line->fk_fournprice); + echo '
' . $langs->trans('Supplier') . ' : ' . $productfourn->getSocNomUrl(1, 'supplier') . ' - ' . $langs->trans('Ref') . ' : '; + // Supplier ref + if ($user->rights->produit->creer || $user->rights->service->creer) // change required right here + { + echo $productfourn->getNomUrl(); + } + else + { + echo $productfourn->ref_supplier; + } + } if (! empty($conf->accounting->enabled) && $line->fk_accounting_account > 0) { From 8c8844d7aea57188c88320a5a170e8f763d9d9b8 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Fri, 30 Aug 2019 09:33:01 +0200 Subject: [PATCH 06/46] Differentiate supplier orders status --- htdocs/core/menus/standard/eldy.lib.php | 18 ++++----- .../class/fournisseur.commande.class.php | 40 +++++++++---------- htdocs/langs/en_US/orders.lang | 30 ++++++++++++++ htdocs/langs/fr_FR/orders.lang | 30 ++++++++++++++ 4 files changed, 89 insertions(+), 29 deletions(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index e2e977b1321..c6b5eb46515 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -915,16 +915,16 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers", $langs->trans("List"), 1, $user->rights->fournisseur->commande->lire); if ($usemenuhider || empty($leftmenu) || $leftmenu=="orders_suppliers") { - $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=0", $langs->trans("StatusOrderDraftShort"), 2, $user->rights->fournisseur->commande->lire); - if (empty($conf->global->SUPPLIER_ORDER_HIDE_VALIDATED)) $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=1", $langs->trans("StatusOrderValidated"), 2, $user->rights->fournisseur->commande->lire); - $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=2", $langs->trans("StatusOrderApprovedShort"), 2, $user->rights->fournisseur->commande->lire); - $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=3", $langs->trans("StatusOrderOnProcessShort"), 2, $user->rights->fournisseur->commande->lire); - $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=4", $langs->trans("StatusOrderReceivedPartiallyShort"), 2, $user->rights->fournisseur->commande->lire); - $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=5", $langs->trans("StatusOrderReceivedAll"), 2, $user->rights->fournisseur->commande->lire); - $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=6,7", $langs->trans("StatusOrderCanceled"), 2, $user->rights->fournisseur->commande->lire); - $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=9", $langs->trans("StatusOrderRefused"), 2, $user->rights->fournisseur->commande->lire); + $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=0", $langs->trans("StatusSupplierOrderDraftShort"), 2, $user->rights->fournisseur->commande->lire); + if (empty($conf->global->SUPPLIER_ORDER_HIDE_VALIDATED)) $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=1", $langs->trans("StatusSupplierOrderValidated"), 2, $user->rights->fournisseur->commande->lire); + $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=2", $langs->trans("StatusSupplierOrderApprovedShort"), 2, $user->rights->fournisseur->commande->lire); + $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=3", $langs->trans("StatusSupplierOrderOnProcessShort"), 2, $user->rights->fournisseur->commande->lire); + $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=4", $langs->trans("StatusSupplierOrderReceivedPartiallyShort"), 2, $user->rights->fournisseur->commande->lire); + $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=5", $langs->trans("StatusSupplierOrderReceivedAll"), 2, $user->rights->fournisseur->commande->lire); + $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=6,7", $langs->trans("StatusSupplierOrderCanceled"), 2, $user->rights->fournisseur->commande->lire); + $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=9", $langs->trans("StatusSupplierOrderRefused"), 2, $user->rights->fournisseur->commande->lire); } - // Billed is another field. We should add instead a dedicated filter on list. if ($usemenuhider || empty($leftmenu) || $leftmenu=="orders_suppliers") $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&billed=1", $langs->trans("StatusOrderBilled"), 2, $user->rights->fournisseur->commande->lire); + // Billed is another field. We should add instead a dedicated filter on list. if ($usemenuhider || empty($leftmenu) || $leftmenu=="orders_suppliers") $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&billed=1", $langs->trans("StatusSupplierOrderBilled"), 2, $user->rights->fournisseur->commande->lire); $newmenu->add("/commande/stats/index.php?leftmenu=orders_suppliers&mode=supplier", $langs->trans("Statistics"), 1, $user->rights->fournisseur->commande->lire); diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 2edd86d1c10..05f64621b01 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -639,28 +639,28 @@ class CommandeFournisseur extends CommonOrder { $langs->load('orders'); - $this->statuts[0] = 'StatusOrderDraft'; - $this->statuts[1] = 'StatusOrderValidated'; - $this->statuts[2] = 'StatusOrderApproved'; - if (empty($conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS)) $this->statuts[3] = 'StatusOrderOnProcess'; - else $this->statuts[3] = 'StatusOrderOnProcessWithValidation'; - $this->statuts[4] = 'StatusOrderReceivedPartially'; - $this->statuts[5] = 'StatusOrderReceivedAll'; - $this->statuts[6] = 'StatusOrderCanceled'; // Approved->Canceled - $this->statuts[7] = 'StatusOrderCanceled'; // Process running->canceled - //$this->statuts[8] = 'StatusOrderBilled'; // Everything is finished, order received totally and bill received - $this->statuts[9] = 'StatusOrderRefused'; + $this->statuts[0] = 'StatusSupplierOrderDraft'; + $this->statuts[1] = 'StatusSupplierOrderValidated'; + $this->statuts[2] = 'StatusSupplierOrderApproved'; + if (empty($conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS)) $this->statuts[3] = 'StatusSupplierOrderOnProcess'; + else $this->statuts[3] = 'StatusSupplierOrderOnProcessWithValidation'; + $this->statuts[4] = 'StatusSupplierOrderReceivedPartially'; + $this->statuts[5] = 'StatusSupplierOrderReceivedAll'; + $this->statuts[6] = 'StatusSupplierOrderCanceled'; // Approved->Canceled + $this->statuts[7] = 'StatusSupplierOrderCanceled'; // Process running->canceled + //$this->statuts[8] = 'StatusSupplierOrderBilled'; // Everything is finished, order received totally and bill received + $this->statuts[9] = 'StatusSupplierOrderRefused'; // List of language codes for status - $this->statutshort[0] = 'StatusOrderDraftShort'; - $this->statutshort[1] = 'StatusOrderValidatedShort'; - $this->statutshort[2] = 'StatusOrderApprovedShort'; - $this->statutshort[3] = 'StatusOrderOnProcessShort'; - $this->statutshort[4] = 'StatusOrderReceivedPartiallyShort'; - $this->statutshort[5] = 'StatusOrderReceivedAllShort'; - $this->statutshort[6] = 'StatusOrderCanceledShort'; - $this->statutshort[7] = 'StatusOrderCanceledShort'; - $this->statutshort[9] = 'StatusOrderRefusedShort'; + $this->statutshort[0] = 'StatusSupplierOrderDraftShort'; + $this->statutshort[1] = 'StatusSupplierOrderValidatedShort'; + $this->statutshort[2] = 'StatusSupplierOrderApprovedShort'; + $this->statutshort[3] = 'StatusSupplierOrderOnProcessShort'; + $this->statutshort[4] = 'StatusSupplierOrderReceivedPartiallyShort'; + $this->statutshort[5] = 'StatusSupplierOrderReceivedAllShort'; + $this->statutshort[6] = 'StatusSupplierOrderCanceledShort'; + $this->statutshort[7] = 'StatusSupplierOrderCanceledShort'; + $this->statutshort[9] = 'StatusSupplierOrderRefusedShort'; } $billedtext=''; diff --git a/htdocs/langs/en_US/orders.lang b/htdocs/langs/en_US/orders.lang index ad895845488..9d61216ac47 100644 --- a/htdocs/langs/en_US/orders.lang +++ b/htdocs/langs/en_US/orders.lang @@ -156,3 +156,33 @@ OptionToSetOrderBilledNotEnabled=Option (from module Workflow) to set order to ' IfValidateInvoiceIsNoOrderStayUnbilled=If invoice validation is 'No', the order will remain to status 'Unbilled' until the invoice is validated. CloseReceivedSupplierOrdersAutomatically=Close order to "%s" automatically if all products are received. SetShippingMode=Set shipping mode + +#### supplier orders status +StatusSupplierOrderCanceledShort=Canceled +StatusSupplierOrderDraftShort=Draft +StatusSupplierOrderValidatedShort=Validated +StatusSupplierOrderSentShort=In process +StatusSupplierOrderSent=Shipment in process +StatusSupplierOrderOnProcessShort=Ordered +StatusSupplierOrderProcessedShort=Processed +StatusSupplierOrderDelivered=Delivered +StatusSupplierOrderDeliveredShort=Delivered +StatusSupplierOrderToBillShort=Delivered +StatusSupplierOrderApprovedShort=Approved +StatusSupplierOrderRefusedShort=Refused +StatusSupplierOrderBilledShort=Billed +StatusSupplierOrderToProcessShort=To process +StatusSupplierOrderReceivedPartiallyShort=Partially received +StatusSupplierOrderReceivedAllShort=Products received +StatusSupplierOrderCanceled=Canceled +StatusSupplierOrderDraft=Draft (needs to be validated) +StatusSupplierOrderValidated=Validated +StatusSupplierOrderOnProcess=Ordered - Standby reception +StatusSupplierOrderOnProcessWithValidation=Ordered - Standby reception or validation +StatusSupplierOrderProcessed=Processed +StatusSupplierOrderToBill=Delivered +StatusSupplierOrderApproved=Approved +StatusSupplierOrderRefused=Refused +StatusSupplierOrderBilled=Billed +StatusSupplierOrderReceivedPartially=Partially received +StatusSupplierOrderReceivedAll=All products received \ No newline at end of file diff --git a/htdocs/langs/fr_FR/orders.lang b/htdocs/langs/fr_FR/orders.lang index a4a8827ca05..957fd02803d 100644 --- a/htdocs/langs/fr_FR/orders.lang +++ b/htdocs/langs/fr_FR/orders.lang @@ -156,3 +156,33 @@ OptionToSetOrderBilledNotEnabled=L'option (issue du module Workflow) pour défin IfValidateInvoiceIsNoOrderStayUnbilled=Si la validation de facture est à "Non", la commande restera au statut "Non facturé" jusqu'à ce que la facture soit validée. CloseReceivedSupplierOrdersAutomatically=Fermer la commande "%s" automatiquement si tous les produits ont été reçus. SetShippingMode=Définir la méthode d'expédition + +###### statuts commandes fournisseurs +StatusSupplierOrderCanceledShort=Annulée +StatusSupplierOrderDraftShort=Brouillon +StatusSupplierOrderValidatedShort=Validée +StatusSupplierOrderSentShort=En cours +StatusSupplierOrderSent=Envoi en cours +StatusSupplierOrderOnProcessShort=Commandé +StatusSupplierOrderProcessedShort=Traitée +StatusSupplierOrderDelivered=Livrée +StatusSupplierOrderDeliveredShort=Livrée +StatusSupplierOrderToBillShort=Livré +StatusSupplierOrderApprovedShort=Approuvée +StatusSupplierOrderRefusedShort=Refusée +StatusSupplierOrderBilledShort=Facturée +StatusSupplierOrderToProcessShort=À traiter +StatusSupplierOrderReceivedPartiallyShort=Reçue partiellement +StatusSupplierOrderReceivedAllShort=Produits reçus +StatusSupplierOrderCanceled=Annulée +StatusSupplierOrderDraft=Brouillon (à valider) +StatusSupplierOrderValidated=Validée +StatusSupplierOrderOnProcess=Commandé - en attente de réception +StatusSupplierOrderOnProcessWithValidation=Commandé - en attente de réception ou validation +StatusSupplierOrderProcessed=Traitée +StatusSupplierOrderToBill=Livrée +StatusSupplierOrderApproved=Approuvée +StatusSupplierOrderRefused=Refusée +StatusSupplierOrderBilled=Facturée +StatusSupplierOrderReceivedPartially=Reçue partiellement +StatusSupplierOrderReceivedAll=Tous les produits reçus From ecaa2df0b8598efdc2c4034749cdf700237803c5 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 5 Sep 2019 10:37:09 +0200 Subject: [PATCH 07/46] FIX change "rowid" type in llx_accounting_account (bigint instead int) --- htdocs/install/mysql/migration/10.0.0-11.0.0.sql | 2 +- htdocs/install/mysql/tables/llx_accounting_account.sql | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql index 8efe44db103..e19ccc1c73b 100644 --- a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql +++ b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql @@ -89,5 +89,5 @@ ALTER TABLE llx_projet ADD COLUMN usage_organize_event integer DEFAULT 0; UPDATE llx_projet set usage_opportunity = 1 WHERE fk_opp_status > 0; - +ALTER TABLE llx_accounting_account MODIFY COLUMN rowid bigint AUTO_INCREMENT; \ No newline at end of file diff --git a/htdocs/install/mysql/tables/llx_accounting_account.sql b/htdocs/install/mysql/tables/llx_accounting_account.sql index 727965f6a9d..fd1962b6c09 100644 --- a/htdocs/install/mysql/tables/llx_accounting_account.sql +++ b/htdocs/install/mysql/tables/llx_accounting_account.sql @@ -21,7 +21,7 @@ create table llx_accounting_account ( - rowid integer AUTO_INCREMENT PRIMARY KEY, + rowid bigint AUTO_INCREMENT PRIMARY KEY, entity integer DEFAULT 1 NOT NULL, datec datetime, tms timestamp, From e91b6f7843dfde2f0d66c4bcac89e6de5496fd0a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 5 Sep 2019 22:48:33 +0200 Subject: [PATCH 08/46] FIX Can't delete a draft leave even if it should --- htdocs/holiday/card.php | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index 2207148e4ea..7301d08f87b 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -55,13 +55,6 @@ $langs->load("holiday"); $childids = $user->getAllChildIds(1); -$cancreate = 0; -if (! empty($user->rights->holiday->write_all)) $cancreate=1; -if (! empty($user->rights->holiday->write) && in_array($fuserid, $childids)) $cancreate=1; - -$candelete = 0; -if (! empty($user->rights->holiday->delete)) $candelete=1; - $morefilter = 'AND employee = 1'; if (! empty($conf->global->HOLIDAY_FOR_NON_SALARIES_TOO)) $morefilter = ''; @@ -82,6 +75,14 @@ if ($id > 0) } } +$cancreate = 0; +if (! empty($user->rights->holiday->write_all)) $cancreate=1; +if (! empty($user->rights->holiday->write) && in_array($fuserid, $childids)) $cancreate=1; + +$candelete = 0; +if (! empty($user->rights->holiday->delete)) $candelete=1; +if ($object->statut == Holiday::STATUS_DRAFT && $user->rights->holiday->create && in_array($object->fk_user, $childids)) $candelete=1; + /* * Actions @@ -1435,7 +1436,7 @@ else { print ''.$langs->trans("SetToDraft").''; } - if ($user->rights->holiday->delete && ($object->statut == Holiday::STATUS_DRAFT || $object->statut == Holiday::STATUS_CANCELED || $object->statut == Holiday::STATUS_REFUSED)) // If draft or canceled or refused + if ($candelete && ($object->statut == Holiday::STATUS_DRAFT || $object->statut == Holiday::STATUS_CANCELED || $object->statut == Holiday::STATUS_REFUSED)) // If draft or canceled or refused { print ''.$langs->trans("DeleteCP").''; } From 9a823f1c64c9cd619cc418772c7fb663f2287e60 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 5 Sep 2019 22:51:26 +0200 Subject: [PATCH 09/46] Fix bad perm --- htdocs/holiday/card.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index 7301d08f87b..204d832a94c 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -81,8 +81,7 @@ if (! empty($user->rights->holiday->write) && in_array($fuserid, $childids)) $ca $candelete = 0; if (! empty($user->rights->holiday->delete)) $candelete=1; -if ($object->statut == Holiday::STATUS_DRAFT && $user->rights->holiday->create && in_array($object->fk_user, $childids)) $candelete=1; - +if ($object->statut == Holiday::STATUS_DRAFT && $user->rights->holiday->write && in_array($object->fk_user, $childids)) $candelete=1; /* * Actions From 80daf29d790e60031d2b3ad02d85ba58504ca0dc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Sep 2019 01:52:51 +0200 Subject: [PATCH 10/46] Fix conflict between new module reception and old process Fix inventory record does not need status at creation Conflicts: htdocs/fourn/commande/card.php --- htdocs/admin/stock.php | 120 ++++++++---------- htdocs/admin/supplier_order.php | 34 +++-- .../class/fournisseur.commande.class.php | 3 +- htdocs/fourn/commande/card.php | 80 +++++++----- htdocs/langs/en_US/admin.lang | 2 +- htdocs/langs/en_US/orders.lang | 2 +- htdocs/langs/en_US/sendings.lang | 2 + htdocs/langs/en_US/stocks.lang | 4 +- htdocs/langs/fr_FR/orders.lang | 2 +- .../inventory/class/inventory.class.php | 4 +- htdocs/reception/card.php | 4 +- 11 files changed, 135 insertions(+), 122 deletions(-) diff --git a/htdocs/admin/stock.php b/htdocs/admin/stock.php index 2e934211970..83834aa5861 100644 --- a/htdocs/admin/stock.php +++ b/htdocs/admin/stock.php @@ -98,14 +98,14 @@ print '
'; print ''; print ''; print "\n"; -print ''."\n"; +print ''."\n"; print ''."\n"; $found=0; print ''; print ''; -print ''; print ''; -print ''; print ''; -print ''; print ''; -print ''; print ''; print ''; - if (! empty($conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS) || !empty($conf->reception->enabled)) + + // Status + if (! empty($conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS) && empty($reception->rowid)) { print ''; + } + elseif(!empty($conf->reception->enabled)) { + print ''; + } + + print ''; print "\n"; @@ -969,17 +977,15 @@ if ($id > 0 || ! empty($ref)) { } } print ''; - }elseif(!empty($conf->reception->enabled)){ + } elseif(!empty($conf->reception->enabled)) { print ''; } - print ''; - print ''; - + print ''; print "\n"; From 5b1d94a668d46b4ad54ce07007eec2cebb933c6e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Sep 2019 02:27:49 +0200 Subject: [PATCH 13/46] Fix translation --- .../core/modules/reception/doc/pdf_squille.modules.php | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/htdocs/core/modules/reception/doc/pdf_squille.modules.php b/htdocs/core/modules/reception/doc/pdf_squille.modules.php index 9acd517370a..ca167e10644 100644 --- a/htdocs/core/modules/reception/doc/pdf_squille.modules.php +++ b/htdocs/core/modules/reception/doc/pdf_squille.modules.php @@ -121,15 +121,7 @@ class pdf_squille extends ModelePdfReception // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; - $outputlangs->load("main"); - $outputlangs->load("dict"); - $outputlangs->load("companies"); - $outputlangs->load("bills"); - $outputlangs->load("products"); - $outputlangs->load("propal"); - $outputlangs->load("deliveries"); - $outputlangs->load("receptions"); - $outputlangs->load("productbatch"); + $outputlangs->loadLangs(array("main","dict","companies","bills","products","propal","deliveries","receptions","productbatch","sendings")); $nblignes = count($object->lines); From 626e3fd90e8cf244f123c9bd8dc77f211ea1dd27 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Sep 2019 02:34:24 +0200 Subject: [PATCH 14/46] Fix look and feel v10 --- htdocs/commande/tpl/linkedobjectblock.tpl.php | 4 +- .../reception/tpl/linkedobjectblock.tpl.php | 39 +++++++++++++------ 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/htdocs/commande/tpl/linkedobjectblock.tpl.php b/htdocs/commande/tpl/linkedobjectblock.tpl.php index 74a2243d633..c2fed2895a8 100644 --- a/htdocs/commande/tpl/linkedobjectblock.tpl.php +++ b/htdocs/commande/tpl/linkedobjectblock.tpl.php @@ -81,8 +81,8 @@ if (count($linkedObjectBlock) > 1) - - + + diff --git a/htdocs/reception/tpl/linkedobjectblock.tpl.php b/htdocs/reception/tpl/linkedobjectblock.tpl.php index 9601c661c70..2b66b76e9dd 100644 --- a/htdocs/reception/tpl/linkedobjectblock.tpl.php +++ b/htdocs/reception/tpl/linkedobjectblock.tpl.php @@ -1,6 +1,7 @@ - * Copyright (C) 2014 Marcos García +/* Copyright (C) 2012 Regis Houssin + * Copyright (C) 2014 Marcos García + * Copyright (C) 2019 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -15,6 +16,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; +} + ?> @@ -22,41 +31,47 @@ load("receptions"); +$linkedObjectBlock = dol_sort_array($linkedObjectBlock, 'date', 'desc', 0, 0, 1); + $total=0; $ilink=0; -$var=true; foreach($linkedObjectBlock as $key => $objectlink) { $ilink++; - $trclass=($var?'pair':'impair'); + $trclass='oddeven'; if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass.=' liste_sub_total'; ?> - - - - - + + + + - - + + ">transnoentitiesnoconv("RemoveLink"), 'unlink'); ?> + Date: Fri, 6 Sep 2019 02:39:08 +0200 Subject: [PATCH 15/46] Fix more consistent setup --- htdocs/admin/supplier_order.php | 20 +++++++++++++------- htdocs/langs/en_US/admin.lang | 1 + 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/htdocs/admin/supplier_order.php b/htdocs/admin/supplier_order.php index f1fbbd4b286..2fef63ffdd8 100644 --- a/htdocs/admin/supplier_order.php +++ b/htdocs/admin/supplier_order.php @@ -35,7 +35,7 @@ require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; // Load translation files required by the page -$langs->loadLangs(array("admin", "other", "orders")); +$langs->loadLangs(array("admin", "other", "orders", "stocks")); if (!$user->admin) accessforbidden(); @@ -561,16 +561,22 @@ print '' print "\n"; // Option to add a quality/validation step, on products, after reception. -$langs->load("stocks"); print ''; print ''; print ''; print '\n\n"; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 5f1d04f8bb0..bc9981faf3f 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1919,3 +1919,4 @@ DeleteEmailCollector=Delete email collector ConfirmDeleteEmailCollector=Are you sure you want to delete this email collector? RecipientEmailsWillBeReplacedWithThisValue=Recipient emails will be always replaced with this value AtLeastOneDefaultBankAccountMandatory=At least 1 default bank account must be defined +FeatureNotAvailableWithReceptionModule=Feature not available when module Reception is enabled \ No newline at end of file From bb81f66a1af79915591aa4eb2c2bae574d82910e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Sep 2019 10:36:49 +0200 Subject: [PATCH 16/46] Add phpunit test for Lessc --- htdocs/comm/action/card.php | 4 +- .../class/bonprelevement.class.php | 2 - .../class/paymentsocialcontribution.class.php | 2 +- htdocs/core/class/CMailFile.class.php | 2 +- htdocs/core/class/extrafields.class.php | 3 +- htdocs/core/class/lessc.class.php | 4 +- htdocs/website/index.php | 2 +- test/phpunit/AllTests.php | 2 + test/phpunit/LesscTest.php | 182 ++++++++++++++++++ 9 files changed, 193 insertions(+), 10 deletions(-) create mode 100644 test/phpunit/LesscTest.php diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index af54186e255..a9dd837fc8c 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -147,7 +147,7 @@ if ($action == 'classin' && ($user->rights->agenda->allactions->create || (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create))) { $object->fetch($id); - $object->setProject(GETPOST('projectid')); + $object->setProject(GETPOST('projectid', 'int')); } // Action clone object @@ -165,7 +165,7 @@ if ($action == 'confirm_clone' && $confirm == 'yes') reset($object->socpeopleassigned); $object->contactid = key($object->socpeopleassigned); } - $result = $object->createFromClone($user, GETPOST('fk_userowner'), GETPOST('socid')); + $result = $object->createFromClone($user, GETPOST('socid', 'int')); if ($result > 0) { header("Location: " . $_SERVER['PHP_SELF'] . '?id=' . $result); exit(); diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index a60330270d4..c9dd592c6a9 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -798,8 +798,6 @@ class BonPrelevement extends CommonObject $month = strftime("%m", $datetimeprev); $year = strftime("%Y", $datetimeprev); - $puser = new User($this->db, $conf->global->PRELEVEMENT_USER); - $this->invoice_in_error = array(); $this->thirdparty_in_error = array(); diff --git a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php index 86dda559061..c17724e2de5 100644 --- a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php +++ b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php @@ -184,7 +184,7 @@ class PaymentSocialContribution extends CommonObject $remaintopay=price2num($contrib->amount - $paiement - $creditnotes - $deposits, 'MT'); if ($remaintopay == 0) { - $result=$contrib->set_paid($user, '', ''); + $result=$contrib->set_paid($user); } else dol_syslog("Remain to pay for conrib ".$contribid." not null. We do nothing."); } diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index eabe0440dca..43ad52b5f47 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -428,7 +428,7 @@ class CMailFile foreach ($this->images_encoded as $img) { //$img['fullpath'],$img['image_encoded'],$img['name'],$img['content_type'],$img['cid'] - $attachment = Swift_Image::fromPath($img['fullpath'], $img['content_type']); + $attachment = Swift_Image::fromPath($img['fullpath']); // embed image $imgcid = $this->message->embed($attachment); // replace cid by the one created by swiftmail in html message diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index c92ae311141..0a9f98b4afd 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -274,9 +274,10 @@ class ExtraFields * @param string $perms Permission * @param string $list Into list view by default * @param string $computed Computed value + * @param string $help Help on tooltip * @return int <=0 if KO, >0 if OK */ - private function create($attrname, $type = 'varchar', $length = 255, $elementtype = 'member', $unique = 0, $required = 0, $default_value = '', $param = '', $perms = '', $list = '0', $computed = '') + private function create($attrname, $type = 'varchar', $length = 255, $elementtype = 'member', $unique = 0, $required = 0, $default_value = '', $param = '', $perms = '', $list = '0', $computed = '', $help = '') { if ($elementtype == 'thirdparty') $elementtype='societe'; if ($elementtype == 'contact') $elementtype='socpeople'; diff --git a/htdocs/core/class/lessc.class.php b/htdocs/core/class/lessc.class.php index f6a9208cadf..396991b6612 100644 --- a/htdocs/core/class/lessc.class.php +++ b/htdocs/core/class/lessc.class.php @@ -3058,7 +3058,7 @@ class lessc_parser { $content[] = $m[1]; if ($m[2] == "@{") { $this->count -= strlen($m[2]); - if ($this->interpolation($inter, false)) { + if ($this->interpolation($inter)) { $content[] = $inter; } else { $this->count += strlen($m[2]); @@ -3310,7 +3310,7 @@ class lessc_parser { continue; } - if ($this->interpolation($inter, false)) { + if ($this->interpolation($inter)) { $attrParts[] = $inter; $hasInterpolation = true; continue; diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 38af5be87e4..47e3188f5ff 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -705,7 +705,7 @@ if ($action == 'addcontainer') getAllImages($object, $objectpage, $urltograbbis, $tmpgeturl['content'], $action, 1, $grabimages, $grabimagesinto); include_once DOL_DOCUMENT_ROOT.'/core/class/lessc.class.php'; - $lesscobj = new lessc(); + $lesscobj = new Lessc(); try { $contentforlessc = ".bodywebsite {\n".$tmpgeturl['content']."\n}\n"; //print '
'.$contentforlessc.'
'; diff --git a/test/phpunit/AllTests.php b/test/phpunit/AllTests.php index 37abbc9a2bd..f5068dc59ee 100644 --- a/test/phpunit/AllTests.php +++ b/test/phpunit/AllTests.php @@ -87,6 +87,8 @@ class AllTests $suite->addTestSuite('DateLibTest'); require_once dirname(__FILE__).'/UtilsTest.php'; $suite->addTestSuite('UtilsTest'); + require_once dirname(__FILE__).'/LesscTest.php'; + $suite->addTestSuite('LesscTest'); //require_once dirname(__FILE__).'/DateLibTzFranceTest.php'; //$suite->addTestSuite('DateLibTzFranceTest'); require_once dirname(__FILE__).'/MarginsLibTest.php'; diff --git a/test/phpunit/LesscTest.php b/test/phpunit/LesscTest.php new file mode 100644 index 00000000000..634b362a7b2 --- /dev/null +++ b/test/phpunit/LesscTest.php @@ -0,0 +1,182 @@ + + * + * 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * or see http://www.gnu.org/ + */ + +/** + * \file test/phpunit/LessTest.php + * \ingroup test + * \brief PHPUnit test + * \remarks To run this script as CLI: phpunit filename.php + */ + +global $conf,$user,$langs,$db; +//define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver +//require_once 'PHPUnit/Autoload.php'; +require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; +require_once dirname(__FILE__).'/../../htdocs/core/lib/security.lib.php'; +require_once dirname(__FILE__).'/../../htdocs/core/lib/security2.lib.php'; + +if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); +if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); +if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); +if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); +if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); +if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); +if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no menu to show +if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php +if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); +if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session) + +if (empty($user->id)) +{ + print "Load permissions for admin user nb 1\n"; + $user->fetch(1); + $user->getrights(); +} +$conf->global->MAIN_DISABLE_ALL_MAILS=1; + + +/** + * Class for PHPUnit tests + * + * @backupGlobals disabled + * @backupStaticAttributes enabled + * @remarks backupGlobals must be disabled to have db,conf,user and lang not erased. + */ +class LesscTest extends PHPUnit\Framework\TestCase +{ + protected $savconf; + protected $savuser; + protected $savlangs; + protected $savdb; + + /** + * Constructor + * We save global variables into local variables + * + * @return SecurityTest + */ + public function __construct() + { + parent::__construct(); + + //$this->sharedFixture + global $conf,$user,$langs,$db; + $this->savconf=$conf; + $this->savuser=$user; + $this->savlangs=$langs; + $this->savdb=$db; + + print __METHOD__." db->type=".$db->type." user->id=".$user->id; + //print " - db ".$db->db; + print "\n"; + } + + // Static methods + public static function setUpBeforeClass() + { + global $conf,$user,$langs,$db; + $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. + + print __METHOD__."\n"; + } + + // tear down after class + public static function tearDownAfterClass() + { + global $conf,$user,$langs,$db; + $db->rollback(); + + print __METHOD__."\n"; + } + + /** + * Init phpunit tests + * + * @return void + */ + protected function setUp() + { + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; + + print __METHOD__."\n"; + } + + /** + * End phpunit tests + * + * @return void + */ + protected function tearDown() + { + print __METHOD__."\n"; + } + + /** + * testLess + * + * @return string + */ + public function testLessc() + { + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; + + include_once DOL_DOCUMENT_ROOT.'/core/class/lessc.class.php'; + + $lesscobj = new Lessc(); + + $cssfile = " + a { font-size: 10px; } + b .test { + font-size: 10px; + } + "; + + try { + $contentforlessc = ".bodywebsite {\n".$cssfile."\n}\n"; + //print '
'.$contentforlessc.'
'; + $result = $lesscobj->compile($contentforlessc); + //var_dump($contentforlessc); exit; + + } catch (exception $e) { + //echo "failed to compile lessc"; + dol_syslog("Failed to compile the CSS with lessc: ".$e->getMessage(), LOG_WARNING); + } + + $cssexpected = " +.bodywebsite a { + font-size: 10px; +} +.bodywebsite b .test { + font-size: 10px; +} +"; + + print __METHOD__." SeparatorDecimal=".$result."\n"; + $this->assertEquals(trim($result), trim($cssexpected)); + + return; + } +} From f08c07f31550db064e66ad603665a4df8df3985b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Sep 2019 10:42:51 +0200 Subject: [PATCH 17/46] Fix bugs reported by scrutinizer --- htdocs/core/lib/files.lib.php | 6 ------ htdocs/core/menus/standard/empty.php | 11 +++++++---- htdocs/core/modules/import/import_csv.modules.php | 2 +- htdocs/core/modules/import/import_xlsx.modules.php | 2 +- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 0c72fe35fab..3bbedb91076 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1023,22 +1023,16 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable { case UPLOAD_ERR_INI_SIZE: // 1 return 'ErrorFileSizeTooLarge'; - break; case UPLOAD_ERR_FORM_SIZE: // 2 return 'ErrorFileSizeTooLarge'; - break; case UPLOAD_ERR_PARTIAL: // 3 return 'ErrorPartialFile'; - break; case UPLOAD_ERR_NO_TMP_DIR: // return 'ErrorNoTmpDir'; - break; case UPLOAD_ERR_CANT_WRITE: return 'ErrorFailedToWriteInDir'; - break; case UPLOAD_ERR_EXTENSION: return 'ErrorUploadBlockedByAddon'; - break; default: break; } diff --git a/htdocs/core/menus/standard/empty.php b/htdocs/core/menus/standard/empty.php index 1898d67ad39..964681a962b 100644 --- a/htdocs/core/menus/standard/empty.php +++ b/htdocs/core/menus/standard/empty.php @@ -51,12 +51,15 @@ class MenuManager /** - * Load this->tabMenu - * - * @return void + * Load this->tabMenu + * + * @param string $forcemainmenu To force mainmenu to load + * @param string $forceleftmenu To force leftmenu to load + * @return void */ - public function loadMenu() + public function loadMenu($forcemainmenu = '', $forceleftmenu = '') { + // Do nothing } diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php index 606b23e2767..0888e5b84bf 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -761,7 +761,7 @@ class ImportCsv extends ModeleImports $lastinsertid = $res->rowid; $last_insert_id_array[$tablename] = $lastinsertid; } elseif($resql->num_rows > 1) { - $this->errors[$error]['lib']=$langs->trans('MultipleRecordFoundWithTheseFilters', implode($filters, ', ')); + $this->errors[$error]['lib']=$langs->trans('MultipleRecordFoundWithTheseFilters', implode(', ', $filters)); $this->errors[$error]['type']='SQL'; $error++; } else { diff --git a/htdocs/core/modules/import/import_xlsx.modules.php b/htdocs/core/modules/import/import_xlsx.modules.php index 66670247a4c..253622d115f 100644 --- a/htdocs/core/modules/import/import_xlsx.modules.php +++ b/htdocs/core/modules/import/import_xlsx.modules.php @@ -782,7 +782,7 @@ class ImportXlsx extends ModeleImports $lastinsertid = $res->rowid; $last_insert_id_array[$tablename] = $lastinsertid; } elseif($resql->num_rows > 1) { - $this->errors[$error]['lib']=$langs->trans('MultipleRecordFoundWithTheseFilters', implode($filters, ', ')); + $this->errors[$error]['lib']=$langs->trans('MultipleRecordFoundWithTheseFilters', implode(', ', $filters)); $this->errors[$error]['type']='SQL'; $error++; } else { From 529dd05226e53316e17995a0b2dd3f3dcd0f836b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Sep 2019 10:53:05 +0200 Subject: [PATCH 18/46] Replace deprecated code --- htdocs/adherents/class/adherent.class.php | 3 ++- htdocs/bom/class/api_boms.class.php | 2 +- htdocs/comm/propal/class/api_proposals.class.php | 2 +- htdocs/commande/class/api_orders.class.php | 2 +- htdocs/compta/facture/class/api_invoices.class.php | 2 +- htdocs/contrat/class/api_contracts.class.php | 2 +- htdocs/don/class/api_donations.class.php | 2 +- htdocs/expedition/class/api_shipments.class.php | 2 +- htdocs/expensereport/class/api_expensereports.class.php | 2 +- htdocs/fichinter/class/api_interventions.class.php | 2 +- htdocs/fourn/class/api_supplier_orders.class.php | 2 +- htdocs/modulebuilder/template/class/api_mymodule.class.php | 2 +- htdocs/product/class/api_products.class.php | 2 +- htdocs/projet/class/api_projects.class.php | 2 +- htdocs/projet/class/api_tasks.class.php | 2 +- htdocs/societe/class/api_thirdparties.class.php | 2 +- .../supplier_proposal/class/api_supplier_proposals.class.php | 2 +- htdocs/ticket/class/api_tickets.class.php | 4 ++-- htdocs/user/class/api_users.class.php | 2 +- 19 files changed, 21 insertions(+), 20 deletions(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index c5128942830..1b516e1c94e 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -2063,9 +2063,10 @@ class Adherent extends CommonObject * @param string $mode ''=Show firstname+lastname as label (using default order), 'firstname'=Show only firstname, 'login'=Show login, 'ref'=Show ref * @param string $morecss Add more css on link * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @param int $notooltip 1=Disable tooltip * @return string Chaine avec URL */ - public function getNomUrl($withpictoimg = 0, $maxlen = 0, $option = 'card', $mode = '', $morecss = '', $save_lastsearch_value = -1) + public function getNomUrl($withpictoimg = 0, $maxlen = 0, $option = 'card', $mode = '', $morecss = '', $save_lastsearch_value = -1, $notooltip = 0) { global $conf, $langs; diff --git a/htdocs/bom/class/api_boms.class.php b/htdocs/bom/class/api_boms.class.php index 54f289a5b23..89f3e337099 100644 --- a/htdocs/bom/class/api_boms.class.php +++ b/htdocs/bom/class/api_boms.class.php @@ -101,7 +101,7 @@ class Boms extends DolibarrApi $obj_ret = array(); $tmpobject = new BOM($db); - $socid = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : ''; + $socid = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : ''; $restrictonsocid = 0; // Set to 1 if there is a field socid in table of object diff --git a/htdocs/comm/propal/class/api_proposals.class.php b/htdocs/comm/propal/class/api_proposals.class.php index 9cc8bd32d26..15badcd75a3 100644 --- a/htdocs/comm/propal/class/api_proposals.class.php +++ b/htdocs/comm/propal/class/api_proposals.class.php @@ -103,7 +103,7 @@ class Proposals extends DolibarrApi $obj_ret = array(); // case of external user, $thirdparty_ids param is ignored and replaced by user's socid - $socids = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $thirdparty_ids; + $socids = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $thirdparty_ids; // If the internal user must only see his customers, force searching by him $search_sale = 0; diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php index 440ea9e6984..56147545f36 100644 --- a/htdocs/commande/class/api_orders.class.php +++ b/htdocs/commande/class/api_orders.class.php @@ -107,7 +107,7 @@ class Orders extends DolibarrApi $obj_ret = array(); // case of external user, $thirdparty_ids param is ignored and replaced by user's socid - $socids = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $thirdparty_ids; + $socids = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $thirdparty_ids; // If the internal user must only see his customers, force searching by him $search_sale = 0; diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index d6b33acbda6..d558bf5ac7f 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -112,7 +112,7 @@ class Invoices extends DolibarrApi $obj_ret = array(); // case of external user, $thirdparty_ids param is ignored and replaced by user's socid - $socids = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $thirdparty_ids; + $socids = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $thirdparty_ids; // If the internal user must only see his customers, force searching by him $search_sale = 0; diff --git a/htdocs/contrat/class/api_contracts.class.php b/htdocs/contrat/class/api_contracts.class.php index 4735f840582..194e145210f 100644 --- a/htdocs/contrat/class/api_contracts.class.php +++ b/htdocs/contrat/class/api_contracts.class.php @@ -108,7 +108,7 @@ class Contracts extends DolibarrApi $obj_ret = array(); // case of external user, $thirdparty_ids param is ignored and replaced by user's socid - $socids = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $thirdparty_ids; + $socids = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $thirdparty_ids; // If the internal user must only see his customers, force searching by him $search_sale = 0; diff --git a/htdocs/don/class/api_donations.class.php b/htdocs/don/class/api_donations.class.php index f9e2c5ab64b..ef59743e03f 100644 --- a/htdocs/don/class/api_donations.class.php +++ b/htdocs/don/class/api_donations.class.php @@ -106,7 +106,7 @@ class Donations extends DolibarrApi $obj_ret = array(); // case of external user, $thirdparty_ids param is ignored and replaced by user's socid - $socids = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $thirdparty_ids; + $socids = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $thirdparty_ids; $sql = "SELECT t.rowid"; if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) ) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) diff --git a/htdocs/expedition/class/api_shipments.class.php b/htdocs/expedition/class/api_shipments.class.php index 9f1e42a7aaa..5e4d0d5e00c 100644 --- a/htdocs/expedition/class/api_shipments.class.php +++ b/htdocs/expedition/class/api_shipments.class.php @@ -106,7 +106,7 @@ class Shipments extends DolibarrApi $obj_ret = array(); // case of external user, $thirdparty_ids param is ignored and replaced by user's socid - $socids = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $thirdparty_ids; + $socids = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $thirdparty_ids; // If the internal user must only see his customers, force searching by him $search_sale = 0; diff --git a/htdocs/expensereport/class/api_expensereports.class.php b/htdocs/expensereport/class/api_expensereports.class.php index cb5a438bc21..f2177aafc63 100644 --- a/htdocs/expensereport/class/api_expensereports.class.php +++ b/htdocs/expensereport/class/api_expensereports.class.php @@ -101,7 +101,7 @@ class ExpenseReports extends DolibarrApi $obj_ret = array(); // case of external user, $societe param is ignored and replaced by user's socid - //$socid = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $societe; + //$socid = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $societe; $sql = "SELECT t.rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as t"; diff --git a/htdocs/fichinter/class/api_interventions.class.php b/htdocs/fichinter/class/api_interventions.class.php index b183623edb3..12f6824ad4d 100644 --- a/htdocs/fichinter/class/api_interventions.class.php +++ b/htdocs/fichinter/class/api_interventions.class.php @@ -113,7 +113,7 @@ class Interventions extends DolibarrApi $obj_ret = array(); // case of external user, $thirdparty_ids param is ignored and replaced by user's socid - $socids = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $thirdparty_ids; + $socids = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $thirdparty_ids; // If the internal user must only see his customers, force searching by him $search_sale = 0; diff --git a/htdocs/fourn/class/api_supplier_orders.class.php b/htdocs/fourn/class/api_supplier_orders.class.php index 897d210b1f1..323ddf29521 100644 --- a/htdocs/fourn/class/api_supplier_orders.class.php +++ b/htdocs/fourn/class/api_supplier_orders.class.php @@ -103,7 +103,7 @@ class SupplierOrders extends DolibarrApi $obj_ret = array(); // case of external user, $thirdparty_ids param is ignored and replaced by user's socid - $socids = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $thirdparty_ids; + $socids = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $thirdparty_ids; // If the internal user must only see his customers, force searching by him $search_sale = 0; diff --git a/htdocs/modulebuilder/template/class/api_mymodule.class.php b/htdocs/modulebuilder/template/class/api_mymodule.class.php index 0fcd9a8afd4..594f979bb22 100644 --- a/htdocs/modulebuilder/template/class/api_mymodule.class.php +++ b/htdocs/modulebuilder/template/class/api_mymodule.class.php @@ -111,7 +111,7 @@ class MyModuleApi extends DolibarrApi throw new RestException(401); } - $socid = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : ''; + $socid = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : ''; $restrictonsocid = 0; // Set to 1 if there is a field socid in table of object diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index 2543ff4a2e6..446b4fa3cfe 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -116,7 +116,7 @@ class Products extends DolibarrApi $obj_ret = array(); - $socid = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : ''; + $socid = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : ''; $sql = "SELECT t.rowid, t.ref, t.ref_ext"; $sql.= " FROM ".MAIN_DB_PREFIX."product as t"; diff --git a/htdocs/projet/class/api_projects.class.php b/htdocs/projet/class/api_projects.class.php index 38ea9796f65..0744017161e 100644 --- a/htdocs/projet/class/api_projects.class.php +++ b/htdocs/projet/class/api_projects.class.php @@ -105,7 +105,7 @@ class Projects extends DolibarrApi $obj_ret = array(); // case of external user, $thirdparty_ids param is ignored and replaced by user's socid - $socids = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $thirdparty_ids; + $socids = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $thirdparty_ids; // If the internal user must only see his customers, force searching by him $search_sale = 0; diff --git a/htdocs/projet/class/api_tasks.class.php b/htdocs/projet/class/api_tasks.class.php index b5e589e4ef9..2415950e37b 100644 --- a/htdocs/projet/class/api_tasks.class.php +++ b/htdocs/projet/class/api_tasks.class.php @@ -113,7 +113,7 @@ class Tasks extends DolibarrApi $obj_ret = array(); // case of external user, $thirdparty_ids param is ignored and replaced by user's socid - $socids = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $thirdparty_ids; + $socids = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : ''; // If the internal user must only see his customers, force searching by him $search_sale = 0; diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index 95aad3a003b..ddb19c563fe 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -124,7 +124,7 @@ class Thirdparties extends DolibarrApi $obj_ret = array(); // case of external user, we force socids - $socids = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : ''; + $socids = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : ''; // If the internal user must only see his customers, force searching by him $search_sale = 0; diff --git a/htdocs/supplier_proposal/class/api_supplier_proposals.class.php b/htdocs/supplier_proposal/class/api_supplier_proposals.class.php index 014951d980e..cb606e8a083 100644 --- a/htdocs/supplier_proposal/class/api_supplier_proposals.class.php +++ b/htdocs/supplier_proposal/class/api_supplier_proposals.class.php @@ -101,7 +101,7 @@ class Supplierproposals extends DolibarrApi $obj_ret = array(); // case of external user, $thirdparty_ids param is ignored and replaced by user's socid - $socids = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $thirdparty_ids; + $socids = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $thirdparty_ids; // If the internal user must only see his customers, force searching by him $search_sale = 0; diff --git a/htdocs/ticket/class/api_tickets.class.php b/htdocs/ticket/class/api_tickets.class.php index 400b8452938..aac1bf88f60 100644 --- a/htdocs/ticket/class/api_tickets.class.php +++ b/htdocs/ticket/class/api_tickets.class.php @@ -234,8 +234,8 @@ class Tickets extends DolibarrApi $obj_ret = array(); - if (!$socid && DolibarrApiAccess::$user->societe_id) { - $socid = DolibarrApiAccess::$user->societe_id; + if (!$socid && DolibarrApiAccess::$user->socid) { + $socid = DolibarrApiAccess::$user->socid; } // If the internal user must only see his customers, force searching by him diff --git a/htdocs/user/class/api_users.class.php b/htdocs/user/class/api_users.class.php index f570dd21285..1344cdd9815 100644 --- a/htdocs/user/class/api_users.class.php +++ b/htdocs/user/class/api_users.class.php @@ -76,7 +76,7 @@ class Users extends DolibarrApi } // case of external user, $societe param is ignored and replaced by user's socid - //$socid = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $societe; + //$socid = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $societe; $sql = "SELECT t.rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."user as t"; From 0ed7ab07fd8207df753e02da89c98ca46396e730 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Sep 2019 12:41:34 +0200 Subject: [PATCH 19/46] Fix date selection for supplier proposal not yet supported --- htdocs/supplier_proposal/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index 56473959a39..551a5f0616e 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -1711,7 +1711,7 @@ if ($action == 'create') if (! empty($conf->global->SUPPLIER_PROPOSAL_WITH_PREDEFINED_PRICES_ONLY)) $senderissupplier=1; if (! empty($object->lines)) - $ret = $object->printObjectLines($action, $soc, $mysoc, $lineid, 1); + $ret = $object->printObjectLines($action, $soc, $mysoc, $lineid, $dateSelector); // Form to add new line if ($object->statut == SupplierProposal::STATUS_DRAFT && $user->rights->supplier_proposal->creer) @@ -1719,7 +1719,7 @@ if ($action == 'create') if ($action != 'editline') { // Add products/services form - $object->formAddObjectLine(1, $soc, $mysoc); + $object->formAddObjectLine($dateSelector, $soc, $mysoc); $parameters = array(); $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook From 123eace8c04159ed57578d193ef3c91183d9a950 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Sep 2019 12:44:23 +0200 Subject: [PATCH 20/46] Fix look and feel v10 --- htdocs/core/class/commonobject.class.php | 19 +++++++++++++++---- htdocs/core/tpl/objectline_create.tpl.php | 2 +- htdocs/core/tpl/objectline_edit.tpl.php | 4 ++-- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index c57148124be..cabd5647bc9 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -6532,9 +6532,12 @@ abstract class CommonObject } else { - $csstyle=''; $class=(!empty($extrafields->attributes[$this->table_element]['hidden'][$key]) ? 'hideobject ' : ''); + $csstyle=''; if (is_array($params) && count($params)>0) { + if (array_key_exists('class', $params)) { + $class.=$params['class'].' '; + } if (array_key_exists('style', $params)) { $csstyle=$params['style']; } @@ -6571,16 +6574,19 @@ abstract class CommonObject $labeltoshow = $langs->trans($label); - $out .= '
'; $html_id = !empty($this->id) ? $this->element.'_extras_'.$key.'_'.$this->id : ''; + $out .=''; + /*for($ii = 0; $ii < ($colspan - 1); $ii++) + { + $out .=''; + }*/ + if (! empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && (($e % 2) == 1)) $out .= ''; else $out .= ''; $e++; diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index f427bb34f92..6bad5bb2ac5 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -375,7 +375,7 @@ if ($nolinesbefore) { { $coldisplay++; ?> - + + showOptionals($extrafieldsline, 'edit', array('style'=>$bc[$var],'colspan'=>$coldisplay), '', '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD)?0:1); + print $line->showOptionals($extrafieldsline, 'edit', array('class'=>'tredited', 'colspan'=>$coldisplay), '', '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD)?0:1); } ?> From e1ee70fd8feb14b564eae6a57e2b990e30682d92 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Sep 2019 12:45:27 +0200 Subject: [PATCH 21/46] Start to implement date selection of supplier proposals --- .../install/mysql/migration/10.0.0-11.0.0.sql | 5 +- .../mysql/tables/llx_supplier_proposaldet.sql | 2 + htdocs/supplier_proposal/card.php | 21 +++-- .../class/supplier_proposal.class.php | 83 +++++++------------ 4 files changed, 53 insertions(+), 58 deletions(-) diff --git a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql index 64de0364139..00964b85e3e 100644 --- a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql +++ b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql @@ -105,4 +105,7 @@ create table llx_c_hrm_public_holiday )ENGINE=innodb; - \ No newline at end of file +ALTER TABLE llx_supplier_proposaldet ADD COLUMN date_start datetime DEFAULT NULL; +ALTER TABLE llx_supplier_proposaldet ADD COLUMN date_end datetime DEFAULT NULL; + + \ No newline at end of file diff --git a/htdocs/install/mysql/tables/llx_supplier_proposaldet.sql b/htdocs/install/mysql/tables/llx_supplier_proposaldet.sql index 211502686ee..b735046a340 100644 --- a/htdocs/install/mysql/tables/llx_supplier_proposaldet.sql +++ b/htdocs/install/mysql/tables/llx_supplier_proposaldet.sql @@ -40,6 +40,8 @@ CREATE TABLE llx_supplier_proposaldet ( total_localtax2 double(24,8) DEFAULT 0, total_ttc double(24,8) DEFAULT 0, product_type integer DEFAULT 0, + date_start datetime DEFAULT NULL, -- date debut si service + date_end datetime DEFAULT NULL, -- date fin si service info_bits integer DEFAULT 0, buy_price_ht double(24,8) DEFAULT 0, fk_product_fournisseur_price integer DEFAULT NULL, diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index efb480370cd..2a61876659d 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -357,7 +357,7 @@ if (empty($reshook)) $array_options = $lines[$i]->array_options; } - $result = $object->addline( + $result = $object->addline( $desc, $lines[$i]->subprice, $lines[$i]->qty, $lines[$i]->tva_tx, $lines[$i]->localtax1_tx, $lines[$i]->localtax2_tx, $lines[$i]->fk_product, $lines[$i]->remise_percent, @@ -646,6 +646,9 @@ if (empty($reshook)) $pu_ht = $productsupplier->fourn_pu; if (empty($pu_ht)) $pu_ht = 0; // If pu is '' or null, we force to have a numeric value + $fournprice = 0; + $buyingprice = 0; + $result=$object->addline( $desc, $pu_ht, @@ -670,9 +673,17 @@ if (empty($reshook)) $productsupplier->fk_unit, '', 0, - $productsupplier->fourn_multicurrency_unitprice + $productsupplier->fourn_multicurrency_unitprice, + $date_start, + $date_end ); + //var_dump($tva_tx);var_dump($productsupplier->fourn_pu);var_dump($price_base_type);exit; + if ($result < 0) + { + $error++; + setEventMessages($object->error, $object->errors, 'errors'); + } } if ($idprod == -99 || $idprod == 0) { @@ -1751,12 +1762,12 @@ if ($action == 'create') // Add free products/services form global $forceall, $senderissupplier, $dateSelector, $inputalsopricewithtax; - $forceall=1; $dateSelector=0; $inputalsopricewithtax=1; + $forceall=1; $dateSelector=1; $inputalsopricewithtax=1; $senderissupplier=2; // $senderissupplier=2 is same than 1 but disable test on minimum qty. if (! empty($conf->global->SUPPLIER_PROPOSAL_WITH_PREDEFINED_PRICES_ONLY)) $senderissupplier=1; if (! empty($object->lines)) - $ret = $object->printObjectLines($action, $soc, $mysoc, $lineid, 1); + $ret = $object->printObjectLines($action, $soc, $mysoc, $lineid, $dateSelector); // Form to add new line if ($object->statut == SupplierProposal::STATUS_DRAFT && $user->rights->supplier_proposal->creer) @@ -1764,7 +1775,7 @@ if ($action == 'create') if ($action != 'editline') { // Add products/services form - $object->formAddObjectLine(1, $soc, $mysoc); + $object->formAddObjectLine($dateSelector, $soc, $mysoc); $parameters = array(); $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index 3748aede1c7..142917a10d3 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -391,11 +391,13 @@ class SupplierProposal extends CommonObject * @param string $origin 'order', 'supplier_proposal', ... * @param int $origin_id Id of origin line * @param double $pu_ht_devise Amount in currency + * @param int $date_start Date start + * @param int $date_end Date end * @return int >0 if OK, <0 if KO * * @see add_product() */ - public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $price_base_type = 'HT', $pu_ttc = 0, $info_bits = 0, $type = 0, $rang = -1, $special_code = 0, $fk_parent_line = 0, $fk_fournprice = 0, $pa_ht = 0, $label = '', $array_option = 0, $ref_supplier = '', $fk_unit = '', $origin = '', $origin_id = 0, $pu_ht_devise = 0) + public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $price_base_type = 'HT', $pu_ttc = 0, $info_bits = 0, $type = 0, $rang = -1, $special_code = 0, $fk_parent_line = 0, $fk_fournprice = 0, $pa_ht = 0, $label = '', $array_option = 0, $ref_supplier = '', $fk_unit = '', $origin = '', $origin_id = 0, $pu_ht_devise = 0, $date_start = 0, $date_end = 0) { global $mysoc, $conf; @@ -570,6 +572,8 @@ class SupplierProposal extends CommonObject $this->line->origin=$origin; $this->line->origin_id=$origin_id; $this->line->ref_fourn = $this->db->escape($ref_supplier); + $this->line->date_start = $date_start; + $this->line->date_end = $date_end; // infos marge if (!empty($fk_product) && empty($fk_fournprice) && empty($pa_ht)) { @@ -594,10 +598,6 @@ class SupplierProposal extends CommonObject // Mise en option de la ligne if (empty($qty) && empty($special_code)) $this->line->special_code=3; - // TODO deprecated - $this->line->price=$price; - $this->line->remise=$remise; - if (is_array($array_option) && count($array_option)>0) { $this->line->array_options=$array_option; } @@ -613,7 +613,7 @@ class SupplierProposal extends CommonObject if ($result > 0) { $this->db->commit(); - return $this->line->rowid; + return $this->line->id; } else { @@ -629,6 +629,11 @@ class SupplierProposal extends CommonObject return -2; } } + else + { + $this->error = 'BadStatusOfObjectToAddLine'; + return -5; + } } @@ -688,6 +693,7 @@ class SupplierProposal extends CommonObject $localtaxes_type=getLocalTaxesFromRate($txtva, 0, $mysoc, $this->thirdparty); // Clean vat code + $reg = array(); $vat_src_code=''; if (preg_match('/\((.*)\)/', $txtva, $reg)) { @@ -707,14 +713,6 @@ class SupplierProposal extends CommonObject $multicurrency_total_tva = $tabprice[17]; $multicurrency_total_ttc = $tabprice[18]; - // Anciens indicateurs: $price, $remise (a ne plus utiliser) - $price = $pu; - if ($remise_percent > 0) - { - $remise = round(($pu * $remise_percent / 100), 2); - $price = $pu - $remise; - } - // Update line $this->line=new SupplierProposalLine($this->db); @@ -730,7 +728,7 @@ class SupplierProposal extends CommonObject $this->line->rang = $rangmax + 1; } - $this->line->rowid = $rowid; + $this->line->id = $rowid; $this->line->label = $label; $this->line->desc = $desc; $this->line->qty = $qty; @@ -768,10 +766,6 @@ class SupplierProposal extends CommonObject } $this->line->pa_ht = $pa_ht; - // TODO deprecated - $this->line->price=$price; - $this->line->remise=$remise; - if (is_array($array_option) && count($array_option)>0) { $this->line->array_options=$array_option; } @@ -791,7 +785,6 @@ class SupplierProposal extends CommonObject $this->update_price(1); $this->fk_supplier_proposal = $this->id; - $this->rowid = $rowid; $this->db->commit(); return $result; @@ -2745,9 +2738,6 @@ class SupplierProposalLine extends CommonObjectLine public $oldline; - // From llx_supplier_proposaldet - public $rowid; // deprecated - /** * @var int ID */ @@ -2813,20 +2803,11 @@ class SupplierProposalLine extends CommonObjectLine // Bit 1: 0 ligne normale - 1 si ligne de remise fixe public $total_ht; // Total HT de la ligne toute quantite et incluant la remise ligne - public $total_tva; // Total TVA de la ligne toute quantite et incluant la remise ligne + public $total_tva; // Total TVA de la ligne toute quantite et incluant la remise ligne public $total_ttc; // Total TTC de la ligne toute quantite et incluant la remise ligne - /** - * @deprecated - * @see remise_percent, fk_remise_except - */ - public $remise; - - /** - * @deprecated - * @see subprice - */ - public $price; + public $date_start; + public $date_end; // From llx_product /** @@ -2902,6 +2883,7 @@ class SupplierProposalLine extends CommonObjectLine public function fetch($rowid) { $sql = 'SELECT pd.rowid, pd.fk_supplier_proposal, pd.fk_parent_line, pd.fk_product, pd.label as custom_label, pd.description, pd.price, pd.qty, pd.tva_tx,'; + $sql.= ' pd.date_start, pd.date_end,'; $sql.= ' pd.remise, pd.remise_percent, pd.fk_remise_except, pd.subprice,'; $sql.= ' pd.info_bits, pd.total_ht, pd.total_tva, pd.total_ttc, pd.fk_product_fournisseur_price as fk_fournprice, pd.buy_price_ht as pa_ht, pd.special_code, pd.rang,'; $sql.= ' pd.localtax1_tx, pd.localtax2_tx, pd.total_localtax1, pd.total_localtax2,'; @@ -2917,21 +2899,20 @@ class SupplierProposalLine extends CommonObjectLine { $objp = $this->db->fetch_object($result); - $this->rowid = $objp->rowid; // deprecated $this->id = $objp->rowid; $this->fk_supplier_proposal = $objp->fk_supplier_proposal; $this->fk_parent_line = $objp->fk_parent_line; $this->label = $objp->custom_label; $this->desc = $objp->description; $this->qty = $objp->qty; - $this->price = $objp->price; // deprecated $this->subprice = $objp->subprice; $this->tva_tx = $objp->tva_tx; - $this->remise = $objp->remise; $this->remise_percent = $objp->remise_percent; $this->fk_remise_except = $objp->fk_remise_except; $this->fk_product = $objp->fk_product; $this->info_bits = $objp->info_bits; + $this->date_start = $this->db->jdate($objp->date_start); + $this->date_end = $this->db->jdate($objp->date_end); $this->total_ht = $objp->total_ht; $this->total_tva = $objp->total_tva; @@ -3028,6 +3009,7 @@ class SupplierProposalLine extends CommonObjectLine // Insert line into database $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'supplier_proposaldet'; $sql.= ' (fk_supplier_proposal, fk_parent_line, label, description, fk_product, product_type,'; + $sql.= ' date_start, date_end,'; $sql.= ' fk_remise_except, qty, tva_tx, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type,'; $sql.= ' subprice, remise_percent, '; $sql.= ' info_bits, '; @@ -3040,6 +3022,8 @@ class SupplierProposalLine extends CommonObjectLine $sql.= " '".$this->db->escape($this->desc)."',"; $sql.= " ".($this->fk_product?"'".$this->db->escape($this->fk_product)."'":"null").","; $sql.= " '".$this->db->escape($this->product_type)."',"; + $sql.= " ".($this->date_start ? "'".$this->db->idate($this->date_start)."'" : "null").","; + $sql.= " ".($this->date_end ? "'".$this->db->idate($this->date_end)."'" : "null").","; $sql.= " ".($this->fk_remise_except?"'".$this->db->escape($this->fk_remise_except)."'":"null").","; $sql.= " ".price2num($this->qty).","; $sql.= " ".price2num($this->tva_tx).","; @@ -3073,8 +3057,7 @@ class SupplierProposalLine extends CommonObjectLine $resql=$this->db->query($sql); if ($resql) { - $this->rowid=$this->db->last_insert_id(MAIN_DB_PREFIX.'supplier_proposaldet'); - $this->id=$this->rowid; + $this->id=$this->db->last_insert_id(MAIN_DB_PREFIX.'supplier_proposaldet'); if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { @@ -3120,7 +3103,7 @@ class SupplierProposalLine extends CommonObjectLine $error=0; $this->db->begin(); - $sql = "DELETE FROM ".MAIN_DB_PREFIX."supplier_proposaldet WHERE rowid = ".$this->rowid; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."supplier_proposaldet WHERE rowid = ".$this->id; dol_syslog("SupplierProposalLine::delete", LOG_DEBUG); if ($this->db->query($sql) ) { @@ -3128,7 +3111,6 @@ class SupplierProposalLine extends CommonObjectLine // Remove extrafields if ((! $error) && (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) // For avoid conflicts if trigger used { - $this->id=$this->rowid; $result=$this->deleteExtraFields(); if ($result < 0) { @@ -3180,8 +3162,6 @@ class SupplierProposalLine extends CommonObjectLine if (empty($this->localtax2_type)) $this->localtax2_type=0; if (empty($this->marque_tx)) $this->marque_tx=0; if (empty($this->marge_tx)) $this->marge_tx=0; - if (empty($this->price)) $this->price=0; // TODO A virer - if (empty($this->remise)) $this->remise=0; // TODO A virer if (empty($this->remise_percent)) $this->remise_percent=0; if (empty($this->info_bits)) $this->info_bits=0; if (empty($this->special_code)) $this->special_code=0; @@ -3212,6 +3192,8 @@ class SupplierProposalLine extends CommonObjectLine $sql.= " description='".$this->db->escape($this->desc)."'"; $sql.= " , label=".(! empty($this->label)?"'".$this->db->escape($this->label)."'":"null"); $sql.= " , product_type=".$this->product_type; + $sql.= " , date_start=".($this->date_start ? "'".$this->db->idate($this->date_start)."'" : "null"); + $sql.= " , date_end=".($this->date_end ? "'".$this->db->idate($this->date_end)."'" : "null"); $sql.= " , tva_tx='".price2num($this->tva_tx)."'"; $sql.= " , localtax1_tx=".price2num($this->localtax1_tx); $sql.= " , localtax2_tx=".price2num($this->localtax2_tx); @@ -3220,8 +3202,6 @@ class SupplierProposalLine extends CommonObjectLine $sql.= " , qty='".price2num($this->qty)."'"; $sql.= " , subprice=".price2num($this->subprice).""; $sql.= " , remise_percent=".price2num($this->remise_percent).""; - $sql.= " , price=".price2num($this->price).""; // TODO A virer - $sql.= " , remise=".price2num($this->remise).""; // TODO A virer $sql.= " , info_bits='".$this->db->escape($this->info_bits)."'"; if (empty($this->skip_update_total)) { @@ -3245,7 +3225,7 @@ class SupplierProposalLine extends CommonObjectLine $sql.= " , multicurrency_total_tva=".price2num($this->multicurrency_total_tva).""; $sql.= " , multicurrency_total_ttc=".price2num($this->multicurrency_total_ttc).""; - $sql.= " WHERE rowid = ".$this->rowid; + $sql.= " WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql=$this->db->query($sql); @@ -3253,7 +3233,6 @@ class SupplierProposalLine extends CommonObjectLine { if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - $this->id=$this->rowid; $result=$this->insertExtraFields(); if ($result < 0) { @@ -3298,10 +3277,10 @@ class SupplierProposalLine extends CommonObjectLine // Mise a jour ligne en base $sql = "UPDATE ".MAIN_DB_PREFIX."supplier_proposaldet SET"; - $sql.= " total_ht=".price2num($this->total_ht, 'MT').""; - $sql.= ",total_tva=".price2num($this->total_tva, 'MT').""; - $sql.= ",total_ttc=".price2num($this->total_ttc, 'MT').""; - $sql.= " WHERE rowid = ".$this->rowid; + $sql.= " total_ht=".price2num($this->total_ht, 'MT'); + $sql.= ",total_tva=".price2num($this->total_tva, 'MT'); + $sql.= ",total_ttc=".price2num($this->total_ttc, 'MT'); + $sql.= " WHERE rowid = ".$this->id; dol_syslog("SupplierProposalLine::update_total", LOG_DEBUG); From 165f64463b754f63d287c02222c266ffca60480a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Sep 2019 12:44:23 +0200 Subject: [PATCH 22/46] Fix look and feel v10 --- htdocs/core/class/commonobject.class.php | 19 +++++++++++++++---- htdocs/core/tpl/objectline_create.tpl.php | 2 +- htdocs/core/tpl/objectline_edit.tpl.php | 4 ++-- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 4e88348c6d0..d20a8d2785b 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -6450,9 +6450,12 @@ abstract class CommonObject } else { - $csstyle=''; $class=(!empty($extrafields->attributes[$this->table_element]['hidden'][$key]) ? 'hideobject ' : ''); + $csstyle=''; if (is_array($params) && count($params)>0) { + if (array_key_exists('class', $params)) { + $class.=$params['class'].' '; + } if (array_key_exists('style', $params)) { $csstyle=$params['style']; } @@ -6489,16 +6492,19 @@ abstract class CommonObject $labeltoshow = $langs->trans($label); - $out .= ''; $html_id = !empty($this->id) ? $this->element.'_extras_'.$key.'_'.$this->id : ''; + $out .=''; + /*for($ii = 0; $ii < ($colspan - 1); $ii++) + { + $out .=''; + }*/ + if (! empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && (($e % 2) == 1)) $out .= ''; else $out .= ''; $e++; diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index f427bb34f92..6bad5bb2ac5 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -375,7 +375,7 @@ if ($nolinesbefore) { { $coldisplay++; ?> - + + showOptionals($extrafieldsline, 'edit', array('style'=>$bc[$var],'colspan'=>$coldisplay), '', '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD)?0:1); + print $line->showOptionals($extrafieldsline, 'edit', array('class'=>'tredited', 'colspan'=>$coldisplay), '', '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD)?0:1); } ?> From 104858cf4751fd73d845c7464a21b58e47b74984 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Sep 2019 12:51:10 +0200 Subject: [PATCH 23/46] Fix date selection on supplier proposal line not yet supported --- htdocs/supplier_proposal/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index 2a61876659d..bf6ec8d0c59 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -1762,7 +1762,7 @@ if ($action == 'create') // Add free products/services form global $forceall, $senderissupplier, $dateSelector, $inputalsopricewithtax; - $forceall=1; $dateSelector=1; $inputalsopricewithtax=1; + $forceall=1; $dateSelector=0; $inputalsopricewithtax=1; $senderissupplier=2; // $senderissupplier=2 is same than 1 but disable test on minimum qty. if (! empty($conf->global->SUPPLIER_PROPOSAL_WITH_PREDEFINED_PRICES_ONLY)) $senderissupplier=1; From d1a5be20ea2321b717e2fd5498b310f3027d493b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Sep 2019 13:02:52 +0200 Subject: [PATCH 24/46] Fix wrong warning --- htdocs/compta/prelevement/card.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/prelevement/card.php b/htdocs/compta/prelevement/card.php index 5864d6301bd..b8aa09eae60 100644 --- a/htdocs/compta/prelevement/card.php +++ b/htdocs/compta/prelevement/card.php @@ -356,8 +356,6 @@ if ($id > 0 || $ref) print_liste_field_titre(''); print "\n"; - $var=false; - $total = 0; while ($i < min($num, $conf->liste_limit)) @@ -406,7 +404,10 @@ if ($id > 0 || $ref) print ''; print ''; print '\n"; print ''; From bc7bf3b4b5d0cdf7748914cf23693b66ff9b5303 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Sep 2019 13:44:02 +0200 Subject: [PATCH 25/46] FIX bad consistency in list of invoice for direct debit order. --- .../class/bonprelevement.class.php | 7 +- htdocs/compta/prelevement/demandes.php | 204 +++++++++++------- htdocs/compta/prelevement/index.php | 3 + 3 files changed, 129 insertions(+), 85 deletions(-) diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 1a98c33ab02..6f8a7431b0e 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -739,14 +739,13 @@ class BonPrelevement extends CommonObject $sql = "SELECT count(f.rowid) as nb"; $sql.= " FROM ".MAIN_DB_PREFIX."facture as f"; $sql.= ", ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; - $sql.= " WHERE f.fk_statut = 1"; + $sql.= " WHERE f.fk_statut = ".Facture::STATUS_VALIDATED; $sql.= " AND f.entity IN (".getEntity('invoice').")"; $sql.= " AND f.rowid = pfd.fk_facture"; - $sql.= " AND f.paye = 0"; $sql.= " AND pfd.traite = 0"; $sql.= " AND f.total_ttc > 0"; - dol_syslog(get_class($this)."::SommeAPrelever"); + dol_syslog(get_class($this)."::NbFactureAPrelever"); $resql = $this->db->query($sql); if ( $resql ) @@ -759,7 +758,7 @@ class BonPrelevement extends CommonObject } else { - $this->error=get_class($this)."::SommeAPrelever Erreur -1 sql=".$this->db->error(); + $this->error=get_class($this)."::NbFactureAPrelever Erreur -1 sql=".$this->db->error(); return -1; } } diff --git a/htdocs/compta/prelevement/demandes.php b/htdocs/compta/prelevement/demandes.php index 8f9df284291..1caf62f1491 100644 --- a/htdocs/compta/prelevement/demandes.php +++ b/htdocs/compta/prelevement/demandes.php @@ -35,31 +35,43 @@ $langs->loadLangs(array('banks', 'categories', 'withdrawals', 'companies')); // Security check $socid = GETPOST('socid', 'int'); +$status = GETPOST('status', 'int'); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'prelevement', '', '', 'bons'); -// Get supervariables -$page = GETPOST('page', 'int'); -$sortorder = GETPOST('sortorder', 'alpha'); -$sortfield = GETPOST('sortfield', 'alpha'); +$contextpage= GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'myobjectlist'; // To manage different context of search +$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page +$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') +// Load variable for pagination $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOST("page", 'int'); -if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; if (! $sortorder) $sortorder="DESC"; if (! $sortfield) $sortfield="f.ref"; +$massactionbutton = ''; + /* * View */ -llxHeader(); +if (!$status) +{ + $title = $langs->trans("RequestStandingOrderToTreat"); +} +else +{ + $title = $langs->trans("RequestStandingOrderTreated"); +} + +llxHeader('', $title); $thirdpartystatic=new Societe($db); $invoicestatic=new Facture($db); @@ -78,95 +90,125 @@ $sql.= " WHERE s.rowid = f.fk_soc"; $sql.= " AND f.entity IN (".getEntity('invoice').")"; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($socid) $sql.= " AND f.fk_soc = ".$socid; -if (!$statut) $sql.= " AND pfd.traite = 0"; -if ($statut) $sql.= " AND pfd.traite = ".$statut; +if (!$status) $sql.= " AND pfd.traite = 0"; +if ($status) $sql.= " AND pfd.traite = ".$status; +$sql.= " AND f.fk_statut = ".Facture::STATUS_VALIDATED; $sql.= " AND pfd.fk_facture = f.rowid"; if (dol_strlen(trim(GETPOST('search_societe', 'alpha')))) { $sql.= natural_search("s.nom", 'search_societe'); } -$sql.= " ORDER BY $sortfield $sortorder "; -$sql.= $db->plimit($limit+1, $offset); +$sql.=$db->order($sortfield, $sortorder); -$resql=$db->query($sql); -if ($resql) + +// Count total nb of records +$nbtotalofrecords = ''; +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $num = $db->num_rows($resql); - $i = 0; - - if (!$statut) + $resql = $db->query($sql); + $nbtotalofrecords = $db->num_rows($resql); + if (($page * $limit) > $nbtotalofrecords) // if total of record found is smaller than page * limit, goto and load page 0 { - print_barre_liste($langs->trans("RequestStandingOrderToTreat"), $page, "demandes.php", $urladd, $sortfield, $sortorder, '', $num); + $page = 0; + $offset = 0; } - else - { - print_barre_liste($langs->trans("RequestStandingOrderTreated"), $page, "demandes.php", $urladd, $sortfield, $sortorder, '', $num); - } - - print '
'; - - print '
".$langs->trans("RuleForStockManagementDecrease")."'.$langs->trans("Status").''.$langs->trans("Status").'
'.$langs->trans("DeStockOnBill").''; +print ''; if (! empty($conf->facture->enabled)) { if ($conf->use_javascript_ajax) { @@ -125,7 +125,7 @@ $found++; print '
'.$langs->trans("DeStockOnValidateOrder").''; +print ''; if (! empty($conf->commande->enabled)) { if ($conf->use_javascript_ajax) { @@ -147,7 +147,7 @@ $found++; print '
'.$langs->trans("DeStockOnShipment").''; +print ''; if (! empty($conf->expedition->enabled)) { if ($conf->use_javascript_ajax) { @@ -167,7 +167,7 @@ $found++; print '
'.$langs->trans("DeStockOnShipmentOnClosing").''; +print ''; if (! empty($conf->expedition->enabled)) { if ($conf->use_javascript_ajax) { @@ -200,14 +200,14 @@ print '
'; print ''; print ''; print "\n"; -print ''."\n"; +print ''."\n"; print ''."\n"; $found=0; print ''; print ''; -print ''; print ''; -print ''; - print ''; - print ''; + print ''; - print ''; - print ''; + print ''; print ''; - print '
".$langs->trans("RuleForStockManagementIncrease")."'.$langs->trans("Status").''.$langs->trans("Status").'
'.$langs->trans("ReStockOnBill").''; +print ''; if (! empty($conf->fournisseur->enabled)) { if ($conf->use_javascript_ajax) { @@ -228,7 +228,7 @@ $found++; print '
'.$langs->trans("ReStockOnValidateOrder").''; +print ''; if (! empty($conf->fournisseur->enabled)) { if ($conf->use_javascript_ajax) { @@ -248,8 +248,8 @@ $found++; if (!empty($conf->reception->enabled)) { print '
'.$langs->trans("StockOnReception").''; + print ''.$langs->trans("StockOnReception").''; if ($conf->use_javascript_ajax) { print ajax_constantonoff('STOCK_CALCULATE_ON_RECEPTION'); @@ -263,8 +263,8 @@ if ($conf->use_javascript_ajax) { print '
'.$langs->trans("StockOnReceptionOnClosing").''; + print ''.$langs->trans("StockOnReceptionOnClosing").''; if ($conf->use_javascript_ajax) { print ajax_constantonoff('STOCK_CALCULATE_ON_RECEPTION_CLOSE'); @@ -279,7 +279,7 @@ else { print '
'.$langs->trans("ReStockOnDispatchOrder").''; + print ''; if (! empty($conf->fournisseur->enabled)) { if ($conf->use_javascript_ajax) { @@ -308,16 +308,17 @@ if ($conf->use_javascript_ajax) { print '
'; print '
'; + print ''; print ''; print "\n"; -print ''."\n"; +print ''."\n"; print ''."\n"; print ''; print ''; -print ''; print ''; - print ''; print ''; - print ''; print ''; - print ''; + print ''; + print ''; + print "
".$langs->trans("RuleForStockAvailability")."'.$langs->trans("Status").''.$langs->trans("Status").'
'.$langs->trans("WarehouseAllowNegativeTransfer").''; +print ''; if ($conf->use_javascript_ajax) { print ajax_constantonoff('STOCK_ALLOW_NEGATIVE_TRANSFER'); } else { @@ -332,7 +333,7 @@ if($conf->invoice->enabled) { print '
'.$langs->trans("StockMustBeEnoughForInvoice").''; + print ''; if ($conf->use_javascript_ajax) { print ajax_constantonoff('STOCK_MUST_BE_ENOUGH_FOR_INVOICE'); } else { @@ -347,7 +348,7 @@ if($conf->order->enabled) { print '
'.$langs->trans("StockMustBeEnoughForOrder").''; + print ''; if ($conf->use_javascript_ajax) { print ajax_constantonoff('STOCK_MUST_BE_ENOUGH_FOR_ORDER'); } else { @@ -362,7 +363,7 @@ if($conf->expedition->enabled) { print '
'.$langs->trans("StockMustBeEnoughForShipment").''; + print ''; if ($conf->use_javascript_ajax) { print ajax_constantonoff('STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT'); } else { @@ -386,12 +387,12 @@ if ($virtualdiffersfromphysical) print ''; print ''; print "\n"; - print ''."\n"; + print ''."\n"; print ''."\n"; print ''; print ''; - print ''; print ''; print ''; print "\n"; -$var=false; -//if ($conf->global->MAIN_FEATURES_LEVEL > 0) -//{ - print '\n"; +print '\n"; -//} // Ask for payment bank during supplier order /* Kept as hidden for the moment @@ -564,6 +560,20 @@ print '\n"; +// Option to add a quality/validation step, on products, after reception. +$langs->load("stocks"); +print ''; +print ''; +print ''; +print '\n\n"; + print '
".$langs->trans("RuleForStockReplenishment")." ".img_help('help', $langs->trans("VirtualDiffersFromPhysical"))."'.$langs->trans("Status").''.$langs->trans("Status").'
'.$langs->trans("UseVirtualStockByDefault").''; + print ''; if ($conf->use_javascript_ajax) { print ajax_constantonoff('STOCK_USE_VIRTUAL_STOCK'); } else { @@ -409,12 +410,12 @@ print ''; print ''; print "\n"; -print ''."\n"; +print ''."\n"; print ''."\n"; print ''; print ''; -print ''; print ''; -print '\n"; print ''; print ''; -print '\n"; print "\n"; -if (! empty($conf->fournisseur->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)) { - print ''; - print ''; - print '\n\n"; -} - print '
".$langs->trans("Other")."'.$langs->trans("Status").''.$langs->trans("Status").'
'.$langs->trans("UserWarehouseAutoCreate").''; +print ''; if ($conf->use_javascript_ajax) { print ajax_constantonoff('STOCK_USERSTOCK_AUTOCREATE'); } else { @@ -428,7 +429,7 @@ print '
'; print $form->textwithpicto($langs->trans("StockSupportServices"), $langs->trans("StockSupportServicesDesc")); print ''; +print ''; if ($conf->use_javascript_ajax) { print ajax_constantonoff('STOCK_SUPPORTS_SERVICES'); } else { @@ -440,7 +441,7 @@ print "
'.$langs->trans("AllowAddLimitStockByWarehouse").''; +print ''; if ($conf->use_javascript_ajax) { print ajax_constantonoff('STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE'); } else { @@ -450,19 +451,6 @@ if ($conf->use_javascript_ajax) { print "
'.$langs->trans("UseDispatchStatus").''; -if ($conf->use_javascript_ajax) { - print ajax_constantonoff('SUPPLIER_ORDER_USE_DISPATCH_STATUS'); -} else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("SUPPLIER_ORDER_USE_DISPATCH_STATUS", $arrval, $conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS); -} - print "
'; print '
'; @@ -471,43 +459,45 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) print ''; print ''; print ''."\n"; - print ''."\n"; - print ''."\n"; + print ''."\n"; + print ''."\n"; // Example with a yes / no select - print ''; + /*print ''; print ''; - print ''; + */ // Example with a yes / no select - print ''; + /*print ''; print ''; - print ''; + print ''; + */ - // Example with a yes / no select + // Example with a yes / no select print ''; - print ''; - print ''; + print ''; print '
'.$langs->trans("Inventory").''.$langs->trans("Status").'
'.$langs->trans("Status").'
'.$langs->trans("INVENTORY_DISABLE_VIRTUAL").''; -if ($conf->use_javascript_ajax) { - print ajax_constantonoff('INVENTORY_DISABLE_VIRTUAL'); -} else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("INVENTORY_DISABLE_VIRTUAL", $arrval, $conf->global->INVENTORY_DISABLE_VIRTUAL); -} + print ''; + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('INVENTORY_DISABLE_VIRTUAL'); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("INVENTORY_DISABLE_VIRTUAL", $arrval, $conf->global->INVENTORY_DISABLE_VIRTUAL); + } print '
'.$langs->trans("INVENTORY_USE_MIN_PA_IF_NO_LAST_PA").''; -if ($conf->use_javascript_ajax) { - print ajax_constantonoff('INVENTORY_USE_MIN_PA_IF_NO_LAST_PA'); -} else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("INVENTORY_USE_MIN_PA_IF_NO_LAST_PA", $arrval, $conf->global->INVENTORY_USE_MIN_PA_IF_NO_LAST_PA); -} - print '
'; + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('INVENTORY_USE_MIN_PA_IF_NO_LAST_PA'); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("INVENTORY_USE_MIN_PA_IF_NO_LAST_PA", $arrval, $conf->global->INVENTORY_USE_MIN_PA_IF_NO_LAST_PA); + } + print '
'.$langs->trans("INVENTORY_USE_INVENTORY_DATE_FROM_DATEMVT").''; -if ($conf->use_javascript_ajax) { - print ajax_constantonoff('INVENTORY_USE_INVENTORY_DATE_FROM_DATEMVT'); -} else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("INVENTORY_USE_INVENTORY_DATE_FROM_DATEMVT", $arrval, $conf->global->INVENTORY_USE_INVENTORY_DATE_FROM_DATEMVT); -} + print ''.$langs->trans("INVENTORY_USE_INVENTORY_DATE_FOR_DATE_OF_MVT").''; + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('INVENTORY_USE_INVENTORY_DATE_FOR_DATE_OF_MVT'); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("INVENTORY_USE_INVENTORY_DATE_FOR_DATE_OF_MVT", $arrval, $conf->global->INVENTORY_USE_INVENTORY_DATE_FOR_DATE_OF_MVT); + } print '
'; diff --git a/htdocs/admin/supplier_order.php b/htdocs/admin/supplier_order.php index e895a0b4005..f1fbbd4b286 100644 --- a/htdocs/admin/supplier_order.php +++ b/htdocs/admin/supplier_order.php @@ -494,20 +494,16 @@ print '
'.$langs->trans("Parameter").''.$langs->trans("Value").' 
'; - print $form->textwithpicto($langs->trans("UseDoubleApproval"), $langs->trans("Use3StepsApproval"), 1, 'help').'
'; - print $langs->trans("IfSetToYesDontForgetPermission"); - print '
'; - print ''; - print ''; - print ''; - print "
'; +print $form->textwithpicto($langs->trans("UseDoubleApproval"), $langs->trans("Use3StepsApproval"), 1, 'help').'
'; +print $langs->trans("IfSetToYesDontForgetPermission"); +print '
'; +print ''; +print ''; +print ''; +print "
'; print ''; print "
'.$langs->trans("UseDispatchStatus").''; +if ($conf->use_javascript_ajax) { + print ajax_constantonoff('SUPPLIER_ORDER_USE_DISPATCH_STATUS'); +} else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("SUPPLIER_ORDER_USE_DISPATCH_STATUS", $arrval, $conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS); +} +print "

'; print ''; diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index d15545e4cda..51829492665 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1822,10 +1822,9 @@ class CommandeFournisseur extends CommonOrder $error++; } - // Si module stock gere et que incrementation faite depuis un dispatching en stock + // If module stock is enabled and the stock increase is done on purchase order dispatching if (! $error && $entrepot > 0 && ! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)) { - $mouv = new MouvementStock($this->db); if ($product > 0) { diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 3e42552a942..1f6baa158da 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -2338,7 +2338,7 @@ elseif (! empty($object->id)) }*/ // Modify - if ($object->statut == 1) + if ($object->statut == CommandeFournisseur::STATUS_VALIDATED) { if ($user->rights->fournisseur->commande->commander) { @@ -2347,7 +2347,7 @@ elseif (! empty($object->id)) } // Approve - if ($object->statut == 1) + if ($object->statut == CommandeFournisseur::STATUS_VALIDATED) { if ($user->rights->fournisseur->commande->approuver) { @@ -2369,7 +2369,7 @@ elseif (! empty($object->id)) // Second approval (if option SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED is set) if (! empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED) && $conf->global->MAIN_FEATURES_LEVEL > 0 && $object->total_ht >= $conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED) { - if ($object->statut == 1) + if ($object->statut == CommandeFournisseur::STATUS_VALIDATED) { if ($user->rights->fournisseur->commande->approve2) { @@ -2390,7 +2390,7 @@ elseif (! empty($object->id)) } // Refuse - if ($object->statut == 1) + if ($object->statut == CommandeFournisseur::STATUS_VALIDATED) { if ($user->rights->fournisseur->commande->approuver || $user->rights->fournisseur->commande->approve2) { @@ -2403,7 +2403,7 @@ elseif (! empty($object->id)) } // Send - if (in_array($object->statut, array(2, 3, 4, 5))) + if (in_array($object->statut, array(CommandeFournisseur::STATUS_ACCEPTED, 3, 4, 5))) { if ($user->rights->fournisseur->commande->commander) { @@ -2412,7 +2412,7 @@ elseif (! empty($object->id)) } // Reopen - if (in_array($object->statut, array(2))) + if (in_array($object->statut, array(CommandeFournisseur::STATUS_ACCEPTED))) { $buttonshown=0; if (! $buttonshown && $user->rights->fournisseur->commande->approuver) @@ -2454,7 +2454,7 @@ elseif (! empty($object->id)) } } - if ($object->statut == 2) + if ($object->statut == CommandeFournisseur::STATUS_ACCEPTED) { if ($user->rights->fournisseur->commande->commander) { @@ -2466,6 +2466,15 @@ elseif (! empty($object->id)) } } + // Classify received (this does not record reception) + if ($object->statut == CommandeFournisseur::STATUS_ORDERSENT || $object->statut == CommandeFournisseur::STATUS_RECEIVED_PARTIALLY) + { + if ($user->rights->fournisseur->commande->receptionner) + { + print ''; + } + } + // Create bill //if (! empty($conf->facture->enabled)) //{ @@ -2583,38 +2592,41 @@ elseif (! empty($object->id)) print '
'; - if ($user->rights->fournisseur->commande->receptionner && ($object->statut == 3 || $object->statut == 4)) + if ($action == 'classifyreception') { - // Set status to received (action=livraison) - print ''."\n"; - print '
'; - print ''; - print ''; - print load_fiche_titre($langs->trans("Receive"), '', ''); + if ($user->rights->fournisseur->commande->receptionner && ($object->statut == CommandeFournisseur::STATUS_ORDERSENT || $object->statut == CommandeFournisseur::STATUS_RECEIVED_PARTIALLY)) + { + // Set status to received (action=livraison) + print ''."\n"; + print ''; + print ''; + print ''; + print load_fiche_titre($langs->trans("Receive"), '', ''); - print ''; - //print ''; - print '\n"; + print '
'.$langs->trans("Receive").'
'.$langs->trans("DeliveryDate").''; - $datepreselected = dol_now(); - print $form->selectDate($datepreselected, '', 1, 1, '', "commande", 1, 1); - print "
'; + //print ''; + print '\n"; - print "'; - print ''; - print ''; - print "
'.$langs->trans("Receive").'
'.$langs->trans("DeliveryDate").''; + $datepreselected = dol_now(); + print $form->selectDate($datepreselected, '', 1, 1, '', "commande", 1, 1); + print "
".$langs->trans("Delivery")."\n"; - $liv = array(); - $liv[''] = ' '; - $liv['tot'] = $langs->trans("CompleteOrNoMoreReceptionExpected"); - $liv['par'] = $langs->trans("PartialWoman"); - $liv['nev'] = $langs->trans("NeverReceived"); - $liv['can'] = $langs->trans("Canceled"); + print '
'.$langs->trans("Delivery")."\n"; + $liv = array(); + $liv[''] = ' '; + $liv['tot'] = $langs->trans("CompleteOrNoMoreReceptionExpected"); + $liv['par'] = $langs->trans("PartialWoman"); + $liv['nev'] = $langs->trans("NeverReceived"); + $liv['can'] = $langs->trans("Canceled"); - print $form->selectarray("type", $liv); + print $form->selectarray("type", $liv); - print '
'.$langs->trans("Comment").'
\n"; - print "
\n"; - print "
"; + print '
'.$langs->trans("Comment").'
\n"; + print "\n"; + print "
"; + } } // List of actions on element diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 367ff6672a5..5f1d04f8bb0 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1685,7 +1685,7 @@ SuppliersSetup=Vendor module setup SuppliersCommandModel=Complete template of purchase order (logo...) SuppliersInvoiceModel=Complete template of vendor invoice (logo...) SuppliersInvoiceNumberingModel=Vendor invoices numbering models -IfSetToYesDontForgetPermission=If set to yes, don't forget to provide permissions to groups or users allowed for the second approval +IfSetToYesDontForgetPermission=If set to a non null value, don't forget to provide permissions to groups or users allowed for the second approval ##### GeoIPMaxmind ##### GeoIPMaxmindSetup=GeoIP Maxmind module setup PathToGeoIPMaxmindCountryDataFile=Path to file containing Maxmind ip to country translation.
Examples:
/usr/local/share/GeoIP/GeoIP.dat
/usr/share/GeoIP/GeoIP.dat diff --git a/htdocs/langs/en_US/orders.lang b/htdocs/langs/en_US/orders.lang index ad895845488..256bd2a7d4d 100644 --- a/htdocs/langs/en_US/orders.lang +++ b/htdocs/langs/en_US/orders.lang @@ -154,5 +154,5 @@ CreateOrders=Create orders ToBillSeveralOrderSelectCustomer=To create an invoice for several orders, click first onto customer, then choose "%s". OptionToSetOrderBilledNotEnabled=Option (from module Workflow) to set order to 'Billed' automatically when invoice is validated is off, so you will have to set status of order to 'Billed' manually. IfValidateInvoiceIsNoOrderStayUnbilled=If invoice validation is 'No', the order will remain to status 'Unbilled' until the invoice is validated. -CloseReceivedSupplierOrdersAutomatically=Close order to "%s" automatically if all products are received. +CloseReceivedSupplierOrdersAutomatically=Close order to status "%s" automatically if all products are received. SetShippingMode=Set shipping mode diff --git a/htdocs/langs/en_US/sendings.lang b/htdocs/langs/en_US/sendings.lang index ede7fea87b7..f3f023f8dcf 100644 --- a/htdocs/langs/en_US/sendings.lang +++ b/htdocs/langs/en_US/sendings.lang @@ -21,6 +21,7 @@ QtyShipped=Qty shipped QtyShippedShort=Qty ship. QtyPreparedOrShipped=Qty prepared or shipped QtyToShip=Qty to ship +QtyToReceive=Qty to receive QtyReceived=Qty received QtyInOtherShipments=Qty in other shipments KeepToShip=Remain to ship @@ -46,6 +47,7 @@ DateDeliveryPlanned=Planned date of delivery RefDeliveryReceipt=Ref delivery receipt StatusReceipt=Status delivery receipt DateReceived=Date delivery received +ClassifyReception=Classify reception SendShippingByEMail=Send shipment by email SendShippingRef=Submission of shipment %s ActionsOnShipping=Events on shipment diff --git a/htdocs/langs/en_US/stocks.lang b/htdocs/langs/en_US/stocks.lang index fd89d432360..17f914b7405 100644 --- a/htdocs/langs/en_US/stocks.lang +++ b/htdocs/langs/en_US/stocks.lang @@ -55,7 +55,7 @@ PMPValue=Weighted average price PMPValueShort=WAP EnhancedValueOfWarehouses=Warehouses value UserWarehouseAutoCreate=Create a user warehouse automatically when creating a user -AllowAddLimitStockByWarehouse=Manage also values for minimum and desired stock per pairing (product-warehouse) in addition to values per product +AllowAddLimitStockByWarehouse=Manage also value for minimum and desired stock per pairing (product-warehouse) in addition to the value for minimum and desired stock per product IndependantSubProductStock=Product stock and subproduct stock are independent QtyDispatched=Quantity dispatched QtyDispatchedShort=Qty dispatched @@ -182,7 +182,7 @@ SelectFournisseur=Vendor filter inventoryOnDate=Inventory INVENTORY_DISABLE_VIRTUAL=Virtual product (kit): do not decrement stock of a child product INVENTORY_USE_MIN_PA_IF_NO_LAST_PA=Use the buy price if no last buy price can be found -INVENTORY_USE_INVENTORY_DATE_FROM_DATEMVT=Stock movement has date of inventory +INVENTORY_USE_INVENTORY_DATE_FOR_DATE_OF_MVT=Stock movements will have the date of inventory (instead of the date of inventory validation) inventoryChangePMPPermission=Allow to change PMP value for a product ColumnNewPMP=New unit PMP OnlyProdsInStock=Do not add product without stock diff --git a/htdocs/langs/fr_FR/orders.lang b/htdocs/langs/fr_FR/orders.lang index a4a8827ca05..bbbeb2638e8 100644 --- a/htdocs/langs/fr_FR/orders.lang +++ b/htdocs/langs/fr_FR/orders.lang @@ -154,5 +154,5 @@ CreateOrders=Créer commandes ToBillSeveralOrderSelectCustomer=Pour créer une facture pour plusieurs commandes, cliquez d'abord sur le client, puis choisir "%s". OptionToSetOrderBilledNotEnabled=L'option (issue du module Workflow) pour définir automatiquement les commandes à 'Facturé' que une facture est validée, est désactivée, aussi vous devrez donc définir le statut de la commande sur 'Facturé' manuellement. IfValidateInvoiceIsNoOrderStayUnbilled=Si la validation de facture est à "Non", la commande restera au statut "Non facturé" jusqu'à ce que la facture soit validée. -CloseReceivedSupplierOrdersAutomatically=Fermer la commande "%s" automatiquement si tous les produits ont été reçus. +CloseReceivedSupplierOrdersAutomatically=Fermer la commande au statut "%s" automatiquement si tous les produits ont été reçus. SetShippingMode=Définir la méthode d'expédition diff --git a/htdocs/product/inventory/class/inventory.class.php b/htdocs/product/inventory/class/inventory.class.php index 62cfc476ba8..85b174ea725 100644 --- a/htdocs/product/inventory/class/inventory.class.php +++ b/htdocs/product/inventory/class/inventory.class.php @@ -59,7 +59,7 @@ class Inventory extends CommonObject * 'type' if the field format. * 'label' the translation key. * 'enabled' is a condition when the field must be managed. - * 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only. Using a negative value means field is not shown by default on list but can be selected for viewing) + * 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only, 3=Visible on create/update/view form only (not list), 4=Visible on list and update/view form only (not create). Using a negative value means field is not shown by default on list but can be selected for viewing) * 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0). * 'index' if we want an index in database. * 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...). @@ -96,7 +96,7 @@ class Inventory extends CommonObject //'fk_user_valid' =>array('type'=>'integer', 'label'=>'UserValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>512), 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'index'=>0, 'position'=>1000), - 'status' => array('type'=>'integer', 'label'=>'Status', 'visible'=>1, 'enabled'=>1, 'position'=>1000, 'default'=>0, 'arrayofkeyval'=>array(0=>'Todo', 1=>'Done', -1=>'Cancel')), + 'status' => array('type'=>'integer', 'label'=>'Status', 'visible'=>4, 'enabled'=>1, 'position'=>1000, 'default'=>0, 'arrayofkeyval'=>array(0=>'ToDo', 1=>'Done', -1=>'Cancel')), ); /** diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php index 7cbd77dd4da..b9156b1837b 100644 --- a/htdocs/reception/card.php +++ b/htdocs/reception/card.php @@ -11,7 +11,7 @@ * Copyright (C) 2015 Claudio Aschieri * Copyright (C) 2016 Ferran Marcet * Copyright (C) 2016 Yasser Carreón - * Copyright (C) 2018 Quentin Vial-Gouteyron + * Copyright (C) 2018 Quentin Vial-Gouteyron * * 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 @@ -56,7 +56,7 @@ if (! empty($conf->projet->enabled)) { require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; } -$langs->loadLangs(array("receptions","companies","bills",'deliveries','orders','stocks','other','propal')); +$langs->loadLangs(array("receptions","companies","bills",'deliveries','orders','stocks','other','propal','sendings')); if (!empty($conf->incoterm->enabled)) $langs->load('incoterm'); if (! empty($conf->productbatch->enabled)) $langs->load('productbatch'); From 08c16ea2e12bad3823928011378ecbd28372e3c9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Sep 2019 02:03:26 +0200 Subject: [PATCH 11/46] Fix bad dir created --- htdocs/core/modules/modReception.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/modReception.class.php b/htdocs/core/modules/modReception.class.php index 6594d7bb04a..f85f5656afe 100644 --- a/htdocs/core/modules/modReception.class.php +++ b/htdocs/core/modules/modReception.class.php @@ -58,7 +58,7 @@ class modReception extends DolibarrModules // Data directories to create when module is enabled $this->dirs = array("/reception/receipt", "/reception/receipt/temp", - "/doctemplates/reception" + "/doctemplates/receptions" ); // Config pages From 16484e1fa3fccb4a44dfa87ff5f051aa5fd4efc5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Sep 2019 02:22:44 +0200 Subject: [PATCH 12/46] Fix balance of td --- htdocs/fourn/commande/dispatch.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php index 48599a5bbf2..17a7443aa9f 100644 --- a/htdocs/fourn/commande/dispatch.php +++ b/htdocs/fourn/commande/dispatch.php @@ -883,8 +883,16 @@ if ($id > 0 || ! empty($ref)) { print '
' . $langs->trans("Warehouse") . '' . $langs->trans("Comment") . '' . $langs->trans("Status") . '
'; if(!empty($reception->id)){ print $reception->getLibStatut(5); } + print ''; - print '
trans("Total"); ?>
trans("Reception"); ?>getNomUrl(1); ?>date_delivery, 'day'); ?>trans("Reception"); ?> + global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) print ' + getNomUrl(1); ?>date_delivery, 'day'); ?>rights->reception->lire) { $total = $total + $objectlink->total_ht; echo price($objectlink->total_ht); } ?>getLibStatut(3); ?> + getLibStatut(3); ?> element != 'order_supplier') { ?> - ">transnoentitiesnoconv("RemoveLink"), 'unlink'); ?>
'.$langs->trans("UseDispatchStatus").''; -if ($conf->use_javascript_ajax) { - print ajax_constantonoff('SUPPLIER_ORDER_USE_DISPATCH_STATUS'); -} else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("SUPPLIER_ORDER_USE_DISPATCH_STATUS", $arrval, $conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS); +if ($conf->reception->enabled) +{ + print ''.$langs->trans("FeatureNotAvailableWithReceptionModule").''; +} +else +{ + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('SUPPLIER_ORDER_USE_DISPATCH_STATUS'); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("SUPPLIER_ORDER_USE_DISPATCH_STATUS", $arrval, $conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS); + } } print "
attributes[$this->table_element]['required'][$key])) $out .= ' fieldrequired'; $out .= '">'; - if (! empty($extrafields->attributes[$object->table_element]['help'][$key])) $out .= $form->textwithpicto($labeltoshow, $extrafields->attributes[$object->table_element]['help'][$key]); + if (! empty($extrafields->attributes[$this->table_element]['help'][$key])) $out .= $form->textwithpicto($labeltoshow, $extrafields->attributes[$this->table_element]['help'][$key]); else $out .= $labeltoshow; $out .= ''; + //$out .=''; switch($mode) { case "view": @@ -6593,6 +6599,11 @@ abstract class CommonObject $out .= '
">"> - attributes[$this->table_element]['required'][$key])) $out .= ' fieldrequired'; $out .= '">'; - if (! empty($extrafields->attributes[$object->table_element]['help'][$key])) $out .= $form->textwithpicto($labeltoshow, $extrafields->attributes[$object->table_element]['help'][$key]); + if (! empty($extrafields->attributes[$this->table_element]['help'][$key])) $out .= $form->textwithpicto($labeltoshow, $extrafields->attributes[$this->table_element]['help'][$key]); else $out .= $labeltoshow; $out .= ''; + //$out .=''; switch($mode) { case "view": @@ -6511,6 +6517,11 @@ abstract class CommonObject $out .= '
">"> -
'.$langs->trans("Total").' '; - if ($total != $object->amount) print img_warning("AmountOfFileDiffersFromSumOfInvoices"); + if (empty($offset) && $num <= $limit) // If we have all record on same page, then the following test/warning can be done + { + if ($total != $object->amount) print img_warning("TotalAmountOfdirectDebitOrderDiffersFromSumOfLines"); + } print price($total); print " 
'; - - print ''; - print_liste_field_titre("Bill", $_SERVER["PHP_SELF"]); - print_liste_field_titre("Company", $_SERVER["PHP_SELF"]); - print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "", "", $param, 'class="right"'); - print_liste_field_titre("DateRequest", $_SERVER["PHP_SELF"], "", "", $param, 'class="center"'); - print_liste_field_titre(''); - print ''; - - print ''; - print ''; - print ''; - print ''; - print ''; - // Action column - print ''; - print ''; - - $users = array(); - - while ($i < min($num, $limit)) - { - $obj = $db->fetch_object($resql); - - print ''; - - // Ref facture - print ''; - - print ''; - - print ''; - - print ''; - - print ''; - - print ''; - $i++; - } - - print "
'; - $searchpicto=$form->showFilterAndCheckAddButtons($massactionbutton?1:0, 'checkforselect', 1); - print $searchpicto; - print '
'; - $invoicestatic->id=$obj->rowid; - $invoicestatic->ref=$obj->ref; - print $invoicestatic->getNomUrl(1, 'withdraw'); - print ''; - $thirdpartystatic->id=$obj->socid; - $thirdpartystatic->name=$obj->name; - print $thirdpartystatic->getNomUrl(1, 'customer'); - print ''.price($obj->total_ttc).''.dol_print_date($db->jdate($obj->date_demande), 'day').'

"; - - print ''; +} +// if total of record found is smaller than limit, no need to do paging and to restart another select with limits set. +if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) +{ + $num = $nbtotalofrecords; } else { - dol_print_error($db); + $sql.= $db->plimit($limit+1, $offset); + + $resql=$db->query($sql); + if (! $resql) + { + dol_print_error($db); + exit; + } + + $num = $db->num_rows($resql); } + + +$newcardbutton = ''.$langs->trans("Back").''; + +print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_generic', 0, $newcardbutton, '', $limit); + +print '
'; +if ($optioncss != '') print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; + + +print ''; + +print ''; +print_liste_field_titre("Bill", $_SERVER["PHP_SELF"]); +print_liste_field_titre("Company", $_SERVER["PHP_SELF"]); +print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "", "", $param, 'class="right"'); +print_liste_field_titre("DateRequest", $_SERVER["PHP_SELF"], "", "", $param, 'class="center"'); +print_liste_field_titre(''); +print ''; + +print ''; +print ''; +print ''; +print ''; +print ''; +// Action column +print ''; +print ''; + +$users = array(); + +$i = 0; +while ($i < min($num, $limit)) +{ + $obj = $db->fetch_object($resql); + if (empty($obj)) break; // Should not happen + + print ''; + + // Ref facture + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + $i++; +} + +print "
'; +$searchpicto=$form->showFilterAndCheckAddButtons($massactionbutton?1:0, 'checkforselect', 1); +print $searchpicto; +print '
'; + $invoicestatic->id=$obj->rowid; + $invoicestatic->ref=$obj->ref; + print $invoicestatic->getNomUrl(1, 'withdraw'); + print ''; + $thirdpartystatic->id=$obj->socid; + $thirdpartystatic->name=$obj->name; + print $thirdpartystatic->getNomUrl(1, 'customer'); + print ''.price($obj->total_ttc).''.dol_print_date($db->jdate($obj->date_demande), 'day').'

"; + +print '
'; + + // End of page llxFooter(); $db->close(); diff --git a/htdocs/compta/prelevement/index.php b/htdocs/compta/prelevement/index.php index 1be716f8f61..44db7dd2625 100644 --- a/htdocs/compta/prelevement/index.php +++ b/htdocs/compta/prelevement/index.php @@ -71,6 +71,7 @@ $thirdpartystatic=new Societe($db); $invoicestatic=new Facture($db); $bprev = new BonPrelevement($db); + print ''; print ''; @@ -100,6 +101,8 @@ if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX $sql.= " , ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; $sql.= " WHERE s.rowid = f.fk_soc"; $sql.= " AND f.entity IN (".getEntity('invoice').")"; +$sql.= " AND f.total_ttc > 0"; +$sql.= " AND f.fk_statut = ".Facture::STATUS_VALIDATED; $sql.= " AND pfd.traite = 0 AND pfd.fk_facture = f.rowid"; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($socid) $sql.= " AND f.fk_soc = ".$socid; From 57a15b88fa3a7ce1a264f39d379432073b52b910 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Sep 2019 14:07:42 +0200 Subject: [PATCH 26/46] Fix UMR --- htdocs/langs/en_US/withdrawals.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/withdrawals.lang b/htdocs/langs/en_US/withdrawals.lang index 88e5eaf128c..b1d6e30e329 100644 --- a/htdocs/langs/en_US/withdrawals.lang +++ b/htdocs/langs/en_US/withdrawals.lang @@ -76,7 +76,7 @@ WithdrawalFile=Withdrawal file SetToStatusSent=Set to status "File Sent" ThisWillAlsoAddPaymentOnInvoice=This will also record payments to invoices and will classify them as "Paid" if remain to pay is null StatisticsByLineStatus=Statistics by status of lines -RUM=Unique Mandate Reference (UMR) +RUM=UMR DateRUM=Mandate signature date RUMLong=Unique Mandate Reference RUMWillBeGenerated=If empty, a UMR (Unique Mandate Reference) will be generated once the bank account information is saved. From bc0b8dfad06163a8c073d5dafe795dcc0278d2f3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Sep 2019 14:24:33 +0200 Subject: [PATCH 27/46] FIX Consistency in direct debit order lists. FIX Confirmation of deletion --- htdocs/compta/prelevement/card.php | 19 ++++++++++++++++++- .../class/bonprelevement.class.php | 4 ++-- htdocs/compta/prelevement/create.php | 9 ++++++--- htdocs/compta/prelevement/demandes.php | 1 + htdocs/langs/en_US/main.lang | 1 + .../modulebuilder/template/myobject_card.php | 2 +- 6 files changed, 29 insertions(+), 7 deletions(-) diff --git a/htdocs/compta/prelevement/card.php b/htdocs/compta/prelevement/card.php index b8aa09eae60..bf95a35f1fd 100644 --- a/htdocs/compta/prelevement/card.php +++ b/htdocs/compta/prelevement/card.php @@ -239,6 +239,23 @@ if ($id > 0 || $ref) dol_fiche_end(); + $formconfirm = ''; + + // Confirmation to delete + if ($action == 'delete') + { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('Delete'), $langs->trans('ConfirmDeleteObject'), 'confirm_delete', '', 0, 1); + } + + // Call Hook formConfirm + /*$parameters = array(); + $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; + elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint;*/ + + // Print form confirm + print $formconfirm; + if (empty($object->date_trans) && $user->rights->prelevement->bons->send && $action=='settransmitted') { @@ -298,7 +315,7 @@ if ($id > 0 || $ref) print "id."\">".$langs->trans("ClassCredited").""; } - print "id."\">".$langs->trans("Delete").""; + print "id."\">".$langs->trans("Delete").""; print ""; } diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 6f8a7431b0e..d37e8be9412 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -1629,8 +1629,8 @@ class BonPrelevement extends CommonObject public static function buildRumNumber($row_code_client, $row_datec, $row_drum) { global $langs; - $pre = $langs->trans('RUM').'-'; - return $pre.$row_code_client.'-'.$row_drum.'-'.date('U', $row_datec); + $pre = substr(dol_string_nospecial(dol_string_unaccent($langs->transnoentitiesnoconv('RUM'))), 0, 3); // Must always be on 3 char ('RUM' or 'UMR'. This is a protection against bad translation) + return $pre.'-'.$row_code_client.'-'.$row_drum.'-'.date('U', $row_datec); } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps diff --git a/htdocs/compta/prelevement/create.php b/htdocs/compta/prelevement/create.php index ddbec62e413..3145bd20598 100644 --- a/htdocs/compta/prelevement/create.php +++ b/htdocs/compta/prelevement/create.php @@ -37,7 +37,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/prelevement.lib.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Load translation files required by the page -$langs->loadLangs(array('banks', 'categories', 'widthdrawals', 'companies', 'bills')); +$langs->loadLangs(array('banks', 'categories', 'withdrawals', 'companies', 'bills')); // Security check if ($user->societe_id) $socid=$user->societe_id; @@ -105,6 +105,7 @@ if (empty($reshook)) /* * View */ + $form = new Form($db); $thirdpartystatic=new Societe($db); @@ -206,9 +207,11 @@ $sql.= " ".MAIN_DB_PREFIX."societe as s,"; $sql.= " ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; $sql.= " WHERE s.rowid = f.fk_soc"; $sql.= " AND f.entity IN (".getEntity('invoice').")"; +$sql.= " AND f.fk_statut = ".Facture::STATUS_VALIDATED; +$sql.= " AND f.total_ttc > 0"; $sql.= " AND pfd.traite = 0"; $sql.= " AND pfd.fk_facture = f.rowid"; -if ($socid) $sql.= " AND f.fk_soc = ".$socid; +if ($socid > 0) $sql.= " AND f.fk_soc = ".$socid; $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) @@ -292,7 +295,7 @@ if ($resql) $i++; } } - else print ''; + else print ''; print "
'.$langs->trans("Statistics").'
'.$langs->trans("None").'
'.$langs->trans("None").'
"; print ""; print "
\n"; diff --git a/htdocs/compta/prelevement/demandes.php b/htdocs/compta/prelevement/demandes.php index 1caf62f1491..a34fde042e5 100644 --- a/htdocs/compta/prelevement/demandes.php +++ b/htdocs/compta/prelevement/demandes.php @@ -92,6 +92,7 @@ if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc. if ($socid) $sql.= " AND f.fk_soc = ".$socid; if (!$status) $sql.= " AND pfd.traite = 0"; if ($status) $sql.= " AND pfd.traite = ".$status; +$sql.= " AND f.total_ttc > 0"; $sql.= " AND f.fk_statut = ".Facture::STATUS_VALIDATED; $sql.= " AND pfd.fk_facture = f.rowid"; if (dol_strlen(trim(GETPOST('search_societe', 'alpha')))) diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 5e55597c306..f6753f1b87a 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -821,6 +821,7 @@ Mandatory=Mandatory Hello=Hello GoodBye=GoodBye Sincerely=Sincerely +ConfirmDeleteObject=Are you sure you want to delete this object? DeleteLine=Delete line ConfirmDeleteLine=Are you sure you want to delete this line? NoPDFAvailableForDocGenAmongChecked=No PDF were available for the document generation among checked record diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php index 28c817658f6..72bc424c53c 100644 --- a/htdocs/modulebuilder/template/myobject_card.php +++ b/htdocs/modulebuilder/template/myobject_card.php @@ -256,7 +256,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Confirmation to delete if ($action == 'delete') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteMyObject'), $langs->trans('ConfirmDeleteMyObject'), 'confirm_delete', '', 0, 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteMyObject'), $langs->trans('ConfirmDeleteObject'), 'confirm_delete', '', 0, 1); } // Confirmation to delete line if ($action == 'deleteline') From 74203a68964997354bf524278f7b17e90999d416 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Sep 2019 16:01:54 +0200 Subject: [PATCH 28/46] Fix phpcs --- test/phpunit/LesscTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/test/phpunit/LesscTest.php b/test/phpunit/LesscTest.php index 634b362a7b2..70ed161c260 100644 --- a/test/phpunit/LesscTest.php +++ b/test/phpunit/LesscTest.php @@ -159,7 +159,6 @@ class LesscTest extends PHPUnit\Framework\TestCase //print '
'.$contentforlessc.'
'; $result = $lesscobj->compile($contentforlessc); //var_dump($contentforlessc); exit; - } catch (exception $e) { //echo "failed to compile lessc"; dol_syslog("Failed to compile the CSS with lessc: ".$e->getMessage(), LOG_WARNING); From 018a43e1d3353a97d58fdc6fdd24f1c0fa9136a0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Sep 2019 18:57:34 +0200 Subject: [PATCH 29/46] Fix --- htdocs/supplier_proposal/class/supplier_proposal.class.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index 142917a10d3..f6866569f13 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -324,9 +324,6 @@ class SupplierProposal extends CommonObject $supplier_proposalligne->rang=-1; $supplier_proposalligne->info_bits=2; - // TODO deprecated - $supplier_proposalligne->price=-$remise->amount_ht; - $supplier_proposalligne->total_ht = -$remise->amount_ht; $supplier_proposalligne->total_tva = -$remise->amount_tva; $supplier_proposalligne->total_ttc = -$remise->amount_ttc; @@ -1350,7 +1347,6 @@ class SupplierProposal extends CommonObject $line->subprice = $objp->subprice; $line->fk_remise_except = $objp->fk_remise_except; $line->remise_percent = $objp->remise_percent; - $line->price = $objp->price; // TODO deprecated $line->info_bits = $objp->info_bits; $line->total_ht = $objp->total_ht; @@ -2364,7 +2360,6 @@ class SupplierProposal extends CommonObject $line->desc=$langs->trans("Description")." ".$xnbp; $line->qty=1; $line->subprice=100; - $line->price=100; $line->tva_tx=19.6; $line->localtax1_tx=0; $line->localtax2_tx=0; From 231725e3511d75c4a12ed71a0c53a3845f58d68c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Sep 2019 19:12:43 +0200 Subject: [PATCH 30/46] Fix scrutinizer --- htdocs/admin/commande.php | 1 - htdocs/asset/info.php | 7 +++++-- htdocs/core/class/fiscalyear.class.php | 8 ++++---- htdocs/cron/class/cronjob.class.php | 7 ++++--- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/htdocs/admin/commande.php b/htdocs/admin/commande.php index 455175220a8..40514cd1890 100644 --- a/htdocs/admin/commande.php +++ b/htdocs/admin/commande.php @@ -438,7 +438,6 @@ foreach ($dirmodels as $reldir) if ($modulequalified) { - $var = !$var; print ''; print (empty($module->name)?$name:$module->name); print "\n"; diff --git a/htdocs/asset/info.php b/htdocs/asset/info.php index 462abf17342..45157e9b7a5 100644 --- a/htdocs/asset/info.php +++ b/htdocs/asset/info.php @@ -44,15 +44,18 @@ $object->fetch($id); * Actions */ + + /* * View */ + +$form = new Form($db); + $title = $langs->trans('Asset') . " - " . $langs->trans('Info'); $helpurl = ""; llxHeader('', $title, $helpurl); -$form = new Form($db); - $object->info($id); $head = asset_prepare_head($object); diff --git a/htdocs/core/class/fiscalyear.class.php b/htdocs/core/class/fiscalyear.class.php index 5593b4a90a4..90d824b7263 100644 --- a/htdocs/core/class/fiscalyear.class.php +++ b/htdocs/core/class/fiscalyear.class.php @@ -63,28 +63,28 @@ class Fiscalyear extends CommonObject * @var string fiscal year label */ public $label; - + /** * Date start (date_start) * * @var integer */ public $date_start; - + /** * Date end (date_end) * * @var integer */ public $date_end; - + /** * Date creation record (datec) * * @var integer */ public $datec; - + public $statut; // 0=open, 1=closed /** diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php index 7934a628880..0e12da80cfc 100644 --- a/htdocs/cron/class/cronjob.class.php +++ b/htdocs/cron/class/cronjob.class.php @@ -894,14 +894,15 @@ class Cronjob extends CommonObject /** * Load object information * - * @return int + * @param int $id ID + * @return int <0 if KO, >0 if OK */ - public function info() + public function info($id) { $sql = "SELECT"; $sql.= " f.rowid, f.datec, f.tms, f.fk_user_mod, f.fk_user_author"; $sql.= " FROM ".MAIN_DB_PREFIX."cronjob as f"; - $sql.= " WHERE f.rowid = ".$this->id; + $sql.= " WHERE f.rowid = ".$id; dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $resql=$this->db->query($sql); From 89e1cdff61556c6fd453794b2753b4dd21f97329 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Sep 2019 19:41:15 +0200 Subject: [PATCH 31/46] Debug module datapolicy --- htdocs/core/modules/modDataPolicy.class.php | 2 +- htdocs/datapolicy/class/datapolicy.class.php | 15 ++++++++++- .../datapolicy/class/datapolicycron.class.php | 27 ++++++++++++------- htdocs/langs/en_US/cron.lang | 1 + 4 files changed, 34 insertions(+), 11 deletions(-) diff --git a/htdocs/core/modules/modDataPolicy.class.php b/htdocs/core/modules/modDataPolicy.class.php index a08ce2f7873..2c6d749d1ee 100644 --- a/htdocs/core/modules/modDataPolicy.class.php +++ b/htdocs/core/modules/modDataPolicy.class.php @@ -187,7 +187,7 @@ class modDataPolicy extends DolibarrModules { // Cronjobs (List of cron jobs entries to add when module is enabled) // unit_frequency must be 60 for minute, 3600 for hour, 86400 for day, 604800 for week $this->cronjobs = array( - 0 => array('label' => 'DATAPOLICY Cron', 'jobtype' => 'method', 'class' => '/datapolicy/class/datapolicyCron.class.php', 'objectname' => 'DataPolicyCron', 'method' => 'exec', 'parameters' => '', 'comment' => 'Clean data', 'frequency' => 1, 'unitfrequency' => 86400, 'status' => 1, 'test' => '$conf->datapolicy->enabled'), + 0 => array('label' => 'DATAPOLICYJob', 'jobtype' => 'method', 'class' => 'datapolicy/class/datapolicycron.class.php', 'objectname' => 'DataPolicyCron', 'method' => 'cleanDataForDataPolicy', 'parameters' => '', 'comment' => 'Clean data', 'frequency' => 1, 'unitfrequency' => 86400, 'status' => 1, 'test' => '$conf->datapolicy->enabled'), //1 => array('label' => 'DATAPOLICY Mailing', 'jobtype' => 'method', 'class' => '/datapolicy/class/datapolicyCron.class.php', 'objectname' => 'RgpdCron', 'method' => 'sendMailing', 'parameters' => '', 'comment' => 'Comment', 'frequency' => 1, 'unitfrequency' => 86400, 'status' => 0, 'test' => true) ); // Example: $this->cronjobs=array(0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'/dir/class/file.class.php', 'objectname'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>true), diff --git a/htdocs/datapolicy/class/datapolicy.class.php b/htdocs/datapolicy/class/datapolicy.class.php index bf1033084d5..c4b3cd2458d 100644 --- a/htdocs/datapolicy/class/datapolicy.class.php +++ b/htdocs/datapolicy/class/datapolicy.class.php @@ -30,6 +30,16 @@ include_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent.class.php'; */ class DataPolicy { + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + } + /** * getAllContactNotInformed * @@ -200,7 +210,6 @@ class DataPolicy } else { $result4 = $mailfile->sendfile(); if (!$error) { - $resultmasssend .= $langs->trans("MailSent") . ': ' . $sendto . "
"; $contact->array_options['options_datapolicy_send'] = date('Y-m-d', time()); $contact->update($contact->id); @@ -301,6 +310,10 @@ class DataPolicy $sendto = $adherent->email; + // TODO Use a dolibarr email template + $s = 'TXTLINKDATAPOLICIESSUBJECT_' . $l; + $ma = 'TXTLINKDATAPOLICIESMESSAGE_' . $l; + $code= md5($adherent->email); if (!empty($adherent->default_lang)) { $l = $adherent->default_lang; diff --git a/htdocs/datapolicy/class/datapolicycron.class.php b/htdocs/datapolicy/class/datapolicycron.class.php index 656831eed2f..a938724ad73 100644 --- a/htdocs/datapolicy/class/datapolicycron.class.php +++ b/htdocs/datapolicy/class/datapolicycron.class.php @@ -27,12 +27,24 @@ */ class DataPolicyCron { + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + } + + /** * Function exec + * CAN BE A CRON TASK * - * @return boolean + * @return int 0 if OK, <>0 if KO (this function is used also by cron so only 0 is OK) */ - public function exec() + public function cleanDataForDataPolicy() { global $conf, $db, $langs, $user; @@ -479,14 +491,10 @@ class DataPolicyCron $db->query($sql); } } else { - if (DOL_VERSION < 8) { + if ($object->element == 'adherent') { $ret = $object->delete($obj->rowid, $user); } else { - if ($object->element == 'adherent') { - $ret = $object->delete($obj->rowid); - } else { - $ret = $object->delete(); - } + $ret = $object->delete($user); } } @@ -495,7 +503,8 @@ class DataPolicyCron } } } - return true; + + return 0; } diff --git a/htdocs/langs/en_US/cron.lang b/htdocs/langs/en_US/cron.lang index aee4d7bb988..1de1251831a 100644 --- a/htdocs/langs/en_US/cron.lang +++ b/htdocs/langs/en_US/cron.lang @@ -81,3 +81,4 @@ JobDisabled=Job disabled MakeLocalDatabaseDumpShort=Local database backup MakeLocalDatabaseDump=Create a local database dump. Parameters are: compression ('gz' or 'bz' or 'none'), backup type ('mysql', 'pgsql', 'auto'), 1, 'auto' or filename to build, number of backup files to keep WarningCronDelayed=Attention, for performance purpose, whatever is next date of execution of enabled jobs, your jobs may be delayed to a maximum of %s hours, before being run. +DATAPOLICYJob=Data cleaner and anonymizer From f338a5f9ad6e27c3ff341e7001d7825a901afc64 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Sep 2019 19:56:00 +0200 Subject: [PATCH 32/46] Debug module datapolicy --- htdocs/core/modules/modDataPolicy.class.php | 1 - .../datapolicy/class/datapolicycron.class.php | 92 +++++++++++-------- 2 files changed, 56 insertions(+), 37 deletions(-) diff --git a/htdocs/core/modules/modDataPolicy.class.php b/htdocs/core/modules/modDataPolicy.class.php index 2c6d749d1ee..13095010a55 100644 --- a/htdocs/core/modules/modDataPolicy.class.php +++ b/htdocs/core/modules/modDataPolicy.class.php @@ -188,7 +188,6 @@ class modDataPolicy extends DolibarrModules { // unit_frequency must be 60 for minute, 3600 for hour, 86400 for day, 604800 for week $this->cronjobs = array( 0 => array('label' => 'DATAPOLICYJob', 'jobtype' => 'method', 'class' => 'datapolicy/class/datapolicycron.class.php', 'objectname' => 'DataPolicyCron', 'method' => 'cleanDataForDataPolicy', 'parameters' => '', 'comment' => 'Clean data', 'frequency' => 1, 'unitfrequency' => 86400, 'status' => 1, 'test' => '$conf->datapolicy->enabled'), - //1 => array('label' => 'DATAPOLICY Mailing', 'jobtype' => 'method', 'class' => '/datapolicy/class/datapolicyCron.class.php', 'objectname' => 'RgpdCron', 'method' => 'sendMailing', 'parameters' => '', 'comment' => 'Comment', 'frequency' => 1, 'unitfrequency' => 86400, 'status' => 0, 'test' => true) ); // Example: $this->cronjobs=array(0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'/dir/class/file.class.php', 'objectname'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>true), // 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24, 'status'=>0, 'test'=>true) diff --git a/htdocs/datapolicy/class/datapolicycron.class.php b/htdocs/datapolicy/class/datapolicycron.class.php index a938724ad73..6c1a740bd98 100644 --- a/htdocs/datapolicy/class/datapolicycron.class.php +++ b/htdocs/datapolicy/class/datapolicycron.class.php @@ -19,7 +19,7 @@ /** * \file htdocs/datapolicy/class/datapolicycron.class.php * \ingroup datapolicy - * \brief Example hook overload. + * \brief File for cron task of module DataPolicy */ /** @@ -46,10 +46,14 @@ class DataPolicyCron */ public function cleanDataForDataPolicy() { - global $conf, $db, $langs, $user; + global $conf, $langs, $user; $langs->load('datapolicy@datapolicy'); + $error = 0; + $errormsg = ''; + $nbupdated = $nbdeleted = 0; + // FIXME Removed hardcoded values of id $arrayofparameters=array( 'DATAPOLICIES_TIERS_CLIENT' => array( @@ -458,14 +462,18 @@ class DataPolicyCron ), ); - foreach ($arrayofparameters as $key => $params) { - if ($conf->global->$key != '' && is_numeric($conf->global->$key) && (int) $conf->global->$key > 0) { + $this->db->begin(); + foreach ($arrayofparameters as $key => $params) + { + if ($conf->global->$key != '' && is_numeric($conf->global->$key) && (int) $conf->global->$key > 0) + { $sql = sprintf($params['sql'], (int) $conf->entity, (int) $conf->global->$key, (int) $conf->global->$key); $resql = $db->query($sql); - if ($resql && $db->num_rows($resql) > 0) { + if ($resql && $db->num_rows($resql) > 0) + { $num = $db->num_rows($resql); $i = 0; @@ -473,29 +481,51 @@ class DataPolicyCron require_once $params['file']; $object = new $params['class']($db); - while ($i < $num) + while ($i < $num && ! $error) { $obj = $db->fetch_object($resql); $object->fetch($obj->rowid); $object->id = $obj->rowid; - if ($object->isObjectUsed($obj->rowid) > 0) { + if ($object->isObjectUsed($obj->rowid) > 0) // If object to clean is used + { foreach ($params['fields_anonym'] as $fields => $val) { $object->$fields = $val; } - $object->update($obj->rowid, $user); - if ($params['class'] == 'Societe') { - // On supprime les contacts associé - $sql = "DELETE FROM ".MAIN_DB_PREFIX."socpeople WHERE fk_soc = " . $obj->rowid; - $db->query($sql); + $result = $object->update($obj->rowid, $user); + if ($result > 0) + { + if ($params['class'] == 'Societe') { + // We delete contacts of thirdparty + $sql = "DELETE FROM ".MAIN_DB_PREFIX."socpeople WHERE fk_soc = " . $obj->rowid; + $result = $this->db->query($sql); + if ($result < 0) + { + $errormsg = $this->db->lasterror(); + $error++; + } + } } - } else { + else + { + $errormsg = $object->error; + $error++; + } + $nbupdated++; + } else { // If object to clean is not used if ($object->element == 'adherent') { - $ret = $object->delete($obj->rowid, $user); + $result = $object->delete($obj->rowid, $user); } else { - $ret = $object->delete($user); + $result = $object->delete($user); } + if ($result < 0) + { + $errormsg = $object->error; + $error++; + } + + $nbdeleted++; } $i++; @@ -504,27 +534,17 @@ class DataPolicyCron } } + $this->db->commit(); + + if (! $error) + { + $this->output = $nbupdated.' record updated, '.$nbdeleted.' record deleted'; + } + else + { + $this->error = $errormsg; + } + return 0; } - - - /** - * sendMailing - * - * @return boolean - */ - public function sendMailing() - { - global $conf, $db, $langs, $user; - - $langs->load('datapolicy@datapolicy'); - - require_once DOL_DOCUMENT_ROOT . '/datapolicy/class/datapolicy.class.php'; - - $contacts = new DataPolicy($db); - $contacts->getAllContactNotInformed(); - $contacts->getAllCompaniesNotInformed(); - $contacts->getAllAdherentsNotInformed(); - return true; - } } From 397e656161aa5fbf7f86fa7d2f74e7d8e84596b2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 7 Sep 2019 10:43:35 +0200 Subject: [PATCH 33/46] Update doc --- htdocs/conf/conf.php.example | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/conf/conf.php.example b/htdocs/conf/conf.php.example index 4d26fef7965..84fc87d35f8 100644 --- a/htdocs/conf/conf.php.example +++ b/htdocs/conf/conf.php.example @@ -152,7 +152,9 @@ $dolibarr_main_db_collation='utf8_unicode_ci'; // dolibarr_main_instance_unique_id -// An ID that is unique for each installation. +// An secret ID that is unique for each installation. +// This value is also visible and never propagated outside of Dolibarr, so it can be used as a salt / key for some encryption. +// To propagate a unique key, you propagate the value concatenated with a string with a hash function. Example: md5('dolibarr'+dolibarr_main_instance_unique_id) // Default value: randomly defined during installation // Examples: // $dolibarr_main_instance_unique_id='84b5bc91f83b56e458db71e0adac2b62'; From 30d2f84eb71082bdb9ff4248ca4063cc9803ebc1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 7 Sep 2019 10:58:20 +0200 Subject: [PATCH 34/46] Remove a label that is no more used --- htdocs/core/menus/standard/eldy.lib.php | 2 +- htdocs/fourn/class/fournisseur.commande.class.php | 1 - htdocs/langs/en_US/orders.lang | 4 ---- 3 files changed, 1 insertion(+), 6 deletions(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index c6b5eb46515..e3f26b1ccd7 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -924,7 +924,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=6,7", $langs->trans("StatusSupplierOrderCanceled"), 2, $user->rights->fournisseur->commande->lire); $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&statut=9", $langs->trans("StatusSupplierOrderRefused"), 2, $user->rights->fournisseur->commande->lire); } - // Billed is another field. We should add instead a dedicated filter on list. if ($usemenuhider || empty($leftmenu) || $leftmenu=="orders_suppliers") $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&billed=1", $langs->trans("StatusSupplierOrderBilled"), 2, $user->rights->fournisseur->commande->lire); + // Billed is another field. We should add instead a dedicated filter on list. if ($usemenuhider || empty($leftmenu) || $leftmenu=="orders_suppliers") $newmenu->add("/fourn/commande/list.php?leftmenu=orders_suppliers&billed=1", $langs->trans("Billed"), 2, $user->rights->fournisseur->commande->lire); $newmenu->add("/commande/stats/index.php?leftmenu=orders_suppliers&mode=supplier", $langs->trans("Statistics"), 1, $user->rights->fournisseur->commande->lire); diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index ddaa74e2525..64c7ca73b7b 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -648,7 +648,6 @@ class CommandeFournisseur extends CommonOrder $this->statuts[5] = 'StatusSupplierOrderReceivedAll'; $this->statuts[6] = 'StatusSupplierOrderCanceled'; // Approved->Canceled $this->statuts[7] = 'StatusSupplierOrderCanceled'; // Process running->canceled - //$this->statuts[8] = 'StatusSupplierOrderBilled'; // Everything is finished, order received totally and bill received $this->statuts[9] = 'StatusSupplierOrderRefused'; // List of language codes for status diff --git a/htdocs/langs/en_US/orders.lang b/htdocs/langs/en_US/orders.lang index 6a99b7e5a6b..3197cc12bca 100644 --- a/htdocs/langs/en_US/orders.lang +++ b/htdocs/langs/en_US/orders.lang @@ -37,7 +37,6 @@ StatusOrderDeliveredShort=Delivered StatusOrderToBillShort=Delivered StatusOrderApprovedShort=Approved StatusOrderRefusedShort=Refused -StatusOrderBilledShort=Billed StatusOrderToProcessShort=To process StatusOrderReceivedPartiallyShort=Partially received StatusOrderReceivedAllShort=Products received @@ -50,7 +49,6 @@ StatusOrderProcessed=Processed StatusOrderToBill=Delivered StatusOrderApproved=Approved StatusOrderRefused=Refused -StatusOrderBilled=Billed StatusOrderReceivedPartially=Partially received StatusOrderReceivedAll=All products received ShippingExist=A shipment exists @@ -170,7 +168,6 @@ StatusSupplierOrderDeliveredShort=Delivered StatusSupplierOrderToBillShort=Delivered StatusSupplierOrderApprovedShort=Approved StatusSupplierOrderRefusedShort=Refused -StatusSupplierOrderBilledShort=Billed StatusSupplierOrderToProcessShort=To process StatusSupplierOrderReceivedPartiallyShort=Partially received StatusSupplierOrderReceivedAllShort=Products received @@ -183,6 +180,5 @@ StatusSupplierOrderProcessed=Processed StatusSupplierOrderToBill=Delivered StatusSupplierOrderApproved=Approved StatusSupplierOrderRefused=Refused -StatusSupplierOrderBilled=Billed StatusSupplierOrderReceivedPartially=Partially received StatusSupplierOrderReceivedAll=All products received \ No newline at end of file From eb7f9642681b353790915e4c983b1151fff6ae56 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 7 Sep 2019 11:25:11 +0200 Subject: [PATCH 35/46] Update objectline_create.tpl.php --- htdocs/core/tpl/objectline_create.tpl.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index 458872cf99b..480e0975f00 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -647,7 +647,7 @@ jQuery(document).ready(function() { jQuery('#trlinefordates').show(); global->EDIT_PREDEF_PRICEHT)) + if (!empty($conf->global->MAIN_EDIT_PREDEF_PRICEHT)) { ?> // get the HT price for the product and display it @@ -842,10 +842,9 @@ function setforpredef() { jQuery("#prod_entry_mode_free").prop('checked',false).change(); jQuery("#prod_entry_mode_predef").prop('checked',true).change(); - global->EDIT_PREDEF_PRICEHT)) - {?> + global->MAIN_EDIT_PREDEF_PRICEHT)) { ?> jQuery("#price_ht").val('').hide(); - + jQuery("#multicurrency_price_ht").hide(); jQuery("#price_ttc").hide(); // May no exists jQuery("#fourn_ref").hide(); From c7a90ad52803ddae84a9a517acdaf1ddff9edb8d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 7 Sep 2019 11:25:58 +0200 Subject: [PATCH 36/46] Update product.php --- htdocs/product/admin/product.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/htdocs/product/admin/product.php b/htdocs/product/admin/product.php index a8116314dda..392ae8eb081 100644 --- a/htdocs/product/admin/product.php +++ b/htdocs/product/admin/product.php @@ -155,9 +155,6 @@ if ($action == 'other') $resql_new = $db->query($sql_new); } } - - $value = GETPOST('activate_EditPredifinedPriceHT','alpha'); - $res = dolibarr_set_const($db, "EDIT_PREDEF_PRICEHT", $value,'chaine',0,'',$conf->entity); } if ($action == 'specimen') // For products From a5d04e8fd5d7725abcb3c4c463b061db14290b40 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 7 Sep 2019 11:26:21 +0200 Subject: [PATCH 37/46] Update product.php --- htdocs/product/admin/product.php | 8 -------- 1 file changed, 8 deletions(-) diff --git a/htdocs/product/admin/product.php b/htdocs/product/admin/product.php index 392ae8eb081..45f938431c3 100644 --- a/htdocs/product/admin/product.php +++ b/htdocs/product/admin/product.php @@ -675,14 +675,6 @@ if (! empty($conf->fournisseur->enabled)) print ''; } -// Activate price ht edition for predefined product on line add -print ''; -print ''.$langs->trans("EditPredifinedPriceHTAbility").''; -print ''; -print $form->selectyesno("activate_EditPredifinedPriceHT",$conf->global->EDIT_PREDEF_PRICEHT,1); -print ''; -print ''; - if (! empty($conf->global->PRODUCT_CANVAS_ABILITY)) { // Add canvas feature From 5d6ccfdf0035582a01e9375a3bc31629e4bc8d50 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 7 Sep 2019 13:12:39 +0200 Subject: [PATCH 38/46] Fix phpcs --- htdocs/core/tpl/objectline_create.tpl.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index b11006ac9bb..1f0897f7e98 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -685,10 +685,10 @@ jQuery(document).ready(function() { jQuery("#price_ht").val(data.price_ht); }, 'json'); - + rights->margins->creer) { $langs->load('stocks'); @@ -850,10 +850,10 @@ function setforpredef() { console.log("Call setforpredef. We hide some fields and show dates"); jQuery("#select_type").val(-1); jQuery("#prod_entry_mode_free").prop('checked',false).change(); - jQuery("#prod_entry_mode_predef").prop('checked',true).change(); + jQuery("#prod_entry_mode_predef").prop('checked',true).change( global->MAIN_EDIT_PREDEF_PRICEHT)) { ?> jQuery("#price_ht").val('').hide(); - + jQuery("#price_ht").val('') jQuery("#price_ht, #multicurrency_price_ht, #price_ttc, #fourn_ref, #tva_tx, #title_vat, #title_up_ht, #title_up_ht_currency, #title_up_ttc, #title_up_ttc_currency").hide(); jQuery("#np_marginRate, #np_markRate, .np_marginRate, .np_markRate, #units, #title_units").hide(); From 44cb9738d696067fa8188151f776a8e33c6f5baf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 7 Sep 2019 14:35:47 +0200 Subject: [PATCH 39/46] Fix trans --- htdocs/langs/en_US/admin.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index a84a052094a..a8f7f9643ce 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -218,7 +218,7 @@ DoliStoreDesc=DoliStore, the official market place for Dolibarr ERP/CRM external DoliPartnersDesc=List of companies providing custom-developed modules or features.
Note: since Dolibarr is an open source application, anyone experienced in PHP programming may develop a module. WebSiteDesc=External websites for more add-on (non-core) modules... DevelopYourModuleDesc=Some solutions to develop your own module... -URL=Link +URL=URL BoxesAvailable=Widgets available BoxesActivated=Widgets activated ActivateOn=Activate on From 452c248a0d5c2579689ab7c6c00d488b6a187a1b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 7 Sep 2019 14:49:48 +0200 Subject: [PATCH 40/46] Show list of menus and permission on the modulebuilder. --- htdocs/modulebuilder/index.php | 231 +++++++++++++++------------------ 1 file changed, 105 insertions(+), 126 deletions(-) diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 1c3c899b19c..30fd315dde3 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -2195,7 +2195,7 @@ elseif (! empty($module)) print ''; print $proptype; print ''; - print ''; + print ''; if ($proparrayofkeyval) { print json_encode($proparrayofkeyval); } @@ -2344,7 +2344,7 @@ elseif (! empty($module)) { $pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath']; - //$menus = $moduleobj->; + $menus = $moduleobj->menu; if ($action != 'editfile' || empty($file)) { @@ -2361,9 +2361,6 @@ elseif (! empty($module)) print '
'; print load_fiche_titre($langs->trans("ListOfMenusEntries"), '', ''); - // @TODO - print $langs->trans("FeatureNotYetAvailable"); - print '
'; print ''; print ''; @@ -2371,77 +2368,90 @@ elseif (! empty($module)) print ''; print ''; - /* - print '
'; - print ''; + print '
'; + print '
'; - print ''; - print_liste_field_titre("Menu",$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder); - print_liste_field_titre("CronTask",'','',"",$param,'',$sortfield,$sortorder); - print_liste_field_titre("CronFrequency",'',"","",$param,'',$sortfield,$sortorder); - print_liste_field_titre("StatusAtInstall",$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder); - print_liste_field_titre("Comment",$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder); - print "\n"; + print ''; + print_liste_field_titre("Type",$_SERVER["PHP_SELF"],'',"",$param,'',$sortfield,$sortorder); + print_liste_field_titre("fk_menu",$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder); + print_liste_field_titre("Title",$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder); + print_liste_field_titre("mainmenu",$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder); + print_liste_field_titre("leftmenu",$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder); + print_liste_field_titre("URL",$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder); + print_liste_field_titre("LanguageFile",$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder); + print_liste_field_titre("Position",$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder); + print_liste_field_titre("Enabled",$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder); + print_liste_field_titre("perms",$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder); + print_liste_field_titre("Target",$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder); + print_liste_field_titre("UserType",$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder); + print "\n"; - if (count($menus)) - { - foreach ($cronjobs as $cron) - { - print ''; + if (count($menus)) + { + foreach ($menus as $menu) + { + print ''; - print ''; + print ''; - print ''; + print ''; - print ''; + print ''; - print ''; + print ''; - print ''; + print ''; - print ''; - } + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + } } else { - print ''; + print ''; } print '
'; - print $cron['label']; - print ''; + print $menu['type']; + print ''; - if ($cron['jobtype']=='method') - { - $text=$langs->trans("CronClass"); - $texttoshow=$langs->trans('CronModule').': '.$module.'
'; - $texttoshow.=$langs->trans('CronClass').': '. $cron['class'].'
'; - $texttoshow.=$langs->trans('CronObject').': '. $cron['objectname'].'
'; - $texttoshow.=$langs->trans('CronMethod').': '. $cron['method']; - $texttoshow.='
'.$langs->trans('CronArgs').': '. $cron['parameters']; - $texttoshow.='
'.$langs->trans('Comment').': '. $langs->trans($cron['comment']); - } - elseif ($cron['jobtype']=='command') - { - $text=$langs->trans('CronCommand'); - $texttoshow=$langs->trans('CronCommand').': '.dol_trunc($cron['command']); - $texttoshow.='
'.$langs->trans('CronArgs').': '. $cron['parameters']; - $texttoshow.='
'.$langs->trans('Comment').': '. $langs->trans($cron['comment']); - } - print $form->textwithpicto($text, $texttoshow, 1); - print '
'; + print $menu['fk_menu']; + print ''; - if($cron['unitfrequency'] == "60") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Minutes'); - if($cron['unitfrequency'] == "3600") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Hours'); - if($cron['unitfrequency'] == "86400") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Days'); - if($cron['unitfrequency'] == "604800") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Weeks'); - print ''; + print $menu['titre']; + print ''; - print $cron['status']; - print ''; + print $menu['mainmenu']; + print ''; - if (!empty($cron['comment'])) {print $cron['comment'];} - print ''; + print $menu['left']; + print '
'; + print $menu['url']; + print ''; + print $menu['langs']; + print ''; + print $menu['position']; + print ''; + print $menu['enabled']; + print ''; + print $menu['perms']; + print ''; + print $menu['target']; + print ''; + print $menu['user']; + print '
'.$langs->trans("None").'
'.$langs->trans("None").'
'; print '
'; print '
'; - */ } else { @@ -2474,7 +2484,7 @@ elseif (! empty($module)) { $pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath']; - //$perms = $moduleobj->; + $perms = $moduleobj->rights; if ($action != 'editfile' || empty($file)) { @@ -2492,10 +2502,6 @@ elseif (! empty($module)) print '
'; print load_fiche_titre($langs->trans("ListOfPermissionsDefined"), '', ''); - - // @TODO - print $langs->trans("FeatureNotYetAvailable"); - print '
'; print ''; print ''; @@ -2503,77 +2509,50 @@ elseif (! empty($module)) print ''; print ''; - /* - print '
'; - print ''; + print '
'; + print '
'; - print ''; - print_liste_field_titre("CronLabel",$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder); - print_liste_field_titre("CronTask",'','',"",$param,'',$sortfield,$sortorder); - print_liste_field_titre("CronFrequency",'',"","",$param,'',$sortfield,$sortorder); - print_liste_field_titre("StatusAtInstall",$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder); - print_liste_field_titre("Comment",$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder); - print "\n"; + print ''; + print_liste_field_titre("ID",$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder); + print_liste_field_titre("Label",$_SERVER["PHP_SELF"],'',"",$param,'',$sortfield,$sortorder); + print_liste_field_titre("Permission",$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder); + print_liste_field_titre("",$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder); + print "\n"; - if (count($cronjobs)) - { - foreach ($cronjobs as $cron) - { - print ''; + if (count($perms)) + { + foreach ($perms as $perm) + { + print ''; - print ''; + print ''; - print ''; + print ''; - print ''; + print ''; - print ''; + print ''; - print ''; + print ''; + } + } + else + { + print ''; + } - print ''; - } - } - else - { - print ''; - } + print '
'; - print $cron['label']; - print ''; + print $perm[0]; + print ''; - if ($cron['jobtype']=='method') - { - $text=$langs->trans("CronClass"); - $texttoshow=$langs->trans('CronModule').': '.$module.'
'; - $texttoshow.=$langs->trans('CronClass').': '. $cron['class'].'
'; - $texttoshow.=$langs->trans('CronObject').': '. $cron['objectname'].'
'; - $texttoshow.=$langs->trans('CronMethod').': '. $cron['method']; - $texttoshow.='
'.$langs->trans('CronArgs').': '. $cron['parameters']; - $texttoshow.='
'.$langs->trans('Comment').': '. $langs->trans($cron['comment']); - } - elseif ($cron['jobtype']=='command') - { - $text=$langs->trans('CronCommand'); - $texttoshow=$langs->trans('CronCommand').': '.dol_trunc($cron['command']); - $texttoshow.='
'.$langs->trans('CronArgs').': '. $cron['parameters']; - $texttoshow.='
'.$langs->trans('Comment').': '. $langs->trans($cron['comment']); - } - print $form->textwithpicto($text, $texttoshow, 1); - print '
'; + print $perm[1]; + print ''; - if($cron['unitfrequency'] == "60") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Minutes'); - if($cron['unitfrequency'] == "3600") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Hours'); - if($cron['unitfrequency'] == "86400") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Days'); - if($cron['unitfrequency'] == "604800") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Weeks'); - print ''; + print $perm[4]; + print ''; - print $cron['status']; - print ''; + print $perm[5]; + print ''; - if (!empty($cron['comment'])) {print $cron['comment'];} - print '
'.$langs->trans("None").'
'.$langs->trans("None").'
'; + print '
'; - print ''; - print ''; - - print '
'; - */ + print ''; } else { From d6f105c78349afd246a842aee55abff084b63218 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 7 Sep 2019 15:44:48 +0200 Subject: [PATCH 41/46] Work on MRP module --- htdocs/core/class/conf.class.php | 3 --- htdocs/core/menus/standard/auguria.lib.php | 4 ++-- htdocs/core/menus/standard/eldy.lib.php | 13 +++++++++++-- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 3c03f9ea14c..b85056fe5e8 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -552,9 +552,6 @@ class Conf if (! isset($this->global->MAIN_PDF_DASH_BETWEEN_LINES)) $this->global->MAIN_PDF_DASH_BETWEEN_LINES=1; // use dash between lines if (! isset($this->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) $this->global->PDF_ALLOW_HTML_FOR_FREE_TEXT=1; // allow html content into free footer text - // Set default value to MAIN_SHOW_LOGO - if (! isset($this->global->MAIN_SHOW_LOGO)) $this->global->MAIN_SHOW_LOGO=1; - // Default max file size for upload $this->maxfilesize = (empty($this->global->MAIN_UPLOAD_DOC) ? 0 : (int) $this->global->MAIN_UPLOAD_DOC * 1024); diff --git a/htdocs/core/menus/standard/auguria.lib.php b/htdocs/core/menus/standard/auguria.lib.php index b321c0da621..438ff8246ea 100644 --- a/htdocs/core/menus/standard/auguria.lib.php +++ b/htdocs/core/menus/standard/auguria.lib.php @@ -53,8 +53,8 @@ function print_auguria_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout if (empty($noout)) print_start_menu_array_auguria(); - $usemenuhider = 1; global $usemenuhider; + $usemenuhider = 1; // Show/Hide vertical menu if ($mode != 'jmobile' && $mode != 'topnb' && $usemenuhider && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) @@ -265,8 +265,8 @@ function print_left_auguria_menu($db, $menu_array_before, $menu_array_after, &$t $mainmenu=($forcemainmenu?$forcemainmenu:$_SESSION["mainmenu"]); $leftmenu=($forceleftmenu?'':(empty($_SESSION["leftmenu"])?'none':$_SESSION["leftmenu"])); - $usemenuhider = 0; global $usemenuhider; + $usemenuhider = 0; // Show logo company if (empty($noout) && ! empty($conf->global->MAIN_SHOW_LOGO) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index e3f26b1ccd7..9efb4dd1e27 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1580,8 +1580,17 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM $langs->load("mrp"); $newmenu->add("", $langs->trans("MenuBOM"), 0, $user->rights->bom->read, '', $mainmenu, 'bom'); - $newmenu->add("/bom/bom_card.php?leftmenu=bom&action=create", $langs->trans("NewBOM"), 1, $user->rights->bom->write); - $newmenu->add("/bom/bom_list.php?leftmenu=bom", $langs->trans("List"), 1, $user->rights->bom->read); + $newmenu->add("/bom/bom_card.php?leftmenu=bom&action=create", $langs->trans("NewBOM"), 1, $user->rights->bom->write, '', $mainmenu, 'bom'); + $newmenu->add("/bom/bom_list.php?leftmenu=bom", $langs->trans("List"), 1, $user->rights->bom->read, '', $mainmenu, 'bom'); + } + + if (! empty($conf->mrp->enabled)) + { + $langs->load("mrp"); + + $newmenu->add("", $langs->trans("MenuMRP"), 0, $user->rights->mrp->read, '', $mainmenu, 'mo'); + $newmenu->add("/mrp/mo_card.php?leftmenu=mo&action=create", $langs->trans("NewMO"), 1, $user->rights->mrp->write, '', $mainmenu, 'mo'); + $newmenu->add("/mrp/mo_list.php?leftmenu=mo", $langs->trans("List"), 1, $user->rights->mrp->read, '', $mainmenu, 'mo'); } } From 1d311b29691d840474e9ea9f38a2922b09582fec Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 8 Sep 2019 21:21:33 +0200 Subject: [PATCH 42/46] Fix scrutinizer --- htdocs/core/modules/modBlockedLog.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/modBlockedLog.class.php b/htdocs/core/modules/modBlockedLog.class.php index d9833e2978e..b582d5e2165 100644 --- a/htdocs/core/modules/modBlockedLog.class.php +++ b/htdocs/core/modules/modBlockedLog.class.php @@ -93,7 +93,7 @@ class modBlockedLog extends DolibarrModules $this->always_enabled = (!empty($conf->blockedlog->enabled) && !empty($conf->global->BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY) && in_array($mysoc->country_code, explode(',', $conf->global->BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY)) - && $this->alreadyUsed(1)); + && $this->alreadyUsed()); // Constants //----------- From 47f72fb74cac7c57f777347098544bad131cb467 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 8 Sep 2019 21:21:58 +0200 Subject: [PATCH 43/46] Update data file --- htdocs/install/mysql/data/llx_c_hrm_public_holiday.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/install/mysql/data/llx_c_hrm_public_holiday.sql b/htdocs/install/mysql/data/llx_c_hrm_public_holiday.sql index 5b6f4bf3f0c..312c30210c8 100644 --- a/htdocs/install/mysql/data/llx_c_hrm_public_holiday.sql +++ b/htdocs/install/mysql/data/llx_c_hrm_public_holiday.sql @@ -41,3 +41,4 @@ INSERT INTO llx_c_hrm_public_holiday (code, entity, fk_country, year, month, day INSERT INTO llx_c_hrm_public_holiday (code, entity, fk_country, year, month, day, active) VALUES('FRASSOMPTION', 0, 1, 0, 8, 15, 1); INSERT INTO llx_c_hrm_public_holiday (code, entity, fk_country, year, month, day, active) VALUES('FRTOUSSAINT', 0, 1, 0, 11, 1, 1); INSERT INTO llx_c_hrm_public_holiday (code, entity, fk_country, year, month, day, active) VALUES('FRARMISTICE', 0, 1, 0, 11, 11, 1); +--INSERT INTO llx_c_hrm_public_holiday (code, entity, fk_country, dayrule, year, month, day, active) VALUES('EASTER', 0, 1, 'easter', 0, 0, 0, 1); From 5cc0b24f6fb77b269498f763ebd33b42c753a59b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 8 Sep 2019 21:24:01 +0200 Subject: [PATCH 44/46] Fix param --- htdocs/core/tpl/contacts.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/tpl/contacts.tpl.php b/htdocs/core/tpl/contacts.tpl.php index 1f7d403b575..0f9b733d010 100644 --- a/htdocs/core/tpl/contacts.tpl.php +++ b/htdocs/core/tpl/contacts.tpl.php @@ -208,7 +208,7 @@ if ($permission) { if ($tab[$i]['source']=='external') { $contactstatic->fetch($tab[$i]['id']); - echo $contactstatic->getNomUrl(1, '', 0, '', 0, 0, '', 'valignmiddle'); + echo $contactstatic->getNomUrl(1, '', 0, '', 0, 0); } ?> From feca9a7ee3198f28fbab20c4555a30d4ce300e85 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 8 Sep 2019 21:28:17 +0200 Subject: [PATCH 45/46] Fix phpcs --- htdocs/modulebuilder/index.php | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 30fd315dde3..4b7efffdfed 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -2372,18 +2372,18 @@ elseif (! empty($module)) print ''; print ''; - print_liste_field_titre("Type",$_SERVER["PHP_SELF"],'',"",$param,'',$sortfield,$sortorder); - print_liste_field_titre("fk_menu",$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder); - print_liste_field_titre("Title",$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder); - print_liste_field_titre("mainmenu",$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder); - print_liste_field_titre("leftmenu",$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder); - print_liste_field_titre("URL",$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder); - print_liste_field_titre("LanguageFile",$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder); - print_liste_field_titre("Position",$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder); - print_liste_field_titre("Enabled",$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder); - print_liste_field_titre("perms",$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder); - print_liste_field_titre("Target",$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder); - print_liste_field_titre("UserType",$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder); + print_liste_field_titre("Type", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("fk_menu", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("Title", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("mainmenu", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("leftmenu", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("URL", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("LanguageFile", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("Position", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("Enabled", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("perms", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("Target", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("UserType", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); print "\n"; if (count($menus)) @@ -2513,10 +2513,10 @@ elseif (! empty($module)) print '
'; print ''; - print_liste_field_titre("ID",$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder); - print_liste_field_titre("Label",$_SERVER["PHP_SELF"],'',"",$param,'',$sortfield,$sortorder); - print_liste_field_titre("Permission",$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder); - print_liste_field_titre("",$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder); + print_liste_field_titre("ID", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("Label", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("Permission", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); print "\n"; if (count($perms)) From 6d38d58000c39109ea40ad973c2f5946d5453865 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 8 Sep 2019 21:31:10 +0200 Subject: [PATCH 46/46] Trans --- htdocs/langs/en_US/mrp.lang | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/langs/en_US/mrp.lang b/htdocs/langs/en_US/mrp.lang index 360f4303f07..96efb3be55f 100644 --- a/htdocs/langs/en_US/mrp.lang +++ b/htdocs/langs/en_US/mrp.lang @@ -15,3 +15,5 @@ ManufacturingEfficiency=Manufacturing efficiency ValueOfMeansLoss=Value of 0.95 means an average of 5%% of loss during the production DeleteBillOfMaterials=Delete Bill Of Materials ConfirmDeleteBillOfMaterials=Are you sure you want to delete this Bill Of Material? +MenuMRP=Manufacturing Orders +NewMO=New Manufacturing Order \ No newline at end of file