From 3299e5f88906bab19d6d53aa86ead716d4bd2648 Mon Sep 17 00:00:00 2001 From: BENKE Charlie Date: Sun, 26 Mar 2017 19:13:10 +0200 Subject: [PATCH 001/183] PRODUCT_PRICE_SUPPLIER_NO_LOG test inverted if PRODUCT_PRICE_SUPPLIER_NO_LOG is empty, no log is stored if PRODUCT_PRICE_SUPPLIER_NO_LOG is not empty log is stored they are inversion @eldy maybe add more field in this table --- htdocs/fourn/class/fournisseur.product.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index eaff46ddc2c..94034408e49 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -310,7 +310,7 @@ class ProductFournisseur extends Product $error++; } - if (! $error && ! empty($conf->global->PRODUCT_PRICE_SUPPLIER_NO_LOG)) { + if (! $error && empty($conf->global->PRODUCT_PRICE_SUPPLIER_NO_LOG)) { // Add record into log table $sql = "INSERT INTO " . MAIN_DB_PREFIX . "product_fournisseur_price_log("; $sql .= "datec, fk_product_fournisseur,fk_user,price,quantity)"; From d8018f7937c2ae4c9a499df2eae9591876461735 Mon Sep 17 00:00:00 2001 From: BENKE Charlie Date: Sun, 26 Mar 2017 19:16:19 +0200 Subject: [PATCH 002/183] add trigger on product price add/update --- .../product/class/productcustomerprice.class.php | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/htdocs/product/class/productcustomerprice.class.php b/htdocs/product/class/productcustomerprice.class.php index fd36c55dcf9..9c2ce3e99d2 100644 --- a/htdocs/product/class/productcustomerprice.class.php +++ b/htdocs/product/class/productcustomerprice.class.php @@ -669,15 +669,12 @@ class Productcustomerprice extends CommonObject if (! $error) { if (! $notrigger) { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action calls a trigger. - - // // Call triggers - // include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - // $interface=new Interfaces($this->db); - // $result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf); - // if ($result < 0) { $error++; $this->errors=$interface->errors; } - // // End call triggers + // Call triggers + include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; + $interface=new Interfaces($this->db); + $result=$interface->run_triggers('CUSTOMER_PRODUCT_SELLPRICE_CREATE',$this,$user,$langs,$conf); + if ($result < 0) { $error++; $this->errors=$interface->errors; } + // End call triggers } } From d60f1d8402a085c54953af11471016f0383689a7 Mon Sep 17 00:00:00 2001 From: BENKE Charlie Date: Sun, 26 Mar 2017 19:29:16 +0200 Subject: [PATCH 003/183] add price_level on product_customer_price_log fk_soc can be 0 when generic price is stored on log --- htdocs/install/mysql/tables/llx_product_customer_price_log.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/install/mysql/tables/llx_product_customer_price_log.sql b/htdocs/install/mysql/tables/llx_product_customer_price_log.sql index 699060cdc98..1d728dd2486 100644 --- a/htdocs/install/mysql/tables/llx_product_customer_price_log.sql +++ b/htdocs/install/mysql/tables/llx_product_customer_price_log.sql @@ -24,7 +24,8 @@ create table llx_product_customer_price_log entity integer DEFAULT 1 NOT NULL, -- multi company id datec datetime, fk_product integer NOT NULL, - fk_soc integer NOT NULL, + fk_soc integer DEFAULT 0 NOT NULL, + price_level smallint NULL DEFAULT 1, price double(24,8) DEFAULT 0, price_ttc double(24,8) DEFAULT 0, price_min double(24,8) DEFAULT 0, From 9871bc3d9a006e6275eebbdaf6c0a6f78ad1bc92 Mon Sep 17 00:00:00 2001 From: BENKE Charlie Date: Sun, 26 Mar 2017 19:35:00 +0200 Subject: [PATCH 004/183] Update 5.0.0-6.0.0.sql --- htdocs/install/mysql/migration/5.0.0-6.0.0.sql | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql index 25145dc7cfe..bdc2630a4c4 100644 --- a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql +++ b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql @@ -25,6 +25,8 @@ -- -- VMYSQL4.1 DELETE FROM llx_usergroup_user WHERE fk_usergroup NOT IN (SELECT rowid from llx_usergroup); +ALTER TABLE llx_product_customer_price_log ADD COLUMN price_level smallint default 1; + ALTER TABLE llx_ecm_files ADD COLUMN ref varchar(128) AFTER rowid; ALTER TABLE llx_ecm_files CHANGE COLUMN fullpath filepath varchar(255); ALTER TABLE llx_ecm_files CHANGE COLUMN filepath filepath varchar(255); From d34a8f42842a7fdd390640e9351c1e2d49d224af Mon Sep 17 00:00:00 2001 From: BENKE Charlene Date: Mon, 26 Jun 2017 14:15:36 +0200 Subject: [PATCH 005/183] Refactoring tpl Folder --- htdocs/core/tpl/originproductline.tpl.php | 29 +++++++++++++---------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/htdocs/core/tpl/originproductline.tpl.php b/htdocs/core/tpl/originproductline.tpl.php index 78006316f63..c8cd6674a7a 100644 --- a/htdocs/core/tpl/originproductline.tpl.php +++ b/htdocs/core/tpl/originproductline.tpl.php @@ -1,5 +1,6 @@ +/* Copyright (C) 2017 Charlie Benke * * 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 @@ -18,16 +19,20 @@ ?> -> - tpl['label']; ?> - tpl['description']; ?> - tpl['vat_rate']; ?> - tpl['price']; ?> - multicurrency->enabled)) { ?>tpl['multicurrency_price']; ?> - tpl['qty']; ?> - global->PRODUCT_USE_UNITS) echo ''.$langs->trans($this->tpl['unit']).''; - ?> - tpl['remise_percent']; ?> - +'; +print ''.$this->tpl['label'].''; +print ''.$this->tpl['description'].''; +print ''.$this->tpl['vat_rate'].''; +print ''.$this->tpl['price'].''; +if (!empty($conf->multicurrency->enabled)) + print ''.$this->tpl['multicurrency_price'].''; + +print ''.$this->tpl['qty'].''; +if($conf->global->PRODUCT_USE_UNITS) + print ''.$langs->trans($this->tpl['unit']).''; + +print ''.$this->tpl['remise_percent'].''; +print ''."\n"; +?> From 01c3e6fb82fd95ef28eb3201588e2dab11796358 Mon Sep 17 00:00:00 2001 From: BENKE Charlene Date: Mon, 26 Jun 2017 23:06:24 +0200 Subject: [PATCH 006/183] TPL refactoring --- htdocs/core/tpl/notes.tpl.php | 40 +++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/htdocs/core/tpl/notes.tpl.php b/htdocs/core/tpl/notes.tpl.php index 2538e052ae4..e925fa64783 100644 --- a/htdocs/core/tpl/notes.tpl.php +++ b/htdocs/core/tpl/notes.tpl.php @@ -66,21 +66,29 @@ elseif ($module == 'product') { $permission=$user->rights->produit->creer; if (! empty($conf->global->FCKEDITOR_ENABLE_SOCIETE)) $typeofdata='ckeditor:dolibarr_notes:100%:200::1:12:95%'; // Rem: This var is for all notes, not only thirdparties note. else $typeofdata='textarea:12:95%'; +print ''."\n"; +print '
'."\n"; +if ($module != 'product') { + // No public note yet on products + print '
'."\n"; + print '
'."\n"; + print $form->editfieldkey("NotePublic", $note_public, $value_public, $object, $permission, $typeofdata, $moreparam, '', 0); + print '
'."\n"; + print '
'."\n"; + print $form->editfieldval("NotePublic", $note_public, $value_public, $object, $permission, $typeofdata, '', null, null, $moreparam, 1)."\n"; + print '
'."\n"; + print '
'."\n"; +} +if (empty($user->societe_id)) { + print '
'."\n"; + print '
'."\n"; + print $form->editfieldkey("NotePrivate", $note_private, $value_private, $object, $permission, $typeofdata, $moreparam, '', 0); + print '
'."\n"; + print '
'."\n"; + print $form->editfieldval("NotePrivate", $note_private, $value_private, $object, $permission, $typeofdata, '', null, null, $moreparam, 1); + print '
'."\n"; + print '
'."\n"; +} +print '
'."\n"; ?> - - -
- -
-
>editfieldkey("NotePublic", $note_public, $value_public, $object, $permission, $typeofdata, $moreparam, '', 0); ?>
-
editfieldval("NotePublic", $note_public, $value_public, $object, $permission, $typeofdata, '', null, null, $moreparam, 1); ?>
-
- -societe_id)) { ?> -
-
>editfieldkey("NotePrivate", $note_private, $value_private, $object, $permission, $typeofdata, $moreparam, '', 0); ?>
-
editfieldval("NotePrivate", $note_private, $value_private, $object, $permission, $typeofdata, '', null, null, $moreparam, 1); ?>
-
- -
From bb6b8015fe8dd841a1f45eb6e56f24a1f5fa94af Mon Sep 17 00:00:00 2001 From: TuxGasy Date: Mon, 3 Jul 2017 12:30:41 +0200 Subject: [PATCH 007/183] Add docker-compose.yml file to build development environment based on Docker --- Dockerfile | 15 ++++++++------- docker-compose.yml | 33 +++++++++++++++++++++++++++++++++ docker-run.sh | 15 +++++++++++++++ 3 files changed, 56 insertions(+), 7 deletions(-) create mode 100644 docker-compose.yml create mode 100644 docker-run.sh diff --git a/Dockerfile b/Dockerfile index 00a5d0ef567..caa7b0c436a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,7 @@ -FROM php:5.6-apache +FROM php:7.0-apache + +ENV HOST_USER_ID 33 +ENV PHP_INI_DATE_TIMEZONE 'UTC' RUN apt-get update && apt-get install -y libpng12-dev libjpeg-dev libldap2-dev \ && rm -rf /var/lib/apt/lists/* \ @@ -9,11 +12,9 @@ RUN apt-get update && apt-get install -y libpng12-dev libjpeg-dev libldap2-dev \ && docker-php-ext-install mysqli \ && apt-get purge -y libpng12-dev libjpeg-dev libldap2-dev -COPY htdocs/ /var/www/html/ - -RUN chown -hR www-data:www-data /var/www/html - -VOLUME /var/www/html/conf -VOLUME /var/www/html/documents +COPY docker-run.sh /usr/local/bin/ +RUN chmod +x /usr/local/bin/docker-run.sh EXPOSE 80 + +ENTRYPOINT ["docker-run.sh"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000000..2f0b5536d4f --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,33 @@ +# This docker-compose.yml file is used to build and run Dolibarr +# in the current workspace +# +# Before build/run, define the variable HOST_USER_ID as following: +# $ export HOST_USER_ID=$(id -u) +# And then, you can run : +# $ docker-compose up + +mariadb: + image: mariadb:latest + environment: + MYSQL_ROOT_PASSWORD: root + MYSQL_DATABASE: dolibarr + +phpmyadmin: + image: phpmyadmin/phpmyadmin + environment: + PMA_HOST: mariadb + links: + - mariadb + ports: + - "8080:80" + +web: + build: . + environment: + HOST_USER_ID: $HOST_USER_ID + volumes: + - ./htdocs:/var/www/html + links: + - mariadb + ports: + - "80:80" diff --git a/docker-run.sh b/docker-run.sh new file mode 100644 index 00000000000..c151e1c3cab --- /dev/null +++ b/docker-run.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +usermod -u $HOST_USER_ID www-data +groupmod -g $HOST_USER_ID www-data + +chown -hR www-data:www-data /var/www + +if [ ! -f /usr/local/etc/php/php.ini ]; then + cat < /usr/local/etc/php/php.ini +date.timezone = $PHP_INI_DATE_TIMEZONE +display_errors = On +EOF +fi + +exec apache2-foreground From 0932ebd6c87f86fa70f2d737102fed64d487b6a8 Mon Sep 17 00:00:00 2001 From: Andreas Pachler Date: Mon, 10 Jul 2017 14:09:21 +0200 Subject: [PATCH 008/183] Added functionality to get order customer contact as contact_xx tags --- .../doc/doc_generic_order_odt.modules.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php b/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php index 9e26b31b0ce..4629f52294b 100644 --- a/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php +++ b/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php @@ -275,9 +275,9 @@ class doc_generic_order_odt extends ModelePDFCommandes dol_mkdir($conf->commande->dir_temp); - // If BILLING contact defined on invoice, we use it + // If CUSTOMER contact defined on order, we use it $usecontact=false; - $arrayidcontact=$object->getIdContact('external','BILLING'); + $arrayidcontact=$object->getIdContact('external','CUSTOMER'); if (count($arrayidcontact) > 0) { $usecontact=true; @@ -289,7 +289,11 @@ class doc_generic_order_odt extends ModelePDFCommandes { // On peut utiliser le nom de la societe du contact if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; - else $socobject = $object->thirdparty; + else { + $socobject = $object->thirdparty; + // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use + $contactobject = $object->contact; + } } else { @@ -356,8 +360,12 @@ class doc_generic_order_odt extends ModelePDFCommandes $array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs); $array_objet=$this->get_substitutionarray_object($object,$outputlangs); $array_other=$this->get_substitutionarray_other($outputlangs); + // retrieve contact information for use in order as contact_xxx tags + $array_thirdparty_contact = array(); + if ($usecontact) + $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); - $tmparray = array_merge($array_user,$array_soc,$array_thirdparty,$array_objet,$array_other); + $tmparray = array_merge($array_user,$array_soc,$array_thirdparty,$array_objet,$array_other,$array_thirdparty_contact); complete_substitutions_array($tmparray, $outputlangs, $object); // Call the ODTSubstitution hook From c9c375f3b8777e5c9ce2932eaaf627901fe95516 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 23 Jul 2017 10:29:45 +0200 Subject: [PATCH 009/183] 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 010/183] 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 011/183] 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 012/183] 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 013/183] 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 d09ca6f3da0c621820dc3f8374d12bdf65a6f461 Mon Sep 17 00:00:00 2001 From: TuxGasy Date: Wed, 26 Jul 2017 11:41:12 +0200 Subject: [PATCH 014/183] Move all docker files into build/docker --- .dockerignore | 16 -------------- build/docker/.dockerignore | 3 +++ Dockerfile => build/docker/Dockerfile | 0 build/docker/README.md | 21 +++++++++++++++++++ .../docker/docker-compose.yml | 10 +-------- docker-run.sh => build/docker/docker-run.sh | 0 6 files changed, 25 insertions(+), 25 deletions(-) delete mode 100644 .dockerignore create mode 100644 build/docker/.dockerignore rename Dockerfile => build/docker/Dockerfile (100%) create mode 100644 build/docker/README.md rename docker-compose.yml => build/docker/docker-compose.yml (59%) rename docker-run.sh => build/docker/docker-run.sh (100%) diff --git a/.dockerignore b/.dockerignore deleted file mode 100644 index e5908c26ac0..00000000000 --- a/.dockerignore +++ /dev/null @@ -1,16 +0,0 @@ -build -build.xml -ChangeLog -composer.json -CONTRIBUTING.md -COPYING -COPYRIGHT -dev -doc -Dockerfile -INSTALL -README-FR.md -README.md -robots.txt -scripts -test \ No newline at end of file diff --git a/build/docker/.dockerignore b/build/docker/.dockerignore new file mode 100644 index 00000000000..e345920fb8c --- /dev/null +++ b/build/docker/.dockerignore @@ -0,0 +1,3 @@ +Dockerfile +README.md +docker-compose.yml diff --git a/Dockerfile b/build/docker/Dockerfile similarity index 100% rename from Dockerfile rename to build/docker/Dockerfile diff --git a/build/docker/README.md b/build/docker/README.md new file mode 100644 index 00000000000..113c03d21b5 --- /dev/null +++ b/build/docker/README.md @@ -0,0 +1,21 @@ +# How to use it ? + +The docker-compose.yml file is used to build and run Dolibarr in the current workspace. + +Before build/run, define the variable HOST_USER_ID as following: + + export HOST_USER_ID=$(id -u) + +And then, you can run : + + docker-compose up + +This will run 3 container Docker : Dolibarr, MariaDB and PhpMyAdmin. + +The URL to go to the Dolibarr is : + + http://0.0.0.0 + +The URL to go to PhpMyAdmin is (login/password is root/root) : + + http://0.0.0.0:8080 diff --git a/docker-compose.yml b/build/docker/docker-compose.yml similarity index 59% rename from docker-compose.yml rename to build/docker/docker-compose.yml index 2f0b5536d4f..a2017335197 100644 --- a/docker-compose.yml +++ b/build/docker/docker-compose.yml @@ -1,11 +1,3 @@ -# This docker-compose.yml file is used to build and run Dolibarr -# in the current workspace -# -# Before build/run, define the variable HOST_USER_ID as following: -# $ export HOST_USER_ID=$(id -u) -# And then, you can run : -# $ docker-compose up - mariadb: image: mariadb:latest environment: @@ -26,7 +18,7 @@ web: environment: HOST_USER_ID: $HOST_USER_ID volumes: - - ./htdocs:/var/www/html + - ../../htdocs:/var/www/html links: - mariadb ports: diff --git a/docker-run.sh b/build/docker/docker-run.sh similarity index 100% rename from docker-run.sh rename to build/docker/docker-run.sh From 8451ba1f149b79fe97e3db7b39fa60f6ee3fddb1 Mon Sep 17 00:00:00 2001 From: atm-quentin Date: Wed, 26 Jul 2017 14:43:10 +0200 Subject: [PATCH 015/183] 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 016/183] 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 017/183] 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 677d50df5ba788f89895b59a0143d610b1fba560 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio Date: Thu, 27 Jul 2017 17:11:15 +0200 Subject: [PATCH 018/183] NEW: add 'formObjectOptions' hook to the form setting the product selling price --- htdocs/product/price.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/product/price.php b/htdocs/product/price.php index 2b5617c601d..54138d099a2 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -1171,6 +1171,9 @@ if ($action == 'edit_price' && $object->getRights()->creer) } print ''; print ''; + + $parameters=array('colspan' => 2); + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook print ''; From f5718106a66d6497c9f8357caccc9534a35d9329 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Fri, 28 Jul 2017 09:45:23 +0200 Subject: [PATCH 019/183] 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 ded6b40489e6755c93816a89159c07324280cba3 Mon Sep 17 00:00:00 2001 From: GUERRIER Kevin Date: Sat, 29 Jul 2017 14:21:58 +0200 Subject: [PATCH 020/183] Add possibility to propose last num releve in conciliation --- htdocs/admin/bank.php | 366 +++++++++++++++++------------ htdocs/compta/bank/bankentries.php | 12 +- htdocs/langs/en_GB/banks.lang | 2 + htdocs/langs/fr_FR/banks.lang | 3 + 4 files changed, 231 insertions(+), 152 deletions(-) diff --git a/htdocs/admin/bank.php b/htdocs/admin/bank.php index afe60acff2e..c8162c5229f 100644 --- a/htdocs/admin/bank.php +++ b/htdocs/admin/bank.php @@ -1,4 +1,5 @@ * Copyright (C) 2010-2016 Juanjo Menent * Copyright (C) 2013-2014 Philippe Grand @@ -21,15 +22,14 @@ /** * \file htdocs/admin/bank.php - * \ingroup bank - * \brief Page to setup the bank module + * \ingroup bank + * \brief Page to setup the bank module */ - require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; -require_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/bank.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php'; +require_once DOL_DOCUMENT_ROOT . '/societe/class/companybankaccount.class.php'; $langs->load("admin"); $langs->load("companies"); @@ -38,12 +38,12 @@ $langs->load("other"); $langs->load("banks"); if (!$user->admin) - accessforbidden(); + accessforbidden(); -$action = GETPOST('action','alpha'); -$value = GETPOST('value','alpha'); -$label = GETPOST('label','alpha'); -$scandir = GETPOST('scandir','alpha'); +$action = GETPOST('action', 'alpha'); +$value = GETPOST('value', 'alpha'); +$label = GETPOST('label', 'alpha'); +$scandir = GETPOST('scandir', 'alpha'); $type = 'bankaccount'; @@ -52,100 +52,109 @@ $type = 'bankaccount'; */ //Order display of bank account -if ($action == 'setbankorder') -{ - if (dolibarr_set_const($db, "BANK_SHOW_ORDER_OPTION",GETPOST('value','alpha'),'chaine',0,'',$conf->entity) > 0) - { - header("Location: ".$_SERVER["PHP_SELF"]); - exit; - } - else - { - dol_print_error($db); - } +if ($action == 'setbankorder') { + if (dolibarr_set_const($db, "BANK_SHOW_ORDER_OPTION", + GETPOST('value', 'alpha'), 'chaine', 0, '', $conf->entity) > 0) { + header("Location: " . $_SERVER["PHP_SELF"]); + exit; + } + else { + dol_print_error($db); + } +} + +//Auto report last num releve on conciliate +if ($action == 'setreportlastnumreleve') { + if (dolibarr_set_const($db, "BANK_REPORT_LAST_NUM_RELEVE", 1, 'chaine', 0, + '', $conf->entity) > 0) { + header("Location: " . $_SERVER["PHP_SELF"]); + exit; + } + else { + dol_print_error($db); + } +} +elseif ($action == 'unsetreportlastnumreleve') { + if (dolibarr_set_const($db, "BANK_REPORT_LAST_NUM_RELEVE", 0, 'chaine', 0, + '', $conf->entity) > 0) { + header("Location: " . $_SERVER["PHP_SELF"]); + exit; + } + else { + dol_print_error($db); + } } -if ($action == 'specimen') -{ - $modele=GETPOST('module','alpha'); - - if ($modele == 'sepamandate') - { +if ($action == 'specimen') { + $modele = GETPOST('module', 'alpha'); + + if ($modele == 'sepamandate') { $object = new CompanyBankAccount($db); } - else - { + else { $object = new Account($db); } $object->initAsSpecimen(); - + // Search template files - $file=''; $classname=''; $filefound=0; - $dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']); - foreach($dirmodels as $reldir) - { - $file=dol_buildpath($reldir."core/modules/bank/doc/pdf_".$modele.".modules.php",0); - if (file_exists($file)) - { - $filefound=1; - $classname = "pdf_".$modele; + $file = ''; + $classname = ''; + $filefound = 0; + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + foreach ($dirmodels as $reldir) { + $file = dol_buildpath($reldir . "core/modules/bank/doc/pdf_" . $modele . ".modules.php", + 0); + if (file_exists($file)) { + $filefound = 1; + $classname = "pdf_" . $modele; break; } } - - if ($filefound) - { + + if ($filefound) { require_once $file; - + $module = new $classname($db); - - if ($module->write_file($object,$langs) > 0) - { - header("Location: ".DOL_URL_ROOT."/document.php?modulepart=bank&file=SPECIMEN.pdf"); + + if ($module->write_file($object, $langs) > 0) { + header("Location: " . DOL_URL_ROOT . "/document.php?modulepart=bank&file=SPECIMEN.pdf"); return; } - else - { + else { setEventMessages($module->error, null, 'errors'); dol_syslog($module->error, LOG_ERR); } } - else - { + else { setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); } } // Activate a model -if ($action == 'set') -{ - $ret = addDocumentModel($value, $type, $label, $scandir); +if ($action == 'set') { + $ret = addDocumentModel($value, $type, $label, $scandir); } - -else if ($action == 'del') -{ - $ret = delDocumentModel($value, $type); - if ($ret > 0) - { - if ($conf->global->BANKADDON_PDF == "$value") dolibarr_del_const($db, 'BANKADDON_PDF',$conf->entity); - } +else if ($action == 'del') { + $ret = delDocumentModel($value, $type); + if ($ret > 0) { + if ($conf->global->BANKADDON_PDF == "$value") + dolibarr_del_const($db, 'BANKADDON_PDF', $conf->entity); + } } // Set default model -else if ($action == 'setdoc') -{ - if (dolibarr_set_const($db, "BANKADDON_PDF",$value,'chaine',0,'',$conf->entity)) - { +else if ($action == 'setdoc') { + if (dolibarr_set_const($db, "BANKADDON_PDF", $value, 'chaine', 0, '', + $conf->entity)) { // The constant that was read before the new set // We therefore requires a variable to have a coherent view $conf->global->BANKADDON_PDF = $value; } - + // On active le modele $ret = delDocumentModel($value, $type); - if ($ret > 0) - { + if ($ret > 0) { $ret = addDocumentModel($value, $type, $label, $scandir); } } @@ -156,80 +165,78 @@ else if ($action == 'setdoc') * view */ -$form=new Form($db); +$form = new Form($db); -$dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']); +$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); -llxHeader("",$langs->trans("BankSetupModule")); +llxHeader("", $langs->trans("BankSetupModule")); -$linkback=''.$langs->trans("BackToModuleList").''; -print load_fiche_titre($langs->trans("BankSetupModule"),$linkback,'title_setup'); +$linkback = '' . $langs->trans("BackToModuleList") . ''; +print load_fiche_titre($langs->trans("BankSetupModule"), $linkback, + 'title_setup'); $head = bank_admin_prepare_head(null); dol_fiche_head($head, 'general', $langs->trans("BankSetupModule"), -1, 'account'); -$var=true; +$var = true; -$var=! $var; +$var = !$var; //Show bank account order print load_fiche_titre($langs->trans("BankOrderShow"), '', ''); print ''; print ''; -print ''; -print ''; -print ''; -print ''; +print ''; +print ''; +print ''; +print ''; print ''; print "\n"; -$bankorder[0][0]=$langs->trans("BankOrderGlobal"); -$bankorder[0][1]=$langs->trans("BankOrderGlobalDesc"); -$bankorder[0][2]='BankCode DeskCode BankAccountNumber BankAccountNumberKey'; -$bankorder[1][0]=$langs->trans("BankOrderES"); -$bankorder[1][1]=$langs->trans("BankOrderESDesc"); -$bankorder[1][2]='BankCode DeskCode BankAccountNumberKey BankAccountNumber'; +$bankorder[0][0] = $langs->trans("BankOrderGlobal"); +$bankorder[0][1] = $langs->trans("BankOrderGlobalDesc"); +$bankorder[0][2] = 'BankCode DeskCode BankAccountNumber BankAccountNumberKey'; +$bankorder[1][0] = $langs->trans("BankOrderES"); +$bankorder[1][1] = $langs->trans("BankOrderESDesc"); +$bankorder[1][2] = 'BankCode DeskCode BankAccountNumberKey BankAccountNumber'; $var = true; -$i=0; +$i = 0; -$nbofbank=count($bankorder); -while ($i < $nbofbank) -{ - $var = !$var; +$nbofbank = count($bankorder); +while ($i < $nbofbank) { + $var = !$var; - print ''; - print ''; - print '\n"; + print ''; + print ''; + print '\n"; - if ($conf->global->BANK_SHOW_ORDER_OPTION == $i) - { - print ''; - } - else - { - print ''; - } - print ''; - print ''."\n"; - $i++; + if ($conf->global->BANK_SHOW_ORDER_OPTION == $i) { + print ''; + } + else { + print ''; + } + print ''; + print '' . "\n"; + $i++; } -print '
'.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("Example").''.$langs->trans("Status").'' . $langs->trans("Name") . '' . $langs->trans("Description") . '' . $langs->trans("Example") . '' . $langs->trans("Status") . ' 
'.$bankorder[$i][0]."\n"; - print $bankorder[$i][1]; - print ''; - $tmparray=explode(' ',$bankorder[$i][2]); - foreach($tmparray as $key => $val) - { - if ($key > 0) print ', '; - print $langs->trans($val); - } - print "
' . $bankorder[$i][0] . "\n"; + print $bankorder[$i][1]; + print ''; + $tmparray = explode(' ', $bankorder[$i][2]); + foreach ($tmparray as $key => $val) { + if ($key > 0) + print ', '; + print $langs->trans($val); + } + print "'; - print img_picto($langs->trans("Activated"),'on'); - print ''; - print img_picto($langs->trans("Disabled"),'off'); - print ' 
'; + print img_picto($langs->trans("Activated"), 'on'); + print ''; + print img_picto($langs->trans("Disabled"), 'off'); + print ' 
'."\n"; +print '' . "\n"; print '

'; @@ -257,7 +264,8 @@ if ($resql) { array_push($def, $array[0]); $i ++; } -} else { +} +else { dol_print_error($db); } @@ -273,11 +281,10 @@ print "\n"; clearstatcache(); -foreach ($dirmodels as $reldir) -{ +foreach ($dirmodels as $reldir) { foreach (array('', '/doc') as $valdir) { $dir = dol_buildpath($reldir . "core/modules/bank" . $valdir); - + if (is_dir($dir)) { $handle = opendir($dir); if (is_resource($handle)) { @@ -286,23 +293,26 @@ foreach ($dirmodels as $reldir) } closedir($handle); arsort($filelist); - + foreach ($filelist as $file) { - if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) { - + if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', + $file)) { + if (file_exists($dir . '/' . $file)) { $name = substr($file, 4, dol_strlen($file) - 16); $classname = substr($file, 0, dol_strlen($file) - 12); - + require_once $dir . '/' . $file; $module = new $classname($db); - + $modulequalified = 1; - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL + < 2) $modulequalified = 0; - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL + < 1) $modulequalified = 0; - + if ($modulequalified) { print ''; print(empty($module->name) ? $name : $module->name); @@ -312,29 +322,35 @@ foreach ($dirmodels as $reldir) else print $module->description; print ''; - + // Active if (in_array($name, $def)) { print '' . "\n"; print ''; - print img_picto($langs->trans("Enabled"), 'switch_on'); + print img_picto($langs->trans("Enabled"), + 'switch_on'); print ''; print ''; - } else { + } + else { print '' . "\n"; - print '' . img_picto($langs->trans("Disabled"), 'switch_off') . ''; + print '' . img_picto($langs->trans("Disabled"), + 'switch_off') . ''; print ""; } - + // Default print ''; if ($conf->global->BANKADDON_PDF == $name) { - print img_picto($langs->trans("Default"), 'on'); - } else { - print '' . img_picto($langs->trans("Disabled"), 'off') . ''; + print img_picto($langs->trans("Default"), + 'on'); + } + else { + print '' . img_picto($langs->trans("Disabled"), + 'off') . ''; } print ''; - + // Info $htmltooltip = '' . $langs->trans("Name") . ': ' . $module->name; $htmltooltip .= '
' . $langs->trans("Type") . ': ' . ($module->type ? $module->type : $langs->trans("Unknown")); @@ -342,27 +358,33 @@ foreach ($dirmodels as $reldir) $htmltooltip .= '
' . $langs->trans("Width") . '/' . $langs->trans("Height") . ': ' . $module->page_largeur . '/' . $module->page_hauteur; } $htmltooltip .= '

' . $langs->trans("FeaturesSupported") . ':'; - $htmltooltip .= '
' . $langs->trans("Logo") . ': ' . yn($module->option_logo, 1, 1); + $htmltooltip .= '
' . $langs->trans("Logo") . ': ' . yn($module->option_logo, + 1, 1); //$htmltooltip .= '
' . $langs->trans("PaymentMode") . ': ' . yn($module->option_modereg, 1, 1); //$htmltooltip .= '
' . $langs->trans("PaymentConditions") . ': ' . yn($module->option_condreg, 1, 1); - $htmltooltip .= '
' . $langs->trans("MultiLanguage") . ': ' . yn($module->option_multilang, 1, 1); + $htmltooltip .= '
' . $langs->trans("MultiLanguage") . ': ' . yn($module->option_multilang, + 1, 1); // $htmltooltip.='
'.$langs->trans("Discounts").': '.yn($module->option_escompte,1,1); // $htmltooltip.='
'.$langs->trans("CreditNote").': '.yn($module->option_credit_note,1,1); //$htmltooltip .= '
' . $langs->trans("WatermarkOnDraftOrders") . ': ' . yn($module->option_draft_watermark, 1, 1); - + print ''; - print $form->textwithpicto('', $htmltooltip, 1, 0); + print $form->textwithpicto('', $htmltooltip, 1, + 0); print ''; - + // Preview print ''; if ($module->type == 'pdf') { - print '' . img_object($langs->trans("Preview"), 'bill') . ''; - } else { - print img_object($langs->trans("PreviewNotAvailable"), 'generic'); + print '' . img_object($langs->trans("Preview"), + 'bill') . ''; + } + else { + print img_object($langs->trans("PreviewNotAvailable"), + 'generic'); } print ''; - + print "\n"; } } @@ -372,9 +394,51 @@ foreach ($dirmodels as $reldir) } } } +print ''; //} + +print '

'; + + +/* + * Document templates generators + */ +//if (! empty($conf->global->MAIN_FEATURES_LEVEL)) +//{ +print load_fiche_titre($langs->trans("BankAccountReleveModule"), '', ''); + + +print "\n"; +print "\n"; +print ''; +print ''; +print '\n"; +print "\n"; + +print ''; +// Active +if ($conf->global->BANK_REPORT_LAST_NUM_RELEVE) { + print ''; +} +else { + print '"; +} + +print "\n"; +print '
' . $langs->trans("Name") . '' . $langs->trans("Description") . '' . $langs->trans("Status") . "
'; +print $langs->trans('AccountStatement'); +print "\n"; +print $langs->trans('AutoReportLastAccountStatement'); +print '' . "\n"; + print ''; + print img_picto($langs->trans("Enabled"), 'switch_on'); + print ''; + print '' . "\n"; + print '' . img_picto($langs->trans("Disabled"), + 'switch_off') . ''; + print "
'; dol_fiche_end(); llxFooter(); diff --git a/htdocs/compta/bank/bankentries.php b/htdocs/compta/bank/bankentries.php index a19ccbb6b7c..42c295b3600 100644 --- a/htdocs/compta/bank/bankentries.php +++ b/htdocs/compta/bank/bankentries.php @@ -605,7 +605,7 @@ if ($resql) // print ''; print '
'; print ''.$langs->trans("InputReceiptNumber").': '; - print ''; // The only default value is value we just entered + print ''; // The only default value is value we just entered print '
'; if ($options) { print $langs->trans("EventualyAddCategory").': '; @@ -649,6 +649,16 @@ if ($resql) { dol_print_error($db); } + /** + * Using BANK_REPORT_LAST_NUM_RELEVE to automatically report last num (or not) + */ + if ($conf->global->BANK_REPORT_LAST_NUM_RELEVE == 1) { + print ' + + '; + } print '

'; // print ''; } diff --git a/htdocs/langs/en_GB/banks.lang b/htdocs/langs/en_GB/banks.lang index 6bc449c5864..71e43f01f8e 100644 --- a/htdocs/langs/en_GB/banks.lang +++ b/htdocs/langs/en_GB/banks.lang @@ -18,3 +18,5 @@ RejectCheck=Cheque returned RejectCheckDate=Date the cheque was returned CheckRejected=Cheque returned CheckRejectedAndInvoicesReopened=Cheque returned and invoices reopened +AutoReportLastAccountStatement=Use automatically last account statement to reconcile +BankAccountReleveModule=Bank Statement \ No newline at end of file diff --git a/htdocs/langs/fr_FR/banks.lang b/htdocs/langs/fr_FR/banks.lang index c28a15a6e16..bf481e5c8e4 100644 --- a/htdocs/langs/fr_FR/banks.lang +++ b/htdocs/langs/fr_FR/banks.lang @@ -38,6 +38,9 @@ AccountStatement=Relevé AccountStatementShort=Relevé AccountStatements=Relevés LastAccountStatements=Derniers relevés bancaires +AutoReportLastAccountStatement=Proposer automatiquement le dernier relevé bancaire rapproché +BankAccountReleveModule=Rapprochement relevés bancaires +Conciliated=Rapproché IOMonthlyReporting=Rapport mensuel E/S BankAccountDomiciliation=Domiciliation du compte BankAccountCountry=Pays du compte From b6b3ab3f1bf062bf957518ff779cec822f29cc14 Mon Sep 17 00:00:00 2001 From: GUERRIER Kevin Date: Sat, 29 Jul 2017 15:07:27 +0200 Subject: [PATCH 021/183] NEW Add Next/Previous button on operation date of bank line Operation date has to be frequently updated because some bank change them in many case. With this feature, this value can be updated simply like the value date. --- htdocs/compta/bank/bankentries.php | 11 +++- htdocs/compta/bank/class/account.class.php | 61 ++++++++++++++++++++++ htdocs/compta/bank/ligne.php | 23 ++++++-- htdocs/core/ajax/bankconciliate.php | 24 +++++++++ 4 files changed, 114 insertions(+), 5 deletions(-) diff --git a/htdocs/compta/bank/bankentries.php b/htdocs/compta/bank/bankentries.php index 42c295b3600..559e16627f8 100644 --- a/htdocs/compta/bank/bankentries.php +++ b/htdocs/compta/bank/bankentries.php @@ -1127,7 +1127,16 @@ if ($resql) // Date ope if (! empty($arrayfields['b.dateo']['checked'])) { - print ''.dol_print_date($db->jdate($objp->do),"day")."\n"; + print ''; + print ''.dol_print_date($db->jdate($objp->do),"day").""; + print ' '; + print ''; + print ''; + print img_edit_remove() . " "; + print ''; + print img_edit_add() .""; + print ''; + print "\n"; if (! $i) $totalarray['nbfield']++; } diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 08631abec79..47c3e5122ff 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -1959,6 +1959,67 @@ class AccountLine extends CommonObject } + /** + * Increase/decrease operation date of a rowid + * + * @param int $rowid Id of line + * @param int $sign 1 or -1 + * @return int >0 if OK, 0 if KO + */ + function dateo_change($rowid,$sign=1) + { + $sql = "SELECT dateo FROM ".MAIN_DB_PREFIX."bank WHERE rowid = ".$rowid; + $resql = $this->db->query($sql); + if ($resql) + { + $obj=$this->db->fetch_object($resql); + $newdate=$this->db->jdate($obj->dateo)+(3600*24*$sign); + + $sql = "UPDATE ".MAIN_DB_PREFIX."bank SET"; + $sql.= " dateo = '".$this->db->idate($newdate)."'"; + $sql.= " WHERE rowid = ".$rowid; + + $result = $this->db->query($sql); + if ($result) + { + if ($this->db->affected_rows($result)) + { + return 1; + } + } + else + { + dol_print_error($this->db); + return 0; + } + } + else dol_print_error($this->db); + return 0; + } + + /** + * Increase operation date of a rowid + * + * @param int $id Id of line to change + * @return int >0 if OK, 0 if KO + */ + function dateo_next($id) + { + return $this->dateo_change($id,1); + } + + /** + * Decrease operation date of a rowid + * + * @param int $id Id of line to change + * @return int >0 if OK, 0 if KO + */ + function dateo_previous($id) + { + return $this->dateo_change($id,-1); + } + + /** * Load miscellaneous information for tab "Info" * diff --git a/htdocs/compta/bank/ligne.php b/htdocs/compta/bank/ligne.php index 99362167a07..525b7a72e12 100644 --- a/htdocs/compta/bank/ligne.php +++ b/htdocs/compta/bank/ligne.php @@ -71,13 +71,20 @@ if ($cancel) } } -if ($user->rights->banque->consolidate && $action == 'dvnext') + +if ($user->rights->banque->consolidate && $action == 'donext') +{ + $al = new AccountLine($db); + $al->dateo_next($_GET["rowid"]); +}elseif ($user->rights->banque->consolidate && $action == 'doprev') +{ + $al = new AccountLine($db); + $al->dateo_previous($_GET["rowid"]); +}elseif ($user->rights->banque->consolidate && $action == 'dvnext') { $al = new AccountLine($db); $al->datev_next($_GET["rowid"]); -} - -if ($user->rights->banque->consolidate && $action == 'dvprev') +}elseif ($user->rights->banque->consolidate && $action == 'dvprev') { $al = new AccountLine($db); $al->datev_previous($_GET["rowid"]); @@ -479,6 +486,14 @@ if ($result) { print ''; print $form->select_date($db->jdate($objp->do),'dateo','','','','update',1,0,1,$objp->rappro); + if (! $objp->rappro) + { + print '   '; + print ''; + print img_edit_remove() . " "; + print ''; + print img_edit_add() .""; + } print ''; } else diff --git a/htdocs/core/ajax/bankconciliate.php b/htdocs/core/ajax/bankconciliate.php index 65620c5429c..e5bfb674e8f 100644 --- a/htdocs/core/ajax/bankconciliate.php +++ b/htdocs/core/ajax/bankconciliate.php @@ -71,3 +71,27 @@ if (($user->rights->banque->modifier || $user->rights->banque->consolidate) && $ exit; } +if (($user->rights->banque->modifier || $user->rights->banque->consolidate) && $action == 'donext') +{ + // Increase date + $al = new AccountLine($db); + $al->dateo_next(GETPOST('rowid','int')); + $al->fetch(GETPOST('rowid','int')); + + print ''.dol_print_date($db->jdate($al->dateo),"day").''; + + exit; +} + +if (($user->rights->banque->modifier || $user->rights->banque->consolidate) && $action == 'doprev') +{ + // Decrease date + $al =new AccountLine($db); + $al->dateo_previous(GETPOST('rowid','int')); + $al->fetch(GETPOST('rowid','int')); + + print ''.dol_print_date($db->jdate($al->dateo),"day").''; + + exit; +} + From eb27f8cfe863a33bf9d8ac26a517a2c8194997ff Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 31 Jul 2017 02:18:33 +0200 Subject: [PATCH 022/183] Fix css --- htdocs/index.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/index.php b/htdocs/index.php index 9b190ac1e2b..f76526d23ea 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -118,7 +118,7 @@ $langs->load("contracts"); if (empty($user->societe_id)) { $boxstat.='
'; - $boxstat.=''; + $boxstat.='
'; $boxstat.=''; $boxstat.=''; $boxstat.=''; @@ -541,7 +541,7 @@ if ($showweather) $boxwork.=''; } -$boxwork.=''; $i++; } - print '
'.$langs->trans("DolibarrStateBoard").'
'; +$boxwork.='
'; // Show dashboard $nbworkboardempty=0; From cfebbe3cc492ae9468afac73338b8b893ba611e0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 31 Jul 2017 03:16:28 +0200 Subject: [PATCH 023/183] Fix css --- htdocs/comm/action/class/actioncomm.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 70b2acb86b7..84e75e06cbd 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -1194,7 +1194,7 @@ class ActionComm extends CommonObject { $libelle.=(($this->type_code && $libelle!=$langs->transnoentities("Action".$this->type_code) && $langs->transnoentities("Action".$this->type_code)!="Action".$this->type_code)?' ('.$langs->transnoentities("Action".$this->type_code).')':''); } - $result.=$linkstart.img_object(($notooltip?'':$langs->trans("ShowAction").': '.$libelle), ($overwritepicto?$overwritepicto:'action'), ($notooltip?'':'class="classfortooltip"'), 0, 0, $notooltip?0:1).$linkend; + $result.=$linkstart.img_object(($notooltip?'':$langs->trans("ShowAction").': '.$libelle), ($overwritepicto?$overwritepicto:'action'), ($notooltip?'class="valigntextbottom"':'class="classfortooltip valigntextbottom"'), 0, 0, $notooltip?0:1).$linkend; } if ($withpicto==1) $result.=' '; $result.=$linkstart.$libelleshort.$linkend; From 52875c08ff632bb139df86983c0f45aa2c5b540b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 31 Jul 2017 04:24:13 +0200 Subject: [PATCH 024/183] Fix missing translation keys --- htdocs/langs/en_US/agenda.lang | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/htdocs/langs/en_US/agenda.lang b/htdocs/langs/en_US/agenda.lang index 38a40315985..a62db9c7158 100644 --- a/htdocs/langs/en_US/agenda.lang +++ b/htdocs/langs/en_US/agenda.lang @@ -78,6 +78,11 @@ InvoiceDeleted=Invoice deleted PRODUCT_CREATEInDolibarr=Product %s created PRODUCT_MODIFYInDolibarr=Product %s modified PRODUCT_DELETEInDolibarr=Product %s deleted +EXPENSE_REPORT_CREATEInDolibarr=Expense report %s created +EXPENSE_REPORT_VALIDATEInDolibarr=Expense report %s validated +EXPENSE_REPORT_APPROVEInDolibarr=Expense report %s approved +EXPENSE_REPORT_DELETEInDolibarr=Expense report %s deleted +EXPENSE_REPORT_REFUSEDInDolibarr=Expense report %s refused ##### End agenda events ##### AgendaModelModule=Document templates for event DateActionStart=Start date From 800aa4d5b6772bf1f1d9bf3a2e828d3525c748e1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 31 Jul 2017 04:49:54 +0200 Subject: [PATCH 025/183] Fix bad target --- htdocs/core/menus/standard/eldy.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 530be07da39..95d3f41661b 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -807,8 +807,8 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu { $langs->load("bills"); $newmenu->add("/fourn/facture/list.php?leftmenu=suppliers_bills", $langs->trans("BillsSuppliers"),0,$user->rights->fournisseur->facture->lire, '', $mainmenu, 'suppliers_bills'); - $newmenu->add("/fourn/facture/card.php?action=create",$langs->trans("NewBill"),1,$user->rights->fournisseur->facture->creer); - $newmenu->add("/fourn/facture/list.php?leftmenu=suppliers_bills", $langs->trans("List"),1,$user->rights->fournisseur->facture->lire, 'suppliers_bills_list'); + $newmenu->add("/fourn/facture/card.php?action=create",$langs->trans("NewBill"),1,$user->rights->fournisseur->facture->creer, '', $mainmenu, 'suppliers_bills_create'); + $newmenu->add("/fourn/facture/list.php?leftmenu=suppliers_bills", $langs->trans("List"),1,$user->rights->fournisseur->facture->lire, '', $mainmenu, 'suppliers_bills_list'); if ($usemenuhider || empty($leftmenu) || preg_match('/suppliers_bills/', $leftmenu)) { $newmenu->add("/fourn/facture/list.php?leftmenu=suppliers_bills_draft&search_status=0", $langs->trans("BillShortStatusDraft"),2,$user->rights->fournisseur->facture->lire, '', $mainmenu, 'suppliers_bills_draft'); From 2f68d446efc8d943811a47a316b91836374b1124 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 31 Jul 2017 04:52:27 +0200 Subject: [PATCH 026/183] Fix on filter on project list --- htdocs/projet/activity/index.php | 44 +++++++++++++++++--------------- htdocs/projet/index.php | 13 +++++----- htdocs/projet/list.php | 24 ++++++++++------- 3 files changed, 45 insertions(+), 36 deletions(-) diff --git a/htdocs/projet/activity/index.php b/htdocs/projet/activity/index.php index 7bea4bf3213..31cd2c1c350 100644 --- a/htdocs/projet/activity/index.php +++ b/htdocs/projet/activity/index.php @@ -29,7 +29,9 @@ require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; -$mine = $_REQUEST['mode']=='mine' ? 1 : 0; +$search_project_user = GETPOST('search_project_user','int'); +$mine = GETPOST('mode','aZ09')=='mine' ? 1 : 0; +if ($search_project_user == $user->id) $mine = 1; // Security check $socid=0; @@ -98,7 +100,7 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele { $listofsearchfields['search_task']=array('text'=>'Task'); } - + if (count($listofsearchfields)) { print ''; @@ -114,7 +116,7 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele print '
'; + print ''; print ''; print '
'; } @@ -148,7 +150,7 @@ if ( $resql ) while ($row = $db->fetch_object($resql)) { - + print ''; print ''; $projectstatic->id=$row->rowid; @@ -205,7 +207,7 @@ if ( $resql ) while ($row = $db->fetch_object($resql)) { - + print ''; print ''; $projectstatic->id=$row->rowid; @@ -237,14 +239,14 @@ print ""; if ($db->type != 'pgsql') { print '
'; - + // Affichage de la liste des projets de la semaine print ''; print ''; print ''; print ''; print "\n"; - + $sql = "SELECT p.rowid, p.ref, p.title, p.public, SUM(tt.task_duration) as nb"; $sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; $sql.= " , ".MAIN_DB_PREFIX."projet_task as t"; @@ -256,16 +258,16 @@ if ($db->type != 'pgsql') $sql.= " AND task_date >= '".$db->idate(dol_get_first_day($year, $month)).'" AND ..."; $sql.= " AND p.rowid in (".$projectsListId.")"; $sql.= " GROUP BY p.rowid, p.ref, p.title"; - + $resql = $db->query($sql); if ( $resql ) { $total = 0; $var=true; - + while ($row = $db->fetch_object($resql)) { - + print ''; print '\n"; $total += $row->nb; } - + $db->free($resql); } else @@ -302,7 +304,7 @@ if (! empty($conf->global->PROJECT_TASK_TIME_MONTH)) print ''; print ''; print "\n"; - + $sql = "SELECT p.rowid, p.ref, p.title, p.public, SUM(tt.task_duration) as nb"; $sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; $sql.= ", ".MAIN_DB_PREFIX."projet_task as t"; @@ -314,12 +316,12 @@ if (! empty($conf->global->PROJECT_TASK_TIME_MONTH)) $sql.= " AND task_date BETWEEN '".$db->idate(dol_get_first_day($year, $month))."' AND '".$db->idate(dol_get_last_day($year, $month))."'"; $sql.= " AND p.rowid in (".$projectsListId.")"; $sql.= " GROUP BY p.rowid, p.ref, p.title, p.public"; - + $resql = $db->query($sql); if ( $resql ) { $var=false; - + while ($row = $db->fetch_object($resql)) { print ''; @@ -331,7 +333,7 @@ if (! empty($conf->global->PROJECT_TASK_TIME_MONTH)) print ''; print ''; print "\n"; - + } $db->free($resql); } @@ -383,7 +385,7 @@ if (! empty($conf->global->PROJECT_TASK_TIME_YEAR)) print ''; print ''; print "\n"; - + } $db->free($resql); } @@ -430,12 +432,12 @@ if (empty($conf->global->PROJECT_HIDE_TASKS) && ! empty($conf->global->PROJECT_S } else dol_print_error($db); if (count($listoftaskcontacttype) == 0) $listoftaskcontacttype[0]='0'; // To avoid sql syntax error if not found - + // Tasks for all resources of all opened projects and time spent for each task/resource // This list can be very long, so we don't show it by default on task area. We prefer to use the list page. // Add constant PROJECT_SHOW_TASK_LIST_ON_PROJECT_AREA to show this list - + $max = (empty($conf->global->PROJECT_LIMIT_TASK_PROJECT_AREA)?1000:$conf->global->PROJECT_LIMIT_TASK_PROJECT_AREA); $sql = "SELECT p.ref, p.title, p.rowid as projectid, p.fk_statut as status, p.fk_opp_status as opp_status, p.public, p.dateo as projdateo, p.datee as projdatee,"; @@ -489,7 +491,7 @@ if (empty($conf->global->PROJECT_HIDE_TASKS) && ! empty($conf->global->PROJECT_S while ($i < $num && $i < $max) { $obj = $db->fetch_object($resql); - + $username=''; if ($obj->userid && $userstatic->id != $obj->userid) // We have a user and it is not last loaded user @@ -509,7 +511,7 @@ if (empty($conf->global->PROJECT_HIDE_TASKS) && ! empty($conf->global->PROJECT_S $projectstatic->public = $obj->public; $projectstatic->dateo = $db->jdate($obj->projdateo); $projectstatic->datee = $db->jdate($obj->projdatee); - + print $projectstatic->getNomUrl(1,'',0,'','
'); print ''; if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) @@ -536,7 +538,7 @@ if (empty($conf->global->PROJECT_HIDE_TASKS) && ! empty($conf->global->PROJECT_S $taskstatic->datee = $db->jdate($obj->datee); print ''; print ''; print ''; $i++; } - print '
'.$langs->trans("ActivityOnProjectThisWeek").''.$langs->trans("Time").'
'; $projectstatic->id=$row->rowid; @@ -278,7 +280,7 @@ if ($db->type != 'pgsql') print "
'.$langs->trans("ActivityOnProjectThisMonth").': '.dol_print_date($now,"%B %Y").''.$langs->trans("Time").'
'.convertSecondToTime($row->nb, 'allhourmin').'
'.convertSecondToTime($row->nb, 'allhourmin').'
'.dol_print_date($db->jdate($obj->dateo),'day').''.dol_print_date($db->jdate($obj->datee),'day'); - print dol_print_date($obj->date_end,'dayhour'); + print dol_print_date($obj->date_end,'dayhour'); if ($taskstatic->hasDelay()) print img_warning($langs->trans("Late")); print ''; diff --git a/htdocs/projet/index.php b/htdocs/projet/index.php index c7f0181dbf5..7aecd454365 100644 --- a/htdocs/projet/index.php +++ b/htdocs/projet/index.php @@ -33,8 +33,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; $langs->load("projects"); $langs->load("companies"); -$mine = GETPOST('mode','aZ09')=='mine' ? 1 : 0; $search_project_user = GETPOST('search_project_user','int'); +$mine = GETPOST('mode','aZ09')=='mine' ? 1 : 0; +if ($search_project_user == $user->id) $mine = 1; // Security check $socid=0; @@ -122,7 +123,7 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele { $listofsearchfields['search_project']=array('text'=>'Project'); } - + if (count($listofsearchfields)) { print '
'; @@ -138,7 +139,7 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele print '
'; + print ''; print ''; print '
'; } @@ -185,7 +186,7 @@ if ( $resql ) while ($i < $num) { $obj = $db->fetch_object($resql); - + print ''; print ''; if ($obj->socid) @@ -217,9 +218,9 @@ if (! empty($conf->global->PROJECT_SHOW_PROJECT_LIST_ON_PROJECT_AREA)) { // This list can be very long, so we don't show it by default on task area. We prefer to use the list page. // Add constant PROJECT_SHOW_PROJECT_LIST_ON_PROJECT_AREA to show this list - + print '
'; - + print_projecttasks_array($db, $form, $socid, $projectsListId, 0, 1, $listofoppstatus, array()); } diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 9e2971195e3..7ee41fcd024 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -261,8 +261,8 @@ if ($search_project_user > 0) } $sql.= " WHERE p.entity IN (".getEntity('project').')'; if (! $user->rights->projet->all->lire) $sql.= " AND p.rowid IN (".$projectsListId.")"; // public and assigned to, or restricted to company for external users -// No need to check company, as filtering of projects must be done by getProjectsAuthorizedForUser -if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; +// No need to check if company is external user, as filtering of projects must be done by getProjectsAuthorizedForUser +if ($socid > 0) $sql.= " AND (p.fk_soc = ".$socid.")"; if ($search_categ > 0) $sql.= " AND cs.fk_categorie = ".$db->escape($search_categ); if ($search_categ == -2) $sql.= " AND cs.fk_categorie IS NULL"; if ($search_ref) $sql .= natural_search('p.ref', $search_ref); @@ -487,19 +487,25 @@ print ''; if (! empty($arrayfields['p.ref']['checked'])) { print ''; - print ''; + print ''; print ''; } if (! empty($arrayfields['p.title']['checked'])) { print ''; - print ''; + print ''; print ''; } if (! empty($arrayfields['s.nom']['checked'])) { print ''; - print ''; + if ($socid > 0) + { + $tmpthirdparty=new Societe($db); + $tmpthirdparty->fetch($socid); + $search_societe=$tmpthirdparty->nom; + } + print ''; print ''; } // Sale representative @@ -511,8 +517,8 @@ if (! empty($arrayfields['commercial']['checked'])) if (! empty($arrayfields['p.dateo']['checked'])) { print ''; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; - print ''; + if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + print ''; $formother->select_year($search_syear?$search_syear:-1,'search_syear',1, 20, 5); print ''; } @@ -520,8 +526,8 @@ if (! empty($arrayfields['p.dateo']['checked'])) if (! empty($arrayfields['p.datee']['checked'])) { print ''; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; - print ''; + if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + print ''; $formother->select_year($search_eyear?$search_eyear:-1,'search_eyear',1, 20, 5); print ''; } From 612ab65b729c8dc7618f48fd5b548c988bfcfea7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 31 Jul 2017 06:01:05 +0200 Subject: [PATCH 027/183] Fix by adding a MULTICOMPANY_BACKWARD_COMPATIBILITY option. --- ChangeLog | 6 +++++- htdocs/user/class/user.class.php | 30 ++++++++++++++++++++++++------ 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2417a7db682..994902e3c01 100644 --- a/ChangeLog +++ b/ChangeLog @@ -142,8 +142,12 @@ Following changes may create regression for some external modules, but were nece * Removed Societe::set_commnucation_level (was deprecated in 4.0). Was not used. * Removed the trigger file of PAYPAL module that stored data that was not used by Dolibarr. The trigger event still exists, but if an external module need action on it, it must provides itself its trigger file. -* Use $conf->global->MULTICOMPANY_TRANSVERSE_MODE instead $conf->multicompany->transverse_mode +* Use $conf->global->MULTICOMPANY_TRANSVERSE_MODE instead $conf->multicompany->transverse_mode. So, if you set var + $multicompany_transverse_mode to 1 into your conf file, you must remove this line and a new key into + the Home - setup - other admin page. * Use getEntity('xxx') instead getEntity('xxx', 1) and use getEntity('xxx', 0) instead getEntity('xxx') +* Some other change were done in the way we read permission of a user when module multicompany is enabled. You can + retreive the old behavior by adding constant MULTICOMPANY_BACKWARD_COMPATIBILITY to 1. * The hook formObjectOptions was not implemented correctly in previous version. Sometimes, you had to return output content by doing a print into function, sometimes by returning content into "resprint". This has been fixed to follow hook specifications so you must return output into "resprint". diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 577a6389b6f..77ee103db63 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -221,7 +221,7 @@ class User extends CommonObject if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) $sql.= " WHERE u.entity IS NOT NULL"; // multicompany is on in transverse mode or user making fetch is on entity 0, so user is allowed to fetch anywhere into database else - $sql.= " WHERE u.entity IN (0, ".($entity!=''?$entity:$conf->entity).")"; // search in entity provided in parameter + $sql.= " WHERE u.entity IN (0, ".(($entity!='' && $entity >= 0)?$entity:$conf->entity).")"; // search in entity provided in parameter } if ($sid) // permet une recherche du user par son SID ActiveDirectory ou Samba @@ -236,8 +236,8 @@ class User extends CommonObject { $sql.= " AND u.rowid = ".$id; } - $sql.= " ORDER BY u.entity ASC"; // Avoid random result when there is 2 login in 2 different entities - + $sql.= " ORDER BY u.entity ASC"; // Avoid random result when there is 2 login in 2 different entities + $result = $this->db->query($sql); if ($result) { @@ -662,7 +662,14 @@ class User extends CommonObject $sql.= " FROM ".MAIN_DB_PREFIX."user_rights as ur"; $sql.= ", ".MAIN_DB_PREFIX."rights_def as r"; $sql.= " WHERE r.id = ur.fk_id"; - $sql.= " AND ur.entity = ".$conf->entity; + if (! empty($conf->global->MULTICOMPANY_BACKWARD_COMPATIBILITY)) + { + $sql.= " AND r.entity IN (0,".(! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)?"1,":"").$conf->entity.")"; + } + else + { + $sql.= " AND ur.entity = ".$conf->entity; + } $sql.= " AND ur.fk_user= ".$this->id; $sql.= " AND r.perms IS NOT NULL"; if ($moduletag) $sql.= " AND r.module = '".$this->db->escape($moduletag)."'"; @@ -708,8 +715,19 @@ class User extends CommonObject $sql.= " ".MAIN_DB_PREFIX."usergroup_user as gu,"; $sql.= " ".MAIN_DB_PREFIX."rights_def as r"; $sql.= " WHERE r.id = gr.fk_id"; - $sql.= " AND gr.entity = ".$conf->entity; - $sql.= " AND r.entity = ".$conf->entity; + if (! empty($conf->global->MULTICOMPANY_BACKWARD_COMPATIBILITY)) + { + if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { + $sql.= " AND gu.entity IN (0,".$conf->entity.")"; + } else { + $sql.= " AND r.entity = ".$conf->entity; + } + } + else + { + $sql.= " AND gr.entity = ".$conf->entity; + $sql.= " AND r.entity = ".$conf->entity; + } $sql.= " AND gr.fk_usergroup = gu.fk_usergroup"; $sql.= " AND gu.fk_user = ".$this->id; $sql.= " AND r.perms IS NOT NULL"; From 13cbd597adfbab09f8dc4f8c727d585b07a9bd70 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 31 Jul 2017 06:20:32 +0200 Subject: [PATCH 028/183] Fix filter lost --- htdocs/projet/activity/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/projet/activity/index.php b/htdocs/projet/activity/index.php index 31cd2c1c350..8418561aa30 100644 --- a/htdocs/projet/activity/index.php +++ b/htdocs/projet/activity/index.php @@ -75,7 +75,7 @@ $morehtml=''; $morehtml.='
'; $morehtml.=''; $morehtml.=''; From ecb4eebfacb2dae39b43f6cd57ca510170f58f78 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 31 Jul 2017 06:58:55 +0200 Subject: [PATCH 029/183] Fix filter of project in timespent view --- htdocs/langs/en_US/projects.lang | 2 +- htdocs/projet/activity/perday.php | 28 ++++++++++++++++++---------- htdocs/projet/activity/perweek.php | 28 ++++++++++++++++++---------- 3 files changed, 37 insertions(+), 21 deletions(-) diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang index d940555f206..a30768709f9 100644 --- a/htdocs/langs/en_US/projects.lang +++ b/htdocs/langs/en_US/projects.lang @@ -23,7 +23,7 @@ OnlyOpenedProject=Only open projects are visible (projects in draft or closed st ClosedProjectsAreHidden=Closed projects are not visible. TasksPublicDesc=This view presents all projects and tasks you are allowed to read. TasksDesc=This view presents all projects and tasks (your user permissions grant you permission to view everything). -AllTaskVisibleButEditIfYouAreAssigned=All tasks for such project are visible, but you can enter time only for task assigned to you. Assign task to yourself if you need to enter time on it. +AllTaskVisibleButEditIfYouAreAssigned=All tasks for qualified projects are visible, but you can enter time only for task assigned to you. Assign task to yourself if you need to enter time on it. OnlyYourTaskAreVisible=Only tasks assigned to you are visible. Assign task to yourself if it is not visible and you need to enter time on it. ImportDatasetTasks=Tasks of projects ProjectCategories=Project tags/categories diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index 7b1f50bb50c..45d7aa237ad 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -82,13 +82,18 @@ else if ($year && $month && $day) $daytoparse=dol_mktime(0, 0, 0, $month, $day, if (empty($search_usertoprocessid) || $search_usertoprocessid == $user->id) { $usertoprocess=$user; + $search_usertoprocessid=$usertoprocess->id; } -else +elseif (search_usertoprocessid > 0) { $usertoprocess=new User($db); $usertoprocess->fetch($search_usertoprocessid); + $search_usertoprocessid=$usertoprocess->id; +} +else +{ + $usertoprocess=new User($db); } -$search_usertoprocessid=$usertoprocess->id; $object=new Task($db); @@ -305,9 +310,9 @@ $next_month = $next['mon']; $next_day = $next['mday']; $title=$langs->trans("TimeSpent"); -if ($mine) $title=$langs->trans("MyTimeSpent"); +if ($mine || ($usertoprocess->id == $user->id)) $title=$langs->trans("MyTimeSpent"); -$projectsListId = $projectstatic->getProjectsAuthorizedForUser($usertoprocess,0,1); // Return all project i have permission on. I want my tasks and some of my task may be on a public projet that is not my project +$projectsListId = $projectstatic->getProjectsAuthorizedForUser($usertoprocess,(empty($usertoprocess->id)?2:0),1); // Return all project i have permission on. I want my tasks and some of my task may be on a public projet that is not my project if ($id) { @@ -320,7 +325,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. +$tasksarray=$taskstatic->getTasksArray(0, 0, ($project->id?$project->id:0), $socid, 0, $search_project_ref, $onlyopenedproject, $morewherefilter, ($search_usertoprocessid?$search_usertoprocessid:0)); // We want to see all task of opened project i am allowed to see and that match filter, not only my tasks. 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); //var_dump($tasksarray); @@ -362,13 +367,16 @@ dol_fiche_head($head, 'inputperday', '', -1, 'task'); // Show description of content print '
'; -if ($mine) print $langs->trans("MyTasksDesc").($onlyopenedproject?' '.$langs->trans("OnlyOpenedProject"):'').'
'; +if ($mine || ($usertoprocess->id == $user->id)) print $langs->trans("MyTasksDesc").($onlyopenedproject?' '.$langs->trans("OnlyOpenedProject"):'').'
'; else { - if ($user->rights->projet->all->lire && ! $socid) print $langs->trans("ProjectsDesc").($onlyopenedproject?' '.$langs->trans("OnlyOpenedProject"):'').'
'; - else print $langs->trans("ProjectsPublicTaskDesc").($onlyopenedproject?' '.$langs->trans("OnlyOpenedProject"):'').'
'; + if (empty($usertoprocess->id) || $usertoprocess->id < 0) + { + if ($user->rights->projet->all->lire && ! $socid) print $langs->trans("ProjectsDesc").($onlyopenedproject?' '.$langs->trans("OnlyOpenedProject"):'').'
'; + else print $langs->trans("ProjectsPublicTaskDesc").($onlyopenedproject?' '.$langs->trans("OnlyOpenedProject"):'').'
'; + } } -if ($mine) +if ($mine || ($usertoprocess->id == $user->id)) { print $langs->trans("OnlyYourTaskAreVisible").'
'; } @@ -413,7 +421,7 @@ $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.=$form->select_dolusers($search_usertoprocessid?$search_usertoprocessid:$usertoprocess->id, 'search_usertoprocessid', $user->rights->user->user->lire?0:0, null, 0, $includeonly, null, 0, 0, 0, '', 0, '', 'maxwidth200'); $moreforfilter.='
'; if (! empty($moreforfilter)) diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php index 3410ba1d949..b4fcd68a3c9 100644 --- a/htdocs/projet/activity/perweek.php +++ b/htdocs/projet/activity/perweek.php @@ -95,13 +95,18 @@ $lastdaytoshow=dol_time_plus_duree($firstdaytoshow, 7, 'd'); if (empty($search_usertoprocessid) || $search_usertoprocessid == $user->id) { $usertoprocess=$user; + $search_usertoprocessid=$usertoprocess->id; } -else +elseif (search_usertoprocessid > 0) { $usertoprocess=new User($db); $usertoprocess->fetch($search_usertoprocessid); + $search_usertoprocessid=$usertoprocess->id; +} +else +{ + $usertoprocess=new User($db); } -$search_usertoprocessid=$usertoprocess->id; $object=new Task($db); @@ -300,9 +305,9 @@ $taskstatic = new Task($db); $thirdpartystatic = new Societe($db); $title=$langs->trans("TimeSpent"); -if ($mine) $title=$langs->trans("MyTimeSpent"); +if ($mine || $usertoprocess->id == $user->id) $title=$langs->trans("MyTimeSpent"); -$projectsListId = $projectstatic->getProjectsAuthorizedForUser($usertoprocess,0,1); // Return all project i have permission on (assigned to me+public). I want my tasks and some of my task may be on a public projet that is not my project +$projectsListId = $projectstatic->getProjectsAuthorizedForUser($usertoprocess,(empty($usertoprocess->id)?2:0),1); // Return all project i have permission on (assigned to me+public). I want my tasks and some of my task may be on a public projet that is not my project //var_dump($projectsListId); if ($id) { @@ -316,7 +321,7 @@ 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. +$tasksarray=$taskstatic->getTasksArray(0, 0, ($project->id?$project->id:0), $socid, 0, $search_project_ref, $onlyopenedproject, $morewherefilter, ($search_usertoprocessid?$search_usertoprocessid:0)); // We want to see all task of opened project i am allowed to see and that match filter, not only my tasks. 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); //var_dump($tasksarray); @@ -356,13 +361,16 @@ dol_fiche_head($head, 'inputperweek', '', -1, 'task'); // Show description of content print '
'; -if ($mine) print $langs->trans("MyTasksDesc").($onlyopenedproject?' '.$langs->trans("OnlyOpenedProject"):'').'
'; +if ($mine || ($usertoprocess->id == $user->id)) print $langs->trans("MyTasksDesc").($onlyopenedproject?' '.$langs->trans("OnlyOpenedProject"):'').'
'; else { - if ($user->rights->projet->all->lire && ! $socid) print $langs->trans("ProjectsDesc").($onlyopenedproject?' '.$langs->trans("OnlyOpenedProject"):'').'
'; - else print $langs->trans("ProjectsPublicTaskDesc").($onlyopenedproject?' '.$langs->trans("OnlyOpenedProject"):'').'
'; + if (empty($usertoprocess->id) || $usertoprocess->id < 0) + { + if ($user->rights->projet->all->lire && ! $socid) print $langs->trans("ProjectsDesc").($onlyopenedproject?' '.$langs->trans("OnlyOpenedProject"):'').'
'; + else print $langs->trans("ProjectsPublicTaskDesc").($onlyopenedproject?' '.$langs->trans("OnlyOpenedProject"):'').'
'; + } } -if ($mine) +if ($mine || ($usertoprocess->id == $user->id)) { print $langs->trans("OnlyYourTaskAreVisible").'
'; } @@ -408,7 +416,7 @@ $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.=$form->select_dolusers($search_usertoprocessid?$search_usertoprocessid:$usertoprocess->id, 'search_usertoprocessid', $user->rights->user->user->lire?0:0, null, 0, $includeonly, null, 0, 0, 0, '', 0, '', 'maxwidth200'); $moreforfilter.='
'; if (! empty($moreforfilter)) From 53add04a2e6e8a6c777278a1aa97bc01cd775643 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Mon, 31 Jul 2017 10:28:24 +0200 Subject: [PATCH 030/183] fix :add missing hook into product price card --- htdocs/product/price.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/product/price.php b/htdocs/product/price.php index 2b5617c601d..d2ba54e12a2 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -1172,6 +1172,9 @@ if ($action == 'edit_price' && $object->getRights()->creer) print ''; print ''; + $parameters=array('colspan' => 2); + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + print ''; dol_fiche_end(); From 2f9f9ac80d736f252e4f397ab7f55a0eaa836920 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 31 Jul 2017 11:56:20 +0200 Subject: [PATCH 031/183] Fix personal conf was not loaded --- 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 9127395e66e..159742eff1a 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -63,7 +63,7 @@ require_once '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; // Load user to have $user->conf loaded (not done into main because of NOLOGIN constant defined) -if (empty($user->id) && ! empty($_SESSION['dol_login'])) $user->fetch('',$_SESSION['dol_login']); +if (empty($user->id) && ! empty($_SESSION['dol_login'])) $user->fetch('',$_SESSION['dol_login'],'',1); // Define css type diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index db788db3178..267d745b9f3 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -64,7 +64,7 @@ require_once '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; // Load user to have $user->conf loaded (not done into main because of NOLOGIN constant defined) -if (empty($user->id) && ! empty($_SESSION['dol_login'])) $user->fetch('',$_SESSION['dol_login']); +if (empty($user->id) && ! empty($_SESSION['dol_login'])) $user->fetch('',$_SESSION['dol_login'],'',1); // Define css type From 97e694f4d9fcd2666261dd34797b381a5fe7b665 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 31 Jul 2017 12:43:07 +0200 Subject: [PATCH 032/183] Fix look and feel v6 --- htdocs/user/ldap.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/htdocs/user/ldap.php b/htdocs/user/ldap.php index 96c0ac881be..49739fa7c77 100644 --- a/htdocs/user/ldap.php +++ b/htdocs/user/ldap.php @@ -70,12 +70,12 @@ if (empty($reshook)) { $result = $ldap->update($dn, $info, $user, $olddn); - if ($result >= 0) + if ($result >= 0) { setEventMessages($langs->trans("UserSynchronized"), null, 'mesgs'); $db->commit(); - } - else + } + else { setEventMessages($ldap->error, $ldap->errors, 'errors'); $db->rollback(); @@ -104,6 +104,7 @@ if ($user->rights->user->user->lire || $user->admin) { dol_banner_tab($object,'id',$linkback,$user->rights->user->user->lire || $user->admin); +print '
'; print '
'; print ''; @@ -128,7 +129,7 @@ if ($conf->global->LDAP_SERVER_TYPE == "activedirectory") { $userSID = $ldap->getObjectSid($object->login); } - print ''; + print ''; print ''; print "\n"; } @@ -150,6 +151,8 @@ print '
'.$langs->trans("SID").'
'.$langs->trans("SID").''.$userSID.'
'; print '
'; +dol_fiche_end(); + /* * Barre d'actions */ From 7ba5cf59581e316fd595df8ddb74dbf8c14f7c5b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 31 Jul 2017 13:48:00 +0200 Subject: [PATCH 033/183] Debug view of services lines --- htdocs/contrat/card.php | 18 ++++---- htdocs/contrat/class/contrat.class.php | 10 ++--- htdocs/core/boxes/box_services_contracts.php | 44 ++++++++++++++++++-- 3 files changed, 55 insertions(+), 17 deletions(-) diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index c13571dd6cb..90ec4c7edba 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -1482,7 +1482,7 @@ else $sql.= " cd.date_fin_validite as date_fin, cd.date_cloture as date_fin_reelle,"; $sql.= " cd.commentaire as comment, cd.fk_product_fournisseur_price as fk_fournprice, cd.buy_price_ht as pa_ht,"; $sql.= " cd.fk_unit,"; - $sql.= " p.rowid as pid, p.ref as pref, p.label as label, p.fk_product_type as ptype, p.entity as pentity"; + $sql.= " p.rowid as pid, p.ref as pref, p.label as plabel, p.fk_product_type as ptype, p.entity as pentity"; $sql.= " FROM ".MAIN_DB_PREFIX."contratdet as cd"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid"; $sql.= " WHERE cd.rowid = ".$object->lines[$cursorline-1]->id; @@ -1513,7 +1513,7 @@ else if ($action != 'editline' || GETPOST('rowid') != $objp->rowid) { print ''; - // Libelle + // Label if ($objp->fk_product > 0) { print ''; @@ -1521,19 +1521,21 @@ else $productstatic->type=$objp->ptype; $productstatic->ref=$objp->pref; $productstatic->entity=$objp->pentity; - $text = $productstatic->getNomUrl(1,'',20); - if ($objp->label) + $productstatic->label=$objp->plabel; + $text = $productstatic->getNomUrl(1,'',20); + if ($objp->plabel) { $text .= ' - '; - $productstatic->ref=$objp->label; - $text .= $productstatic->getNomUrl(0,'',16); + //$productstatic->ref=$objp->label; + //$text .= $productstatic->getNomUrl(0,'',16); + $text .= $objp->plabel; } $description = $objp->description; // Add description in form if (! empty($conf->global->PRODUIT_DESC_IN_FORM)) { - $text .= (! empty($objp->description) && $objp->description!=$objp->product_label)?'
'.dol_htmlentitiesbr($objp->description):''; + $text .= (! empty($objp->description) && $objp->description!=$objp->plabel)?'
'.dol_htmlentitiesbr($objp->description):''; $description = ''; // Already added into main visible desc } @@ -1543,7 +1545,7 @@ else } else { - print ''.dol_htmlentitiesbr($objp->description)."\n"; + print ''.img_object($langs->trans("ShowProductOrService"), ($objp->product_type ? 'service' : 'product')).' '.dol_htmlentitiesbr($objp->description)."\n"; } // TVA print ''; diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 0c3ee14666a..bf31ef4070c 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -1278,7 +1278,7 @@ class Contrat extends CommonObject //// End call triggers } } - + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options)>0) // For avoid conflicts if trigger used { $result=$this->insertExtraFields(); @@ -1831,13 +1831,13 @@ class Contrat extends CommonObject $text.=':     '; } $text.=($mode == 7?'
':''); - $text.=($mode != 7 || $this->nbofserviceswait > 0) ? $this->nbofserviceswait.' '.$line->LibStatut(0,3).(($this->nbofservicesopened || $this->nbofservicesexpired || $this->nbofservicesclosed)?'   ':'') : ''; + $text.=($mode != 7 || $this->nbofserviceswait > 0) ? ($this->nbofserviceswait.$line->LibStatut(0,3)).(($mode != 7 || $this->nbofservicesopened || $this->nbofservicesexpired || $this->nbofservicesclosed)?'   ':'') : ''; $text.=($mode == 7?'
':''); - $text.=($mode != 7 || $this->nbofservicesopened > 0) ? $this->nbofservicesopened.' '.$line->LibStatut(4,3,0).(($this->nbofservicesexpired || $this->nbofservicesclosed)?'   ':'') : ''; + $text.=($mode != 7 || $this->nbofservicesopened > 0) ? ($this->nbofservicesopened.$line->LibStatut(4,3,0)).(($mode != 7 || $this->nbofservicesexpired || $this->nbofservicesclosed)?'   ':'') : ''; $text.=($mode == 7?'
':''); - $text.=($mode != 7 || $this->nbofservicesexpired > 0) ? $this->nbofservicesexpired.' '.$line->LibStatut(4,3,1).(($this->nbofservicesclosed)?'   ':'') : ''; + $text.=($mode != 7 || $this->nbofservicesexpired > 0) ? ($this->nbofservicesexpired.$line->LibStatut(4,3,1)).(($mode != 7 || $this->nbofservicesclosed)?'   ':'') : ''; $text.=($mode == 7?'
':''); - $text.=($mode != 7 || $this->nbofservicesclosed > 0) ? $this->nbofservicesclosed.' '.$line->LibStatut(5,3) : ''; + $text.=($mode != 7 || $this->nbofservicesclosed > 0) ? ($this->nbofservicesclosed.$line->LibStatut(5,3)) : ''; $text.=($mode == 7?'
':''); return $text; } diff --git a/htdocs/core/boxes/box_services_contracts.php b/htdocs/core/boxes/box_services_contracts.php index ccdcfbdbe5a..1795f7c6f2f 100644 --- a/htdocs/core/boxes/box_services_contracts.php +++ b/htdocs/core/boxes/box_services_contracts.php @@ -27,7 +27,7 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; /** - * Class to manage the box to show last services lines + * Class to manage the box to show last contracted products/services lines */ class box_services_contracts extends ModeleBoxes { @@ -72,6 +72,8 @@ class box_services_contracts extends ModeleBoxes include_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; + $form = new Form($db); + $this->info_box_head = array('text' => $langs->trans("BoxLastProductsInContract",$max)); if ($user->rights->service->lire && $user->rights->contrat->lire) @@ -79,11 +81,12 @@ class box_services_contracts extends ModeleBoxes $contractstatic=new Contrat($db); $contratlignestatic=new ContratLigne($db); $thirdpartytmp = new Societe($db); + $productstatic = new Product($db); $sql = "SELECT s.nom as name, s.rowid as socid,"; $sql.= " c.rowid, c.ref, c.statut as contract_status,"; - $sql.= " cd.rowid as cdid, cd.tms as datem, cd.statut, cd.label, cd.description, cd.product_type as type,"; - $sql.= " p.rowid as product_id, p.ref as product_ref"; + $sql.= " cd.rowid as cdid, cd.label, cd.description, cd.tms as datem, cd.statut, cd.product_type as type,"; + $sql.= " p.rowid as product_id, p.ref as product_ref, p.label as plabel, p.fk_product_type as ptype, p.entity"; $sql.= " FROM (".MAIN_DB_PREFIX."societe as s"; $sql.= " INNER JOIN ".MAIN_DB_PREFIX."contrat as c ON s.rowid = c.fk_soc"; $sql.= " INNER JOIN ".MAIN_DB_PREFIX."contratdet as cd ON c.rowid = cd.fk_contrat"; @@ -140,8 +143,41 @@ class box_services_contracts extends ModeleBoxes } } + // Label + if ($objp->product_id > 0) + { + $productstatic->id=$objp->product_id; + $productstatic->type=$objp->ptype; + $productstatic->ref=$objp->product_ref; + $productstatic->entity=$objp->pentity; + $productstatic->label=$objp->plabel; + $text = $productstatic->getNomUrl(1,'',20); + if ($objp->plabel) + { + $text .= ' - '; + //$productstatic->ref=$objp->label; + //$text .= $productstatic->getNomUrl(0,'',16); + $text .= $objp->plabel; + } + $description = $objp->description; + + // Add description in form + if (! empty($conf->global->PRODUIT_DESC_IN_FORM)) + { + //$text .= (! empty($objp->description) && $objp->description!=$objp->plabel)?'
'.dol_htmlentitiesbr($objp->description):''; + $description = ''; // Already added into main visible desc + } + + $s = $form->textwithtooltip($text,$description,3,'','',$cursorline,0,(!empty($line->fk_parent_line)?img_picto('', 'rightarrow'):'')); + } + else + { + $s = img_object($langs->trans("ShowProductOrService"), ($objp->product_type ? 'service' : 'product')).' '.dol_htmlentitiesbr($objp->description); + } + + $this->info_box_contents[$i][] = array('td' => 'class="tdoverflowmax100 maxwidth100onsmartphone"', - 'text' => $contratlignestatic->getNomUrl(1), + 'text' => $s, 'asis' => 1 ); From 9cf6c43f8a633a288e96f9e8083e538cb2bda18c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 31 Jul 2017 15:51:08 +0200 Subject: [PATCH 034/183] Fix code comment --- htdocs/core/tpl/login.tpl.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/core/tpl/login.tpl.php b/htdocs/core/tpl/login.tpl.php index 9cddb8d183d..c518649a337 100644 --- a/htdocs/core/tpl/login.tpl.php +++ b/htdocs/core/tpl/login.tpl.php @@ -17,6 +17,8 @@ */ // Need global variable $title to be defined by caller (like dol_loginfunction) +// Caller can also set $theResArray = array(['options']=>array('js'=>..., 'table'=>...); + header('Cache-Control: Public, must-revalidate'); @@ -249,7 +251,7 @@ if (!empty($conf->global->MAIN_EASTER_EGG_COMMITSTRIP)) { } else { $resgetcommitstrip = getURLContent("http://www.commitstrip.com/en/feed/"); } - if ($resgetcommitstrip && $resgetcommitstrip['http_code'] == '200') + if ($resgetcommitstrip && $resgetcommitstrip['http_code'] == '200') { $xml = simplexml_load_string($resgetcommitstrip['content']); $little = $xml->channel->item[0]->children('content',true); From 7d6d4adcdba1a8dab42b8c58a453d0e79a15b271 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 31 Jul 2017 18:16:41 +0200 Subject: [PATCH 035/183] Fix combo for multicompany not visible where there is other hooks by other modules --- htdocs/core/lib/security2.lib.php | 3 ++- htdocs/core/tpl/login.tpl.php | 12 +++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/htdocs/core/lib/security2.lib.php b/htdocs/core/lib/security2.lib.php index 248c3bde43e..817fd2be8da 100644 --- a/htdocs/core/lib/security2.lib.php +++ b/htdocs/core/lib/security2.lib.php @@ -166,7 +166,7 @@ function dol_loginfunction($langs,$conf,$mysoc) } $conf_css = $themepath."?lang=".$langs->defaultlang; - // Select templates + // Select templates dir if (! empty($conf->modules_parts['tpl'])) // Using this feature slow down application { $dirtpls=array_merge($conf->modules_parts['tpl'],array('/core/tpl/')); @@ -205,6 +205,7 @@ function dol_loginfunction($langs,$conf,$mysoc) // Should be an array with differents options in $hookmanager->resArray $parameters=array('entity' => GETPOST('entity','int')); $reshook = $hookmanager->executeHooks('getLoginPageOptions',$parameters); // Note that $action and $object may have been modified by some hooks. resArray is filled by hook. + $morelogincontent = $hookmanager->resArray['options']; // TODO Use here a resprints // Login $login = (! empty($hookmanager->resArray['username']) ? $hookmanager->resArray['username'] : (GETPOST("username","alpha") ? GETPOST("username","alpha") : $demologin)); diff --git a/htdocs/core/tpl/login.tpl.php b/htdocs/core/tpl/login.tpl.php index c518649a337..a1fdc3e9e9d 100644 --- a/htdocs/core/tpl/login.tpl.php +++ b/htdocs/core/tpl/login.tpl.php @@ -17,9 +17,7 @@ */ // Need global variable $title to be defined by caller (like dol_loginfunction) -// Caller can also set $theResArray = array(['options']=>array('js'=>..., 'table'=>...); - - +// Caller can also set $morelogincontent = array(['options']=>array('js'=>..., 'table'=>...); header('Cache-Control: Public, must-revalidate'); header("Content-type: text/html; charset=".$conf->file->character_set_client); @@ -125,8 +123,8 @@ if ($disablenofollow) echo ''; resArray['options'])) { - foreach ($hookmanager->resArray['options'] as $format => $option) +if (! empty($morelogincontent) && is_array($morelogincontent)) { + foreach ($morelogincontent as $format => $option) { if ($format == 'table') { echo ''; @@ -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 d2b662c671d250c15fea77a38672ac8896811c5a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 31 Jul 2017 19:31:52 +0200 Subject: [PATCH 036/183] Add field fk_user in bookkeeping (the user who valiated the accounting document. Will be used for statistics purpose only). --- htdocs/install/mysql/migration/6.0.0-7.0.0.sql | 1 + htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql index be8bd9c2701..8dbd0341e07 100644 --- a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql +++ b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql @@ -48,4 +48,5 @@ ALTER TABLE llx_accounting_bookkeeping ADD COLUMN import_key varchar(14); ALTER TABLE llx_accounting_bookkeeping ADD COLUMN extraparams varchar(255); ALTER TABLE llx_accounting_bookkeeping ADD COLUMN date_lim_reglement datetime; +ALTER TABLE llx_accounting_bookkeeping ADD COLUMN fk_user integer NULL; diff --git a/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql b/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql index e9a4921a840..269e73987ee 100644 --- a/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql +++ b/htdocs/install/mysql/tables/llx_accounting_bookkeeping.sql @@ -45,9 +45,10 @@ CREATE TABLE llx_accounting_bookkeeping fk_user_modif integer, -- | user making last change date_creation datetime, -- FEC:EcritureDate | creation date tms timestamp, -- | date last modification + fk_user integer NULL -- The id of user that validate the accounting source document code_journal varchar(32) NOT NULL, -- FEC:JournalCode journal_label varchar(255), -- FEC:JournalLib - piece_num integer NOT NULL, -- FEC:EcritureNum + piece_num integer NOT NULL, -- FEC:EcritureNum | accounting source document validated tinyint DEFAULT 0 NOT NULL, -- | 0 line not validated / 1 line validated (No deleting / No modification) date_validated datetime -- FEC:ValidDate import_key varchar(14), From ba221650cf3e78337a7682ff1bb2d5519d003f5c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 1 Aug 2017 01:25:30 +0200 Subject: [PATCH 037/183] Start to work on using the jquery date selector. --- htdocs/core/class/html.form.class.php | 87 ++++++++++++++++++--------- 1 file changed, 60 insertions(+), 27 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index cda39e3ca9d..b39208b9237 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -4727,6 +4727,7 @@ class Form $smin = !isset($conf->global->MAIN_DEFAULT_DATE_MIN) ? '' : $conf->global->MAIN_DEFAULT_DATE_MIN; } + // You can set MAIN_POPUP_CALENDAR to 'eldy' or 'jquery' $usecalendar='combo'; if (! empty($conf->use_javascript_ajax) && (empty($conf->global->MAIN_POPUP_CALENDAR) || $conf->global->MAIN_POPUP_CALENDAR != "none")) $usecalendar=empty($conf->global->MAIN_POPUP_CALENDAR)?'eldy':$conf->global->MAIN_POPUP_CALENDAR; if ($conf->browser->phone) $usecalendar='combo'; @@ -4758,7 +4759,8 @@ class Form { $retstring.=''; + $retstring.=' onClick="showDP(\''.$base.'\',\''.$prefix.'\',\''.$langs->trans("FormatDateShortJavaInput").'\',\''.$langs->defaultlang.'\');"'; + $retstring.='>'.img_object($langs->trans("SelectDate"),'calendarday','class="datecallink"').''; } else $retstring.=''; @@ -4766,6 +4768,37 @@ class Form $retstring.=''."\n"; $retstring.=''."\n"; } + elseif ($usecalendar == 'jquery') + { + if (! $disabled) + { + print ""; + } + + // Zone de saisie manuelle de la date + $retstring.='trans("FormatDateShortJavaInput").'\'); "'; // FormatDateShortInput for dol_print_date / FormatDateShortJavaInput that is same for javascript + $retstring.='>'; + + // Icone calendrier + if (! $disabled) + { + //$retstring.=''; + } + else $retstring.=''; + + $retstring.=''."\n"; + $retstring.=''."\n"; + $retstring.=''."\n"; + } else { print "Bad value of MAIN_POPUP_CALENDAR"; @@ -6325,40 +6358,40 @@ class Form } return $out; } - + /** * Return HTML to show the select categories of expense category - * + * * @param string $selected preselected category * @param string $htmlname name of HTML select list * @param integer $useempty 1=Add empty line * @param array $excludeid id to exclude * @param string $target htmlname of target select to bind event * @param int $default_selected default category to select if fk_c_type_fees change = EX_KME - * @param array $params param to give + * @param array $params param to give * @return string */ function selectExpenseCategories($selected='', $htmlname='fk_c_exp_tax_cat', $useempty=0, $excludeid=array(), $target='', $default_selected=0, $params=array()) { global $db,$conf,$langs; - + $sql = 'SELECT rowid, label FROM '.MAIN_DB_PREFIX.'c_exp_tax_cat WHERE active = 1'; $sql.= ' AND entity IN (0,'.getEntity('').')'; if (!empty($excludeid)) $sql.= ' AND rowid NOT IN ('.implode(',', $excludeid).')'; $sql.= ' ORDER BY label'; - + $resql = $db->query($sql); if ($resql) { $out = ''; - + if (!empty($target)) { $sql = "SELECT c.id FROM ".MAIN_DB_PREFIX."c_type_fees as c WHERE c.code = 'EX_KME' AND c.active = 1"; @@ -6374,19 +6407,19 @@ class Form var current_val = $(this).val(); if (current_val == '.$obj->id.') {'; if (!empty($default_selected) || !empty($selected)) $out.= '$("select[name='.$htmlname.']").val("'.($default_selected > 0 ? $default_selected : $selected).'");'; - + $out.= ' $("select[name='.$htmlname.']").change(); } }); $("select[name='.$htmlname.']").change(function() { - + if ($("select[name='.$target.']").val() == '.$obj->id.') { // get price of kilometer to fill the unit price var data = '.json_encode($params).'; data.fk_c_exp_tax_cat = $(this).val(); - + $.ajax({ method: "POST", dataType: "json", @@ -6407,20 +6440,20 @@ class Form }); '; } - } + } } } else { dol_print_error($db); } - + return $out; } - + /** * Return HTML to show the select ranges of expense range - * + * * @param string $selected preselected category * @param string $htmlname name of HTML select list * @param integer $useempty 1=Add empty line @@ -6429,16 +6462,16 @@ class Form function selectExpenseRanges($selected='', $htmlname='fk_range', $useempty=0) { global $db,$conf,$langs; - + $sql = 'SELECT rowid, range_ik FROM '.MAIN_DB_PREFIX.'c_exp_tax_range'; $sql.= ' WHERE entity = '.$conf->entity.' AND active = 1'; - + $resql = $db->query($sql); if ($resql) { $out = ''; if ($useempty) $out.= ''; if ($allchoice) $out.= ''; - + $field = 'code'; if ($useid) $field = 'id'; - + while ($obj = $db->fetch_object($resql)) { $key = $langs->trans($obj->code); @@ -6491,9 +6524,9 @@ class Form { dol_print_error($db); } - + return $out; } - + } From ae444b57810cabc3d0d488ed758914b3f951086f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 1 Aug 2017 01:28:07 +0200 Subject: [PATCH 038/183] 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/183] 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 ''.length_accountg($accountingaccount->getNomUrl(0,1,1,'',1)).''; + print ''.$accountingaccount->getNomUrl(0,1,1,'',1).''; 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/183] 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/183] 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/183] 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 ''; - $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/183] 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/183] 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/183] 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/183] 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/183] 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/183] 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/183] 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 '\n"; + //print ''; + print ''; + print ''; + print ''; + + print "\n"; + $url='https://partners.dolibarr.org'; + print ''; + print ''; + print ''; + 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 '"; print '\n"; @@ -777,11 +777,11 @@ if ($action == 'create') // Other attributes $parameters = array('objectsrc' => $objectsrc, 'colspan' => ' colspan="3"', 'socid'=>$socid); - $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$expe,$action); // Note that $action and $object may have been modified by hook + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (empty($reshook) && ! empty($extrafields->attribute_label)) { - print $expe->showOptionals($extrafields, 'edit'); + print $object->showOptionals($extrafields, 'edit'); } From 749355abc2b96ac4d19c86c2c8be688cd5adfc50 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 22 Aug 2017 10:41:30 +0200 Subject: [PATCH 166/183] Update cron_run_jobs.php --- scripts/cron/cron_run_jobs.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/cron/cron_run_jobs.php b/scripts/cron/cron_run_jobs.php index 5c32272bed1..a0d4cb7caee 100755 --- a/scripts/cron/cron_run_jobs.php +++ b/scripts/cron/cron_run_jobs.php @@ -55,9 +55,9 @@ $key=$argv[1]; if (! isset($argv[2]) || ! $argv[2]) { usage($path,$script_file); exit(-1); -} else { - $userlogin=$argv[2]; -} +} + +$userlogin=$argv[2]; // Global variables From d2955cb32f489f037c166fd3cf9a96ff82ae0ebd Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 22 Aug 2017 08:31:23 +0200 Subject: [PATCH 167/183] Fix: virtualmin script update --- build/perl/virtualmin/README | 8 +++--- build/perl/virtualmin/dolibarr.pl | 45 +++++++++++++++++-------------- 2 files changed, 30 insertions(+), 23 deletions(-) diff --git a/build/perl/virtualmin/README b/build/perl/virtualmin/README index 22db444a31f..6da04e5f0b8 100644 --- a/build/perl/virtualmin/README +++ b/build/perl/virtualmin/README @@ -1,8 +1,10 @@ README (English) ################################################## -Install script for Virtualmin Pro +Install script for Virtualmin Professional / GPL ################################################## -This script will install automatically Dolibarr from Virtualmin Pro -http://www.virtualmin.com +This script will install automatically Dolibarr from Virtualmin. +(Included in the professional version and can be added in the GPL version) + +https://www.virtualmin.com http://www.webmin.com/virtualmin.html \ No newline at end of file diff --git a/build/perl/virtualmin/dolibarr.pl b/build/perl/virtualmin/dolibarr.pl index 32324d28e42..93439303833 100644 --- a/build/perl/virtualmin/dolibarr.pl +++ b/build/perl/virtualmin/dolibarr.pl @@ -1,7 +1,7 @@ #---------------------------------------------------------------------------- # \file dolibarr.pl # \brief Dolibarr script install for Virtualmin Pro -# \author (c)2009-2015 Regis Houssin +# \author (c)2009-2017 Regis Houssin #---------------------------------------------------------------------------- @@ -30,7 +30,12 @@ return "Regis Houssin"; # script_dolibarr_versions() sub script_dolibarr_versions { -return ( "3.8.1", "3.7.1", "3.6.4", "3.5.7" ); +return ( "5.0.4", "4.0.6", "3.9.4" ); +} + +sub script_dolibarr_release +{ +return 2; # for mysqli fix } sub script_dolibarr_category @@ -163,7 +168,7 @@ return ("tar", "gunzip"); } # script_dolibarr_install(&domain, version, &opts, &files, &upgrade-info) -# Actually installs dolibarr, and returns either 1 and an informational +# Actually installs joomla, and returns either 1 and an informational # message, or 0 and an error sub script_dolibarr_install { @@ -177,9 +182,9 @@ if ($opts->{'newdb'} && !$upgrade) { local ($dbtype, $dbname) = split(/_/, $opts->{'db'}, 2); local $dbuser = $dbtype eq "mysql" ? &mysql_user($d) : &postgres_user($d); local $dbpass = $dbtype eq "mysql" ? &mysql_pass($d) : &postgres_pass($d, 1); -local $dbphptype = $dbtype eq "mysql" && $version >= 3.6 ? "mysql" : +local $dbphptype = $dbtype eq "mysql" && $version < 3.6 ? "mysql" : $dbtype eq "mysql" ? "mysqli" : "pgsql"; -local $dbhost = &get_database_host($dbtype); +local $dbhost = &get_database_host($dbtype, $d); local $dberr = &check_script_db_connection($dbtype, $dbname, $dbuser, $dbpass); return (0, "Database connection failed : $dberr") if ($dberr); @@ -206,9 +211,6 @@ $pgcharset = $tmpl->{'postgres_encoding'}; $charset = $dbtype eq "mysql" ? $mycharset : $pgcharset; $collate = $dbtype eq "mysql" ? $mycollate : "C"; -# Install filename -local $step = $version >= 3.8 ? "step" : "etape"; - $path = &script_path_url($d, $opts); if ($path =~ /^https:/ || $d->{'ssl'}) { $url = "https://$d->{'dom'}"; @@ -222,15 +224,11 @@ if ($opts->{'path'} =~ /\w/) { if (!$upgrade) { local $cdef = "$opts->{'dir'}/conf/conf.php.example"; - &run_as_domain_user($d, "cp ".quotemeta($cdef)." ".quotemeta($cfile)); + ©_source_dest_as_domain_user($d, $cdef, $cfile); &set_permissions_as_domain_user($d, 0777, $cfiledir); - &set_permissions_as_domain_user($d, 0666, $cfile); + ©_source_dest_as_domain_user($d, $cfile); &run_as_domain_user($d, "mkdir ".quotemeta($docdir)); &set_permissions_as_domain_user($d, 0777, $docdir); - if (!$version >= 3.7.2) { - &run_as_domain_user($d, "mkdir ".quotemeta($altdir)); - &set_permissions_as_domain_user($d, 0777, $altdir); - } } else { # Preserve old config file, documents and custom directory @@ -266,7 +264,8 @@ if ($upgrade) { [ "versionfrom", $upgrade->{'version'} ], [ "versionto", $ver ], ); - local $err = &call_dolibarr_wizard_page(\@params, $step."5", $d, $opts); + local $p = $ver >= 3.8 ? "step5" : "etape5"; + local $err = &call_dolibarr_wizard_page(\@params, $p, $d, $opts); return (-1, "Dolibarr wizard failed : $err") if ($err); # Remove the installation directory. @@ -289,15 +288,17 @@ else { [ "main_force_https", $opts->{'forcehttps'} ], [ "dolibarr_main_db_character_set", $charset ], [ "dolibarr_main_db_collation", $collate ], - [ "main_use_alt_dir", "1" ], + [ "usealternaterootdir", "1" ], [ "main_alt_dir_name", "custom" ], ); - local $err = &call_dolibarr_wizard_page(\@params, $step."1", $d, $opts); + local $p = $ver >= 3.8 ? "step1" : "etape1"; + local $err = &call_dolibarr_wizard_page(\@params, $p, $d, $opts); return (-1, "Dolibarr wizard failed : $err") if ($err); # Second page (Populate database) local @params = ( [ "action", "set" ] ); - local $err = &call_dolibarr_wizard_page(\@params, $step."2", $d, $opts); + local $p = $ver >= 3.8 ? "step2" : "etape2"; + local $err = &call_dolibarr_wizard_page(\@params, $p, $d, $opts); return (-1, "Dolibarr wizard failed : $err") if ($err); # Third page (Add administrator account) @@ -306,7 +307,8 @@ else { [ "pass", $dompass ], [ "pass_verif", $dompass ], ); - local $err = &call_dolibarr_wizard_page(\@params, $step."5", $d, $opts); + local $p = $ver >= 3.8 ? "step5" : "etape5"; + local $err = &call_dolibarr_wizard_page(\@params, $p, $d, $opts); return (-1, "Dolibarr wizard failed : $err") if ($err); # Remove the installation directory and protect config file. @@ -384,7 +386,10 @@ sub script_dolibarr_check_latest { local ($ver) = @_; local @vers = &osdn_package_versions("dolibarr", - $ver >= 3.8 ? "dolibarr\\-(3\\.[0-9\\.]+)\\.tgz" : + $ver >= 5.0 ? "dolibarr\\-(5\\.0\\.[0-9\\.]+)\\.tgz" : + $ver >= 4.0 ? "dolibarr\\-(4\\.0\\.[0-9\\.]+)\\.tgz" : + $ver >= 3.9 ? "dolibarr\\-(3\\.9\\.[0-9\\.]+)\\.tgz" : + $ver >= 3.8 ? "dolibarr\\-(3\\.8\\.[0-9\\.]+)\\.tgz" : $ver >= 3.7 ? "dolibarr\\-(3\\.7\\.[0-9\\.]+)\\.tgz" : $ver >= 3.6 ? "dolibarr\\-(3\\.6\\.[0-9\\.]+)\\.tgz" : $ver >= 3.5 ? "dolibarr\\-(3\\.5\\.[0-9\\.]+)\\.tgz" : From a17e4434beec2099f786ba668ba1d00a9e041f16 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 22 Aug 2017 08:35:16 +0200 Subject: [PATCH 168/183] Fix: wrong app name --- build/perl/virtualmin/dolibarr.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/perl/virtualmin/dolibarr.pl b/build/perl/virtualmin/dolibarr.pl index 93439303833..08d02e8b2b8 100644 --- a/build/perl/virtualmin/dolibarr.pl +++ b/build/perl/virtualmin/dolibarr.pl @@ -168,7 +168,7 @@ return ("tar", "gunzip"); } # script_dolibarr_install(&domain, version, &opts, &files, &upgrade-info) -# Actually installs joomla, and returns either 1 and an informational +# Actually installs dolibarr, and returns either 1 and an informational # message, or 0 and an error sub script_dolibarr_install { From 7d57cd691356abe2777868305f58437d2eca825d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 22 Aug 2017 11:38:32 +0200 Subject: [PATCH 169/183] Update productcustomerprice.class.php --- htdocs/product/class/productcustomerprice.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/class/productcustomerprice.class.php b/htdocs/product/class/productcustomerprice.class.php index 9c2ce3e99d2..89497b68315 100644 --- a/htdocs/product/class/productcustomerprice.class.php +++ b/htdocs/product/class/productcustomerprice.class.php @@ -672,7 +672,7 @@ class Productcustomerprice extends CommonObject // Call triggers include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; $interface=new Interfaces($this->db); - $result=$interface->run_triggers('CUSTOMER_PRODUCT_SELLPRICE_CREATE',$this,$user,$langs,$conf); + $result=$interface->run_triggers('PRODUCT_CUSTOMER_PRICE_UPDATE',$this,$user,$langs,$conf); if ($result < 0) { $error++; $this->errors=$interface->errors; } // End call triggers } From 927da89c8975f75d1f4e6ea4b692fb94ec3e3fcb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 22 Aug 2017 11:52:34 +0200 Subject: [PATCH 170/183] Revert bad change --- htdocs/install/mysql/tables/llx_product_customer_price_log.sql | 3 ++- htdocs/install/mysql/tables/llx_product_price.sql | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/install/mysql/tables/llx_product_customer_price_log.sql b/htdocs/install/mysql/tables/llx_product_customer_price_log.sql index 3844b3e332f..deec2ac78b5 100644 --- a/htdocs/install/mysql/tables/llx_product_customer_price_log.sql +++ b/htdocs/install/mysql/tables/llx_product_customer_price_log.sql @@ -18,6 +18,8 @@ -- -- ============================================================================ +-- To log changes of prices per customer (llx_product_customer_price) + create table llx_product_customer_price_log ( rowid integer AUTO_INCREMENT PRIMARY KEY, @@ -25,7 +27,6 @@ create table llx_product_customer_price_log datec datetime, fk_product integer NOT NULL, fk_soc integer DEFAULT 0 NOT NULL, - price_level smallint NULL DEFAULT 1, price double(24,8) DEFAULT 0, price_ttc double(24,8) DEFAULT 0, price_min double(24,8) DEFAULT 0, diff --git a/htdocs/install/mysql/tables/llx_product_price.sql b/htdocs/install/mysql/tables/llx_product_price.sql index a7f9ba38751..4e5920e1dff 100755 --- a/htdocs/install/mysql/tables/llx_product_price.sql +++ b/htdocs/install/mysql/tables/llx_product_price.sql @@ -18,6 +18,9 @@ -- -- ============================================================================ +-- To save customer prices (one price per product or several prices per segment/level) +-- TODO We should introduce table llx_product_price_log to store changes and keep in this table only last current price ! + create table llx_product_price ( rowid integer AUTO_INCREMENT PRIMARY KEY, From 5cf684f5a23f5c02bb791c56e4626073e88a567c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 22 Aug 2017 13:14:10 +0200 Subject: [PATCH 171/183] NEW Popup for preview of image add a button "Original size" --- htdocs/core/js/lib_head.js.php | 33 ++++++++++++++++++++++++++++----- htdocs/langs/en_US/main.lang | 1 + htdocs/theme/eldy/style.css.php | 13 +++++++++++++ 3 files changed, 42 insertions(+), 5 deletions(-) diff --git a/htdocs/core/js/lib_head.js.php b/htdocs/core/js/lib_head.js.php index 28b908aa13c..c58cd3eba9e 100644 --- a/htdocs/core/js/lib_head.js.php +++ b/htdocs/core/js/lib_head.js.php @@ -983,6 +983,8 @@ function newpopup(url,title) { function document_preview(file, type, title) { var ValidImageTypes = ["image/gif", "image/jpeg", "image/png"]; + var showOriginalSizeButton = false; + console.log("document_preview A click was done. file="+file+", type="+type+", title="+title); if ($.inArray(type, ValidImageTypes) < 0) { @@ -991,7 +993,7 @@ function document_preview(file, type, title) var height = $( window ).height()*0.90; var object_height='98%'; - show_preview(); + show_preview('notimage'); } else { var object_width=0; @@ -1005,23 +1007,38 @@ function document_preview(file, type, title) width = $( window ).width()*0.90; if(object_width < width){ + console.log("Object width is small, we set width of popup according to image width."); width = object_width + 30 } height = $( window ).height()*0.85; if(object_height < height){ + console.log("Object height is small, we set height of popup according to image height."); height = object_height + 80 } + else + { + showOriginalSizeButton = true; + } - show_preview(); + show_preview('image'); }; img.src = file; } - function show_preview(){ - /* console.log("file="+file+" type="+type+" width="+width+" height="+height); */ + function show_preview(mode) { + console.log("mode="+mode+" file="+file+" type="+type+" width="+width+" height="+height); var newElem = ''; + optionsbuttons = {} + if (mode == 'image' && showOriginalSizeButton) + { + optionsbuttons = { + "trans("OriginalSize")); ?>": function() { console.log("Click on original size"); jQuery(".ui-dialog-content.ui-widget-content > object").css({ "max-height": "none" }); }, + "trans("Close")); ?>": function() { $( this ).dialog( "close" ); } + }; + } + $("#dialogforpopup").html(newElem); $("#dialogforpopup").dialog({ closeOnEscape: true, @@ -1029,8 +1046,14 @@ function document_preview(file, type, title) width: width, height: height, modal: true, - title: title + title: title, + buttons: optionsbuttons }); + + if (showOriginalSizeButton) + { + jQuery(".ui-dialog-content.ui-widget-content > object").css({ "max-height": "100%", "width": "auto", "margin-left": "auto", "margin-right": "auto", "display": "block" }); + } } } diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 9d5040afd53..d59a6276d05 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -460,6 +460,7 @@ Discount=Discount Unknown=Unknown General=General Size=Size +OriginalSize=Original size Received=Received Paid=Paid Topic=Subject diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 07d73b86758..a4e0a2f6a66 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -3148,6 +3148,19 @@ div.titre { font-size: px !important; } + +/* ============================================================================== */ +/* For content of image preview */ +/* ============================================================================== */ + +/* +.ui-dialog-content.ui-widget-content > object { + max-height: none; + width: auto; margin-left: auto; margin-right: auto; display: block; +} +*/ + + /* ============================================================================== */ /* Formulaire confirmation (When HTML is used) */ /* ============================================================================== */ From d9450477944a798a4dd6f8fa000f3ffca9896ab7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 22 Aug 2017 13:15:56 +0200 Subject: [PATCH 172/183] Remove log --- htdocs/core/js/lib_head.js.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/js/lib_head.js.php b/htdocs/core/js/lib_head.js.php index c58cd3eba9e..55055792510 100644 --- a/htdocs/core/js/lib_head.js.php +++ b/htdocs/core/js/lib_head.js.php @@ -1027,7 +1027,7 @@ function document_preview(file, type, title) } function show_preview(mode) { - console.log("mode="+mode+" file="+file+" type="+type+" width="+width+" height="+height); + /* console.log("mode="+mode+" file="+file+" type="+type+" width="+width+" height="+height); */ var newElem = ''; optionsbuttons = {} From 14cd1507625de148d9b125743281f7c8fdfab3d1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 22 Aug 2017 14:47:01 +0200 Subject: [PATCH 173/183] NEW Introduce experimental feature to search dolistore from application --- htdocs/{ => admin}/dolistore/ajax/image.php | 132 +- .../class/PSWebServiceLibrary.class.php | 18 +- .../dolistore/class/dolistore.class.php | 624 ++--- htdocs/{ => admin}/dolistore/class/init.php | 0 .../{ => admin}/dolistore/css/dolistore.css | 0 .../dolistore/img/Download-128.png | Bin .../dolistore/img/NoImageAvailable.png | Bin .../{ => admin}/dolistore/img/compatible.png | Bin .../{ => admin}/dolistore/img/dolistore.png | Bin htdocs/{ => admin}/dolistore/img/follow.png | Bin .../dolistore/img/object_dolistore.png | Bin htdocs/admin/modules.php | 123 +- htdocs/core/class/conf.class.php | 3 + htdocs/core/lib/admin.lib.php | 39 +- .../core/modules/modDolistore.class.php | 159 -- htdocs/dolistore/index.php | 115 - htdocs/dolistore/js/dolistore.js.php | 79 - htdocs/dolistore/js/fancybox/blank.gif | Bin 43 -> 0 bytes .../js/fancybox/fancybox_loading.gif | Bin 6567 -> 0 bytes .../js/fancybox/fancybox_loading@2x.gif | Bin 13984 -> 0 bytes .../js/fancybox/fancybox_overlay.png | Bin 1003 -> 0 bytes .../dolistore/js/fancybox/fancybox_sprite.png | Bin 1362 -> 0 bytes .../js/fancybox/fancybox_sprite@2x.png | Bin 6553 -> 0 bytes .../js/fancybox/helpers/fancybox_buttons.png | Bin 1080 -> 0 bytes .../helpers/jquery.fancybox-buttons.css | 97 - .../helpers/jquery.fancybox-buttons.js | 122 - .../fancybox/helpers/jquery.fancybox-media.js | 201 -- .../helpers/jquery.fancybox-thumbs.css | 55 - .../helpers/jquery.fancybox-thumbs.js | 165 -- .../dolistore/js/fancybox/jquery.fancybox.css | 275 --- .../dolistore/js/fancybox/jquery.fancybox.js | 2018 ----------------- .../js/fancybox/jquery.fancybox.pack.js | 46 - htdocs/dolistore/langs/de_DE/dolistore.lang | 22 - htdocs/dolistore/langs/en_EN/dolistore.lang | 22 - htdocs/dolistore/langs/es_ES/dolistore.lang | 22 - htdocs/dolistore/langs/fr_FR/dolistore.lang | 22 - htdocs/dolistore/langs/it_IT/dolistore.lang | 22 - htdocs/langs/en_US/admin.lang | 18 +- 38 files changed, 544 insertions(+), 3855 deletions(-) rename htdocs/{ => admin}/dolistore/ajax/image.php (94%) rename htdocs/{ => admin}/dolistore/class/PSWebServiceLibrary.class.php (96%) rename htdocs/{ => admin}/dolistore/class/dolistore.class.php (95%) rename htdocs/{ => admin}/dolistore/class/init.php (100%) rename htdocs/{ => admin}/dolistore/css/dolistore.css (100%) rename htdocs/{ => admin}/dolistore/img/Download-128.png (100%) rename htdocs/{ => admin}/dolistore/img/NoImageAvailable.png (100%) rename htdocs/{ => admin}/dolistore/img/compatible.png (100%) rename htdocs/{ => admin}/dolistore/img/dolistore.png (100%) rename htdocs/{ => admin}/dolistore/img/follow.png (100%) rename htdocs/{ => admin}/dolistore/img/object_dolistore.png (100%) delete mode 100644 htdocs/dolistore/core/modules/modDolistore.class.php delete mode 100644 htdocs/dolistore/index.php delete mode 100644 htdocs/dolistore/js/dolistore.js.php delete mode 100644 htdocs/dolistore/js/fancybox/blank.gif delete mode 100644 htdocs/dolistore/js/fancybox/fancybox_loading.gif delete mode 100644 htdocs/dolistore/js/fancybox/fancybox_loading@2x.gif delete mode 100644 htdocs/dolistore/js/fancybox/fancybox_overlay.png delete mode 100644 htdocs/dolistore/js/fancybox/fancybox_sprite.png delete mode 100644 htdocs/dolistore/js/fancybox/fancybox_sprite@2x.png delete mode 100644 htdocs/dolistore/js/fancybox/helpers/fancybox_buttons.png delete mode 100644 htdocs/dolistore/js/fancybox/helpers/jquery.fancybox-buttons.css delete mode 100644 htdocs/dolistore/js/fancybox/helpers/jquery.fancybox-buttons.js delete mode 100644 htdocs/dolistore/js/fancybox/helpers/jquery.fancybox-media.js delete mode 100644 htdocs/dolistore/js/fancybox/helpers/jquery.fancybox-thumbs.css delete mode 100644 htdocs/dolistore/js/fancybox/helpers/jquery.fancybox-thumbs.js delete mode 100644 htdocs/dolistore/js/fancybox/jquery.fancybox.css delete mode 100644 htdocs/dolistore/js/fancybox/jquery.fancybox.js delete mode 100644 htdocs/dolistore/js/fancybox/jquery.fancybox.pack.js delete mode 100644 htdocs/dolistore/langs/de_DE/dolistore.lang delete mode 100644 htdocs/dolistore/langs/en_EN/dolistore.lang delete mode 100644 htdocs/dolistore/langs/es_ES/dolistore.lang delete mode 100644 htdocs/dolistore/langs/fr_FR/dolistore.lang delete mode 100644 htdocs/dolistore/langs/it_IT/dolistore.lang diff --git a/htdocs/dolistore/ajax/image.php b/htdocs/admin/dolistore/ajax/image.php similarity index 94% rename from htdocs/dolistore/ajax/image.php rename to htdocs/admin/dolistore/ajax/image.php index 5bc6c9f2f0f..10ce4656c40 100644 --- a/htdocs/dolistore/ajax/image.php +++ b/htdocs/admin/dolistore/ajax/image.php @@ -1,65 +1,67 @@ -. - * - * This program is free software; you can redistribute it and/or modifyion 2.0 (the "License"); - * it under the terms of the GNU General Public License as published bypliance with the License. - * the Free Software Foundation; either version 3 of the License, or - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * or see http://www.gnu.org/ - */ - -if (!defined('REQUIRE_JQUERY_BLOCKUI')) define('REQUIRE_JQUERY_BLOCKUI', 1); -/** - * \file htdocs/commande/info.php - * \ingroup commande - * \brief Page des informations d'une commande - */ -$res = 0; -if (!$res && file_exists("../main.inc.php")) $res = @include("../main.inc.php"); -if (!$res && file_exists("../../main.inc.php")) $res = @include("../../main.inc.php"); -if (!$res && file_exists("../../../main.inc.php")) $res = @include("../../../main.inc.php"); -if (!$res && file_exists("../../../../main.inc.php")) $res = @include("../../../../main.inc.php"); -if (!$res && file_exists("../../../dolibarr/htdocs/main.inc.php")) - $res = @include("../../../dolibarr/htdocs/main.inc.php"); // Used on dev env only -if (!$res && file_exists("../../../../dolibarr/htdocs/main.inc.php")) - $res = @include("../../../../dolibarr/htdocs/main.inc.php"); // Used on dev env only -if (!$res && file_exists("../../../../../dolibarr/htdocs/main.inc.php")) - $res = @include("../../../../../dolibarr/htdocs/main.inc.php"); // Used on dev env only -if (!$res) die("Include of main fails"); - -// CORE - -global $lang, $user, $conf; - - -dol_include_once('/dolistore/class/dolistore.class.php'); -$dolistore = new Dolistore(); - -$id_product = GETPOST('id_product', 'int'); -$id_image = GETPOST('id_image', 'int'); -// quality : image resize with this in the URL : "cart_default", "home_default", "large_default", "medium_default", "small_default", "thickbox_default" -$quality = GETPOST('quality', 'alpha'); - -try { - $url = $conf->global->MAIN_MODULE_DOLISTORE_API_SRV.'/api/images/products/'.$id_product.'/'.$id_image.'/'.$quality; - $api = new PrestaShopWebservice($conf->global->MAIN_MODULE_DOLISTORE_API_SRV, - $conf->global->MAIN_MODULE_DOLISTORE_API_KEY, $dolistore->debug_api); - //echo $url; - $request = $api->executeRequest($url, array(CURLOPT_CUSTOMREQUEST => 'GET')); - header('Content-type:image'); - print $request['response']; -} catch (PrestaShopWebserviceException $e) { - // Here we are dealing with errors - $trace = $e->getTrace(); - if ($trace[0]['args'][0] == 404) die('Bad ID'); - else if ($trace[0]['args'][0] == 401) die('Bad auth key'); - else die('Can not access to '.$conf->global->MAIN_MODULE_DOLISTORE_API_SRV); -} \ No newline at end of file +. + * Copyright (C) 2008-2011 Laurent Destailleur + * + * This program is free software; you can redistribute it and/or modifyion 2.0 (the "License"); + * it under the terms of the GNU General Public License as published bypliance with the License. + * the Free Software Foundation; either version 3 of the License, or + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * or see http://www.gnu.org/ + */ + +if (!defined('REQUIRE_JQUERY_BLOCKUI')) define('REQUIRE_JQUERY_BLOCKUI', 1); + + +/** + * \file htdocs/commande/info.php + * \ingroup commande + * \brief Page des informations d'une commande + */ +$res = 0; +if (!$res && file_exists("../main.inc.php")) $res = @include("../main.inc.php"); +if (!$res && file_exists("../../main.inc.php")) $res = @include("../../main.inc.php"); +if (!$res && file_exists("../../../main.inc.php")) $res = @include("../../../main.inc.php"); +if (!$res && file_exists("../../../../main.inc.php")) $res = @include("../../../../main.inc.php"); +if (!$res && file_exists("../../../dolibarr/htdocs/main.inc.php")) + $res = @include("../../../dolibarr/htdocs/main.inc.php"); // Used on dev env only +if (!$res && file_exists("../../../../dolibarr/htdocs/main.inc.php")) + $res = @include("../../../../dolibarr/htdocs/main.inc.php"); // Used on dev env only +if (!$res && file_exists("../../../../../dolibarr/htdocs/main.inc.php")) + $res = @include("../../../../../dolibarr/htdocs/main.inc.php"); // Used on dev env only +if (!$res) die("Include of main fails"); + +// CORE + +global $lang, $user, $conf; + + +dol_include_once('/dolistore/class/dolistore.class.php'); +$dolistore = new Dolistore(); + +$id_product = GETPOST('id_product', 'int'); +$id_image = GETPOST('id_image', 'int'); +// quality : image resize with this in the URL : "cart_default", "home_default", "large_default", "medium_default", "small_default", "thickbox_default" +$quality = GETPOST('quality', 'alpha'); + +try { + $url = $conf->global->MAIN_MODULE_DOLISTORE_API_SRV.'/api/images/products/'.$id_product.'/'.$id_image.'/'.$quality; + $api = new PrestaShopWebservice($conf->global->MAIN_MODULE_DOLISTORE_API_SRV, + $conf->global->MAIN_MODULE_DOLISTORE_API_KEY, $dolistore->debug_api); + //echo $url; + $request = $api->executeRequest($url, array(CURLOPT_CUSTOMREQUEST => 'GET')); + header('Content-type:image'); + print $request['response']; +} catch (PrestaShopWebserviceException $e) { + // Here we are dealing with errors + $trace = $e->getTrace(); + if ($trace[0]['args'][0] == 404) die('Bad ID'); + else if ($trace[0]['args'][0] == 401) die('Bad auth key'); + else die('Can not access to '.$conf->global->MAIN_MODULE_DOLISTORE_API_SRV); +} \ No newline at end of file diff --git a/htdocs/dolistore/class/PSWebServiceLibrary.class.php b/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php similarity index 96% rename from htdocs/dolistore/class/PSWebServiceLibrary.class.php rename to htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php index 8f55f6fd323..bb59fa93929 100644 --- a/htdocs/dolistore/class/PSWebServiceLibrary.class.php +++ b/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php @@ -45,8 +45,8 @@ class PrestaShopWebservice protected $version; /** @var array compatible versions of PrestaShop Webservice */ - const psCompatibleVersionsMin = '1.4.0.0'; - const psCompatibleVersionsMax = '1.6.99.99'; + const PSCOMPATIBLEVERSIONMIN = '1.4.0.0'; + const PSCOMPATIBLEVERSIONMAX = '1.6.99.99'; /** * PrestaShopWebservice constructor. Throw an exception when CURL is not installed/activated @@ -152,8 +152,8 @@ class PrestaShopWebservice { $this->version = $headerArray['PSWS-Version']; if ( - version_compare(PrestaShopWebservice::psCompatibleVersionsMin, $headerArray['PSWS-Version']) == 1 || - version_compare(PrestaShopWebservice::psCompatibleVersionsMax, $headerArray['PSWS-Version']) == -1 + version_compare(PrestaShopWebservice::PSCOMPATIBLEVERSIONMIN, $headerArray['PSWS-Version']) == 1 || + version_compare(PrestaShopWebservice::PSCOMPATIBLEVERSIONMAX, $headerArray['PSWS-Version']) == -1 ) throw new PrestaShopWebserviceException('This library is not compatible with this version of PrestaShop. Please upgrade/downgrade this library'); } @@ -218,8 +218,9 @@ class PrestaShopWebservice * 'resource' => Resource name
* 'postXml' => Full XML string to add resource

