From c9c375f3b8777e5c9ce2932eaaf627901fe95516 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 23 Jul 2017 10:29:45 +0200 Subject: [PATCH 001/207] Fix: run_jobs return always an error !! --- htdocs/cron/class/cronjob.class.php | 102 ++++++++++++++-------------- 1 file changed, 51 insertions(+), 51 deletions(-) diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php index bd1d74e35b8..5f7f8e5ead0 100644 --- a/htdocs/cron/class/cronjob.class.php +++ b/htdocs/cron/class/cronjob.class.php @@ -108,7 +108,7 @@ class Cronjob extends CommonObject if (isset($this->nbrun)) $this->nbrun=trim($this->nbrun); if (isset($this->libname)) $this->libname = trim($this->libname); if (isset($this->test)) $this->test = trim($this->test); - + // Check parameters // Put here code to add a control on parameters values if (dol_strlen($this->datestart)==0) { @@ -363,9 +363,9 @@ class Cronjob extends CommonObject function fetch_all($sortorder='DESC', $sortfield='t.rowid', $limit=0, $offset=0, $status=1, $filter='') { global $langs; - + $this->lines=array(); - + $sql = "SELECT"; $sql.= " t.rowid,"; $sql.= " t.entity,"; @@ -403,7 +403,7 @@ class Cronjob extends CommonObject if ($status == 2) $sql.= " AND t.status = 2"; //Manage filter if (is_array($filter) && count($filter)>0) { - foreach($filter as $key => $value) + foreach($filter as $key => $value) { if ($key == 't.rowid') $sql.= ' AND '.$key.' = '.$this->db->escape($value); else $sql.= ' AND '.$key.' LIKE \'%'.$this->db->escape($value).'%\''; @@ -526,7 +526,7 @@ class Cronjob extends CommonObject if (empty($this->maxrun)) $this->maxrun=0; if (isset($this->libname)) $this->libname = trim($this->libname); if (isset($this->test)) $this->test = trim($this->test); - + // Check parameters // Put here code to add a control on parameters values if (dol_strlen($this->datestart)==0) { @@ -837,8 +837,8 @@ class Cronjob extends CommonObject /** * Run a job. - * Once job is finished, status and nb of run is updated. - * This function does not plan the next run. This is done by function ->reprogram_jobs + * Once job is finished, status and nb of run is updated. + * This function does not plan the next run. This is done by function ->reprogram_jobs * * @param string $userlogin User login * @return int <0 if KO, >0 if OK @@ -853,7 +853,7 @@ class Cronjob extends CommonObject $langs->load('cron'); - if (empty($userlogin)) + if (empty($userlogin)) { $this->error="User login is mandatory"; dol_syslog(get_class($this)."::run_jobs ".$this->error, LOG_ERR); @@ -914,16 +914,16 @@ class Cronjob extends CommonObject // load classes if (! $error) { - $ret=dol_include_once($this->classesname); - if ($ret===false || (! class_exists($this->objectname))) - { - $this->error=$langs->trans('CronCannotLoadClass',$this->classesname,$this->objectname); - dol_syslog(get_class($this)."::run_jobs ".$this->error, LOG_ERR); - $this->lastoutput = $this->error; - $this->lastresult = -1; - $retval = $this->lastresult; - $error++; - } + $ret=dol_include_once($this->classesname); + if ($ret===false || (! class_exists($this->objectname))) + { + $this->error=$langs->trans('CronCannotLoadClass',$this->classesname,$this->objectname); + dol_syslog(get_class($this)."::run_jobs ".$this->error, LOG_ERR); + $this->lastoutput = $this->error; + $this->lastresult = -1; + $retval = $this->lastresult; + $error++; + } } // test if method exists @@ -939,7 +939,7 @@ class Cronjob extends CommonObject $error++; } } - + // Load langs if (! $error) { @@ -954,14 +954,14 @@ class Cronjob extends CommonObject $error++; } } - + if (! $error) { dol_syslog(get_class($this)."::run_jobs START ".$this->objectname."->".$this->methodename."(".$this->params.");", LOG_DEBUG); - + // Create Object for the call module $object = new $this->objectname($this->db); - + $params_arr = explode(", ",$this->params); if (!is_array($params_arr)) { @@ -971,8 +971,8 @@ class Cronjob extends CommonObject { $result = call_user_func_array(array($object, $this->methodename), $params_arr); } - - if ($result===false || $result != 0) + + if ($result===false || $result < 0) { $langs->load("errors"); dol_syslog(get_class($this)."::run_jobs END result=".$result." error=".$object->error, LOG_ERR); @@ -989,7 +989,7 @@ class Cronjob extends CommonObject $this->lastresult=var_export($result,true); $retval = $this->lastresult; } - } + } } if($this->jobtype == 'function') @@ -1021,7 +1021,7 @@ class Cronjob extends CommonObject $result = call_user_func_array($this->methodename, $params_arr); } - if ($result === false || $result != 0) + if ($result === false || $result < 0) { $langs->load("errors"); dol_syslog(get_class($this)."::run_jobs result=".$result, LOG_ERR); @@ -1062,7 +1062,7 @@ class Cronjob extends CommonObject $this->lastoutput = ''; // Will be filled later $this->lastresult = $retval; $retval = $this->lastresult; - $error++; + $error++; } } if ($execmethod == 2) @@ -1086,21 +1086,21 @@ class Cronjob extends CommonObject } // Update with result - if (is_array($output_arr) && count($output_arr)>0) - { - foreach($output_arr as $val) - { - $this->lastoutput.=$val."\n"; - } - } - - $this->lastresult=$retval; - - dol_syslog(get_class($this)."::run_jobs output_arr:".var_export($output_arr,true)." lastoutput=".$this->lastoutput." lastresult=".$this->lastresult, LOG_DEBUG); + if (is_array($output_arr) && count($output_arr)>0) + { + foreach($output_arr as $val) + { + $this->lastoutput.=$val."\n"; + } + } + + $this->lastresult=$retval; + + dol_syslog(get_class($this)."::run_jobs output_arr:".var_export($output_arr,true)." lastoutput=".$this->lastoutput." lastresult=".$this->lastresult, LOG_DEBUG); } - + dol_syslog(get_class($this)."::run_jobs now we update job to track it is finished (with success or error)"); - + $this->datelastresult=dol_now(); $result = $this->update($user); // This include begin/commit if ($result < 0) @@ -1125,19 +1125,19 @@ class Cronjob extends CommonObject function reprogram_jobs($userlogin, $now) { dol_syslog(get_class($this)."::reprogram_jobs userlogin:$userlogin", LOG_DEBUG); - + require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; $user=new User($this->db); $result=$user->fetch('',$userlogin); - if ($result<0) + if ($result<0) { $this->error="User Error:".$user->error; dol_syslog(get_class($this)."::reprogram_jobs ".$this->error, LOG_ERR); return -1; } - else + else { - if (empty($user->id)) + if (empty($user->id)) { $this->error=" User user login:".$userlogin." do not exists"; dol_syslog(get_class($this)."::reprogram_jobs ".$this->error, LOG_ERR); @@ -1147,24 +1147,24 @@ class Cronjob extends CommonObject dol_syslog(get_class($this)."::reprogram_jobs ", LOG_DEBUG); - - if (empty($this->datenextrun)) + + if (empty($this->datenextrun)) { if (empty($this->datestart)) $this->datenextrun = $now + ($this->frequency * $this->unitfrequency); else $this->datenextrun = $this->datestart + ($this->frequency * $this->unitfrequency); } - if ($this->datenextrun < $now && $this->frequency > 0 && $this->unitfrequency > 0) + if ($this->datenextrun < $now && $this->frequency > 0 && $this->unitfrequency > 0) { // Loop until date is after future while ($this->datenextrun < $now) { $this->datenextrun += ($this->frequency * $this->unitfrequency); - + // TODO For exact frequency (every month, every year, ...), use instead a dol_time_plus_duree($time, $duration_value, $duration_unit) } } - else + else { //$this->datenextrun=$this->datenextrun + ($this->frequency * $this->unitfrequency); } @@ -1180,9 +1180,9 @@ class Cronjob extends CommonObject dol_syslog(get_class($this)."::reprogram_jobs Job will be set to archived", LOG_ERR); } } - + $result = $this->update($user); - if ($result<0) + if ($result<0) { dol_syslog(get_class($this)."::reprogram_jobs ".$this->error, LOG_ERR); return -1; From 566bc555ebb82206f5d8b042285f358e57ff07fe Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 24 Jul 2017 15:41:22 +0200 Subject: [PATCH 002/207] Fix: add possibility to force entity id --- htdocs/public/cron/cron_run_jobs.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/htdocs/public/cron/cron_run_jobs.php b/htdocs/public/cron/cron_run_jobs.php index 3ca058acb8a..725aea8825d 100644 --- a/htdocs/public/cron/cron_run_jobs.php +++ b/htdocs/public/cron/cron_run_jobs.php @@ -1,7 +1,8 @@ - * Copyright (C) 2013-2015 Laurent Destailleur +/* Copyright (C) 2012 Nicolas Villa aka Boyquotes http://informetic.fr + * Copyright (C) 2013 Florian Henry + * Copyright (C) 2013-2015 Laurent Destailleur + * Copyright (C) 2017 Regis Houssin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -30,6 +31,11 @@ if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); if (! defined('NOLOGIN')) define('NOLOGIN','1'); //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); +// For MultiCompany module. +// Do not use GETPOST here, function is not defined and define must be done before including main.inc.php +$entity=(! empty($_GET['entity']) ? (int) $_GET['entity'] : (! empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); +if (is_numeric($entity)) define("DOLENTITY", $entity); + // librarie core // Dolibarr environment $res = @include("../../main.inc.php"); // From htdocs directory From a52adcad4a6fc645baf2432abf094c651c0cd0df Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 25 Jul 2017 13:52:10 +0200 Subject: [PATCH 003/207] Fix: change the condition --- htdocs/cron/class/cronjob.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php index 5f7f8e5ead0..d62be5d915c 100644 --- a/htdocs/cron/class/cronjob.class.php +++ b/htdocs/cron/class/cronjob.class.php @@ -972,7 +972,7 @@ class Cronjob extends CommonObject $result = call_user_func_array(array($object, $this->methodename), $params_arr); } - if ($result===false || $result < 0) + if ($result !== true || $result != 0) { $langs->load("errors"); dol_syslog(get_class($this)."::run_jobs END result=".$result." error=".$object->error, LOG_ERR); @@ -1021,7 +1021,7 @@ class Cronjob extends CommonObject $result = call_user_func_array($this->methodename, $params_arr); } - if ($result === false || $result < 0) + if ($result !== true || $result != 0) { $langs->load("errors"); dol_syslog(get_class($this)."::run_jobs result=".$result, LOG_ERR); From ab72fbffc679add0c145c90ac31bad68f5af89e4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 25 Jul 2017 23:02:14 +0200 Subject: [PATCH 004/207] Fix pb with .svg files --- htdocs/core/lib/functions.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index a099b33eee7..57e4f612840 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2325,7 +2325,7 @@ function img_picto($titlealt, $picto, $morealt = '', $pictoisfullpath = false, $ if ($pictoisfullpath) { // Clean parameters - if (! preg_match('/(\.png|\.gif)$/i',$picto)) $picto .= '.png'; + if (! preg_match('/(\.png|\.gif|\.svg)$/i',$picto)) $picto .= '.png'; $fullpathpicto = $picto; } else @@ -2346,7 +2346,7 @@ function img_picto($titlealt, $picto, $morealt = '', $pictoisfullpath = false, $ $path = $regs[2]; // $path is $mymodule } // Clean parameters - if (! preg_match('/(\.png|\.gif)$/i',$picto)) $picto .= '.png'; + if (! preg_match('/(\.png|\.gif|\.svg)$/i',$picto)) $picto .= '.png'; // If alt path are defined, define url where img file is, according to physical path foreach ($conf->file->dol_document_root as $type => $dirroot) // ex: array(["main"]=>"/home/maindir/htdocs", ["alt0"]=>"/home/moddir0/htdocs", ...) { From b932ce62468f55e6f13bfb84149827d7863326ca Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 26 Jul 2017 01:25:15 +0200 Subject: [PATCH 005/207] Update cronjob.class.php is better condition for use true or 0 if ($result === false || (! is_bool($result) && $result != 0)) --- htdocs/cron/class/cronjob.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php index d62be5d915c..5fba81a3422 100644 --- a/htdocs/cron/class/cronjob.class.php +++ b/htdocs/cron/class/cronjob.class.php @@ -972,7 +972,7 @@ class Cronjob extends CommonObject $result = call_user_func_array(array($object, $this->methodename), $params_arr); } - if ($result !== true || $result != 0) + if ($result === false || (! is_bool($result) && $result != 0)) { $langs->load("errors"); dol_syslog(get_class($this)."::run_jobs END result=".$result." error=".$object->error, LOG_ERR); @@ -1021,7 +1021,7 @@ class Cronjob extends CommonObject $result = call_user_func_array($this->methodename, $params_arr); } - if ($result !== true || $result != 0) + if ($result === false || (! is_bool($result) && $result != 0)) { $langs->load("errors"); dol_syslog(get_class($this)."::run_jobs result=".$result, LOG_ERR); From 8451ba1f149b79fe97e3db7b39fa60f6ee3fddb1 Mon Sep 17 00:00:00 2001 From: atm-quentin Date: Wed, 26 Jul 2017 14:43:10 +0200 Subject: [PATCH 006/207] FIX invoice situation division by zero --- htdocs/core/modules/facture/doc/pdf_crabe.modules.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index c421ec6124c..092ae36fe28 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -568,7 +568,7 @@ class pdf_crabe extends ModelePDFFactures if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1; // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva $prev_progress = $object->lines[$i]->get_prev_progress($object->id); - if ($prev_progress > 0) // Compute progress from previous situation + if ($prev_progress > 0 && !empty($object->lines[$i]->situation_percent)) // Compute progress from previous situation { if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne = $sign * $object->lines[$i]->multicurrency_total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent; else $tvaligne = $sign * $object->lines[$i]->total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent; From 29a4900d0b24fbfd17e27e1c05db297cad8ffcbb Mon Sep 17 00:00:00 2001 From: atm-quentin Date: Wed, 26 Jul 2017 15:20:31 +0200 Subject: [PATCH 007/207] FIX_next_situation_keep_extrafields --- htdocs/compta/facture/class/facture.class.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index c410e507b96..4b0ba1ac2b7 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -748,6 +748,10 @@ class Facture extends CommonInvoice // Charge facture source $facture=new Facture($this->db); + + foreach($this->lines as $line){ + $line->fetch_optionals();//fetch extrafields + } $facture->fk_facture_source = $this->fk_facture_source; $facture->type = $this->type; From 09a11180369fa20b2b022d8e264239006fb8a0bb Mon Sep 17 00:00:00 2001 From: atm-quentin Date: Wed, 26 Jul 2017 15:55:50 +0200 Subject: [PATCH 008/207] FIX extrafields for invoice too --- htdocs/compta/facture/class/facture.class.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 4b0ba1ac2b7..221f224e043 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -749,7 +749,12 @@ class Facture extends CommonInvoice // Charge facture source $facture=new Facture($this->db); - foreach($this->lines as $line){ + $this->fetch_optionals(); + if(!empty($this->array_options)){ + $facture->array_options = $this->array_options; + } + + foreach($this->lines as &$line){ $line->fetch_optionals();//fetch extrafields } From f5718106a66d6497c9f8357caccc9534a35d9329 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Fri, 28 Jul 2017 09:45:23 +0200 Subject: [PATCH 009/207] FIX : 7213 --- .../class/ProductCombination.class.php | 7 +- htdocs/variants/combinations.php | 104 +++++++++--------- 2 files changed, 56 insertions(+), 55 deletions(-) diff --git a/htdocs/variants/class/ProductCombination.class.php b/htdocs/variants/class/ProductCombination.class.php index f6eb4c58935..fd08ccf1b6a 100644 --- a/htdocs/variants/class/ProductCombination.class.php +++ b/htdocs/variants/class/ProductCombination.class.php @@ -186,7 +186,7 @@ class ProductCombination { $nb = 0; $sql = "SELECT count(rowid) as nb FROM ".MAIN_DB_PREFIX."product_attribute_combination WHERE fk_product_parent = ".(int) $fk_product_parent." AND entity IN (".getEntity('product').")"; - + $resql = $this->db->query($sql); if ($resql) { $obj = $this->db->fetch_object($resql); @@ -195,7 +195,7 @@ class ProductCombination return $nb; } - + /** * Creates a product attribute combination * @@ -249,9 +249,10 @@ class ProductCombination /** * Deletes a product combination * + * @param User $user * @return int <0 KO >0 OK */ - public function delete() + public function delete(User $user) { $this->db->begin(); diff --git a/htdocs/variants/combinations.php b/htdocs/variants/combinations.php index 76a091ad8a2..0ec1bf07b68 100644 --- a/htdocs/variants/combinations.php +++ b/htdocs/variants/combinations.php @@ -101,8 +101,8 @@ if ($_POST) { if (!$features) { setEventMessage($langs->trans('ErrorFieldsRequired'), 'errors'); - } - else + } + else { $weight_impact = price2num($weight_impact); $price_impact = price2num($price_impact); @@ -149,8 +149,8 @@ if ($_POST) { $db->rollback(); } - } - elseif (! empty($massaction)) + } + elseif (! empty($massaction)) { $bulkaction = $massaction; $error = 0; @@ -203,7 +203,7 @@ if ($_POST) { setEventMessage($langs->trans('RecordSaved')); } - } + } elseif ($valueid > 0) { if ($prodcomb->fetch($valueid) < 0) { @@ -234,7 +234,7 @@ if ($action === 'confirm_deletecombination') { $db->begin(); - if ($prodcomb->delete() > 0 && $prodstatic->fetch($prodcomb->fk_product_child) > 0 && $prodstatic->delete() > 0) { + if ($prodcomb->delete($user) > 0 && $prodstatic->fetch($prodcomb->fk_product_child) > 0 && $prodstatic->delete($user) > 0) { $db->commit(); setEventMessage($langs->trans('RecordSaved')); header('Location: '.dol_buildpath('/variants/combinations.php?id='.$object->id, 2)); @@ -288,26 +288,26 @@ if ($action === 'confirm_deletecombination') { $form = new Form($db); -if (! empty($id) || ! empty($ref)) +if (! empty($id) || ! empty($ref)) { llxHeader("", "", $langs->trans("CardProduct".$object->type)); $showbarcode=empty($conf->barcode->enabled)?0:1; if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) $showbarcode=0; - + $head=product_prepare_head($object); $titre=$langs->trans("CardProduct".$object->type); $picto=($object->type== Product::TYPE_SERVICE?'service':'product'); dol_fiche_head($head, 'combinations', $titre, 0, $picto); - + $linkback = ''.$langs->trans("BackToList").''; $object->next_prev_filter=" fk_product_type = ".$object->type; - + dol_banner_tab($object, 'ref', $linkback, ($user->societe_id?0:1), 'ref', '', '', '', 0, '', '', 1); - + dol_fiche_end(); - + // Create or edit a varian if ($action == 'add' || ($action == 'edit')) { @@ -343,7 +343,7 @@ if (! empty($id) || ! empty($ref)) info: [] }; - fetch($pc2v->fk_prod_attr_val); ?> @@ -355,8 +355,8 @@ if (! empty($id) || ! empty($ref)) label: 'value ?>' } }; - restoreAttributes = function() { @@ -369,7 +369,7 @@ if (! empty($id) || ! empty($ref)) }); }; - + jQuery(document).ready(function() { jQuery("select#attribute").change(function () { console.log("Change of field variant attribute"); @@ -404,18 +404,18 @@ if (! empty($id) || ! empty($ref)) }); }); - - '."\n"; print ''."\n"; print ''."\n"; - + print dol_fiche_head(); - + ?> - + @@ -445,7 +445,7 @@ if (! empty($id) || ! empty($ref))

- @@ -495,12 +495,12 @@ if (! empty($id) || ! empty($ref))   - + '; } - else + else { if ($action === 'delete') { @@ -538,7 +538,7 @@ if (! empty($id) || ! empty($ref)) $comb2val = new ProductCombination2ValuePair($db); - if ($productCombinations) + if ($productCombinations) { ?> @@ -563,36 +563,36 @@ if (! empty($id) || ! empty($ref)) }); - '; - + print '
'; if ($productCombinations) { print ''.$langs->trans('PropagateVariant').''; } - + print ''.$langs->trans('NewProductCombination').''; // NewVariant - + // Too much bugged page. /* print ''.$langs->trans('ProductCombinationGenerator').''; */ - + print '
'; - + print ''; - - - + + + $arrayofselected=is_array($toselect)?$toselect:array(); - - + + // List of variants print ''; - - + + // List of mass actions available /* $arrayofmassactions = array( @@ -603,7 +603,7 @@ if (! empty($id) || ! empty($ref)) if ($massaction == 'presend' || $massaction == 'createbills') $arrayofmassactions=array(); $massactionbutton=$form->selectMassAction('', $arrayofmassactions); */ - + $aaa=''; if (count($productCombinations)) { @@ -620,11 +620,11 @@ if (! empty($id) || ! empty($ref)) $aaa .= ''; } $massactionbutton = $aaa; - + $title = $langs->trans("ProductCombinations"); - + print_barre_liste($title, 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, $aaa, 0); - + print '
'; ?>
@@ -636,7 +636,7 @@ if (! empty($id) || ! empty($ref)) - '; $searchpicto=$form->showCheckAddButtons('checkforselect', 1); print $searchpicto; @@ -644,23 +644,23 @@ if (! empty($id) || ! empty($ref)) ?> fetch($currcomb->fk_product_child); + $prodstatic->fetch($currcomb->fk_product_child); ?> - '; if ($productCombinations || $massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined { @@ -690,7 +690,7 @@ if (! empty($id) || ! empty($ref)) } else { - print ''; + print ''; } ?>
trans('OnSell') ?> trans('OnBuy') ?>
getNomUrl(1) ?> fetchByFkCombination($currcomb->id); $iMax = count($productCombination2ValuePairs); - + for ($i = 0; $i < $iMax; $i++) { echo dol_htmlentities($productCombination2ValuePairs[$i]); - + if ($i !== ($iMax - 1)) { echo ', '; } @@ -674,7 +674,7 @@ if (! empty($id) || ! empty($ref))
'.$langs->trans("None").'
'.$langs->trans("None").'
From 60493d0a4774735616feefe769cfe40a74db7921 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 28 Jul 2017 10:16:17 +0200 Subject: [PATCH 010/207] Several fixes (permission, missing method or class) in REST APIs --- htdocs/api/index.php | 1 + .../comm/propal/class/api_proposals.class.php | 128 +++--- htdocs/commande/class/api_orders.class.php | 20 +- .../facture/class/api_invoices.class.php | 127 ++++-- htdocs/core/lib/functions2.lib.php | 2 +- .../class/api_supplier_invoices.class.php | 126 ++++-- .../fourn/class/api_supplier_orders.class.php | 365 ++++++++++++++++++ 7 files changed, 623 insertions(+), 146 deletions(-) create mode 100644 htdocs/fourn/class/api_supplier_orders.class.php diff --git a/htdocs/api/index.php b/htdocs/api/index.php index 905d560f9c2..9f734c9e24d 100644 --- a/htdocs/api/index.php +++ b/htdocs/api/index.php @@ -238,6 +238,7 @@ if (! empty($reg[1]) && ($reg[1] != 'explorer' || ($reg[2] != '/resources.json' { $classfile = str_replace('_', '', $module); if ($module == 'supplierinvoices') $classfile = 'supplier_invoices'; + if ($module == 'supplierorders') $classfile = 'supplier_orders'; $dir_part_file = dol_buildpath('/'.$moduledirforclass.'/class/api_'.$classfile.'.class.php'); $classname=ucwords($module); diff --git a/htdocs/comm/propal/class/api_proposals.class.php b/htdocs/comm/propal/class/api_proposals.class.php index 2f067f46b18..42dbdbf9d2c 100644 --- a/htdocs/comm/propal/class/api_proposals.class.php +++ b/htdocs/comm/propal/class/api_proposals.class.php @@ -24,14 +24,14 @@ require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; /** * API class for orders * - * @access protected + * @access protected * @class DolibarrApiAccess {@requires user,external} */ class Proposals extends DolibarrApi { /** - * @var array $FIELDS Mandatory fields, checked when create and update object + * @var array $FIELDS Mandatory fields, checked when create and update object */ static $FIELDS = array( 'socid' @@ -56,36 +56,36 @@ class Proposals extends DolibarrApi * Get properties of a commercial proposal object * * Return an array with commercial proposal informations - * + * * @param int $id ID of commercial proposal * @return array|mixed data without useless information * * @throws RestException */ function get($id) - { + { if(! DolibarrApiAccess::$user->rights->propal->lire) { throw new RestException(401); } - + $result = $this->propal->fetch($id); if( ! $result ) { throw new RestException(404, 'Commercial Proposal not found'); } - + if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - + $this->propal->fetchObjectLinked(); return $this->_cleanObjectDatas($this->propal); } /** * List commercial proposals - * + * * Get a list of commercial proposals - * + * * @param string $sortfield Sort field * @param string $sortorder Sort order * @param int $limit Limit for list @@ -96,12 +96,12 @@ class Proposals extends DolibarrApi */ function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 0, $page = 0, $thirdparty_ids = '', $sqlfilters = '') { global $db, $conf; - + $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; - + // If the internal user must only see his customers, force searching by him $search_sale = 0; if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) $search_sale = DolibarrApiAccess::$user->id; @@ -109,7 +109,7 @@ class Proposals extends DolibarrApi $sql = "SELECT t.rowid"; if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $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) $sql.= " FROM ".MAIN_DB_PREFIX."propal as t"; - + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale $sql.= ' WHERE t.entity IN ('.getEntity('propal').')'; @@ -122,7 +122,7 @@ class Proposals extends DolibarrApi $sql .= " AND sc.fk_user = ".$search_sale; } // Add sql filters - if ($sqlfilters) + if ($sqlfilters) { if (! DolibarrApi::_checkFilters($sqlfilters)) { @@ -131,7 +131,7 @@ class Proposals extends DolibarrApi $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } - + $sql.= $db->order($sortfield, $sortorder); if ($limit) { if ($page < 0) @@ -144,7 +144,7 @@ class Proposals extends DolibarrApi } $result = $db->query($sql); - + if ($result) { $num = $db->num_rows($result); @@ -195,7 +195,7 @@ class Proposals extends DolibarrApi if ($this->propal->create(DolibarrApiAccess::$user) < 0) { throw new RestException(500, "Error creating order", array_merge(array($this->propal->error), $this->propal->errors)); } - + return $this->propal->id; } @@ -203,21 +203,21 @@ class Proposals extends DolibarrApi * Get lines of a commercial proposal * * @param int $id Id of commercial proposal - * + * * @url GET {id}/lines - * - * @return int + * + * @return int */ function getLines($id) { if(! DolibarrApiAccess::$user->rights->propal->lire) { throw new RestException(401); } - + $result = $this->propal->fetch($id); if( ! $result ) { throw new RestException(404, 'Commercial Proposal not found'); } - + if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -233,22 +233,22 @@ class Proposals extends DolibarrApi * Add a line to given commercial proposal * * @param int $id Id of commercial proposal to update - * @param array $request_data Commercial proposal line data - * + * @param array $request_data Commercial proposal line data + * * @url POST {id}/lines - * - * @return int + * + * @return int */ function postLine($id, $request_data = NULL) { if(! DolibarrApiAccess::$user->rights->propal->creer) { throw new RestException(401); } - + $result = $this->propal->fetch($id); if( ! $result ) { throw new RestException(404, 'Commercial Proposal not found'); } - + if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -294,22 +294,22 @@ class Proposals extends DolibarrApi * * @param int $id Id of commercial proposal to update * @param int $lineid Id of line to update - * @param array $request_data Commercial proposal line data - * + * @param array $request_data Commercial proposal line data + * * @url PUT {id}/lines/{lineid} - * - * @return object + * + * @return object */ function putLine($id, $lineid, $request_data = NULL) { if(! DolibarrApiAccess::$user->rights->propal->creer) { throw new RestException(401); } - + $result = $this->propal->fetch($id); if( ! $result ) { throw new RestException(404, 'Proposal not found'); } - + if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -352,21 +352,21 @@ class Proposals extends DolibarrApi * * @param int $id Id of commercial proposal to update * @param int $lineid Id of line to delete - * + * * @url DELETE {id}/lines/{lineid} - * - * @return int + * + * @return int */ function delLine($id, $lineid) { if(! DolibarrApiAccess::$user->rights->propal->creer) { throw new RestException(401); } - + $result = $this->propal->fetch($id); if( ! $result ) { throw new RestException(404, 'Proposal not found'); } - + if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -382,20 +382,20 @@ class Proposals extends DolibarrApi * Update commercial proposal general fields (won't touch lines of commercial proposal) * * @param int $id Id of commercial proposal to update - * @param array $request_data Datas - * - * @return int + * @param array $request_data Datas + * + * @return int */ function put($id, $request_data = NULL) { if(! DolibarrApiAccess::$user->rights->propal->creer) { throw new RestException(401); } - + $result = $this->propal->fetch($id); if( ! $result ) { throw new RestException(404, 'Proposal not found'); } - + if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -403,18 +403,18 @@ class Proposals extends DolibarrApi if ($field == 'id') continue; $this->propal->$field = $value; } - + if($this->propal->update($id, DolibarrApiAccess::$user,1,'','','update')) return $this->get($id); - + return false; } - + /** * Delete commercial proposal * * @param int $id Commercial proposal ID - * + * * @return array */ function delete($id) @@ -426,32 +426,32 @@ class Proposals extends DolibarrApi if( ! $result ) { throw new RestException(404, 'Commercial Proposal not found'); } - + if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - + if( ! $this->propal->delete(DolibarrApiAccess::$user)) { throw new RestException(500, 'Error when delete Commercial Proposal : '.$this->propal->error); } - + return array( 'success' => array( 'code' => 200, 'message' => 'Commercial Proposal deleted' ) ); - + } - + /** * Validate a commercial proposal - * + * * @param int $id Commercial proposal ID * @param int $notrigger Use {} - * + * * @url POST {id}/validate - * + * * @return array * FIXME An error 403 is returned if the request has an empty body. * Error message: "Forbidden: Content type `text/plain` is not supported." @@ -469,11 +469,11 @@ class Proposals extends DolibarrApi if( ! $result ) { throw new RestException(404, 'Commercial Proposal not found'); } - + if( ! DolibarrApi::_checkAccessToResource('propal',$this->propal->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - + $result = $this->propal->valid(DolibarrApiAccess::$user, $notrigger); if ($result == 0) { throw new RestException(500, 'Error nothing done. May be object is already validated'); @@ -481,30 +481,30 @@ class Proposals extends DolibarrApi if ($result < 0) { throw new RestException(500, 'Error when validating Commercial Proposal: '.$this->propal->error); } - + return array( 'success' => array( 'code' => 200, - 'message' => 'Commercial Proposal validated' + 'message' => 'Commercial Proposal validated (Ref='.$this->propal->ref.')' ) ); } - + /** * Validate fields before create or update object - * + * * @param array $data Array with data to verify - * @return array + * @return array * @throws RestException */ function _validate($data) { $propal = array(); - foreach (Orders::$FIELDS as $field) { + foreach (Proposals::$FIELDS as $field) { if (!isset($data[$field])) throw new RestException(400, "$field field missing"); $propal[$field] = $data[$field]; - + } return $propal; } diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php index a1330a7be04..d4b4502d4ed 100644 --- a/htdocs/commande/class/api_orders.class.php +++ b/htdocs/commande/class/api_orders.class.php @@ -80,8 +80,8 @@ class Orders extends DolibarrApi return $this->_cleanObjectDatas($this->commande); } - - + + /** * List orders * @@ -101,7 +101,7 @@ class Orders extends DolibarrApi global $db, $conf; $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; @@ -125,7 +125,7 @@ class Orders extends DolibarrApi $sql .= " AND sc.fk_user = ".$search_sale; } // Add sql filters - if ($sqlfilters) + if ($sqlfilters) { if (! DolibarrApi::_checkFilters($sqlfilters)) { @@ -134,7 +134,7 @@ class Orders extends DolibarrApi $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } - + $sql.= $db->order($sortfield, $sortorder); if ($limit) { if ($page < 0) @@ -490,7 +490,7 @@ class Orders extends DolibarrApi return array( 'success' => array( 'code' => 200, - 'message' => 'Order validated' + 'message' => 'Order validated (Ref='.$this->commande->ref.')' ) ); } @@ -502,14 +502,14 @@ class Orders extends DolibarrApi * @return array Array of cleaned object properties */ function _cleanObjectDatas($object) { - + $object = parent::_cleanObjectDatas($object); - + unset($object->address); - + return $object; } - + /** * Validate fields before create or update object * diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index 55304136ed6..f841fc80050 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -22,14 +22,14 @@ /** * API class for invoices * - * @access protected + * @access protected * @class DolibarrApiAccess {@requires user,external} */ class Invoices extends DolibarrApi { /** * - * @var array $FIELDS Mandatory fields, checked when create and update object + * @var array $FIELDS Mandatory fields, checked when create and update object */ static $FIELDS = array( 'socid' @@ -54,23 +54,23 @@ class Invoices extends DolibarrApi * Get properties of a invoice object * * Return an array with invoice informations - * + * * @param int $id ID of invoice * @return array|mixed data without useless information * * @throws RestException */ function get($id) - { + { if(! DolibarrApiAccess::$user->rights->facture->lire) { throw new RestException(401); } - + $result = $this->invoice->fetch($id); if( ! $result ) { throw new RestException(404, 'Invoice not found'); } - + if( ! DolibarrApi::_checkAccessToResource('facture',$this->invoice->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -80,9 +80,9 @@ class Invoices extends DolibarrApi /** * List invoices - * + * * Get a list of invoices - * + * * @param string $sortfield Sort field * @param string $sortorder Sort order * @param int $limit Limit for list @@ -96,12 +96,12 @@ class Invoices extends DolibarrApi */ function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 0, $page = 0, $thirdparty_ids='', $status='', $sqlfilters = '') { global $db, $conf; - + $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; - + // If the internal user must only see his customers, force searching by him $search_sale = 0; if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) $search_sale = DolibarrApiAccess::$user->id; @@ -109,7 +109,7 @@ class Invoices extends DolibarrApi $sql = "SELECT t.rowid"; if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $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) $sql.= " FROM ".MAIN_DB_PREFIX."facture as t"; - + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale $sql.= ' WHERE t.entity IN ('.getEntity('facture').')'; @@ -117,7 +117,7 @@ class Invoices extends DolibarrApi if ($socids) $sql.= " AND t.fk_soc IN (".$socids.")"; if ($search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale - + // Filter by status if ($status == 'draft') $sql.= " AND t.fk_statut IN (0)"; if ($status == 'unpaid') $sql.= " AND t.fk_statut IN (1)"; @@ -129,7 +129,7 @@ class Invoices extends DolibarrApi $sql .= " AND sc.fk_user = ".$search_sale; } // Add sql filters - if ($sqlfilters) + if ($sqlfilters) { if (! DolibarrApi::_checkFilters($sqlfilters)) { @@ -138,7 +138,7 @@ class Invoices extends DolibarrApi $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } - + $sql.= $db->order($sortfield, $sortorder); if ($limit) { if ($page < 0) @@ -174,10 +174,10 @@ class Invoices extends DolibarrApi } return $obj_ret; } - + /** * Create invoice object - * + * * @param array $request_data Request datas * @return int ID of invoice */ @@ -188,7 +188,7 @@ class Invoices extends DolibarrApi } // Check mandatory fields $result = $this->_validate($request_data); - + foreach($request_data as $field => $value) { $this->invoice->$field = $value; } @@ -203,7 +203,7 @@ class Invoices extends DolibarrApi } $this->invoice->lines = $lines; }*/ - + if ($this->invoice->create(DolibarrApiAccess::$user) < 0) { throw new RestException(500, "Error creating invoice", array_merge(array($this->invoice->error), $this->invoice->errors)); } @@ -214,20 +214,20 @@ class Invoices extends DolibarrApi * Update invoice * * @param int $id Id of invoice to update - * @param array $request_data Datas - * @return int + * @param array $request_data Datas + * @return int */ function put($id, $request_data = NULL) { if(! DolibarrApiAccess::$user->rights->facture->creer) { throw new RestException(401); } - + $result = $this->invoice->fetch($id); if( ! $result ) { throw new RestException(404, 'Invoice not found'); } - + if( ! DolibarrApi::_checkAccessToResource('facture',$this->invoice->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -236,13 +236,13 @@ class Invoices extends DolibarrApi if ($field == 'id') continue; $this->invoice->$field = $value; } - + if($this->invoice->update($id, DolibarrApiAccess::$user)) return $this->get ($id); - + return false; } - + /** * Delete invoice * @@ -258,16 +258,16 @@ class Invoices extends DolibarrApi if( ! $result ) { throw new RestException(404, 'Invoice not found'); } - + if( ! DolibarrApi::_checkAccessToResource('facture',$this->invoice->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - + if( $this->invoice->delete($id) < 0) { throw new RestException(500); } - + return array( 'success' => array( 'code' => 200, @@ -275,13 +275,76 @@ class Invoices extends DolibarrApi ) ); } - + + /** + * Validate an order + * + * @param int $id Order ID + * @param int $idwarehouse Warehouse ID + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers + * + * @url POST {id}/validate + * + * @return array + * FIXME An error 403 is returned if the request has an empty body. + * Error message: "Forbidden: Content type `text/plain` is not supported." + * Workaround: send this in the body + * { + * "idwarehouse": 0, + * "notrigger": 0 + * } + */ + function validate($id, $idwarehouse=0, $notrigger=0) + { + if(! DolibarrApiAccess::$user->rights->facture->creer) { + throw new RestException(401); + } + $result = $this->invoice->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Invoice not found'); + } + + if( ! DolibarrApi::_checkAccessToResource('facture',$this->invoice->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + $result = $this->invoice->validate(DolibarrApiAccess::$user, '', $idwarehouse, $notrigger); + if ($result == 0) { + throw new RestException(500, 'Error nothing done. May be object is already validated'); + } + if ($result < 0) { + throw new RestException(500, 'Error when validating Invoice: '.$this->invoice->error); + } + + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Invoice validated (Ref='.$this->invoice->ref.')' + ) + ); + } + + /** + * Clean sensible object datas + * + * @param object $object Object to clean + * @return array Array of cleaned object properties + */ + function _cleanObjectDatas($object) { + + $object = parent::_cleanObjectDatas($object); + + unset($object->address); + + return $object; + } + /** * Validate fields before create or update object - * + * * @param array|null $data Datas to validate * @return array - * + * * @throws RestException */ function _validate($data) @@ -294,5 +357,5 @@ class Invoices extends DolibarrApi } return $invoice; } - + } diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index 72f27a16602..181e8a7fe11 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -2200,7 +2200,7 @@ function getModuleDirForApiClass($module) elseif ($module == 'stock' || $module == 'stockmovements' || $module == 'warehouses') { $moduledirforclass = 'product/stock'; } - elseif ($module == 'fournisseur' || $module == 'supplierinvoices') { + elseif ($module == 'fournisseur' || $module == 'supplierinvoices' || $module == 'supplierorders') { $moduledirforclass = 'fourn'; } elseif ($module == 'expensereports') { diff --git a/htdocs/fourn/class/api_supplier_invoices.class.php b/htdocs/fourn/class/api_supplier_invoices.class.php index 6f3291518ca..26ae936d5a0 100644 --- a/htdocs/fourn/class/api_supplier_invoices.class.php +++ b/htdocs/fourn/class/api_supplier_invoices.class.php @@ -23,14 +23,14 @@ require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; /** * API class for supplier invoices * - * @access protected + * @access protected * @class DolibarrApiAccess {@requires user,external} */ class SupplierInvoices extends DolibarrApi { /** * - * @var array $FIELDS Mandatory fields, checked when create and update object + * @var array $FIELDS Mandatory fields, checked when create and update object */ static $FIELDS = array( 'socid' @@ -55,24 +55,24 @@ class SupplierInvoices extends DolibarrApi * Get properties of a supplier invoice object * * Return an array with supplier invoice information - * + * * @param int $id ID of supplier invoice * @return array|mixed data without useless information * * @throws RestException */ function get($id) - { + { if(! DolibarrApiAccess::$user->rights->fournisseur->facture->lire) { throw new RestException(401); } - + $result = $this->invoice->fetch($id); if( ! $result ) { throw new RestException(404, 'Supplier invoice not found'); } - - if( ! DolibarrApi::_checkAccessToResource('facture',$this->invoice->id)) { + + if( ! DolibarrApi::_checkAccessToResource('fournisseur',$this->invoice->id,'facture_fourn','facture')) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -81,9 +81,9 @@ class SupplierInvoices extends DolibarrApi /** * List invoices - * + * * Get a list of supplier invoices - * + * * @param string $sortfield Sort field * @param string $sortorder Sort order * @param int $limit Limit for list @@ -97,12 +97,12 @@ class SupplierInvoices extends DolibarrApi */ function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 0, $page = 0, $thirdparty_ids='', $status='', $sqlfilters = '') { global $db, $conf; - + $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; - + // If the internal user must only see his customers, force searching by him $search_sale = 0; if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) $search_sale = DolibarrApiAccess::$user->id; @@ -110,14 +110,14 @@ class SupplierInvoices extends DolibarrApi $sql = "SELECT t.rowid"; if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $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) $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn as t"; - + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale $sql.= ' WHERE t.entity IN ('.getEntity('supplier_invoice').')'; if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc"; if ($socids) $sql.= " AND t.fk_soc IN (".$socids.")"; if ($search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale - + // Filter by status if ($status == 'draft') $sql.= " AND t.fk_statut IN (0)"; if ($status == 'unpaid') $sql.= " AND t.fk_statut IN (1)"; @@ -129,7 +129,7 @@ class SupplierInvoices extends DolibarrApi $sql .= " AND sc.fk_user = ".$search_sale; } // Add sql filters - if ($sqlfilters) + if ($sqlfilters) { if (! DolibarrApi::_checkFilters($sqlfilters)) { @@ -138,7 +138,7 @@ class SupplierInvoices extends DolibarrApi $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } - + $sql.= $db->order($sortfield, $sortorder); if ($limit) { if ($page < 0) @@ -174,10 +174,10 @@ class SupplierInvoices extends DolibarrApi } return $obj_ret; } - + /** * Create supplier invoice object - * + * * @param array $request_data Request datas * @return int ID of supplier invoice */ @@ -188,7 +188,7 @@ class SupplierInvoices extends DolibarrApi } // Check mandatory fields $result = $this->_validate($request_data); - + foreach($request_data as $field => $value) { $this->invoice->$field = $value; } @@ -203,7 +203,7 @@ class SupplierInvoices extends DolibarrApi } $this->invoice->lines = $lines; }*/ - + if ($this->invoice->create(DolibarrApiAccess::$user) < 0) { throw new RestException(500, "Error creating order", array_merge(array($this->invoice->error), $this->invoice->errors)); } @@ -214,21 +214,21 @@ class SupplierInvoices extends DolibarrApi * Update supplier invoice * * @param int $id Id of supplier invoice to update - * @param array $request_data Datas - * @return int + * @param array $request_data Datas + * @return int */ function put($id, $request_data = NULL) { if(! DolibarrApiAccess::$user->rights->fournisseur->facture->creer) { throw new RestException(401); } - + $result = $this->invoice->fetch($id); if( ! $result ) { throw new RestException(404, 'Supplier invoice not found'); } - - if( ! DolibarrApi::_checkAccessToResource('facture',$this->invoice->id)) { + + if( ! DolibarrApi::_checkAccessToResource('fournisseur',$this->invoice->id,'facture_fourn','facture')) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -236,13 +236,13 @@ class SupplierInvoices extends DolibarrApi if ($field == 'id') continue; $this->invoice->$field = $value; } - + if($this->invoice->update($id, DolibarrApiAccess::$user)) return $this->get ($id); - + return false; } - + /** * Delete supplier invoice * @@ -258,16 +258,16 @@ class SupplierInvoices extends DolibarrApi if( ! $result ) { throw new RestException(404, 'Supplier invoice not found'); } - - if( ! DolibarrApi::_checkAccessToResource('facture',$this->invoice->id)) { + + if( ! DolibarrApi::_checkAccessToResource('fournisseur',$this->invoice->id,'facture_fourn','facture')) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - + if( $this->invoice->delete(DolibarrApiAccess::$user) < 0) { throw new RestException(500); } - + return array( 'success' => array( 'code' => 200, @@ -275,8 +275,56 @@ class SupplierInvoices extends DolibarrApi ) ); } - - + + + /** + * Validate an order + * + * @param int $id Order ID + * @param int $idwarehouse Warehouse ID + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers + * + * @url POST {id}/validate + * + * @return array + * FIXME An error 403 is returned if the request has an empty body. + * Error message: "Forbidden: Content type `text/plain` is not supported." + * Workaround: send this in the body + * { + * "idwarehouse": 0, + * "notrigger": 0 + * } + */ + function validate($id, $idwarehouse=0, $notrigger=0) + { + if(! DolibarrApiAccess::$user->rights->fournisseur->facture->creer) { + throw new RestException(401); + } + $result = $this->invoice->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Invoice not found'); + } + + if( ! DolibarrApi::_checkAccessToResource('fournisseur',$this->invoice->id,'facture_fourn','facture')) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + $result = $this->invoice->validate(DolibarrApiAccess::$user, '', $idwarehouse, $notrigger); + if ($result == 0) { + throw new RestException(500, 'Error nothing done. May be object is already validated'); + } + if ($result < 0) { + throw new RestException(500, 'Error when validating Invoice: '.$this->invoice->error); + } + + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Invoice validated (Ref='.$this->invoice->ref.')' + ) + ); + } + /** * Clean sensible object datas * @@ -284,20 +332,20 @@ class SupplierInvoices extends DolibarrApi * @return array Array of cleaned object properties */ function _cleanObjectDatas($object) { - + $object = parent::_cleanObjectDatas($object); - + unset($object->rowid); - + return $object; } - + /** * Validate fields before create or update object - * + * * @param array $data Datas to validate * @return array - * + * * @throws RestException */ function _validate($data) diff --git a/htdocs/fourn/class/api_supplier_orders.class.php b/htdocs/fourn/class/api_supplier_orders.class.php new file mode 100644 index 00000000000..2695727c3ee --- /dev/null +++ b/htdocs/fourn/class/api_supplier_orders.class.php @@ -0,0 +1,365 @@ + + * Copyright (C) 2016 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 + * 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 . + */ + +use Luracast\Restler\RestException; + +require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; + +/** + * API class for supplier orders + * + * @access protected + * @class DolibarrApiAccess {@requires user,external} + */ +class SupplierOrders extends DolibarrApi +{ + /** + * + * @var array $FIELDS Mandatory fields, checked when create and update object + */ + static $FIELDS = array( + 'socid' + ); + + /** + * @var CommandeFournisseur $order {@type CommandeFournisseur} + */ + public $order; + + /** + * Constructor + */ + function __construct() + { + global $db, $conf; + $this->db = $db; + $this->order = new CommandeFournisseur($this->db); + } + + /** + * Get properties of a supplier order object + * + * Return an array with supplier order information + * + * @param int $id ID of supplier order + * @return array|mixed data without useless information + * + * @throws RestException + */ + function get($id) + { + if(! DolibarrApiAccess::$user->rights->fournisseur->commande->lire) { + throw new RestException(401); + } + + $result = $this->order->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Supplier order not found'); + } + + if( ! DolibarrApi::_checkAccessToResource('fournisseur',$this->order->id,'','commande')) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + return $this->_cleanObjectDatas($this->order); + } + + /** + * List orders + * + * Get a list of supplier orders + * + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param int $limit Limit for list + * @param int $page Page number + * @param string $thirdparty_ids Thirdparty ids to filter orders of. {@example '1' or '1,2,3'} {@pattern /^[0-9,]*$/i} + * @param string $status Filter by order status : draft | validated | approved | running | received_start | received_end | cancelled | refused + * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.datec:<:'20160101')" + * @return array Array of order objects + * + * @throws RestException + */ + function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 0, $page = 0, $thirdparty_ids='', $status='', $sqlfilters = '') { + global $db, $conf; + + $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; + + // If the internal user must only see his customers, force searching by him + $search_sale = 0; + if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) $search_sale = DolibarrApiAccess::$user->id; + + $sql = "SELECT t.rowid"; + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $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) + $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as t"; + + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale + + $sql.= ' WHERE t.entity IN ('.getEntity('supplier_order').')'; + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc"; + if ($socids) $sql.= " AND t.fk_soc IN (".$socids.")"; + if ($search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale + + // Filter by status + if ($status == 'draft') $sql.= " AND t.fk_statut IN (0)"; + if ($status == 'validated') $sql.= " AND t.fk_statut IN (1)"; + if ($status == 'approved') $sql.= " AND t.fk_statut IN (2)"; + if ($status == 'running') $sql.= " AND t.fk_statut IN (3)"; + if ($status == 'received_start') $sql.= " AND t.fk_statut IN (4)"; + if ($status == 'received_end') $sql.= " AND t.fk_statut IN (5)"; + if ($status == 'cancelled') $sql.= " AND t.fk_statut IN (6,7)"; + if ($status == 'refused') $sql.= " AND t.fk_statut IN (9)"; + // Insert sale filter + if ($search_sale > 0) + { + $sql .= " AND sc.fk_user = ".$search_sale; + } + // Add sql filters + if ($sqlfilters) + { + if (! DolibarrApi::_checkFilters($sqlfilters)) + { + throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); + } + $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + } + + $sql.= $db->order($sortfield, $sortorder); + if ($limit) { + if ($page < 0) + { + $page = 0; + } + $offset = $limit * $page; + + $sql.= $db->plimit($limit + 1, $offset); + } + + $result = $db->query($sql); + if ($result) + { + $i = 0; + $num = $db->num_rows($result); + $min = min($num, ($limit <= 0 ? $num : $limit)); + while ($i < $min) + { + $obj = $db->fetch_object($result); + $order_static = new CommandeFournisseur($db); + if($order_static->fetch($obj->rowid)) { + $obj_ret[] = $this->_cleanObjectDatas($order_static); + } + $i++; + } + } + else { + throw new RestException(503, 'Error when retrieve supplier order list : '.$db->lasterror()); + } + if( ! count($obj_ret)) { + throw new RestException(404, 'No supplier order found'); + } + return $obj_ret; + } + + /** + * Create supplier order object + * + * @param array $request_data Request datas + * @return int ID of supplier order + */ + function post($request_data = NULL) + { + if(! DolibarrApiAccess::$user->rights->fournisseur->commande->creer) { + throw new RestException(401, "Insuffisant rights"); + } + // Check mandatory fields + $result = $this->_validate($request_data); + + foreach($request_data as $field => $value) { + $this->order->$field = $value; + } + if(! array_keys($request_data,'date')) { + $this->order->date = dol_now(); + } + /* We keep lines as an array + if (isset($request_data["lines"])) { + $lines = array(); + foreach ($request_data["lines"] as $line) { + array_push($lines, (object) $line); + } + $this->order->lines = $lines; + }*/ + + if ($this->order->create(DolibarrApiAccess::$user) < 0) { + throw new RestException(500, "Error creating order", array_merge(array($this->order->error), $this->order->errors)); + } + return $this->order->id; + } + + /** + * Update supplier order + * + * @param int $id Id of supplier order to update + * @param array $request_data Datas + * @return int + */ + function put($id, $request_data = NULL) + { + if(! DolibarrApiAccess::$user->rights->fournisseur->commande->creer) { + throw new RestException(401); + } + + $result = $this->order->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Supplier order not found'); + } + + if( ! DolibarrApi::_checkAccessToResource('fournisseur',$this->order->id,'','commande')) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + foreach($request_data as $field => $value) { + if ($field == 'id') continue; + $this->order->$field = $value; + } + + if($this->order->update($id, DolibarrApiAccess::$user)) + return $this->get ($id); + + return false; + } + + /** + * Delete supplier order + * + * @param int $id Supplier order ID + * @return type + */ + function delete($id) + { + if(! DolibarrApiAccess::$user->rights->fournisseur->commande->supprimer) { + throw new RestException(401); + } + $result = $this->order->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Supplier order not found'); + } + + if( ! DolibarrApi::_checkAccessToResource('fournisseur',$this->order->id,'','commande')) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + if( $this->order->delete(DolibarrApiAccess::$user) < 0) + { + throw new RestException(500); + } + + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Supplier order deleted' + ) + ); + } + + + /** + * Validate an order + * + * @param int $id Order ID + * @param int $idwarehouse Warehouse ID + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers + * + * @url POST {id}/validate + * + * @return array + * FIXME An error 403 is returned if the request has an empty body. + * Error message: "Forbidden: Content type `text/plain` is not supported." + * Workaround: send this in the body + * { + * "idwarehouse": 0, + * "notrigger": 0 + * } + */ + function validate($id, $idwarehouse=0, $notrigger=0) + { + if(! DolibarrApiAccess::$user->rights->fournisseur->commande->creer) { + throw new RestException(401); + } + $result = $this->order->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Order not found'); + } + + if( ! DolibarrApi::_checkAccessToResource('fournisseur',$this->order->id,'','commande')) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + $result = $this->order->valid(DolibarrApiAccess::$user, $idwarehouse, $notrigger); + if ($result == 0) { + throw new RestException(500, 'Error nothing done. May be object is already validated'); + } + if ($result < 0) { + throw new RestException(500, 'Error when validating Order: '.$this->order->error); + } + + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Order validated (Ref='.$this->order->ref.')' + ) + ); + } + + /** + * Clean sensible object datas + * + * @param Object $object Object to clean + * @return array Array of cleaned object properties + */ + function _cleanObjectDatas($object) { + + $object = parent::_cleanObjectDatas($object); + + unset($object->rowid); + + return $object; + } + + /** + * Validate fields before create or update object + * + * @param array $data Datas to validate + * @return array + * + * @throws RestException + */ + function _validate($data) + { + $order = array(); + foreach (SupplierOrders::$FIELDS as $field) { + if (!isset($data[$field])) + throw new RestException(400, "$field field missing"); + $order[$field] = $data[$field]; + } + return $order; + } +} From f9442c10924d5c9c5a63abbfc8333bd748ff8c88 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 28 Jul 2017 11:10:00 +0200 Subject: [PATCH 011/207] Fix box activity --- htdocs/core/boxes/box_activity.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/htdocs/core/boxes/box_activity.php b/htdocs/core/boxes/box_activity.php index 8d8b2962688..ae3e270101e 100644 --- a/htdocs/core/boxes/box_activity.php +++ b/htdocs/core/boxes/box_activity.php @@ -83,17 +83,17 @@ class box_activity extends ModeleBoxes $cachetime = 3600; $fileid = '-e'.$conf->entity.'-u'.$user->id.'-s'.$user->societe_id.'-r'.($user->rights->societe->client->voir?'1':'0').'.cache'; $now = dol_now(); - $nbofyears=2; + $nbofperiod=3; - if (! empty($conf->global->MAIN_BOX_ACTIVITY_DURATION)) $nbofyears=$conf->global->MAIN_BOX_ACTIVITY_DURATION; - $textHead = $langs->trans("Activity").' - '.$langs->trans("LastXMonthRolling", $nbofyears*12); + if (! empty($conf->global->MAIN_BOX_ACTIVITY_DURATION)) $nbofperiod=$conf->global->MAIN_BOX_ACTIVITY_DURATION; + $textHead = $langs->trans("Activity").' - '.$langs->trans("LastXMonthRolling", $nbofperiod); $this->info_box_head = array( 'text' => $textHead, 'limit'=> dol_strlen($textHead), ); // compute the year limit to show - $tmpdate= dol_time_plus_duree(dol_now(), -1*$nbofyears, "y"); + $tmpdate= dol_time_plus_duree(dol_now(), -1*$nbofperiod, "m"); $cumuldata = array(); @@ -103,6 +103,7 @@ class box_activity extends ModeleBoxes include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; $facturestatic=new Facture($db); + // part 1 $cachedir = DOL_DATA_ROOT.'/facture/temp'; $filename = '/boxactivity-invoice'.$fileid; @@ -189,6 +190,7 @@ class box_activity extends ModeleBoxes ); } + // part 2 $cachedir = DOL_DATA_ROOT.'/facture/temp'; $filename = '/boxactivity-invoice2'.$fileid; From bfb904557f8a96b424c1046de8157dcc100bf854 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 28 Jul 2017 12:06:12 +0200 Subject: [PATCH 012/207] Fix include fails --- ChangeLog | 8 +++++--- htdocs/websites/index.php | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2417a7db682..bdc39167310 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,9 +4,11 @@ English Dolibarr ChangeLog ***** ChangeLog for 6.0.0 compared to 5.0.* ***** -NEW: Add experimental BlockeLog module (to log business events in a non reversible log file). NEW: Add a payment module for Stripe. -NEW: Add module "Product variant" (like red, blue for the product shoes) +NEW: Add "Non Reversible Logs" module as experimental (to log business events in a non reversible log file). +NEW: Add module "Product variant" as experimental (like red, blue for the product shoes) +NEW: Add module "Website" as experimental +NEW: Add module "Module Builder" as experimental NEW: Accountancy - Activate multi-journal & Add journal_label to database (FEC) NEW: Add a tracking id into mass emailing. NEW: Tax system more compatible with the new tax roollout in India (IGST / CGST / SGST). @@ -115,7 +117,7 @@ NEW: Add hook "formatNotificationMessage" NEW: Add index and constraints keys on supplier proposal detail table NEW: Add phpunit to check the engine is defined into sql create files. NEW: Add project and Hook to Loan -NEW: Add REST API to push a file. +NEW: Add more REST API (API to push a file, to manage supplier orders, to validate invoices) NEW: Allow extrafields list select to be dependands on other standard list and not only other extrafields list NEW: Architecture to manage search criteria persistance (using save_lastsearch_values=1 on exit links and restore_lastsearch_values=1 in entry links) NEW: data files are now also parsed by phpunit for sql syntax diff --git a/htdocs/websites/index.php b/htdocs/websites/index.php index 9fbd6e6a4e0..1881ffd95a2 100644 --- a/htdocs/websites/index.php +++ b/htdocs/websites/index.php @@ -568,7 +568,7 @@ if ($action == 'updatecontent' || GETPOST('refreshsite') || GETPOST('refreshpage $tplcontent =''; $tplcontent.= " Date: Fri, 28 Jul 2017 12:07:05 +0200 Subject: [PATCH 013/207] Revert "Fix include fails" This reverts commit bfb904557f8a96b424c1046de8157dcc100bf854. --- ChangeLog | 8 +++----- htdocs/websites/index.php | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index bdc39167310..2417a7db682 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,11 +4,9 @@ English Dolibarr ChangeLog ***** ChangeLog for 6.0.0 compared to 5.0.* ***** +NEW: Add experimental BlockeLog module (to log business events in a non reversible log file). NEW: Add a payment module for Stripe. -NEW: Add "Non Reversible Logs" module as experimental (to log business events in a non reversible log file). -NEW: Add module "Product variant" as experimental (like red, blue for the product shoes) -NEW: Add module "Website" as experimental -NEW: Add module "Module Builder" as experimental +NEW: Add module "Product variant" (like red, blue for the product shoes) NEW: Accountancy - Activate multi-journal & Add journal_label to database (FEC) NEW: Add a tracking id into mass emailing. NEW: Tax system more compatible with the new tax roollout in India (IGST / CGST / SGST). @@ -117,7 +115,7 @@ NEW: Add hook "formatNotificationMessage" NEW: Add index and constraints keys on supplier proposal detail table NEW: Add phpunit to check the engine is defined into sql create files. NEW: Add project and Hook to Loan -NEW: Add more REST API (API to push a file, to manage supplier orders, to validate invoices) +NEW: Add REST API to push a file. NEW: Allow extrafields list select to be dependands on other standard list and not only other extrafields list NEW: Architecture to manage search criteria persistance (using save_lastsearch_values=1 on exit links and restore_lastsearch_values=1 in entry links) NEW: data files are now also parsed by phpunit for sql syntax diff --git a/htdocs/websites/index.php b/htdocs/websites/index.php index 1881ffd95a2..9fbd6e6a4e0 100644 --- a/htdocs/websites/index.php +++ b/htdocs/websites/index.php @@ -568,7 +568,7 @@ if ($action == 'updatecontent' || GETPOST('refreshsite') || GETPOST('refreshpage $tplcontent =''; $tplcontent.= " Date: Fri, 28 Jul 2017 12:37:52 +0200 Subject: [PATCH 014/207] Module website not stable enough --- htdocs/core/modules/modWebsites.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/modWebsites.class.php b/htdocs/core/modules/modWebsites.class.php index 57abe371314..f3564c31367 100644 --- a/htdocs/core/modules/modWebsites.class.php +++ b/htdocs/core/modules/modWebsites.class.php @@ -50,7 +50,7 @@ class modWebsites extends DolibarrModules // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i','',get_class($this)); $this->description = "Enable to build and serve public websites with CMS features"; - $this->version = 'experimental'; // 'experimental' or 'dolibarr' or version + $this->version = 'development'; // 'experimental' or 'dolibarr' or version // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); // Where to store the module in setup page (0=common,1=interface,2=others,3=very specific) From 25c5ed8f7232d96d020898580bda8c2e050e74f7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 28 Jul 2017 18:09:38 +0200 Subject: [PATCH 015/207] Fix for compatibility --- htdocs/core/lib/ajax.lib.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/ajax.lib.php b/htdocs/core/lib/ajax.lib.php index 705bcf6deab..76a1458b913 100644 --- a/htdocs/core/lib/ajax.lib.php +++ b/htdocs/core/lib/ajax.lib.php @@ -46,6 +46,12 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption='', $minLengt { if (empty($minLength)) $minLength=1; + $dataforrenderITem='ui-autocomplete'; + $dataforitem='ui-autocomplete-item'; + // Allow two constant to use other values for backward compatibility + if (defined('JS_QUERY_AUTOCOMPLETE_RENDERITEM')) $dataforrenderITem=constant('JS_QUERY_AUTOCOMPLETE_RENDERITEM'); + if (defined('JS_QUERY_AUTOCOMPLETE_ITEM')) $dataforitem=constant('JS_QUERY_AUTOCOMPLETE_ITEM'); + // Input search_htmlname is original field // Input htmlname is a second input field used when using ajax autocomplete. $script = ''; @@ -185,10 +191,10 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption='', $minLengt $("#search_'.$htmlname.'").trigger("change"); // We have changed value of the combo select, we must be sure to trigger all js hook binded on this event. This is required to trigger other javascript change method binded on original field by other code. } ,delay: 500 - }).data("ui-autocomplete")._renderItem = function( ul, item ) { + }).data("'.$dataforrenderITem.'")._renderItem = function( ul, item ) { return $("
  • ") - .data( "ui-autocomplete-item", item ) // jQuery UI > 1.10.0 + .data( "'.$dataforitem.'", item ) // jQuery UI > 1.10.0 .append( \'\' + item.label + "" ) .appendTo(ul); }; From 5e17c2efb90cbdd0d6f3bb90529a15714cb489c6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 28 Jul 2017 23:32:55 +0200 Subject: [PATCH 016/207] Fix into filters of time consumed --- htdocs/core/lib/project.lib.php | 4 +++ htdocs/projet/activity/perday.php | 43 ++++++++++++++++++++++----- htdocs/projet/activity/perweek.php | 47 ++++++++++++++++++++++++------ htdocs/projet/list.php | 4 +-- 4 files changed, 79 insertions(+), 19 deletions(-) diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index c3583e72ac8..366413c376f 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -629,9 +629,11 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr print ''."\n"; // User + /* print ''; print $fuser->getNomUrl(1, 'withproject', 'time'); print ''; + */ // Ref print ''; @@ -835,9 +837,11 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$ print ''."\n"; // User + /* print ''; print $fuser->getNomUrl(1, 'withproject', 'time'); print ''; + */ // Ref print ''; diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index a7b243dd338..7b1f50bb50c 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -64,6 +64,7 @@ $day=GETPOST('reday')?GETPOST('reday'):(GETPOST("day","int")?GETPOST("day","int" $day = (int) $day; $week=GETPOST("week","int")?GETPOST("week","int"):date("W"); +$search_categ=GETPOST("search_categ",'alpha'); $search_usertoprocessid=GETPOST('search_usertoprocessid', 'int'); $search_task_ref=GETPOST('search_task_ref', 'alpha'); $search_task_label=GETPOST('search_task_label', 'alpha'); @@ -100,13 +101,14 @@ $object=new Task($db); if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers { $action = ''; + $search_categ=''; $search_usertoprocessid = ''; $search_task_ref = ''; $search_task_label = ''; $search_project_ref = ''; $search_thirdparty = ''; } -if (GETPOST("button_search_x") || GETPOST("button_search.x") || GETPOST("button_search")) +if (GETPOST("button_search_x",'alpha') || GETPOST("button_search.x",'alpha') || GETPOST("button_search",'alpha')) { $action = ''; } @@ -394,15 +396,41 @@ print ''; print '
    '; +$moreforfilter=''; + +// Filter on categories +/*if (! empty($conf->categorie->enabled)) +{ + require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; + $moreforfilter.='
    '; + $moreforfilter.=$langs->trans('ProjectCategories'). ': '; + $moreforfilter.=$formother->select_categories('project', $search_categ, 'search_categ', 1, 1, 'maxwidth300'); + $moreforfilter.='
    '; +}*/ + +// If the user can view user other than himself +$moreforfilter.='
    '; +$moreforfilter.=$langs->trans('ProjectsWithThisUserAsContact'). ': '; +$includeonly='hierachyme'; +if (empty($user->rights->user->user->lire)) $includeonly=array($user->id); +$moreforfilter.=$form->select_dolusers($search_project_user?$search_project_user:$usertoprocess->id, 'search_usertoprocessid', 0, null, 0, $includeonly, null, 0, 0, 0, '', 0, '', 'maxwidth200'); +$moreforfilter.='
    '; + +if (! empty($moreforfilter)) +{ + print '
    '; + print $moreforfilter; + $parameters=array(); + $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + print '
    '; +} + + print '
    '; print ''."\n"; print ''; -print ''; print ''; print ''; print ''; @@ -422,7 +450,6 @@ print ''; print "\n"; print ''; -print ''; print ''; print ''; print ''; @@ -454,7 +481,7 @@ if (count($tasksarray) > 0) } else { - print ''; + print ''; } print "
    '; -$usersettoshow='hierarchyme'; -if ($user->rights->projet->all->lire) $usersettoshow=''; -print $form->select_dolusers($usertoprocess->id, 'search_usertoprocessid', 0, null, 0, $usersettoshow, 0, 0, 0, 1, '', 0, '', 'maxwidth150'); -print '
    '.$langs->trans("User").''.$langs->trans("RefTask").''.$langs->trans("LabelTask").''.$langs->trans("ProjectRef").'
    '.$langs->trans("NoTasks").'
    '.$langs->trans("NoTasks").'
    "; print '
    '; diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php index 5f3e9b1aa20..3410ba1d949 100644 --- a/htdocs/projet/activity/perweek.php +++ b/htdocs/projet/activity/perweek.php @@ -65,6 +65,7 @@ $day=GETPOST('reday')?GETPOST('reday','int'):(GETPOST("day")?GETPOST("day","int" $day = (int) $day; $week=GETPOST("week","int")?GETPOST("week","int"):date("W"); +$search_categ=GETPOST("search_categ",'alpha'); $search_usertoprocessid=GETPOST('search_usertoprocessid', 'int'); $search_task_ref=GETPOST('search_task_ref', 'alpha'); $search_task_label=GETPOST('search_task_label', 'alpha'); @@ -113,13 +114,14 @@ $object=new Task($db); if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers { $action = ''; + $search_categ=''; $search_usertoprocessid = ''; $search_task_ref = ''; $search_task_label = ''; $search_project_ref = ''; $search_thirdparty = ''; } -if (GETPOST("button_search_x") || GETPOST("button_search.x") || GETPOST("button_search")) +if (GETPOST("button_search_x",'alpha') || GETPOST("button_search.x",'alpha') || GETPOST("button_search",'alpha')) { $action = ''; } @@ -313,6 +315,7 @@ $morewherefilter=''; if ($search_task_ref) $morewherefilter.=natural_search("t.ref", $search_task_ref); if ($search_task_label) $morewherefilter.=natural_search("t.label", $search_task_label); if ($search_thirdparty) $morewherefilter.=natural_search("s.nom", $search_thirdparty); + $tasksarray=$taskstatic->getTasksArray(0, 0, ($project->id?$project->id:0), $socid, 0, $search_project_ref, $onlyopenedproject, $morewherefilter); // We want to see all task of opened project i am allowed to see, not only mine. Later only mine will be editable later. $projectsrole=$taskstatic->getUserRolesForProjectsOrTasks($usertoprocess, 0, ($project->id?$project->id:0), 0, $onlyopenedproject); $tasksrole=$taskstatic->getUserRolesForProjectsOrTasks(0, $usertoprocess, ($project->id?$project->id:0), 0, $onlyopenedproject); @@ -387,15 +390,42 @@ print ''; print '
    '; +$moreforfilter=''; + +// Filter on categories +/* +if (! empty($conf->categorie->enabled)) +{ + require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; + $moreforfilter.='
    '; + $moreforfilter.=$langs->trans('ProjectCategories'). ': '; + $moreforfilter.=$formother->select_categories('project', $search_categ, 'search_categ', 1, 1, 'maxwidth300'); + $moreforfilter.='
    '; +}*/ + +// If the user can view user other than himself +$moreforfilter.='
    '; +$moreforfilter.=$langs->trans('ProjectsWithThisUserAsContact'). ': '; +$includeonly='hierachyme'; +if (empty($user->rights->user->user->lire)) $includeonly=array($user->id); +$moreforfilter.=$form->select_dolusers($search_project_user?$search_project_user:$usertoprocess->id, 'search_usertoprocessid', 0, null, 0, $includeonly, null, 0, 0, 0, '', 0, '', 'maxwidth200'); +$moreforfilter.='
    '; + +if (! empty($moreforfilter)) +{ + print '
    '; + print $moreforfilter; + $parameters=array(); + $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + print '
    '; +} + + print '
    '; print ''."\n"; print ''; -print ''; print ''; print ''; print ''; @@ -416,7 +446,6 @@ print ''; print "\n"; print ''; -print ''; print ''; print ''; print ''; @@ -453,7 +482,7 @@ if (count($tasksarray) > 0) $level=0; projectLinesPerWeek($j, $firstdaytoshow, $usertoprocess, 0, $tasksarray, $level, $projectsrole, $tasksrole, $mine, $restrictviewformytask); - $colspan=8; + $colspan=7; if (! empty($conf->global->PROJECT_LINES_PERWEEK_SHOW_THIRDPARTY)) $colspan++; print ' @@ -470,7 +499,7 @@ if (count($tasksarray) > 0) } else { - print ''; + print ''; } print "
    '; -$usersettoshow='hierarchyme'; -if ($user->rights->projet->all->lire) $usersettoshow=''; -print $form->select_dolusers($usertoprocess->id, 'search_usertoprocessid', 0, null, 0, $usersettoshow, 0, 0, 0, 1, '', 0, '', 'maxwidth150'); -print '
    '.$langs->trans("User").''.$langs->trans("RefTask").''.$langs->trans("LabelTask").''.$langs->trans("ProjectRef").'
    '.$langs->trans("NoTasks").'
    '.$langs->trans("NoTasks").'
    "; print '
    '; diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 1bf65decd71..9e2971195e3 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -371,6 +371,7 @@ llxHeader("", $title, $help_url); $param=''; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; +if ($search_all != '') $param.='&search_all='.$search_all; if ($search_sday) $param.='&search_sday='.$search_sday; if ($search_smonth) $param.='&search_smonth='.$search_smonth; if ($search_syear) $param.='&search_syear=' .$search_syear; @@ -378,7 +379,6 @@ if ($search_eday) $param.='&search_eday='.$search_eday; if ($search_emonth) $param.='&search_emonth='.$search_emonth; if ($search_eyear) $param.='&search_eyear=' .$search_eyear; if ($socid) $param.='&socid='.$socid; -if ($search_all != '') $param.='&search_all='.$search_all; if ($search_ref != '') $param.='&search_ref='.$search_ref; if ($search_label != '') $param.='&search_label='.$search_label; if ($search_societe != '') $param.='&search_societe='.$search_societe; @@ -451,7 +451,7 @@ if (! empty($conf->categorie->enabled)) // If the user can view user other than himself $moreforfilter.='
    '; $moreforfilter.=$langs->trans('ProjectsWithThisUserAsContact'). ': '; -$includeonly=''; +$includeonly='hierachyme'; if (empty($user->rights->user->user->lire)) $includeonly=array($user->id); $moreforfilter.=$form->select_dolusers($search_project_user?$search_project_user:'', 'search_project_user', 1, '', 0, $includeonly, '', 0, 0, 0, '', 0, '', 'maxwidth200'); $moreforfilter.='
    '; From af63dc76c1c4d00f4e115e3f3ae6fd27cbbfefcf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 28 Jul 2017 23:46:11 +0200 Subject: [PATCH 017/207] Fix flex problems --- htdocs/theme/eldy/style.css.php | 2 +- htdocs/theme/md/style.css.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 7bd3d913782..cd2c0f95582 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -2805,7 +2805,7 @@ div.tabBar .noborder { } .boxstats { padding: 3px; - width: 105px; + width: 103px; } .boxstats130 { width: 160px; diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index b190a3fad67..cf787f09071 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -2889,7 +2889,7 @@ div .tdtop { } .boxstats { padding: 3px; - width: 105px; + width: 100px; } .boxstats130 { width: 135px; From 8b82fc3c708ccb03b2fd1303ec5c3444b86646be Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 29 Jul 2017 00:28:41 +0200 Subject: [PATCH 018/207] Fix project edition on loan menu Fix translation on profit view of projects. --- htdocs/loan/card.php | 36 +++++++++++++++++++----------------- htdocs/loan/document.php | 34 ++++++++++++++++++++++++++++++++-- htdocs/loan/info.php | 34 ++++++++++++++++++++++++++++++++-- htdocs/loan/note.php | 34 ++++++++++++++++++++++++++++++++-- htdocs/projet/element.php | 32 ++++++++++++++++---------------- 5 files changed, 131 insertions(+), 39 deletions(-) diff --git a/htdocs/loan/card.php b/htdocs/loan/card.php index 29cea1eb019..4f61aa833bf 100644 --- a/htdocs/loan/card.php +++ b/htdocs/loan/card.php @@ -41,6 +41,8 @@ $action=GETPOST('action','aZ09'); $confirm=GETPOST('confirm'); $cancel=GETPOST('cancel','alpha'); +$projectid = GETPOST('projectid','int'); + // Security check $socid = GETPOST('socid','int'); if ($user->societe_id) $socid=$user->societe_id; @@ -133,7 +135,7 @@ if (empty($reshook)) $object->rate = $rate; $object->note_private = GETPOST('note_private'); $object->note_public = GETPOST('note_public'); - $object->fk_project = GETPOST('fk_project'); + $object->fk_project = GETPOST('projectid','int'); $accountancy_account_capital = GETPOST('accountancy_account_capital'); $accountancy_account_insurance = GETPOST('accountancy_account_insurance'); @@ -215,7 +217,7 @@ if (empty($reshook)) if ($action == 'classin' && $user->rights->loan->write) { $object->fetch($id); - $result = $object->setProject(GETPOST('projectid')); + $result = $object->setProject($projectid); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } @@ -309,7 +311,7 @@ if ($action == 'create') print ''.$langs->trans("Project").''; - $numproject=$formproject->select_projects(-1,GETPOST("fk_project"),'fk_project',16,0,1,1); + $numproject=$formproject->select_projects(-1, $projectid, 'projectid', 16, 0, 1, 1); print ''; } @@ -443,21 +445,21 @@ if ($id > 0) { $langs->load("projects"); $morehtmlref.='
    '.$langs->trans('Project') . ' '; - if ($user->rights->commande->creer) + if ($user->rights->loan->write) { - if ($action != 'classify') - $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.=''; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } + if ($action != 'classify') + $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
    '; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
    '; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } } else { if (! empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/loan/document.php b/htdocs/loan/document.php index f4f490a146a..b43261d2b9d 100644 --- a/htdocs/loan/document.php +++ b/htdocs/loan/document.php @@ -89,8 +89,38 @@ if ($object->id) $morehtmlref='
    '; // Ref loan - $morehtmlref.=$form->editfieldkey("Label", 'label', $object->label, $object, $user->rights->loan->write, 'string', '', 0, 1); - $morehtmlref.=$form->editfieldval("Label", 'label', $object->label, $object, $user->rights->loan->write, 'string', '', null, null, '', 1); + $morehtmlref.=$form->editfieldkey("Label", 'label', $object->label, $object, 0, 'string', '', 0, 1); + $morehtmlref.=$form->editfieldval("Label", 'label', $object->label, $object, 0, 'string', '', null, null, '', 1); + // Project + if (! empty($conf->projet->enabled)) { + $langs->load("projects"); + $morehtmlref .= '
    ' . $langs->trans('Project') . ' : '; + if ($user->rights->loan->write) { + //if ($action != 'classify') + // $morehtmlref .= '' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + if ($action == 'classify') { + // $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref .= '
    '; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= '
    '; + } else { + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (! empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref .= ''; + $morehtmlref .= $proj->ref; + $morehtmlref .= ''; + } else { + $morehtmlref .= ''; + } + } + } $morehtmlref.='
    '; $linkback = '' . $langs->trans("BackToList") . ''; diff --git a/htdocs/loan/info.php b/htdocs/loan/info.php index 73bb1c1f984..96da6182da6 100644 --- a/htdocs/loan/info.php +++ b/htdocs/loan/info.php @@ -57,8 +57,38 @@ dol_fiche_head($head, 'info', $langs->trans("Loan"), -1, 'bill'); $morehtmlref='
    '; // Ref loan -$morehtmlref.=$form->editfieldkey("Label", 'label', $object->label, $object, $user->rights->loan->write, 'string', '', 0, 1); -$morehtmlref.=$form->editfieldval("Label", 'label', $object->label, $object, $user->rights->loan->write, 'string', '', null, null, '', 1); +$morehtmlref.=$form->editfieldkey("Label", 'label', $object->label, $object, 0, 'string', '', 0, 1); +$morehtmlref.=$form->editfieldval("Label", 'label', $object->label, $object, 0, 'string', '', null, null, '', 1); +// Project +if (! empty($conf->projet->enabled)) { + $langs->load("projects"); + $morehtmlref .= '
    ' . $langs->trans('Project') . ' : '; + if ($user->rights->loan->write) { + //if ($action != 'classify') + // $morehtmlref .= '' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + if ($action == 'classify') { + // $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref .= '
    '; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= '
    '; + } else { + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (! empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref .= ''; + $morehtmlref .= $proj->ref; + $morehtmlref .= ''; + } else { + $morehtmlref .= ''; + } + } +} $morehtmlref.='
    '; $linkback = '' . $langs->trans("BackToList") . ''; diff --git a/htdocs/loan/note.php b/htdocs/loan/note.php index 4b76cad1d6d..5f435444f32 100644 --- a/htdocs/loan/note.php +++ b/htdocs/loan/note.php @@ -74,8 +74,38 @@ if ($id > 0) $morehtmlref='
    '; // Ref loan - $morehtmlref.=$form->editfieldkey("Label", 'label', $object->label, $object, $user->rights->loan->write, 'string', '', 0, 1); - $morehtmlref.=$form->editfieldval("Label", 'label', $object->label, $object, $user->rights->loan->write, 'string', '', null, null, '', 1); + $morehtmlref.=$form->editfieldkey("Label", 'label', $object->label, $object, 0, 'string', '', 0, 1); + $morehtmlref.=$form->editfieldval("Label", 'label', $object->label, $object, 0, 'string', '', null, null, '', 1); + // Project + if (! empty($conf->projet->enabled)) { + $langs->load("projects"); + $morehtmlref .= '
    ' . $langs->trans('Project') . ' : '; + if ($user->rights->loan->write) { + //if ($action != 'classify') + // $morehtmlref .= '' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + if ($action == 'classify') { + // $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref .= '
    '; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= '
    '; + } else { + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (! empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref .= ''; + $morehtmlref .= $proj->ref; + $morehtmlref .= ''; + } else { + $morehtmlref .= ''; + } + } + } $morehtmlref.='
    '; $linkback = '' . $langs->trans("BackToList") . ''; diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index 93e15f2fe77..bda8d793840 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -336,7 +336,7 @@ $listofreferent=array( 'table'=>'fichinter', 'datefieldname'=>'date_valid', 'disableamount'=>0, - 'margin'=>'minus', + 'margin'=>'minus', 'urlnew'=>DOL_URL_ROOT.'/fichinter/card.php?action=create&origin=project&originid='.$id.'&socid='.$socid, 'lang'=>'interventions', 'buttonnew'=>'AddIntervention', @@ -417,9 +417,9 @@ $listofreferent=array( 'lang'=>'compta', 'buttonnew'=>'AddSocialContribution', 'testnew'=>$user->rights->tax->charges->lire, - 'test'=>$conf->tax->enabled && $user->rights->tax->charges->lire), + 'test'=>$conf->tax->enabled && $user->rights->tax->charges->lire), 'project_task'=>array( - 'name'=>"TaskTimeValorised", + 'name'=>"TaskTimeSpent", 'title'=>"ListTaskTimeUserProject", 'class'=>'Task', 'margin'=>'minus', @@ -573,7 +573,7 @@ foreach ($listofreferent as $key => $value) if ($tablename != 'expensereport_det' && method_exists($element, 'fetch_thirdparty')) $element->fetch_thirdparty(); if ($tablename == 'don' || $tablename == 'chargesociales') $total_ht_by_line=$element->amount; elseif ($tablename == 'stock_mouvement') $total_ht_by_line=$element->price*abs($element->qty); - else if($tablename == 'fichinter') $total_ht_by_line=$element->getAmount(); + else if($tablename == 'fichinter') $total_ht_by_line=$element->getAmount(); elseif ($tablename == 'projet_task') { if ($idofelementuser) @@ -598,7 +598,7 @@ foreach ($listofreferent as $key => $value) if ($qualifiedfortotal) $total_ht = $total_ht + $total_ht_by_line; if ($tablename == 'don' || $tablename == 'chargesociales') $total_ttc_by_line=$element->amount; - else if($tablename == 'fichinter') $total_ttc_by_line=$element->getAmount(); + else if($tablename == 'fichinter') $total_ttc_by_line=$element->getAmount(); elseif ($tablename == 'stock_mouvement') $total_ttc_by_line=$element->price*abs($element->qty); elseif ($tablename == 'projet_task') { @@ -629,7 +629,7 @@ foreach ($listofreferent as $key => $value) $total_ttc = -$total_ttc; } - switch ($classname) { + /*switch ($classname) { case 'FactureFournisseur': $newclassname = 'SupplierInvoice'; break; @@ -653,12 +653,12 @@ foreach ($listofreferent as $key => $value) break; default: $newclassname = $classname; - } + }*/ $var = ! $var; print ''; // Module - print ''.$langs->trans($newclassname).''; + print ''.$name.''; // Nb print ''.$i.''; // Amount HT @@ -711,7 +711,7 @@ foreach ($listofreferent as $key => $value) $idtofilterthirdparty=0; $array_of_element_linkable_with_different_thirdparty = array('facture_fourn', 'commande_fournisseur'); - if (! in_array($tablename, $array_of_element_linkable_with_different_thirdparty)) + if (! in_array($tablename, $array_of_element_linkable_with_different_thirdparty)) { $idtofilterthirdparty=$object->thirdparty->id; if (! empty($conf->global->PROJECT_OTHER_THIRDPARTY_ID_TO_ADD_ELEMENTS)) $idtofilterthirdparty.=','.$conf->global->PROJECT_OTHER_THIRDPARTY_ID_TO_ADD_ELEMENTS; @@ -854,7 +854,7 @@ foreach ($listofreferent as $key => $value) print '' . img_picto($langs->trans('Unlink'), 'editdelete') . ''; } print "\n"; - + // Ref print ''; if ($tablename == 'expensereport_det') @@ -922,7 +922,7 @@ foreach ($listofreferent as $key => $value) print dol_print_date($element->datep,'dayhour'); if ($element->datef && $element->datef > $element->datep) print " - ".dol_print_date($element->datef,'dayhour'); } - else if (in_array($tablename, array('projet_task'))) + else if (in_array($tablename, array('projet_task'))) { $tmpprojtime = $element->getSumOfAmount($elementuser, $dates, $datee); // $element is a task. $elementuser may be empty print ''; @@ -1018,7 +1018,7 @@ foreach ($listofreferent as $key => $value) else { $othermessage=$form->textwithpicto($langs->trans("NotAvailable"), $langs->trans("ModuleSalaryToDefineHourlyRateMustBeEnabled")); - } + } } else { @@ -1074,8 +1074,8 @@ foreach ($listofreferent as $key => $value) $total_ht_by_third += $total_ht_by_line; $total_ttc_by_third += $total_ttc_by_line; - - $total_time = $total_time + $total_time_by_line; + + $total_time = $total_time + $total_time_by_line; } if (canApplySubtotalOn($tablename)) @@ -1115,7 +1115,7 @@ foreach ($listofreferent as $key => $value) //if (empty($value['disableamount']) && ! in_array($tablename, array('projet_task'))) print ''.$langs->trans("TotalHT").' : '.price($total_ht).''; //elseif (empty($value['disableamount']) && in_array($tablename, array('projet_task'))) print ''.$langs->trans("Total").' : '.price($total_ht).''; print ''; - if (empty($value['disableamount'])) + if (empty($value['disableamount'])) { if ($tablename != 'projet_task' || ! empty($conf->salaries->enabled)) print ''.$langs->trans("TotalHT").' : '.price($total_ht); } @@ -1123,7 +1123,7 @@ foreach ($listofreferent as $key => $value) //if (empty($value['disableamount']) && ! in_array($tablename, array('projet_task'))) print ''.$langs->trans("TotalTTC").' : '.price($total_ttc).''; //elseif (empty($value['disableamount']) && in_array($tablename, array('projet_task'))) print ''; print ''; - if (empty($value['disableamount'])) + if (empty($value['disableamount'])) { if ($tablename != 'projet_task' || ! empty($conf->salaries->enabled)) print $langs->trans("TotalTTC").' : '.price($total_ttc); } From cae21d3937684cb77488a4eda2012e30fcde2529 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 29 Jul 2017 01:59:26 +0200 Subject: [PATCH 019/207] Fix in agenda output per user/type (reduce memory usage) --- htdocs/comm/action/pertype.php | 61 ++++++++++++++----------- htdocs/comm/action/peruser.php | 81 ++++++++++++++++++--------------- htdocs/projet/ganttview.php | 42 ++++++++--------- htdocs/theme/eldy/style.css.php | 9 ++++ htdocs/theme/md/style.css.php | 11 +++++ 5 files changed, 120 insertions(+), 84 deletions(-) diff --git a/htdocs/comm/action/pertype.php b/htdocs/comm/action/pertype.php index cd96a4fa8ad..589a2731f1b 100644 --- a/htdocs/comm/action/pertype.php +++ b/htdocs/comm/action/pertype.php @@ -38,7 +38,7 @@ if (! empty($conf->projet->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class if (! isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW=3; -$filter = GETPOST("filter",'',3); +$filter = GETPOST("filter",'alpha',3); $filtert = GETPOST("filtert","int",3); $usergroup = GETPOST("usergroup","int",3); //if (! ($usergroup > 0) && ! ($filtert > 0)) $filtert = $user->id; @@ -82,9 +82,9 @@ $month=GETPOST("month","int")?GETPOST("month","int"):date("m"); $week=GETPOST("week","int")?GETPOST("week","int"):date("W"); $day=GETPOST("day","int")?GETPOST("day","int"):date("d"); $pid=GETPOST("projectid","int",3); -$status=GETPOST("status"); -$type=GETPOST("type"); -$maxprint=(isset($_GET["maxprint"])?GETPOST("maxprint"):$conf->global->AGENDA_MAX_EVENTS_DAY_VIEW); +$status=GETPOST("status",'alpha'); +$type=GETPOST("type",'alpha'); +$maxprint=((GETPOST("maxprint",'int')!='')?GETPOST("maxprint",'int'):$conf->global->AGENDA_MAX_EVENTS_DAY_VIEW); // Set actioncode (this code must be same for setting actioncode into peruser, listacton and index) if (GETPOST('actioncode','array')) { @@ -97,18 +97,18 @@ else } if ($actioncode == '' && empty($actioncodearray)) $actioncode=(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE); -$dateselect=dol_mktime(0, 0, 0, GETPOST('dateselectmonth'), GETPOST('dateselectday'), GETPOST('dateselectyear')); +$dateselect=dol_mktime(0, 0, 0, GETPOST('dateselectmonth','int'), GETPOST('dateselectday','int'), GETPOST('dateselectyear','int')); if ($dateselect > 0) { - $day=GETPOST('dateselectday'); - $month=GETPOST('dateselectmonth'); - $year=GETPOST('dateselectyear'); + $day=GETPOST('dateselectday','int'); + $month=GETPOST('dateselectmonth','int'); + $year=GETPOST('dateselectyear','int'); } $tmp=empty($conf->global->MAIN_DEFAULT_WORKING_HOURS)?'9-18':$conf->global->MAIN_DEFAULT_WORKING_HOURS; $tmparray=explode('-',$tmp); -$begin_h = GETPOST('begin_h')!=''?GETPOST('begin_h','int'):($tmparray[0] != '' ? $tmparray[0] : 9); -$end_h = GETPOST('end_h')?GETPOST('end_h'):($tmparray[1] != '' ? $tmparray[1] : 18); +$begin_h = GETPOST('begin_h','int')!=''?GETPOST('begin_h','int'):($tmparray[0] != '' ? $tmparray[0] : 9); +$end_h = GETPOST('end_h','int')?GETPOST('end_h','int'):($tmparray[1] != '' ? $tmparray[1] : 18); if ($begin_h < 0 || $begin_h > 23) $begin_h = 9; if ($end_h < 1 || $end_h > 24) $end_h = 18; if ($end_h <= $begin_h) $end_h = $begin_h + 1; @@ -124,13 +124,13 @@ if (empty($action) && ! isset($_GET['action']) && ! isset($_POST['action'])) $ac if (GETPOST('viewcal') && $action != 'show_day' && $action != 'show_week' && $action != 'show_peruser') { $action='show_month'; $day=''; } // View by month -if (GETPOST('viewweek') || $action == 'show_week') { +if (GETPOST('viewweek','alpha') || $action == 'show_week') { $action='show_week'; $week=($week?$week:date("W")); $day=($day?$day:date("d")); } // View by week -if (GETPOST('viewday') || $action == 'show_day') { +if (GETPOST('viewday','alpha') || $action == 'show_day') { $action='show_day'; $day=($day?$day:date("d")); } // View by day -if (GETPOST('viewyear') || $action == 'show_year') { +if (GETPOST('viewyear','alpha') || $action == 'show_year') { $action='show_year'; } // View by year @@ -161,12 +161,12 @@ if ($action =='delete_action') * View */ -$help_url='EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda'; -llxHeader('',$langs->trans("Agenda"),$help_url); - $form=new Form($db); $companystatic=new Societe($db); +$help_url='EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda'; +llxHeader('',$langs->trans("Agenda"),$help_url); + $now=dol_now(); $nowarray=dol_getdate($now); $nowyear=$nowarray['year']; @@ -456,11 +456,14 @@ if ($resql) continue; } + $datep=$db->jdate($obj->datep); + $datep2=$db->jdate($obj->datep2); + // Create a new object action $event=new ActionComm($db); $event->id=$obj->id; - $event->datep=$db->jdate($obj->datep); // datep and datef are GMT date - $event->datef=$db->jdate($obj->datep2); + $event->datep=$datep; // datep and datef are GMT date + $event->datef=$datep2; $event->type_code=$obj->code; $event->type_color=$obj->color; //$event->libelle=$obj->label; // deprecated @@ -469,7 +472,6 @@ if ($resql) //$event->author->id=$obj->fk_user_author; // user id of creator $event->authorid=$obj->fk_user_author; // user id of creator $event->userownerid=$obj->fk_user_action; // user id of owner - $event->fetch_userassigned(); // This load $event->userassigned $event->priority=$obj->priority; $event->fulldayevent=$obj->fulldayevent; $event->location=$obj->location; @@ -487,15 +489,15 @@ if ($resql) // They are date start and end of action but modified to not be outside calendar view. if ($event->percentage <= 0) { - $event->date_start_in_calendar=$event->datep; - if ($event->datef != '' && $event->datef >= $event->datep) $event->date_end_in_calendar=$event->datef; - else $event->date_end_in_calendar=$event->datep; + $event->date_start_in_calendar=$datep; + if ($datep2 != '' && $datep2 >= $datep) $event->date_end_in_calendar=$datep2; + else $event->date_end_in_calendar=$datep; } else - { - $event->date_start_in_calendar=$event->datep; - if ($event->datef != '' && $event->datef >= $event->datep) $event->date_end_in_calendar=$event->datef; - else $event->date_end_in_calendar=$event->datep; + { + $event->date_start_in_calendar=$datep; + if ($datep2 != '' && $datep2 >= $datep) $event->date_end_in_calendar=$datep2; + else $event->date_end_in_calendar=$datep; } // Define ponctual property if ($event->date_start_in_calendar == $event->date_end_in_calendar) @@ -508,10 +510,14 @@ if ($resql) $event->date_start_in_calendar >= $lastdaytoshow) { // This record is out of visible range + unset($event); } else { - if ($event->date_start_in_calendar < $firstdaytoshow) $event->date_start_in_calendar=$firstdaytoshow; + //print $i.' - '.dol_print_date($this->date_start_in_calendar, 'dayhour').' - '.dol_print_date($this->date_end_in_calendar, 'dayhour').'
    '."\n"; + $event->fetch_userassigned(); // This load $event->userassigned + + if ($event->date_start_in_calendar < $firstdaytoshow) $event->date_start_in_calendar=$firstdaytoshow; if ($event->date_end_in_calendar >= $lastdaytoshow) $event->date_end_in_calendar=($lastdaytoshow - 1); // Add an entry in actionarray for each day @@ -928,6 +934,7 @@ function show_day_events_pertype($username, $day, $month, $year, $monthshown, $s } } + // Now output $casesX for ($h = $begin_h; $h < $end_h; $h++) { $color1='';$color2=''; diff --git a/htdocs/comm/action/peruser.php b/htdocs/comm/action/peruser.php index 7453b84d477..364e63d8a1b 100644 --- a/htdocs/comm/action/peruser.php +++ b/htdocs/comm/action/peruser.php @@ -38,7 +38,7 @@ if (! empty($conf->projet->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class if (! isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW=3; -$filter = GETPOST("filter",'',3); +$filter = GETPOST("filter",'alpha',3); $filtert = GETPOST("filtert","int",3); $usergroup = GETPOST("usergroup","int",3); //if (! ($usergroup > 0) && ! ($filtert > 0)) $filtert = $user->id; @@ -82,9 +82,9 @@ $month=GETPOST("month","int")?GETPOST("month","int"):date("m"); $week=GETPOST("week","int")?GETPOST("week","int"):date("W"); $day=GETPOST("day","int")?GETPOST("day","int"):date("d"); $pid=GETPOST("projectid","int",3); -$status=GETPOST("status"); -$type=GETPOST("type"); -$maxprint=(isset($_GET["maxprint"])?GETPOST("maxprint"):$conf->global->AGENDA_MAX_EVENTS_DAY_VIEW); +$status=GETPOST("status",'alpha'); +$type=GETPOST("type",'alpha'); +$maxprint=((GETPOST("maxprint",'int')!='')?GETPOST("maxprint",'int'):$conf->global->AGENDA_MAX_EVENTS_DAY_VIEW); // Set actioncode (this code must be same for setting actioncode into peruser, listacton and index) if (GETPOST('actioncode','array')) { @@ -96,26 +96,26 @@ else $actioncode=GETPOST("actioncode","alpha",3)?GETPOST("actioncode","alpha",3):(GETPOST("actioncode")=='0'?'0':(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE)); } if ($actioncode == '' && empty($actioncodearray)) $actioncode=(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE); -$dateselect=dol_mktime(0, 0, 0, GETPOST('dateselectmonth'), GETPOST('dateselectday'), GETPOST('dateselectyear')); +$dateselect=dol_mktime(0, 0, 0, GETPOST('dateselectmonth','int'), GETPOST('dateselectday','int'), GETPOST('dateselectyear','int')); if ($dateselect > 0) { - $day=GETPOST('dateselectday'); - $month=GETPOST('dateselectmonth'); - $year=GETPOST('dateselectyear'); + $day=GETPOST('dateselectday','int'); + $month=GETPOST('dateselectmonth','int'); + $year=GETPOST('dateselectyear','int'); } $tmp=empty($conf->global->MAIN_DEFAULT_WORKING_HOURS)?'9-18':$conf->global->MAIN_DEFAULT_WORKING_HOURS; $tmparray=explode('-',$tmp); -$begin_h = GETPOST('begin_h')!=''?GETPOST('begin_h','int'):($tmparray[0] != '' ? $tmparray[0] : 9); -$end_h = GETPOST('end_h')?GETPOST('end_h'):($tmparray[1] != '' ? $tmparray[1] : 18); +$begin_h = GETPOST('begin_h','int')!=''?GETPOST('begin_h','int'):($tmparray[0] != '' ? $tmparray[0] : 9); +$end_h = GETPOST('end_h','int')?GETPOST('end_h','int'):($tmparray[1] != '' ? $tmparray[1] : 18); if ($begin_h < 0 || $begin_h > 23) $begin_h = 9; if ($end_h < 1 || $end_h > 24) $end_h = 18; if ($end_h <= $begin_h) $end_h = $begin_h + 1; $tmp=empty($conf->global->MAIN_DEFAULT_WORKING_DAYS)?'1-5':$conf->global->MAIN_DEFAULT_WORKING_DAYS; $tmparray=explode('-',$tmp); -$begin_d = GETPOST('begin_d')?GETPOST('begin_d','int'):($tmparray[0] != '' ? $tmparray[0] : 1); -$end_d = GETPOST('end_d')?GETPOST('end_d'):($tmparray[1] != '' ? $tmparray[1] : 5); +$begin_d = GETPOST('begin_d','int')?GETPOST('begin_d','int'):($tmparray[0] != '' ? $tmparray[0] : 1); +$end_d = GETPOST('end_d','int')?GETPOST('end_d','int'):($tmparray[1] != '' ? $tmparray[1] : 5); if ($begin_d < 1 || $begin_d > 7) $begin_d = 1; if ($end_d < 1 || $end_d > 7) $end_d = 7; if ($end_d < $begin_d) $end_d = $begin_d + 1; @@ -123,13 +123,13 @@ if ($end_d < $begin_d) $end_d = $begin_d + 1; if ($status == '' && ! isset($_GET['status']) && ! isset($_POST['status'])) $status=(empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS)?'':$conf->global->AGENDA_DEFAULT_FILTER_STATUS); if (empty($action) && ! isset($_GET['action']) && ! isset($_POST['action'])) $action=(empty($conf->global->AGENDA_DEFAULT_VIEW)?'show_month':$conf->global->AGENDA_DEFAULT_VIEW); -if (GETPOST('viewcal') && $action != 'show_day' && $action != 'show_week' && $action != 'show_peruser') { +if (GETPOST('viewcal','alpha') && $action != 'show_day' && $action != 'show_week' && $action != 'show_peruser') { $action='show_month'; $day=''; } // View by month -if (GETPOST('viewweek') || $action == 'show_week') { +if (GETPOST('viewweek','alpha') || $action == 'show_week') { $action='show_week'; $week=($week?$week:date("W")); $day=($day?$day:date("d")); } // View by week -if (GETPOST('viewday') || $action == 'show_day') { +if (GETPOST('viewday','alpha') || $action == 'show_day') { $action='show_day'; $day=($day?$day:date("d")); } // View by day @@ -160,12 +160,12 @@ if ($action =='delete_action') * View */ -$help_url='EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda'; -llxHeader('',$langs->trans("Agenda"),$help_url); - $form=new Form($db); $companystatic=new Societe($db); +$help_url='EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda'; +llxHeader('',$langs->trans("Agenda"),$help_url); + $now=dol_now(); $nowarray=dol_getdate($now); $nowyear=$nowarray['year']; @@ -418,14 +418,14 @@ else { // To limit array $sql.= " AND ("; - $sql.= " (a.datep BETWEEN '".$db->idate(dol_mktime(0,0,0,$month,1,$year)-(60*60*24*7))."'"; // Start 7 days before - $sql.= " AND '".$db->idate(dol_mktime(23,59,59,$month,28,$year)+(60*60*24*10))."')"; // End 7 days after + 3 to go from 28 to 31 + $sql.= " (a.datep BETWEEN '".$db->idate($firstdaytoshow-(60*60*24*2))."'"; // Start 2 day before $firstdaytoshow + $sql.= " AND '".$db->idate($lastdaytoshow+(60*60*24*2))."')"; // End 2 day after $lastdaytoshow $sql.= " OR "; - $sql.= " (a.datep2 BETWEEN '".$db->idate(dol_mktime(0,0,0,$month,1,$year)-(60*60*24*7))."'"; - $sql.= " AND '".$db->idate(dol_mktime(23,59,59,$month,28,$year)+(60*60*24*10))."')"; + $sql.= " (a.datep2 BETWEEN '".$db->idate($firstdaytoshow-(60*60*24*2))."'"; + $sql.= " AND '".$db->idate($lastdaytoshow+(60*60*24*2))."')"; $sql.= " OR "; - $sql.= " (a.datep < '".$db->idate(dol_mktime(0,0,0,$month,1,$year)-(60*60*24*7))."'"; - $sql.= " AND a.datep2 > '".$db->idate(dol_mktime(23,59,59,$month,28,$year)+(60*60*24*10))."')"; + $sql.= " (a.datep < '".$db->idate($firstdaytoshow-(60*60*24*2))."'"; + $sql.= " AND a.datep2 > '".$db->idate($lastdaytoshow+(60*60*24*2))."')"; $sql.= ')'; } if ($type) $sql.= " AND ca.id = ".$type; @@ -444,13 +444,14 @@ if ($filtert > 0 || $usergroup > 0) } // Sort on date $sql.= ' ORDER BY fk_user_action, datep'; //fk_user_action -//print $sql; +//print $sql;exit; dol_syslog("comm/action/peruser.php", LOG_DEBUG); $resql=$db->query($sql); if ($resql) { $num = $db->num_rows($resql); + $i=0; while ($i < $num) { @@ -463,11 +464,14 @@ if ($resql) continue; } + $datep=$db->jdate($obj->datep); + $datep2=$db->jdate($obj->datep2); + // Create a new object action $event=new ActionComm($db); $event->id=$obj->id; - $event->datep=$db->jdate($obj->datep); // datep and datef are GMT date - $event->datef=$db->jdate($obj->datep2); + $event->datep=$datep; // datep and datef are GMT date + $event->datef=$datep2; $event->type_code=$obj->code; $event->type_color=$obj->color; //$event->libelle=$obj->label; // deprecated @@ -476,7 +480,6 @@ if ($resql) //$event->author->id=$obj->fk_user_author; // user id of creator $event->authorid=$obj->fk_user_author; // user id of creator $event->userownerid=$obj->fk_user_action; // user id of owner - $event->fetch_userassigned(); // This load $event->userassigned $event->priority=$obj->priority; $event->fulldayevent=$obj->fulldayevent; $event->location=$obj->location; @@ -494,15 +497,15 @@ if ($resql) // They are date start and end of action but modified to not be outside calendar view. if ($event->percentage <= 0) { - $event->date_start_in_calendar=$event->datep; - if ($event->datef != '' && $event->datef >= $event->datep) $event->date_end_in_calendar=$event->datef; - else $event->date_end_in_calendar=$event->datep; + $event->date_start_in_calendar=$datep; + if ($datep2 != '' && $datep2 >= $datep) $event->date_end_in_calendar=$datep2; + else $event->date_end_in_calendar=$datep; } else { - $event->date_start_in_calendar=$event->datep; - if ($event->datef != '' && $event->datef >= $event->datep) $event->date_end_in_calendar=$event->datef; - else $event->date_end_in_calendar=$event->datep; + $event->date_start_in_calendar=$datep; + if ($datep2 != '' && $datep2 >= $datep) $event->date_end_in_calendar=$datep2; + else $event->date_end_in_calendar=$datep; } // Define ponctual property if ($event->date_start_in_calendar == $event->date_end_in_calendar) @@ -515,10 +518,14 @@ if ($resql) $event->date_start_in_calendar >= $lastdaytoshow) { // This record is out of visible range + unset($event); } else { - if ($event->date_start_in_calendar < $firstdaytoshow) $event->date_start_in_calendar=$firstdaytoshow; + //print $i.' - '.dol_print_date($this->date_start_in_calendar, 'dayhour').' - '.dol_print_date($this->date_end_in_calendar, 'dayhour').'
    '."\n"; + $event->fetch_userassigned(); // This load $event->userassigned + + if ($event->date_start_in_calendar < $firstdaytoshow) $event->date_start_in_calendar=$firstdaytoshow; if ($event->date_end_in_calendar >= $lastdaytoshow) $event->date_end_in_calendar=($lastdaytoshow - 1); // Add an entry in actionarray for each day @@ -548,6 +555,7 @@ if ($resql) $i++; } + $db->free($resql); } else { @@ -869,7 +877,7 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, & $cases1 = array(); // Color first half hour $cases2 = array(); // Color second half hour - $curtime = dol_mktime(0, 0, 0, $month, $day, $year); + $curtime = dol_mktime(0, 0, 0, $month, $day, $year, false, 0); $i=0; $nummytasks=0; $numother=0; $numbirthday=0; $numical=0; $numicals=array(); $ymd=sprintf("%04d",$year).sprintf("%02d",$month).sprintf("%02d",$day); @@ -1029,6 +1037,7 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, & } } + // Now output $casesX for ($h = $begin_h; $h < $end_h; $h++) { $color1='';$color2=''; diff --git a/htdocs/projet/ganttview.php b/htdocs/projet/ganttview.php index 7ec9dcf1a4b..ca3c0ba35e6 100644 --- a/htdocs/projet/ganttview.php +++ b/htdocs/projet/ganttview.php @@ -98,12 +98,12 @@ if ($id > 0 || ! empty($ref)) $param=($mode=='mine'?'&mode=mine':''); - + // Project card - + $linkback = '
    '.$langs->trans("BackToList").''; - + $morehtmlref='
    '; // Title $morehtmlref.=$object->title; @@ -113,29 +113,29 @@ if ($id > 0 || ! empty($ref)) $morehtmlref.='
    '.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1, 'project'); } $morehtmlref.='
    '; - + // Define a complementary filter for search of next/prev ref. if (! $user->rights->projet->all->lire) { $objectsListId = $object->getProjectsAuthorizedForUser($user,0,0); $object->next_prev_filter=" rowid in (".(count($objectsListId)?join(',',array_keys($objectsListId)):'0').")"; } - + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); - - + + print '
    '; print '
    '; print '
    '; - + print ''; - + // Visibility print ''; - + // Date start - end print ''; - + // Budget print ''; - + // Other attributes $cols = 2; include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; - + print '
    '.$langs->trans("Visibility").''; if ($object->public) print $langs->trans('SharedProject'); else print $langs->trans('PrivateProject'); print '
    '.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").''; $start = dol_print_date($object->date_start,'dayhour'); @@ -145,45 +145,45 @@ if ($id > 0 || ! empty($ref)) print ($end?$end:'?'); if ($object->hasDelay()) print img_warning("Late"); print '
    '.$langs->trans("Budget").''; if (strcmp($object->budget_amount, '')) print price($object->budget_amount,'',$langs,1,0,0,$conf->currency); print '
    '; - + print '
    '; print '
    '; print '
    '; print '
    '; - + print ''; - + // Description print ''; - + // Categories if($conf->categorie->enabled) { print '"; } - + print '
    '.$langs->trans("Description").''; print nl2br($object->description); print '
    '.$langs->trans("Categories").''; print $form->showCategories($object->id,'project',1); print "
    '; - + print '
    '; print '
    '; print '
    '; - + print '
    '; - + dol_fiche_end(); } diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index cd2c0f95582..801911c0f5f 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -3425,6 +3425,15 @@ table.cal_event td.cal_event_right { padding: 4px 4px !important; } cursor:pointer; } +/* ============================================================================== */ +/* Gantt +/* ============================================================================== */ + +td.gtaskname { + overflow: hidden; + text-overflow: ellipsis; +} + /* ============================================================================== */ /* jQuery - jeditable */ diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index cf787f09071..5768a70bf18 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -3508,6 +3508,17 @@ table.cal_event td.cal_event_right { padding: 4px 4px !important; } cursor:pointer; } + +/* ============================================================================== */ +/* Gantt +/* ============================================================================== */ + +td.gtaskname { + overflow: hidden; + text-overflow: ellipsis; +} + + /* ============================================================================== */ /* jQuery - jeditable */ /* ============================================================================== */ From 2a361668398cf44e0cefe49a05d5c30a8511f5d4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 29 Jul 2017 02:11:45 +0200 Subject: [PATCH 020/207] Fix error method on non object --- htdocs/comm/action/card.php | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 14ab91a2f31..16bb308c966 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -38,11 +38,8 @@ require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; -if (! empty($conf->projet->enabled)) -{ - require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; - require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; -} +require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; $langs->load("companies"); @@ -585,6 +582,8 @@ if ($action == 'mupdate') * View */ +$formproject=new FormProjets($db); + $help_url='EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda'; llxHeader('',$langs->trans("Agenda"),$help_url); @@ -786,8 +785,6 @@ if ($action == 'create') // Project if (! empty($conf->projet->enabled)) { - $formproject=new FormProjets($db); - // Projet associe $langs->load("projects"); @@ -1133,8 +1130,6 @@ if ($id > 0) // Project if (! empty($conf->projet->enabled)) { - $formproject=new FormProjets($db); - $langs->load("projects"); print ''.$langs->trans("Project").''; From 837afa0e6560546e9bf92e6ae0820e459a508d24 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 29 Jul 2017 04:07:46 +0200 Subject: [PATCH 021/207] Fix better way to get info for contact/thirdparty on agenda --- htdocs/comm/action/pertype.php | 80 ++++++++++++++++++++++++++----- htdocs/comm/action/peruser.php | 86 ++++++++++++++++++++++++++++------ 2 files changed, 140 insertions(+), 26 deletions(-) diff --git a/htdocs/comm/action/pertype.php b/htdocs/comm/action/pertype.php index 589a2731f1b..b10ab8dc05b 100644 --- a/htdocs/comm/action/pertype.php +++ b/htdocs/comm/action/pertype.php @@ -30,10 +30,12 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; +require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; -if (! empty($conf->projet->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; +require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; if (! isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW=3; @@ -55,7 +57,7 @@ $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 -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $offset = $limit * $page; if (! $sortorder) $sortorder="ASC"; if (! $sortfield) $sortfield="a.datec"; @@ -93,7 +95,7 @@ if (GETPOST('actioncode','array')) } else { - $actioncode=GETPOST("actioncode","alpha",3)?GETPOST("actioncode","alpha",3):(GETPOST("actioncode")=='0'?'0':(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE)); + $actioncode=GETPOST("actioncode","alpha",3)?GETPOST("actioncode","alpha",3):(GETPOST("actioncode","alpha")=='0'?'0':(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE)); } if ($actioncode == '' && empty($actioncodearray)) $actioncode=(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE); @@ -354,7 +356,7 @@ $sql.= ' a.datep2,'; $sql.= ' a.percent,'; $sql.= ' a.fk_user_author,a.fk_user_action,'; $sql.= ' a.transparency, a.priority, a.fulldayevent, a.location,'; -$sql.= ' a.fk_soc, a.fk_contact, a.fk_element, a.elementtype,'; +$sql.= ' a.fk_soc, a.fk_contact, a.fk_element, a.elementtype, a.fk_project,'; $sql.= ' ca.code, ca.color'; $sql.= ' FROM '.MAIN_DB_PREFIX.'c_actioncomm as ca, '.MAIN_DB_PREFIX."actioncomm as a"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; @@ -477,6 +479,8 @@ if ($resql) $event->location=$obj->location; $event->transparency=$obj->transparency; + $event->fk_project=$obj->fk_project; + $event->socid=$obj->fk_soc; $event->contactid=$obj->fk_contact; //$event->societe->id=$obj->fk_soc; // deprecated @@ -887,11 +891,37 @@ function show_day_events_pertype($username, $day, $month, $year, $monthshown, $s } $cases1[$h][$event->id]['string'].=' - '.$event->label; $cases1[$h][$event->id]['typecode']=$event->type_code; - if ($event->socid) - { - //$cases1[$h][$event->id]['string'].='xxx'; - } $cases1[$h][$event->id]['color']=$color; + if ($event->fk_project > 0) + { + if (empty($cache_project[$event->fk_project])) + { + $tmpproj=new Project($db); + $tmpproj->fetch($event->fk_project); + $cache_project[$event->fk_project]=$tmpproj; + } + $cases1[$h][$event->id]['string'].=', '.$langs->trans("Project").': '.$cache_project[$event->fk_project]->ref.' - '.$cache_project[$event->fk_project]->title; + } + if ($event->socid > 0) + { + if (empty($cache_thirdparty[$event->socid])) + { + $tmpthirdparty=new Societe($db); + $tmpthirdparty->fetch($event->socid); + $cache_thirdparty[$event->socid]=$tmpthirdparty; + } + $cases1[$h][$event->id]['string'].=', '.$cache_thirdparty[$event->socid]->name; + } + if ($event->contactid > 0) + { + if (empty($cache_contact[$event->contactid])) + { + $tmpcontact=new Contact($db); + $tmpcontact->fetch($event->contactid); + $cache_contact[$event->contactid]=$tmpcontact; + } + $cases1[$h][$event->id]['string'].=', '.$cache_contact[$event->contactid]->getFullName($langs); + } } if ($event->date_start_in_calendar < $c && $dateendtouse > $b) { @@ -907,11 +937,37 @@ function show_day_events_pertype($username, $day, $month, $year, $monthshown, $s } $cases2[$h][$event->id]['string'].=' - '.$event->label; $cases2[$h][$event->id]['typecode']=$event->type_code; - if ($event->socid) - { - //$cases2[$h][$event->id]['string'].='xxx'; - } $cases2[$h][$event->id]['color']=$color; + if ($event->fk_project > 0) + { + if (empty($cache_project[$event->fk_project])) + { + $tmpproj=new Project($db); + $tmpproj->fetch($event->fk_project); + $cache_project[$event->fk_project]=$tmpproj; + } + $cases2[$h][$event->id]['string'].=', '.$langs->trans("Project").': '.$cache_project[$event->fk_project]->ref.' - '.$cache_project[$event->fk_project]->title; + } + if ($event->socid > 0) + { + if (empty($cache_thirdparty[$event->socid])) + { + $tmpthirdparty=new Societe($db); + $tmpthirdparty->fetch($event->socid); + $cache_thirdparty[$event->socid]=$tmpthirdparty; + } + $cases2[$h][$event->id]['string'].=', '.$cache_thirdparty[$event->socid]->name; + } + if ($event->contactid > 0) + { + if (empty($cache_contact[$event->contactid])) + { + $tmpcontact=new Contact($db); + $tmpcontact->fetch($event->contactid); + $cache_contact[$event->contactid]=$tmpcontact; + } + $cases2[$h][$event->id]['string'].=', '.$cache_contact[$event->contactid]->getFullName($langs); + } } } else diff --git a/htdocs/comm/action/peruser.php b/htdocs/comm/action/peruser.php index 364e63d8a1b..792d4f9760d 100644 --- a/htdocs/comm/action/peruser.php +++ b/htdocs/comm/action/peruser.php @@ -30,10 +30,12 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; +require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; -if (! empty($conf->projet->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; +require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; if (! isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW=3; @@ -55,7 +57,7 @@ $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 -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $offset = $limit * $page; if (! $sortorder) $sortorder="ASC"; if (! $sortfield) $sortfield="a.datec"; @@ -93,9 +95,10 @@ if (GETPOST('actioncode','array')) } else { - $actioncode=GETPOST("actioncode","alpha",3)?GETPOST("actioncode","alpha",3):(GETPOST("actioncode")=='0'?'0':(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE)); + $actioncode=GETPOST("actioncode","alpha",3)?GETPOST("actioncode","alpha",3):(GETPOST("actioncode","alpha")=='0'?'0':(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE)); } if ($actioncode == '' && empty($actioncodearray)) $actioncode=(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE); + $dateselect=dol_mktime(0, 0, 0, GETPOST('dateselectmonth','int'), GETPOST('dateselectday','int'), GETPOST('dateselectyear','int')); if ($dateselect > 0) { @@ -361,7 +364,7 @@ $sql.= ' a.datep2,'; $sql.= ' a.percent,'; $sql.= ' a.fk_user_author,a.fk_user_action,'; $sql.= ' a.transparency, a.priority, a.fulldayevent, a.location,'; -$sql.= ' a.fk_soc, a.fk_contact, a.fk_element, a.elementtype,'; +$sql.= ' a.fk_soc, a.fk_contact, a.fk_element, a.elementtype, a.fk_project,'; $sql.= ' ca.code, ca.color'; $sql.= ' FROM '.MAIN_DB_PREFIX.'c_actioncomm as ca, '.MAIN_DB_PREFIX."actioncomm as a"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; @@ -485,6 +488,8 @@ if ($resql) $event->location=$obj->location; $event->transparency=$obj->transparency; + $event->fk_project=$obj->fk_project; + $event->socid=$obj->fk_soc; $event->contactid=$obj->fk_contact; //$event->societe->id=$obj->fk_soc; // deprecated @@ -873,6 +878,7 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, & global $theme_datacolor; // Array with a list of different we can use (come from theme) global $cachethirdparties, $cachecontacts, $colorindexused; global $begin_h, $end_h; + global $cache_project, $cache_thirdparty, $cache_contact; $cases1 = array(); // Color first half hour $cases2 = array(); // Color second half hour @@ -988,13 +994,39 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, & if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $cases1[$h][$event->id]['string'].='-'.dol_print_date($event->date_end_in_calendar,'hour'); else $cases1[$h][$event->id]['string'].='-'.dol_print_date($event->date_end_in_calendar,'dayhour'); } - $cases1[$h][$event->id]['string'].=' - '.$event->label; + if ($event->label) $cases1[$h][$event->id]['string'].=' - '.$event->label; $cases1[$h][$event->id]['typecode']=$event->type_code; - if ($event->socid) - { - //$cases1[$h][$event->id]['string'].='xxx'; - } $cases1[$h][$event->id]['color']=$color; + if ($event->fk_project > 0) + { + if (empty($cache_project[$event->fk_project])) + { + $tmpproj=new Project($db); + $tmpproj->fetch($event->fk_project); + $cache_project[$event->fk_project]=$tmpproj; + } + $cases1[$h][$event->id]['string'].=', '.$langs->trans("Project").': '.$cache_project[$event->fk_project]->ref.' - '.$cache_project[$event->fk_project]->title; + } + if ($event->socid > 0) + { + if (empty($cache_thirdparty[$event->socid])) + { + $tmpthirdparty=new Societe($db); + $tmpthirdparty->fetch($event->socid); + $cache_thirdparty[$event->socid]=$tmpthirdparty; + } + $cases1[$h][$event->id]['string'].=', '.$cache_thirdparty[$event->socid]->name; + } + if ($event->contactid > 0) + { + if (empty($cache_contact[$event->contactid])) + { + $tmpcontact=new Contact($db); + $tmpcontact->fetch($event->contactid); + $cache_contact[$event->contactid]=$tmpcontact; + } + $cases1[$h][$event->id]['string'].=', '.$cache_contact[$event->contactid]->getFullName($langs); + } } if ($event->date_start_in_calendar < $c && $dateendtouse > $b) { @@ -1008,13 +1040,39 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, & if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $cases2[$h][$event->id]['string'].='-'.dol_print_date($event->date_end_in_calendar,'hour'); else $cases2[$h][$event->id]['string'].='-'.dol_print_date($event->date_end_in_calendar,'dayhour'); } - $cases2[$h][$event->id]['string'].=' - '.$event->label; + if ($event->label) $cases2[$h][$event->id]['string'].=' - '.$event->label; $cases2[$h][$event->id]['typecode']=$event->type_code; - if ($event->socid) - { - //$cases2[$h][$event->id]['string'].='xxx'; - } $cases2[$h][$event->id]['color']=$color; + if ($event->fk_project > 0) + { + if (empty($cache_project[$event->fk_project])) + { + $tmpproj=new Project($db); + $tmpproj->fetch($event->fk_project); + $cache_project[$event->fk_project]=$tmpproj; + } + $cases2[$h][$event->id]['string'].=', '.$langs->trans("Project").': '.$cache_project[$event->fk_project]->ref.' - '.$cache_project[$event->fk_project]->title; + } + if ($event->socid > 0) + { + if (empty($cache_thirdparty[$event->socid])) + { + $tmpthirdparty=new Societe($db); + $tmpthirdparty->fetch($event->socid); + $cache_thirdparty[$event->socid]=$tmpthirdparty; + } + $cases2[$h][$event->id]['string'].=', '.$cache_thirdparty[$event->socid]->name; + } + if ($event->contactid > 0) + { + if (empty($cache_contact[$event->contactid])) + { + $tmpcontact=new Contact($db); + $tmpcontact->fetch($event->contactid); + $cache_contact[$event->contactid]=$tmpcontact; + } + $cases2[$h][$event->id]['string'].=', '.$cache_contact[$event->contactid]->getFullName($langs); + } } } else From bb8d4584680282b1f54b27be2c0a4a66d8a57521 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 30 Jul 2017 19:38:12 +0200 Subject: [PATCH 022/207] Fix menu editor --- htdocs/admin/menus/index.php | 11 ++++++----- htdocs/core/lib/treeview.lib.php | 6 +++--- .../template/core/modules/modMyModule.class.php | 6 +++--- htdocs/theme/eldy/style.css.php | 8 +++++++- htdocs/theme/md/style.css.php | 17 +++++++++++++---- 5 files changed, 32 insertions(+), 16 deletions(-) diff --git a/htdocs/admin/menus/index.php b/htdocs/admin/menus/index.php index 5fb19b0b5ec..c3211fc2d75 100644 --- a/htdocs/admin/menus/index.php +++ b/htdocs/admin/menus/index.php @@ -296,7 +296,7 @@ if ($conf->use_javascript_ajax) //puis tous les elements enfants - $sql = "SELECT m.rowid, m.titre, m.langs, m.mainmenu, m.leftmenu, m.fk_menu, m.fk_mainmenu, m.fk_leftmenu, m.module"; + $sql = "SELECT m.rowid, m.titre, m.langs, m.mainmenu, m.leftmenu, m.fk_menu, m.fk_mainmenu, m.fk_leftmenu, m.position, m.module"; $sql.= " FROM ".MAIN_DB_PREFIX."menu as m"; $sql.= " WHERE menu_handler = '".$db->escape($menu_handler_to_search)."'"; $sql.= " AND entity = ".$conf->entity; @@ -323,6 +323,7 @@ if ($conf->use_javascript_ajax) 'leftmenu'=>$menu['leftmenu'], 'fk_mainmenu'=>$menu['fk_mainmenu'], 'fk_leftmenu'=>$menu['fk_leftmenu'], + 'position'=>$menu['position'], 'entry'=>''; @@ -376,7 +378,6 @@ if ($conf->use_javascript_ajax) print ''; print '
    '. '   '.$titre.''. ''. @@ -344,10 +345,11 @@ if ($conf->use_javascript_ajax) global $tree_recur_alreadyadded; // This var was def into tree_recur - // Appelle de la fonction recursive (ammorce) - // avec recherche depuis la racine. //var_dump($data); - tree_recur($data, $data[0], 0, 'iddivjstree'); // $data[0] is virtual record 'racine' + + // Appelle de la fonction recursive (ammorce) avec recherche depuis la racine. + //tree_recur($data, $data[0], 0, 'iddivjstree', 0, 1); // use this to get info on name and foreign keys of menu entry + tree_recur($data, $data[0], 0, 'iddivjstree', 0, 0); // $data[0] is virtual record 'racine' print '
    '; - foreach($remainingdata as $datar) { $father = array('rowid'=>$datar['rowid'],'title'=>"???",'mainmenu'=>$datar['fk_mainmenu'],'leftmenu'=>$datar['fk_leftmenu'],'fk_mainmenu'=>'','fk_leftmenu'=>''); diff --git a/htdocs/core/lib/treeview.lib.php b/htdocs/core/lib/treeview.lib.php index 944520d04d5..6c66079090a 100644 --- a/htdocs/core/lib/treeview.lib.php +++ b/htdocs/core/lib/treeview.lib.php @@ -182,7 +182,7 @@ function tree_recur($tab, $pere, $rang, $iddivjstree='iddivjstree', $donoresetal //print ' -> A '.$tab[$x]['rowid'].' mainmenu='.$tab[$x]['mainmenu'].' leftmenu='.$tab[$x]['leftmenu'].' fk_mainmenu='.$tab[$x]['fk_mainmenu'].' fk_leftmenu='.$tab[$x]['fk_leftmenu'].'
    '."\n"; $tree_recur_alreadyadded[$tab[$x]['rowid']]=($rang + 1); // And now we search all its sons of lower level - tree_recur($tab,$tab[$x],$rang+1); + tree_recur($tab, $tab[$x], $rang+1, 'iddivjstree', 0, $showfk); print ''; } elseif (! empty($tab[$x]['rowid']) && $tab[$x]['fk_menu'] == -1 && $tab[$x]['fk_mainmenu'] == $pere['mainmenu'] && $tab[$x]['fk_leftmenu'] == $pere['leftmenu']) @@ -206,7 +206,7 @@ function tree_recur($tab, $pere, $rang, $iddivjstree='iddivjstree', $donoresetal print '   '; print $tab[$x]['title']; print ''; - print '  (fk_mainmenu='.$tab[$x]['fk_mainmenu'].' fk_leftmenu='.$tab[$x]['fk_leftmenu'].')'; + print '  (mainmenu='.$tab[$x]['mainmenu'].' leftmenu='.$tab[$x]['leftmenu'].' - fk_mainmenu='.$tab[$x]['fk_mainmenu'].' fk_leftmenu='.$tab[$x]['fk_leftmenu'].')'; print '
    '; print $tab[$x]['buttons']; print '
    '; @@ -219,7 +219,7 @@ function tree_recur($tab, $pere, $rang, $iddivjstree='iddivjstree', $donoresetal $tree_recur_alreadyadded[$tab[$x]['rowid']]=($rang + 1); // And now we search all its sons of lower level //print 'Call tree_recur for x='.$x.' rowid='.$tab[$x]['rowid']." fk_mainmenu pere = ".$tab[$x]['fk_mainmenu']." fk_leftmenu pere = ".$tab[$x]['fk_leftmenu']."
    \n"; - tree_recur($tab,$tab[$x],$rang+1); + tree_recur($tab, $tab[$x], $rang+1, 'iddivjstree', 0, $showfk); print '
  • '; } } diff --git a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php index 3e217618d4a..8f8079b1d46 100644 --- a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php +++ b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php @@ -235,7 +235,7 @@ class modMyModule extends DolibarrModules 'leftmenu'=>'', 'url'=>'/mymodule/mymoduleindex.php', 'langs'=>'mymodule@mymodule', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. - 'position'=>1000, + 'position'=>1000+$r, 'enabled'=>'$conf->mymodule->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. 'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules 'target'=>'', @@ -252,7 +252,7 @@ class modMyModule extends DolibarrModules 'leftmenu'=>'mymodule', 'url'=>'/mymodule/myobject_list.php', 'langs'=>'mymodule@mymodule', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. - 'position'=>1100, + 'position'=>1000+$r, 'enabled'=>'$conf->mymodule->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. 'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules 'target'=>'', @@ -264,7 +264,7 @@ class modMyModule extends DolibarrModules 'leftmenu'=>'mymodule', 'url'=>'/mymodule/myobject_page.php?action=create', 'langs'=>'mymodule@mymodule', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. - 'position'=>1101, + 'position'=>1000+$r, 'enabled'=>'$conf->mymodule->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. 'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules 'target'=>'', diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 801911c0f5f..0fa905113ad 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -2653,7 +2653,6 @@ div.liste_titre_bydiv, .liste_titre div.tagtr, tr.liste_titre, tr.liste_titre_se } tr.liste_titre th, tr.liste_titre td, th.liste_titre { -/* border-bottom: 1px solid #; */ border-bottom: 1px solid #888; } tr.liste_titre:first-child th, tr:first-child th.liste_titre { @@ -2779,6 +2778,13 @@ div.tabBar .noborder { border-bottom: 1px solid #ddd; } +ul.noborder li:nth-child(even):not(.liste_titre) { + background-color: rgb() !important; + background-color: rgb() !important; + background-color: rgb() !important; + background-color: rgb() !important; + background-color: rgb() !important; +} /* diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 5768a70bf18..741a08c4ac8 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -2623,6 +2623,15 @@ div.pagination li.paginationafterarrows { } */ +ul.noborder li:nth-child(odd):not(.liste_titre) { + background-color: rgb() !important; + background-color: rgb() !important; + background-color: rgb() !important; + background-color: rgb() !important; + background-color: rgb() !important; +} + + /* Set the color for hover lines */ .oddeven:hover, .evenodd:hover, .impair:hover, .pair:hover { @@ -2723,19 +2732,19 @@ tr.liste_titre, tr.liste_titre_sel, form.liste_titre, form.liste_titre_sel, tabl { height: 26px !important; } -div.liste_titre, tr.liste_titre, tr.liste_titre_sel, form.liste_titre, form.liste_titre_sel, table.dataTable thead tr +div.liste_titre_bydiv, .liste_titre div.tagtr, tr.liste_titre, tr.liste_titre_sel, form.liste_titre, form.liste_titre_sel, table.dataTable thead tr { background: rgb(); font-weight: ; + border-bottom: 1px solid #FDFFFF; color: rgb(); font-family: ; - border-bottom: 1px solid #FDFFFF; text-align: ; } -tr.liste_titre th, tr.liste_titre td, th.liste_titre, form.liste_titre div, div.liste_titre +tr.liste_titre th, tr.liste_titre td, th.liste_titre { - border-bottom: 1px solid #; + border-bottom: 1px solid #aaa; } /* TODO Once title line is moved under title search, make border bottom of all th black and force to whit when it's first tr */ tr:first-child th.liste_titre { From 1897e3cbadf417748970e632b219f6272ccf7181 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 30 Jul 2017 20:43:18 +0200 Subject: [PATCH 023/207] Some fix for better compatibility --- htdocs/main.inc.php | 4 ++-- htdocs/public/test/test_arrays.php | 18 ++++++------------ htdocs/theme/eldy/style.css.php | 5 +++++ htdocs/theme/md/style.css.php | 6 ++++-- 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 090a35d6c83..89b99a61041 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1199,7 +1199,7 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs print ''."\n"; if (defined('JS_JQUERY') && constant('JS_JQUERY')) print ''."\n"; else print ''."\n"; - if (! empty($conf->global->MAIN_FEATURES_LEVEL)) + if (! empty($conf->global->MAIN_FEATURES_LEVEL) && ! defined('JS_JQUERY_MIGRATE_DISABLED')) { if (defined('JS_JQUERY_MIGRATE') && constant('JS_JQUERY_MIGRATE')) print ''."\n"; else print ''."\n"; @@ -2002,7 +2002,7 @@ if (! function_exists("llxFooter")) } // Wrapper to manage dropdown - if ($conf->use_javascript_ajax) + if (! empty($conf->use_javascript_ajax) && ! defined('JS_JQUERY_DISABLE_DROPDOWN')) { print "\n\n"; print ' @@ -43,9 +40,6 @@ if (empty($usedolheader)) - - - @@ -74,7 +68,7 @@ else '/includes/pdfmake/vfs_fonts.js' ); */ - + llxHeader('','','','',0,0,$arrayjs,$arraycss); } @@ -92,7 +86,7 @@ This page is a sample of page using tables. It is designed to make test with
    - tablednd
    - +


    Example 0a : Table with div+div+div containg a select that should be overflowed and truncated => Use this to align text or form
    @@ -139,7 +133,7 @@ This page is a sample of page using tables. It is designed to make test with



    Example 1 : Standard table/thead/tbody/tr/th-td (no class pair/impair on td) => Use this if you need the drag and drop for lines or for long result tables
    - + - + - + " id="tablelines3"> @@ -243,7 +237,7 @@ if (! empty($moreforfilter))
    -'; @@ -280,8 +278,8 @@ if (!empty($conf->global->MAIN_EASTER_EGG_COMMITSTRIP)) { global->MAIN_HTML_FOOTER)) print $conf->global->MAIN_HTML_FOOTER; ?> resArray['options'])) { - foreach ($hookmanager->resArray['options'] as $format => $option) +if (! empty($morelogincontent) && is_array($morelogincontent)) { + foreach ($morelogincontent as $format => $option) { if ($format == 'js') { echo "\n".''; From ae444b57810cabc3d0d488ed758914b3f951086f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 1 Aug 2017 01:28:07 +0200 Subject: [PATCH 038/207] Fix travis error --- htdocs/variants/class/ProductCombination.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/variants/class/ProductCombination.class.php b/htdocs/variants/class/ProductCombination.class.php index fd08ccf1b6a..d3e6964aea6 100644 --- a/htdocs/variants/class/ProductCombination.class.php +++ b/htdocs/variants/class/ProductCombination.class.php @@ -249,8 +249,8 @@ class ProductCombination /** * Deletes a product combination * - * @param User $user - * @return int <0 KO >0 OK + * @param User $user Object user + * @return int <0 if KO, >0 if OK */ public function delete(User $user) { From efd24cc1a2b27f613b0f29cb977410b1899615d7 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Tue, 1 Aug 2017 06:16:23 +0200 Subject: [PATCH 039/207] Fix: function length_accountg has been moved in getNomUrl --- htdocs/compta/bank/index.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/htdocs/compta/bank/index.php b/htdocs/compta/bank/index.php index 9bc8608692d..6c0d1613943 100644 --- a/htdocs/compta/bank/index.php +++ b/htdocs/compta/bank/index.php @@ -492,12 +492,10 @@ foreach ($accounts as $key=>$type) // Account number if (! empty($arrayfields['b.account_number']['checked'])) { - include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; - $accountingaccount = new AccountingAccount($db); $accountingaccount->fetch('',$acc->account_number); - print ''; + print ''; if (! $i) $totalarray['nbfield']++; } From 9629a50853fb81953e17e012d4c7d84ae0be9c73 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Tue, 1 Aug 2017 06:21:19 +0200 Subject: [PATCH 040/207] Fix: SQL error in payment list --- htdocs/compta/paiement/list.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/htdocs/compta/paiement/list.php b/htdocs/compta/paiement/list.php index 4a7a2e3c81a..bddc5e9f500 100644 --- a/htdocs/compta/paiement/list.php +++ b/htdocs/compta/paiement/list.php @@ -3,8 +3,9 @@ * Copyright (C) 2004-2011 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2013 Cédric Salvador - * Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2015 Juanjo Menent + * Copyright (C) 2017 Alexandre Spangaro * * 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 @@ -31,14 +32,15 @@ require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php'; $langs->load("bills"); $langs->load("compta"); // Security check -$facid =GETPOST('facid','int'); -$socid =GETPOST('socid','int'); -$userid=GETPOST('userid','int'); +$facid = GETPOST('facid','int'); +$socid = GETPOST('socid','int'); +$userid = GETPOST('userid','int'); $day = GETPOST('day','int'); $month = GETPOST('month','int'); $year = GETPOST('year','int'); @@ -129,7 +131,7 @@ else $sql = "SELECT DISTINCT p.rowid, p.ref, p.datep as dp, p.amount,"; // DISTINCT is to avoid duplicate when there is a link to sales representatives $sql.= " p.statut, p.num_paiement,"; $sql.= " c.code as paiement_code,"; - $sql.= " ba.rowid as bid, ba.ref as bref, ba.label as blabel, ba.number, ba.account_number as account_number, ba.accountancy_journal as accountancy_journal,"; + $sql.= " ba.rowid as bid, ba.ref as bref, ba.label as blabel, ba.number, ba.account_number as account_number, ba.fk_accountancy_journal as accountancy_journal,"; $sql.= " s.rowid as socid, s.nom as name"; // Add fields for extrafields foreach ($extrafields->attribute_list as $key => $val) $sql.=",ef.".$key.' as options_'.$key; @@ -329,7 +331,11 @@ if ($resql) $accountstatic->label=$objp->blabel; $accountstatic->number=$objp->number; $accountstatic->account_number=$objp->account_number; - $accountstatic->accountancy_journal=$objp->accountancy_journal; + + $accountingjournal = new AccountingJournal($db); + $accountingjournal->fetch($objp->accountancy_journal); + $accountstatic->accountancy_journal = $accountingjournal->getNomUrl(0,1,1,'',1); + print $accountstatic->getNomUrl(1); } else print ' '; From 3c34add0d60c4351045fd1cdb221baa31724a961 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Tue, 1 Aug 2017 06:26:35 +0200 Subject: [PATCH 041/207] remove condition --- htdocs/compta/paiement/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/paiement/list.php b/htdocs/compta/paiement/list.php index bddc5e9f500..04dbaf8fc11 100644 --- a/htdocs/compta/paiement/list.php +++ b/htdocs/compta/paiement/list.php @@ -32,7 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; -if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php'; +require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; $langs->load("bills"); $langs->load("compta"); From e41543c22eefe9796b1bdf7be1e2e4b777554aad Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Tue, 1 Aug 2017 06:44:37 +0200 Subject: [PATCH 042/207] Fix v6: Debug various_payment --- htdocs/compta/bank/various_payment/card.php | 20 ++-- htdocs/compta/bank/various_payment/index.php | 103 +++++++++++++------ 2 files changed, 85 insertions(+), 38 deletions(-) diff --git a/htdocs/compta/bank/various_payment/card.php b/htdocs/compta/bank/various_payment/card.php index f75c111094d..9328b6f599b 100644 --- a/htdocs/compta/bank/various_payment/card.php +++ b/htdocs/compta/bank/various_payment/card.php @@ -28,6 +28,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/paymentvarious.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; +if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; $langs->loadLangs(array("compta", "banks", "bills", "users", "accountancy")); @@ -70,7 +71,7 @@ if (empty($reshook)) { if ($action != 'addlink') { - $urltogo=$backtopage?$backtopage:dol_buildpath('/mymodule/myobject_list.php',1); + $urltogo=$backtopage?$backtopage:dol_buildpath('/compta/bank/various_payment/index.php',1); header("Location: ".$urltogo); exit; } @@ -172,7 +173,7 @@ if (empty($reshook)) if ($result >= 0) { $db->commit(); - header("Location: ".DOL_URL_ROOT.'/compta/salaries/index.php'); + header("Location: ".DOL_URL_ROOT.'/compta/bank/various_payment/index.php'); exit; } else @@ -339,9 +340,9 @@ if ($id) print '
    '.length_accountg($accountingaccount->getNomUrl(0,1,1,'',1)).''.$accountingaccount->getNomUrl(0,1,1,'',1).'
    '; - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; - print ""; + print ""; print ''; @@ -349,11 +350,13 @@ if ($id) // Label print ''; + // Payment date print ""; print ''; + // Value date print ''; @@ -370,11 +373,10 @@ if ($id) print '\n"; print ''; + // Ref print ''; + // Label print ''; + // Date print ''; + // Type print ''; + // Account if (! empty($conf->banque->enabled)) { @@ -181,10 +189,15 @@ if ($result) $form->select_comptes($search_account,'search_account',0,'',1); print ''; } - // Amount - print ''; - // Sens - print ''; + + // Accounting account + if (! empty($conf->accounting->enabled)) print ''; + + // Debit + print ''; + + // Credit + print ''; print '\n"; + $totalarray=array(); while ($i < min($num,$limit)) { $obj = $db->fetch_object($result); @@ -201,50 +215,81 @@ if ($result) $variousstatic->id=$obj->rowid; $variousstatic->ref=$obj->rowid; + // Ref print "\n"; + // Label payment print "\n"; + // Date payment print '\n"; + // Type print ''; + // Account if (! empty($conf->banque->enabled)) { print ''; } - // Amount - print ""; - // Sens - if ($obj->sens == '1') $sens = $langs->trans("Credit"); else $sens = $langs->trans("Debit"); - print ""; - print ""; - print "\n"; - $total = $total + $obj->amount; + // Accounting account + if (! empty($conf->accounting->enabled)) { + $accountingaccount = new AccountingAccount($db); + $accountingaccount->fetch('',$obj->accountancy_code); + + print ''; + } + + // Debit + print ""; + + // Credit + print ""; + + print ""; $i++; } - $colspan=4; + $colspan=5; if (! empty($conf->banque->enabled)) $colspan++; print ''; print ''; - print '"; + print '"; + print '"; print ''; print ''; print ''; From ddee8023249105fe0c264e703752084bce3976f6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 1 Aug 2017 10:22:09 +0200 Subject: [PATCH 043/207] Add second parameter in GETPOST --- htdocs/comm/propal/list.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 0fd9ddb4c7c..0f0f1ded0db 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -73,9 +73,9 @@ $search_zip=GETPOST('search_zip','alpha'); $search_state=trim(GETPOST("search_state")); $search_country=GETPOST("search_country",'int'); $search_type_thirdparty=GETPOST("search_type_thirdparty",'int'); -$viewstatut=GETPOST('viewstatut'); +$viewstatut=GETPOST('viewstatut','alpha'); $optioncss = GETPOST('optioncss','alpha'); -$object_statut=GETPOST('propal_statut'); +$object_statut=GETPOST('propal_statut','alpha'); $sall=GETPOST('sall', 'alphanohtml'); $mesg=(GETPOST("msg") ? GETPOST("msg") : GETPOST("mesg")); From adbb41799cd52c99a2fd9d12a33ce8595a022a32 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio Date: Tue, 1 Aug 2017 11:08:58 +0200 Subject: [PATCH 044/207] FIX: calculate correct remain to pay for planned bank transactions --- htdocs/compta/bank/treso.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/compta/bank/treso.php b/htdocs/compta/bank/treso.php index cbdb769789f..92c1a73cf4f 100644 --- a/htdocs/compta/bank/treso.php +++ b/htdocs/compta/bank/treso.php @@ -282,6 +282,8 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) $refcomp=$societestatic->getNomUrl(1,'',24); $paiement = $facturestatic->getSommePaiement(); // Payment already done + $paiement+= $facturestatic->getSumDepositsUsed(); + $paiement+= $facturestatic->getSumCreditNotesUsed(); } if ($obj->family == 'social_contribution') { From 03b3f54c2cc2c000a684d21e814653af0c8133ff Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 1 Aug 2017 13:10:15 +0200 Subject: [PATCH 045/207] Fix class not found --- .../project/doc/pdf_beluga.modules.php | 82 ++++++++++++------- 1 file changed, 51 insertions(+), 31 deletions(-) diff --git a/htdocs/core/modules/project/doc/pdf_beluga.modules.php b/htdocs/core/modules/project/doc/pdf_beluga.modules.php index 2b58cd59c09..15fd0e5f615 100644 --- a/htdocs/core/modules/project/doc/pdf_beluga.modules.php +++ b/htdocs/core/modules/project/doc/pdf_beluga.modules.php @@ -33,16 +33,17 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; -if (! empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; -if (! empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; -if (! empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php'; -if (! empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; -if (! empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; -if (! empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; -if (! empty($conf->contrat->enabled)) require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; -if (! empty($conf->ficheinter->enabled)) require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; -if (! empty($conf->deplacement->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php'; -if (! empty($conf->agenda->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; +if (! empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; +if (! empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; +if (! empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php'; +if (! empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; +if (! empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; +if (! empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; +if (! empty($conf->contrat->enabled)) require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; +if (! empty($conf->ficheinter->enabled)) require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; +if (! empty($conf->deplacement->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php'; +if (! empty($conf->expensereport->enabled)) require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; +if (! empty($conf->agenda->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; @@ -223,7 +224,7 @@ class pdf_beluga extends ModelePDFProjects $iniY = $tab_top + 7; $curY = $tab_top + 7; $nexY = $tab_top + 7; - + $listofreferent=array( 'propal'=>array( 'name'=>"Proposals", @@ -311,7 +312,7 @@ class pdf_beluga extends ModelePDFProjects 'margin'=>'minus', 'disableamount'=>1, 'test'=>$conf->expensereport->enabled && $user->rights->expensereport->lire, - 'lang'=>'trip'), + 'lang'=>'trip'), 'agenda'=>array( 'name'=>"Agenda", 'title'=>"ListActionsAssociatedProject", @@ -322,8 +323,8 @@ class pdf_beluga extends ModelePDFProjects 'test'=>$conf->agenda->enabled && $user->rights->agenda->allactions->read, 'lang'=>'agenda') ); - - + + foreach ($listofreferent as $key => $value) { $title=$value['title']; @@ -333,13 +334,13 @@ class pdf_beluga extends ModelePDFProjects $qualified=$value['test']; $langstoload=$value['lang']; $langs->load($langstoload); - + if ($qualified) { //var_dump("$key, $tablename, $datefieldname, $dates, $datee"); $elementarray = $object->get_element_list($key, $tablename, $datefieldname, $dates, $datee); //var_dump($elementarray); - + $num = count($elementarray); if ($num >= 0) { @@ -347,7 +348,7 @@ class pdf_beluga extends ModelePDFProjects $curY = $nexY; $pdf->SetXY($this->posxref, $curY); $pdf->MultiCell($this->posxstatut - $this->posxref, 3, $outputlangs->transnoentities($title), 0, 'L'); - + $selectList = $formproject->select_element($tablename, $project->thirdparty->id); $nexY = $pdf->GetY() + 1; $curY = $nexY; @@ -356,7 +357,9 @@ class pdf_beluga extends ModelePDFProjects $pdf->SetXY($this->posxdate, $curY); $pdf->MultiCell($this->posxsociety - $this->posxdate, 3, $outputlangs->transnoentities("Date"), 1, 'C'); $pdf->SetXY($this->posxsociety, $curY); - $pdf->MultiCell($this->posxamountht - $this->posxsociety, 3, $outputlangs->transnoentities("ThirdParty"), 1, 'L'); + $titlethirdparty=$outputlangs->transnoentities("ThirdParty"); + if ($classname == 'ExpenseReport') $titlethirdparty=$langs->trans("User"); + $pdf->MultiCell($this->posxamountht - $this->posxsociety, 3, $titlethirdparty, 1, 'L'); if (empty($value['disableamount'])) { $pdf->SetXY($this->posxamountht, $curY); $pdf->MultiCell($this->posxamountttc - $this->posxamountht, 3, $outputlangs->transnoentities("AmountHTShort"), 1, 'R'); @@ -368,30 +371,39 @@ class pdf_beluga extends ModelePDFProjects } $pdf->SetXY($this->posxstatut, $curY); $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxstatut, 3, $outputlangs->transnoentities("Statut"), 1, 'R'); - + if (is_array($elementarray) && count($elementarray) > 0) { $nexY = $pdf->GetY(); $curY = $nexY; - + $total_ht = 0; $total_ttc = 0; $num = count($elementarray); for ($i = 0; $i < $num; $i ++) { + $idofelement=$elementarray[$i]; + if ($classname == 'ExpenseReport') + { + // We get id of expense report + $expensereportline=new ExpenseReportLine($this->db); + $expensereportline->fetch($idofelement); + $idofelement = $expensereportline->fk_expensereport; + } + $element = new $classname($this->db); - $element->fetch($elementarray[$i]); + $element->fetch($idofelement); $element->fetch_thirdparty(); // print $classname; - + $qualifiedfortotal = true; if ($key == 'invoice') { if ($element->close_code == 'replaced') $qualifiedfortotal = false; // Replacement invoice } - + $pdf->SetXY($this->posxref, $curY); $pdf->MultiCell($this->posxdate - $this->posxref, 3, $element->ref, 1, 'L'); - + // Date if ($tablename == 'commande_fournisseur' || $tablename == 'supplier_order') $date = $element->date_commande; @@ -404,15 +416,23 @@ class pdf_beluga extends ModelePDFProjects if (empty($date)) $date = $element->datev; // Fiche inter } - + $pdf->SetXY($this->posxdate, $curY); $pdf->MultiCell($this->posxsociety - $this->posxdate, 3, dol_print_date($date, 'day'), 1, 'C'); - + $pdf->SetXY($this->posxsociety, $curY); if (is_object($element->thirdparty)) + { $pdf->MultiCell($this->posxamountht - $this->posxsociety, 3, $element->thirdparty->name, 1, 'L'); - - // Amount without tax + } + elseif ($classname == 'ExpenseReport') + { + $fuser=new User($this->db); + $fuser->fetch($element->fk_user_author); + $pdf->MultiCell($this->posxamountht - $this->posxsociety, 3, $fuser->getFullName($outputlangs), 1, 'L'); + } + + // Amount without tax if (empty($value['disableamount'])) { $pdf->SetXY($this->posxamountht, $curY); $pdf->MultiCell($this->posxamountttc - $this->posxamountht, 3, (isset($element->total_ht) ? price($element->total_ht) : ' '), 1, 'R'); @@ -422,7 +442,7 @@ class pdf_beluga extends ModelePDFProjects $pdf->SetXY($this->posxamountht, $curY); $pdf->MultiCell($this->posxstatut - $this->posxamountht, 3, "", 1, 'R'); } - + // Status if ($element instanceof CommonInvoice) { // This applies for Facture and FactureFournisseur @@ -432,7 +452,7 @@ class pdf_beluga extends ModelePDFProjects } $pdf->SetXY($this->posxstatut, $curY); $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxstatut, 3, $outputstatut, 1, 'R', false, 1, '', '', true, 0, true); - + if ($qualifiedfortotal) { $total_ht = $total_ht + $element->total_ht; $total_ttc = $total_ttc + $element->total_ttc; @@ -440,7 +460,7 @@ class pdf_beluga extends ModelePDFProjects $nexY = $pdf->GetY(); $curY = $nexY; } - + if (empty($value['disableamount'])) { $curY = $nexY; $pdf->SetXY($this->posxref, $curY); From 19ba90f57780e1ed724e382d7ed3a4f3e5dc64f2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 1 Aug 2017 13:17:27 +0200 Subject: [PATCH 046/207] Fix creation of leave request --- htdocs/holiday/card.php | 17 ++++++++++------- htdocs/holiday/class/holiday.class.php | 6 +++--- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index e50c880c0ee..8ee0fb64b40 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -60,7 +60,7 @@ if ($action == 'create') $object = new Holiday($db); // If no right to create a request - $fuserid = GETPOST('fuserid'); + $fuserid = GETPOST('fuserid','int'); if (($fuserid == $user->id && empty($user->rights->holiday->write)) || ($fuserid != $user->id && empty($user->rights->holiday->write_all))) { $error++; @@ -118,7 +118,7 @@ if ($action == 'create') } // Check if there is already holiday for this period - $verifCP = $object->verifDateHolidayCP($userID, $date_debut, $date_fin, $halfday); + $verifCP = $object->verifDateHolidayCP($fuserid, $date_debut, $date_fin, $halfday); if (! $verifCP) { setEventMessages($langs->trans("alreadyCPexist"), null, 'errors'); @@ -144,11 +144,9 @@ if ($action == 'create') $result = 0; - $result = 0; - if (! $error) { - $object->fk_user = $userid; + $object->fk_user = $fuserid; $object->description = $description; $object->date_debut = $date_debut; $object->date_fin = $date_fin; @@ -157,10 +155,15 @@ if ($action == 'create') $object->fk_type = $type; $result = $object->create($user); + if ($result <= 0) + { + setEventMessages($object->error, $object->errors, 'errors'); + $error++; + } } // If no SQL error we redirect to the request card - if (! $error && $result > 0) + if (! $error) { $db->commit(); @@ -834,7 +837,7 @@ if (empty($id) || $action == 'add' || $action == 'request' || $action == 'create print $form->select_dolusers($fuserid, 'useridbis', 0, '', 1, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); print ''; } - else print $form->select_dolusers(GETPOST('fuserid')?GETPOST('fuserid'):$user->id,'fuserid',0,'',0); + else print $form->select_dolusers(GETPOST('fuserid','int')?GETPOST('fuserid','int'):$user->id,'fuserid',0,'',0); print ''; print ''; diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 9973223ba0f..4815bee4b00 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -125,9 +125,9 @@ class Holiday extends CommonObject $now=dol_now(); // Check parameters - if (empty($this->fk_user) || ! is_numeric($this->fk_user) || $this->fk_user < 0) { $this->error="ErrorBadParameter"; return -1; } - if (empty($this->fk_validator) || ! is_numeric($this->fk_validator) || $this->fk_validator < 0) { $this->error="ErrorBadParameter"; return -1; } - if (empty($this->fk_type) || ! is_numeric($this->fk_type) || $this->fk_type < 0) { $this->error="ErrorBadParameter"; return -1; } + if (empty($this->fk_user) || ! is_numeric($this->fk_user) || $this->fk_user < 0) { $this->error="ErrorBadParameterFkUser"; return -1; } + if (empty($this->fk_validator) || ! is_numeric($this->fk_validator) || $this->fk_validator < 0) { $this->error="ErrorBadParameterFkValidator"; return -1; } + if (empty($this->fk_type) || ! is_numeric($this->fk_type) || $this->fk_type < 0) { $this->error="ErrorBadParameterFkType"; return -1; } // Insert request $sql = "INSERT INTO ".MAIN_DB_PREFIX."holiday("; From f9dc628f0bb0d528f292a4b7a4bb5a7bebb1f73d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 1 Aug 2017 15:53:22 +0200 Subject: [PATCH 047/207] Add tool to fix missing thumbs --- htdocs/core/lib/images.lib.php | 2 +- scripts/product/regenerate_thumbs.php | 106 ++++++++++++++++++++++++++ 2 files changed, 107 insertions(+), 1 deletion(-) create mode 100755 scripts/product/regenerate_thumbs.php diff --git a/htdocs/core/lib/images.lib.php b/htdocs/core/lib/images.lib.php index d9d7d0d9730..e6f69da1d93 100644 --- a/htdocs/core/lib/images.lib.php +++ b/htdocs/core/lib/images.lib.php @@ -347,7 +347,7 @@ function dolRotateImage($file_path) * @param int $quality Quality of compression (0=worst, 100=best) * @param string $outdir Directory where to store thumb * @param int $targetformat New format of target (IMAGETYPE_GIF, IMAGETYPE_JPG, IMAGETYPE_PNG, IMAGETYPE_BMP, IMAGETYPE_WBMP ... or 0 to keep old format) - * @return string Full path of thumb or '' if it fails + * @return string Full path of thumb or '' if it fails or 'Error...' if it fails */ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName='_small', $quality=50, $outdir='thumbs', $targetformat=0) { diff --git a/scripts/product/regenerate_thumbs.php b/scripts/product/regenerate_thumbs.php new file mode 100755 index 00000000000..389dcf2222a --- /dev/null +++ b/scripts/product/regenerate_thumbs.php @@ -0,0 +1,106 @@ +#!/usr/bin/env php + + * Copyright (C) 2015 Jean Heimburger + * + * 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 . + */ + +/** + * \file scripts/product/migrate_picture_path.php + * \ingroup scripts + * \brief Migrate pictures from old system prior to 3.7 to new path for 3.7+ + */ + +$sapi_type = php_sapi_name(); +$script_file = basename(__FILE__); +$path=dirname(__FILE__).'/'; + +// Test if batch mode +if (substr($sapi_type, 0, 3) == 'cgi') { + echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n"; + exit(-1); +} + +@set_time_limit(0); // No timeout for this script +define('EVEN_IF_ONLY_LOGIN_ALLOWED',1); // Set this define to 0 if you want to lock your script when dolibarr setup is "locked to admin user only". + +// Include and load Dolibarr environment variables +require_once($path."../../htdocs/master.inc.php"); +require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php"); +require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); +require_once(DOL_DOCUMENT_ROOT."/core/lib/images.lib.php"); +// After this $db, $mysoc, $langs, $conf and $hookmanager are defined (Opened $db handler to database will be closed at end of file). +// $user is created but empty. + +//$langs->setDefaultLang('en_US'); // To change default language of $langs +$langs->load("main"); // To load language file for default language + + +// Global variables +$version=DOL_VERSION; +$error=0; +$forcecommit=0; + + +print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n"; +dol_syslog($script_file." launched with arg ".join(',',$argv)); + +if (empty($argv[1])) { + print "Usage: $script_file subdirtoscan\n"; + print "Example: $script_file produit\n"; + exit(-1); +} + +print '--- start'."\n"; + +$dir = DOL_DATA_ROOT; +$subdir=$argv[1]; +if (empty($dir) || empty($subdir)) +{ + dol_print_error('', 'dir not defined'); + exit(1); +} +if (! dol_is_dir($dir.'/'.$subdir)) +{ + print 'Directory '.$dir.'/'.$subdir.' not found.'."\n"; + exit(2); +} + +$filearray=dol_dir_list($dir.'/'.$subdir,"directories",0,'','temp$'); + +global $maxwidthsmall, $maxheightsmall, $maxwidthmini, $maxheightmini; + +foreach($filearray as $keyf => $valf) +{ + $ref=basename($valf['name']); + $filearrayimg=dol_dir_list($valf['fullname'],"files",0,'(\.gif|\.png|\.jpg|\.jpeg|\.bmp)$','(\.meta|_preview.*\.png)$'); + foreach($filearrayimg as $keyi => $vali) + { + print 'Process image for ref '.$ref.' : '.$vali['name']."\n"; + + // Used on logon for example + $imgThumbSmall = vignette($vali['fullname'], $maxwidthsmall, $maxheightsmall, '_small', 50, "thumbs"); + if (preg_match('/Error/', $imgThumbSmall)) print $imgThumbSmall."\n"; + + // Create mini thumbs for image (Ratio is near 16/9) + // Used on menu or for setup page for example + $imgThumbMini = vignette($vali['fullname'], $maxwidthmini, $maxheightmini, '_mini', 50, "thumbs"); + if (preg_match('/Error/', $imgThumbMini)) print $imgThumbMini."\n"; + } +} + +$db->close(); // Close $db database opened handler + +exit($error); From 747719b3e8c93ed02a3770d5cb2127170f1c65ab Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 1 Aug 2017 15:54:28 +0200 Subject: [PATCH 048/207] Code comment --- scripts/product/regenerate_thumbs.php | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/product/regenerate_thumbs.php b/scripts/product/regenerate_thumbs.php index 389dcf2222a..bc3e1f53a6b 100755 --- a/scripts/product/regenerate_thumbs.php +++ b/scripts/product/regenerate_thumbs.php @@ -90,6 +90,7 @@ foreach($filearray as $keyf => $valf) { print 'Process image for ref '.$ref.' : '.$vali['name']."\n"; + // Create small thumbs for image // Used on logon for example $imgThumbSmall = vignette($vali['fullname'], $maxwidthsmall, $maxheightsmall, '_small', 50, "thumbs"); if (preg_match('/Error/', $imgThumbSmall)) print $imgThumbSmall."\n"; From 71d49f1c6f5761b9e09e980eeedc457c2ff1555a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 1 Aug 2017 18:32:21 +0200 Subject: [PATCH 049/207] Fix pb in ecm --- htdocs/core/ajax/ajaxdirpreview.php | 4 +- htdocs/core/class/html.form.class.php | 28 ++++++++----- htdocs/core/class/html.formfile.class.php | 6 +-- htdocs/core/lib/files.lib.php | 24 ++++++----- htdocs/core/lib/functions.lib.php | 2 +- htdocs/core/modules/modECM.class.php | 2 +- htdocs/ecm/class/ecmdirectory.class.php | 28 ++++++++++++- htdocs/ecm/docfile.php | 8 ++-- htdocs/ecm/docmine.php | 50 +++++++++++++++-------- htdocs/ecm/index.php | 4 +- 10 files changed, 104 insertions(+), 52 deletions(-) diff --git a/htdocs/core/ajax/ajaxdirpreview.php b/htdocs/core/ajax/ajaxdirpreview.php index 709d07c0832..cee16f923f5 100644 --- a/htdocs/core/ajax/ajaxdirpreview.php +++ b/htdocs/core/ajax/ajaxdirpreview.php @@ -202,7 +202,7 @@ if ($type == 'directory') $upload_dir = $conf->ecm->dir_output.'/'.$relativepath; // If $section defined with value 0 - if ($section === '0') + if ($section === '0' || empty($section)) { $filearray=array(); } @@ -216,7 +216,7 @@ if ($type == 'directory') else if ($section === '0') $textifempty='
    '.$langs->trans("DirNotSynchronizedSyncFirst").'

    '; else $textifempty=($showonrightsize=='featurenotyetavailable'?$langs->trans("FeatureNotYetAvailable"):$langs->trans("ECMSelectASection")); - $formfile->list_of_documents($filearray,'','ecm',$param,1,$relativepath,$user->rights->ecm->upload,1,$textifempty,$maxlengthname,'',$url); + $formfile->list_of_documents($filearray,'','ecm',$param,1,$relativepath,$user->rights->ecm->upload,1,$textifempty,$maxlengthname,'',$url); } } diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 27115d12eb7..c7dd20547f4 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -5890,18 +5890,22 @@ class Form $object->next_prev_filter.=$hookmanager->resPrint; } - //print "paramid=$paramid,morehtml=$morehtml,shownav=$shownav,$fieldid,$fieldref,$morehtmlref,$moreparam"; - $object->load_previous_next_ref((isset($object->next_prev_filter)?$object->next_prev_filter:''),$fieldid,$nodbprefix); - - $navurl = $_SERVER["PHP_SELF"]; - // Special case for project/task page - if ($paramid == 'project_ref') + $previous_ref = $next_ref = ''; + if ($shownav) { - $navurl = preg_replace('/\/tasks\/(task|contact|time|note|document).php/','/tasks.php',$navurl); - $paramid='ref'; + //print "paramid=$paramid,morehtml=$morehtml,shownav=$shownav,$fieldid,$fieldref,$morehtmlref,$moreparam"; + $object->load_previous_next_ref((isset($object->next_prev_filter)?$object->next_prev_filter:''),$fieldid,$nodbprefix); + + $navurl = $_SERVER["PHP_SELF"]; + // Special case for project/task page + if ($paramid == 'project_ref') + { + $navurl = preg_replace('/\/tasks\/(task|contact|time|note|document)\.php/','/tasks.php',$navurl); + $paramid='ref'; + } + $previous_ref = $object->ref_previous?'':''; + $next_ref = $object->ref_next?'':''; } - $previous_ref = $object->ref_previous?'':''; - $next_ref = $object->ref_next?'':''; //print "xx".$previous_ref."x".$next_ref; $ret.='
    '; @@ -5955,6 +5959,10 @@ class Form { $ret.=$object->label; } + else if ($object->element == 'ecm_directories') + { + $ret.=''; + } else if ($fieldref != 'none') $ret.=dol_htmlentities($object->$fieldref); diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 040ae1ba96e..c02d2b5c2be 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -1007,9 +1007,9 @@ class FormFile print '
    '.$langs->trans("Ref").''; print $form->showrefnav($object, 'id', $linkback, 1, 'rowid', 'ref', ''); print '
    '.$langs->trans("Label").''.$object->label.'
    '.$langs->trans("DatePayment").''; print dol_print_date($object->datep,'day'); print '
    '.$langs->trans("DateValue").''; print dol_print_date($object->datev,'day'); print '
    '; if (! empty($conf->accounting->enabled)) { - $accountancyaccount = new AccountingAccount($db); - $accountancyaccount->fetch('',$object->accountancy_code); + $accountingaccount = new AccountingAccount($db); + $accountingaccount->fetch('',$object->accountancy_code); - print $accountancyaccount->getNomUrl(1); - // print length_accountg($object->accountancy_code); + print $accountingaccount->getNomUrl(1); } else { print $object->accountancy_code; } @@ -411,7 +413,7 @@ if ($id) print '
    '."\n"; if ($object->rappro == 0) { - if (! empty($user->rights->banque->delete)) + if (! empty($user->rights->banque->modifier)) { print ''.$langs->trans("Delete").''; } diff --git a/htdocs/compta/bank/various_payment/index.php b/htdocs/compta/bank/various_payment/index.php index 5b2488cc5e8..101517df6fd 100644 --- a/htdocs/compta/bank/various_payment/index.php +++ b/htdocs/compta/bank/various_payment/index.php @@ -17,7 +17,7 @@ */ /** - * \file htdocs/compta/bank/various_payment/index.php + * \file htdocs/compta/bank/various_payment/index.php * \ingroup bank * \brief List of various payments */ @@ -25,10 +25,10 @@ require '../../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/paymentvarious.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; +if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php'; +if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php'; -$langs->load("compta"); -$langs->load("banks"); -$langs->load("bills"); +$langs->loadLangs(array("compta","banks","bills","accountancy")); // Security check $socid = GETPOST("socid","int"); @@ -41,7 +41,8 @@ $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; $search_ref = GETPOST('search_ref','int'); $search_user = GETPOST('search_user','alpha'); $search_label = GETPOST('search_label','alpha'); -$search_amount = GETPOST('search_amount','alpha'); +$search_amount_deb = GETPOST('search_amount_deb','alpha'); +$search_amount_cred = GETPOST('search_amount_cred','alpha'); $search_account = GETPOST('search_account','int'); $sortfield = GETPOST("sortfield",'alpha'); @@ -75,7 +76,8 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x', { $search_ref=""; $search_label=""; - $search_amount=""; + $search_amount_deb=""; + $search_amount_cred=""; $search_account=''; $typeid=""; } @@ -90,8 +92,8 @@ $form = new Form($db); $variousstatic = new PaymentVarious($db); $accountstatic = new Account($db); -$sql = "SELECT v.rowid, v.amount, v.label, v.datep as datep, v.datev as datev, v.fk_typepayment as type, v.num_payment, v.fk_bank,"; -$sql.= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel,"; +$sql = "SELECT v.rowid, v.amount, v.label, v.datep as datep, v.datev as datev, v.fk_typepayment as type, v.num_payment, v.fk_bank, v.accountancy_code, v.sens,"; +$sql.= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number as bank_account_number, ba.fk_accountancy_journal as accountancy_journal, ba.label as blabel,"; $sql.= " pst.code as payment_code"; $sql.= " FROM ".MAIN_DB_PREFIX."payment_various as v"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pst ON v.fk_typepayment = pst.id"; @@ -102,7 +104,8 @@ $sql.= " WHERE v.entity = ".$conf->entity; // Search criteria if ($search_ref) $sql.=" AND v.rowid=".$search_ref; if ($search_label) $sql.=natural_search(array('v.label'), $search_label); -if ($search_amount) $sql.=natural_search("v.amount", $search_amount, 1); +if ($search_amount_deb) $sql.=natural_search("v.amount", $search_amount_deb, 1); +if ($search_amount_cred) $sql.=natural_search("v.amount", $search_amount_cred, 1); if ($search_account > 0) $sql .=" AND b.fk_account=".$search_account; if ($filtre) { $filtre=str_replace(":","=",$filtre); @@ -113,7 +116,6 @@ if ($typeid) { } $sql.= $db->order($sortfield,$sortorder); -//$sql.= " GROUP BY u.rowid, u.lastname, u.firstname, v.rowid, v.fk_user, v.amount, v.label, v.datev, v.fk_typepayment, v.num_payment, pst.code"; $totalnboflines=0; $result=$db->query($sql); if ($result) @@ -156,24 +158,30 @@ if ($result) print_liste_field_titre($langs->trans("DatePayment"),$_SERVER["PHP_SELF"],"v.datep","",$param,'align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("PaymentMode"),$_SERVER["PHP_SELF"],"type","",$param,'align="left"',$sortfield,$sortorder); if (! empty($conf->banque->enabled)) print_liste_field_titre($langs->trans("BankAccount"),$_SERVER["PHP_SELF"],"ba.label","",$param,"",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Amount"),$_SERVER["PHP_SELF"],"v.amount","",$param,'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Sens"),$_SERVER["PHP_SELF"],"v.sens","",$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("AccountAccounting"),$_SERVER["PHP_SELF"],"v.accountancy_code","",$param,'align="left"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Debit"),$_SERVER["PHP_SELF"],"v.amount","",$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Credit"),$_SERVER["PHP_SELF"],"v.amount","",$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch '); print "
    '; print ''; print ' '; $form->select_types_paiements($typeid,'typeid','',0,0,1,16); print '  '; $searchpicto=$form->showFilterAndCheckAddButtons(0); @@ -193,6 +206,7 @@ if ($result) print "
    ".$variousstatic->getNomUrl(1)."".dol_trunc($obj->label,40)."'.dol_print_date($db->jdate($obj->datep),'day')."'.$langs->trans("PaymentTypeShort".$obj->payment_code).' '.$obj->num_payment.''; if ($obj->fk_bank > 0) { - //$accountstatic->fetch($obj->fk_bank); $accountstatic->id=$obj->bid; $accountstatic->ref=$obj->bref; $accountstatic->number=$obj->bnumber; - $accountstatic->accountancy_number=$obj->account_number; - $accountstatic->fk_accountancy_journal=$obj->fk_accountancy_journal; + + if (! empty($conf->accounting->enabled)) { + $accountstatic->account_number=$obj->bank_account_number; + + $accountingjournal = new AccountingJournal($db); + $accountingjournal->fetch($obj->accountancy_journal); + $accountstatic->accountancy_journal = $accountingjournal->getNomUrl(0,1,1,'',1); + } + $accountstatic->label=$obj->blabel; print $accountstatic->getNomUrl(1); } else print ' '; print '".price($obj->amount)."".$sens."
    '.$accountingaccount->getNomUrl(0,1,1,'',1).'"; + if ($obj->sens == 0) + { + print price($obj->amount); + $totalarray['totaldeb'] += $obj->amount; + } + print ""; + if ($obj->sens == 1) + { + print price($obj->amount); + $totalarray['totalcred'] += $obj->amount; + } + print "
    '.$langs->trans("Total").''.price($total)."'.price($totalarray['totaldeb'])."'.price($totalarray['totalcred'])."
    '."\n"; print ''; - print_liste_field_titre($langs->trans("Documents2"),$url,"name","",$param,'align="left"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Size"),$url,"size","",$param,'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Date"),$url,"date","",$param,'align="center"',$sortfield,$sortorder); + print_liste_field_titre('Documents2',$url,"name","",$param,'align="left"',$sortfield,$sortorder); + print_liste_field_titre('Size',$url,"size","",$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre('Date',$url,"date","",$param,'align="center"',$sortfield,$sortorder); if (empty($useinecm)) print_liste_field_titre('',$url,"","",$param,'align="center"'); print_liste_field_titre(''); if (! $disablemove) print_liste_field_titre(''); diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 0b8282ad5b6..394b3e76778 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1349,14 +1349,15 @@ function dol_init_file_process($pathtoscan='', $trackid='') * * @param string $upload_dir Directory where to store uploaded file (note: used to forge $destpath = $upload_dir + filename) * @param int $allowoverwrite 1=Allow overwrite existing file - * @param int $donotupdatesession 1=Do no edit _SESSION variable + * @param int $donotupdatesession 1=Do no edit _SESSION variable but update database index. 0=Update _SESSION and not database index. * @param string $varfiles _FILES var name * @param string $savingdocmask Mask to use to define output filename. For example 'XXXXX-__YYYYMMDD__-__file__' * @param string $link Link to add (to add a link instead of a file) * @param string $trackid Track id (used to prefix name of session vars to avoid conflict) + * @param int $generatethumbs 1=Generate also thumbs for uploaded image files * @return int <=0 if KO, >0 if OK */ -function dol_add_file_process($upload_dir, $allowoverwrite=0, $donotupdatesession=0, $varfiles='addedfile', $savingdocmask='', $link=null, $trackid='') +function dol_add_file_process($upload_dir, $allowoverwrite=0, $donotupdatesession=0, $varfiles='addedfile', $savingdocmask='', $link=null, $trackid='', $generatethumbs=1) { global $db,$user,$conf,$langs; @@ -1407,16 +1408,19 @@ function dol_add_file_process($upload_dir, $allowoverwrite=0, $donotupdatesessio include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; // Generate thumbs. - if (image_format_supported($destfull) == 1) + if ($generatethumbs) { - // Create thumbs - // We can't use $object->addThumbs here because there is no $object known + if (image_format_supported($destfull) == 1) + { + // Create thumbs + // We can't use $object->addThumbs here because there is no $object known - // Used on logon for example - $imgThumbSmall = vignette($destfull, $maxwidthsmall, $maxheightsmall, '_small', 50, "thumbs"); - // Create mini thumbs for image (Ratio is near 16/9) - // Used on menu or for setup page for example - $imgThumbMini = vignette($destfull, $maxwidthmini, $maxheightmini, '_mini', 50, "thumbs"); + // Used on logon for example + $imgThumbSmall = vignette($destfull, $maxwidthsmall, $maxheightsmall, '_small', 50, "thumbs"); + // Create mini thumbs for image (Ratio is near 16/9) + // Used on menu or for setup page for example + $imgThumbMini = vignette($destfull, $maxwidthmini, $maxheightmini, '_mini', 50, "thumbs"); + } } // Update session diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 61093ebcc52..0b629c1f215 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1341,7 +1341,7 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r if (! empty($object->label)) $morehtmlref.='
    '.$object->label.'
    '; } - if ($object->element != 'product' && $object->element != 'bookmark') + if ($object->element != 'product' && $object->element != 'bookmark' && $object->element != 'ecm_directories') { $morehtmlref.='
    '; $morehtmlref.=$object->getBannerAddress('refaddress',$object); diff --git a/htdocs/core/modules/modECM.class.php b/htdocs/core/modules/modECM.class.php index b263b16e29e..bfe0e45e02c 100644 --- a/htdocs/core/modules/modECM.class.php +++ b/htdocs/core/modules/modECM.class.php @@ -63,7 +63,7 @@ class modECM extends DolibarrModules $this->picto='dir'; // Data directories to create when module is enabled - $this->dirs = array("/ecm/temp"); + $this->dirs = array("/ecm/My_First_Directory","/ecm/temp"); // Config pages. Put here list of php page names stored in admmin directory used to setup module $this->config_page_url = array('ecm.php'); diff --git a/htdocs/ecm/class/ecmdirectory.class.php b/htdocs/ecm/class/ecmdirectory.class.php index 31439fa5ba3..5f713bdab91 100644 --- a/htdocs/ecm/class/ecmdirectory.class.php +++ b/htdocs/ecm/class/ecmdirectory.class.php @@ -27,8 +27,9 @@ */ class EcmDirectory // extends CommonObject { - //public $element='ecm_directories'; //!< Id that identify managed objects + public $element='ecm_directories'; //!< Id that identify managed objects //public $table_element='ecm_directories'; //!< Name of table without prefix where object is stored + var $picto = 'dir'; var $id; @@ -514,6 +515,31 @@ class EcmDirectory // extends CommonObject } + /** + * Retourne le libelle du status d'un user (actif, inactif) + * + * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @return string Label of status + */ + function getLibStatut($mode=0) + { + return $this->LibStatut($this->status,$mode); + } + + /** + * Return the status + * + * @param int $status Id status + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 5=Long label + Picto + * @return string Label of status + */ + static function LibStatut($status,$mode=0) + { + global $langs; + return ''; + } + + /** * Reconstruit l'arborescence des categories sous la forme d'un tableau à partir de la base de donnée * Renvoi un tableau de tableau('id','id_mere',...) trie selon arbre et avec: diff --git a/htdocs/ecm/docfile.php b/htdocs/ecm/docfile.php index 31f9b6b11c2..577ac3e0262 100644 --- a/htdocs/ecm/docfile.php +++ b/htdocs/ecm/docfile.php @@ -78,7 +78,7 @@ if (! $urlfile) // Load ecm object $ecmdir = new EcmDirectory($db); -$result=$ecmdir->fetch(GETPOST("section")); +$result=$ecmdir->fetch(GETPOST("section",'alpha')); if (! $result > 0) { dol_print_error($db,$ecmdir->error); @@ -109,10 +109,10 @@ if (! empty($_GET["fileid"])) * Put here all code to do according to value of "action" parameter ********************************************************************/ -if ($action == 'cancel') +if ($action == 'cancel') { $action =''; - if ($backtourl) + if ($backtourl) { header("Location: ".$backtourl); exit; @@ -144,7 +144,7 @@ if ($action == 'update') //print $oldfile.' - '.$newfile; if ($newlabel != $oldlabel) { - $result=dol_move($oldfile,$newfile); + $result=dol_move($oldfile, $newfile); if (! $result) { $langs->load('errors'); diff --git a/htdocs/ecm/docmine.php b/htdocs/ecm/docmine.php index 48f39cb12f2..f418627d1be 100644 --- a/htdocs/ecm/docmine.php +++ b/htdocs/ecm/docmine.php @@ -191,15 +191,15 @@ if ($action == 'update' && ! GETPOST('cancel')) /******************************************************************* -* PAGE -* -* Put here all code to do according to value of "action" parameter +* View ********************************************************************/ -llxHeader(); - $form=new Form($db); +$object=new EcmDirectory($db); // Need to create a new one +$object->fetch($ecmdir->id); + +llxHeader(); // Built the file List $filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1); @@ -211,7 +211,8 @@ foreach($filearray as $key => $file) $head = ecm_prepare_head($ecmdir); -dol_fiche_head($head, 'card', $langs->trans("ECMSectionManual"), '', 'dir'); +dol_fiche_head($head, 'card', $langs->trans("ECMSectionManual"), -1, 'dir'); + if ($action == 'edit') { @@ -221,13 +222,11 @@ if ($action == 'edit') print ''; } -print '
    '; -print ''; print "\n"; - + print ''; @@ -977,7 +977,7 @@ else print ''; print "\n"; - + print ""; print '\n"; - + print ""; print '
    '.$langs->trans("Ref").''; $s=''; -$tmpecmdir=new EcmDirectory($db); // Need to create a new one -$tmpecmdir->fetch($ecmdir->id); $result = 1; $i=0; +$tmpecmdir=new EcmDirectory($db); // Need to create a new one +$tmpecmdir->fetch($ecmdir->id); while ($tmpecmdir && $result > 0) { $tmpecmdir->ref=$tmpecmdir->label; @@ -248,10 +247,21 @@ while ($tmpecmdir && $result > 0) $i++; } +$morehtml=''; + +$morehtmlref = ''.$langs->trans("ECMRoot").' -> '.$s; + +dol_banner_tab($object, '', $morehtml, 0, '', '', $morehtmlref); + +print '
    '; + +print '
    '; +print ''; +/*print ''; -print '';*/ +print ''."\n"; + print ''."\n"; + - print ''."\n"; + print ''."\n"; + - print ''."\n"; + print ''."\n"; // Country - + print ''."\n"; - + print ''."\n"; - + print ''."\n"; - + print ''; print ''."\n"; - + print ''; print ''."\n"; - + print ''; print ''."\n"; // Web - + print ''; print ''."\n"; // Barcode if (! empty($conf->barcode->enabled)) { - + print ''; print ''; } // Logo - + print ''; // Capital - + print ''; // Juridical Status - + print ''; - + // Object of the company - + print ''; print ''; @@ -546,7 +546,7 @@ if ($action == 'edit' || $action == 'updateedit') print ''; print "\n"; - + print ''; @@ -561,7 +561,7 @@ if ($action == 'edit' || $action == 'updateedit') print ''; print "\n"; - + print ""; print '\n"; - + print ""; print '\n"; - + print ""; print '\n"; - + print ""; print ''; // Managing Director(s) - + print ''; // Capital - + print ''; // Juridical Status - + print ''; @@ -814,7 +814,7 @@ else // ProfId1 if ($langs->transcountry("ProfId1",$mysoc->country_code) != '-') { - + print ''; print ''; print ''; - - + + print ''; print '
    '.$langs->trans("Ref").''; print img_picto('','object_dir').' '.$langs->trans("ECMRoot").' -> '; print $s; -print '
    '.$langs->trans("Description").''; +print '
    '.$langs->trans("Description").''; if ($action == 'edit') { print '
    '; - print '
    '; - print '
    '; //if (empty($country_selected)) $country_selected=substr($langs->defaultlang,-2); // By default, country of localization print $form->select_country($mysoc->country_id,'country_id'); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); print '
    '; $formcompany->select_departement($conf->global->MAIN_INFO_SOCIETE_STATE,$mysoc->country_code,'state_id'); print '
    '; print $form->selectCurrency($conf->currency,"currency"); print '
    '; print '
    '; print '
    '; print '
    '; print '
    '; print '
    '; print ''; // Note - + print ''; + print ''; print ''; print '
    '; print ''; @@ -392,9 +392,9 @@ if ($action == 'edit' || $action == 'updateedit') print '
    '; - print '
    '; @@ -409,17 +409,17 @@ if ($action == 'edit' || $action == 'updateedit') $langs->load("companies"); // Managing Director(s) - + print '
    '; print '
    '; print '
    '; if ($mysoc->country_code) { print $formcompany->select_juridicalstatus($conf->global->MAIN_INFO_SOCIETE_FORME_JURIDIQUE, $mysoc->country_code, '', 'forme_juridique_code'); @@ -431,7 +431,7 @@ if ($action == 'edit' || $action == 'updateedit') // ProfID1 if ($langs->transcountry("ProfId1",$mysoc->country_code) != '-') { - + print '
    '; if (! empty($mysoc->country_code)) { @@ -447,7 +447,7 @@ if ($action == 'edit' || $action == 'updateedit') // ProfId2 if ($langs->transcountry("ProfId2",$mysoc->country_code) != '-') { - + print '
    '; if (! empty($mysoc->country_code)) { @@ -463,7 +463,7 @@ if ($action == 'edit' || $action == 'updateedit') // ProfId3 if ($langs->transcountry("ProfId3",$mysoc->country_code) != '-') { - + print '
    '; if (! empty($mysoc->country_code)) { @@ -479,7 +479,7 @@ if ($action == 'edit' || $action == 'updateedit') // ProfId4 if ($langs->transcountry("ProfId4",$mysoc->country_code) != '-') { - + print '
    '; if (! empty($mysoc->country_code)) { @@ -495,7 +495,7 @@ if ($action == 'edit' || $action == 'updateedit') // ProfId5 if ($langs->transcountry("ProfId5",$mysoc->country_code) != '-') { - + print '
    '; if (! empty($mysoc->country_code)) { @@ -511,7 +511,7 @@ if ($action == 'edit' || $action == 'updateedit') // ProfId6 if ($langs->transcountry("ProfId6",$mysoc->country_code) != '-') { - + print '
    '; if (! empty($mysoc->country_code)) { @@ -525,13 +525,13 @@ if ($action == 'edit' || $action == 'updateedit') } // TVA Intra - + print '
    '; print ''; print '
    '; print '
    '.$langs->trans("FiscalYearInformation").''.$langs->trans("Value").'
    '; print $formother->select_month($conf->global->SOCIETE_FISCAL_MONTH_START,'fiscalmonthstart',0,1) . '
     
    '; print ""; @@ -570,7 +570,7 @@ if ($action == 'edit' || $action == 'updateedit') print "
    "; print "
    '; print ""; @@ -593,7 +593,7 @@ if ($action == 'edit' || $action == 'updateedit') print ''; print ''; print "\n"; - + // Note: When option is not set, it must not appears as set on on, because there is no default value for this option print ""; print '
    '.$langs->transcountry("LocalTax1Management",$mysoc->country_code).''.$langs->trans("Description").' 
    global->FACTURE_LOCAL_TAX1_OPTION == '1' || $conf->global->FACTURE_LOCAL_TAX1_OPTION == "localtax1on")?" checked":"")."> ".$langs->transcountry("LocalTax1IsUsed",$mysoc->country_code)."'; @@ -616,7 +616,7 @@ if ($action == 'edit' || $action == 'updateedit') print "
    "; print "
    global->FACTURE_LOCAL_TAX1_OPTION) || $conf->global->FACTURE_LOCAL_TAX1_OPTION == "localtax1off")?" checked":"")."> ".$langs->transcountry("LocalTax1IsNotUsed",$mysoc->country_code)."'; print ""; @@ -637,7 +637,7 @@ if ($action == 'edit' || $action == 'updateedit') print ''; print "\n"; - + // Note: When option is not set, it must not appears as set on on, because there is no default value for this option print ""; print '
     
    global->FACTURE_LOCAL_TAX2_OPTION == '1' || $conf->global->FACTURE_LOCAL_TAX2_OPTION == "localtax2on")?" checked":"")."> ".$langs->transcountry("LocalTax2IsUsed",$mysoc->country_code)."'; @@ -657,7 +657,7 @@ if ($action == 'edit' || $action == 'updateedit') print "
    "; print "
    global->FACTURE_LOCAL_TAX2_OPTION) || $conf->global->FACTURE_LOCAL_TAX2_OPTION == "localtax2off")?" checked":"")."> ".$langs->transcountry("LocalTax2IsNotUsed",$mysoc->country_code)."'; print ""; @@ -693,22 +693,22 @@ else print '
    '; print ''; - + print ''; - + print ''; - + print ''; - + print ''; - + print ''; - + print ''; - + print ''; - + print ''; - + print ''; - + print ''; // Web - + print ''; // Barcode if (! empty($conf->barcode->enabled)) { - + print ''; } // Logo - + print ''; - + print ''; print '
    '.$langs->trans("CompanyInfo").''.$langs->trans("Value").'
    '.$langs->trans("CompanyName").''; if (! empty($conf->global->MAIN_INFO_SOCIETE_NOM)) print $conf->global->MAIN_INFO_SOCIETE_NOM; else print img_warning().' '.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyName")).''; print '
    '.$langs->trans("CompanyAddress").'' . nl2br(empty($conf->global->MAIN_INFO_SOCIETE_ADDRESS)?'':$conf->global->MAIN_INFO_SOCIETE_ADDRESS) . '
    '.$langs->trans("CompanyZip").'' . (empty($conf->global->MAIN_INFO_SOCIETE_ZIP)?'':$conf->global->MAIN_INFO_SOCIETE_ZIP) . '
    '.$langs->trans("CompanyTown").'' . (empty($conf->global->MAIN_INFO_SOCIETE_TOWN)?'':$conf->global->MAIN_INFO_SOCIETE_TOWN) . '
    '.$langs->trans("CompanyCountry").''; if ($mysoc->country_code) { @@ -719,13 +719,13 @@ else else print img_warning().' '.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).''; print '
    '.$langs->trans("State").''; if (! empty($conf->global->MAIN_INFO_SOCIETE_STATE)) print getState($conf->global->MAIN_INFO_SOCIETE_STATE); else print ' '; print '
    '.$langs->trans("CompanyCurrency").''; print currency_name($conf->currency,1); print ' ('.$conf->currency; @@ -733,28 +733,28 @@ else print ')'; print '
    '.$langs->trans("Phone").'' . dol_print_phone($conf->global->MAIN_INFO_SOCIETE_TEL,$mysoc->country_code) . '
    '.$langs->trans("Fax").'' . dol_print_phone($conf->global->MAIN_INFO_SOCIETE_FAX,$mysoc->country_code) . '
    '.$langs->trans("Mail").'' . dol_print_email($conf->global->MAIN_INFO_SOCIETE_MAIL,0,0,0,80) . '
    '.$langs->trans("Web").'' . dol_print_url($conf->global->MAIN_INFO_SOCIETE_WEB,'_blank',80) . '
    '.$langs->trans("Gencod").'' . $conf->global->MAIN_INFO_SOCIETE_GENCOD . '
    '.$langs->trans("Logo").''; $tagtd='tagtd '; @@ -780,7 +780,7 @@ else print '
    '.$langs->trans("Note").'' . (! empty($conf->global->MAIN_INFO_SOCIETE_NOTE) ? nl2br($conf->global->MAIN_INFO_SOCIETE_NOTE) : '') . '
    '; @@ -796,17 +796,17 @@ else print '
    '.$langs->trans("CompanyIds").''.$langs->trans("Value").'
    '.$langs->trans("ManagingDirectors").''; print $conf->global->MAIN_INFO_SOCIETE_MANAGERS . '
    '.$langs->trans("Capital").''; print $conf->global->MAIN_INFO_CAPITAL . '
    '.$langs->trans("JuridicalStatus").''; print getFormeJuridiqueLabel($conf->global->MAIN_INFO_SOCIETE_FORME_JURIDIQUE); print '
    '.$langs->transcountry("ProfId1",$mysoc->country_code).''; if (! empty($conf->global->MAIN_INFO_SIREN)) { @@ -830,7 +830,7 @@ else // ProfId2 if ($langs->transcountry("ProfId2",$mysoc->country_code) != '-') { - + print '
    '.$langs->transcountry("ProfId2",$mysoc->country_code).''; if (! empty($conf->global->MAIN_INFO_SIRET)) { @@ -846,7 +846,7 @@ else // ProfId3 if ($langs->transcountry("ProfId3",$mysoc->country_code) != '-') { - + print '
    '.$langs->transcountry("ProfId3",$mysoc->country_code).''; if (! empty($conf->global->MAIN_INFO_APE)) { @@ -862,7 +862,7 @@ else // ProfId4 if ($langs->transcountry("ProfId4",$mysoc->country_code) != '-') { - + print '
    '.$langs->transcountry("ProfId4",$mysoc->country_code).''; if (! empty($conf->global->MAIN_INFO_RCS)) { @@ -878,7 +878,7 @@ else // ProfId5 if ($langs->transcountry("ProfId5",$mysoc->country_code) != '-') { - + print '
    '.$langs->transcountry("ProfId5",$mysoc->country_code).''; if (! empty($conf->global->MAIN_INFO_PROFID5)) { @@ -894,7 +894,7 @@ else // ProfId6 if ($langs->transcountry("ProfId6",$mysoc->country_code) != '-') { - + print '
    '.$langs->transcountry("ProfId6",$mysoc->country_code).''; if (! empty($conf->global->MAIN_INFO_PROFID6)) { @@ -908,7 +908,7 @@ else } // VAT - + print '
    '.$langs->trans("VATIntra").''; if (! empty($conf->global->MAIN_INFO_TVAINTRA)) @@ -944,8 +944,8 @@ else } print '
    '.$langs->trans("CompanyObject").'' . (! empty($conf->global->MAIN_INFO_SOCIETE_OBJECT) ? nl2br($conf->global->MAIN_INFO_SOCIETE_OBJECT) : '') . '
    '; @@ -960,7 +960,7 @@ else print '
    '.$langs->trans("FiscalYearInformation").''.$langs->trans("Value").'
    '.$langs->trans("FiscalMonthStart").''; $monthstart=(! empty($conf->global->SOCIETE_FISCAL_MONTH_START)) ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1; print dol_print_date(dol_mktime(12,0,0,$monthstart,1,2000,1),'%B','gm') . '
     
    global->FACTURE_TVAOPTION)?"":" checked")."> ".$langs->trans("VATIsUsed")."'; print ""; @@ -986,7 +986,7 @@ else print "
    "; print "
    global->FACTURE_TVAOPTION)?" checked":"")."> ".$langs->trans("VATIsNotUsed")."'; print ""; @@ -1011,7 +1011,7 @@ else print ''; print "\n"; - + print ""; print '\n"; - + print ""; print '
     
    global->FACTURE_LOCAL_TAX1_OPTION == '1' || $conf->global->FACTURE_LOCAL_TAX1_OPTION == "localtax1on")?" checked":"")."> ".$langs->transcountry("LocalTax1IsUsed",$mysoc->country_code)."'; print ""; @@ -1039,7 +1039,7 @@ else print "
    "; print "
    global->FACTURE_LOCAL_TAX1_OPTION) || $conf->global->FACTURE_LOCAL_TAX1_OPTION == "localtax1off")?" checked":"")."> ".$langs->transcountry("LocalTax1IsNotUsed",$mysoc->country_code)."'; print ""; @@ -1061,7 +1061,7 @@ else print ''; print "\n"; - + print ""; print '\n"; - + print ""; print '
     
    global->FACTURE_LOCAL_TAX2_OPTION == '1' || $conf->global->FACTURE_LOCAL_TAX2_OPTION == "localtax2on")?" checked":"")."> ".$langs->transcountry("LocalTax2IsUsed",$mysoc->country_code)."'; print ""; @@ -1090,7 +1090,7 @@ else print "
    "; print "
    global->FACTURE_LOCAL_TAX2_OPTION) || $conf->global->FACTURE_LOCAL_TAX2_OPTION == "localtax2off")?" checked":"")."> ".$langs->transcountry("LocalTax2IsNotUsed",$mysoc->country_code)."'; print ""; diff --git a/htdocs/admin/menus/edit.php b/htdocs/admin/menus/edit.php index db03407fed1..cd236d85122 100644 --- a/htdocs/admin/menus/edit.php +++ b/htdocs/admin/menus/edit.php @@ -83,27 +83,27 @@ if ($action == 'update') } } } - + $menu = new Menubase($db); - $result=$menu->fetch($_POST['menuId']); + $result=$menu->fetch(GETPOST('menuId', 'int')); if ($result > 0) { - $menu->titre=$_POST['titre']; - $menu->leftmenu=$_POST['leftmenu']; - $menu->url=$_POST['url']; - $menu->langs=$_POST['langs']; - $menu->position=$_POST['position']; - $menu->enabled=$_POST['enabled']; - $menu->perms=$_POST['perms']; - $menu->target=$_POST['target']; - $menu->user=$_POST['user']; - if (is_numeric($_POST['menuIdParent'])) + $menu->titre=GETPOST('titre', 'alpha'); + $menu->leftmenu=GETPOST('leftmenu', 'alpha'); + $menu->url=GETPOST('url','alpha'); + $menu->langs=GETPOST('langs','alpha'); + $menu->position=GETPOST('position','int'); + $menu->enabled=GETPOST('enabled','alpha'); + $menu->perms=GETPOST('perms','alpha'); + $menu->target=GETPOST('target','alpha'); + $menu->user=GETPOST('user','alpha'); + if (is_numeric(GETPOST('menuIdParent','alpha'))) { - $menu->fk_menu=$_POST['menuIdParent']; + $menu->fk_menu=GETPOST('menuIdParent','alpha'); } else { - if ($_POST['type'] == 'top') $menu->fk_menu=0; + if (GETPOST('type','alpha') == 'top') $menu->fk_menu=0; else $menu->fk_menu=-1; $menu->fk_mainmenu=$mainmenu; $menu->fk_leftmenu=$leftmenu; @@ -123,7 +123,6 @@ if ($action == 'update') { setEventMessages($menu->error, $menu->errors, 'errors'); } - $_GET["menuId"] = $_POST['menuId']; $action = "edit"; } else @@ -148,9 +147,9 @@ if ($action == 'add') } $leftmenu=''; $mainmenu=''; - if (! empty($_POST['menuId']) && ! is_numeric($_POST['menuId'])) + if (GETPOST('menuId','int') && ! is_numeric(GETPOST('menuId','int'))) { - $tmp=explode('&',$_POST['menuId']); + $tmp=explode('&',GETPOST('menuId','int')); foreach($tmp as $s) { if (preg_match('/fk_mainmenu=/',$s)) @@ -197,7 +196,7 @@ if ($action == 'add') $action = 'create'; $error++; } - if (! $error && empty($_POST['menuId']) && $_POST['type'] == 'left') + if (! $error && ! $_POST['menuId'] && $_POST['type'] == 'left') { setEventMessages($langs->trans("ErrorLeftMenuMustHaveAParentId"), null, 'errors'); $action = 'create'; @@ -207,23 +206,23 @@ if ($action == 'add') if (! $error) { $menu = new Menubase($db); - $menu->menu_handler=preg_replace('/_menu$/','',$_POST['menu_handler']); - $menu->type=$_POST['type']; - $menu->titre=$_POST['titre']; - $menu->url=$_POST['url']; - $menu->langs=$_POST['langs']; - $menu->position=$_POST['position']; - $menu->enabled=$_POST['enabled']; - $menu->perms=$_POST['perms']; - $menu->target=$_POST['target']; - $menu->user=$_POST['user']; - if (is_numeric($_POST['menuId'])) + $menu->menu_handler=preg_replace('/_menu$/','',GETPOST('menu_handler','aZ09')); + $menu->type=GETPOST('type','alpha'); + $menu->titre=GETPOST('titre','alpha'); + $menu->url=GETPOST('url','alpha'); + $menu->langs=GETPOST('langs','alpha'); + $menu->position=GETPOST('position','int'); + $menu->enabled=GETPOST('enabled','alpha'); + $menu->perms=GETPOST('perms','alpha'); + $menu->target=GETPOST('target','alpha'); + $menu->user=GETPOST('user','alpha'); + if (is_numeric(GETPOST('menuId','int'))) { - $menu->fk_menu=$_POST['menuId']; + $menu->fk_menu=GETPOST('menuId','int'); } else { - if ($_POST['type'] == 'top') $menu->fk_menu=0; + if (GETPOST('type','alpha') == 'top') $menu->fk_menu=0; else $menu->fk_menu=-1; $menu->fk_mainmenu=$mainmenu; $menu->fk_leftmenu=$leftmenu; @@ -232,7 +231,7 @@ if ($action == 'add') $result=$menu->create($user); if ($result > 0) { - header("Location: ".DOL_URL_ROOT."/admin/menus/index.php?menu_handler=".$_POST['menu_handler']); + header("Location: ".DOL_URL_ROOT."/admin/menus/index.php?menu_handler=".GETPOST('menu_handler','aZ09')); exit; } else @@ -305,17 +304,17 @@ if ($action == 'create') '; print load_fiche_titre($langs->trans("NewMenu"),'','title_setup'); - - print ''; + + print ''; print ''; dol_fiche_head(); - + print '
    '; // Id - $parent_rowid = $_GET['menuId']; - if ($_GET['menuId']) + $parent_rowid = GETPOST('menuId', 'int'); + if (GETPOST('menuId', 'int')) { $sql = "SELECT m.rowid, m.mainmenu, m.leftmenu, m.level, m.langs FROM ".MAIN_DB_PREFIX."menu as m WHERE m.rowid = ".GETPOST('menuId', 'int'); $res = $db->query($sql); @@ -375,40 +374,40 @@ if ($action == 'create') } else { - print ''; + print ''; } print ''; // Title - print ''; + print ''; // URL - print ''; + print ''; // Langs print ''; // Position - print ''; + print ''; // Target print ''; // Enabled - print ''; + print ''; // Perms - print ''; + print ''; print '
    '.$langs->trans('DetailMenuIdParent'); print ', '.$langs->trans("Example").': fk_mainmenu=abc&fk_leftmenu=def'; print '
    '.$langs->trans('Title').''.$langs->trans('DetailTitre').'
    '.$langs->trans('Title').''.$langs->trans('DetailTitre').'
    '.$langs->trans('URL').''.$langs->trans('DetailUrl').'
    '.$langs->trans('URL').''.$langs->trans('DetailUrl').'
    '.$langs->trans('LangFile').''.$langs->trans('DetailLangs').'
    '.$langs->trans('Position').''.$langs->trans('DetailPosition').'
    '.$langs->trans('Position').''.$langs->trans('DetailPosition').'
    '.$langs->trans('Target').''.$langs->trans('DetailTarget').'
    '.$langs->trans('Enabled').''.$langs->trans('DetailEnabled').'
    '.$langs->trans('Enabled').''.$langs->trans('DetailEnabled').'
    '.$langs->trans('Rights').''.$langs->trans('DetailRight').'
    '.$langs->trans('Rights').''.$langs->trans('DetailRight').'
    '; dol_fiche_end(); - + // Boutons print '
    '; print ''; @@ -426,14 +425,14 @@ elseif ($action == 'edit') print ''; print ''; print ''; - print ''; + print ''; dol_fiche_head(); - + print ''; $menu = new Menubase($db); - $result=$menu->fetch($_GET['menuId']); + $result=$menu->fetch(GETPOST('menuId', 'int')); //var_dump($menu); // Id @@ -472,20 +471,20 @@ elseif ($action == 'edit') //print ''; // Title - print ''; + print ''; // Url print ''; // Langs - print ''; + print ''; // Position print ''; // Target print ''; @@ -502,7 +501,7 @@ elseif ($action == 'edit') print '
    '.$langs->trans('Level').''.$menu->level.''.$langs->trans('DetailLevel').'
    '.$langs->trans('Title').''.$langs->trans('DetailTitre').'
    '.$langs->trans('Title').''.$langs->trans('DetailTitre').'
    '.$langs->trans('URL').''.$langs->trans('DetailUrl').'
    '.$langs->trans('LangFile').''.$langs->trans('DetailLangs').'
    '.$langs->trans('LangFile').''.$langs->trans('DetailLangs').'
    '.$langs->trans('Position').''.$langs->trans('DetailPosition').'
    '.$langs->trans('Target').''.$langs->trans('DetailTarget').'
    '; dol_fiche_end(); - + // Bouton print '
    '; print ''; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index d79c3def247..ee683f5747d 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3251,7 +3251,12 @@ function dol_print_error($db='',$error='',$errors=null) } if (empty($dolibarr_main_prod)) print $out; - else define("MAIN_CORE_ERROR", 1); + else + { + print $langs->trans("DolibarrHasDetectedError").'. '; + print $langs->trans("YouCanSetOptionDolibarrMainProdToZero"); + define("MAIN_CORE_ERROR", 1); + } //else print 'Sorry, an error occured but the parameter $dolibarr_main_prod is defined in conf file so no message is reported to your browser. Please read the log file for error message.'; dol_syslog("Error ".$syslog, LOG_ERR); } diff --git a/htdocs/document.php b/htdocs/document.php index 206ea69688a..d35021005e6 100644 --- a/htdocs/document.php +++ b/htdocs/document.php @@ -110,7 +110,7 @@ if (empty($modulepart)) accessforbidden('Bad value for parameter modulepart'); $check_access = dol_check_secure_access_document($modulepart, $original_file, $entity, $refname); $accessallowed = $check_access['accessallowed']; $sqlprotectagainstexternals = $check_access['sqlprotectagainstexternals']; -$original_file = $check_access['original_file']; // original_file is now a full path name +$fullpath_original_file = $check_access['original_file']; // $fullpath_original_file is now a full path name // Basic protection (against external users only) if ($user->societe_id > 0) @@ -137,36 +137,35 @@ if ($user->societe_id > 0) } // Security: -// Limite acces si droits non corrects +// Limit access if permissions are wrong if (! $accessallowed) { accessforbidden(); } // Security: -// On interdit les remontees de repertoire ainsi que les pipe dans -// les noms de fichiers. -if (preg_match('/\.\./',$original_file) || preg_match('/[<>|]/',$original_file)) +// On interdit les remontees de repertoire ainsi que les pipe dans les noms de fichiers. +if (preg_match('/\.\./',$fullpath_original_file) || preg_match('/[<>|]/',$fullpath_original_file)) { - dol_syslog("Refused to deliver file ".$original_file); - $file=basename($original_file); // Do no show plain path of original_file in shown error message - dol_print_error(0,$langs->trans("ErrorFileNameInvalid",$file)); + dol_syslog("Refused to deliver file ".$fullpath_original_file); + print "ErrorFileNameInvalid: ".$original_file; exit; } clearstatcache(); -$filename = basename($original_file); +$filename = basename($fullpath_original_file); // Output file on browser -dol_syslog("document.php download $original_file $filename content-type=$type"); -$original_file_osencoded=dol_osencode($original_file); // New file name encoded in OS encoding charset +dol_syslog("document.php download $fullpath_original_file filename=$filename content-type=$type"); +$fullpath_original_file_osencoded=dol_osencode($fullpath_original_file); // New file name encoded in OS encoding charset // This test if file exists should be useless. We keep it to find bug more easily -if (! file_exists($original_file_osencoded)) +if (! file_exists($fullpath_original_file_osencoded)) { - dol_print_error(0,$langs->trans("ErrorFileDoesNotExists",$original_file)); + dol_syslog("ErrorFileDoesNotExists: ".$fullpath_original_file); + print "ErrorFileDoesNotExists: ".$original_file; exit; } @@ -177,7 +176,7 @@ if ($encoding) header('Content-Encoding: '.$encoding); // Add MIME Content-Disposition from RFC 2183 (inline=automatically displayed, atachment=need user action to open) if ($attachment) header('Content-Disposition: attachment; filename="'.$filename.'"'); else header('Content-Disposition: inline; filename="'.$filename.'"'); -header('Content-Length: ' . dol_filesize($original_file)); +header('Content-Length: ' . dol_filesize($fullpath_original_file)); // Ajout directives pour resoudre bug IE header('Cache-Control: Public, must-revalidate'); header('Pragma: public'); @@ -185,6 +184,6 @@ header('Pragma: public'); //ob_clean(); //flush(); -readfile($original_file_osencoded); +readfile($fullpath_original_file_osencoded); if (is_object($db)) $db->close(); diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index d5cbd14c11d..a314f59b6b5 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -103,7 +103,8 @@ RequestLastAccessInError=Latest database access request error ReturnCodeLastAccessInError=Return code for latest database access request error InformationLastAccessInError=Information for latest database access request error DolibarrHasDetectedError=Dolibarr has detected a technical error -InformationToHelpDiagnose=This information can be useful for diagnostic purposes +YouCanSetOptionDolibarrMainProdToZero=You can read log file or set option $dolibarr_main_prod to '0' in your config file to get more information. +InformationToHelpDiagnose=This information can be useful for diagnostic purposes (you can set option $dolibarr_main_prod to '1' to remove such notices) MoreInformation=More information TechnicalInformation=Technical information TechnicalID=Technical ID diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 8d34517686b..cd5cb0ba296 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -77,38 +77,39 @@ if (function_exists('get_magic_quotes_gpc')) // magic_quotes_* deprecated in PHP */ function test_sql_and_script_inject($val, $type) { - $sql_inj = 0; + $inj = 0; // For SQL Injection (only GET and POST are used to be included into bad escaped SQL requests) if ($type != 2) { - $sql_inj += preg_match('/delete\s+from/i', $val); - $sql_inj += preg_match('/create\s+table/i', $val); - $sql_inj += preg_match('/update.+set.+=/i', $val); - $sql_inj += preg_match('/insert\s+into/i', $val); - $sql_inj += preg_match('/select.+from/i', $val); - $sql_inj += preg_match('/union.+select/i', $val); - $sql_inj += preg_match('/into\s+(outfile|dumpfile)/i', $val); - $sql_inj += preg_match('/(\.\.%2f)+/i', $val); + $inj += preg_match('/delete\s+from/i', $val); + $inj += preg_match('/create\s+table/i', $val); + $inj += preg_match('/update.+set.+=/i', $val); + $inj += preg_match('/insert\s+into/i', $val); + $inj += preg_match('/select.+from/i', $val); + $inj += preg_match('/union.+select/i', $val); + $inj += preg_match('/into\s+(outfile|dumpfile)/i', $val); + $inj += preg_match('/(\.\.%2f)+/i', $val); } // For XSS Injection done by adding javascript with script // This is all cases a browser consider text is javascript: // When it found ' - $sql_inj += preg_match('/onerror\s*=/i', $val); // onerror can be set on img or any html tag like - $sql_inj += preg_match('/onfocus\s*=/i', $val); // onfocus can be set on input text html tag like + $inj += preg_match('/