* Examples are given in the tutorial

- * @param array $options - * @return SimpleXMLElement status_code, response + * + * @param array $options Options + * @return SimpleXMLElement status_code, response */ public function add($options) { @@ -406,4 +407,7 @@ class PrestaShopWebservice /** * @package PrestaShopWebservice */ -class PrestaShopWebserviceException extends Exception { } \ No newline at end of file +class PrestaShopWebserviceException extends Exception +{ + +} diff --git a/htdocs/dolistore/class/dolistore.class.php b/htdocs/admin/dolistore/class/dolistore.class.php similarity index 95% rename from htdocs/dolistore/class/dolistore.class.php rename to htdocs/admin/dolistore/class/dolistore.class.php index 35900d66f7d..3b3abadd3e4 100644 --- a/htdocs/dolistore/class/dolistore.class.php +++ b/htdocs/admin/dolistore/class/dolistore.class.php @@ -1,308 +1,316 @@ -. - * - * This program is free software; you can redistribute it and/or modifyion 2.0 (the "License"); - * it under the terms of the GNU General Public License as published bypliance with the License. - * the Free Software Foundation; either version 3 of the License, or - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * or see http://www.gnu.org/ - */ -dol_include_once('/core/lib/admin.lib.php'); -dol_include_once('/dolistore/class/PSWebServiceLibrary.class.php'); - -class Dolistore extends DolistoreModel -{ - // params - public $start // beginning of pagination - , $end // end of pagination - , $per_page // pagination: display per page - , $categorie // the current categorie - , $search // the search keywords - // setups - , $url // the url of this page - , $shop_url // the url of the shop - , $vat_rate // the vat rate used in the shop (prices are provided without vat) - , $lang // the integer representing the lang in the store - , $debug_api; // usefull if no dialog - - function __construct($options = array('start' => 0, 'end' => 10, 'per_page' => 50, 'categorie' => 0)) - { - global $conf, $langs; - - $this->start = $options['start']; - $this->end = $options['end']; - $this->per_page = $options['per_page']; - $this->categorie = $options['categorie']; - $this->search = $options['search']; - - $this->url = dol_buildpath('/dolistore/index.php', 2); - $this->shop_url = 'https://www.dolistore.com/index.php?controller=product&id_product='; - $this->vat_rate = 1.2; // 20% de TVA - $this->debug_api = false; - - if ($this->end == 0) { - $this->end = $this->per_page; - } - - $lang = explode('_', $langs->defaultlang); - $lang = $lang[0]; - $lang_array = ['fr', 'en', 'es', 'it', 'de']; - if (!in_array($lang, $lang_array)) { - $lang = 'en'; - } - $this->lang = array_search($lang, $lang_array) + 1; // 1=fr 2=en ... - - try { - $this->api = new PrestaShopWebservice($conf->global->MAIN_MODULE_DOLISTORE_API_SRV, - $conf->global->MAIN_MODULE_DOLISTORE_API_KEY, $this->debug_api); - - // Here we set the option array for the Webservice : we want products resources - $opt = array(); - $opt['resource'] = 'products'; - // make a search to limit the id returned. - if ($this->search != '') { - $opt2 = array(); - $opt2['url'] = $conf->global->MAIN_MODULE_DOLISTORE_API_SRV.'/api/search?query='.$this->search.'&language='.$this->lang; - // Call - $xml = $this->api->get($opt2); - $products = array(); - foreach ($xml->products->children() as $product) { - $products[] = (int) $product['id']; - } - $opt['filter[id]'] = '['.implode('|', $products).']'; - } elseif ($this->categorie != 0) { - $opt2 = array(); - $opt2['resource'] = 'categories'; - $opt2['id'] = $this->categorie; - // Call - $xml = $this->api->get($opt2); - $products = array(); - foreach ($xml->category->associations->products->children() as $product) { - $products[] = (int) $product->id; - } - $opt['filter[id]'] = '['.implode('|', $products).']'; - } - $opt['display'] = '[id,name,id_default_image,id_category_default,reference,price,condition,show_price,date_add,date_upd,description_short,description,module_version,dolibarr_min,dolibarr_max]'; - $opt['sort'] = 'id_desc'; - $opt['filter[active]'] = '[1]'; - $opt['limit'] = "$this->start,$this->end"; - // Call - $xml = $this->api->get($opt); - $this->products = $xml->products->children(); - - - // Here we set the option array for the Webservice : we want categories resources - $opt = array(); - $opt['resource'] = 'categories'; - $opt['display'] = '[id,id_parent,nb_products_recursive,active,is_root_category,name,description]'; - $opt['sort'] = 'id_asc'; - // Call - $xml = $this->api->get($opt); - $this->categories = $xml->categories->children(); - } catch (PrestaShopWebserviceException $e) { - // Here we are dealing with errors - $trace = $e->getTrace(); - if ($trace[0]['args'][0] == 404) die('Bad ID'); - else if ($trace[0]['args'][0] == 401) die('Bad auth key'); - else die('Can not access to '.$conf->global->MAIN_MODULE_DOLISTORE_API_SRV); - } - } - - function get_previous_url() - { - $param_array = array(); - if ($this->start < $this->per_page) { - $sub = 0; - } else { - $sub = $this->per_page; - } - $param_array['start'] = $this->start - $sub; - $param_array['end'] = $this->end - $sub; - if ($this->categorie != 0) { - $param_array['categorie'] = $this->categorie; - } - $param = http_build_query($param_array); - return $this->url."?$param"; - } - - function get_next_url() - { - $param_array = array(); - if (count($this->products) < $this->per_page) { - $add = 0; - } else { - $add = $this->per_page; - } - $param_array['start'] = $this->start + $add; - $param_array['end'] = $this->end + $add; - if ($this->categorie != 0) { - $param_array['categorie'] = $this->categorie; - } - $param = http_build_query($param_array); - return $this->url."?$param"; - } - - function version_compare($v1, $v2) - { - $v1 = explode('.', $v1); - $v2 = explode('.', $v2); - $ret = 0; - $level = 0; - $count1 = count($v1); - $count2 = count($v2); - $maxcount = max($count1, $count2); - while ($level < $maxcount) { - $operande1 = isset($v1[$level]) ? $v1[$level] : 'x'; - $operande2 = isset($v2[$level]) ? $v2[$level] : 'x'; - $level++; - if (strtoupper($operande1) == 'X' || strtoupper($operande2) == 'X' || $operande1 == '*' || $operande2 == '*') { - break; - } - if ($operande1 < $operande2) { - $ret = -$level; - break; - } - if ($operande1 > $operande2) { - $ret = $level; - break; - } - } - //print join('.',$versionarray1).'('.count($versionarray1).') / '.join('.',$versionarray2).'('.count($versionarray2).') => '.$ret.'
'."\n"; - return $ret; - } -} - -class DolistoreModel -{ - - function get_categories($parent = 0) - { - if (!isset($this->categories)) die('not possible'); - if ($parent != 0) { - $html = '
    '; - } else { - $html = ''; - } - - for ($i = 0; $i < count($this->categories); $i++) { - $cat = $this->categories[$i]; - if ($cat->is_root_category == 1 && $parent == 0) { - $html .= '
  • '.$cat->name->language[$this->lang].' '.$cat->nb_products_recursive.'

    '; - $html .= self::get_categories($cat->id); - $html .= "
  • \n"; - } elseif (trim($cat->id_parent) == $parent && $cat->active == 1 && trim($cat->id_parent) != 0) { // si cat est de ce niveau - $select = ($cat->id == $this->categorie) ? ' selected' : ''; - $html .= '
  • '.$cat->name->language[$this->lang].' '.$cat->nb_products_recursive.''; - $html .= self::get_categories($cat->id); - $html .= "
  • \n"; - } else { - - } - } - - if ($html == '
      ') { - return ''; - } - if ($parent != 0) { - return $html.'
    '; - } else { - return $html; - } - } - - function get_products() - { - global $langs, $conf; - $html = ""; - $parity = "pair"; - $last_month = time() - (30 * 24 * 60 * 60); - foreach ($this->products as $product) { - $parity = ($parity == "impair") ? 'pair' : 'impair'; - - // check new product ? - $newapp = ''; - if ($last_month < strtotime($product->date_add)) { - $newapp .= ''.$langs->trans('New').' '; - } - - // check updated ? - if ($last_month < strtotime($product->date_upd) && $newapp == '') { - $newapp .= ''.$langs->trans('Updated').' '; - } - - // add image or default ? - if ($product->id_default_image != '') { - $image_url = dol_buildPath('/dolistore/ajax/image.php?id_product=', 2).$product->id.'&id_image='.$product->id_default_image; - $images = ''. - ''; - } else { - $images = ''; - } - - // free or pay ? - if ($product->price > 0) { - $price = '

    '.price(round((float) $product->price * $this->vat_rate, 2)).' €

    '; - $download_link = ''; - } else { - $price = $langs->trans('Free'); - $download_link = ''; - } - - //checking versions - if ($this->version_compare($product->dolibarr_min, DOL_VERSION) <= 0) { - if ($this->version_compare($product->dolibarr_max, DOL_VERSION) >= 0) { - //compatible - $version = ''.$langs->trans('CompatibleUpTo', $product->dolibarr_max, - $product->dolibarr_min, $product->dolibarr_max).''; - $compatible = ''; - } else { - //never compatible, module expired - $version = ''.$langs->trans('NotCompatible', DOL_VERSION, - $product->dolibarr_min, $product->dolibarr_max).''; - $compatible = 'NotCompatible'; - } - } else { - //need update - $version = ''.$langs->trans('CompatibleAfterUpdate', DOL_VERSION, - $product->dolibarr_min, $product->dolibarr_max).''; - $compatible = 'NotCompatible'; - } - - //output template - $html .= '
- - - - - - '; - } - return $html; - } - - function get_previous_link($text = '<<') - { - return "$text"; - } - - function get_next_link($text = '>>') - { - return "$text"; - } -} \ No newline at end of file +. + * + * This program is free software; you can redistribute it and/or modifyion 2.0 (the "License"); + * it under the terms of the GNU General Public License as published bypliance with the License. + * the Free Software Foundation; either version 3 of the License, or + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * or see http://www.gnu.org/ + */ + +include_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +include_once DOL_DOCUMENT_ROOT.'/admin/dolistore/class/PSWebServiceLibrary.class.php'; + +/** + * Class DolistoreModel + */ +class Dolistore extends DolistoreModel +{ + // params + public $start // beginning of pagination + , $end // end of pagination + , $per_page // pagination: display per page + , $categorie // the current categorie + , $search // the search keywords + // setups + , $url // the url of this page + , $shop_url // the url of the shop + , $vat_rate // the vat rate used in the shop (prices are provided without vat) + , $lang // the integer representing the lang in the store + , $debug_api; // usefull if no dialog + + function __construct($options = array('start' => 0, 'end' => 10, 'per_page' => 50, 'categorie' => 0)) + { + global $conf, $langs; + + $this->start = $options['start']; + $this->end = $options['end']; + $this->per_page = $options['per_page']; + $this->categorie = $options['categorie']; + $this->search = $options['search']; + + $this->url = DOL_URL_ROOT.'/admin/modules.php?mode=marketplace'; + $this->shop_url = 'https://www.dolistore.com/index.php?controller=product&id_product='; + $this->vat_rate = 1.2; // 20% de TVA + $this->debug_api = false; + + if ($this->end == 0) { + $this->end = $this->per_page; + } + + $lang = explode('_', $langs->defaultlang); + $lang = $lang[0]; + $lang_array = ['fr', 'en', 'es', 'it', 'de']; + if (!in_array($lang, $lang_array)) { + $lang = 'en'; + } + $this->lang = array_search($lang, $lang_array) + 1; // 1=fr 2=en ... + + try { + $this->api = new PrestaShopWebservice($conf->global->MAIN_MODULE_DOLISTORE_API_SRV, + $conf->global->MAIN_MODULE_DOLISTORE_API_KEY, $this->debug_api); + + // Here we set the option array for the Webservice : we want products resources + $opt = array(); + $opt['resource'] = 'products'; + // make a search to limit the id returned. + if ($this->search != '') { + $opt2 = array(); + $opt2['url'] = $conf->global->MAIN_MODULE_DOLISTORE_API_SRV.'/api/search?query='.$this->search.'&language='.$this->lang; + // Call + $xml = $this->api->get($opt2); + $products = array(); + foreach ($xml->products->children() as $product) { + $products[] = (int) $product['id']; + } + $opt['filter[id]'] = '['.implode('|', $products).']'; + } elseif ($this->categorie != 0) { + $opt2 = array(); + $opt2['resource'] = 'categories'; + $opt2['id'] = $this->categorie; + // Call + $xml = $this->api->get($opt2); + $products = array(); + foreach ($xml->category->associations->products->children() as $product) { + $products[] = (int) $product->id; + } + $opt['filter[id]'] = '['.implode('|', $products).']'; + } + $opt['display'] = '[id,name,id_default_image,id_category_default,reference,price,condition,show_price,date_add,date_upd,description_short,description,module_version,dolibarr_min,dolibarr_max]'; + $opt['sort'] = 'id_desc'; + $opt['filter[active]'] = '[1]'; + $opt['limit'] = "$this->start,$this->end"; + // Call + $xml = $this->api->get($opt); + $this->products = $xml->products->children(); + + + // Here we set the option array for the Webservice : we want categories resources + $opt = array(); + $opt['resource'] = 'categories'; + $opt['display'] = '[id,id_parent,nb_products_recursive,active,is_root_category,name,description]'; + $opt['sort'] = 'id_asc'; + // Call + $xml = $this->api->get($opt); + $this->categories = $xml->categories->children(); + } catch (PrestaShopWebserviceException $e) { + // Here we are dealing with errors + $trace = $e->getTrace(); + if ($trace[0]['args'][0] == 404) die('Bad ID'); + else if ($trace[0]['args'][0] == 401) die('Bad auth key'); + else die('Can not access to '.$conf->global->MAIN_MODULE_DOLISTORE_API_SRV); + } + } + + function get_previous_url() + { + $param_array = array(); + if ($this->start < $this->per_page) { + $sub = 0; + } else { + $sub = $this->per_page; + } + $param_array['start'] = $this->start - $sub; + $param_array['end'] = $this->end - $sub; + if ($this->categorie != 0) { + $param_array['categorie'] = $this->categorie; + } + $param = http_build_query($param_array); + return $this->url."&".$param; + } + + function get_next_url() + { + $param_array = array(); + if (count($this->products) < $this->per_page) { + $add = 0; + } else { + $add = $this->per_page; + } + $param_array['start'] = $this->start + $add; + $param_array['end'] = $this->end + $add; + if ($this->categorie != 0) { + $param_array['categorie'] = $this->categorie; + } + $param = http_build_query($param_array); + return $this->url."&".$param; + } + + function version_compare($v1, $v2) + { + $v1 = explode('.', $v1); + $v2 = explode('.', $v2); + $ret = 0; + $level = 0; + $count1 = count($v1); + $count2 = count($v2); + $maxcount = max($count1, $count2); + while ($level < $maxcount) { + $operande1 = isset($v1[$level]) ? $v1[$level] : 'x'; + $operande2 = isset($v2[$level]) ? $v2[$level] : 'x'; + $level++; + if (strtoupper($operande1) == 'X' || strtoupper($operande2) == 'X' || $operande1 == '*' || $operande2 == '*') { + break; + } + if ($operande1 < $operande2) { + $ret = -$level; + break; + } + if ($operande1 > $operande2) { + $ret = $level; + break; + } + } + //print join('.',$versionarray1).'('.count($versionarray1).') / '.join('.',$versionarray2).'('.count($versionarray2).') => '.$ret.'
'."\n"; + return $ret; + } +} + + +/** + * Class DolistoreModel + */ +class DolistoreModel +{ + + function get_categories($parent = 0) + { + if (!isset($this->categories)) die('not possible'); + if ($parent != 0) { + $html = '
    '; + } else { + $html = ''; + } + + for ($i = 0; $i < count($this->categories); $i++) { + $cat = $this->categories[$i]; + if ($cat->is_root_category == 1 && $parent == 0) { + $html .= '
  • '.$cat->name->language[$this->lang].' '.$cat->nb_products_recursive.'

    '; + $html .= self::get_categories($cat->id); + $html .= "
  • \n"; + } elseif (trim($cat->id_parent) == $parent && $cat->active == 1 && trim($cat->id_parent) != 0) { // si cat est de ce niveau + $select = ($cat->id == $this->categorie) ? ' selected' : ''; + $html .= '
  • '.$cat->name->language[$this->lang].' '.$cat->nb_products_recursive.''; + $html .= self::get_categories($cat->id); + $html .= "
  • \n"; + } else { + + } + } + + if ($html == '
      ') { + return ''; + } + if ($parent != 0) { + return $html.'
    '; + } else { + return $html; + } + } + + function get_products() + { + global $langs, $conf; + $html = ""; + $parity = "pair"; + $last_month = time() - (30 * 24 * 60 * 60); + foreach ($this->products as $product) { + $parity = ($parity == "impair") ? 'pair' : 'impair'; + + // check new product ? + $newapp = ''; + if ($last_month < strtotime($product->date_add)) { + $newapp .= ''.$langs->trans('New').' '; + } + + // check updated ? + if ($last_month < strtotime($product->date_upd) && $newapp == '') { + $newapp .= ''.$langs->trans('Updated').' '; + } + + // add image or default ? + if ($product->id_default_image != '') { + $image_url = dol_buildPath('/dolistore/ajax/image.php?id_product=', 2).$product->id.'&id_image='.$product->id_default_image; + $images = ''. + ''; + } else { + $images = ''; + } + + // free or pay ? + if ($product->price > 0) { + $price = '

    '.price(round((float) $product->price * $this->vat_rate, 2)).' €

    '; + $download_link = ''; + } else { + $price = $langs->trans('Free'); + $download_link = ''; + } + + //checking versions + if ($this->version_compare($product->dolibarr_min, DOL_VERSION) <= 0) { + if ($this->version_compare($product->dolibarr_max, DOL_VERSION) >= 0) { + //compatible + $version = ''.$langs->trans('CompatibleUpTo', $product->dolibarr_max, + $product->dolibarr_min, $product->dolibarr_max).''; + $compatible = ''; + } else { + //never compatible, module expired + $version = ''.$langs->trans('NotCompatible', DOL_VERSION, + $product->dolibarr_min, $product->dolibarr_max).''; + $compatible = 'NotCompatible'; + } + } else { + //need update + $version = ''.$langs->trans('CompatibleAfterUpdate', DOL_VERSION, + $product->dolibarr_min, $product->dolibarr_max).''; + $compatible = 'NotCompatible'; + } + + //output template + $html .= '
+ + + + + + '; + } + return $html; + } + + function get_previous_link($text = '<<') + { + return "$text"; + } + + function get_next_link($text = '>>') + { + return "$text"; + } +} diff --git a/htdocs/dolistore/class/init.php b/htdocs/admin/dolistore/class/init.php similarity index 100% rename from htdocs/dolistore/class/init.php rename to htdocs/admin/dolistore/class/init.php diff --git a/htdocs/dolistore/css/dolistore.css b/htdocs/admin/dolistore/css/dolistore.css similarity index 100% rename from htdocs/dolistore/css/dolistore.css rename to htdocs/admin/dolistore/css/dolistore.css diff --git a/htdocs/dolistore/img/Download-128.png b/htdocs/admin/dolistore/img/Download-128.png similarity index 100% rename from htdocs/dolistore/img/Download-128.png rename to htdocs/admin/dolistore/img/Download-128.png diff --git a/htdocs/dolistore/img/NoImageAvailable.png b/htdocs/admin/dolistore/img/NoImageAvailable.png similarity index 100% rename from htdocs/dolistore/img/NoImageAvailable.png rename to htdocs/admin/dolistore/img/NoImageAvailable.png diff --git a/htdocs/dolistore/img/compatible.png b/htdocs/admin/dolistore/img/compatible.png similarity index 100% rename from htdocs/dolistore/img/compatible.png rename to htdocs/admin/dolistore/img/compatible.png diff --git a/htdocs/dolistore/img/dolistore.png b/htdocs/admin/dolistore/img/dolistore.png similarity index 100% rename from htdocs/dolistore/img/dolistore.png rename to htdocs/admin/dolistore/img/dolistore.png diff --git a/htdocs/dolistore/img/follow.png b/htdocs/admin/dolistore/img/follow.png similarity index 100% rename from htdocs/dolistore/img/follow.png rename to htdocs/admin/dolistore/img/follow.png diff --git a/htdocs/dolistore/img/object_dolistore.png b/htdocs/admin/dolistore/img/object_dolistore.png similarity index 100% rename from htdocs/dolistore/img/object_dolistore.png rename to htdocs/admin/dolistore/img/object_dolistore.png diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index a59d6fca3bb..40beaeadec2 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -32,6 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/admin/dolistore/class/dolistore.class.php'; $langs->load("errors"); $langs->load("admin"); @@ -46,6 +47,17 @@ $search_status=GETPOST('search_status','alpha'); $search_nature=GETPOST('search_nature','alpha'); $search_version=GETPOST('search_version','alpha'); + +// For dolistore search +$options = array(); +$options['per_page'] = 20; +$options['categorie'] = GETPOST('categorie', 'int') + 0; +$options['start'] = GETPOST('start', 'int') + 0; +$options['end'] = GETPOST('end', 'int') + 0; +$options['search'] = GETPOST('search_keyword', 'alpha'); +$dolistore = new Dolistore($options); + + if (! $user->admin) accessforbidden(); @@ -240,6 +252,11 @@ if ($action == 'reset' && $user->admin) * View */ +$form = new Form($db); + +$morejs = array("/admin/dolistore/js/dolistore.js.php"); +$morecss = array("/admin/dolistore/css/dolistore.css"); + // Set dir where external modules are installed if (! dol_is_dir($dirins)) { @@ -247,10 +264,8 @@ if (! dol_is_dir($dirins)) } $dirins_ok=(dol_is_dir($dirins)); -$form = new Form($db); - $help_url='EN:First_setup|FR:Premiers_paramétrages|ES:Primeras_configuraciones'; -llxHeader('',$langs->trans("Setup"),$help_url); +llxHeader('',$langs->trans("Setup"),$help_url, '', '', '', $morejs, $morecss, 0, 0); $arrayofnatures=array('core'=>$langs->transnoentitiesnoconv("Core"), 'external'=>$langs->transnoentitiesnoconv("External").' - '.$langs->trans("AllPublishers")); $arrayofwarnings=array(); // Array of warning each module want to show when activated @@ -423,24 +438,9 @@ print load_fiche_titre($langs->trans("ModulesSetup"),$moreinfo,'title_setup'); if ($mode=='common') print ''.$langs->trans("ModulesDesc")."
\n"; if ($mode=='marketplace') print ''.$langs->trans("ModulesMarketPlaceDesc")."
\n"; if ($mode=='deploy') print ''.$langs->trans("ModulesDeployDesc", $langs->transnoentitiesnoconv("AvailableModules"))."
\n"; +if ($mode=='develop') print ''.$langs->trans("ModulesDevelopDesc")."
\n"; - -$h = 0; - -$head[$h][0] = DOL_URL_ROOT."/admin/modules.php?mode=common"; -$head[$h][1] = $langs->trans("AvailableModules"); -$head[$h][2] = 'common'; -$h++; - -$head[$h][0] = DOL_URL_ROOT."/admin/modules.php?mode=marketplace"; -$head[$h][1] = $langs->trans("ModulesMarketPlaces"); -$head[$h][2] = 'marketplace'; -$h++; - -$head[$h][0] = DOL_URL_ROOT."/admin/modules.php?mode=deploy"; -$head[$h][1] = $langs->trans("AddExtensionThemeModuleOrOther"); -$head[$h][2] = 'deploy'; -$h++; +$head = modules_prepare_head(); print "
\n"; @@ -817,7 +817,6 @@ if ($mode == 'marketplace') print ''; print ''; - print "\n"; $url='https://www.dolistore.com'; print ''; @@ -825,17 +824,57 @@ if ($mode == 'marketplace') print ''; print ''; - - print "\n"; - $url='https://partners.dolibarr.org'; - 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 '

'+text2; @@ -951,7 +952,7 @@ function copyToClipboard(text,text2) /** * Show a popup HTML page. Use the "window.open" function. - * + * * @param string url Url * @param string title Title of popup * @return boolean False @@ -983,7 +984,7 @@ function document_preview(file, type, title) { var ValidImageTypes = ["image/gif", "image/jpeg", "image/png"]; console.log("document_preview A click was done. file="+file+", type="+type+", title="+title); - + if ($.inArray(type, ValidImageTypes) < 0) { var width='85%'; var object_width='100%'; @@ -1034,13 +1035,13 @@ function document_preview(file, type, title) } /* - * Provide a function to get an URL GET parameter in javascript - * + * Provide a function to get an URL GET parameter in javascript + * * @param string name Name of parameter * @param mixed valueifnotfound Value if not found * @return string Value */ -function getParameterByName(name, valueifnotfound) +function getParameterByName(name, valueifnotfound) { name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"), @@ -1098,7 +1099,7 @@ function getParameterByName(name, valueifnotfound) } })(); -// Another solution, easier, to build a javascript rounding function +// Another solution, easier, to build a javascript rounding function function dolroundjs(number, decimals) { return +(Math.round(number + "e+" + decimals) + "e-" + decimals); } @@ -1146,10 +1147,10 @@ function price2numjs(amount) { amount = amount.replace(dec, '.'); //console.log("amount before="+amount+" rouding="+rounding) var res = Math.round10(amount, - rounding); - // Other solution is + // Other solution is // var res = dolroundjs(amount, rounding) console.log("res="+res) return res; } - + diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index c100583dd76..f2f0aba9579 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1318,7 +1318,7 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs // Add datepicker default options if (! defined('DISABLE_DATE_PICKER')) { - print ''."\n"; + print ''."\n"; } // JS forced by modules (relative url starting with /) From 1fe23e3fec26f6fcbbd512c75e6aa3fda31b6405 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 22 Aug 2017 09:24:26 +0200 Subject: [PATCH 162/183] Move french text into english --- .../install/mysql/data/llx_c_payment_term.sql | 29 +++++++++---------- htdocs/langs/en_US/bills.lang | 2 +- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/htdocs/install/mysql/data/llx_c_payment_term.sql b/htdocs/install/mysql/data/llx_c_payment_term.sql index c7fd08a62d6..852ff9db4cb 100644 --- a/htdocs/install/mysql/data/llx_c_payment_term.sql +++ b/htdocs/install/mysql/data/llx_c_payment_term.sql @@ -23,21 +23,20 @@ -- -- --- Ne pas placer de commentaire en fin de ligne, ce fichier est parsé lors --- de l'install et tous les sigles '--' sont supprimés. +-- Do not include comments at end of line, this file is parsed during install and string '--' are removed. -- -insert into llx_c_payment_term(rowid, code, sortorder, active, libelle, libelle_facture, type_cdr, nbjour) values (1,'RECEP', 1,1, 'Due Upon Receipt','Due Upon Receipt',0,1); -insert into llx_c_payment_term(rowid, code, sortorder, active, libelle, libelle_facture, type_cdr, nbjour) values (2,'30D', 2,1, '30 jours','Réglement à 30 jours',0,30); -insert into llx_c_payment_term(rowid, code, sortorder, active, libelle, libelle_facture, type_cdr, nbjour) values (3,'30DENDMONTH', 3,1, '30 jours fin de mois','Réglement à 30 jours fin de mois',1,30); -insert into llx_c_payment_term(rowid, code, sortorder, active, libelle, libelle_facture, type_cdr, nbjour) values (4,'60D', 4,1, '60 jours','Réglement à 60 jours',0,60); -insert into llx_c_payment_term(rowid, code, sortorder, active, libelle, libelle_facture, type_cdr, nbjour) values (5,'60DENDMONTH', 5,1, '60 jours fin de mois','Réglement à 60 jours fin de mois',1,60); -insert into llx_c_payment_term(rowid, code, sortorder, active, libelle, libelle_facture, type_cdr, nbjour) values (6,'PT_ORDER', 6,1, 'A réception de commande','A réception de commande',0,1); -insert into llx_c_payment_term(rowid, code, sortorder, active, libelle, libelle_facture, type_cdr, nbjour) values (7,'PT_DELIVERY', 7,1, 'Livraison','Règlement à la livraison',0,1); -insert into llx_c_payment_term(rowid, code, sortorder, active, libelle, libelle_facture, type_cdr, nbjour) values (8,'PT_5050', 8,1, '50 et 50','Règlement 50% à la commande, 50% à la livraison',0,1); +insert into llx_c_payment_term(rowid, code, sortorder, active, libelle, libelle_facture, type_cdr, nbjour) values (1 ,'RECEP', 1,1, 'Due upon receipt','Due upon receipt',0,1); +insert into llx_c_payment_term(rowid, code, sortorder, active, libelle, libelle_facture, type_cdr, nbjour) values (2 ,'30D', 2,1, '30 days','Due in 30 days',0,30); +insert into llx_c_payment_term(rowid, code, sortorder, active, libelle, libelle_facture, type_cdr, nbjour) values (3 ,'30DENDMONTH', 3,1, '30 days end of month','Due in 30 days, end of month',1,30); +insert into llx_c_payment_term(rowid, code, sortorder, active, libelle, libelle_facture, type_cdr, nbjour) values (4 ,'60D', 4,1, '60 days','Due in 60 days, end of month',0,60); +insert into llx_c_payment_term(rowid, code, sortorder, active, libelle, libelle_facture, type_cdr, nbjour) values (5 ,'60DENDMONTH', 5,1, '60 days end of month','Due in 60 days, end of month',1,60); +insert into llx_c_payment_term(rowid, code, sortorder, active, libelle, libelle_facture, type_cdr, nbjour) values (6 ,'PT_ORDER', 6,1, 'Due on order','Due on order',0,1); +insert into llx_c_payment_term(rowid, code, sortorder, active, libelle, libelle_facture, type_cdr, nbjour) values (7 ,'PT_DELIVERY', 7,1, 'Due on delivery','Due on delivery',0,1); +insert into llx_c_payment_term(rowid, code, sortorder, active, libelle, libelle_facture, type_cdr, nbjour) values (8 ,'PT_5050', 8,1, '50 and 50','50% on order, 50% on delivery',0,1); --- add additional payment terms often needed in Austria -insert into llx_c_payment_term(rowid, code, sortorder, active, libelle, libelle_facture, type_cdr, nbjour) values (9,'10D', 9,1, '10 jours','Réglement à 10 jours',0,10); -insert into llx_c_payment_term(rowid, code, sortorder, active, libelle, libelle_facture, type_cdr, nbjour) values (10,'10DENDMONTH', 10,1, '10 jours fin de mois','Réglement à 10 jours fin de mois',1,10); -insert into llx_c_payment_term(rowid, code, sortorder, active, libelle, libelle_facture, type_cdr, nbjour) values (11,'14D', 11,1, '14 jours','Réglement à 14 jours',0,14); -insert into llx_c_payment_term(rowid, code, sortorder, active, libelle, libelle_facture, type_cdr, nbjour) values (12,'14DENDMONTH', 12,1, '14 jours fin de mois','Réglement à 14 jours fin de mois',1,14); +-- Add additional payment terms often needed in Austria +insert into llx_c_payment_term(rowid, code, sortorder, active, libelle, libelle_facture, type_cdr, nbjour) values (9 ,'10D', 9,1, '10 days','Due in 10 days',0,10); +insert into llx_c_payment_term(rowid, code, sortorder, active, libelle, libelle_facture, type_cdr, nbjour) values (10,'10DENDMONTH', 10,1, '10 days end of month','Due in 10 days, end of month',1,10); +insert into llx_c_payment_term(rowid, code, sortorder, active, libelle, libelle_facture, type_cdr, nbjour) values (11,'14D', 11,1, '14 days','Due in 14 days',0,14); +insert into llx_c_payment_term(rowid, code, sortorder, active, libelle, libelle_facture, type_cdr, nbjour) values (12,'14DENDMONTH', 12,1, '14 days end of month','Due in 14 days, end of month',1,14); diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index 03ddb1f958e..44cb0143a1e 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -229,7 +229,7 @@ SendReminderBillByMail=Send reminder by email RelatedCommercialProposals=Related commercial proposals RelatedRecurringCustomerInvoices=Related recurring customer invoices MenuToValid=To valid -DateMaxPayment=Payment due before +DateMaxPayment=Payment due on DateInvoice=Invoice date DatePointOfTax=Point of tax NoInvoice=No invoice From e86d3d7905fd55be10c9cdc1e493cf628408e334 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 22 Aug 2017 09:47:33 +0200 Subject: [PATCH 163/183] Fix: Travis error "Missing parameter name" --- htdocs/core/lib/files.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 42324ec2e3b..3fe6d5887f4 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -288,8 +288,8 @@ function dol_dir_list_in_database($path, $filter="", $excludefilter=null, $sortc * Complete $filearray with data from database. * This will call doldir_list_indatabase to complate filearray. * - * @param $filearray Array of files get using dol_dir_list - * @param $relativedir Relative dir from DOL_DATA_ROOT + * @param array $filearray Array of files get using dol_dir_list + * @param string $relativedir Relative dir from DOL_DATA_ROOT * @return void */ function completeFileArrayWithDatabaseInfo(&$filearray, $relativedir) From 9be342bd2532c8f6f5ff34fb2c5ab096d05cb227 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 22 Aug 2017 10:02:45 +0200 Subject: [PATCH 164/183] Fix missing $form --- htdocs/accountancy/admin/fiscalyear_card.php | 4 ++-- htdocs/compta/facture/info.php | 2 ++ htdocs/compta/sociales/info.php | 2 ++ htdocs/contrat/info.php | 6 ++++-- htdocs/fichinter/info.php | 2 ++ htdocs/fourn/facture/info.php | 2 ++ htdocs/loan/info.php | 2 ++ htdocs/supplier_proposal/info.php | 12 +++++++----- 8 files changed, 23 insertions(+), 9 deletions(-) diff --git a/htdocs/accountancy/admin/fiscalyear_card.php b/htdocs/accountancy/admin/fiscalyear_card.php index fa817942a54..420246411c8 100644 --- a/htdocs/accountancy/admin/fiscalyear_card.php +++ b/htdocs/accountancy/admin/fiscalyear_card.php @@ -145,12 +145,12 @@ else if ($action == 'update') { * View */ +$form = new Form($db); + $title = $langs->trans("Fiscalyear") . " - " . $langs->trans("Card"); $helpurl = ""; llxHeader("",$title,$helpurl); -$form = new Form($db); - if ($action == 'create') { print load_fiche_titre($langs->trans("NewFiscalYear")); diff --git a/htdocs/compta/facture/info.php b/htdocs/compta/facture/info.php index 56f89a83154..fd43cc42982 100644 --- a/htdocs/compta/facture/info.php +++ b/htdocs/compta/facture/info.php @@ -39,6 +39,8 @@ $ref=GETPOST("ref",'alpha'); * View */ +$form = new Form($db); + $title = $langs->trans('InvoiceCustomer') . " - " . $langs->trans('Info'); $helpurl = "EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes"; llxHeader('', $title, $helpurl); diff --git a/htdocs/compta/sociales/info.php b/htdocs/compta/sociales/info.php index 91334134a2c..b67c844a7b9 100644 --- a/htdocs/compta/sociales/info.php +++ b/htdocs/compta/sociales/info.php @@ -60,6 +60,8 @@ if ($action == 'setlib' && $user->rights->tax->charges->creer) * View */ +$form = new Form($db); + if (! empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } $title = $langs->trans("SocialContribution") . ' - ' . $langs->trans("Info"); diff --git a/htdocs/contrat/info.php b/htdocs/contrat/info.php index 35cca237b21..95ab0b9ca25 100644 --- a/htdocs/contrat/info.php +++ b/htdocs/contrat/info.php @@ -39,8 +39,10 @@ $result = restrictedArea($user, 'contrat', $id, ''); /* -* View -*/ + * View + */ + +$form = new Form($db); llxHeader('',$langs->trans("Contract"),""); diff --git a/htdocs/fichinter/info.php b/htdocs/fichinter/info.php index 87533644893..a32cda9bb57 100644 --- a/htdocs/fichinter/info.php +++ b/htdocs/fichinter/info.php @@ -52,6 +52,8 @@ if (! $object->fetch($id, $ref) > 0) * View */ +$form = new Form($db); + llxHeader('',$langs->trans("Intervention")); $object->fetch_thirdparty(); diff --git a/htdocs/fourn/facture/info.php b/htdocs/fourn/facture/info.php index f5ab9164042..73d6b94a0d6 100644 --- a/htdocs/fourn/facture/info.php +++ b/htdocs/fourn/facture/info.php @@ -46,6 +46,8 @@ $object = new FactureFournisseur($db); * View */ +$form = new Form($db); + $title = $langs->trans('SupplierInvoice') . " - " . $langs->trans('Info'); $helpurl = "EN:Module_Suppliers_Invoices|FR:Module_Fournisseurs_Factures|ES:Módulo_Facturas_de_proveedores"; llxHeader('', $title, $helpurl); diff --git a/htdocs/loan/info.php b/htdocs/loan/info.php index 96da6182da6..64987afa8b5 100644 --- a/htdocs/loan/info.php +++ b/htdocs/loan/info.php @@ -43,6 +43,8 @@ $result = restrictedArea($user, 'loan', $id, '',''); * View */ +$form = new Form($db); + $title = $langs->trans("Loan") . ' - ' . $langs->trans("Info"); $help_url = 'EN:Module_Loan|FR:Module_Emprunt'; llxHeader("",$title,$help_url); diff --git a/htdocs/supplier_proposal/info.php b/htdocs/supplier_proposal/info.php index 718b79ce4ae..8cee304e3bb 100644 --- a/htdocs/supplier_proposal/info.php +++ b/htdocs/supplier_proposal/info.php @@ -43,6 +43,8 @@ $result = restrictedArea($user, 'supplier_proposal', $id); * View */ +$form = new Form($db); + llxHeader('',$langs->trans('CommRequest'),'EN:Ask_Price_Supplier|FR:Demande_de_prix_fournisseur'); $object = new SupplierProposal($db); @@ -57,8 +59,8 @@ dol_fiche_head($head, 'info', $langs->trans('CommRequest'), -1, 'supplier_propos // Supplier proposal card $linkback = '' . $langs->trans("BackToList") . ''; - - + + $morehtmlref='
'; // Ref supplier //$morehtmlref.=$form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->fournisseur->commande->creer, 'string', '', 0, 1); @@ -99,11 +101,11 @@ if (! empty($conf->projet->enabled)) } } $morehtmlref.='
'; - - + + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); - + print '
'; print '
'; From 7c3640a4c344e06e4a6210605a5660f4db7dbf1d Mon Sep 17 00:00:00 2001 From: BENKE Charlene Date: Sat, 19 Aug 2017 13:26:50 +0200 Subject: [PATCH 165/183] Bad ojbject for extrafields https://www.dolibarr.fr/forum/527-bugs-sur-la-version-stable-courante/59536-extrafields-commande-dans-expedition --- htdocs/expedition/card.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 6c93166c063..f15c091263e 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -765,7 +765,7 @@ if ($action == 'create') print "
".$langs->trans("DeliveryMethod")."'; $expe->fetch_delivery_methods(); - print $form->selectarray("shipping_method_id",$expe->meths,GETPOST('shipping_method_id','int'),1,0,0,"",1); + print $form->selectarray("shipping_method_id", $expe->meths, GETPOST('shipping_method_id','int'),1,0,0,"",1); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); print "
'.$newapp.$images.'

'.$product->name->language[$this->lang].'Details' - .'
'.$version.'

- '.dol_print_date(strtotime($product->date_upd)).' - '.$langs->trans('Référence').': '.$product->reference.' - '.$langs->trans('Id').': '.$product->id.'

'.$product->description_short->language[$this->lang].'
'.$price.''.$download_link.'
'.$newapp.$images.'

'.$product->name->language[$this->lang].'Details' + .'
'.$version.'

+ '.dol_print_date(strtotime($product->date_upd)).' - '.$langs->trans('Référence').': '.$product->reference.' - '.$langs->trans('Id').': '.$product->id.'

'.$product->description_short->language[$this->lang].'
'.$price.''.$download_link.'
'.$langs->trans("URL").'
'.$url.'
'.$langs->trans("DoliPartnersDesc").''.$url.'
\n"; dol_fiche_end(); + + print '
'; + + if ($conf->global->MAIN_FEATURES_LEVEL >= 1) + { + print ''.$langs->trans('DOLISTOREdescriptionLong').''; + + + ?> +

+ +
+ + +
trans('Mot-cle') ?>: +
+
+


+ +
+
+
    + get_categories(); ?> +
+
+
+ + + + + + + + get_products($categorie); ?> + + + + + + +
get_previous_link() ?> get_next_link() ?> trans('AchatTelechargement') ?>
get_previous_link() ?> get_next_link() ?> trans('AchatTelechargement') ?>
+
+ + \n"; + print "
'.$langs->trans("Logo").''.$langs->trans("DevelopYourModuleDesc").''.$langs->trans("URL").'
'.$langs->trans("DoliPartnersDesc").''.$url.'
\n"; + + dol_fiche_end(); +} + + + llxFooter(); $db->close(); diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 77c24ff4109..15a17feaea8 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -579,6 +579,9 @@ class Conf $conf->global->AGENDA_DEFAULT_FILTER_TYPE='0'; // 'AC_NON_AUTO' does not exists when AGENDA_DEFAULT_FILTER_TYPE is not on. } + $conf->global->MAIN_MODULE_DOLISTORE_API_SRV='https://www.dolistore.com'; + $conf->global->MAIN_MODULE_DOLISTORE_API_KEY='dolistorecatalogpublickey1234567'; + // For backward compatibility if (isset($this->product)) $this->produit=$this->product; if (isset($this->facture)) $this->invoice=$this->facture; diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index 2f604a5c702..d2c466287ff 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -532,6 +532,43 @@ function dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $not } + + +/** + * Prepare array with list of tabs + * + * @return array Array of tabs to show + */ +function modules_prepare_head() +{ + global $langs, $conf, $user; + $h = 0; + $head = array(); + + $head[$h][0] = DOL_URL_ROOT."/admin/modules.php?mode=common"; + $head[$h][1] = $langs->trans("AvailableModules"); + $head[$h][2] = 'common'; + $h++; + + $head[$h][0] = DOL_URL_ROOT."/admin/modules.php?mode=marketplace"; + $head[$h][1] = $langs->trans("ModulesMarketPlaces"); + $head[$h][2] = 'marketplace'; + $h++; + + $head[$h][0] = DOL_URL_ROOT."/admin/modules.php?mode=deploy"; + $head[$h][1] = $langs->trans("AddExtensionThemeModuleOrOther"); + $head[$h][2] = 'deploy'; + $h++; + + $head[$h][0] = DOL_URL_ROOT."/admin/modules.php?mode=develop"; + $head[$h][1] = $langs->trans("ModulesDevelopYourModule"); + $head[$h][2] = 'develop'; + $h++; + + return $head; +} + + /** * Prepare array with list of tabs * @@ -564,7 +601,7 @@ function security_prepare_head() $head[$h][2] = 'filedownload'; $h++; */ - + $head[$h][0] = DOL_URL_ROOT."/admin/proxy.php"; $head[$h][1] = $langs->trans("ExternalAccess"); $head[$h][2] = 'proxy'; diff --git a/htdocs/dolistore/core/modules/modDolistore.class.php b/htdocs/dolistore/core/modules/modDolistore.class.php deleted file mode 100644 index a582b93a038..00000000000 --- a/htdocs/dolistore/core/modules/modDolistore.class.php +++ /dev/null @@ -1,159 +0,0 @@ -. - * - * 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 . - * - * - * Classe de description et activation du module DOLISTORE - */ - - -include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php'; - -class modDolistore extends DolibarrModules -{ - - /** - * Constructor. Define names, constants, directories, boxes, permissions - * - * @param DoliDB $db Database handler - */ - function __construct($db) - { - global $conf, $langs; - - $this->db = $db; - $this->numero = 66666; - - - // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) - $this->name = /* $langs->trans( */preg_replace('/^mod/i', '', get_class($this))/* ) */; - - $this->boxes = array(); - - - $this->description = $langs->trans("DOLISTOREdescription"); - - $this->descriptionlong = $langs->trans("DOLISTOREdescriptionLong"); - - $this->family = "interface"; - - $this->module_position = 1; - $this->version = 'dolibarr'; - $this->picto = 'dolistore@dolistore'; - $this->special=1; - $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - - // Data directories to create when module is enabled - $this->dirs = array(); - - // Dependances - $this->depends = array(); - $this->requiredby = array(); - $this->langfiles = array('dolistore@dolistore'); - - // Config pages - //$this->config_page_url = array("index.php?page=config@dolistore"); - - - - $this->module_parts = array( - 'triggers' => 0, - // Set this to 1 if module overwrite template dir (core/tpl) - 'tpl' => 0, - ); - - - - - - // Main menu entries - $r = 0; - - $this->menu[$r] = array( - //'fk_menu' => -1, // Put 0 if this is a top menu - 'fk_menu' => 'fk_mainmenu=home,fk_leftmenu=setup', - 'type' => 'left', // This is a left menu entry - 'titre' => 'DOLISTOREMENU', - 'mainmenu' => 'home', - 'leftmenu' => 'setup', - 'url' => '/dolistore/index.php?mainmenu=home&leftmenu=setup', - 'langs' => 'dolistore@dolistore', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. - 'position' => 1, - 'enabled' => '$leftmenu=="setup" && $conf->dolistore->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. - //'perms' => '$user->rights->edi->message->view', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules - 'perms' => '', - 'target' => '', - 'user' => 0); // 0=Menu for internal users, 1=external users, 2=both - - $r++; - - // Constantes - $this->const = array(); - - - $r = 0; - $this->const[$r][0] = 'MAIN_MODULE_'.strtoupper($this->name).'_API_SRV'; - $this->const[$r][1] = "chaine"; - $this->const[$r][2] = "https://www.dolistore.com"; - $this->const[$r][3] = "Server URL"; - $this->const[$r][4] = 0; - $this->const[$r][5] = 1; // supprime la constante à la désactivation du module - $r++; - - $this->const[$r][0] = 'MAIN_MODULE_'.strtoupper($this->name).'_API_KEY'; - $this->const[$r][1] = "chaine"; - $this->const[$r][2] = "dolistorecatalogpublickey1234567"; - $this->const[$r][3] = "API key to authenticate"; - $this->const[$r][4] = 0; - $this->const[$r][5] = 1; // supprime la constante à la désactivation du module - $r++; - - } - - /** - * Function called when module is enabled. - * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. - * It also creates data directories - * - * @param string $options Options when enabling module ('', 'noboxes') - * @return int 1 if OK, 0 if KO - */ - function init($options = '') - { - global $conf; - - $this->remove($options); - - $sql = array(); - - return $this->_init($sql, $options); - } - - /** - * Function called when module is disabled. - * Remove from database constants, boxes and permissions from Dolibarr database. - * Data directories are not deleted - * - * @param string $options Options when enabling module ('', 'noboxes') - * @return int 1 if OK, 0 if KO - */ - function remove($options = '') - { - $sql = array(); - - return $this->_remove($sql, $options); - } -} \ No newline at end of file diff --git a/htdocs/dolistore/index.php b/htdocs/dolistore/index.php deleted file mode 100644 index 1295801b436..00000000000 --- a/htdocs/dolistore/index.php +++ /dev/null @@ -1,115 +0,0 @@ -. - * - * This program is free software; you can redistribute it and/or modifyion 2.0 (the "License"); - * it under the terms of the GNU General Public License as published bypliance with the License. - * the Free Software Foundation; either version 3 of the License, or - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * or see http://www.gnu.org/ - */ - -if (!defined('REQUIRE_JQUERY_BLOCKUI')) define('REQUIRE_JQUERY_BLOCKUI', 1); -/** - * \file htdocs/commande/info.php - * \ingroup commande - * \brief Page des informations d'une commande - */ -$res = 0; -if (!$res && file_exists("../main.inc.php")) $res = @include("../main.inc.php"); -if (!$res && file_exists("../../main.inc.php")) $res = @include("../../main.inc.php"); -if (!$res && file_exists("../../../main.inc.php")) $res = @include("../../../main.inc.php"); -if (!$res && file_exists("../../../../main.inc.php")) $res = @include("../../../../main.inc.php"); -if (!$res && file_exists("../../../dolibarr/htdocs/main.inc.php")) - $res = @include("../../../dolibarr/htdocs/main.inc.php"); // Used on dev env only -if (!$res && file_exists("../../../../dolibarr/htdocs/main.inc.php")) - $res = @include("../../../../dolibarr/htdocs/main.inc.php"); // Used on dev env only -if (!$res && file_exists("../../../../../dolibarr/htdocs/main.inc.php")) - $res = @include("../../../../../dolibarr/htdocs/main.inc.php"); // Used on dev env only -if (!$res) die("Include of main fails"); - -// CORE - -global $lang, $user, $conf; - - -dol_include_once('/dolistore/class/dolistore.class.php'); -$options = array(); -$options['per_page'] = 20; -$options['categorie'] = GETPOST('categorie', 'int') + 0; -$options['start'] = GETPOST('start', 'int') + 0; -$options['end'] = GETPOST('end', 'int') + 0; -$options['search'] = GETPOST('search_keyword', 'alpha'); -$dolistore = new Dolistore($options); -/* - * View - */ - -/* * ************************************************* - * VIEW - * - * Put here all code to build page - * ************************************************** */ - -// llxHeader('', iconv(iconv_get_encoding($langs->trans($lbl_folder)), $character_set_client . "//TRANSLIT", $langs->trans($lbl_folder)) . ' (' . $info->Nmsgs . ') ', ''); - -$morejs = array("/dolistore/js/dolistore.js.php", - "/dolistore/js/fancybox/jquery.fancybox.pack.js", - "/dolistore/js/fancybox/helpers/jquery.fancybox-thumbs.js"); -$morecss = array("/dolistore/css/dolistore.css", - "/dolistore/js/fancybox/jquery.fancybox.css", - "/dolistore/js/fancybox/helpers/jquery.fancybox-thumbs.css"); -llxHeader('', $langs->trans('DOLISTOREMENU'), '', '', '', '', $morejs, $morecss, 0, 0); -?>
- - -
- - -
trans('Extensions disponibles sur le Dolistore') ?>
-
- trans('DOLISTOREdescriptionLong') ?>

- -
-
-
trans('Mot-cle') ?>: -
-
-


-
-
-
-
    - get_categories(); ?> -
-
-
- - - - - - - - get_products($categorie); ?> - - - - - - -
get_previous_link() ?> get_next_link() ?> trans('AchatTelechargement') ?>
get_previous_link() ?> get_next_link() ?> trans('AchatTelechargement') ?>
-
-
-. - * - * This program is free software; you can redistribute it and/or modifyion 2.0 (the "License"); - * it under the terms of the GNU General Public License as published bypliance with the License. - * the Free Software Foundation; either version 3 of the License, or - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * or see http://www.gnu.org/ - */ -$res = 0; -if (!$res && file_exists("../main.inc.php")) $res = @include("../main.inc.php"); -if (!$res && file_exists("../../main.inc.php")) $res = @include("../../main.inc.php"); -if (!$res && file_exists("../../../main.inc.php")) $res = @include("../../../main.inc.php"); -if (!$res && file_exists("../../../../main.inc.php")) $res = @include("../../../../main.inc.php"); -if (!$res && file_exists("../../../dolibarr/htdocs/main.inc.php")) - $res = @include("../../../dolibarr/htdocs/main.inc.php"); // Used on dev env only -if (!$res && file_exists("../../../../dolibarr/htdocs/main.inc.php")) - $res = @include("../../../../dolibarr/htdocs/main.inc.php"); // Used on dev env only -if (!$res && file_exists("../../../../../dolibarr/htdocs/main.inc.php")) - $res = @include("../../../../../dolibarr/htdocs/main.inc.php"); // Used on dev env only -if (!$res) die("Include of main fails"); - -global $langs; - -ob_start(); -?>