diff --git a/README-FR.md b/README-FR.md index 53ae1be8e8d..b3ce951c975 100644 --- a/README-FR.md +++ b/README-FR.md @@ -133,12 +133,19 @@ Voici un liste de fonctionnalites pas encore gérées par Dolibarr: - Dolibarr ne fait pas le café (pas encore). -## RESEAUX SOCIAUX +## ACTUALITES ET RESEAUX SOCIAUX -Suivez le projet Dolibarr project sur +Suivez le projet Dolibarr project sur les réseaux francophones -Facebook: +- Facebook: +- Google+: +- Twitter: -Google+: +ou sur les réseaux anglophones -Twitter: +- [Facebook](https://www.facebook.com/dolibarr) +- [Google+](https://plus.google.com/+DolibarrOrg) +- [Twitter](http://www.twitter.com/dolibarr) +- [LinkedIn](https://www.linkedin.com/company/association-dolibarr) +- [YouTube](https://www.youtube.com/user/DolibarrERPCRM) +- [GitHub](https://github.com/Dolibarr/dolibarr) diff --git a/README.md b/README.md index f6f4b8be34f..91f99dc8025 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # DOLIBARR ERP & CRM -![Build status](https://img.shields.io/travis/Dolibarr/dolibarr/develop.svg) ![Downloads per day](https://img.shields.io/sourceforge/dd/dolibarr.svg) +![Build status](https://img.shields.io/travis/Dolibarr/dolibarr/develop.svg) ![Downloads per day](https://img.shields.io/sourceforge/dm/dolibarr.svg) Dolibarr ERP & CRM is a modern software to manage your organization's activity (contacts, suppliers, invoices, orders, stocks, agenda, ...). @@ -16,9 +16,9 @@ You can use it as a standalone application or as a web application to be able to Dolibarr is released 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 (GPL-3+). -See the [COPYING](COPYING) file for a full copy of the license. +See the [COPYING](https://github.com/Dolibarr/dolibarr/blob/develop/COPYING) file for a full copy of the license. -Other licenses apply for some included dependencies. See [COPYRIGHT](COPYRIGHT) for a full list. +Other licenses apply for some included dependencies. See [COPYRIGHT](https://github.com/Dolibarr/dolibarr/blob/develop/COPYRIGHT) for a full list. ## INSTALLING @@ -65,9 +65,9 @@ You can use a Web server and a supported database (MySQL recommended) to install *Note: migration process can safely be done multiple times.* -## NEWS +## WHAT'S NEW -See the [ChangeLog](ChangeLog) file. +See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog) file. ## FEATURES @@ -153,9 +153,9 @@ Administrator, user, developer and translator's documentations are available alo Dolibarr is the work of many contributors over the years and uses some fine libraries. -See [COPYRIGHT](COPYRIGHT) file. +See [COPYRIGHT](https://github.com/Dolibarr/dolibarr/blob/develop/COPYRIGHT) file. -## SOCIAL NETWORKS +## NEWS AND SOCIAL NETWORKS Follow Dolibarr project on: diff --git a/build/debian/README.howto b/build/debian/README.howto index 92397130a3a..1889c7b633e 100644 --- a/build/debian/README.howto +++ b/build/debian/README.howto @@ -239,7 +239,7 @@ http://packages.qa.debian.org/t/tcpdf.html ##### Create/Maintain dolibarr package -To update dolibarr debian package when upstream version has changed +To update dolibarr debian package when upstream (official version of external project) has changed: * You can git clone debian git repo > git clone git.debian.org:/git/collab-maint/dolibarr.git [dolibarr-debian] @@ -284,10 +284,10 @@ Then check/modify also the user/date signature: - Name and email must match value into debian/control file (Entry added here is used by next step). -To update dolibarr debian package when only files into debian has changed +To update dolibarr debian package when only files into debian has changed, or if you include manually backport: * Change files and commit. -* Add a tag debian/x.y.z+dfsgw-2 (increase the last 1 into 2) +* Add a tag debian/x.y.z+dfsgw-2 (increase the last 1 into 2, 3...) Once files has been prepared, it's time to test: diff --git a/composer.lock b/composer.lock index f178ec4f419..47122ebe431 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "f441e6348ae7862942693cab10810418", + "hash": "d88b5c84a9ea1af354d867ba2e2ab251", + "content-hash": "85e60ec7f8ab593387c7bd10d8db860d", "packages": [ { "name": "ccampbell/chromephp", @@ -126,6 +127,64 @@ "homepage": "https://github.com/firephp/firephp-core", "time": "2013-04-23 15:28:20" }, + { + "name": "mike42/escpos-php", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/mike42/escpos-php.git", + "reference": "0564ff94de45564221eca99c4cd5ab24492894c2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/mike42/escpos-php/zipball/0564ff94de45564221eca99c4cd5ab24492894c2", + "reference": "0564ff94de45564221eca99c4cd5ab24492894c2", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "require-dev": { + "phpunit/phpunit": "4.5.*" + }, + "type": "library", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Roni Saha", + "email": "roni.cse@gmail.com" + }, + { + "name": "Michael Billington", + "email": "michael.billington@gmail.com" + }, + { + "name": "Gergely Radics", + "email": "gerifield@ustream.tv" + }, + { + "name": "Warren Doyle", + "email": "w.doyle@fuelled.co" + }, + { + "name": "vharo", + "email": "vharo@geepok.com" + } + ], + "description": "Thermal receipt printer library, for use with ESC/POS compatible printers", + "homepage": "https://github.com/mike42/escpos-php", + "keywords": [ + "ESC-POS", + "driver", + "escpos", + "print", + "receipt" + ], + "time": "2015-11-02 10:50:46" + }, { "name": "mobiledetect/mobiledetectlib", "version": "2.8.3", @@ -424,13 +483,16 @@ "pdf417", "qrcode" ], + "abandoned": "tecnickcom/tcpdf", "time": "2015-01-28 18:51:40" } ], "packages-dev": [], "aliases": [], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": { + "mike42/escpos-php": 20 + }, "prefer-stable": false, "prefer-lowest": false, "platform": { diff --git a/dev/initdata/generate-facture.php b/dev/initdata/generate-invoice.php similarity index 95% rename from dev/initdata/generate-facture.php rename to dev/initdata/generate-invoice.php index 97f00f7d6d6..321cc6af06a 100755 --- a/dev/initdata/generate-facture.php +++ b/dev/initdata/generate-invoice.php @@ -19,8 +19,8 @@ */ /** - * \file dev/intdata/generate-facture.php - * \brief Script de generation de donnees aleatoires pour les factures + * \file dev/intdata/generate-invoice.php + * \brief Script example to inject random customer invoices (for load tests) */ // Test si mode batch diff --git a/dev/initdata/generate-commande.php b/dev/initdata/generate-order.php similarity index 97% rename from dev/initdata/generate-commande.php rename to dev/initdata/generate-order.php index 785c0544876..6ba813c5135 100755 --- a/dev/initdata/generate-commande.php +++ b/dev/initdata/generate-order.php @@ -20,8 +20,8 @@ */ /** - * \file dev/initdata/generate-commande.php - * \brief Script de generation de donnees aleatoires pour les commandes + * \file dev/initdata/generate-order.php + * \brief Script example to inject random orders (for load tests) */ // Test si mode batch diff --git a/dev/initdata/generate-produit.php b/dev/initdata/generate-product.php similarity index 96% rename from dev/initdata/generate-produit.php rename to dev/initdata/generate-product.php index 6e7ea6dd05f..38c0e755db3 100755 --- a/dev/initdata/generate-produit.php +++ b/dev/initdata/generate-product.php @@ -20,8 +20,8 @@ */ /** - * \file dev/initdata/generate-produit.php - * \brief Script de generation de donnees aleatoires pour les produits + * \file dev/initdata/generate-product.php + * \brief Script example to inject random products (for load tests) */ // Test si mode batch diff --git a/dev/initdata/generate-propale.php b/dev/initdata/generate-proposal.php similarity index 96% rename from dev/initdata/generate-propale.php rename to dev/initdata/generate-proposal.php index b7b76ec2c02..8e17e673b86 100755 --- a/dev/initdata/generate-propale.php +++ b/dev/initdata/generate-proposal.php @@ -20,8 +20,8 @@ */ /** - * \file dev/initdata/generate-propale.php - * \brief Script de generation de donnees aleatoires pour les propales + * \file dev/initdata/generate-proposal.php + * \brief Script example to inject random proposals (for load tests) */ // Test si mode batch diff --git a/dev/initdata/generate-societe.php b/dev/initdata/generate-thirdparty.php similarity index 97% rename from dev/initdata/generate-societe.php rename to dev/initdata/generate-thirdparty.php index 72e4d9b1e84..9d928db6ac0 100755 --- a/dev/initdata/generate-societe.php +++ b/dev/initdata/generate-thirdparty.php @@ -20,8 +20,8 @@ */ /** - * \file dev/initdata/generate-societe.php - * \brief Script de generation de donnees aleatoires pour les societes + * \file dev/initdata/generate-thirdparty.php + * \brief Script example to inject random thirdparties (for load tests) */ // Test si mode batch diff --git a/dev/initdata/sftpget_and_loaddump.php b/dev/initdata/sftpget_and_loaddump.php index c91ddcc3e17..72a33cf197c 100755 --- a/dev/initdata/sftpget_and_loaddump.php +++ b/dev/initdata/sftpget_and_loaddump.php @@ -15,6 +15,8 @@ * 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/ + * + * Get a distant dump file and load it into a mysql database */ $sapi_type = php_sapi_name(); @@ -32,9 +34,10 @@ $error=0; $sourceserver=isset($argv[1])?$argv[1]:''; // user@server:/src/file $password=isset($argv[2])?$argv[2]:''; -$database=isset($argv[3])?$argv[3]:''; -$loginbase=isset($argv[4])?$argv[4]:''; -$passwordbase=isset($argv[5])?$argv[5]:''; +$dataserver=isset($argv[3])?$argv[3]:''; +$database=isset($argv[4])?$argv[4]:''; +$loginbase=isset($argv[5])?$argv[5]:''; +$passwordbase=isset($argv[6])?$argv[6]:''; // Include Dolibarr environment $res=0; @@ -64,7 +67,7 @@ if (preg_match('/^(.*)@(.*):(.*)$/',$sourceserver,$reg)) } if (empty($sourceserver) || empty($server) || empty($login) || empty($sourcefile) || empty($password) || empty($database) || empty($loginbase) || empty($passwordbase)) { - print "Usage: $script_file login@server:/src/file.(sql|gz|bz2) passssh database loginbase passbase\n"; + print "Usage: $script_file login@server:/src/file.(sql|gz|bz2) passssh databaseserver databasename loginbase passbase\n"; print "Return code: 0 if success, <>0 if error\n"; print "Warning, this script may take a long time.\n"; exit(-1); @@ -108,14 +111,14 @@ if ($connection) print 'Get file '.$sourcefile.' into '.$targetdir.$targetfile."\n"; ssh2_scp_recv($connection, $sourcefile, $targetdir.$targetfile); - $fullcommand="cat ".$targetdir.$targetfile." | mysql -u".$loginbase." -p".$passwordbase." -D ".$database; + $fullcommand="cat ".$targetdir.$targetfile." | mysql -h".$databaseserver." -u".$loginbase." -p".$passwordbase." -D ".$database; if (preg_match('/\.bz2$/',$targetfile)) { - $fullcommand="bzip2 -c -d ".$targetdir.$targetfile." | mysql -u".$loginbase." -p".$passwordbase." -D ".$database; + $fullcommand="bzip2 -c -d ".$targetdir.$targetfile." | mysql -h".$databaseserver." -u".$loginbase." -p".$passwordbase." -D ".$database; } if (preg_match('/\.gz$/',$targetfile)) { - $fullcommand="gzip -d ".$targetdir.$targetfile." | mysql -u".$loginbase." -p".$passwordbase." -D ".$database; + $fullcommand="gzip -d ".$targetdir.$targetfile." | mysql -h".$databaseserver." -u".$loginbase." -p".$passwordbase." -D ".$database; } print "Load dump with ".$fullcommand."\n"; $output=array(); diff --git a/dev/skeletons/build_class_from_table.php b/dev/skeletons/build_class_from_table.php index 6025f6a1f4e..803a6c8b8f5 100755 --- a/dev/skeletons/build_class_from_table.php +++ b/dev/skeletons/build_class_from_table.php @@ -619,17 +619,28 @@ foreach ($skeletonfiles as $skeletonfile => $outfile) $targetcontent=preg_replace('/'.preg_quote("if (! empty(\$arrayfields['t.field1']['checked'])) print ''.\$obj->field1.'';",'/').'/', $varprop, $targetcontent); $targetcontent=preg_replace('/'.preg_quote("if (! empty(\$arrayfields['t.field2']['checked'])) print ''.\$obj->field2.'';",'/').'/', '', $targetcontent); - // LIST_OF_TD_LABEL_FIELDS_CREATE and EDIT - List of td for card view + // LIST_OF_TD_LABEL_FIELDS_CREATE - List of td for card view $varprop="\n"; $cleanparam=''; foreach($property as $key => $prop) { if ($prop['field'] != 'rowid' && $prop['field'] != 'id' && ! $prop['istime']) { - $varprop.="print ''.\$langs->trans(\"Field".$prop['field']."\").'';\n"; + $varprop.="print ''.\$langs->trans(\"Field".$prop['field']."\").'';\n"; } } $targetcontent=preg_replace('/LIST_OF_TD_LABEL_FIELDS_CREATE/', $varprop, $targetcontent); + + // LIST_OF_TD_LABEL_FIELDS_EDIT - List of td for card view + $varprop="\n"; + $cleanparam=''; + foreach($property as $key => $prop) + { + if ($prop['field'] != 'rowid' && $prop['field'] != 'id' && ! $prop['istime']) + { + $varprop.="print ''.\$langs->trans(\"Field".$prop['field']."\").'".$prop['field'].".'\">';\n"; + } + } $targetcontent=preg_replace('/LIST_OF_TD_LABEL_FIELDS_EDIT/', $varprop, $targetcontent); // LIST_OF_TD_LABEL_FIELDS_VIEW - List of td for card view diff --git a/dev/skeletons/skeleton_card.php b/dev/skeletons/skeleton_card.php index 22958c9c833..a85969c53ad 100644 --- a/dev/skeletons/skeleton_card.php +++ b/dev/skeletons/skeleton_card.php @@ -281,12 +281,17 @@ if (($id || $ref) && $action == 'edit') // Part to show record -if ($id && (empty($action) || $action == 'view')) +if ($id && (empty($action) || $action == 'view' || $action == 'delete')) { print load_fiche_titre($langs->trans("MyModule")); dol_fiche_head(); + if ($action == 'delete') { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteMyOjbect'), $langs->trans('ConfirmDeleteMyObject'), 'confirm_delete', '', 0, 1); + print $formconfirm; + } + print ''."\n"; // print ''; // LIST_OF_TD_LABEL_FIELDS_VIEW @@ -310,14 +315,7 @@ if ($id && (empty($action) || $action == 'view')) if ($user->rights->mymodule->delete) { - if ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile)) // We can't use preloaded confirm form with jmobile - { - print '
'.$langs->trans('Delete').'
'."\n"; - } - else - { - print ''."\n"; - } + print ''."\n"; } } print ''."\n"; diff --git a/dev/skeletons/skeleton_list.php b/dev/skeletons/skeleton_list.php index 3018a23fdea..686549f19a8 100644 --- a/dev/skeletons/skeleton_list.php +++ b/dev/skeletons/skeleton_list.php @@ -96,6 +96,23 @@ if (($id > 0 || ! empty($ref)) && $action != 'add') if ($result < 0) dol_print_error($db); } +// Definition of fields for list +$arrayfields=array( + 't.field1'=>array('label'=>$langs->trans("Field1"), 'checked'=>1), + 't.field2'=>array('label'=>$langs->trans("Field2"), 'checked'=>1), + //'t.entity'=>array('label'=>$langs->trans("Entity"), 'checked'=>1, 'enabled'=>(! empty($conf->multicompany->enabled) && empty($conf->multicompany->transverse_mode))), + 't.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), + 't.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), + //'t.statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000), +); +// Extra fields +if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) +{ + foreach($extrafields->attribute_label as $key => $val) + { + $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); + } +} @@ -267,22 +284,6 @@ if ($resql) print ''; } - $arrayfields=array( - 't.field1'=>array('label'=>$langs->trans("Field1"), 'checked'=>1), - 't.field2'=>array('label'=>$langs->trans("Field2"), 'checked'=>1), - //'t.entity'=>array('label'=>$langs->trans("Entity"), 'checked'=>1, 'enabled'=>(! empty($conf->multicompany->enabled) && empty($conf->multicompany->transverse_mode))), - 't.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), - 't.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), - //'t.statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000), - ); - // Extra fields - if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) - { - foreach($extrafields->attribute_label as $key => $val) - { - $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); - } - } $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields diff --git a/htdocs/admin/barcode.php b/htdocs/admin/barcode.php index 0a57508c271..fbaf68a96d9 100644 --- a/htdocs/admin/barcode.php +++ b/htdocs/admin/barcode.php @@ -162,7 +162,7 @@ foreach($dirbarcode as $reldir) { $filebis=$reg[1]; - // Chargement de la classe de codage + // Loading encoding class require_once $newdir.$file; $classname = "mod".ucfirst($filebis); $module = new $classname($db); diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 6fe2e8efb38..7022c5877eb 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -510,7 +510,7 @@ if ($id == 10) } -// Actions ajout ou modification d'une entree dans un dictionnaire de donnee +// Actions add or modify an entry into a dictionary if (GETPOST('actionadd') || GETPOST('actionmodify')) { $listfield=explode(',',$tabfield[$id]); @@ -581,7 +581,12 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) setEventMessages($langs->transnoentities("ErrorFieldRequired",$langs->transnoentities("Country")), null, 'errors'); } } - + if ($id == 3 && ! is_numeric($_POST["code"])) + { + $ok=0; + setEventMessages($langs->transnoentities("ErrorFieldMustBeANumeric",$langs->transnoentities("Code")), null, 'errors'); + } + // Clean some parameters if (isset($_POST["localtax1"]) && empty($_POST["localtax1"])) $_POST["localtax1"]='0'; // If empty, we force to 0 if (isset($_POST["localtax2"]) && empty($_POST["localtax2"])) $_POST["localtax2"]='0'; // If empty, we force to 0 diff --git a/htdocs/admin/facture.php b/htdocs/admin/facture.php index 46ca2b9fd87..b3f1d7a5d51 100644 --- a/htdocs/admin/facture.php +++ b/htdocs/admin/facture.php @@ -344,7 +344,7 @@ foreach ($dirmodels as $reldir) $classname = preg_replace('/\-.*$/','',$classname); if (! class_exists($classname) && is_readable($dir.$filebis) && (preg_match('/mod_/',$filebis) || preg_match('/mod_/',$classname)) && substr($filebis, dol_strlen($filebis)-3, 3) == 'php') { - // Chargement de la classe de numerotation + // Charging the numbering class require_once $dir.$filebis; $module = new $classname($db); diff --git a/htdocs/admin/oauth.php b/htdocs/admin/oauth.php index aab05bd4c56..66878753b46 100644 --- a/htdocs/admin/oauth.php +++ b/htdocs/admin/oauth.php @@ -27,6 +27,13 @@ require '../main.inc.php'; // required Class require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; + +// Define $urlwithroot +$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); +$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file +//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current + + $langs->load("admin"); $langs->load("oauth"); @@ -36,6 +43,8 @@ if (!$user->admin) $action = GETPOST('action', 'alpha'); +// Supported OAUTH +$supportedoauth2array=array('OAUTH_GOOGLE_NAME'); // API access parameters OAUTH $list = array ( array( @@ -297,11 +306,7 @@ print ''; dol_fiche_head(array(), '', '', 0, 'technic'); -// Define $urlwithroot -$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); -$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file -//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current - +print $langs->trans("ListOfSupportedOauthProviders").'

'; print '
'.$langs->trans("Label").'
'; @@ -309,12 +314,16 @@ $var = true; foreach ($list as $key) { + $supported=0; + if (in_array($key[0], $supportedoauth2array)) $supported=1; + if (! $supported) continue; // show only supported + print ''; // Api Name $label = $langs->trans($key[0]); print ''; - if (in_array($key[0], array('OAUTH_GOOGLE_NAME'))) + if ($supported) { $redirect_uri=$urlwithroot.'/core/modules/oauth/getgoogleoauthcallback.php'; $var = !$var; diff --git a/htdocs/admin/payment.php b/htdocs/admin/payment.php index c9bf610bd1b..07113231bcc 100644 --- a/htdocs/admin/payment.php +++ b/htdocs/admin/payment.php @@ -130,7 +130,7 @@ foreach ($dirmodels as $reldir) $classname = preg_replace('/\-.*$/','',$classname); if (! class_exists($classname) && is_readable($dir.$filebis) && (preg_match('/mod_/',$filebis) || preg_match('/mod_/',$classname)) && substr($filebis, dol_strlen($filebis)-3, 3) == 'php') { - // Chargement de la classe de numerotation + // Charging the numbering class require_once $dir.$filebis; $module = new $classname($db); diff --git a/htdocs/admin/security.php b/htdocs/admin/security.php index a409d0c8b3f..ea81e63305e 100644 --- a/htdocs/admin/security.php +++ b/htdocs/admin/security.php @@ -221,7 +221,7 @@ if (is_resource($handle)) { if (preg_match('/(modGeneratePass[a-z]+)\.class\.php/i',$file,$reg)) { - // Chargement de la classe de numerotation + // Charging the numbering class $classname = $reg[1]; require_once $dir.'/'.$file; diff --git a/htdocs/categories/edit.php b/htdocs/categories/edit.php index 0a13c3e7fab..9ffd7ac6401 100644 --- a/htdocs/categories/edit.php +++ b/htdocs/categories/edit.php @@ -101,12 +101,12 @@ if ($action == 'update' && $user->rights->categorie->creer) } else { - setEventMessage($categorie->error, 'errors'); + setEventMessages($categorie->error, $categorie->errors, 'errors'); } } else { - setEventMessage($categorie->error, 'errors'); + setEventMessages($categorie->error, $categorie->errors, 'errors'); } } diff --git a/htdocs/categories/traduction.php b/htdocs/categories/traduction.php index 94570d48f3e..98f02c7a742 100644 --- a/htdocs/categories/traduction.php +++ b/htdocs/categories/traduction.php @@ -95,7 +95,7 @@ $cancel != $langs->trans("Cancel") && else { $action = 'add'; - setEventMessage($object->error, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } } @@ -128,7 +128,7 @@ $cancel != $langs->trans("Cancel") && else { $action = 'edit'; - setEventMessage($object->error, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } } diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index bf86c1d496c..39f8d62fb7b 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -122,7 +122,7 @@ if ($user->rights->categorie->supprimer && $action == 'confirm_delete' && $confi } else { - setEventMessage($object->error, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } } @@ -137,13 +137,13 @@ if ($type == Categorie::TYPE_PRODUCT && $elemid && $action == 'addintocategory' $result=$object->add_type($newobject,$elementtype); if ($result >= 0) { - setEventMessage($langs->trans("WasAddedSuccessfully",$newobject->ref)); + setEventMessages($langs->trans("WasAddedSuccessfully",$newobject->ref), null, 'mesgs'); } else { if ($cat->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { - setEventMessage($langs->trans("ObjectAlreadyLinkedToCategory"),'warnings'); + setEventMessages($langs->trans("ObjectAlreadyLinkedToCategory"), null, 'warnings'); } else { diff --git a/htdocs/comm/action/rapport/index.php b/htdocs/comm/action/rapport/index.php index 24eb117684f..066df5fb39e 100644 --- a/htdocs/comm/action/rapport/index.php +++ b/htdocs/comm/action/rapport/index.php @@ -62,7 +62,7 @@ if ($action == 'builddoc') $result=$cat->write_file(GETPOST('id','int')); if ($result < 0) { - setEventMessage($cat->error, 'errors'); + setEventMessages($cat->error, $cat->errors, 'errors'); } } diff --git a/htdocs/comm/address.php b/htdocs/comm/address.php index eb3c51b1760..edb5042e358 100644 --- a/htdocs/comm/address.php +++ b/htdocs/comm/address.php @@ -106,7 +106,7 @@ if ($action == 'add' || $action == 'update') } else { - setEventMessage($object->error, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); $action='create'; } } @@ -147,7 +147,7 @@ if ($action == 'add' || $action == 'update') else { $reload = 0; - setEventMessage($object->error, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); $action= "edit"; } } diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index b874eeefde5..0045316d419 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -105,7 +105,7 @@ if (empty($reshook)) $result=$object->fetch($id); $object->code_compta=$_POST["customeraccountancycode"]; $result=$object->update($object->id,$user,1,1,0); - if ($result < 0) setEventMessage($object->error,$object->errors,'errors'); + if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } // conditions de reglement @@ -113,7 +113,7 @@ if (empty($reshook)) { $object->fetch($id); $result=$object->setPaymentTerms(GETPOST('cond_reglement_id','int')); - if ($result < 0) setEventMessage($object->error,$object->errors,'errors'); + if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } // mode de reglement @@ -121,7 +121,7 @@ if (empty($reshook)) { $object->fetch($id); $result=$object->setPaymentMethods(GETPOST('mode_reglement_id','int')); - if ($result < 0) setEventMessage($object->error,$object->errors,'errors'); + if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } // assujetissement a la TVA @@ -130,7 +130,7 @@ if (empty($reshook)) $object->fetch($id); $object->tva_assuj=$_POST['assujtva_value']; $result=$object->update($object->id); - if ($result < 0) setEventMessage($object->error,$object->errors,'errors'); + if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } // set prospect level @@ -139,7 +139,7 @@ if (empty($reshook)) $object->fetch($id); $object->fk_prospectlevel=GETPOST('prospect_level_id','alpha'); $result=$object->set_prospect_level($user); - if ($result < 0) setEventMessage($object->error,$object->errors,'errors'); + if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } // set communication status @@ -148,7 +148,7 @@ if (empty($reshook)) $object->fetch($id); $object->stcomm_id=dol_getIdFromCode($db, GETPOST('stcomm','alpha'), 'c_stcomm'); $result=$object->set_commnucation_level($user); - if ($result < 0) setEventMessages($object->error,$object->errors,'errors'); + if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } // update outstandng limit @@ -157,7 +157,7 @@ if (empty($reshook)) $object->fetch($id); $object->outstanding_limit=GETPOST('outstanding_limit'); $result=$object->set_OutstandingBill($user); - if ($result < 0) setEventMessage($object->error,$object->errors,'errors'); + if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } } diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index 2ff7796bfae..e54aeb1c8a5 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -117,7 +117,7 @@ if (empty($reshook)) { if (empty($_REQUEST["clone_content"]) && empty($_REQUEST["clone_receivers"])) { - setEventMessage($langs->trans("NoCloneOptionsSpecified"), 'errors'); + setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors'); } else { @@ -129,7 +129,7 @@ if (empty($reshook)) } else { - setEventMessage($object->error, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } } $action=''; @@ -141,14 +141,14 @@ if (empty($reshook)) if (empty($conf->global->MAILING_LIMIT_SENDBYWEB)) { // As security measure, we don't allow send from the GUI - setEventMessage($langs->trans("MailingNeedCommand"), 'warnings'); - setEventMessage('', 'warnings'); - setEventMessage($langs->trans("MailingNeedCommand2"), 'warnings'); + setEventMessages($langs->trans("MailingNeedCommand"), null, 'warnings'); + setEventMessages('', null, 'warnings'); + setEventMessages($langs->trans("MailingNeedCommand2"), null, 'warnings'); $action=''; } else if ($conf->global->MAILING_LIMIT_SENDBYWEB < 0) { - setEventMessage($langs->trans("NotEnoughPermissions"), 'warnings'); + setEventMessages($langs->trans("NotEnoughPermissions"), null, 'warnings'); $action=''; } else @@ -351,27 +351,27 @@ if (empty($reshook)) } else { - setEventMessage($langs->transnoentitiesnoconv("NoMoreRecipientToSendTo")); + setEventMessages($langs->transnoentitiesnoconv("NoMoreRecipientToSendTo"), null, 'mesgs'); } // Loop finished, set global statut of mail if ($nbko > 0) { $statut=2; // Status 'sent partially' (because at least one error) - if ($nbok > 0) setEventMessage($langs->transnoentitiesnoconv("EMailSentToNRecipients",$nbok)); - else setEventMessage($langs->transnoentitiesnoconv("EMailSentToNRecipients",$nbok)); + if ($nbok > 0) setEventMessages($langs->transnoentitiesnoconv("EMailSentToNRecipients",$nbok), null, 'mesgs'); + else setEventMessages($langs->transnoentitiesnoconv("EMailSentToNRecipients",$nbok), null, 'mesgs'); } else { if ($nbok >= $num) { $statut=3; // Send to everybody - setEventMessage($langs->transnoentitiesnoconv("EMailSentToNRecipients",$nbok)); + setEventMessages($langs->transnoentitiesnoconv("EMailSentToNRecipients",$nbok), null, 'mesgs'); } else { $statut=2; // Status 'sent partially' (because not send to everybody) - setEventMessage($langs->transnoentitiesnoconv("EMailSentToNRecipients",$nbok)); + setEventMessages($langs->transnoentitiesnoconv("EMailSentToNRecipients",$nbok), null, 'mesgs'); } } @@ -443,11 +443,11 @@ if (empty($reshook)) $result=$mailfile->sendfile(); if ($result) { - setEventMessage($langs->trans("MailSuccessfulySent",$mailfile->getValidAddress($object->email_from,2),$mailfile->getValidAddress($object->sendto,2))); + setEventMessages($langs->trans("MailSuccessfulySent",$mailfile->getValidAddress($object->email_from,2),$mailfile->getValidAddress($object->sendto,2)), null, 'mesgs'); } else { - setEventMessage($langs->trans("ResultKo").'
'.$mailfile->error.' '.$result, 'errors'); + setEventMessages($langs->trans("ResultKo").'
'.$mailfile->error.' '.$result, null, 'errors'); } $action=''; @@ -488,7 +488,7 @@ if (empty($reshook)) $mesgs[] = $object->error; } - setEventMessage($mesgs, 'errors'); + setEventMessages($mesg, $mesgs, 'errors'); $action="create"; } @@ -518,7 +518,7 @@ if (empty($reshook)) $mesg = $object->error; } - setEventMessage($mesg, 'errors'); + setEventMessages($mesg, $mesgs, 'errors'); $action=""; } @@ -582,7 +582,7 @@ if (empty($reshook)) $mesgs[] =$object->error; } - setEventMessage($mesgs, 'errors'); + setEventMessages($mesg, $mesgs, 'errors'); $action="edit"; } else @@ -597,7 +597,7 @@ if (empty($reshook)) if ($object->id > 0) { $object->valid($user); - setEventMessage($langs->trans("MailingSuccessfullyValidated")); + setEventMessages($langs->trans("MailingSuccessfullyValidated"), null, 'mesgs'); header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; } @@ -628,7 +628,7 @@ if (empty($reshook)) } else { - setEventMessage($object->error, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); $db->rollback(); } } @@ -764,18 +764,18 @@ else // You ensure that every user is using its own SMTP server. $linktoadminemailbefore=''; $linktoadminemailend=''; - setEventMessage($langs->trans("MailSendSetupIs", $listofmethods[$sendingmode]), 'warnings'); - setEventMessage($langs->trans("MailSendSetupIs2", $linktoadminemailbefore, $linktoadminemailend, $langs->transnoentitiesnoconv("MAIN_MAIL_SENDMODE"), $listofmethods['smtps']), 'warnings'); - if (! empty($conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS)) setEventMessage($langs->trans("MailSendSetupIs3", $conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS), 'warnings'); + setEventMessages($langs->trans("MailSendSetupIs", $listofmethods[$sendingmode]), null, 'warnings'); + setEventMessages($langs->trans("MailSendSetupIs2", $linktoadminemailbefore, $linktoadminemailend, $langs->transnoentitiesnoconv("MAIN_MAIL_SENDMODE"), $listofmethods['smtps']), null, 'warnings'); + if (! empty($conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS)) setEventMessages($langs->trans("MailSendSetupIs3", $conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS), null, 'warnings'); $_GET["action"]=''; } else if (empty($conf->global->MAILING_LIMIT_SENDBYWEB)) { // Pour des raisons de securite, on ne permet pas cette fonction via l'IHM, // on affiche donc juste un message - setEventMessage($langs->trans("MailingNeedCommand"), 'warnings'); - setEventMessage('', 'warnings'); - setEventMessage($langs->trans("MailingNeedCommand2"), 'warnings'); + setEventMessages($langs->trans("MailingNeedCommand"), null, 'warnings'); + setEventMessages('', null, 'warnings'); + setEventMessages($langs->trans("MailingNeedCommand2"), null, 'warnings'); $_GET["action"]=''; } else diff --git a/htdocs/comm/mailing/cibles.php b/htdocs/comm/mailing/cibles.php index cd3ff7b00ee..ad4e3210619 100644 --- a/htdocs/comm/mailing/cibles.php +++ b/htdocs/comm/mailing/cibles.php @@ -80,7 +80,7 @@ if ($action == 'add') //print $dir."\n
"; dol_syslog("Scan directory ".$dir." for modules"); - // Chargement de la classe + // Loading Class $file = $dir."/".$module.".modules.php"; $classname = "mailing_".$module; @@ -100,24 +100,24 @@ if ($action == 'add') } if ($result > 0) { - setEventMessage($langs->trans("XTargetsAdded",$result),'mesgs'); + setEventMessages($langs->trans("XTargetsAdded",$result), null, 'mesgs'); header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); exit; } if ($result == 0) { - setEventMessage($langs->trans("WarningNoEMailsAdded"),'warnings'); + setEventMessages($langs->trans("WarningNoEMailsAdded"), null, 'warnings'); } if ($result < 0) { - setEventMessage($langs->trans("Error").($obj->error?' '.$obj->error:''),'errors'); + setEventMessages($langs->trans("Error").($obj->error?' '.$obj->error:''), null, 'errors'); } } if (GETPOST('clearlist')) { - // Chargement de la classe + // Loading Class $obj = new MailingTargets($db); $obj->clear_target($id); @@ -267,7 +267,7 @@ if ($object->fetch($id) >= 0) // Loop on each submodule foreach($modulenames as $modulename) { - // Chargement de la classe + // Loading Class $file = $dir.$modulename.".modules.php"; $classname = "mailing_".$modulename; require_once $file; diff --git a/htdocs/comm/mailing/index.php b/htdocs/comm/mailing/index.php index 59753ee1904..5904bec0009 100644 --- a/htdocs/comm/mailing/index.php +++ b/htdocs/comm/mailing/index.php @@ -83,7 +83,7 @@ if (is_resource($handle)) $modulename=$reg[1]; if ($modulename == 'example') continue; - // Chargement de la classe + // Loading Class $file = $dir."/".$modulename.".modules.php"; $classname = "mailing_".$modulename; require_once $file; diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 408d01d8eaa..1107e3b9b4d 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -6,7 +6,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2010-2014 Juanjo Menent - * Copyright (C) 2010-2011 Philippe Grand + * Copyright (C) 2010-2015 Philippe Grand * Copyright (C) 2012-2013 Christophe Battarel * Copyright (C) 2012 Cedric Salvador * Copyright (C) 2013-2014 Florian Henry @@ -131,7 +131,7 @@ if (empty($reshook)) { if (! GETPOST('socid', 3)) { - setEventMessage($langs->trans("NoCloneOptionsSpecified"), 'errors'); + setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors'); } else { @@ -141,7 +141,7 @@ if (empty($reshook)) header("Location: " . $_SERVER['PHP_SELF'] . '?id=' . $result); exit(); } else { - if (count($object->errors) > 0) setEventMessage($object->errors, 'errors'); + if (count($object->errors) > 0) setEventMessages($object->error, $object->errors, 'errors'); $action = ''; } } @@ -157,7 +157,7 @@ if (empty($reshook)) exit(); } else { $langs->load("errors"); - setEventMessage($langs->trans($object->error), 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } } @@ -211,8 +211,8 @@ if (empty($reshook)) } } else { $langs->load("errors"); - if (count($object->errors) > 0) setEventMessage($object->errors, 'errors'); - else setEventMessage($langs->trans($object->error), 'errors'); + if (count($object->errors) > 0) setEventMessages($object->error, $object->errors, 'errors'); + else setEventMessages($langs->trans($object->error), null, 'errors'); } } @@ -318,7 +318,7 @@ if (empty($reshook)) $id = $object->create_from($user); } else { - setEventMessage($langs->trans("ErrorFailedToCopyProposal", GETPOST('copie_propal')), 'errors'); + setEventMessages($langs->trans("ErrorFailedToCopyProposal", GETPOST('copie_propal')), null, 'errors'); } } else { $object->ref = GETPOST('ref'); @@ -507,7 +507,7 @@ if (empty($reshook)) if ($result < 0) { $error++; - setEventMessage($langs->trans("ErrorFailedToAddContact"), 'errors'); + setEventMessages($langs->trans("ErrorFailedToAddContact"), null, 'errors'); } } @@ -671,7 +671,7 @@ if (empty($reshook)) if ($object->id > 0) { $result = $object->insert_discount($_POST["remise_id"]); if ($result < 0) { - setEventMessage($object->error, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } } } @@ -875,7 +875,7 @@ if (empty($reshook)) if (! empty($price_min) && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min))) { $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)); - setEventMessage($mesg, 'errors'); + setEventMessages($mesg, null, 'errors'); } else { // Insert line $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $pu_ttc, $info_bits, $type, - 1, 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $date_start, $date_end, $array_options, $fk_unit); @@ -929,13 +929,13 @@ if (empty($reshook)) } else { $db->rollback(); - setEventMessage($object->error, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } } } } - // Mise a jour d'une ligne dans la propale + // Update a line within proposal else if ($action == 'updateligne' && $user->rights->propal->creer && GETPOST('save')) { // Define info_bits @@ -991,7 +991,7 @@ if (empty($reshook)) $label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : ''); if ($price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent')) / 100) < price2num($price_min))) { - setEventMessage($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)), 'errors'); + setEventMessages($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)), null, 'errors'); $error ++; } } else { @@ -1040,7 +1040,7 @@ if (empty($reshook)) } else { $db->rollback(); - setEventMessage($object->error, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } } } @@ -1137,9 +1137,9 @@ if (empty($reshook)) } else { if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { $langs->load("errors"); - setEventMessage($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), 'errors'); + setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors'); } else { - setEventMessage($object->error, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } } } @@ -1636,13 +1636,13 @@ if ($action == 'create') else if ($action == 'validate') { $error = 0; - // on verifie si l'objet est en numerotation provisoire + // We verifie whether the object is provisionally numbering $ref = substr($object->ref, 1, 4); if ($ref == 'PROV') { $numref = $object->getNextNumRef($soc); if (empty($numref)) { $error ++; - setEventMessage($object->error, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } } else { $numref = $object->ref; diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 390e05363bb..fcac4ba9de1 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -375,13 +375,15 @@ class Propal extends CommonObject * @param int $date_end End date of the line * @param array $array_options extrafields array * @param string $fk_unit Code of the unit to use. Null to use the default one + * @param string $origin 'order', ... + * @param int $origin_id Id of origin object * @return int >0 if OK, <0 if KO * * @see add_product */ - function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0.0, $txlocaltax2=0.0, $fk_product=0, $remise_percent=0.0, $price_base_type='HT', $pu_ttc=0.0, $info_bits=0, $type=0, $rang=-1, $special_code=0, $fk_parent_line=0, $fk_fournprice=0, $pa_ht=0, $label='',$date_start='', $date_end='',$array_options=0, $fk_unit=null) + function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0.0, $txlocaltax2=0.0, $fk_product=0, $remise_percent=0.0, $price_base_type='HT', $pu_ttc=0.0, $info_bits=0, $type=0, $rang=-1, $special_code=0, $fk_parent_line=0, $fk_fournprice=0, $pa_ht=0, $label='',$date_start='', $date_end='',$array_options=0, $fk_unit=null, $origin='', $origin_id=0) { - global $mysoc; + global $mysoc, $conf, $langs; dol_syslog(get_class($this)."::addline propalid=$this->id, desc=$desc, pu_ht=$pu_ht, qty=$qty, txtva=$txtva, fk_product=$fk_product, remise_except=$remise_percent, price_base_type=$price_base_type, pu_ttc=$pu_ttc, info_bits=$info_bits, type=$type"); include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; @@ -499,6 +501,9 @@ class Propal extends CommonObject $this->line->fk_fournprice = $fk_fournprice; $this->line->pa_ht = $pa_ht; + $this->line->origin_id = $origin_id; + $this->line->origin = $origin; + // Mise en option de la ligne if (empty($qty) && empty($special_code)) $this->line->special_code=3; @@ -570,7 +575,8 @@ class Propal extends CommonObject { global $mysoc; - dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise_percent=$remise_percent, txtva=$txtva, desc=$desc, price_base_type=$price_base_type, info_bits=$info_bits, special_code=$special_code, fk_parent_line=$fk_parent_line, pa_ht=$a_ht, type=$type, date_start=$date_start, date_end=$date_end"); + dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise_percent=$remise_percent, + txtva=$txtva, desc=$desc, price_base_type=$price_base_type, info_bits=$info_bits, special_code=$special_code, fk_parent_line=$fk_parent_line, pa_ht=$pa_ht, type=$type, date_start=$date_start, date_end=$date_end"); include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; // Clean parameters @@ -894,7 +900,9 @@ class Propal extends CommonObject $this->lines[$i]->date_start, $this->lines[$i]->date_end, $this->lines[$i]->array_options, - $this->lines[$i]->fk_unit + $this->lines[$i]->fk_unit, + $this->element, + $this->lines[$i]->id ); if ($result < 0) @@ -1384,7 +1392,10 @@ class Propal extends CommonObject */ function update_extrafields($user) { + global $conf, $hookmanager; + $action='update'; + $error = 0; // Actions on extra fields (by external module or standard code) // TODO le hook fait double emploi avec le trigger !! @@ -2717,7 +2728,7 @@ class Propal extends CommonObject */ function getNomUrl($withpicto=0,$option='', $get_params='') { - global $langs; + global $langs, $conf; $result=''; $label = '' . $langs->trans("ShowPropal") . ''; diff --git a/htdocs/comm/propal/contact.php b/htdocs/comm/propal/contact.php index 6a0a1076e62..544c5ab27e3 100644 --- a/htdocs/comm/propal/contact.php +++ b/htdocs/comm/propal/contact.php @@ -2,7 +2,7 @@ /* Copyright (C) 2005 Patrick Rouillon * Copyright (C) 2005-2009 Destailleur Laurent * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2011-2012 Philippe Grand + * Copyright (C) 2011-2015 Philippe Grand * * 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 @@ -54,12 +54,12 @@ if ($id > 0 || ! empty($ref)) if ($ret == 0) { $langs->load("errors"); - setEventMessage($langs->trans('ErrorRecordNotFound'), 'errors'); + setEventMessages($langs->trans('ErrorRecordNotFound'), null, 'errors'); $error++; } else if ($ret < 0) { - setEventMessage($object->error, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); $error++; } } @@ -75,7 +75,7 @@ else /* - * Ajout d'un nouveau contact + * Add a new contact */ if ($action == 'addcontact' && $user->rights->propale->creer) @@ -96,16 +96,16 @@ if ($action == 'addcontact' && $user->rights->propale->creer) if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { $langs->load("errors"); - setEventMessage($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), 'errors'); + setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors'); } else { - setEventMessage($object->error, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } } } -// Bascule du statut d'un contact +// Toggle the status of a contact else if ($action == 'swapstatut' && $user->rights->propale->creer) { if ($object->id > 0) @@ -114,7 +114,7 @@ else if ($action == 'swapstatut' && $user->rights->propale->creer) } } -// Efface un contact +// Deletes a contact else if ($action == 'deletecontact' && $user->rights->propale->creer) { $result = $object->delete_contact($lineid); diff --git a/htdocs/comm/remx.php b/htdocs/comm/remx.php index e472c5fb848..ba85d593fce 100644 --- a/htdocs/comm/remx.php +++ b/htdocs/comm/remx.php @@ -65,17 +65,17 @@ if ($action == 'confirm_split' && GETPOST("confirm") == 'yes') if (! $res > 0) { $error++; - setEventMessage($langs->trans("ErrorFailedToLoadDiscount"), 'errors'); + setEventMessages($langs->trans("ErrorFailedToLoadDiscount"), null, 'errors'); } if (! $error && price2num($_POST["amount_ttc_1"]+$_POST["amount_ttc_2"]) != $discount->amount_ttc) { $error++; - setEventMessage($langs->trans("TotalOfTwoDiscountMustEqualsOriginal"), 'errors'); + setEventMessages($langs->trans("TotalOfTwoDiscountMustEqualsOriginal"), null, 'errors'); } if (! $error && $discount->fk_facture_line) { $error++; - setEventMessage($langs->trans("ErrorCantSplitAUsedDiscount"), 'errors'); + setEventMessages($langs->trans("ErrorCantSplitAUsedDiscount"), null, 'errors'); } if (! $error) { @@ -166,13 +166,13 @@ if ($action == 'setremise') else { $error++; - setEventMessage($soc->error, 'errors'); + setEventMessages($soc->error, $soc->errors, 'errors'); } } } else { - setEventMessage($langs->trans("ErrorFieldFormat",$langs->trans("NewGlobalDiscount")), 'errors'); + setEventMessages($langs->trans("ErrorFieldFormat",$langs->trans("NewGlobalDiscount")), null, 'errors'); } } @@ -194,7 +194,7 @@ if (GETPOST("action") == 'confirm_remove' && GETPOST("confirm")=='yes') } else { - setEventMessage($discount->error, 'errors'); + setEventMessages($discount->error, $discount->errors, 'errors'); $db->rollback(); } } @@ -216,7 +216,7 @@ if ($socid > 0) $object->fetch($socid); /* - * Affichage onglets + * Display tabs */ $head = societe_prepare_head($object); @@ -300,7 +300,7 @@ if ($socid > 0) } /* - * Liste remises fixes restant en cours (= liees a acune facture ni ligne de facture) + * Liste remises fixes restant en cours (= liees a aucune facture ni ligne de facture) */ $sql = "SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx,"; $sql.= " rc.datec as dc, rc.description,"; diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index b4b44de3a70..65540732674 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -5,10 +5,10 @@ * Copyright (C) 2005-2015 Regis Houssin * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2010-2013 Juanjo Menent - * Copyright (C) 2011 Philippe Grand + * Copyright (C) 2011-2015 Philippe Grand * Copyright (C) 2012-2013 Christophe Battarel * Copyright (C) 2012 Marcos García - * Copyright (C) 2012 Cedric Salvador + * Copyright (C) 2012 Cedric Salvador * Copyright (C) 2013 Florian Henry * Copyright (C) 2014 Ferran Marcet * Copyright (C) 2015 Jean-François Ferry @@ -123,7 +123,7 @@ if (empty($reshook)) { if (1==0 && ! GETPOST('clone_content') && ! GETPOST('clone_receivers')) { - setEventMessage($langs->trans("NoCloneOptionsSpecified"), 'errors'); + setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors'); } else { @@ -140,7 +140,7 @@ if (empty($reshook)) } else { - setEventMessage($object->error, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); $object = $orig; $action=''; } @@ -176,7 +176,7 @@ if (empty($reshook)) } else { - setEventMessage($object->error, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } } @@ -224,7 +224,7 @@ if (empty($reshook)) $datelivraison = dol_mktime(12, 0, 0, GETPOST('liv_month'), GETPOST('liv_day'), GETPOST('liv_year')); if ($datecommande == '') { - setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentities('Date')), 'errors'); + setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentities('Date')), null, 'errors'); $action = 'create'; $error++; } @@ -373,11 +373,11 @@ if (empty($reshook)) if ($reshook < 0) $error++; } else { - setEventMessage($srcobject->error, 'errors'); + setEventMessages($srcobject->error, $srcobject->errors, 'errors'); $error++; } } else { - setEventMessage($object->error, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); $error++; } } else { @@ -413,7 +413,7 @@ if (empty($reshook)) { $result = $object->add_contact(GETPOST('contactid'), 'CUSTOMER', 'external'); if ($result < 0) { - setEventMessage($langs->trans("ErrorFailedToAddContact"), 'errors'); + setEventMessages($langs->trans("ErrorFailedToAddContact"), null, 'errors'); $error++; } } @@ -431,7 +431,7 @@ if (empty($reshook)) } else { $db->rollback(); $action = 'create'; - setEventMessage($object->error, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } } } @@ -441,7 +441,7 @@ if (empty($reshook)) $ret=$object->classifyBilled(); if ($ret < 0) { - setEventMessage($object->error, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } } @@ -594,11 +594,11 @@ if (empty($reshook)) } if (empty($idprod) && ($price_ht < 0) && ($qty < 0)) { - setEventMessage($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPriceHT'), $langs->transnoentitiesnoconv('Qty')), 'errors'); + setEventMessages($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPriceHT'), $langs->transnoentitiesnoconv('Qty')), null, 'errors'); $error++; } if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && GETPOST('type') < 0) { - setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), 'errors'); + setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), null, 'errors'); $error++; } if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && (! ($price_ht >= 0) || $price_ht == '')) // Unit price can be 0 but not '' @@ -607,11 +607,11 @@ if (empty($reshook)) $error++; } if ($qty == '') { - setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), 'errors'); + setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), null, 'errors'); $error++; } if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && empty($product_desc)) { - setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Description')), 'errors'); + setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Description')), null, 'errors'); $error++; } @@ -672,7 +672,7 @@ if (empty($reshook)) } else { - setEventMessage($prodcustprice->error,'errors'); + setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors'); } } @@ -756,7 +756,7 @@ if (empty($reshook)) if (! empty($price_min) && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min))) { $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)); - setEventMessage($mesg, 'errors'); + setEventMessages($mesg, null, 'errors'); } else { // Insert line $result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $info_bits, 0, $price_base_type, $pu_ttc, $date_start, $date_end, $type, - 1, 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $array_options, $fk_unit); @@ -810,7 +810,7 @@ if (empty($reshook)) unset($_POST['date_endmonth']); unset($_POST['date_endyear']); } else { - setEventMessage($object->error, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } } } @@ -874,7 +874,7 @@ if (empty($reshook)) $label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : ''); if ($price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent')) / 100) < price2num($price_min))) { - setEventMessage($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)), 'errors'); + setEventMessages($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)), null, 'errors'); $error++; } } else { @@ -922,7 +922,7 @@ if (empty($reshook)) unset($_POST['fournprice']); unset($_POST['buying_price']); } else { - setEventMessage($object->error, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } } } @@ -955,7 +955,7 @@ if (empty($reshook)) if (! $idwarehouse || $idwarehouse == -1) { $error++; - setEventMessage($langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("Warehouse")), 'errors'); + setEventMessages($langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("Warehouse")), null, 'errors'); $action=''; } } @@ -1008,7 +1008,7 @@ if (empty($reshook)) if (! $idwarehouse || $idwarehouse == -1) { $error++; - setEventMessage($langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("Warehouse")), 'errors'); + setEventMessages($langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("Warehouse")), null, 'errors'); $action=''; } } @@ -1040,7 +1040,7 @@ if (empty($reshook)) else if ($action == 'confirm_shipped' && $confirm == 'yes' && $user->rights->commande->cloturer) { $result = $object->cloture($user); if ($result < 0) { - setEventMessages($object->error, $object->errors(), 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } } @@ -1067,7 +1067,7 @@ if (empty($reshook)) if (! $idwarehouse || $idwarehouse == -1) { $error++; - setEventMessage($langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("Warehouse")), 'errors'); + setEventMessages($langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("Warehouse")), null, 'errors'); $action=''; } } @@ -1076,7 +1076,7 @@ if (empty($reshook)) $result = $object->cancel($idwarehouse); if ($result < 0) { - setEventMessage($object->error, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } } } @@ -1123,9 +1123,9 @@ if (empty($reshook)) $file = $upload_dir . '/' . GETPOST('file'); $ret = dol_delete_file($file, 0, 0, 0, $object); if ($ret) - setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile'))); + setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs'); else - setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors'); + setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors'); $action = ''; } } @@ -1189,9 +1189,9 @@ if (empty($reshook)) } else { if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { $langs->load("errors"); - setEventMessage($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), 'errors'); + setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors'); } else { - setEventMessage($object->error, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } } } diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 32a1cac7c29..3c0df82fc88 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -777,7 +777,9 @@ class Commande extends CommonOrder $this->lines[$i]->pa_ht, $this->lines[$i]->label, $this->lines[$i]->array_options, - $this->lines[$i]->fk_unit + $this->lines[$i]->fk_unit, + $this->element, + $this->lines[$i]->id ); if ($result < 0) { @@ -2322,6 +2324,7 @@ class Commande extends CommonOrder function classifyBilled() { global $conf, $user, $langs; + $error = 0; $this->db->begin(); @@ -2636,6 +2639,7 @@ class Commande extends CommonOrder global $hookmanager, $conf; $action='create'; + $error = 0; // Actions on extra fields (by external module or standard code) // TODO le hook fait double emploi avec le trigger !! @@ -2872,7 +2876,7 @@ class Commande extends CommonOrder */ function LibStatut($statut,$billed,$mode) { - global $langs; + global $langs, $conf; //print 'x'.$statut.'-'.$billed; if ($mode == 0) { diff --git a/htdocs/commande/contact.php b/htdocs/commande/contact.php index 6a322e8681e..c72e040e61c 100644 --- a/htdocs/commande/contact.php +++ b/htdocs/commande/contact.php @@ -2,7 +2,7 @@ /* Copyright (C) 2005 Patrick Rouillon * Copyright (C) 2005-2011 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2011-2012 Philippe Grand + * Copyright (C) 2011-2015 Philippe Grand * * 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 @@ -69,11 +69,11 @@ if ($action == 'addcontact' && $user->rights->commande->creer) if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { $langs->load("errors"); - setEventMessage($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), 'errors'); + setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors'); } else { - setEventMessage($object->error, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } } } diff --git a/htdocs/commande/orderstoinvoice.php b/htdocs/commande/orderstoinvoice.php index 136ac6c1b89..1abffe069f4 100644 --- a/htdocs/commande/orderstoinvoice.php +++ b/htdocs/commande/orderstoinvoice.php @@ -74,7 +74,7 @@ if ($action == 'create') if (is_array($selected) == false) { $error++; - setEventMessage($langs->trans('Error_OrderNotChecked'), 'errors'); + setEventMessages($langs->trans('Error_OrderNotChecked'), null, 'errors'); } else { @@ -251,7 +251,7 @@ if (($action == 'create' || $action == 'add') && !$error) } else { - setEventMessage($discount->error, 'errors'); + setEventMessages($discount->error, $discount->errors, 'errors'); $error++; break; } @@ -320,7 +320,7 @@ if (($action == 'create' || $action == 'add') && !$error) } else { - setEventMessage($objectsrc->error, 'errors'); + setEventMessages($objectsrc->error, $objectsrc->errors, 'errors'); $error++; } $ii++; @@ -328,7 +328,7 @@ if (($action == 'create' || $action == 'add') && !$error) } else { - setEventMessage($object->error, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); $error++; } } @@ -348,7 +348,7 @@ if (($action == 'create' || $action == 'add') && !$error) $action='create'; $_GET["origin"]=$_POST["origin"]; $_GET["originid"]=$_POST["originid"]; - setEventMessage($object->error, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); $error++; } } diff --git a/htdocs/compta/bank/account.php b/htdocs/compta/bank/account.php index e3bc2a3fc2c..d6f8652d31c 100644 --- a/htdocs/compta/bank/account.php +++ b/htdocs/compta/bank/account.php @@ -152,13 +152,13 @@ if ($action == 'add' && $id && ! isset($_POST["cancel"]) && $user->rights->banqu $insertid = $object->addline($dateop, $operation, $label, $amount, $num_chq, $cat1, $user); if ($insertid > 0) { - setEventMessage($langs->trans("RecordSaved")); + setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); header("Location: ".$_SERVER['PHP_SELF']."?id=".$id."&action=addline"); exit; } else { - setEventMessage($object->error, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } } else @@ -378,19 +378,6 @@ if ($id > 0 || ! empty($ref)) { print '
'; - if ($object->type != 2 && $object->rappro) - { - // If not cash account and can be reconciliate - if ($user->rights->banque->consolidate) - { - print ''.$langs->trans("Conciliate").''; - } - else - { - print ''.$langs->trans("Conciliate").''; - } - } - if ($action != 'addline') { if (empty($conf->global->BANK_DISABLE_DIRECT_INPUT)) @@ -409,6 +396,20 @@ if ($id > 0 || ! empty($ref)) print ''.$langs->trans("AddBankRecord").''; } } + + if ($object->type != 2 && $object->rappro) + { + // If not cash account and can be reconciliate + if ($user->rights->banque->consolidate) + { + print ''.$langs->trans("Conciliate").''; + } + else + { + print ''.$langs->trans("Conciliate").''; + } + } + print '
'; } diff --git a/htdocs/compta/bank/annuel.php b/htdocs/compta/bank/annuel.php index 68ef0a42e32..7b53d775cb6 100644 --- a/htdocs/compta/bank/annuel.php +++ b/htdocs/compta/bank/annuel.php @@ -291,7 +291,7 @@ if ($result < 0) { $langs->load("errors"); $error++; - setEventMessage($langs->trans("ErrorFailedToCreateDir"), 'errors'); + setEventMessages($langs->trans("ErrorFailedToCreateDir"), null, 'errors'); } else { diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index 063fee8ca78..fb8383cd91a 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -4,7 +4,7 @@ * Copyright (C) 2004-2015 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2014-2015 Alexandre Spangaro - * Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2015 Jean-François Ferry * * 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 @@ -102,19 +102,19 @@ if ($_POST["action"] == 'add') if ($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED && empty($account->account_number)) { - setEventMessage($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("AccountancyCode")), 'error'); + setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("AccountancyCode")), null, 'error'); $action='create'; // Force chargement page en mode creation $error++; } if (empty($account->ref)) { - setEventMessage($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("Ref")), 'errors'); + setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("Ref")), null, 'errors'); $action='create'; // Force chargement page en mode creation $error++; } if (empty($account->label)) { - setEventMessage($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("LabelBankCashAccount")), 'errors'); + setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("LabelBankCashAccount")), null, 'errors'); $action='create'; // Force chargement page en mode creation $error++; } @@ -130,7 +130,7 @@ if ($_POST["action"] == 'add') $_GET["id"]=$id; // Force chargement page en mode visu } else { - setEventMessage($account->error,'errors'); + setEventMessages($account->error, $account->errors, 'errors'); $action='create'; // Force chargement page en mode creation } } @@ -177,19 +177,19 @@ if ($_POST["action"] == 'update' && ! $_POST["cancel"]) if ($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED && empty($account->account_number)) { - setEventMessage($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("AccountancyCode")), 'error'); + setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("AccountancyCode")), null, 'error'); $action='edit'; // Force chargement page en mode creation $error++; } if (empty($account->ref)) { - setEventMessage($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("Ref")), 'errors'); + setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("Ref")), null, 'errors'); $action='edit'; // Force chargement page en mode creation $error++; } if (empty($account->label)) { - setEventMessage($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("LabelBankCashAccount")), 'errors'); + setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("LabelBankCashAccount")), null, 'errors'); $action='edit'; // Force chargement page en mode creation $error++; } @@ -206,7 +206,7 @@ if ($_POST["action"] == 'update' && ! $_POST["cancel"]) } else { - setEventMessage($account->error, 'errors'); + setEventMessages($account->error, $account->errors, 'errors'); $action='edit'; // Force chargement page edition } } diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index e8978310ca3..65661b3cce8 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -998,7 +998,12 @@ class Account extends CommonObject $link = ''; + } + if ($withpicto) $result.=($link.img_object($label, 'account', 'class="classfortooltip"').$linkend.' '); $result.=$link.$this->label.$linkend; return $result; diff --git a/htdocs/compta/bank/document.php b/htdocs/compta/bank/document.php index 0b588fa64d0..3b6957df40f 100644 --- a/htdocs/compta/bank/document.php +++ b/htdocs/compta/bank/document.php @@ -133,9 +133,9 @@ else if ($action == 'confirm_deletefile' && $confirm == 'yes') { $ret = dol_delete_file($file, 0, 0, 0, $object); if ($ret) { - setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile'))); + setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs'); } else { - setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors'); + setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors'); } Header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $id); diff --git a/htdocs/compta/bank/graph.php b/htdocs/compta/bank/graph.php index 6f885e12bde..0764c87f5ab 100644 --- a/htdocs/compta/bank/graph.php +++ b/htdocs/compta/bank/graph.php @@ -81,7 +81,7 @@ if ($result < 0) { $langs->load("errors"); $error++; - setEventMessage($langs->trans("ErrorFailedToCreateDir"), 'errors'); + setEventMessages($langs->trans("ErrorFailedToCreateDir"), null, 'errors'); } else { @@ -113,7 +113,7 @@ else if ($mode == 'standard') { - // Chargement du tableau $amounts + // Loading table $amounts $amounts = array(); $monthnext = $month+1; @@ -153,7 +153,7 @@ else dol_print_error($db); } - // Calcul de $solde avant le debut du graphe + // Calculation of $solde before the start of the graph $solde = 0; $sql = "SELECT SUM(b.amount)"; @@ -265,7 +265,7 @@ else if ($mode == 'standard') { - // Chargement du tableau $amounts + // Loading table $amounts $amounts = array(); $sql = "SELECT date_format(b.datev,'%Y%m%d')"; $sql.= ", SUM(b.amount)"; @@ -296,7 +296,7 @@ else dol_print_error($db); } - // Calcul de $solde avant le debut du graphe + // Calculation of $solde before the start of the graph $solde = 0; $sql = "SELECT SUM(b.amount)"; @@ -403,7 +403,7 @@ else if ($mode == 'showalltime') { - // Chargement du tableau $amounts + // Loading table $amounts $amounts = array(); $sql = "SELECT date_format(b.datev,'%Y%m%d')"; diff --git a/htdocs/compta/bank/index.php b/htdocs/compta/bank/index.php index 46b382ed080..7ea3bf1be5a 100644 --- a/htdocs/compta/bank/index.php +++ b/htdocs/compta/bank/index.php @@ -113,7 +113,7 @@ foreach ($accounts as $key=>$type) { $result=$acc->load_board($user,$acc->id); if ($result<0) { - setEventMessage($acc->error, 'errors'); + setEventMessages($acc->error, $acc->errors, 'errors'); } else { print $result->nbtodo; if ($result->nbtodolate) print ' ('.$result->nbtodolate.img_warning($langs->trans("Late")).')'; @@ -229,7 +229,7 @@ foreach ($accounts as $key=>$type) { $result=$acc->load_board($user,$acc->id); if ($result<0) { - setEventMessage($acc->error, 'errors'); + setEventMessages($acc->error, $acc->errors, 'errors'); } else { print $result->nbtodo; if ($result->nbtodolate) print ' ('.$result->nbtodolate.img_warning($langs->trans("Late")).')'; diff --git a/htdocs/compta/bank/ligne.php b/htdocs/compta/bank/ligne.php index f1bb4eb9a62..0f73e5cb6cf 100644 --- a/htdocs/compta/bank/ligne.php +++ b/htdocs/compta/bank/ligne.php @@ -1,7 +1,7 @@ * Copyright (C) 2003 Xavier DUTOIT - * Copyright (C) 2004-2014 Laurent Destailleur + * Copyright (C) 2004-2015 Laurent Destailleur * Copyright (C) 2004 Christophe Combelles * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2015 Alexandre Spangaro @@ -104,7 +104,7 @@ if ($user->rights->banque->modifier && $action == "update") if ($ac->courant == 2 && $_POST['value'] != 'LIQ') { - setEventMessage($langs->trans("ErrorCashAccountAcceptsOnlyCashMoney"), 'errors'); + setEventMessages($langs->trans("ErrorCashAccountAcceptsOnlyCashMoney"), null, 'errors'); $error++; } @@ -146,7 +146,7 @@ if ($user->rights->banque->modifier && $action == "update") $result = $db->query($sql); if ($result) { - setEventMessage($langs->trans("RecordSaved")); + setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); $db->commit(); } else @@ -184,7 +184,7 @@ if ($user->rights->banque->consolidate && ($action == 'num_releve' || $action == $result = $db->query($sql); if ($result) { - setEventMessage($langs->trans("RecordSaved")); + setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); $db->commit(); } else @@ -205,7 +205,7 @@ $form = new Form($db); llxHeader(); -// On initialise la liste des categories +// The list of categories is initialized $sql = "SELECT rowid, label"; $sql.= " FROM ".MAIN_DB_PREFIX."bank_categ"; $sql.= " ORDER BY label"; @@ -587,7 +587,7 @@ if ($result) if ($user->rights->banque->consolidate) { print '
'; } else diff --git a/htdocs/compta/bank/rappro.php b/htdocs/compta/bank/rappro.php index 2bafa7e780e..82070a957e2 100644 --- a/htdocs/compta/bank/rappro.php +++ b/htdocs/compta/bank/rappro.php @@ -71,7 +71,7 @@ if ($action == 'rappro' && $user->rights->banque->consolidate) $result=$bankline->update_conciliation($user,$_POST["cat"]); if ($result < 0) { - setEventMessage($bankline->error, 'errors'); + setEventMessages($bankline->error, $bankline->errors, 'errors'); $error++; break; } @@ -83,7 +83,7 @@ if ($action == 'rappro' && $user->rights->banque->consolidate) { $error++; $langs->load("errors"); - setEventMessage($langs->trans("ErrorPleaseTypeBankTransactionReportName"), 'errors'); + setEventMessages($langs->trans("ErrorPleaseTypeBankTransactionReportName"), null, 'errors'); } if (! $error) @@ -186,7 +186,7 @@ if ($resql) print '
'; // Show last bank receipts - $nbmax=5; + $nbmax=15; // We accept to show last 15 receipts (so we can have more than one year) $liste=""; $sql = "SELECT DISTINCT num_releve FROM ".MAIN_DB_PREFIX."bank"; $sql.= " WHERE fk_account=".$acct->id." AND num_releve IS NOT NULL"; @@ -226,7 +226,7 @@ if ($resql) print ''; print ''.$langs->trans("InputReceiptNumber").': '; - print ''; + print ''; // The only default value is value we just entered print '
'; if ($options) { diff --git a/htdocs/compta/bank/releve.php b/htdocs/compta/bank/releve.php index 9620b00098b..84c2edde0dd 100644 --- a/htdocs/compta/bank/releve.php +++ b/htdocs/compta/bank/releve.php @@ -157,6 +157,7 @@ if (empty($num)) } print ''; + print '

'; print_barre_liste('', $page, $_SERVER["PHP_SELF"], "&account=".$object->id, $sortfield, $sortorder,'',$numrows); @@ -282,10 +283,15 @@ else $found=true; } - $mesprevnext ="
id\">".img_previous()."  "; - $mesprevnext.= $langs->trans("AccountStatement")." $num"; - $mesprevnext.="   id\">".img_next().""; - print load_fiche_titre($langs->trans("AccountStatement").' '.$num.', '.$langs->trans("BankAccount").' : '.$object->getNomUrl(0),$mesprevnext, 'title_bank.png'); + $mesprevnext=''; + $mesprevnext.=''; + print load_fiche_titre($langs->trans("AccountStatement").' '.$num.', '.$langs->trans("BankAccount").' : '.$object->getNomUrl(0, 'receipts'), $mesprevnext, 'title_bank.png'); print '
'; print ""; diff --git a/htdocs/compta/bank/virement.php b/htdocs/compta/bank/virement.php index 56071d61f9b..4e323893d85 100644 --- a/htdocs/compta/bank/virement.php +++ b/htdocs/compta/bank/virement.php @@ -113,18 +113,18 @@ if ($action == 'add') if (! $error) { $mesgs = $langs->trans("TransferFromToDone","id."\">".$accountfrom->label."","id."\">".$accountto->label."",$amount,$langs->transnoentities("Currency".$conf->currency)); - setEventMessage($mesgs); + setEventMessages($mesgs, null, 'mesgs'); $db->commit(); } else { - setEventMessage($accountfrom->error.' '.$accountto->error, 'errors'); + setEventMessages($accountfrom->error.' '.$accountto->error, null, 'errors'); $db->rollback(); } } else { - setEventMessage($langs->trans("ErrorFromToAccountsMustDiffers"), 'errors'); + setEventMessages($langs->trans("ErrorFromToAccountsMustDiffers"), null, 'errors'); } } } @@ -132,7 +132,7 @@ if ($action == 'add') /* - * Affichage + * View */ llxHeader(); diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index fee460c49ae..ca7afeb7959 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -63,6 +63,7 @@ class Facture extends CommonInvoice var $author; var $fk_user_author; var $fk_user_valid; + var $date; // Date invoice var $date_creation; // Creation date var $date_validation; // Validation date var $datem; @@ -385,6 +386,8 @@ class Facture extends CommonInvoice { $newinvoiceline=$this->lines[$i]; $newinvoiceline->fk_facture=$this->id; + $newinvoiceline->origin = $this->element; + $newinvoiceline->origin_id = $this->lines[$i]->id; if ($result >= 0 && ($newinvoiceline->info_bits & 0x01) == 0) // We keep only lines with first bit = 0 { // Reset fk_parent_line for no child products and special product @@ -441,8 +444,8 @@ class Facture extends CommonInvoice $this->lines[$i]->product_type, $this->lines[$i]->rang, $this->lines[$i]->special_code, - '', - 0, + $this->element, + $this->lines[$i]->id, $fk_parent_line, $this->lines[$i]->fk_fournprice, $this->lines[$i]->pa_ht, @@ -873,7 +876,7 @@ class Facture extends CommonInvoice */ function getNomUrl($withpicto=0,$option='',$max=0,$short=0,$moretitle='') { - global $langs; + global $langs, $conf; $result=''; diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index 7466686239a..8c028b23aaa 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -415,7 +415,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print ''; print ''; diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index ee5c24f3017..d10e34227d6 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -122,6 +122,34 @@ $fieldstosearchall = array( 's.nom'=>"ThirdParty", ); +// Definition of fields for list +$arrayfields=array( + 'p.lastname'=>array('label'=>$langs->trans("Lastname"), 'checked'=>1), + 'p.firstname'=>array('label'=>$langs->trans("Firsname"), 'checked'=>1), + 'p.poste'=>array('label'=>$langs->trans("Post"), 'checked'=>1), + 'p.town'=>array('label'=>$langs->trans("Town"), 'checked'=>0), + 'p.zip'=>array('label'=>$langs->trans("Zip"), 'checked'=>0), + 'p.phone'=>array('label'=>$langs->trans("PhonePro"), 'checked'=>1), + 'p.phone_perso'=>array('label'=>$langs->trans("PhonePerso"), 'checked'=>0), + 'p.phone_mobile'=>array('label'=>$langs->trans("PhoneMobile"), 'checked'=>1), + 'p.fax'=>array('label'=>$langs->trans("Fax"), 'checked'=>1), + 'p.email'=>array('label'=>$langs->trans("Email"), 'checked'=>1), + 'p.skype'=>array('label'=>$langs->trans("Skype"), 'checked'=>1, 'enabled'=>(! empty($conf->skype->enabled))), + 'p.thirdparty'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1, 'enabled'=>empty($conf->global->SOCIETE_DISABLE_CONTACTS)), + 'p.priv'=>array('label'=>$langs->trans("ContactVisibility"), 'checked'=>1, 'position'=>200), + 'p.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), + 'p.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), + 'p.statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000), +); +// Extra fields +if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) +{ + foreach($extrafields->attribute_label as $key => $val) + { + $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); + } +} + /* * Actions @@ -386,35 +414,10 @@ if ($result) print ''; } - $arrayfields=array( - 'p.lastname'=>array('label'=>$langs->trans("Lastname"), 'checked'=>1), - 'p.firstname'=>array('label'=>$langs->trans("Firsname"), 'checked'=>1), - 'p.poste'=>array('label'=>$langs->trans("Post"), 'checked'=>1), - 'p.town'=>array('label'=>$langs->trans("Town"), 'checked'=>0), - 'p.zip'=>array('label'=>$langs->trans("Zip"), 'checked'=>0), - 'p.phone'=>array('label'=>$langs->trans("PhonePro"), 'checked'=>1), - 'p.phone_perso'=>array('label'=>$langs->trans("PhonePerso"), 'checked'=>0), - 'p.phone_mobile'=>array('label'=>$langs->trans("PhoneMobile"), 'checked'=>1), - 'p.fax'=>array('label'=>$langs->trans("Fax"), 'checked'=>1), - 'p.email'=>array('label'=>$langs->trans("Email"), 'checked'=>1), - 'p.skype'=>array('label'=>$langs->trans("Skype"), 'checked'=>1, 'enabled'=>(! empty($conf->skype->enabled))), - 'p.thirdparty'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1, 'enabled'=>empty($conf->global->SOCIETE_DISABLE_CONTACTS)), - 'p.priv'=>array('label'=>$langs->trans("ContactVisibility"), 'checked'=>1, 'position'=>200), - 'p.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), - 'p.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), - 'p.statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000), - ); - // Extra fields - if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) - { - foreach($extrafields->attribute_label as $key => $val) - { - $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); - } - } $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - print '
'.$label.'
'; - print 'rappro?' checked':'')).'">'; + print 'rappro?' checked="checked"':'')).'">'; print '
'.$langs->trans('Date').''; $datepayment = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); $datepayment= ($datepayment == '' ? (empty($conf->global->MAIN_AUTOFILL_DATE)?-1:'') : $datepayment); - $form->select_date($datepayment,'','','',0,"add_paiement",1,1); + $form->select_date($datepayment,'','','',0,"add_paiement",1,1,0,0,'','',$facture->date); print ''.$langs->trans('Comments').'
'; + + print '
'; // Ligne des titres print ''; diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index c53d1b793f3..645b50cb8bc 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -258,7 +258,7 @@ class ExtraFields if (! empty($attrname) && preg_match("/^\w[a-zA-Z0-9-_]*$/",$attrname) && ! is_numeric($attrname)) { - if(is_array($param) and count($param) > 0) + if(is_array($param) && count($param) > 0) { $params = $this->db->escape(serialize($param)); } diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 10f5fc25695..393560b4640 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1546,7 +1546,7 @@ class Form print img_picto($langs->trans("Search"), 'search'); } } - print ''; + print ''; if ($hidelabel == 3) { print img_picto($langs->trans("Search"), 'search'); } @@ -1663,7 +1663,7 @@ class Form require_once DOL_DOCUMENT_ROOT.'/product/dynamic_price/class/price_parser.class.php'; $num = $this->db->num_rows($result); - $out.=''; $out.=''; $i = 0; @@ -4057,10 +4057,11 @@ class Form * @param int $disabled Disable input fields * @param int $fullday When a checkbox with this html name is on, hour and day are set with 00:00 or 23:59 * @param string $addplusone Add a link "+1 hour". Value must be name of another select_date field. + * @param datetime $adddateof Add a link "Date of invoice" using the following date. * @return mixed Nothing or string if nooutput is 1 * @see form_date */ - function select_date($set_time='', $prefix='re', $h=0, $m=0, $empty=0, $form_name="", $d=1, $addnowlink=0, $nooutput=0, $disabled=0, $fullday='', $addplusone='') + function select_date($set_time='', $prefix='re', $h=0, $m=0, $empty=0, $form_name="", $d=1, $addnowlink=0, $nooutput=0, $disabled=0, $fullday='', $addplusone='', $adddateof='') { global $conf,$langs; @@ -4318,6 +4319,13 @@ class Form } } + // Add a "Plus one hour" link + if ($conf->use_javascript_ajax && $adddateof) + { + $tmparray=dol_getdate($adddateof); + $retstring.=' -
'; - // looking for a token already stored in db - //try { - // $token = $storage->retrieveAccessToken('Google'); - // $old_token=1; - //} catch (Exception $e) { - // $old_token=0; - //} - //if ($old_token==1) { - // print ''; - // print ''; - //} - //$refreshtoken = $token->getRefreshToken(); + //print '
'.$langs->trans('OldTokenStored').'
'.print_r($token,true).'
'; // This was a callback request from service, get the token try { - $apiService->requestAccessToken($_GET['code'], $state); + //var_dump($_GET['code']); + //var_dump($state); + //var_dump($apiService); // OAuth\OAuth2\Service\Google + $token = $apiService->requestAccessToken($_GET['code'], $state); + + setEventMessages($langs->trans('NewTokenStored'), null, 'mesgs'); } catch (Exception $e) { print $e->getMessage(); } - //print '
'.print_r($apiService,true).'
'; - // retrieve new token in db - try { - $token = $storage->retrieveAccessToken('Google'); - $new_token=1; - } catch (Exception $e) { - $new_token=0; - } - $newrefreshtoken = $token->getRefreshToken(); - if (empty($newrefreshtoken) && ! empty($refreshtoken)) { - $token->setRefreshToken($refreshtoken); - $storage->storeAccessToken('Google', $token); - } - if ($new_token==1) { - print ''; - print ''; - } - //print ''; - //$apiService->refreshAccessToken($token); - //print '
'.print_r($apiService,true).'
'; - //$token = $storage->retrieveAccessToken('Google'); - //print ''; - print ''; - print '
'.$langs->trans('NewTokenStored').'
'.print_r($token,true).'
'.print_r($token,true).'
'.print_r($token,true).'
Applications associées à votre compte
'; - - dol_fiche_end(); -} else { + $backtourl = $_SESSION["backtourlsavedbeforeoauthjump"]; + unset($_SESSION["backtourlsavedbeforeoauthjump"]); + + header('Location: ' . $backtourl); + exit(); +} +else +{ + $_SESSION["backtourlsavedbeforeoauthjump"]=$backtourl; + $url = $apiService->getAuthorizationUri(); // we go on google authorization page header('Location: ' . $url); exit(); } -llxFooter(); + +/* + * View + */ + +// No view at all, just actions $db->close(); + diff --git a/htdocs/core/modules/printing/printgcp.modules.php b/htdocs/core/modules/printing/printgcp.modules.php index 7010ec7de78..aab1ae13bb6 100644 --- a/htdocs/core/modules/printing/printgcp.modules.php +++ b/htdocs/core/modules/printing/printgcp.modules.php @@ -87,6 +87,8 @@ class printing_printgcp extends PrintingDriver $this->errors[] = $e->getMessage(); $token_ok = false; } + //var_dump($this->errors);exit; + $expire = false; // Is token expired or will token expire in the next 30 seconds if ($token_ok) { @@ -116,12 +118,12 @@ class printing_printgcp extends PrintingDriver $refreshtoken = $token->getRefreshToken(); $this->conf[] = array('varname'=>'PRINTGCP_TOKEN_REFRESH', 'info'=>((! empty($refreshtoken))?'Yes':'No'), 'type'=>'info'); $this->conf[] = array('varname'=>'PRINTGCP_TOKEN_EXPIRED', 'info'=>($expire?'Yes':'No'), 'type'=>'info'); - $this->conf[] = array('varname'=>'PRINTGCP_TOKEN_EXPIRE_AT', 'info'=>(date("Y-m-d H:i:s", $token->getEndOfLife())), 'type'=>'info'); + $this->conf[] = array('varname'=>'PRINTGCP_TOKEN_EXPIRE_AT', 'info'=>(dol_print_date($token->getEndOfLife(), "dayhour")), 'type'=>'info'); } if (!$storage->hasAccessToken('Google')) { - $this->conf[] = array('varname'=>'PRINTGCP_AUTHLINK', 'link'=>$urlwithroot.'/core/modules/oauth/getgoogleoauthcallback.php', 'type'=>'authlink'); + $this->conf[] = array('varname'=>'PRINTGCP_AUTHLINK', 'link'=>$urlwithroot.'/core/modules/oauth/getgoogleoauthcallback.php?backtourl='.urlencode(DOL_URL_ROOT.'/printing/admin/printing.php?mode=setup&driver=printgcp'), 'type'=>'authlink'); } else { - $this->conf[] = array('varname'=>'PRINTGCP_DELETE_TOKEN', 'link'=>$urlwithroot.'/core/modules/oauth/getgoogleoauthcallback.php?action=delete', 'type'=>'delete'); + $this->conf[] = array('varname'=>'PRINTGCP_DELETE_TOKEN', 'link'=>$urlwithroot.'/core/modules/oauth/getgoogleoauthcallback.php?action=delete&backtourl='.urlencode(DOL_URL_ROOT.'/printing/admin/printing.php?mode=setup&driver=printgcp'), 'type'=>'delete'); } } else { $this->conf[] = array('varname'=>'PRINTGCP_INFO', 'info'=>'GoogleAuthNotConfigured', 'type'=>'info'); diff --git a/htdocs/core/modules/project/doc/pdf_beluga.modules.php b/htdocs/core/modules/project/doc/pdf_beluga.modules.php index 4a8839ef865..11b1d378981 100644 --- a/htdocs/core/modules/project/doc/pdf_beluga.modules.php +++ b/htdocs/core/modules/project/doc/pdf_beluga.modules.php @@ -94,8 +94,8 @@ class pdf_beluga extends ModelePDFProjects $this->posxref=$this->marge_gauche+1; $this->posxdate=$this->marge_gauche+25; $this->posxsociety=$this->marge_gauche+45; - $this->posxamountht=$this->marge_gauche+115; - $this->posxamountttc=$this->marge_gauche+140; + $this->posxamountht=$this->marge_gauche+110; + $this->posxamountttc=$this->marge_gauche+135; $this->posxstatut=$this->marge_gauche+165; } @@ -231,14 +231,16 @@ class pdf_beluga extends ModelePDFProjects 'class'=>'Propal', 'table'=>'propal', 'datefieldname'=>'datep', - 'test'=>$conf->propal->enabled && $user->rights->propale->lire), + 'test'=>$conf->propal->enabled && $user->rights->propale->lire, + 'lang'=>'propal'), 'order'=>array( 'name'=>"CustomersOrders", 'title'=>"ListOrdersAssociatedProject", 'class'=>'Commande', 'table'=>'commande', 'datefieldname'=>'date_commande', - 'test'=>$conf->commande->enabled && $user->rights->commande->lire), + 'test'=>$conf->commande->enabled && $user->rights->commande->lire, + 'lang'=>'order'), 'invoice'=>array( 'name'=>"CustomersInvoices", 'title'=>"ListInvoicesAssociatedProject", @@ -246,21 +248,24 @@ class pdf_beluga extends ModelePDFProjects 'margin'=>'add', 'table'=>'facture', 'datefieldname'=>'datef', - 'test'=>$conf->facture->enabled && $user->rights->facture->lire), + 'test'=>$conf->facture->enabled && $user->rights->facture->lire, + 'lang'=>'bills'), 'invoice_predefined'=>array( 'name'=>"PredefinedInvoices", 'title'=>"ListPredefinedInvoicesAssociatedProject", 'class'=>'FactureRec', 'table'=>'facture_rec', 'datefieldname'=>'datec', - 'test'=>$conf->facture->enabled && $user->rights->facture->lire), + 'test'=>$conf->facture->enabled && $user->rights->facture->lire, + 'lang'=>'bills'), 'order_supplier'=>array( 'name'=>"SuppliersOrders", 'title'=>"ListSupplierOrdersAssociatedProject", 'class'=>'CommandeFournisseur', 'table'=>'commande_fournisseur', 'datefieldname'=>'date_commande', - 'test'=>$conf->fournisseur->enabled && $user->rights->fournisseur->commande->lire), + 'test'=>$conf->fournisseur->enabled && $user->rights->fournisseur->commande->lire, + 'lang'=>'orders'), 'invoice_supplier'=>array( 'name'=>"BillsSuppliers", 'title'=>"ListSupplierInvoicesAssociatedProject", @@ -268,14 +273,16 @@ class pdf_beluga extends ModelePDFProjects 'margin'=>'minus', 'table'=>'facture_fourn', 'datefieldname'=>'datef', - 'test'=>$conf->fournisseur->enabled && $user->rights->fournisseur->facture->lire), + 'test'=>$conf->fournisseur->enabled && $user->rights->fournisseur->facture->lire, + 'lang'=>'bills'), 'contract'=>array( 'name'=>"Contracts", 'title'=>"ListContractAssociatedProject", 'class'=>'Contrat', 'table'=>'contrat', 'datefieldname'=>'date_contrat', - 'test'=>$conf->contrat->enabled && $user->rights->contrat->lire), + 'test'=>$conf->contrat->enabled && $user->rights->contrat->lire, + 'lang'=>'contract'), 'intervention'=>array( 'name'=>"Interventions", 'title'=>"ListFichinterAssociatedProject", @@ -283,7 +290,8 @@ class pdf_beluga extends ModelePDFProjects 'table'=>'fichinter', 'datefieldname'=>'date_valid', 'disableamount'=>1, - 'test'=>$conf->ficheinter->enabled && $user->rights->ficheinter->lire), + 'test'=>$conf->ficheinter->enabled && $user->rights->ficheinter->lire, + 'lang'=>'interventions'), 'trip'=>array( 'name'=>"TripsAndExpenses", 'title'=>"ListTripAssociatedProject", @@ -292,7 +300,18 @@ class pdf_beluga extends ModelePDFProjects 'datefieldname'=>'dated', 'margin'=>'minus', 'disableamount'=>1, - 'test'=>$conf->deplacement->enabled && $user->rights->deplacement->lire), + 'test'=>$conf->deplacement->enabled && $user->rights->deplacement->lire, + 'lang'=>'trip'), + 'expensereport'=>array( + 'name'=>"ExpensesReports", + 'title'=>"ListTripAssociatedProject", + 'class'=>'ExpenseReport', + 'table'=>'expensereport', + 'datefieldname'=>'dated', + 'margin'=>'minus', + 'disableamount'=>1, + 'test'=>$conf->expensereport->enabled && $user->rights->expensereport->lire, + 'lang'=>'trip'), 'agenda'=>array( 'name'=>"Agenda", 'title'=>"ListActionsAssociatedProject", @@ -300,7 +319,8 @@ class pdf_beluga extends ModelePDFProjects 'table'=>'actioncomm', 'datefieldname'=>'datep', 'disableamount'=>1, - 'test'=>$conf->agenda->enabled && $user->rights->agenda->allactions->lire) + 'test'=>$conf->agenda->enabled && $user->rights->agenda->allactions->read, + 'lang'=>'agenda') ); @@ -311,12 +331,17 @@ class pdf_beluga extends ModelePDFProjects $tablename=$value['table']; $datefieldname=$value['datefieldname']; $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) + if ($num >= 0) { $nexY = $pdf->GetY() + 5; $curY = $nexY; @@ -334,9 +359,9 @@ class pdf_beluga extends ModelePDFProjects $pdf->MultiCell($this->posxamountht - $this->posxsociety, 3, $outputlangs->transnoentities("ThirdParty"), 1, 'L'); if (empty($value['disableamount'])) { $pdf->SetXY($this->posxamountht, $curY); - $pdf->MultiCell($this->posxamountttc - $this->posxamountht, 3, $outputlangs->transnoentities("AmountHT"), 1, 'R'); + $pdf->MultiCell($this->posxamountttc - $this->posxamountht, 3, $outputlangs->transnoentities("AmountHTShort"), 1, 'R'); $pdf->SetXY($this->posxamountttc, $curY); - $pdf->MultiCell($this->posxstatut - $this->posxamountttc, 3, $outputlangs->transnoentities("AmountTTC"), 1, 'R'); + $pdf->MultiCell($this->posxstatut - $this->posxamountttc, 3, $outputlangs->transnoentities("AmountTTCShort"), 1, 'R'); } else { $pdf->SetXY($this->posxamountht, $curY); $pdf->MultiCell($this->posxstatut - $this->posxamountht, 3, "", 1, 'R'); @@ -434,8 +459,6 @@ class pdf_beluga extends ModelePDFProjects } } - - /* * Pied de page */ diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index edb065c9d9b..c757efa23b4 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -5,6 +5,7 @@ * Copyright (C) 2012 Cédric Salvador * Copyright (C) 2014 Florian Henry * Copyright (C) 2014 Raphaël Doursenaud + * Copyright (C) 2015 Marcos García * * 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 @@ -315,14 +316,39 @@ else { service->enabled) || ($object->element == 'contrat')) && $dateSelector && GETPOST('type') != '0') // We show date field if required { - if(! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) $colspan = 10; - else $colspan = 9; - if($this->situation_cycle_ref) $colspan++; - if (! empty($inputalsopricewithtax)) $colspan++; // We add 1 if col total ttc - if (in_array($object->element,array('propal','askpricesupplier','facture','invoice','commande','order','order_supplier','invoice_supplier'))) $colspan++; // With this, there is a column move button + $colspan = 6; + + if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { + $colspan++; + } + if ($this->situation_cycle_ref) { + $colspan++; + } + // We add 1 if col total ttc + if (!empty($inputalsopricewithtax)) { + $colspan++; + } if ($conf->global->PRODUCT_USE_UNITS) { $colspan++; } + if (count($object->lines)) { + //There will be an edit and a delete button + $colspan += 2; + + // With this, there is a column move button ONLY if lines > 1 + if (in_array($object->element, array( + 'propal', + 'askpricesupplier', + 'facture', + 'invoice', + 'commande', + 'order', + 'order_supplier', + 'invoice_supplier' + ))) { + $colspan++; + } + } if (! empty($usemargins)) { @@ -497,7 +523,6 @@ jQuery(document).ready(function() { /* When changing predefined product, we reload list of supplier prices */ $("#idprod, #idprodfournprice").change(function() { - console.log("change #idprod, #idprodfournprice, conf->global->MARGIN_TYPE=global->MARGIN_TYPE ?>"); setforpredef(); jQuery('#trlinefordates').show(); diff --git a/htdocs/exports/class/export.class.php b/htdocs/exports/class/export.class.php index 88e4ecc8596..3a3436c71a9 100644 --- a/htdocs/exports/class/export.class.php +++ b/htdocs/exports/class/export.class.php @@ -107,7 +107,7 @@ class Export if ($enabled) { - // Chargement de la classe + // Loading Class $file = $dir.$modulename.".class.php"; $classname = $modulename; require_once $file; diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 4252e4a9ef6..a46c5e6ca38 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -273,7 +273,7 @@ if ($resql) if ($search_all) { foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print $langs->trans("FilterOnInto", $search_all, join(', ',$fieldstosearchall)); + print $langs->transnoentities("FilterOnInto", $search_all, join(', ',$fieldstosearchall)); } print ''; diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php index 76497bf4300..82bccf3df19 100644 --- a/htdocs/fourn/facture/paiement.php +++ b/htdocs/fourn/facture/paiement.php @@ -257,7 +257,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie $dateinvoice=($datefacture==''?(empty($conf->global->MAIN_AUTOFILL_DATE)?-1:''):$datefacture); $sql = 'SELECT s.nom as name, s.rowid as socid,'; - $sql.= ' f.rowid, f.ref, f.ref_supplier, f.amount, f.total_ttc as total'; + $sql.= ' f.rowid, f.ref, f.ref_supplier, f.amount, f.total_ttc as total, fk_mode_reglement, fk_account'; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user "; $sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s, '.MAIN_DB_PREFIX.'facture_fourn as f'; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -292,11 +292,11 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print $supplierstatic->getNomUrl(1,'supplier'); print ''; print ''; print ''; print ''; print ''; @@ -304,7 +304,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie if (! empty($conf->banque->enabled)) { print ''; } else diff --git a/htdocs/hrm/admin/admin_establishment.php b/htdocs/hrm/admin/admin_establishment.php index 771f2e243bc..26e11dd6b94 100644 --- a/htdocs/hrm/admin/admin_establishment.php +++ b/htdocs/hrm/admin/admin_establishment.php @@ -33,9 +33,13 @@ if (! $user->admin) $error=0; -$action = GETPOST('action', 'alpha'); - -$object = new Establishment($db); +// List of statut +static $tmpstatus2label=array( + '0'=>'OpenEtablishment', + '1'=>'CloseEtablishment' +); +$status2label=array(''); +foreach ($tmpstatus2label as $key => $val) $status2label[$key]=$langs->trans($val); /* * Actions @@ -44,10 +48,24 @@ $object = new Establishment($db); /* * View */ -$page_name = "Establishments"; -llxHeader('', $langs->trans($page_name)); +llxHeader('', $langs->trans("Establishments")); + +$sortorder = GETPOST("sortorder"); +$sortfield = GETPOST("sortfield"); +if (!$sortorder) $sortorder="DESC"; +if (!$sortfield) $sortfield="e.rowid"; + +if ($page == -1) { + $page = 0 ; +} + +$offset = $conf->liste_limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; +$limit = $conf->liste_limit; $form = new Form($db); +$establishmenttmp=new Establishment($db); dol_htmloutput_mesg($mesg); @@ -62,43 +80,50 @@ dol_fiche_head($head, 'establishments', $langs->trans("HRM"), 0, "user"); $sql = "SELECT e.rowid, e.name, e.address, e.zip, e.town, e.status"; $sql.= " FROM ".MAIN_DB_PREFIX."establishment as e"; $sql.= " WHERE e.entity = ".$conf->entity; +$sql.= $db->order($sortfield,$sortorder); +$sql.= $db->plimit($limit+1, $offset); $result = $db->query($sql); if ($result) { - $var=false; - $num = $db->num_rows($result); - - $i = 0; + $num = $db->num_rows($result); + $i = 0; // Load attribute_label print '
'.$langs->trans('Date').''; - $form->select_date($dateinvoice,'','','','',"addpaiement",1,1); + $form->select_date($dateinvoice,'','','','',"addpaiement",1,1,0,0,'','',$object->date); print ''.$langs->trans('Comments').'
'.$langs->trans('PaymentMode').''; - $form->select_types_paiements(empty($_POST['paiementid'])?'':$_POST['paiementid'],'paiementid'); + $form->select_types_paiements(empty($_POST['paiementid'])?$obj->fk_mode_reglement:$_POST['paiementid'],'paiementid'); print ''; print '
'.$langs->trans('Account').''; - $form->select_comptes(empty($accountid)?'':$accountid,'accountid',0,'',2); + $form->select_comptes(empty($accountid)?$obj->fk_account:$accountid,'accountid',0,'',2); print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + print ""; + print_liste_field_titre($langs->trans("Name"),$_SERVER["PHP_SELF"],"e.name","","","",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Address"),$_SERVER["PHP_SELF"],"e.address","","","",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Zipcode"),$_SERVER["PHP_SELF"],"e.zip","","","",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Town"),$_SERVER["PHP_SELF"],"e.town","","","",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"e.status","","",'align="right"',$sortfield,$sortorder); + print "\n"; - if ($num) + $var=true; + + if ($num > 0) { $establishmentstatic=new Establishment($db); - while ($i < $num && $i < $max) - { + while ($i < min($num,$limit)) + { $obj = $db->fetch_object($result); - $fiscalyearstatic->id=$obj->rowid; - print ''; - print ''; - print ''; + + $establishmentstatic->id=$obj->rowid; + $establishmentstatic->name=$obj->name; + + $var=!$var; + print ''; + print ''; print ''; print ''; print ''; - print ''; - print ''; - $var=!$var; + + print ''; + print "\n"; + $i++; } diff --git a/htdocs/hrm/class/employee.class.php b/htdocs/hrm/class/employee.class.php index 4014bb717f2..1a1350b3b63 100644 --- a/htdocs/hrm/class/employee.class.php +++ b/htdocs/hrm/class/employee.class.php @@ -67,26 +67,41 @@ class Employee extends CommonObject * @param int $id Id of record to load * @return int <0 if KO, >0 if OK */ - function fetch($id) + function fetch($id='') { - $sql = "SELECT rowid, firstname, lastname, status, fk_user"; - $sql.= " FROM ".MAIN_DB_PREFIX."user"; + global $conf, $user; + + $sql = "SELECT e.rowid, e.firstname, e.lastname, e.gender, e.email, e.statut, e.entity, e.fk_user"; + $sql.= " FROM ".MAIN_DB_PREFIX."user as e"; $sql.= " WHERE rowid = ".$id; dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $result = $this->db->query($sql); - if ( $result ) + if ($result) { $obj = $this->db->fetch_object($result); + if ($obj) + { + $this->id = $obj->rowid; + $this->lastname = $obj->lastname; + $this->firstname = $obj->firstname; + $this->gender = $obj->gender; + $this->address = $obj->address; + $this->zip = $obj->zip; + $this->town = $obj->town; + $this->statut = $obj->statut; + $this->photo = $obj->photo; - $this->id = $obj->rowid; - $this->name = $obj->name; - $this->address = $obj->address; - $this->zip = $obj->zip; - $this->town = $obj->town; - $this->status = $obj->status; + $this->db->free($result); + } + else + { + $this->error="EMPLOYEENOTFOUND"; + dol_syslog(get_class($this)."::fetch user not found", LOG_DEBUG); - return 1; + $this->db->free($result); + return 0; + } } else { diff --git a/htdocs/hrm/class/establishment.class.php b/htdocs/hrm/class/establishment.class.php index c5ba77fd547..88b765740ef 100644 --- a/htdocs/hrm/class/establishment.class.php +++ b/htdocs/hrm/class/establishment.class.php @@ -34,6 +34,7 @@ class Establishment extends CommonObject public $fk_element = 'fk_establishment'; protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe + var $id; var $rowid; var $name; @@ -43,6 +44,8 @@ class Establishment extends CommonObject var $status; // 0=open, 1=closed var $entity; + var $country_id; + var $statuts=array(); var $statuts_short=array(); @@ -69,12 +72,18 @@ class Establishment extends CommonObject */ function create($user) { - global $conf; + global $conf, $langs; $error = 0; - + $ret = 0; $now=dol_now(); + // Clean parameters + $this->address=($this->address>0?$this->address:$this->address); + $this->zip=($this->zip>0?$this->zip:$this->zip); + $this->town=($this->town>0?$this->town:$this->town); + $this->country_id=($this->country_id>0?$this->country_id:$this->country_id); + $this->db->begin(); $sql = "INSERT INTO ".MAIN_DB_PREFIX."establishment ("; @@ -83,22 +92,22 @@ class Establishment extends CommonObject $sql.= ", zip"; $sql.= ", town"; $sql.= ", status"; + $sql.= ", fk_country"; $sql.= ", entity"; $sql.= ", datec"; $sql.= ", fk_user_author"; $sql.= ") VALUES ("; - $sql.= " '".$this->name."'"; - $sql.= ", '".$this->address."'"; - $sql.= ", '".$this->zip."'"; - $sql.= ", '".$this->town."'"; + $sql.= " '".$this->db->escape($this->name)."'"; + $sql.= ", '".$this->db->escape($this->address)."'"; + $sql.= ", '".$this->db->escape($this->zip)."'"; + $sql.= ", '".$this->db->escape($this->town)."'"; + $sql.= ", ".$this->country_id; $sql.= ", ".$this->status; $sql.= ", ".$conf->entity; $sql.= ", '".$this->db->idate($now)."'"; $sql.= ", ". $user->id; $sql.= ")"; - $this->db->begin(); - dol_syslog(get_class($this)."::create", LOG_DEBUG); $resql = $this->db->query($sql); if (! $resql) { @@ -148,6 +157,7 @@ class Establishment extends CommonObject $sql .= ", address = '".$this->address."'"; $sql .= ", zip = '".$this->zip."'"; $sql .= ", town = '".$this->town."'"; + $sql .= ", status = '".$this->status."'"; $sql .= ", fk_user_mod = " . $user->id; $sql .= " WHERE rowid = ".$this->id; @@ -172,9 +182,11 @@ class Establishment extends CommonObject */ function fetch($id) { - $sql = "SELECT rowid, name, address, zip, town, status"; - $sql.= " FROM ".MAIN_DB_PREFIX."establishment"; - $sql.= " WHERE rowid = ".$id; + $sql = "SELECT e.rowid, e.name, e.address, e.zip, e.town, e.status, e.fk_country as country_id,"; + $sql.= ' c.code as country_code, c.label as country'; + $sql.= " FROM ".MAIN_DB_PREFIX."establishment as e"; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON e.fk_country = c.rowid'; + $sql.= " WHERE e.rowid = ".$id; dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $result = $this->db->query($sql); @@ -189,6 +201,10 @@ class Establishment extends CommonObject $this->town = $obj->town; $this->status = $obj->status; + $this->country_id = $obj->country_id; + $this->country_code = $obj->country_code; + $this->country = $obj->country; + return 1; } else @@ -257,23 +273,23 @@ class Establishment extends CommonObject } if ($mode == 2) { - if ($status==0) return img_picto($langs->trans($this->statuts_short[$status]),'status4').' '.$langs->trans($this->statuts_short[$status]); - if ($status==1) return img_picto($langs->trans($this->statuts_short[$status]),'status8').' '.$langs->trans($this->statuts_short[$status]); + if ($status==0) return img_picto($langs->trans($this->statuts_short[$status]),'statut4').' '.$langs->trans($this->statuts_short[$status]); + if ($status==1) return img_picto($langs->trans($this->statuts_short[$status]),'statut8').' '.$langs->trans($this->statuts_short[$status]); } if ($mode == 3) { - if ($status==0 && ! empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]),'status4'); - if ($status==1 && ! empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]),'status8'); + if ($status==0 && ! empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]),'statut4'); + if ($status==1 && ! empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]),'statut8'); } if ($mode == 4) { - if ($status==0 && ! empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]),'status4').' '.$langs->trans($this->statuts[$status]); - if ($status==1 && ! empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]),'status8').' '.$langs->trans($this->statuts[$status]); + if ($status==0 && ! empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]),'statut4').' '.$langs->trans($this->statuts[$status]); + if ($status==1 && ! empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]),'statut8').' '.$langs->trans($this->statuts[$status]); } if ($mode == 5) { - if ($status==0 && ! empty($this->statuts_short[$status])) return $langs->trans($this->statuts_short[$status]).' '.img_picto($langs->trans($this->statuts_short[$status]),'status4'); - if ($status==1 && ! empty($this->statuts_short[$status])) return $langs->trans($this->statuts_short[$status]).' '.img_picto($langs->trans($this->statuts_short[$status]),'status8'); + if ($status==0 && ! empty($this->statuts_short[$status])) return $langs->trans($this->statuts_short[$status]).' '.img_picto($langs->trans($this->statuts_short[$status]),'statut4'); + if ($status==1 && ! empty($this->statuts_short[$status])) return $langs->trans($this->statuts_short[$status]).' '.img_picto($langs->trans($this->statuts_short[$status]),'statut8'); } } @@ -298,20 +314,22 @@ class Establishment extends CommonObject { $obj = $this->db->fetch_object($result); $this->id = $obj->rowid; + + $this->date_creation = $this->db->jdate($obj->datec); if ($obj->fk_user_author) { $cuser = new User($this->db); $cuser->fetch($obj->fk_user_author); $this->user_creation = $cuser; } - if ($obj->fk_user_modif) + if ($obj->fk_user_mod) { $muser = new User($this->db); $muser->fetch($obj->fk_user_mod); $this->user_modification = $muser; + + $this->date_modification = $this->db->jdate($obj->tms); } - $this->date_creation = $this->db->jdate($obj->datec); - $this->date_modification = $this->db->jdate($obj->tms); } $this->db->free($result); } @@ -321,4 +339,46 @@ class Establishment extends CommonObject } } + /** + * Return clicable name (with picto eventually) + * + * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto + * @return string String with URL + */ + function getNomUrl($withpicto=0) + { + global $langs; + + $result=''; + + $link = ''; + $linkend=''; + + $picto='building'; + + $label=$langs->trans("Show").': '.$this->name; + + if ($withpicto) $result.=($link.img_object($label,$picto).$linkend); + if ($withpicto && $withpicto != 2) $result.=' '; + if ($withpicto != 2) $result.=$link.$this->name.$linkend; + return $result; + } + + /** + * Return account country code + * + * @return string country code + */ + function getCountryCode() + { + global $mysoc; + + // We return country code of bank account + if (! empty($this->country_code)) return $this->country_code; + + // We return country code of managed company + if (! empty($mysoc->country_code)) return $mysoc->country_code; + + return ''; + } } diff --git a/htdocs/hrm/employee/list.php b/htdocs/hrm/employee/list.php index 1635ba41cda..46c59e90937 100644 --- a/htdocs/hrm/employee/list.php +++ b/htdocs/hrm/employee/list.php @@ -169,8 +169,8 @@ if ($result) $employeestatic->email=$obj->email; $employeestatic->gender=$obj->gender; $employeestatic->societe_id=$obj->fk_soc; - $employeestatic->firstname=''; - $employeestatic->lastname=$obj->login; + $userstatic->firstname=$obj->firstname; + $userstatic->lastname=$obj->lastname; $li=$employeestatic->getNomUrl(1,'',0,0,24,1); diff --git a/htdocs/hrm/establishment/card.php b/htdocs/hrm/establishment/card.php index 533ad5117ff..10a1b42e961 100644 --- a/htdocs/hrm/establishment/card.php +++ b/htdocs/hrm/establishment/card.php @@ -81,34 +81,27 @@ else if ($action == 'add') if (empty($error)) { - $tmparray=getCountry(GETPOST('country_id','int'),'all',$db,$langs,0); - if (! empty($tmparray['id'])) - { - $object->country_id =$tmparray['id']; - $object->country_code =$tmparray['code']; - $object->country_label=$tmparray['label']; - } - $object->address = GETPOST('address', 'alpha'); $object->zip = GETPOST('zipcode', 'alpha'); $object->town = GETPOST('town', 'alpha'); - $object->fk_pays = $object->country_id; + $object->country_id = $_POST["country_id"]; $object->status = GETPOST('status','int'); $object->fk_user_author = $user->id; $object->datec = dol_now(); + + $id = $object->create($user); if ($id > 0) { header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id); exit; - } - else - { - setEventMessage($object->error, 'errors'); - $action='create'; - } + } + else + { + setEventMessages($object->error, $object->errors, 'errors'); + } } else { @@ -131,12 +124,7 @@ else if ($action == 'update') $name = GETPOST('name', 'alpha'); if (empty($name)) { - setEventMessage($langs->trans('ErrorFieldRequired', $langs->trans('NameProperty')), 'errors'); - $error ++; - } - $typeid = GETPOST('typeid', 'int'); - if (empty($typeid)) { - setEventMessage($langs->trans('ErrorFieldRequired', $langs->trans('TypeProperty')), 'errors'); + setEventMessage($langs->trans('ErrorFieldRequired', $langs->trans('Name')), 'errors'); $error ++; } @@ -145,25 +133,23 @@ else if ($action == 'update') $object->address = GETPOST('address', 'alpha'); $object->zip = GETPOST('zipcode', 'alpha'); $object->town = GETPOST('town', 'alpha'); - $object->fk_pays = GETPOST('country_id', 'int'); - $object->rowid = GETPOST('id'); + $object->country_id = $_POST["country_id"]; $object->fk_user_mod = $user->id; - $id = $object->update(); + $result = $object->update(); - if ($id > 0) + if ($result > 0) { - header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id); + header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $_POST['id']); exit; } - else - { - setEventMessage($object->error, 'errors'); - $action='create'; - } + else + { + setEventMessages($object->error, $object->errors, 'errors'); + } } } else { - header("Location: card.php?id=" . $id); + header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $_POST['id']); exit; } } @@ -193,11 +179,11 @@ if ($action == 'create') print '
'.$langs->trans("Ref").''.$langs->trans("Name").''.$langs->trans("Address").''.$langs->trans("Zipcode").''.$langs->trans("Town").''.$langs->trans("Status").'
'.img_object($langs->trans("ShowEstablishment"),"building").' '.$obj->rowid.''.$obj->name.'
'.$establishmentstatic->getNomUrl(1).''.$obj->address.''.$obj->zip.''.$obj->town.''.$establishmentstatic->LibStatut($obj->status,5).'
'; + print $establishmenttmp->getLibStatus(5); + print '
'; // Name - print ''; + print ''; // Address print ''; - print ''; + print ''; print ''; @@ -205,7 +191,7 @@ if ($action == 'create') // Zipcode print ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; @@ -273,46 +259,43 @@ else if ($id) // Ref print ""; - print ''; // Name - print ''; // Address - print ''; - print ''; + print ''; print ''; - print ''; + print ''; // Zipcode / Town - print ''; - print ''; // Country - print ''; - print ''; + print ''; print ''; print ''; // Status - print ''; @@ -347,7 +330,7 @@ else if ($id) // Ref print ''; @@ -379,7 +362,14 @@ else if ($id) // Country print ''; print ''; - print ''; + print ''; print ''; // Status diff --git a/htdocs/hrm/establishment/info.php b/htdocs/hrm/establishment/info.php index 2bf014481ac..806bd893fbb 100644 --- a/htdocs/hrm/establishment/info.php +++ b/htdocs/hrm/establishment/info.php @@ -22,6 +22,7 @@ require('../../main.inc.php'); require_once DOL_DOCUMENT_ROOT.'/core/lib/hrm.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/hrm/class/establishment.class.php'; $langs->load("admin"); diff --git a/htdocs/includes/OAuth/Common/Storage/DoliStorage.php b/htdocs/includes/OAuth/Common/Storage/DoliStorage.php index 2e4b9c195a2..0ce3abf39c1 100644 --- a/htdocs/includes/OAuth/Common/Storage/DoliStorage.php +++ b/htdocs/includes/OAuth/Common/Storage/DoliStorage.php @@ -86,6 +86,10 @@ class DoliStorage implements TokenStorageInterface */ public function storeAccessToken($service, TokenInterface $token) { + //var_dump("storeAccessToken"); + //var_dump($token); + dol_syslog("storeAccessToken"); + $serializedToken = serialize($token); $this->tokens[$service] = $token; @@ -95,6 +99,10 @@ class DoliStorage implements TokenStorageInterface $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."oauth_token"; $sql.= " WHERE service='".$service."' AND entity=1"; $resql = $this->db->query($sql); + if (! $resql) + { + dol_print_error($this->db); + } $obj = $this->db->fetch_array($resql); if ($obj) { // update @@ -108,7 +116,8 @@ class DoliStorage implements TokenStorageInterface $sql.= " VALUES ('".$service."', '".$this->db->escape($serializedToken)."', 1)"; $resql = $this->db->query($sql); } - + //print $sql; + // allow chaining return $this; } @@ -122,8 +131,13 @@ class DoliStorage implements TokenStorageInterface $sql = "SELECT token FROM ".MAIN_DB_PREFIX."oauth_token"; $sql.= " WHERE service='".$service."'"; $resql = $this->db->query($sql); + if (! $resql) + { + dol_print_error($this->db); + } $result = $this->db->fetch_array($resql); - $token = unserialize($result[token]); + $token = unserialize($result['token']); + $this->tokens[$service] = $token; return is_array($this->tokens) @@ -194,6 +208,10 @@ class DoliStorage implements TokenStorageInterface $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."oauth_state"; $sql.= " WHERE service='".$service."' AND entity=1"; $resql = $this->db->query($sql); + if (! $resql) + { + dol_print_error($this->db); + } $obj = $this->db->fetch_array($resql); if ($obj) { // update diff --git a/htdocs/install/mysql/migration/3.8.0-3.9.0.sql b/htdocs/install/mysql/migration/3.8.0-3.9.0.sql index 19ee13533b0..13451e55c50 100755 --- a/htdocs/install/mysql/migration/3.8.0-3.9.0.sql +++ b/htdocs/install/mysql/migration/3.8.0-3.9.0.sql @@ -18,6 +18,11 @@ -- -- VPGSQL8.2 DELETE FROM llx_usergroup_user WHERE fk_user NOT IN (SELECT rowid from llx_user); -- -- VMYSQL4.1 DELETE FROM llx_usergroup_user WHERE fk_usergroup NOT IN (SELECT rowid from llx_usergroup); + +-- Was done into a 3.8 fix, so we must do it also in 3.9 +ALTER TABLE llx_don ADD COLUMN fk_country integer NOT NULL DEFAULT 0 after country; + + -- Fix bad data update llx_opensurvey_sondage set format = 'D' where format = 'D+'; update llx_opensurvey_sondage set format = 'A' where format = 'A+'; @@ -51,16 +56,17 @@ create table llx_overwrite_trans transvalue text )ENGINE=innodb; -ALTER TABLE llx_payment_salary ADD COLUMN datec datetime after tms; +ALTER TABLE llx_payment_salary ADD COLUMN datec datetime AFTER tms; ALTER TABLE llx_payment_salary CHANGE COLUMN fk_user_creat fk_user_author integer; -ALTER TABLE llx_adherent ADD COLUMN pass_crypted varchar(128) after pass; +ALTER TABLE llx_adherent ADD COLUMN pass_crypted varchar(128) AFTER pass; -ALTER TABLE llx_paiement ADD COLUMN ref varchar(30) NOT NULL AFTER rowid; +ALTER TABLE llx_paiement ADD COLUMN ref varchar(30) NOT NULL DEFAULT '' AFTER rowid; ALTER TABLE llx_socpeople ADD COLUMN photo varchar(255) AFTER skype; -ALTER TABLE llx_user_param MODIFY COLUMN value text NOT NULL; +ALTER TABLE llx_user_param MODIFY COLUMN param varchar(255) NOT NULL DEFAULT ''; +ALTER TABLE llx_user_param MODIFY COLUMN value text NOT NULL DEFAULT ''; ALTER TABLE llx_expedition ADD COLUMN import_key varchar(14); ALTER TABLE llx_expedition ADD COLUMN extraparams varchar(255); @@ -71,7 +77,7 @@ ALTER TABLE llx_prelevement_lignes MODIFY COLUMN code_banque varchar(128); ALTER TABLE llx_societe_rib MODIFY COLUMN code_banque varchar(128); ALTER TABLE llx_contrat ADD COLUMN ref_customer varchar(30); -ALTER TABLE llx_commande ADD COLUMN fk_warehouse integer DEFAULT NULL after fk_shipping_method; +ALTER TABLE llx_commande ADD COLUMN fk_warehouse integer DEFAULT NULL AFTER fk_shipping_method; ALTER TABLE llx_ecm_directories MODIFY COLUMN fullpath varchar(750); ALTER TABLE llx_ecm_directories DROP INDEX idx_ecm_directories; @@ -102,20 +108,21 @@ ALTER TABLE llx_ecm_files ADD UNIQUE INDEX uk_ecm_files (label, entity); --ALTER TABLE llx_ecm_files ADD UNIQUE INDEX uk_ecm_files_fullpath(fullpath); -ALTER TABLE llx_product ADD COLUMN onportal tinyint DEFAULT 0 after tobuy; +ALTER TABLE llx_product ADD COLUMN onportal smallint DEFAULT 0 AFTER tobuy; -ALTER TABLE llx_user ADD COLUMN employee tinyint DEFAULT 1; +ALTER TABLE llx_user ADD COLUMN employee smallint DEFAULT 1 AFTER ref_int; +ALTER TABLE llx_user ADD COLUMN fk_establishment integer DEFAULT 0 AFTER employee; CREATE TABLE IF NOT EXISTS llx_c_hrm_function ( rowid integer PRIMARY KEY, - pos tinyint DEFAULT 0 NOT NULL, + pos smallint DEFAULT 0 NOT NULL, code varchar(16) NOT NULL, label varchar(50), - c_level tinyint DEFAULT 0 NOT NULL, - active tinyint DEFAULT 1 NOT NULL + c_level smallint DEFAULT 0 NOT NULL, + active smallint DEFAULT 1 NOT NULL )ENGINE=innodb; INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(1, 5, 'EXECBOARD', 'Executive board', 0, 1); @@ -131,10 +138,10 @@ INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES CREATE TABLE IF NOT EXISTS llx_c_hrm_department ( rowid integer PRIMARY KEY, - pos tinyint DEFAULT 0 NOT NULL, + pos smallint DEFAULT 0 NOT NULL, code varchar(16) NOT NULL, label varchar(50), - active tinyint DEFAULT 1 NOT NULL + active smallint DEFAULT 1 NOT NULL )ENGINE=innodb; INSERT INTO llx_c_hrm_department (rowid, pos, code, label, active) VALUES(1, 5,'MANAGEMENT', 'Management', 1); @@ -173,7 +180,7 @@ CREATE TABLE IF NOT EXISTS llx_establishment ( fk_user_mod integer NOT NULL, datec datetime NOT NULL, tms timestamp NOT NULL, - status tinyint DEFAULT 1 + status smallint DEFAULT 1 ) ENGINE=InnoDB; @@ -221,7 +228,7 @@ create table llx_budget_lines ( rowid integer AUTO_INCREMENT PRIMARY KEY, fk_budget integer NOT NULL, - fk_project integer NOT NULL, + fk_project_ids varchar(255) NOT NULL, -- List of project ids related to this budget. If budget is dedicated to projects not yet started, we recommand to create a project "Projects to come". amount double(24,8) NOT NULL, datec datetime, tms timestamp, @@ -230,13 +237,12 @@ create table llx_budget_lines import_key integer )ENGINE=innodb; -ALTER TABLE llx_budget_lines ADD UNIQUE INDEX uk_budget_lines (fk_budget, fk_project); +ALTER TABLE llx_budget_lines ADD UNIQUE INDEX uk_budget_lines (fk_budget, fk_project_ids); -- Supprime orphelins pour permettre montee de la cle -- MYSQL V4 DELETE llx_budget_lines FROM llx_budget_lines LEFT JOIN llx_budget ON llx_budget.rowid = llx_budget_lines.fk_budget WHERE llx_budget_lines.rowid IS NULL; -- POSTGRESQL V8 DELETE FROM llx_budget_lines USING llx_budget WHERE llx_budget_lines.fk_budget NOT IN (SELECT llx_budget.rowid FROM llx_budget); -ALTER TABLE llx_budget_lines ADD INDEX idx_budget_lines (fk_project); ALTER TABLE llx_budget_lines ADD CONSTRAINT fk_budget_lines_budget FOREIGN KEY (fk_budget) REFERENCES llx_budget (rowid); @@ -255,7 +261,7 @@ CREATE TABLE llx_product_pricerules var_percent FLOAT NOT NULL, -- Price variation over based price var_min_percent FLOAT NOT NULL -- Min price discount over general price ); -ALTER TABLE llx_product ADD COLUMN price_autogen TINYINT(1) DEFAULT 0; +ALTER TABLE llx_product ADD COLUMN price_autogen smallint DEFAULT 0; ALTER TABLE llx_product_pricerules ADD CONSTRAINT unique_level UNIQUE (level); @@ -282,3 +288,23 @@ CREATE TABLE llx_opensurvey_user_formanswers ( ) ENGINE=InnoDB; + + +create table llx_categorie_project +( + fk_categorie integer NOT NULL, + fk_project integer NOT NULL, + import_key varchar(14) +)ENGINE=innodb; + +ALTER TABLE llx_categorie_project ADD PRIMARY KEY pk_categorie_project (fk_categorie, fk_project); +ALTER TABLE llx_categorie_project ADD INDEX idx_categorie_project_fk_categorie (fk_categorie); +ALTER TABLE llx_categorie_project ADD INDEX idx_categorie_project_fk_project (fk_project); + +ALTER TABLE llx_categorie_project ADD CONSTRAINT fk_categorie_project_categorie_rowid FOREIGN KEY (fk_categorie) REFERENCES llx_categorie (rowid); +ALTER TABLE llx_categorie_project ADD CONSTRAINT fk_categorie_project_fk_project FOREIGN KEY (fk_project) REFERENCES llx_projet (rowid); + + + + + diff --git a/htdocs/install/mysql/tables/llx_budget.sql b/htdocs/install/mysql/tables/llx_budget.sql index aeb60cd1ce5..908bfc1337c 100644 --- a/htdocs/install/mysql/tables/llx_budget.sql +++ b/htdocs/install/mysql/tables/llx_budget.sql @@ -20,7 +20,7 @@ create table llx_budget ( rowid integer AUTO_INCREMENT PRIMARY KEY, entity integer NOT NULL DEFAULT 1, - label varchar(255) NOT NULL, + label varchar(255) NOT NULL, -- For example 'Global budget for year' or 'Budget for each project' status integer, note text, date_start date, diff --git a/htdocs/install/mysql/tables/llx_budget_lines.key.sql b/htdocs/install/mysql/tables/llx_budget_lines.key.sql index 9a9771570b1..b31e74b324d 100644 --- a/htdocs/install/mysql/tables/llx_budget_lines.key.sql +++ b/htdocs/install/mysql/tables/llx_budget_lines.key.sql @@ -17,11 +17,10 @@ -- =================================================================== -ALTER TABLE llx_budget_lines ADD UNIQUE INDEX uk_budget_lines (fk_budget, fk_project); +ALTER TABLE llx_budget_lines ADD UNIQUE INDEX uk_budget_lines (fk_budget, fk_project_ids); -- Supprime orphelins pour permettre montee de la cle -- MYSQL V4 DELETE llx_budget_lines FROM llx_budget_lines LEFT JOIN llx_budget ON llx_budget.rowid = llx_budget_lines.fk_budget WHERE llx_budget_lines.rowid IS NULL; -- POSTGRESQL V8 DELETE FROM llx_budget_lines USING llx_budget WHERE llx_budget_lines.fk_budget NOT IN (SELECT llx_budget.rowid FROM llx_budget); -ALTER TABLE llx_budget_lines ADD INDEX idx_budget_lines (fk_project); ALTER TABLE llx_budget_lines ADD CONSTRAINT fk_budget_lines_budget FOREIGN KEY (fk_budget) REFERENCES llx_budget (rowid); diff --git a/htdocs/install/mysql/tables/llx_budget_lines.sql b/htdocs/install/mysql/tables/llx_budget_lines.sql index c5d3d3a4bf2..aba5c7f53ee 100644 --- a/htdocs/install/mysql/tables/llx_budget_lines.sql +++ b/htdocs/install/mysql/tables/llx_budget_lines.sql @@ -18,13 +18,13 @@ create table llx_budget_lines ( - rowid integer AUTO_INCREMENT PRIMARY KEY, - fk_budget integer NOT NULL, - fk_project integer NOT NULL, - amount double(24,8) NOT NULL, - datec datetime, - tms timestamp, - fk_user_creat integer, - fk_user_modif integer, - import_key integer + rowid integer AUTO_INCREMENT PRIMARY KEY, + fk_budget integer NOT NULL, + fk_project_ids varchar(255) NOT NULL, -- 'IDS:x,y' = List of project ids related to this budget. If budget is dedicated to projects not yet started, we recommand to create a project "Projects to come". 'FILTER:ref=*ABC' = Can also be a dynamic rule to select projects. + amount double(24,8) NOT NULL, + datec datetime, + tms timestamp, + fk_user_creat integer, + fk_user_modif integer, + import_key integer )ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_categorie_project.key.sql b/htdocs/install/mysql/tables/llx_categorie_project.key.sql new file mode 100644 index 00000000000..f92e86ff6e9 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_categorie_project.key.sql @@ -0,0 +1,24 @@ +-- ============================================================================ +-- Copyright (C) 2007 Patrick Raguin +-- +-- 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 . +-- +-- ============================================================================ + +ALTER TABLE llx_categorie_project ADD PRIMARY KEY pk_categorie_project (fk_categorie, fk_project); +ALTER TABLE llx_categorie_project ADD INDEX idx_categorie_project_fk_categorie (fk_categorie); +ALTER TABLE llx_categorie_project ADD INDEX idx_categorie_project_fk_project (fk_project); + +ALTER TABLE llx_categorie_project ADD CONSTRAINT fk_categorie_project_categorie_rowid FOREIGN KEY (fk_categorie) REFERENCES llx_categorie (rowid); +ALTER TABLE llx_categorie_project ADD CONSTRAINT fk_categorie_project_fk_project_rowid FOREIGN KEY (fk_project) REFERENCES llx_projet (rowid); diff --git a/htdocs/install/mysql/tables/llx_categorie_project.sql b/htdocs/install/mysql/tables/llx_categorie_project.sql new file mode 100644 index 00000000000..ca536822ac2 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_categorie_project.sql @@ -0,0 +1,25 @@ +-- ============================================================================ +-- Copyright (C) 2007 Patrick Raguin +-- Copyright (C) 2012 Juanjo Menent +-- +-- 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 . +-- +-- ============================================================================ + +create table llx_categorie_project +( + fk_categorie integer NOT NULL, + fk_project integer NOT NULL, + import_key varchar(14) +)ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_opensurvey_sondage.sql b/htdocs/install/mysql/tables/llx_opensurvey_sondage.sql index 16e8a624e72..b728702db79 100644 --- a/htdocs/install/mysql/tables/llx_opensurvey_sondage.sql +++ b/htdocs/install/mysql/tables/llx_opensurvey_sondage.sql @@ -29,5 +29,5 @@ CREATE TABLE llx_opensurvey_sondage ( allow_comments tinyint NOT NULL DEFAULT 1, allow_spy tinyint NOT NULL DEFAULT 1, tms TIMESTAMP, - sujet TEXT, -- Not filled if format = 'F'. Question are into table llx_opensurvey_formquestions + sujet TEXT -- Not filled if format = 'F'. Question are into table llx_opensurvey_formquestions ) ENGINE=InnoDB; diff --git a/htdocs/install/mysql/tables/llx_user.sql b/htdocs/install/mysql/tables/llx_user.sql index e1fc421c911..7263803feb6 100644 --- a/htdocs/install/mysql/tables/llx_user.sql +++ b/htdocs/install/mysql/tables/llx_user.sql @@ -27,6 +27,7 @@ create table llx_user ref_int varchar(50), -- reference into an internal system (deprecated) employee tinyint DEFAULT 1, -- 1 if user is an employee + fk_establishment integer DEFAULT 0, datec datetime, tms timestamp, diff --git a/htdocs/install/mysql/tables/llx_user_param.sql b/htdocs/install/mysql/tables/llx_user_param.sql index 7194d73b4c4..67bce42645a 100644 --- a/htdocs/install/mysql/tables/llx_user_param.sql +++ b/htdocs/install/mysql/tables/llx_user_param.sql @@ -22,7 +22,7 @@ create table llx_user_param ( fk_user integer NOT NULL, entity integer DEFAULT 1 NOT NULL, -- multi company id - param varchar(64) NOT NULL, + param varchar(255) NOT NULL, value text NOT NULL )ENGINE=innodb; @@ -32,4 +32,4 @@ create table llx_user_param -- 1 : first company param -- 2 : second company param -- 3 : etc... --- \ No newline at end of file +-- diff --git a/htdocs/langs/en_US/oauth.lang b/htdocs/langs/en_US/oauth.lang index ef58d605c49..4567af2a0b6 100644 --- a/htdocs/langs/en_US/oauth.lang +++ b/htdocs/langs/en_US/oauth.lang @@ -1,7 +1,11 @@ # Dolibarr language file - Source file is en_US - oauth ConfigOAuth=Oauth Configuration NoAccessToken=No token access saved. +HasAccessToken=A token was generated and saved into database +NewTokenStored=Token received ans saved +TokenDeleted=Token deleted UseTheFollowingUrlAsRedirectURI=Use the following URL as the Redirect URI when creating your credential on your OAuth provider: +ListOfSupportedOauthProviders=Enter here credential provided by your OAuth2 provider. Only supported OAuth2 providers are visible here. This setup may be used by other modules than need OAuth2 authentication. OAUTH_AMAZON_NAME=Api Amazon OAUTH_AMAZON_ID=Api Amazon Id OAUTH_AMAZON_SECRET=Api Amazon Secret diff --git a/htdocs/langs/en_US/printing.lang b/htdocs/langs/en_US/printing.lang index a4f9fe09e04..ab70ca671d7 100644 --- a/htdocs/langs/en_US/printing.lang +++ b/htdocs/langs/en_US/printing.lang @@ -3,7 +3,7 @@ Module64000Name=Direct Printing Module64000Desc=Enable Direct Printing System PrintingSetup=Setup of Direct Printing System PrintingDesc=This module adds a Print button to send documents directly to a printer (without opening document into an application) with various module. -MenuDirectPrinting=Direct Printing +MenuDirectPrinting=Direct Printing jobs DirectPrint=Direct print ModuleDriverSetup=Setup Module Driver PrintingDriverDesc=Configuration variables for printing driver. @@ -20,11 +20,13 @@ UserConf=Setup per user PRINTGCP=Google Cloud Print PRINTGCP_INFO=Google Api State PRINTGCP_AUTHLINK=Authentication -PRINTGCP_TOKEN_ACCESS=Google Cloud Print Token +PRINTGCP_TOKEN_ACCESS=Google Cloud Print OAuth Token PRINTGCP_TOKEN_REFRESH=Token Refresh Present PRINTGCP_TOKEN_EXPIRED=Token Expired PRINTGCP_TOKEN_EXPIRE_AT=Token expire at -RequestAccess=Request Access +PRINTGCP_DELETE_TOKEN=Delete saved token +RequestAccess=Click here to request access and receive a token to save +DeleteAccess=Click here to delete token PrintGCPDesc=This driver allow to send documents directly to a printer with Google Cloud Print. PrintingDriverDescprintgcp=Configuration variables for printing driver Google Cloud Print. PrintTestDescprintgcp=List of Printers for Google Cloud Print. @@ -83,4 +85,4 @@ MEDIA_IPP_thermal=Thermal IPP_COLOR_print-black=BW Printer DirectPrintingJobsDesc=This page lists printing jobs found for available printers. GoogleAuthNotConfigured=Google OAuth setup not done. Enable module OAuth and set a Google ID/Secret. -GoogleAuthConfigured=Google OAuth credentials found. \ No newline at end of file +GoogleAuthConfigured=Google OAuth credentials found into setup of module OAuth. \ No newline at end of file diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang index 4ed6ccfc2f5..505f6bce8e5 100644 --- a/htdocs/langs/en_US/projects.lang +++ b/htdocs/langs/en_US/projects.lang @@ -176,6 +176,7 @@ ProjectOpenedProjectByOppStatus=Opened project/lead by opportunity status ProjectsStatistics=Statistics on projects/leads TaskAssignedToEnterTime=Task assigned. Entering time on this task should be possible. IdTaskTime=Id task time +YouCanCompleteRef=If you want to complete the ref with some information (to use it as search filters), it is recommanded to add a - character to separate it, so the automatic numbering will still work correctly for next projects. For example %s-ABC. You may also prefer to add search keys into label. OpenedProjectsByThirdparties=Opened projects by thirdparties OpportunityTotalAmount=Opportunities total amount OpportunityPonderatedAmount=Opportunities weighted amount diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 8943ca95821..354ecb7b611 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -931,7 +931,7 @@ if (! function_exists("llxHeader")) } if (empty($conf->dol_hide_leftmenu)) { - left_menu('', $help_url, '', '', 1, $title); + left_menu('', $help_url, '', '', 1, $title, 1); } // main area @@ -1401,13 +1401,6 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a ' . "\n"; } - // Wrapper to show tooltips - print '' . "\n"; - // Raven.js for client-side Sentry logging support if (array_key_exists('mod_syslog_sentry', $conf->loghandlers) && ! empty($conf->global->SYSLOG_SENTRY_DSN)) { @@ -1539,9 +1532,10 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a * @param array $menu_array_after Table of menu entries to show after entries of menu handler * @param int $leftmenuwithoutmainarea Must be set to 1. 0 by default for backward compatibility with old modules. * @param string $title Title of web page + * @param string $acceptdelayedhtml 1 if caller request to have html delayed content not returned but saved into global $delayedhtmlcontent (so caller can show it at end of page to avoid flash FOUC effect) * @return void */ -function left_menu($menu_array_before, $helppagename='', $notused='', $menu_array_after='', $leftmenuwithoutmainarea=0, $title='') +function left_menu($menu_array_before, $helppagename='', $notused='', $menu_array_after='', $leftmenuwithoutmainarea=0, $title='', $acceptdelayedhtml=0) { global $user, $conf, $langs, $db, $form; global $hookmanager, $menumanager; @@ -1563,7 +1557,7 @@ function left_menu($menu_array_before, $helppagename='', $notused='', $menu_arra { if (! is_object($form)) $form=new Form($db); $selected=-1; - $searchform.=$form->selectArrayAjax('searchselectcombo', DOL_URL_ROOT.'/core/ajax/selectsearchbox.php', $selected, '', '', 0, 1, 'vmenusearchselectcombo', 1, $langs->trans("Search")); + $searchform.=$form->selectArrayAjax('searchselectcombo', DOL_URL_ROOT.'/core/ajax/selectsearchbox.php', $selected, '', '', 0, 1, 'vmenusearchselectcombo', 1, $langs->trans("Search"), 1); } else { @@ -1770,7 +1764,6 @@ function left_menu($menu_array_before, $helppagename='', $notused='', $menu_arra print "\n"; print ''."\n"; - if (empty($leftmenuwithoutmainarea)) main_area($title); } @@ -1892,6 +1885,7 @@ if (! function_exists("llxFooter")) /** * Show HTML footer * Close div /DIV data-role=page + /DIV class=fiche + /DIV /DIV main layout + /BODY + /HTML. + * If global var $delayedhtmlcontent was filled, we output it just before closing the body. * * @param string $comment A text to add as HTML comment into HTML generated page * @param string $zone 'private' (for private pages) or 'public' (for public pages) @@ -1900,7 +1894,8 @@ if (! function_exists("llxFooter")) function llxFooter($comment='',$zone='private') { global $conf, $langs; - + global $delayedhtmlcontent; + // Global html output events ($mesgs, $errors, $warnings) dol_htmloutput_events(); @@ -1937,6 +1932,18 @@ if (! function_exists("llxFooter")) //var_dump($langs); // Uncommment to see the property _tab_loaded to see which language file were loaded if (empty($conf->dol_hide_leftmenu) && empty($conf->dol_use_jmobile) && empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT)) print ' '."\n"; // End div container + + if (! empty($delayedhtmlcontent)) print $delayedhtmlcontent; + + // Wrapper to show tooltips + print "\n\n"; + print '' . "\n"; + + print "\n"; print "\n"; } diff --git a/htdocs/margin/tabs/productMargins.php b/htdocs/margin/tabs/productMargins.php index 934be1f5a41..b409d0c752f 100644 --- a/htdocs/margin/tabs/productMargins.php +++ b/htdocs/margin/tabs/productMargins.php @@ -82,31 +82,16 @@ if ($id > 0 || ! empty($ref)) $picto=($object->type== Product::TYPE_SERVICE?'service':'product'); dol_fiche_head($head, 'margin', $titre, 0, $picto); - print '
'. fieldLabel('Name','name',1).'
'.fieldLabel('Address','address',0).''; print ''; print '
'.fieldLabel('Zip','zipcode',0).''; print $formcompany->select_ziptown(GETPOST('zipcode', 'alpha'), 'zipcode', array ( 'town', @@ -216,7 +202,7 @@ if ($action == 'create') // Town print '
'.fieldLabel('Town','town',0).''; print $formcompany->select_ziptown(GETPOST('town', 'alpha'), 'town', array ( 'zipcode', @@ -227,7 +213,7 @@ if ($action == 'create') // Country print '
'.fieldLabel('Country','selectcountry_id',0).''; print $form->select_country($mysoc->country_id,'country_id'); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); @@ -236,7 +222,7 @@ if ($action == 'create') // Status print '
'.fieldLabel('Status','status',1).''; print $form->selectarray('status',$status2label,GETPOST('status')); print '
'.$langs->trans("Ref").''; - print $object->rowid; + print ''.$langs->trans("Ref").''; + print $object->id; print '
'; + print '
'.fieldLabel('Name','name',1).''; print ''; print '
'.fieldLabel('Address','address',0).''; print ''; - print '
'; + print '
'.fieldLabel('Zip','zipcode',0).''; print $formcompany->select_ziptown($object->zip, 'zipcode', array ( 'town', 'selectcountry_id' ), 6) . '
'; + print '
'.fieldLabel('Town','town',0).''; print $formcompany->select_ziptown($object->town, 'town', array ( 'zipcode', 'selectcountry_id' )) . '
'.fieldLabel('Country','selectcountry_id',0).''; - print $form->select_country($object->fk_pays,'country_id'); + print $form->select_country($object->fk_country,'country_id'); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); print '
'; + print '
'.fieldLabel('Status','status',1).''; print $form->selectarray('status',$status2label,$object->status); print '
'.$langs->trans("Ref").''; - print $object->rowid; + print $object->id; print ''; print $linkback; print '
'.$langs->trans("Country").''.getCountry($object->fk_pays,1).''; + if ($object->country_id > 0) + { + $img=picto_from_langcode($object->country_code); + print $img?$img.' ':''; + print getCountry($object->getCountryCode(),0,$db); + } + print '
'; - - // Reference - print ''; - print ''; - print ''; - - // Libelle - print ''; - print ''; - - // Status (to sell) - print ''; - - // Status (to buy) - print ''; + dol_banner_tab($object, 'ref', '', ($user->societe_id?0:1), 'ref'); + + + print '
'; + + print '
'; + print '
'.$langs->trans("Ref").''; - print $form->showrefnav($object,'ref','',1,'ref'); - print '
'.$langs->trans("Label").''.$object->label.'
'.$langs->trans("Status").' ('.$langs->trans("Sell").')'; - print $object->getLibStatut(2,0); - print '
'.$langs->trans("Status").' ('.$langs->trans("Buy").')'; - print $object->getLibStatut(2,1); - print '
'; // Total Margin - print ''; @@ -125,7 +110,11 @@ if ($id > 0 || ! empty($ref)) } print "
'.$langs->trans("TotalMargin").''; + print '
'.$langs->trans("TotalMargin").''; print ''; // set by jquery (see below) print '
"; - print ''; + + print ''; + print '
'; + + dol_fiche_end(); if ($user->rights->facture->lire) { diff --git a/htdocs/margin/tabs/thirdpartyMargins.php b/htdocs/margin/tabs/thirdpartyMargins.php index bd2730edda0..9f2f745ad0c 100644 --- a/htdocs/margin/tabs/thirdpartyMargins.php +++ b/htdocs/margin/tabs/thirdpartyMargins.php @@ -73,21 +73,21 @@ if ($socid > 0) dol_fiche_head($head, 'margin', $langs->trans("ThirdParty"),0,'company'); - print ''; - - print ''; - print ''; - - if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field - { - print ''; - } + dol_banner_tab($object, 'socid', '', ($user->societe_id?0:1), 'rowid', 'nom'); + + print '
'; + + print '
'; + print '
'.$langs->trans('ThirdPartyName').''; - print $form->showrefnav($object,'socid','',($user->societe_id?0:1),'rowid','nom'); - print '
'.$langs->trans('Prefix').''.$object->prefix_comm.'
'; + + // Alias names (commercial, trademark or alias names) + print '"; if ($object->client) { - print ''; @@ -123,7 +123,11 @@ if ($socid > 0) } print "
'.$langs->trans('AliasNames').''; + print $object->name_alias; + print "
'; + print '
'; print $langs->trans('CustomerCode').''; print $object->code_client; if ($object->check_codeclient() <> 0) print ' ('.$langs->trans("WrongCustomerCode").')'; @@ -96,7 +96,7 @@ if ($socid > 0) if ($object->fournisseur) { - print '
'; + print '
'; print $langs->trans('SupplierCode').''; print $object->code_fournisseur; if ($object->check_codefournisseur() <> 0) print ' ('.$langs->trans("WrongSupplierCode").')'; @@ -104,7 +104,7 @@ if ($socid > 0) } // Total Margin - print '
'.$langs->trans("TotalMargin").''; + print '
'.$langs->trans("TotalMargin").''; print ''; // set by jquery (see below) print '
"; + + dol_fiche_end(); + print ''; + print '
'; $sql = "SELECT distinct s.nom, s.rowid as socid, s.code_client,"; diff --git a/htdocs/printing/admin/printing.php b/htdocs/printing/admin/printing.php index ac6f030ae16..ce87a5c7178 100644 --- a/htdocs/printing/admin/printing.php +++ b/htdocs/printing/admin/printing.php @@ -137,7 +137,8 @@ if ($mode == 'setup' && $user->admin) $classname = 'printing_'.$driver; $langs->load($driver); $printer = new $classname($db); - //print '
'.print_r($printer, true).'
'; + //var_dump($printer); + $i=0; $submit_enabled=0; foreach ($printer->conf as $key) @@ -157,14 +158,14 @@ if ($mode == 'setup' && $user->admin) case "authlink": print ''; print ''.$langs->trans($key['varname']).''; - print ''.$langs->trans('RequestAccess').''; + print ''.$langs->trans('RequestAccess').''; print ' '; print ''."\n"; break; case "delete": print ''; print ''.$langs->trans($key['varname']).''; - print ''.$langs->trans('DeleteAccess').''; + print ''.$langs->trans('DeleteAccess').''; print ' '; print ''."\n"; break; diff --git a/htdocs/printing/index.php b/htdocs/printing/index.php index d263c60db8d..13e3883702d 100644 --- a/htdocs/printing/index.php +++ b/htdocs/printing/index.php @@ -27,7 +27,7 @@ include_once DOL_DOCUMENT_ROOT.'/core/modules/printing/modules_printing.php'; llxHeader("",$langs->trans("Printing")); -print load_fiche_titre($langs->trans("Printing")); +print_barre_liste($langs->trans("Printing"), 0, $_SERVER["PHP_SELF"], '', '', '', ''.$langs->trans("Refresh").'', 0); print $langs->trans("DirectPrintingJobsDesc").'

'; diff --git a/htdocs/product/canvas/product/tpl/card_create.tpl.php b/htdocs/product/canvas/product/tpl/card_create.tpl.php index 81ddb147fe3..c5f968dee4f 100644 --- a/htdocs/product/canvas/product/tpl/card_create.tpl.php +++ b/htdocs/product/canvas/product/tpl/card_create.tpl.php @@ -90,9 +90,6 @@ $statutarray=array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSe volume_units; ?> -trans("Hidden"); ?> -hidden; ?> - trans("NoteNotVisibleOnBill"); ?> textarea_note; ?> diff --git a/htdocs/product/canvas/service/tpl/card_create.tpl.php b/htdocs/product/canvas/service/tpl/card_create.tpl.php index 9d526383a67..39c91695f8f 100644 --- a/htdocs/product/canvas/service/tpl/card_create.tpl.php +++ b/htdocs/product/canvas/service/tpl/card_create.tpl.php @@ -63,9 +63,6 @@ $statutarray=array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSe duration_unit; ?> -trans("Hidden"); ?> -hidden; ?> - trans("NoteNotVisibleOnBill"); ?> textarea_note; ?> diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 9fadd0f3e5a..4c30691318f 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -249,7 +249,6 @@ if (empty($reshook)) $object->volume = GETPOST('volume'); $object->volume_units = GETPOST('volume_units'); $object->finished = GETPOST('finished'); - $object->hidden = GETPOST('hidden')=='yes'?1:0; $object->fk_unit = GETPOST('units'); $object->accountancy_code_sell = GETPOST('accountancy_code_sell'); $object->accountancy_code_buy = GETPOST('accountancy_code_buy'); @@ -335,7 +334,6 @@ if (empty($reshook)) $object->volume = GETPOST('volume'); $object->volume_units = GETPOST('volume_units'); $object->finished = GETPOST('finished'); - $object->hidden = GETPOST('hidden')=='yes'?1:0; $units = GETPOST('units', 'int'); @@ -1040,7 +1038,7 @@ else require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $type = $langs->trans('Product'); - if ($object->isservice()) $type = $langs->trans('Service'); + if ($object->isService()) $type = $langs->trans('Service'); //print load_fiche_titre($langs->trans('Modify').' '.$type.' : '.(is_object($object->oldcopy)?$object->oldcopy->ref:$object->ref), ""); // Main official, simple, and not duplicated code @@ -1146,7 +1144,7 @@ else // Stock /* - if ($object->isproduct() && ! empty($conf->stock->enabled)) + if ($object->isProduct() && ! empty($conf->stock->enabled)) { print "".''.$langs->trans("StockLimit").''; print ''; @@ -1171,7 +1169,7 @@ else print ''; } - if ($object->isservice()) + if ($object->isService()) { // Duration print ''.$langs->trans("Duration").''; @@ -1239,16 +1237,9 @@ else print $object->showOptionals($extrafields,'edit'); } - // Note - print ''.$langs->trans("NoteNotVisibleOnBill").''; - - $doleditor = new DolEditor('note', $object->note, '', 140, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, 4, 80); - $doleditor->Create(); - - print ""; - - if($conf->categorie->enabled) { - // Categories + // Tags-Categories + if ($conf->categorie->enabled) + { print ''.$langs->trans("Categories").''; $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, '', 'parent', 64, 0, 1); $c = new Categorie($db); @@ -1260,6 +1251,14 @@ else print ""; } + // Note + print ''.$langs->trans("NoteNotVisibleOnBill").''; + + $doleditor = new DolEditor('note', $object->note, '', 140, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, 4, 80); + $doleditor->Create(); + + print ""; + print ''; print '
'; @@ -1298,58 +1297,29 @@ else // Fiche en mode visu else { - $head=product_prepare_head($object); + $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, 'card', $titre, 0, $picto); - $showphoto=$object->is_photo_available($conf->product->multidir_output[$object->entity]); - $showbarcode=empty($conf->barcode->enabled)?0:1; - if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) $showbarcode=0; - - // En mode visu - print ''; - - // Ref - print ''; - - print ''; - - // Label - print ''; - - $nblignes=7; - if (! empty($conf->produit->enabled) && ! empty($conf->service->enabled)) $nblignes++; - if ($showbarcode) $nblignes+=2; - if ($object->type!= Product::TYPE_SERVICE) $nblignes++; - if (empty($conf->global->PRODUCT_DISABLE_CUSTOM_INFO)) $nblignes+=2; - if ($object->isservice()) $nblignes++; - else $nblignes+=4; - - // Photo - if ($showphoto || $showbarcode) - { - print ''; - } - - print ''; - + dol_banner_tab($object, 'ref', '', ($user->societe_id?0:1), 'ref'); + + + print '
'; + print '
'; + + print '
'; + print '
'.$langs->trans("Ref").''; - print $form->showrefnav($object,'ref','',1,'ref'); - print '
'.$langs->trans("Label").''.$object->label.''; - print '
'; - $maxvisiblephotos=(isset($conf->global->PRODUCT_MAX_VISIBLE_PHOTO)?$conf->global->PRODUCT_MAX_VISIBLE_PHOTO:5); - if ($conf->browser->phone) $maxvisiblephotos=1; - if ($showphoto) print $object->show_photos($conf->product->multidir_output[$object->entity],1,$maxvisiblephotos,0,0,0,80); - if ($showphoto && $showbarcode) print '

'; - if ($showbarcode) print $form->showbarcode($object); - print '
'; - print '
'; + // Type if (! empty($conf->produit->enabled) && ! empty($conf->service->enabled)) { // TODO change for compatibility with edit in place $typeformat='select;0:'.$langs->trans("Product").',1:'.$langs->trans("Service"); - print ''; } @@ -1412,6 +1382,7 @@ else print ''; // Status (to sell) + /* print ''; - + */ + // Batch number management (to batch) if (! empty($conf->productbatch->enabled)) { print ''; + print '
'.$form->editfieldkey("Type",'fk_product_type',$object->type,$object,$user->rights->produit->creer||$user->rights->service->creer,$typeformat).''; + print '
'.$form->editfieldkey("Type",'fk_product_type',$object->type,$object,$user->rights->produit->creer||$user->rights->service->creer,$typeformat).''; print $form->editfieldval("Type",'fk_product_type',$object->type,$object,$user->rights->produit->creer||$user->rights->service->creer,$typeformat); print '
'.$langs->trans("Status").' ('.$langs->trans("Sell").')'; if (! empty($conf->use_javascript_ajax) && $user->rights->produit->creer && ! empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { print ajax_object_onoff($object, 'status', 'tosell', 'ProductStatusOnSell', 'ProductStatusNotOnSell'); @@ -1428,7 +1399,8 @@ else print $object->getLibStatut(2,1); } print '
'.$langs->trans("ManageLotSerial").''; @@ -1448,18 +1420,25 @@ else print dol_print_url($object->url); print '
'; + print ''; + print '
'; + + print '
'; + print ''; + // Nature if($object->type!= Product::TYPE_SERVICE) { - print ''; } - if ($object->isservice()) + if ($object->isService()) { // Duration - print ''."\n"; - print ' '."\n"; - // Categories if($conf->categorie->enabled) { print '"; } - print "
'.$langs->trans("Nature").''; + print '
'.$langs->trans("Nature").''; print $object->getLibFinished(); print '
'.$langs->trans("Duration").''.$object->duration_value.' '; + print '
'.$langs->trans("Duration").''.$object->duration_value.' '; if ($object->duration_value > 1) { $dur=array("h"=>$langs->trans("Hours"),"d"=>$langs->trans("Days"),"w"=>$langs->trans("Weeks"),"m"=>$langs->trans("Months"),"y"=>$langs->trans("Years")); @@ -1475,7 +1454,7 @@ else else { // Weight - print '
'.$langs->trans("Weight").''; + print '
'.$langs->trans("Weight").''; if ($object->weight != '') { print $object->weight." ".measuring_units_string($object->weight_units,"weight"); @@ -1549,11 +1528,6 @@ else print $object->showOptionals($extrafields); } - // Note - print ' '."\n"; - print '
'.$langs->trans("Note").''.(dol_textishtml($object->note)?$object->note:dol_nl2br($object->note,1,true)).'
'.$langs->trans("Categories").''; @@ -1561,8 +1535,17 @@ else print "
\n"; + // Note + print ' '."\n"; + print ''.$langs->trans("Note").''.(dol_textishtml($object->note)?$object->note:dol_nl2br($object->note,1,true)).''."\n"; + print ' '."\n"; + print "\n"; + print '
'; + + print '
'; + print '
'; + dol_fiche_end(); } diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 4c1fbc6c929..64068652ca9 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -84,11 +84,13 @@ class Product extends CommonObject //! Base price ('TTC' for price including tax or 'HT' for net price) var $price_base_type; //! Arrays for multiprices - var $multiprices=array(); - var $multiprices_ttc=array(); - var $multiprices_base_type=array(); - var $multiprices_tva_tx=array(); - var $multiprices_recuperableonly=array(); + public $multiprices=array(); + public $multiprices_ttc=array(); + public $multiprices_base_type=array(); + public $multiprices_min=array(); + public $multiprices_min_ttc=array(); + public $multiprices_tva_tx=array(); + public $multiprices_recuperableonly=array(); //! Price by quantity arrays var $price_by_qty; var $prices_by_qty=array(); @@ -125,6 +127,12 @@ class Product extends CommonObject var $customcode; // Customs code + /** + * Product URL + * @var string + */ + public $url; + //! Unites de mesure var $weight; var $weight_units; @@ -717,6 +725,7 @@ class Product extends CommonObject $sql.= ", desiredstock = " . ((isset($this->desiredstock) && $this->desiredstock != '') ? $this->desiredstock : "null"); $sql.= ", fk_unit= " . (!$this->fk_unit ? 'NULL' : $this->fk_unit); $sql.= ", price_autogen = " . (!$this->price_autogen ? 0 : 1); + $sql.= ", fk_price_expression = ".($this->fk_price_expression != 0 ? $this->fk_price_expression : 'NULL'); $sql.= " WHERE rowid = " . $id; dol_syslog(get_class($this)."::update", LOG_DEBUG); @@ -1443,6 +1452,14 @@ class Product extends CommonObject $resql=$this->db->query($sql); if ($resql) { + $this->multiprices[$level] = $price; + $this->multiprices_ttc[$level] = $price_ttc; + $this->multiprices_min[$level]= $price_min; + $this->multiprices_min_ttc[$level]= $price_min_ttc; + $this->multiprices_base_type[$level]= $newpricebase; + $this->multiprices_tva_tx[$level]= $newvat; + $this->multiprices_recuperableonly[$level]= $newnpr; + $this->price = $price; $this->price_ttc = $price_ttc; $this->price_min = $price_min; @@ -1487,33 +1504,15 @@ class Product extends CommonObject * * @param int $expression_id Expression * @return int <0 if KO, >0 if OK + * @deprecated Use Product::update instead */ function setPriceExpression($expression_id) { - global $conf; + global $user; - // Clean parameters - $this->db->begin(); - $expression_id = $expression_id != 0 ? $expression_id : 'NULL'; + $this->fk_price_expression = $expression_id; - $sql = "UPDATE ".MAIN_DB_PREFIX."product"; - $sql.= " SET fk_price_expression = ".$expression_id; - $sql.= " WHERE rowid = ".$this->id; - - dol_syslog(get_class($this)."::setPriceExpression", LOG_DEBUG); - - $resql = $this->db->query($sql); - if ($resql) - { - $this->db->commit(); - return 1; - } - else - { - $this->error=$this->db->error()." sql=".$sql; - $this->db->rollback(); - return -1; - } + return $this->update($this->id, $user); } /** @@ -2194,11 +2193,12 @@ class Product extends CommonObject /** * Return nb of units or customers invoices in which product is included * - * @param int $socid Limit count on a particular third party id - * @param string $mode 'byunit'=number of unit, 'bynumber'=nb of entities - * @return array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 + * @param int $socid Limit count on a particular third party id + * @param string $mode 'byunit'=number of unit, 'bynumber'=nb of entities + * @param int $filteronproducttype 0=To filter on product only, 1=To filter on services only + * @return array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 */ - function get_nb_vente($socid,$mode) + function get_nb_vente($socid, $mode, $filteronproducttype=-1) { global $conf; global $user; @@ -2206,9 +2206,11 @@ class Product extends CommonObject $sql = "SELECT sum(d.qty), date_format(f.datef, '%Y%m')"; if ($mode == 'bynumber') $sql.= ", count(DISTINCT f.rowid)"; $sql.= " FROM ".MAIN_DB_PREFIX."facturedet as d, ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."societe as s"; + if ($filteronproducttype >= 0) $sql.=", ".MAIN_DB_PREFIX."product as p"; if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE f.rowid = d.fk_facture"; - $sql.= " AND d.fk_product =".$this->id; + if ($this->id > 0) $sql.= " AND d.fk_product =".$this->id; + if ($filteronproducttype >= 0) $sql.= " AND p.rowid = d.fk_product AND p.fk_product_type =".$filteronproducttype; $sql.= " AND f.fk_soc = s.rowid"; $sql.= " AND f.entity IN (".getEntity('facture', 1).")"; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND f.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; @@ -2223,11 +2225,12 @@ class Product extends CommonObject /** * Return nb of units or supplier invoices in which product is included * - * @param int $socid Limit count on a particular third party id - * @param string $mode 'byunit'=number of unit, 'bynumber'=nb of entities - * @return array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 + * @param int $socid Limit count on a particular third party id + * @param string $mode 'byunit'=number of unit, 'bynumber'=nb of entities + * @param int $filteronproducttype 0=To filter on product only, 1=To filter on services only + * @return array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 */ - function get_nb_achat($socid,$mode) + function get_nb_achat($socid, $mode, $filteronproducttype=-1) { global $conf; global $user; @@ -2235,9 +2238,11 @@ class Product extends CommonObject $sql = "SELECT sum(d.qty), date_format(f.datef, '%Y%m')"; if ($mode == 'bynumber') $sql.= ", count(DISTINCT f.rowid)"; $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn_det as d, ".MAIN_DB_PREFIX."facture_fourn as f, ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if ($filteronproducttype >= 0) $sql.=", ".MAIN_DB_PREFIX."product as p"; + if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE f.rowid = d.fk_facture_fourn"; - $sql.= " AND d.fk_product =".$this->id; + if ($this->id > 0) $sql.= " AND d.fk_product =".$this->id; + if ($filteronproducttype >= 0) $sql.= " AND p.rowid = d.fk_product AND p.fk_product_type =".$filteronproducttype; $sql.= " AND f.fk_soc = s.rowid"; $sql.= " AND f.entity IN (".getEntity('facture_fourn', 1).")"; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND f.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; @@ -2252,11 +2257,12 @@ class Product extends CommonObject /** * Return nb of units or proposals in which product is included * - * @param int $socid Limit count on a particular third party id - * @param string $mode 'byunit'=number of unit, 'bynumber'=nb of entities - * @return array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 + * @param int $socid Limit count on a particular third party id + * @param string $mode 'byunit'=number of unit, 'bynumber'=nb of entities + * @param int $filteronproducttype 0=To filter on product only, 1=To filter on services only + * @return array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 */ - function get_nb_propal($socid,$mode) + function get_nb_propal($socid, $mode, $filteronproducttype=-1) { global $conf; global $user; @@ -2264,9 +2270,11 @@ class Product extends CommonObject $sql = "SELECT sum(d.qty), date_format(p.datep, '%Y%m')"; if ($mode == 'bynumber') $sql.= ", count(DISTINCT p.rowid)"; $sql.= " FROM ".MAIN_DB_PREFIX."propaldet as d, ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."societe as s"; + if ($filteronproducttype >= 0) $sql.=", ".MAIN_DB_PREFIX."product as prod"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE p.rowid = d.fk_propal"; - $sql.= " AND d.fk_product =".$this->id; + if ($this->id > 0) $sql.= " AND d.fk_product =".$this->id; + if ($filteronproducttype >= 0) $sql.= " AND prod.rowid = d.fk_product AND prod.fk_product_type =".$filteronproducttype; $sql.= " AND p.fk_soc = s.rowid"; $sql.= " AND p.entity IN (".getEntity('propal', 1).")"; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; @@ -2280,20 +2288,23 @@ class Product extends CommonObject /** * Return nb of units or orders in which product is included * - * @param int $socid Limit count on a particular third party id - * @param string $mode 'byunit'=number of unit, 'bynumber'=nb of entities - * @return array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 + * @param int $socid Limit count on a particular third party id + * @param string $mode 'byunit'=number of unit, 'bynumber'=nb of entities + * @param int $filteronproducttype 0=To filter on product only, 1=To filter on services only + * @return array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 */ - function get_nb_order($socid,$mode) + function get_nb_order($socid, $mode, $filteronproducttype=-1) { global $conf, $user; $sql = "SELECT sum(d.qty), date_format(c.date_commande, '%Y%m')"; if ($mode == 'bynumber') $sql.= ", count(DISTINCT c.rowid)"; $sql.= " FROM ".MAIN_DB_PREFIX."commandedet as d, ".MAIN_DB_PREFIX."commande as c, ".MAIN_DB_PREFIX."societe as s"; - if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if ($filteronproducttype >= 0) $sql.=", ".MAIN_DB_PREFIX."product as p"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE c.rowid = d.fk_commande"; - $sql.= " AND d.fk_product =".$this->id; + if ($this->id > 0) $sql.= " AND d.fk_product =".$this->id; + if ($filteronproducttype >= 0) $sql.= " AND p.rowid = d.fk_product AND p.fk_product_type =".$filteronproducttype; $sql.= " AND c.fk_soc = s.rowid"; $sql.= " AND c.entity IN (".getEntity('commande', 1).")"; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; @@ -2307,20 +2318,23 @@ class Product extends CommonObject /** * Return nb of units or orders in which product is included * - * @param int $socid Limit count on a particular third party id - * @param string $mode 'byunit'=number of unit, 'bynumber'=nb of entities - * @return array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 + * @param int $socid Limit count on a particular third party id + * @param string $mode 'byunit'=number of unit, 'bynumber'=nb of entities + * @param int $filteronproducttype 0=To filter on product only, 1=To filter on services only + * @return array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 */ - function get_nb_ordersupplier($socid,$mode) + function get_nb_ordersupplier($socid, $mode, $filteronproducttype=-1) { global $conf, $user; $sql = "SELECT sum(d.qty), date_format(c.date_commande, '%Y%m')"; if ($mode == 'bynumber') $sql.= ", count(DISTINCT c.rowid)"; $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as d, ".MAIN_DB_PREFIX."commande_fournisseur as c, ".MAIN_DB_PREFIX."societe as s"; + if ($filteronproducttype >= 0) $sql.=", ".MAIN_DB_PREFIX."product as p"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE c.rowid = d.fk_commande"; - $sql.= " AND d.fk_product =".$this->id; + if ($this->id > 0) $sql.= " AND d.fk_product =".$this->id; + if ($filteronproducttype >= 0) $sql.= " AND p.rowid = d.fk_product AND p.fk_product_type =".$filteronproducttype; $sql.= " AND c.fk_soc = s.rowid"; $sql.= " AND c.entity IN (".getEntity('commande_fournisseur', 1).")"; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; @@ -3485,9 +3499,10 @@ class Product extends CommonObject * @param int $showaction 1=Show icon with action links (resize, delete) * @param int $maxHeight Max height of image when size=1 * @param int $maxWidth Max width of image when size=1 + * @param int $nolink Do not add a href link to view enlarged imaged into a new tab * @return string Html code to show photo. Number of photos shown is saved in this->nbphoto */ - function show_photos($sdir,$size=0,$nbmax=0,$nbbyrow=5,$showfilename=0,$showaction=0,$maxHeight=120,$maxWidth=160) + function show_photos($sdir,$size=0,$nbmax=0,$nbbyrow=5,$showfilename=0,$showaction=0,$maxHeight=120,$maxWidth=160,$nolink=0) { global $conf,$user,$langs; @@ -3552,7 +3567,7 @@ class Product extends CommonObject else if ($nbbyrow < 0) $return .= '
'; $return.= "\n"; - $return.= ''; + if (empty($nolink)) $return.= ''; // Show image (width height=$maxHeight) // Si fichier vignette disponible et image source trop grande, on utilise la vignette, sinon on utilise photo origine @@ -3568,7 +3583,8 @@ class Product extends CommonObject $return.= 'dol_use_jmobile?'max-height':'height').'="'.$maxHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&entity='.$this->entity.'&file='.urlencode($pdir.$photo).'" title="'.dol_escape_htmltag($alt).'">'; } - $return.= ''."\n"; + if (empty($nolink)) $return.= ''; + $return.="\n"; if ($showfilename) $return.= '
'.$viewfilename; if ($showaction) @@ -3788,7 +3804,7 @@ class Product extends CommonObject * * @return boolean True if it's a product */ - function isproduct() + function isProduct() { return ($this->type == Product::TYPE_PRODUCT ? true : false); } @@ -3798,7 +3814,7 @@ class Product extends CommonObject * * @return boolean True if it's a service */ - function isservice() + function isService() { return ($this->type == Product::TYPE_SERVICE ? true : false); } @@ -4072,4 +4088,19 @@ class Product extends CommonObject return 1; } + + /** + * Returns the rights used for this class + * @return stdClass + */ + public function getRights() + { + global $user; + + if ($this->isProduct()) { + return $user->rights->produit; + } else { + return $user->rights->service; + } + } } diff --git a/htdocs/product/composition/card.php b/htdocs/product/composition/card.php index 276356d8bca..86dfb8a8fd4 100644 --- a/htdocs/product/composition/card.php +++ b/htdocs/product/composition/card.php @@ -193,8 +193,8 @@ if ($id > 0 || ! empty($ref)) print ""; $nblignes=6; - if ($object->isproduct() && ! empty($conf->stock->enabled)) $nblignes++; - if ($object->isservice()) $nblignes++; + if ($object->isProduct() && ! empty($conf->stock->enabled)) $nblignes++; + if ($object->isService()) $nblignes++; // Reference print ''.$langs->trans("Ref").''; diff --git a/htdocs/product/document.php b/htdocs/product/document.php index 3d5f40b768c..ecb3d12bb52 100644 --- a/htdocs/product/document.php +++ b/htdocs/product/document.php @@ -70,8 +70,8 @@ if ($id > 0 || ! empty($ref)) { $result = $object->fetch($id, $ref); - if (! empty($conf->product->enabled)) $upload_dir = $conf->product->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 1, $object, 'product').dol_sanitizeFileName($object->ref); - elseif (! empty($conf->service->enabled)) $upload_dir = $conf->service->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 1, $object, 'product').dol_sanitizeFileName($object->ref); + if (! empty($conf->product->enabled)) $upload_dir = $conf->product->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 0, $object, 'product').dol_sanitizeFileName($object->ref); + elseif (! empty($conf->service->enabled)) $upload_dir = $conf->service->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 0, $object, 'product').dol_sanitizeFileName($object->ref); if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) // For backward compatiblity, we scan also old dirs { @@ -195,33 +195,21 @@ if ($object->id) } - print ''; + dol_banner_tab($object, 'ref', '', ($user->societe_id?0:1), 'ref'); + + print '
'; + + print '
'; + print '
'; - // Ref - print ''; - print ''; - print ''; - - // Label - print ''; - - // Status (to sell) - print ''; - - // Status (to buy) - print ''; - - print ''; + print ''; print ''; print '
'.$langs->trans("Ref").''; - print $form->showrefnav($object,'ref','',1,'ref'); - print '
'.$langs->trans("Label").''.$object->label.'
'.$langs->trans("Status").' ('.$langs->trans("Sell").')'; - print $object->getLibStatut(2,0); - print '
'.$langs->trans("Status").' ('.$langs->trans("Buy").')'; - print $object->getLibStatut(2,1); - print '
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'.$langs->trans("TotalSizeOfAttachedFiles").''.$totalsize.' '.$langs->trans("bytes").'
'; print '
'; + print '
'; + + dol_fiche_end(); $modulepart = 'produit'; $permission = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->creer) || ($object->type == Product::TYPE_SERVICE && $user->rights->service->creer)); diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index 526b67b123c..96aa9aa6311 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -264,21 +264,15 @@ if ($id > 0 || $ref) $picto=($object->type== Product::TYPE_SERVICE?'service':'product'); dol_fiche_head($head, 'suppliers', $titre, 0, $picto); - - print ''; - - // Reference - print ''; - print ''; - print ''; - - // Label - print ''; + dol_banner_tab($object, 'ref', '', ($user->societe_id?0:1), 'ref'); + + print '
'; + + print '
'; + print '
'.$langs->trans("Ref").''; - print $form->showrefnav($object,'ref','',1,'ref'); - print '
'.$langs->trans("Label").''.$object->label.'
'; // Minimum Price - print ''; + print ''; print ''; - // Status (to buy) - print ''; - print '
'.$langs->trans("BuyingPriceMin").'
'.$langs->trans("BuyingPriceMin").''; $product_fourn = new ProductFournisseur($db); if ($product_fourn->find_min_price_product_fournisseur($object->id) > 0) @@ -288,14 +282,13 @@ if ($id > 0 || $ref) } print '
'.$langs->trans("Status").' ('.$langs->trans("Buy").')'; - print $object->getLibStatut(2,1); - print '
'; - print "\n"; + print ''; + print '
'; + + dol_fiche_end(); + // Form to add or update a price if (($action == 'add_price' || $action == 'updateprice' ) && ($user->rights->produit->creer || $user->rights->service->creer)) @@ -528,7 +521,7 @@ if ($id > 0 || $ref) { // Suppliers list title print ''; - if ($object->isproduct()) $nblignefour=4; + if ($object->isProduct()) $nblignefour=4; else $nblignefour=4; $param="&id=".$object->id; diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 781db3fda3f..b656b88efc6 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -112,7 +112,31 @@ if (! empty($conf->barcode->enabled)) { $fieldstosearchall['p.barcode']='Gencod'; } +// Definition of fields for lists +$arrayfields=array( + 'p.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), + 'p.label'=>array('label'=>$langs->trans("Label"), 'checked'=>1), + 'p.barcode'=>array('label'=>$langs->trans("Gencod"), 'checked'=>($contextpage != 'servicelist'), 'enabled'=>(! empty($conf->barcode->enabled))), + 'p.duration'=>array('label'=>$langs->trans("Duration"), 'checked'=>($contextpage != 'productlist'), 'enabled'=>(! empty($conf->service->enabled))), + 'p.sellprice'=>array('label'=>$titlesellprice, 'checked'=>1, 'enabled'=>empty($conf->global->PRODUIT_MULTIPRICES)), + 'p.minbuyprice'=>array('label'=>$langs->trans("BuyingPriceMinShort"), 'checked'=>1, 'enabled'=>(! empty($user->rights->fournisseur->lire))), + 'p.desiredstock'=>array('label'=>$langs->trans("DesiredStock"), 'checked'=>1, 'enabled'=>(! empty($conf->stock->enabled) && $user->rights->stock->lire && $contextpage != 'service')), + 'p.stock'=>array('label'=>$langs->trans("PhysicalStock"), 'checked'=>1, 'enabled'=>(! empty($conf->stock->enabled) && $user->rights->stock->lire && $contextpage != 'service')), + 'p.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), + 'p.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), + 'p.tosell'=>array('label'=>$langs->trans("Status").' ('.$langs->trans("Sell").')', 'checked'=>1, 'position'=>1000), + 'p.tobuy'=>array('label'=>$langs->trans("Status").' ('.$langs->trans("Purchases").')', 'checked'=>1, 'position'=>1000) +); +// Extra fields +if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) +{ + foreach($extrafields->attribute_label as $key => $val) + { + $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key]); + } +} + /* * Actions */ @@ -364,31 +388,10 @@ else } } - $arrayfields=array( - 'p.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), - 'p.label'=>array('label'=>$langs->trans("Label"), 'checked'=>1), - 'p.barcode'=>array('label'=>$langs->trans("Gencod"), 'checked'=>($contextpage != 'servicelist'), 'enabled'=>(! empty($conf->barcode->enabled))), - 'p.duration'=>array('label'=>$langs->trans("Duration"), 'checked'=>($contextpage != 'productlist'), 'enabled'=>(! empty($conf->service->enabled))), - 'p.sellprice'=>array('label'=>$titlesellprice, 'checked'=>1, 'enabled'=>empty($conf->global->PRODUIT_MULTIPRICES)), - 'p.minbuyprice'=>array('label'=>$langs->trans("BuyingPriceMinShort"), 'checked'=>1, 'enabled'=>(! empty($user->rights->fournisseur->lire))), - 'p.desiredstock'=>array('label'=>$langs->trans("DesiredStock"), 'checked'=>1, 'enabled'=>(! empty($conf->stock->enabled) && $user->rights->stock->lire && $contextpage != 'service')), - 'p.stock'=>array('label'=>$langs->trans("PhysicalStock"), 'checked'=>1, 'enabled'=>(! empty($conf->stock->enabled) && $user->rights->stock->lire && $contextpage != 'service')), - 'p.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), - 'p.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), - 'p.tosell'=>array('label'=>$langs->trans("Status").' ('.$langs->trans("Sell").')', 'checked'=>1, 'position'=>1000), - 'p.tobuy'=>array('label'=>$langs->trans("Status").' ('.$langs->trans("Purchases").')', 'checked'=>1, 'position'=>1000) - ); - // Extra fields - if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) - { - foreach($extrafields->attribute_label as $key => $val) - { - $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key]); - } - } - $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; - $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - print '
'; + $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; + $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + + print '
'; print ''; if (! empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"],"p.ref","",$param,"",$sortfield,$sortorder); if (! empty($arrayfields['p.label']['checked'])) print_liste_field_titre($arrayfields['p.label']['label'], $_SERVER["PHP_SELF"],"p.label","",$param,"",$sortfield,$sortorder); diff --git a/htdocs/product/popuprop.php b/htdocs/product/popuprop.php index c8da665dd98..aad606627cb 100644 --- a/htdocs/product/popuprop.php +++ b/htdocs/product/popuprop.php @@ -38,18 +38,16 @@ $type=GETPOST("type","int"); if (! empty($user->societe_id)) $socid=$user->societe_id; $result=restrictedArea($user,'produit|service'); +$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); -if ($page < 0) $page = 0; +if ($page == -1) { $page = 0; } if (! $sortfield) $sortfield="c"; if (! $sortorder) $sortorder="DESC"; - -$conf->liste_limit = 3; - -if ($page == -1) $page = 0; -$limit = $conf->liste_limit; $offset = $limit * $page ; +$pageprev = $page - 1; +$pagenext = $page + 1; $staticproduct=new Product($db); @@ -69,7 +67,13 @@ if ($type == '0') else if ($type == '1') { $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; - $title=$langs->trans("StatisticsOfServices"); + //$title=$langs->trans("StatisticsOfServices"); + $title=$langs->trans("Statistics"); +} +else +{ + $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; + //$title=$langs->trans("StatisticsOfProductsOrServices"); $title=$langs->trans("Statistics"); } @@ -80,24 +84,30 @@ print load_fiche_titre($title, $mesg,'title_products.png'); $param = ''; $title = $langs->trans("ListProductServiceByPopularity"); -if ($type != '') { - $param = '&type='.$type; - - if ($type == 1) { - $title = $langs->trans("ListServiceByPopularity"); - } else { - $title = $langs->trans("ListProductByPopularity"); - } +if ((string) $type == '1') { + $title = $langs->trans("ListServiceByPopularity"); } +if ((string) $type == '0') { + $title = $langs->trans("ListProductByPopularity"); +} + +if ($type != '') $param .= '&type='.$type; + $h=0; $head = array(); -$head[$h][0] = $_SERVER['PHP_SELF']; -$head[$h][1] = $title; -$head[$h][2] = 'product'; + +$head[$h][0] = DOL_URL_ROOT.'/product/stats/card.php?id=all'; +$head[$h][1] = $langs->trans("Chart"); +$head[$h][2] = 'chart'; $h++; -dol_fiche_head($head,'product',$langs->trans("Statistics")); +$head[$h][0] = $_SERVER['PHP_SELF']; +$head[$h][1] = $title; +$head[$h][2] = 'popularityprop'; +$h++; + +dol_fiche_head($head,'popularityprop',$langs->trans("Statistics")); @@ -127,15 +137,15 @@ if ($result) $num = $db->num_rows($result); $i = 0; - print_barre_liste($title, $page, $_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,"",$num, $totalnboflines, ''); + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, "", $num, $totalnboflines, ''); print '
'; print ""; - print_liste_field_titre($langs->trans('Ref'), $_SERVER["PHP_SELF"], 'p.ref', '', '', '', $sortfield, $sortorder); - print_liste_field_titre($langs->trans('Type'), $_SERVER["PHP_SELF"], 'p.type', '', '', '', $sortfield, $sortorder); - print_liste_field_titre($langs->trans('Label'), $_SERVER["PHP_SELF"], 'p.label', '', '', '', $sortfield, $sortorder); - print_liste_field_titre($langs->trans('NbOfProposals'), $_SERVER["PHP_SELF"], 'c', '', '', 'align="right"', $sortfield, $sortorder); + print_liste_field_titre($langs->trans('Ref'), $_SERVER["PHP_SELF"], 'p.ref', '', $param, '', $sortfield, $sortorder); + print_liste_field_titre($langs->trans('Type'), $_SERVER["PHP_SELF"], 'p.fk_product_type', '', $param, '', $sortfield, $sortorder); + print_liste_field_titre($langs->trans('Label'), $_SERVER["PHP_SELF"], 'p.label', '', $param, '', $sortfield, $sortorder); + print_liste_field_titre($langs->trans('NbOfProposals'), $_SERVER["PHP_SELF"], 'c', '', $param, 'align="right"', $sortfield, $sortorder); print "\n"; diff --git a/htdocs/product/price.php b/htdocs/product/price.php index 69802f51d57..497f676ae8c 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -113,86 +113,115 @@ if (empty($reshook)) $action=''; } - if (($action == 'update_price') && !$cancel && ($user->rights->produit->creer || $user->rights->service->creer)) + if (($action == 'update_price') && !$cancel && $object->getRights()->creer) { - $newprice = ''; - $newprice_min = ''; - $newpricebase = ''; - $newvat = ''; - + $error = 0; + $pricestoupdate = array(); + + $psq = GETPOST('psqflag'); + $psq = empty($newpsq) ? 0 : $newpsq; $maxpricesupplier = $object->min_recommended_price(); - $object->fk_price_expression = empty($eid) ? 0 : $eid; //0 discards expression - // MultiPrix - if (!empty($conf->global->PRODUIT_MULTIPRICES)) { - - //Shall we generate prices using price rules? - $object->price_autogen = GETPOST('usePriceRules') == 'on' ? true : false; - $object->update($object->id, $user); - - for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i ++) { - if (isset($_POST ["price_".$i])) { - $level = $i; - $newprice = price2num($_POST ["price_".$i], 'MU'); - $newprice_min = price2num($_POST ["price_min_".$i], 'MU'); - $newpricebase = $_POST ["multiprices_base_type_".$i]; - $newnpr = (preg_match('/\*/', $_POST ["tva_tx_".$i]) ? 1 : 0); - $newvat = str_replace('*', '', $_POST ["tva_tx_".$i]); - $newpsq = GETPOST('psqflag'); - $newpsq = empty($newpsq) ? 0 : $newpsq; - break; // We found submited price - } - } - } else { - $level = 0; - $newprice = price2num($_POST ["price"], 'MU'); - $newprice_min = price2num($_POST ["price_min"], 'MU'); - $newpricebase = $_POST ["price_base_type"]; - $newnpr = (preg_match('/\*/', $_POST ["tva_tx"]) ? 1 : 0); - $newvat = str_replace('*', '', $_POST ["tva_tx"]); - $newpsq = GETPOST('psqflag'); - $newpsq = empty($newpsq) ? 0 : $newpsq; - } - - if (!empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE) && $newprice_min < $maxpricesupplier) { - setEventMessage($langs->trans("MinimumPriceLimit", price($maxpricesupplier, 0, '', 1, - 1, - 1, 'auto')), 'errors'); - $error ++; - $action = 'edit_price'; - } - - if ($newprice < $newprice_min && !empty($object->fk_price_expression)) { - $newprice = $newprice_min; //Set price same as min, the user will not see the - } - - $res = $object->updatePrice($newprice, $newpricebase, $user, $newvat, $newprice_min, $level, $newnpr, $newpsq); - - if ($res) { + if (!empty($conf->dynamicprices->enabled)) { + $object->fk_price_expression = empty($eid) ? 0 : $eid; //0 discards expression if ($object->fk_price_expression != 0) { //Check the expression validity by parsing it $priceparser = new PriceParser($db); - $price_result = $priceparser->parseProduct($object); - if ($price_result < 0) { //Expression is not valid + + if ($priceparser->parseProduct($object) < 0) { $error ++; - $action = 'edit_price'; setEventMessage($priceparser->translatedError(), 'errors'); } } - if (empty($error) && !empty($conf->dynamicprices->enabled)) { - $ret = $object->setPriceExpression($object->fk_price_expression); - if ($ret < 0) { - $error ++; - $action = 'edit_price'; - setEventMessage($object->error, 'errors'); + } + + // Multiprices + if (!$error && !empty($conf->global->PRODUIT_MULTIPRICES)) { + + $newprice = GETPOST('price', 'array'); + $newprice_min = GETPOST('price_min', 'array'); + $newpricebase = GETPOST('multiprices_base_type', 'array'); + $newvattx = GETPOST('tva_tx', 'array'); + + //Shall we generate prices using price rules? + $object->price_autogen = GETPOST('usePriceRules') == 'on' ? true : false; + + for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i ++) { + + if (!isset($newprice[$i])) { + continue; + } + + $newnpr = (preg_match('/\*/', $newvattx[$i] ? 1 : 0)); + $newvat = str_replace('*', '', $newvattx[$i]); + + $pricestoupdate[$i] = array( + 'price' => $newprice[$i], + 'price_min' => $newprice_min[$i], + 'price_base_type' => $newpricebase[$i], + 'vat_tx' => $newvat, + 'npr' => $newnpr + ); + + //If autogeneration is enabled, then we only set the first level + if ($object->price_autogen) { + break; } } - if (empty($error)) { - $action = ''; - setEventMessage($langs->trans("RecordSaved")); + } else { + $pricestoupdate[0] = array( + 'price' => $_POST ["price"], + 'price_min' => $_POST ["price_min"], + 'price_base_type' => $_POST ["price_base_type"], + 'vat_tx' => str_replace('*', '', $_POST ["tva_tx"]), + 'npr' => preg_match('/\*/', $_POST ["tva_tx"]) ? 1 : 0 + ); + } + + if (!$error && $object->update($object->id, $user) < 1) { + $error++; + setEventMessage($object->error, 'errors'); + $action = 'edit_price'; + } + + if (!$error) { + $db->begin(); + + foreach ($pricestoupdate as $key => $val) { + + $newprice = $val['price']; + + if ($val['price'] < $val['price_min'] && !empty($object->fk_price_expression)) { + $newprice = $val['price_min']; //Set price same as min, the user will not see the + } + + $newprice = price2num($newprice, 'MU'); + $newprice_min = price2num($val['price_min'], 'MU'); + + if (!empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE) && $newprice_min < $maxpricesupplier) { + setEventMessage($langs->trans("MinimumPriceLimit", price($maxpricesupplier, 0, '', 1, - 1, - 1, 'auto')), 'errors'); + $error ++; + break; + } + + $res = $object->updatePrice($newprice, $val['price_base_type'], $user, $val['vat_tx'], $newprice_min, $key, $val['npr'], $psq); + + if ($res < 0) { + $error ++; + setEventMessage($object->error, 'errors'); + break; + } } + } + + if (empty($error)) { + $action = ''; + setEventMessage($langs->trans("RecordSaved")); + $db->commit(); } else { $action = 'edit_price'; - setEventMessage($object->error, 'errors'); + $db->rollback(); } } @@ -402,34 +431,13 @@ $titre = $langs->trans("CardProduct" . $object->type); $picto = ($object->type == Product::TYPE_SERVICE ? 'service' : 'product'); dol_fiche_head($head, 'price', $titre, 0, $picto); -print '
'; +dol_banner_tab($object, 'ref', '', ($user->societe_id?0:1), 'ref'); -// Ref -print ''; -print ''; -print ''; -// Label -print ''; +print '
'; -$isphoto = $object->is_photo_available($conf->product->multidir_output [$object->entity]); - -$nblignes = 5; -if ($isphoto) { - // Photo - print '
'; -} - -print ''; - -// Status (to sell) -print ''; +print '
'; +print '
' . $langs->trans("Ref") . ''; -print $form->showrefnav($object, 'ref', '', 1, 'ref'); -print '
' . $langs->trans("Label") . '' . $object->label . ''; - print $object->show_photos($conf->product->multidir_output [$object->entity], 1, 1, 0, 0, 0, 80); - print '
' . $langs->trans("Status") . ' (' . $langs->trans("Sell") . ')'; -print $object->getLibStatut(2, 0); -print '
'; // MultiPrix if (! empty($conf->global->PRODUIT_MULTIPRICES)) @@ -442,15 +450,15 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES)) $soc->fetch($socid); // Selling price - print '' . $langs->trans("SellingPrice") . ''; + print ''; print ''; if (! empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) // using this option is a bug. kept for backward compatibility { // TVA - print ''; + print ''; } else { @@ -483,12 +491,12 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES)) if (! empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) // using this option is a bug. kept for backward compatibility { // We show only vat for level 1 - print ''; + print ''; } else { // TVA - print ''; + print ''; } print ''; @@ -503,28 +511,28 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES)) if (! empty($conf->global->$keyforlabel)) print ' - '.$langs->trans($conf->global->$keyforlabel); print ''; - if ($object->multiprices_base_type ["$i"] == 'TTC') { - print '';; + if ($object->multiprices_base_type[$i]) { + print ' '.$langs->trans($object->multiprices_base_type [$i]).''; } else { - print ' '.$langs->trans($object->price_base_type).'';; + print ' '.$langs->trans($object->price_base_type).''; } // Prix min print ''; @@ -605,7 +613,7 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES)) else { // TVA - print ''; + print ''; // Price print '
' . $langs->trans("SellingPrice") . ''; - if ($object->multiprices_base_type["$soc->price_level"] == 'TTC') { - print price($object->multiprices_ttc["$soc->price_level"]); + if ($object->multiprices_base_type[$soc->price_level] == 'TTC') { + print price($object->multiprices_ttc[$soc->price_level]); } else { - print price($object->multiprices["$soc->price_level"]); + print price($object->multiprices[$soc->price_level]); } - if ($object->multiprices_base_type["$soc->price_level"]) { - print ' ' . $langs->trans($object->multiprices_base_type["$soc->price_level"]); + if ($object->multiprices_base_type[$soc->price_level]) { + print ' ' . $langs->trans($object->multiprices_base_type[$soc->price_level]); } else { print ' ' . $langs->trans($object->price_base_type); } @@ -458,18 +466,18 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES)) // Price min print '
' . $langs->trans("MinPrice") . ''; - if ($object->multiprices_base_type["$soc->price_level"] == 'TTC') + if ($object->multiprices_base_type[$soc->price_level] == 'TTC') { - print price($object->multiprices_min_ttc["$soc->price_level"]) . ' ' . $langs->trans($object->multiprices_base_type["$soc->price_level"]); + print price($object->multiprices_min_ttc[$soc->price_level]) . ' ' . $langs->trans($object->multiprices_base_type[$soc->price_level]); } else { - print price($object->multiprices_min["$soc->price_level"]) . ' ' . $langs->trans(empty($object->multiprices_base_type["$soc->price_level"])?'HT':$object->multiprices_base_type["$soc->price_level"]); + print price($object->multiprices_min[$soc->price_level]) . ' ' . $langs->trans(empty($object->multiprices_base_type[$soc->price_level])?'HT':$object->multiprices_base_type[$soc->price_level]); } print '
' . $langs->trans("VATRate") . '' . vatrate($object->multiprices_tva_tx["$soc->price_level"], true) . '
' . $langs->trans("VATRate") . '' . vatrate($object->multiprices_tva_tx[$soc->price_level], true) . '
' . $langs->trans("VATRate") . '' . vatrate($object->multiprices_tva_tx [1], true) . '
' . $langs->trans("VATRate") . '' . vatrate($object->multiprices_tva_tx [1], true) . '
' . $langs->trans("VATRate") . '' . vatrate($object->tva_tx . ($object->tva_npr ? '*' : ''), true) . '
' . $langs->trans("VATRate") . '' . vatrate($object->tva_tx . ($object->tva_npr ? '*' : ''), true) . '
'.$langs->trans("PriceLevel").''.$langs->trans("SellingPrice").''.$langs->trans("MinPrice").'
' . price($object->multiprices_ttc["$i"]); + if ($object->multiprices_base_type [$i] == 'TTC') { + print '' . price($object->multiprices_ttc[$i]); } else { - print '' . price($object->multiprices["$i"]); + print '' . price($object->multiprices[$i]); } - if ($object->multiprices_base_type["$i"]) { - print ' '.$langs->trans($object->multiprices_base_type ["$i"]).''; - if (empty($object->multiprices_base_type["$i"])) $object->multiprices_base_type["$i"]="HT"; - if ($object->multiprices_base_type["$i"] == 'TTC') + if (empty($object->multiprices_base_type[$i])) $object->multiprices_base_type[$i]="HT"; + if ($object->multiprices_base_type[$i] == 'TTC') { - print price($object->multiprices_min_ttc["$i"]) . ' ' . $langs->trans($object->multiprices_base_type["$i"]); + print price($object->multiprices_min_ttc[$i]) . ' ' . $langs->trans($object->multiprices_base_type[$i]); } else { - print price($object->multiprices_min["$i"]) . ' ' . $langs->trans($object->multiprices_base_type["$i"]); + print price($object->multiprices_min[$i]) . ' ' . $langs->trans($object->multiprices_base_type[$i]); } print '
' . $langs->trans("VATRate") . '' . vatrate($object->tva_tx . ($object->tva_npr ? '*' : ''), true) . '
' . $langs->trans("VATRate") . '' . vatrate($object->tva_tx . ($object->tva_npr ? '*' : ''), true) . '
' . $langs->trans("SellingPrice") . ''; @@ -703,6 +711,10 @@ else print "
\n"; +print ''; +print '
'; + + dol_fiche_end(); @@ -894,7 +906,7 @@ if ($action == 'edit_price' && ($user->rights->produit->creer || $user->rights-> id . '" method="POST">'; + for($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i ++) { - - print ''; - if ($i > 1) print '
'; + + if ($i > 1) print '
'; elseif (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($conf->global->PRODUIT_MULTIPRICES_ALLOW_AUTOCALC_PRICELEVEL)) { print $langs->trans('UseMultipriceRules'). ' price_autogen ? 'checked' : '').'>

'; } @@ -927,7 +940,7 @@ if ($action == 'edit_price' && ($user->rights->produit->creer || $user->rights-> print ''; if (empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) { - print ''; + print ''; } print ''; @@ -936,7 +949,7 @@ if ($action == 'edit_price' && ($user->rights->produit->creer || $user->rights-> if (! empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) // This option is kept for backward compatibility but has no sense { print ''; } @@ -945,22 +958,22 @@ if ($action == 'edit_price' && ($user->rights->produit->creer || $user->rights-> $text = $langs->trans('SellingPrice') . ' ' . $i; print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1); print ''; // Min price print ''; - print ''; - print '
' . $langs->trans("VATRate") . ''; - print $form->load_tva("tva_tx_" . $i, $object->multiprices_tva_tx["$i"], $mysoc, '', $object->id); + print $form->load_tva("tva_tx[" . $i.']', $object->multiprices_tva_tx[$i], $mysoc, '', $object->id); print '
'; - if ($object->multiprices_base_type ["$i"] == 'TTC') { - print ''; + if ($object->multiprices_base_type [$i] == 'TTC') { + print ''; } else { - print ''; + print ''; } - print $form->selectPriceBaseType($object->multiprices_base_type ["$i"], "multiprices_base_type_" . $i); + print ' '.$form->selectPriceBaseType($object->multiprices_base_type [$i], "multiprices_base_type[" . $i."]"); print '
'; $text = $langs->trans('MinPrice') . ' ' . $i; print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1); - if ($object->multiprices_base_type ["$i"] == 'TTC') { - print ''; + if ($object->multiprices_base_type [$i] == 'TTC') { + print ''; } else { - print ''; + print ''; } if ( !empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE)) { @@ -968,15 +981,16 @@ if ($action == 'edit_price' && ($user->rights->produit->creer || $user->rights-> } print '
'; - print '   '; - print '
'; - print ''; } - + + print '
'; + print ''; + print '   '; + print '
'; + print ''; + dol_fiche_end(); } } diff --git a/htdocs/product/stats/card.php b/htdocs/product/stats/card.php index 5fe6d5a4be3..79d33b1d884 100644 --- a/htdocs/product/stats/card.php +++ b/htdocs/product/stats/card.php @@ -27,6 +27,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; @@ -38,7 +39,7 @@ $langs->load("products"); $langs->load("bills"); $langs->load("other"); -$id = GETPOST('id','int'); +$id = GETPOST('id','int'); // For this page, id can also be 'all' $ref = GETPOST('ref'); $mode = (GETPOST('mode') ? GETPOST('mode') : 'byunit'); $error = 0; @@ -56,16 +57,48 @@ $result=restrictedArea($user,'produit|service',$fieldvalue,'product&product','', /* * View */ + $form = new Form($db); -if (! empty($id) || ! empty($ref)) +if (! empty($id) || ! empty($ref) || GETPOST('id') == 'all') { $object = new Product($db); - $result = $object->fetch($id,$ref); + if (GETPOST('id') == 'all') + { + llxHeader("",$langs->trans("ProductStatistics")); - llxHeader("","",$langs->trans("CardProduct".$object->type)); - - if ($result) + $type = GETPOST('type'); + + $helpurl=''; + if ($type == '0') + { + $helpurl='EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; + //$title=$langs->trans("StatisticsOfProducts"); + $title=$langs->trans("Statistics"); + } + else if ($type == '1') + { + $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; + //$title=$langs->trans("StatisticsOfServices"); + $title=$langs->trans("Statistics"); + } + else + { + $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; + //$title=$langs->trans("StatisticsOfProductsOrServices"); + $title=$langs->trans("Statistics"); + } + + print load_fiche_titre($title, $mesg,'title_products.png'); + } + else + { + $result = $object->fetch($id,$ref); + llxHeader("",$langs->trans("CardProduct".$object->type)); + } + + + if ($result && (! empty($id) || ! empty($ref))) { $head=product_prepare_head($object); $titre=$langs->trans("CardProduct".$object->type); @@ -73,37 +106,74 @@ if (! empty($id) || ! empty($ref)) dol_fiche_head($head, 'stats', $titre, 0, $picto); - print ''; - - // Reference - print ''; - print ''; - print ''; - - // Label - print ''; - - // Status (to sell) - print ''; - - // Status (to buy) - print ''; - - print '
'.$langs->trans("Ref").''; - print $form->showrefnav($object,'ref','',1,'ref'); - print '
'.$langs->trans("Label").''.$object->label.'
'.$langs->trans("Status").' ('.$langs->trans("Sell").')'; - print $object->getLibStatut(2,0); - print '
'.$langs->trans("Status").' ('.$langs->trans("Buy").')'; - print $object->getLibStatut(2,1); - print '
'; - + dol_banner_tab($object, 'ref', '', ($user->societe_id?0:1), 'ref'); + dol_fiche_end(); - - + } + if (GETPOST('id') == 'all') + { + $h=0; + $head = array(); + + $head[$h][0] = DOL_URL_ROOT.'/product/stats/card.php?id=all'; + $head[$h][1] = $langs->trans("Chart"); + $head[$h][2] = 'chart'; + $h++; + + $title = $langs->trans("ListProductServiceByPopularity"); + if ((string) $type == '1') { + $title = $langs->trans("ListServiceByPopularity"); + } + if ((string) $type == '0') { + $title = $langs->trans("ListProductByPopularity"); + } + + $head[$h][0] = DOL_URL_ROOT.'/product/popuprop.php'.($type != ''?'?type='.$type:''); + $head[$h][1] = $title; + $head[$h][2] = 'popularityprop'; + $h++; + + dol_fiche_head($head,'chart',$langs->trans("Statistics")); + } + + + if ($result || GETPOST('id') == 'all') + { + if (GETPOST('id') == 'all') + { + // Choice of type of product + if (! empty($conf->dol_use_jmobile)) print "\n".'
'."\n"; + + if ((string) $type != '0') print 'id).'&type=0">'; + else print img_picto('','tick').' '; + print $langs->trans("Products"); + if ((string) $type != '0') print ''; + + if (! empty($conf->dol_use_jmobile)) print '
'."\n".'
'."\n"; + else print '   /   '; + + if ((string) $type != '1') print 'id).'&type=1">'; + else print img_picto('','tick').' '; + print $langs->trans("Services"); + if ((string) $type != '1') print ''; + + if (! empty($conf->dol_use_jmobile)) print '
'."\n".'
'."\n"; + else print '   /   '; + + if ((string) $type == '0' || (string) $type == '1') print 'id).'">'; + else print img_picto('','tick').' '; + print $langs->trans("ProductsAndServices"); + if ((string) $type == '0' || (string) $type == '1') print ''; + + if (! empty($conf->dol_use_jmobile)) print '
'; + else print '
'; + print '
'; + } + // Choice of stats if (! empty($conf->dol_use_jmobile)) print "\n".'
'."\n"; - if ($mode == 'bynumber') print ''; + if ($mode == 'bynumber') print 'id).($type != '' ? '&type='.$type:'').'&mode=byunit">'; else print img_picto('','tick').' '; print $langs->trans("StatsByNumberOfUnits"); if ($mode == 'bynumber') print ''; @@ -111,7 +181,7 @@ if (! empty($id) || ! empty($ref)) if (! empty($conf->dol_use_jmobile)) print '
'."\n".'
'."\n"; else print '   /   '; - if ($mode == 'byunit') print ''; + if ($mode == 'byunit') print 'id).($type != '' ? '&type='.$type:'').'&mode=bynumber">'; else print img_picto('','tick').' '; print $langs->trans("StatsByNumberOfEntities"); if ($mode == 'byunit') print ''; @@ -135,19 +205,19 @@ if (! empty($id) || ! empty($ref)) $graphfiles=array( 'propal' =>array('modulepart'=>'productstats_proposals', - 'file' => $object->id.'/propal12m.png', + 'file' => $object->id.'/propal12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.'.png', 'label' => ($mode=='byunit'?$langs->transnoentitiesnoconv("NumberOfUnitsProposals"):$langs->transnoentitiesnoconv("NumberOfProposals"))), 'orders' =>array('modulepart'=>'productstats_orders', - 'file' => $object->id.'/orders12m.png', + 'file' => $object->id.'/orders12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.'.png', 'label' => ($mode=='byunit'?$langs->transnoentitiesnoconv("NumberOfUnitsCustomerOrders"):$langs->transnoentitiesnoconv("NumberOfCustomerOrders"))), 'invoices' =>array('modulepart'=>'productstats_invoices', - 'file' => $object->id.'/invoices12m.png', + 'file' => $object->id.'/invoices12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.'.png', 'label' => ($mode=='byunit'?$langs->transnoentitiesnoconv("NumberOfUnitsCustomerInvoices"):$langs->transnoentitiesnoconv("NumberOfCustomerInvoices"))), 'orderssuppliers'=>array('modulepart'=>'productstats_orderssuppliers', - 'file' => $object->id.'/orderssuppliers12m.png', + 'file' => $object->id.'/orderssuppliers12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.'.png', 'label' => ($mode=='byunit'?$langs->transnoentitiesnoconv("NumberOfUnitsSupplierOrders"):$langs->transnoentitiesnoconv("NumberOfSupplierOrders"))), 'invoicessuppliers'=>array('modulepart'=>'productstats_invoicessuppliers', - 'file' => $object->id.'/invoicessuppliers12m.png', + 'file' => $object->id.'/invoicessuppliers12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.'.png', 'label' => ($mode=='byunit'?$langs->transnoentitiesnoconv("NumberOfUnitsSupplierInvoices"):$langs->transnoentitiesnoconv("NumberOfSupplierInvoices"))), ); @@ -164,13 +234,21 @@ if (! empty($id) || ! empty($ref)) $graph_data = array(); - // TODO Test si deja existant et recent, on ne genere pas - if ($key == 'propal') $graph_data = $object->get_nb_propal($socid,$mode); - if ($key == 'orders') $graph_data = $object->get_nb_order($socid,$mode); - if ($key == 'invoices') $graph_data = $object->get_nb_vente($socid,$mode); - if ($key == 'invoicessuppliers') $graph_data = $object->get_nb_achat($socid,$mode); - if ($key == 'orderssuppliers') $graph_data = $object->get_nb_ordersupplier($socid,$mode); - + if (dol_is_file($dir . '/' . $graphfiles[$key]['file'])) + { + // TODO Load cachefile $graphfiles[$key]['file'] + } + else + { + if ($key == 'propal') $graph_data = $object->get_nb_propal($socid,$mode,((string) $type != '' ? $type : -1)); + if ($key == 'orders') $graph_data = $object->get_nb_order($socid,$mode,((string) $type != '' ? $type : -1)); + if ($key == 'invoices') $graph_data = $object->get_nb_vente($socid,$mode,((string) $type != '' ? $type : -1)); + if ($key == 'invoicessuppliers') $graph_data = $object->get_nb_achat($socid,$mode,((string) $type != '' ? $type : -1)); + if ($key == 'orderssuppliers') $graph_data = $object->get_nb_ordersupplier($socid,$mode,((string) $type != '' ? $type : -1)); + + // TODO Save cachefile $graphfiles[$key]['file'] + } + if (is_array($graph_data)) { $px->SetData($graph_data); @@ -237,13 +315,13 @@ if (! empty($id) || ! empty($ref)) if ($graphfiles[$key]['output'] && ! $px->isGraphKo()) { if (file_exists($dir."/".$graphfiles[$key]['file']) && filemtime($dir."/".$graphfiles[$key]['file'])) print ''.$langs->trans("GeneratedOn",dol_print_date(filemtime($dir."/".$graphfiles[$key]['file']),"dayhour")).''; - else print ''.$langs->trans("GeneratedOn",dol_print_date(dol_now()),"dayhour").''; + else print ''.$langs->trans("GeneratedOn",dol_print_date(dol_now(),"dayhour")).''; } else { print ''.($mesg?''.$mesg.'':$langs->trans("ChartNotGenerated")).''; } - print ''.img_picto($langs->trans("ReCalculate"),'refresh').''; + print 'id).((string) $type != ''?'&type='.$type:'').'&action=recalcul&mode='.$mode.'">'.img_picto($langs->trans("ReCalculate"),'refresh').''; print ''; print ''; @@ -266,10 +344,11 @@ if (! empty($id) || ! empty($ref)) print "\n".'
'; print '

'."\n"; } - - print '
'; - print '
'; - + } + + if (GETPOST('id') == 'all') + { + dol_fiche_end(); } } else diff --git a/htdocs/product/stats/commande.php b/htdocs/product/stats/commande.php index cdf571d7c75..69334976141 100644 --- a/htdocs/product/stats/commande.php +++ b/htdocs/product/stats/commande.php @@ -81,6 +81,8 @@ if ($id > 0 || ! empty($ref)) $product = new Product($db); $result = $product->fetch($id, $ref); + $object = $product; + $parameters=array('id'=>$id); $reshook=$hookmanager->executeHooks('doActions',$parameters,$product,$action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -97,34 +99,22 @@ if ($id > 0 || ! empty($ref)) $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$product,$action); // Note that $action and $object may have been modified by hook if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - print ''; - - // Reference - print ''; - print ''; - print ''; - - // Libelle - print ''; - print ''; - - // Status (to sell) - print ''; - - // Status (to buy) - print ''; + dol_banner_tab($object, 'ref', '', ($user->societe_id?0:1), 'ref'); + + print '
'; + + print '
'; + print '
'.$langs->trans("Ref").''; - print $form->showrefnav($product,'ref','',1,'ref'); - print '
'.$langs->trans("Label").''.$product->label.'
'.$langs->trans("Status").' ('.$langs->trans("Sell").')'; - print $product->getLibStatut(2,0); - print '
'.$langs->trans("Status").' ('.$langs->trans("Buy").')'; - print $product->getLibStatut(2,1); - print '
'; show_stats_for_company($product,$socid); print "
"; - print ''; + print ''; + print '
'; + + dol_fiche_end(); + if ($user->rights->commande->lire) { diff --git a/htdocs/product/stats/commande_fournisseur.php b/htdocs/product/stats/commande_fournisseur.php index ef5352892c6..83f0912b3ee 100644 --- a/htdocs/product/stats/commande_fournisseur.php +++ b/htdocs/product/stats/commande_fournisseur.php @@ -86,16 +86,17 @@ if ($id > 0 || ! empty($ref)) { $product = new Product($db); $result = $product->fetch($id, $ref); - $parameters = array ( - 'id' => $id - ); + $object = $product; + + $parameters = array ('id' => $id); $reshook = $hookmanager->executeHooks('doActions', $parameters, $product, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); llxHeader("", "", $langs->trans("CardProduct" . $product->type)); - if ($result > 0) { + if ($result > 0) + { $head = product_prepare_head($product); $titre = $langs->trans("CardProduct" . $product->type); $picto = ($product->type == Product::TYPE_SERVICE ? 'service' : 'product'); @@ -105,34 +106,22 @@ if ($id > 0 || ! empty($ref)) { if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - print ''; - - // Reference - print ''; - print ''; - print ''; - - // Libelle - print ''; - print ''; - - // Status (to sell) - print ''; - - // Status (to buy) - print ''; + dol_banner_tab($object, 'ref', '', ($user->societe_id?0:1), 'ref'); + + print '
'; + + print '
'; + print '
' . $langs->trans("Ref") . ''; - print $form->showrefnav($product, 'ref', '', 1, 'ref'); - print '
' . $langs->trans("Label") . '' . $product->label . '
' . $langs->trans("Status") . ' (' . $langs->trans("Sell") . ')'; - print $product->getLibStatut(2, 0); - print '
' . $langs->trans("Status") . ' (' . $langs->trans("Buy") . ')'; - print $product->getLibStatut(2, 1); - print '
'; show_stats_for_company($product, $socid); print "
"; - print ''; + print ''; + print '
'; + + dol_fiche_end(); + if ($user->rights->fournisseur->commande->lire) { diff --git a/htdocs/product/stats/contrat.php b/htdocs/product/stats/contrat.php index 9d4d7d53abc..c2e6b25f7ab 100644 --- a/htdocs/product/stats/contrat.php +++ b/htdocs/product/stats/contrat.php @@ -71,6 +71,8 @@ if ($id > 0 || ! empty($ref)) $product = new Product($db); $result = $product->fetch($id, $ref); + $object = $product; + $parameters=array('id'=>$id); $reshook=$hookmanager->executeHooks('doActions',$parameters,$product,$action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -87,34 +89,22 @@ if ($id > 0 || ! empty($ref)) $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$product,$action); // Note that $action and $object may have been modified by hook if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - print ''; + dol_banner_tab($object, 'ref', '', ($user->societe_id?0:1), 'ref'); + + print '
'; + + print '
'; + print '
'; - // Reference - print ''; - print ''; - print ''; - - // Libelle - print ''; - print ''; - - // Status (to sell) - print ''; - - // Status (to buy) - print ''; - - show_stats_for_company($product,$socid); + show_stats_for_company($product,$socid); print "
'.$langs->trans("Ref").''; - print $form->showrefnav($product,'ref','',1,'ref'); - print '
'.$langs->trans("Label").''.$product->label.'
'.$langs->trans("Status").' ('.$langs->trans("Sell").')'; - print $product->getLibStatut(2,0); - print '
'.$langs->trans("Status").' ('.$langs->trans("Buy").')'; - print $product->getLibStatut(2,1); - print '
"; - print ''; + print ''; + print '
'; + + dol_fiche_end(); + $now=dol_now(); diff --git a/htdocs/product/stats/facture.php b/htdocs/product/stats/facture.php index da39d5d67c1..590830702bb 100644 --- a/htdocs/product/stats/facture.php +++ b/htdocs/product/stats/facture.php @@ -81,7 +81,9 @@ if ($id > 0 || ! empty($ref)) { $product = new Product($db); $result = $product->fetch($id, $ref); - + + $object = $product; + $parameters=array('id'=>$id); $reshook=$hookmanager->executeHooks('doActions',$parameters,$product,$action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -98,34 +100,21 @@ if ($id > 0 || ! empty($ref)) $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$product,$action); // Note that $action and $object may have been modified by hook if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - print ''; - - // Reference - print ''; - print ''; - print ''; - - // Libelle - print ''; - print ''; - - // Status (to sell) - print ''; - - // Status (to buy) - print ''; + dol_banner_tab($object, 'ref', '', ($user->societe_id?0:1), 'ref'); + + print '
'; + + print '
'; + print '
'.$langs->trans("Ref").''; - print $form->showrefnav($product,'ref','',1,'ref'); - print '
'.$langs->trans("Label").''.$product->label.'
'.$langs->trans("Status").' ('.$langs->trans("Sell").')'; - print $product->getLibStatut(2,0); - print '
'.$langs->trans("Status").' ('.$langs->trans("Buy").')'; - print $product->getLibStatut(2,1); - print '
'; show_stats_for_company($product,$socid); print "
"; - print ''; + print ''; + print '
'; + + dol_fiche_end(); if ($user->rights->facture->lire) diff --git a/htdocs/product/stats/facture_fournisseur.php b/htdocs/product/stats/facture_fournisseur.php index 3d5cbcbe455..27e5495a771 100644 --- a/htdocs/product/stats/facture_fournisseur.php +++ b/htdocs/product/stats/facture_fournisseur.php @@ -83,6 +83,8 @@ if ($id > 0 || ! empty($ref)) $product = new Product($db); $result = $product->fetch($id, $ref); + $object = $product; + $parameters = array('id' => $id); $reshook = $hookmanager->executeHooks('doActions', $parameters, $product, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -99,34 +101,22 @@ if ($id > 0 || ! empty($ref)) $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $product, $action); // Note that $action and $object may have been modified by hook if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - print ''; - - // Reference - print ''; - print ''; - print ''; - - // Libelle - print ''; - print ''; - - // Status (to sell) - print ''; - - // Status (to buy) - print ''; + dol_banner_tab($object, 'ref', '', ($user->societe_id?0:1), 'ref'); + + print '
'; + + print '
'; + print '
' . $langs->trans("Ref") . ''; - print $form->showrefnav($product, 'ref', '', 1, 'ref'); - print '
' . $langs->trans("Label") . '' . $product->label . '
' . $langs->trans("Status") . ' (' . $langs->trans("Sell") . ')'; - print $product->getLibStatut(2, 0); - print '
' . $langs->trans("Status") . ' (' . $langs->trans("Buy") . ')'; - print $product->getLibStatut(2, 1); - print '
'; show_stats_for_company($product, $socid); print "
"; - print ''; + print ''; + print '
'; + + dol_fiche_end(); + if ($user->rights->fournisseur->facture->lire) { diff --git a/htdocs/product/stats/propal.php b/htdocs/product/stats/propal.php index 44101d72e52..2fa69740e8b 100644 --- a/htdocs/product/stats/propal.php +++ b/htdocs/product/stats/propal.php @@ -81,6 +81,8 @@ if ($id > 0 || ! empty($ref)) $product = new Product($db); $result = $product->fetch($id, $ref); + $object = $product; + $parameters = array ('id' => $id); $reshook = $hookmanager->executeHooks('doActions', $parameters, $product, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -97,34 +99,22 @@ if ($id > 0 || ! empty($ref)) $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $product, $action); // Note that $action and $object may have been modified by hook if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - print ''; - - // Reference - print ''; - print ''; - print ''; - - // Libelle - print ''; - print ''; - - // Status (to sell) - print ''; - - // Status (to buy) - print ''; + dol_banner_tab($object, 'ref', '', ($user->societe_id?0:1), 'ref'); + + print '
'; + + print '
'; + print '
' . $langs->trans("Ref") . ''; - print $form->showrefnav($product, 'ref', '', 1, 'ref'); - print '
' . $langs->trans("Label") . '' . $product->label . '
' . $langs->trans("Status") . ' (' . $langs->trans("Sell") . ')'; - print $product->getLibStatut(2, 0); - print '
' . $langs->trans("Status") . ' (' . $langs->trans("Buy") . ')'; - print $product->getLibStatut(2, 1); - print '
'; show_stats_for_company($product, $socid); print "
"; - print ''; + print ''; + print '
'; + + dol_fiche_end(); + if ($user->rights->propale->lire) { diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index dfa0cf0c55c..0476a459f60 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -72,24 +72,24 @@ if ($cancel) $action=''; // Set stock limit if ($action == 'setstocklimit') { - $product = new Product($db); - $result=$product->fetch($id); - $product->seuil_stock_alerte=$stocklimit; - $result=$product->update($product->id,$user,0,'update'); + $object = new Product($db); + $result=$object->fetch($id); + $object->seuil_stock_alerte=$stocklimit; + $result=$object->update($object->id,$user,0,'update'); if ($result < 0) - setEventMessage($product->error, 'errors'); + setEventMessage($object->error, 'errors'); $action=''; } // Set desired stock if ($action == 'setdesiredstock') { - $product = new Product($db); - $result=$product->fetch($id); - $product->desiredstock=$desiredstock; - $result=$product->update($product->id,$user,0,'update'); + $object = new Product($db); + $result=$object->fetch($id); + $object->desiredstock=$desiredstock; + $result=$object->update($object->id,$user,0,'update'); if ($result < 0) - setEventMessage($product->error, 'errors'); + setEventMessage($object->error, 'errors'); $action=''; } @@ -112,10 +112,10 @@ if ($action == "correct_stock" && ! $cancel) if (! empty($conf->productbatch->enabled)) { - $product = new Product($db); - $result=$product->fetch($id); + $object = new Product($db); + $result=$object->fetch($id); - if ($product->hasbatch() && (! GETPOST("sellby")) && (! GETPOST("eatby")) && (! GETPOST("batch_number"))) { + if ($object->hasbatch() && (! GETPOST("sellby")) && (! GETPOST("eatby")) && (! GETPOST("batch_number"))) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("atleast1batchfield")), null, 'errors'); $error++; $action='correction'; @@ -127,13 +127,13 @@ if ($action == "correct_stock" && ! $cancel) $priceunit=price2num(GETPOST("unitprice")); if (is_numeric(GETPOST("nbpiece")) && $id) { - if (empty($product)) { - $product = new Product($db); - $result=$product->fetch($id); + if (empty($object)) { + $object = new Product($db); + $result=$object->fetch($id); } - if ($product->hasbatch()) + if ($object->hasbatch()) { - $result=$product->correct_stock_batch( + $result=$object->correct_stock_batch( $user, GETPOST("id_entrepot"), GETPOST("nbpiece"), @@ -148,7 +148,7 @@ if ($action == "correct_stock" && ! $cancel) } else { - $result=$product->correct_stock( + $result=$object->correct_stock( $user, GETPOST("id_entrepot"), GETPOST("nbpiece"), @@ -168,13 +168,13 @@ if ($action == "correct_stock" && ! $cancel) } else { - header("Location: ".$_SERVER["PHP_SELF"]."?id=".$product->id); + header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id); exit; } } else { - setEventMessage($product->error,'errors'); + setEventMessages($object->error, $object->errors, 'errors'); $action='correction'; } } @@ -198,7 +198,7 @@ if ($action == "transfert_stock" && ! $cancel) } if (GETPOST("id_entrepot_source",'int') == GETPOST("id_entrepot_destination",'int')) { - setEventMessage($langs->trans("ErrorSrcAndTargetWarehouseMustDiffers"), 'errors'); + setEventMessages($langs->trans("ErrorSrcAndTargetWarehouseMustDiffers"), null, 'errors'); $error++; $action='transfert'; } @@ -207,20 +207,20 @@ if ($action == "transfert_stock" && ! $cancel) { if ($id) { - $product = new Product($db); - $result=$product->fetch($id); + $object = new Product($db); + $result=$object->fetch($id); $db->begin(); - $product->load_stock(); // Load array product->stock_warehouse + $object->load_stock(); // Load array product->stock_warehouse // Define value of products moved $pricesrc=0; - //if (isset($product->stock_warehouse[GETPOST("id_entrepot_source")]->pmp)) $pricesrc=$product->stock_warehouse[GETPOST("id_entrepot_source")]->pmp; - if (isset($product->pmp)) $pricesrc=$product->pmp; + //if (isset($object->stock_warehouse[GETPOST("id_entrepot_source")]->pmp)) $pricesrc=$object->stock_warehouse[GETPOST("id_entrepot_source")]->pmp; + if (isset($object->pmp)) $pricesrc=$object->pmp; $pricedest=$pricesrc; - if ($product->hasbatch()) + if ($object->hasbatch()) { $pdluo = new Productbatch($db); @@ -251,7 +251,7 @@ if ($action == "transfert_stock" && ! $cancel) if (! $error) { // Remove stock - $result1=$product->correct_stock_batch( + $result1=$object->correct_stock_batch( $user, $srcwarehouseid, GETPOST("nbpiece",'int'), @@ -262,7 +262,7 @@ if ($action == "transfert_stock" && ! $cancel) GETPOST('inventorycode') ); // Add stock - $result2=$product->correct_stock_batch( + $result2=$object->correct_stock_batch( $user, GETPOST("id_entrepot_destination",'int'), GETPOST("nbpiece",'int'), @@ -277,7 +277,7 @@ if ($action == "transfert_stock" && ! $cancel) else { // Remove stock - $result1=$product->correct_stock( + $result1=$object->correct_stock( $user, GETPOST("id_entrepot_source"), GETPOST("nbpiece"), @@ -288,7 +288,7 @@ if ($action == "transfert_stock" && ! $cancel) ); // Add stock - $result2=$product->correct_stock( + $result2=$object->correct_stock( $user, GETPOST("id_entrepot_destination"), GETPOST("nbpiece"), @@ -309,13 +309,13 @@ if ($action == "transfert_stock" && ! $cancel) } else { - header("Location: product.php?id=".$product->id); + header("Location: product.php?id=".$object->id); exit; } } else { - setEventMessages($product->error, $product->errors, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); $db->rollback(); $action='transfert'; } @@ -370,70 +370,46 @@ if ($action == 'updateline' && GETPOST('save') == $langs->trans('Save')) * View */ +$form = new Form($db); $formproduct=new FormProduct($db); if ($id > 0 || $ref) { - $product = new Product($db); - $result = $product->fetch($id,$ref); - $product->load_stock(); + $object = new Product($db); + $result = $object->fetch($id,$ref); + $object->load_stock(); $help_url='EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks'; - llxHeader("",$langs->trans("CardProduct".$product->type),$help_url); + llxHeader("",$langs->trans("CardProduct".$object->type),$help_url); if ($result > 0) { - $head=product_prepare_head($product); - $titre=$langs->trans("CardProduct".$product->type); - $picto=($product->type==Product::TYPE_SERVICE?'service':'product'); + $head=product_prepare_head($object); + $titre=$langs->trans("CardProduct".$object->type); + $picto=($object->type==Product::TYPE_SERVICE?'service':'product'); dol_fiche_head($head, 'stock', $titre, 0, $picto); dol_htmloutput_events(); - $form = new Form($db); - - print ''; - - // Ref - print ''; - print ''; - print ''; - - // Label - print ''; - print ''; - - // Status (to sell) - print ''; - - // Status (to buy) - print ''; - - if ($conf->productbatch->enabled) { - print '
'.$langs->trans("Ref").''; - print $form->showrefnav($product,'ref','',1,'ref'); - print '
'.$langs->trans("Label").''.$product->label.'
'.$langs->trans("Status").' ('.$langs->trans("Sell").')'; - if (! empty($conf->use_javascript_ajax) && $user->rights->produit->creer && ! empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { - print ajax_object_onoff($product, 'status', 'tosell', 'ProductStatusOnSell', 'ProductStatusNotOnSell'); - } else { - print $product->getLibStatut(2,0); - } - print '
'.$langs->trans("Status").' ('.$langs->trans("Buy").')'; - if (! empty($conf->use_javascript_ajax) && $user->rights->produit->creer && ! empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { - print ajax_object_onoff($product, 'status_buy', 'tobuy', 'ProductStatusOnBuy', 'ProductStatusNotOnBuy'); - } else { - print $product->getLibStatut(2,1); - } - print '
'.$langs->trans("ManageLotSerial").''; - print $product->getLibStatut(0,2); + dol_banner_tab($object, 'ref', '', ($user->societe_id?0:1), 'ref'); + + print '
'; + + print '
'; + print ''; + + if ($conf->productbatch->enabled) + { + print ''; } // PMP - print ''; + print ''; print ''; print ''; @@ -441,14 +417,13 @@ if ($id > 0 || $ref) print ''; print ''; - $object = $product; if (empty($conf->global->PRODUIT_MULTIPRICES)) { // Price @@ -483,17 +458,17 @@ if ($id > 0 || $ref) } // Stock alert threshold - print ''; // Desired stock - print ''; // Real stock - $product->load_stock(); + $object->load_stock(); $text_stock_options = ''; $text_stock_options.= (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT)?$langs->trans("DeStockOnShipment").'
':''); $text_stock_options.= (! empty($conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER)?$langs->trans("DeStockOnValidateOrder").'
':''); @@ -504,15 +479,15 @@ if ($id > 0 || $ref) print ''; - print ''; print ''; // Calculating a theorical value print ''; - print "'; @@ -528,36 +503,36 @@ if ($id > 0 || $ref) if (! empty($conf->commande->enabled)) { if ($found) print '
'; else $found=1; - print $langs->trans("ProductQtyInCustomersOrdersRunning").': '.$product->stats_commande['qty']; - $result=$product->load_stats_commande(0,'0'); - if ($result < 0) dol_print_error($db,$product->error); - print ' ('.$langs->trans("ProductQtyInDraft").': '.$product->stats_commande['qty'].')'; + print $langs->trans("ProductQtyInCustomersOrdersRunning").': '.$object->stats_commande['qty']; + $result=$object->load_stats_commande(0,'0'); + if ($result < 0) dol_print_error($db,$object->error); + print ' ('.$langs->trans("ProductQtyInDraft").': '.$object->stats_commande['qty'].')'; } // Number of product from customer order already sent (partial shipping) if (! empty($conf->expedition->enabled)) { if ($found) print '
'; else $found=1; - $result=$product->load_stats_sending(0,'2'); - print $langs->trans("ProductQtyInShipmentAlreadySent").': '.$product->stats_expedition['qty']; + $result=$object->load_stats_sending(0,'2'); + print $langs->trans("ProductQtyInShipmentAlreadySent").': '.$object->stats_expedition['qty']; } // Number of supplier order running if (! empty($conf->fournisseur->enabled)) { if ($found) print '
'; else $found=1; - $result=$product->load_stats_commande_fournisseur(0,'3,4'); - print $langs->trans("ProductQtyInSuppliersOrdersRunning").': '.$product->stats_commande_fournisseur['qty']; - $result=$product->load_stats_commande_fournisseur(0,'0,1,2'); - if ($result < 0) dol_print_error($db,$product->error); - print ' ('.$langs->trans("ProductQtyInDraftOrWaitingApproved").': '.$product->stats_commande_fournisseur['qty'].')'; + $result=$object->load_stats_commande_fournisseur(0,'3,4'); + print $langs->trans("ProductQtyInSuppliersOrdersRunning").': '.$object->stats_commande_fournisseur['qty']; + $result=$object->load_stats_commande_fournisseur(0,'0,1,2'); + if ($result < 0) dol_print_error($db,$object->error); + print ' ('.$langs->trans("ProductQtyInDraftOrWaitingApproved").': '.$object->stats_commande_fournisseur['qty'].')'; } // Number of product from supplier order already received (partial receipt) if (! empty($conf->fournisseur->enabled)) { if ($found) print '
'; else $found=1; - print $langs->trans("ProductQtyInSuppliersShipmentAlreadyRecevied").': '.$product->stats_reception['qty']; + print $langs->trans("ProductQtyInSuppliersShipmentAlreadyRecevied").': '.$object->stats_reception['qty']; } print ''; @@ -565,7 +540,7 @@ if ($id > 0 || $ref) // Last movement $sql = "SELECT max(m.datem) as datem"; $sql.= " FROM ".MAIN_DB_PREFIX."stock_mouvement as m"; - $sql.= " WHERE m.fk_product = '".$product->id."'"; + $sql.= " WHERE m.fk_product = '".$object->id."'"; $resqlbis = $db->query($sql); if ($resqlbis) { @@ -580,18 +555,21 @@ if ($id > 0 || $ref) if ($lastmovementdate) { print dol_print_date($lastmovementdate,'dayhour').' '; - print '('.$langs->trans("FullList").')'; + print '('.$langs->trans("FullList").')'; } else { - print ''.$langs->trans("None").''; + print ''.$langs->trans("None").''; } print ""; print "
'.$langs->trans("ManageLotSerial").''; + print $object->getLibStatut(0,2); print '
'.$langs->trans("AverageUnitPricePMP").'
'.$langs->trans("AverageUnitPricePMP").''; - if ($product->pmp > 0) print price($product->pmp).' '.$langs->trans("HT"); + if ($object->pmp > 0) print price($object->pmp).' '.$langs->trans("HT"); print '
'.$langs->trans("BuyingPriceMin").''; $product_fourn = new ProductFournisseur($db); - if ($product_fourn->find_min_price_product_fournisseur($product->id) > 0) + if ($product_fourn->find_min_price_product_fournisseur($object->id) > 0) { if ($product_fourn->product_fourn_price_id > 0) print $product_fourn->display_price_product_fournisseur(); else print $langs->trans("NotDefined"); } print '
'.$form->editfieldkey("StockLimit",'stocklimit',$product->seuil_stock_alerte,$product,$user->rights->produit->creer).''; - print $form->editfieldval("StockLimit",'stocklimit',$product->seuil_stock_alerte,$product,$user->rights->produit->creer); + print '
'.$form->editfieldkey("StockLimit",'stocklimit',$object->seuil_stock_alerte,$object,$user->rights->produit->creer).''; + print $form->editfieldval("StockLimit",'stocklimit',$object->seuil_stock_alerte,$object,$user->rights->produit->creer); print '
'.$form->editfieldkey("DesiredStock",'desiredstock',$product->desiredstock,$product,$user->rights->produit->creer).''; - print $form->editfieldval("DesiredStock",'desiredstock',$product->desiredstock,$product,$user->rights->produit->creer); + print '
'.$form->editfieldkey("DesiredStock",'desiredstock',$object->desiredstock,$object,$user->rights->produit->creer).''; + print $form->editfieldval("DesiredStock",'desiredstock',$object->desiredstock,$object,$user->rights->produit->creer); print '
'; print $form->textwithtooltip($langs->trans("PhysicalStock"), $text_stock_options, 2, 1, img_picto('', 'info'), '', 2); print ''.$product->stock_reel; - if ($product->seuil_stock_alerte && ($product->stock_reel < $product->seuil_stock_alerte)) print ' '.img_warning($langs->trans("StockLowerThanLimit")); + print ''.$object->stock_reel; + if ($object->seuil_stock_alerte && ($object->stock_reel < $object->seuil_stock_alerte)) print ' '.img_warning($langs->trans("StockLowerThanLimit")); print '
'.$langs->trans("VirtualStock").'".(empty($product->stock_theorique)?0:$product->stock_theorique); - if ($product->stock_theorique < $product->seuil_stock_alerte) { + print "".(empty($object->stock_theorique)?0:$object->stock_theorique); + if ($object->stock_theorique < $object->seuil_stock_alerte) { print ' '.img_warning($langs->trans("StockLowerThanLimit")); } print '
"; + print '
'; + print '
'; + + dol_fiche_end(); } - print ''; /* * Correct stock @@ -618,7 +596,7 @@ if ($id > 0 || $ref) if ($_GET["action"] == "definir") { print load_fiche_titre($langs->trans("SetStock")); - print "
id\" method=\"post\">\n"; + print "id\" method=\"post\">\n"; print ''; print ''; print ''; @@ -645,19 +623,19 @@ else /* ************************************************************************** */ -if (empty($action) && $product->id) +if (empty($action) && $object->id) { print "
\n"; if ($user->rights->stock->mouvement->creer) { - print ''.$langs->trans("StockCorrection").''; + print ''.$langs->trans("StockCorrection").''; } - //if (($user->rights->stock->mouvement->creer) && ! $product->hasbatch()) + //if (($user->rights->stock->mouvement->creer) && ! $object->hasbatch()) if ($user->rights->stock->mouvement->creer) { - print ''.$langs->trans("StockMovement").''; + print ''.$langs->trans("StockMovement").''; } print '
'; @@ -678,7 +656,7 @@ print ''; print ''; print ''; print ''; -if ((! empty($conf->productbatch->enabled)) && $product->hasbatch()) +if ((! empty($conf->productbatch->enabled)) && $object->hasbatch()) { print ''; print ''; @@ -695,7 +673,7 @@ $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = ps.fk_product"; $sql.= " WHERE ps.reel != 0"; $sql.= " AND ps.fk_entrepot = e.rowid"; $sql.= " AND e.entity IN (".getEntity('stock', 1).")"; -$sql.= " AND ps.fk_product = ".$product->id; +$sql.= " AND ps.fk_product = ".$object->id; $sql.= " ORDER BY e.label"; $entrepotstatic=new Entrepot($db); @@ -718,25 +696,25 @@ if ($resql) print ''; print ''; // PMP - print ''; + print ''; // Value purchase - print ''; + print ''; // Sell price print ''; // Value sell print ''; + if (empty($conf->global->PRODUIT_MULTI_PRICES)) print price(price2num($object->price*$obj->reel,'MT'),1).''; else print $langs->trans("Variable"); print ''; ; $total += $obj->reel; - if (price2num($product->pmp)) $totalwithpmp += $obj->reel; - $totalvalue = $totalvalue + ($product->pmp*$obj->reel); - $totalvaluesell = $totalvaluesell + ($product->price*$obj->reel); + if (price2num($object->pmp)) $totalwithpmp += $obj->reel; + $totalvalue = $totalvalue + ($object->pmp*$obj->reel); + $totalvaluesell = $totalvaluesell + ($object->price*$obj->reel); //Batch Detail - if ((! empty($conf->productbatch->enabled)) && $product->hasbatch()) + if ((! empty($conf->productbatch->enabled)) && $object->hasbatch()) { $details=Productbatch::findAll($db,$obj->product_stock_id); if ($details<0) dol_print_error($db); @@ -762,7 +740,7 @@ if ($resql) { print "\n".'
'.$langs->trans("EstimatedStockValueShort").''.$langs->trans("SellPriceMin").''.$langs->trans("EstimatedStockValueSellShort").'
'.$langs->trans("batch_number").''.$entrepotstatic->getNomUrl(1).''.$obj->reel.($obj->reel<0?' '.img_warning():'').''.(price2num($product->pmp)?price2num($product->pmp,'MU'):'').''.(price2num($object->pmp)?price2num($object->pmp,'MU'):'').''.(price2num($product->pmp)?price(price2num($product->pmp*$obj->reel,'MT')):'').''.(price2num($object->pmp)?price(price2num($object->pmp*$obj->reel,'MT')):'').''; - if (empty($conf->global->PRODUIT_MULTI_PRICES)) print price(price2num($product->price,'MU'),1); + if (empty($conf->global->PRODUIT_MULTI_PRICES)) print price(price2num($object->price,'MU'),1); else print $langs->trans("Variable"); print ''; - if (empty($conf->global->PRODUIT_MULTI_PRICES)) print price(price2num($product->price*$obj->reel,'MT'),1).'
'; print img_picto($langs->trans("Tranfer"),'uparrow','class="hideonsmartphone"').' '; - print 'id.'">'.$langs->trans("StockMovement").''; + print 'id.'">'.$langs->trans("StockMovement").''; // Disabled, because edition of stock content must use the "Correct stock menu". // Do not use this, or data will be wrong (bad tracking of movement label, inventory code, ... //print 'id.'#'.$pdluo->id.'">'; diff --git a/htdocs/product/stock/tpl/stockcorrection.tpl.php b/htdocs/product/stock/tpl/stockcorrection.tpl.php index dc102d8eb05..b1121731293 100644 --- a/htdocs/product/stock/tpl/stockcorrection.tpl.php +++ b/htdocs/product/stock/tpl/stockcorrection.tpl.php @@ -21,7 +21,9 @@ load("productbatch"); + if (! is_object($product)) $product=$object; + + $langs->load("productbatch"); if (empty($id)) $id = $object->id; diff --git a/htdocs/product/stock/tpl/stocktransfer.tpl.php b/htdocs/product/stock/tpl/stocktransfer.tpl.php index de947a75014..93c3135e5f1 100644 --- a/htdocs/product/stock/tpl/stocktransfer.tpl.php +++ b/htdocs/product/stock/tpl/stocktransfer.tpl.php @@ -21,7 +21,11 @@ load("productbatch"); + + $pdluoid=GETPOST('pdluoid','int'); $pdluo = new Productbatch($db); diff --git a/htdocs/product/traduction.php b/htdocs/product/traduction.php index 413cb589dff..96187fad8dd 100644 --- a/htdocs/product/traduction.php +++ b/htdocs/product/traduction.php @@ -58,9 +58,9 @@ if ($cancel == $langs->trans("Cancel")) if ($action == 'delete' && GETPOST('langtodelete','alpha')) { - $product = new Product($db); - $product->fetch($id); - $product->delMultiLangs(GETPOST('langtodelete','alpha')); + $object = new Product($db); + $object->fetch($id); + $object->delMultiLangs(GETPOST('langtodelete','alpha')); } // Add translation @@ -68,33 +68,33 @@ if ($action == 'vadd' && $cancel != $langs->trans("Cancel") && ($user->rights->produit->creer || $user->rights->service->creer)) { - $product = new Product($db); - $product->fetch($id); + $object = new Product($db); + $object->fetch($id); $current_lang = $langs->getDefaultLang(); // update de l'objet if ( $_POST["forcelangprod"] == $current_lang ) { - $product->label = $_POST["libelle"]; - $product->description = dol_htmlcleanlastbr($_POST["desc"]); - $product->note = dol_htmlcleanlastbr($_POST["note"]); + $object->label = $_POST["libelle"]; + $object->description = dol_htmlcleanlastbr($_POST["desc"]); + $object->note = dol_htmlcleanlastbr($_POST["note"]); } else { - $product->multilangs[$_POST["forcelangprod"]]["label"] = $_POST["libelle"]; - $product->multilangs[$_POST["forcelangprod"]]["description"] = dol_htmlcleanlastbr($_POST["desc"]); - $product->multilangs[$_POST["forcelangprod"]]["note"] = dol_htmlcleanlastbr($_POST["note"]); + $object->multilangs[$_POST["forcelangprod"]]["label"] = $_POST["libelle"]; + $object->multilangs[$_POST["forcelangprod"]]["description"] = dol_htmlcleanlastbr($_POST["desc"]); + $object->multilangs[$_POST["forcelangprod"]]["note"] = dol_htmlcleanlastbr($_POST["note"]); } // sauvegarde en base - if ( $product->setMultiLangs() > 0 ) + if ( $object->setMultiLangs() > 0 ) { $action = ''; } else { $action = 'add'; - setEventMessage($product->error,'errors'); + setEventMessage($object->error,'errors'); } } @@ -103,34 +103,34 @@ if ($action == 'vedit' && $cancel != $langs->trans("Cancel") && ($user->rights->produit->creer || $user->rights->service->creer)) { - $product = new Product($db); - $product->fetch($id); + $object = new Product($db); + $object->fetch($id); $current_lang = $langs->getDefaultLang(); - foreach ( $product->multilangs as $key => $value ) // enregistrement des nouvelles valeurs dans l'objet + foreach ( $object->multilangs as $key => $value ) // enregistrement des nouvelles valeurs dans l'objet { if ( $key == $current_lang ) { - $product->label = $_POST["libelle-".$key]; - $product->description = dol_htmlcleanlastbr($_POST["desc-".$key]); - $product->note = dol_htmlcleanlastbr($_POST["note-".$key]); + $object->label = $_POST["libelle-".$key]; + $object->description = dol_htmlcleanlastbr($_POST["desc-".$key]); + $object->note = dol_htmlcleanlastbr($_POST["note-".$key]); } else { - $product->multilangs[$key]["label"] = $_POST["libelle-".$key]; - $product->multilangs[$key]["description"] = dol_htmlcleanlastbr($_POST["desc-".$key]); - $product->multilangs[$key]["note"] = dol_htmlcleanlastbr($_POST["note-".$key]); + $object->multilangs[$key]["label"] = $_POST["libelle-".$key]; + $object->multilangs[$key]["description"] = dol_htmlcleanlastbr($_POST["desc-".$key]); + $object->multilangs[$key]["note"] = dol_htmlcleanlastbr($_POST["note-".$key]); } } - if ( $product->setMultiLangs() > 0 ) + if ( $object->setMultiLangs() > 0 ) { $action = ''; } else { $action = 'edit'; - setEventMessage($product->error,'errors'); + setEventMessage($object->error,'errors'); } } @@ -139,24 +139,24 @@ if ($action == 'vdelete' && $cancel != $langs->trans("Cancel") && ($user->rights->produit->creer || $user->rights->service->creer)) { - $product = new Product($db); - $product->fetch($id); + $object = new Product($db); + $object->fetch($id); $langtodelete=GETPOST('langdel','alpha'); - if ( $product->delMultiLangs($langtodelete) > 0 ) + if ( $object->delMultiLangs($langtodelete) > 0 ) { $action = ''; } else { $action = 'edit'; - setEventMessage($product->error,'errors'); + setEventMessage($object->error,'errors'); } } -$product = new Product($db); -$result = $product->fetch($id,$ref); +$object = new Product($db); +$result = $object->fetch($id,$ref); /* @@ -168,20 +168,10 @@ llxHeader("","",$langs->trans("Translation")); $form = new Form($db); $formadmin=new FormAdmin($db); -$head=product_prepare_head($product); -$titre=$langs->trans("CardProduct".$product->type); -$picto=($product->type==Product::TYPE_SERVICE?'service':'product'); -dol_fiche_head($head, 'translation', $titre, 0, $picto); +$head=product_prepare_head($object); +$titre=$langs->trans("CardProduct".$object->type); +$picto=($object->type==Product::TYPE_SERVICE?'service':'product'); -print ''; - -// Reference -print ''; -print ''; -print ''; -print '
'.$langs->trans("Ref").''; -print $form->showrefnav($product,'ref','',1,'ref'); -print '
'; if ($action == 'edit') { @@ -191,33 +181,40 @@ if ($action == 'edit') print ''; print ''; print ''; - print ''; + print ''; - if (! empty($product->multilangs)) + dol_fiche_head($head, 'translation', $titre, 0, $picto); + + dol_banner_tab($object, 'ref', '', ($user->societe_id?0:1), 'ref'); + + if (! empty($object->multilangs)) { - foreach ($product->multilangs as $key => $value) + foreach ($object->multilangs as $key => $value) { - print "
".$langs->trans('Language_'.$key)." :
"; + $s=picto_from_langcode($key); + print "
".($s?$s.' ':'')." ".$langs->trans('Language_'.$key).": ".'
'.img_delete('', '')."
"; + print ''; - print ''; + print ''; print ''; print ''; - print ''; print '
'.$langs->trans('Label').'
'.$langs->trans('Label').'
'.$langs->trans('Description').''; - $doleditor = new DolEditor("desc-$key", $product->multilangs[$key]["description"], '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, 3, 80); + $doleditor = new DolEditor("desc-$key", $object->multilangs[$key]["description"], '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, 3, 80); $doleditor->Create(); print '
'.$langs->trans('Note').''; - $doleditor = new DolEditor("note-$key", $product->multilangs[$key]["note"], '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, 3, 80); + $doleditor = new DolEditor("note-$key", $object->multilangs[$key]["note"], '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, 3, 80); $doleditor->Create(); print '
'.$langs->trans("Delete").'
'; } } - print '
'; + dol_fiche_end(); + + print '
'; print ''; print '     '; print ''; @@ -228,25 +225,30 @@ if ($action == 'edit') } else { - $cnt_trans = 0; - if (! empty($product->multilangs)) + dol_fiche_head($head, 'translation', $titre, 0, $picto); + + dol_banner_tab($object, 'ref', '', ($user->societe_id?0:1), 'ref'); + + $cnt_trans = 0; + if (! empty($object->multilangs)) { - foreach ($product->multilangs as $key => $value) + foreach ($object->multilangs as $key => $value) { $cnt_trans++; $s=picto_from_langcode($key); - print "
".($s?$s.' ':'')." ".$langs->trans('Language_'.$key).": ".''.img_delete('', '')."
"; + print "
".($s?$s.' ':'')." ".$langs->trans('Language_'.$key).": ".''.img_delete('', '')."
"; print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; print '
'.$langs->trans('Label').''.$product->multilangs[$key]["label"].'
'.$langs->trans('Description').''.$product->multilangs[$key]["description"].'
'.$langs->trans('Note').''.$product->multilangs[$key]["note"].'
'.$langs->trans('Label').''.$object->multilangs[$key]["label"].'
'.$langs->trans('Description').''.$object->multilangs[$key]["description"].'
'.$langs->trans('Note').''.$object->multilangs[$key]["note"].'
'; } } if (! $cnt_trans) print '
'. $langs->trans('NoTranslation'); + + dol_fiche_end(); } -print "
\n"; /* ************************************************************************** */ @@ -260,8 +262,8 @@ print "\n
\n"; if ($action == '') if ($user->rights->produit->creer || $user->rights->service->creer) { - print ''.$langs->trans("Add").''; - print ''.$langs->trans("Update").''; + print ''.$langs->trans("Add").''; + print ''.$langs->trans("Update").''; } print "\n
\n"; @@ -284,7 +286,7 @@ if ($action == 'add' && ($user->rights->produit->creer || $user->rights->service print ''; print ''; print ''; print ''; + $suggestedref=($_POST["ref"]?$_POST["ref"]:$defaultref); + print ''; // Label - print ''; + print ''; // Thirdparty print '
'.$langs->trans('Language').''; - print $formadmin->select_language('','forcelangprod',0,$product->multilangs,1); + print $formadmin->select_language('','forcelangprod',0,$object->multilangs,1); print '
'.$langs->trans('Label').'
'.$langs->trans('Description').''; diff --git a/htdocs/projet/admin/project.php b/htdocs/projet/admin/project.php index 686e764978a..f42fc7c4720 100644 --- a/htdocs/projet/admin/project.php +++ b/htdocs/projet/admin/project.php @@ -104,7 +104,7 @@ else if ($action == 'specimen') $project = new Project($db); $project->initAsSpecimen(); - + // Search template files $file=''; $classname=''; $filefound=0; $dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']); diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index 748f91dbefe..c05cb6948a5 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -450,10 +450,13 @@ if ($action == 'create' && $user->rights->projet->creer) if (is_numeric($defaultref) && $defaultref <= 0) $defaultref=''; // Ref - print '
'.$langs->trans("Ref").'
'.$langs->trans("Ref").''; + print ' '.$form->textwithpicto('', $langs->trans("YouCanCompleteRef", $suggestedref)); + print '
'.$langs->trans("Label").'
'.$langs->trans("Label").'
'.$langs->trans("ThirdParty").''; @@ -617,12 +620,15 @@ else print ''; // Ref + $suggestedref=$object->ref; print ''; - print ''; + print ''; // Label print ''; - print ''; + print ''; // Thirdparty print '
'.$langs->trans("Ref").'
'; + print ' '.$form->textwithpicto('', $langs->trans("YouCanCompleteRef", $suggestedref)); + print '
'.$langs->trans("Label").'
'.$langs->trans("ThirdParty").''; diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 7ac7fa66cea..aca5fe67d0d 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -453,7 +453,9 @@ class Project extends CommonObject function get_element_list($type, $tablename, $datefieldname='', $dates='', $datee='') { $elements = array(); - + + if ($this->id <= 0) return $elements; + if ($type == 'agenda') { $sql = "SELECT id as rowid FROM " . MAIN_DB_PREFIX . "actioncomm WHERE fk_project=" . $this->id; @@ -929,6 +931,7 @@ class Project extends CommonObject $this->date_c = $now; $this->date_m = $now; $this->date_start = $now; + $this->date_end = $now + (3600 * 24 * 365); $this->note_public = 'SPECIMEN'; $this->fk_ele = 20000; $this->opp_amount = 20000; diff --git a/htdocs/public/paybox/newpayment.php b/htdocs/public/paybox/newpayment.php index 42ea013eade..481fd17f049 100644 --- a/htdocs/public/paybox/newpayment.php +++ b/htdocs/public/paybox/newpayment.php @@ -583,7 +583,7 @@ if (GETPOST("source") == 'contractline' && $valid) $duration=''; if ($contractline->fk_product) { - if ($product->isservice() && $product->duration_value > 0) + if ($product->isService() && $product->duration_value > 0) { $label=$langs->trans("Duration"); diff --git a/htdocs/public/paypal/newpayment.php b/htdocs/public/paypal/newpayment.php index 23f81c4295b..dcb43c07170 100644 --- a/htdocs/public/paypal/newpayment.php +++ b/htdocs/public/paypal/newpayment.php @@ -720,7 +720,7 @@ if (GETPOST("source") == 'contractline' && $valid) $duration=''; if ($contractline->fk_product) { - if ($product->isservice() && $product->duration_value > 0) + if ($product->isService() && $product->duration_value > 0) { $label=$langs->trans("Duration"); diff --git a/htdocs/public/test/test_forms.php b/htdocs/public/test/test_forms.php index f1c00f94acf..7fec8e895b6 100644 --- a/htdocs/public/test/test_forms.php +++ b/htdocs/public/test/test_forms.php @@ -68,7 +68,6 @@ print "Test 4d: a select with ajax refresh and with onchange call of url
\n"; $selected=-1; print $form->selectArrayAjax('testselectc', DOL_URL_ROOT.'/core/ajax/selectsearchbox.php', $selected, 'style="min-width: 250px;"', '', 0, 1, '', 1); - print '

'."\n"; // Test5a: form->select_thirdparty diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 3d234728a70..1ebdde8b717 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -121,6 +121,55 @@ if (($tmp = $langs->transnoentities("ProfId5".$mysoc->country_code)) && $tmp != if (($tmp = $langs->transnoentities("ProfId6".$mysoc->country_code)) && $tmp != "ProfId6".$mysoc->country_code && $tmp != '-') $fieldstosearchall['s.idprof6']='ProfId6'; if (!empty($conf->barcode->enabled)) $fieldstosearchall['s.barcode']='Gencod'; +// Define list of fields to show into list +$checkedcustomercode=(in_array($contextpage, array('thirdpartylist', 'customerlist', 'prospectlist')) ? 1 : 0); +$checkedsuppliercode=(in_array($contextpage, array('supplierlist')) ? 1 : 0); +$checkedcustomeraccountcode=(in_array($contextpage, array('customerlist')) ? 1 : 0); +$checkedsupplieraccountcode=(in_array($contextpage, array('supplierlist')) ? 1 : 0); +$checkedtypetiers=1; +$checkedprofid1=0; +$checkedprofid2=0; +$checkedprofid3=0; +$checkedprofid4=0; +$checkedprofid5=0; +$checkedprofid6=0; +//$checkedprofid4=((($tmp = $langs->transnoentities("ProfId4".$mysoc->country_code)) && $tmp != "ProfId4".$mysoc->country_code && $tmp != '-') ? 1 : 0); +//$checkedprofid5=((($tmp = $langs->transnoentities("ProfId5".$mysoc->country_code)) && $tmp != "ProfId5".$mysoc->country_code && $tmp != '-') ? 1 : 0); +//$checkedprofid6=((($tmp = $langs->transnoentities("ProfId6".$mysoc->country_code)) && $tmp != "ProfId6".$mysoc->country_code && $tmp != '-') ? 1 : 0); +$checkprospectlevel=(in_array($contextpage, array('prospectlist')) ? 1 : 0); +$checkstcomm=(in_array($contextpage, array('prospectlist')) ? 1 : 0); +$arrayfields=array( + 's.nom'=>array('label'=>$langs->trans("Company"), 'checked'=>1), + 's.barcode'=>array('label'=>$langs->trans("Gencod"), 'checked'=>1, 'enabled'=>(! empty($conf->barcode->enabled))), + 's.code_client'=>array('label'=>$langs->trans("CustomerCodeShort"), 'checked'=>$checkedcustomercode), + 's.code_fournisseur'=>array('label'=>$langs->trans("SupplierCodeShort"), 'checked'=>$checkedsuppliercode, 'enabled'=>(! empty($conf->fournisseur->enabled))), + 's.code_compta'=>array('label'=>$langs->trans("CustomerAccountancyCodeShort"), 'checked'=>$checkedcustomeraccountcode), + 's.code_compta_fournisseur'=>array('label'=>$langs->trans("SupplierAccountancyCodeShort"), 'checked'=>$checkedsupplieraccountcode, 'enabled'=>(! empty($conf->fournisseur->enabled))), + 's.town'=>array('label'=>$langs->trans("Town"), 'checked'=>1), + 's.zip'=>array('label'=>$langs->trans("Zip"), 'checked'=>1), + 'country.code_iso'=>array('label'=>$langs->trans("Country"), 'checked'=>0), + 'typent.code'=>array('label'=>$langs->trans("ThirdPartyType"), 'checked'=>$checkedtypetiers), + 's.siren'=>array('label'=>$langs->trans("ProfId1Short"), 'checked'=>$checkedprofid1), + 's.siret'=>array('label'=>$langs->trans("ProfId2Short"), 'checked'=>$checkedprofid2), + 's.ape'=>array('label'=>$langs->trans("ProfId3Short"), 'checked'=>$checkedprofid3), + 's.idprof4'=>array('label'=>$langs->trans("ProfId4Short"), 'checked'=>$checkedprofid4), + 's.idprof5'=>array('label'=>$langs->trans("ProfId5Short"), 'checked'=>$checkedprofid5), + 's.idprof6'=>array('label'=>$langs->trans("ProfId6Short"), 'checked'=>$checkedprofid6), + 's.fk_prospectlevel'=>array('label'=>$langs->trans("ProspectLevelShort"), 'checked'=>$checkprospectlevel), + 's.fk_stcomm'=>array('label'=>$langs->trans("StatusProsp"), 'checked'=>$checkstcomm), + 's.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), + 's.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), + 's.status'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000), +); +// Extra fields +if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) +{ + foreach($extrafields->attribute_label as $key => $val) + { + $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); + } +} + /* @@ -489,56 +538,9 @@ if ($resql) print ''; } - // Define list of fields to show into list - $checkedcustomercode=(in_array($contextpage, array('thirdpartylist', 'customerlist', 'prospectlist')) ? 1 : 0); - $checkedsuppliercode=(in_array($contextpage, array('supplierlist')) ? 1 : 0); - $checkedcustomeraccountcode=(in_array($contextpage, array('customerlist')) ? 1 : 0); - $checkedsupplieraccountcode=(in_array($contextpage, array('supplierlist')) ? 1 : 0); - $checkedtypetiers=1; - $checkedprofid1=0; - $checkedprofid2=0; - $checkedprofid3=0; - $checkedprofid4=0; - $checkedprofid5=0; - $checkedprofid6=0; - //$checkedprofid4=((($tmp = $langs->transnoentities("ProfId4".$mysoc->country_code)) && $tmp != "ProfId4".$mysoc->country_code && $tmp != '-') ? 1 : 0); - //$checkedprofid5=((($tmp = $langs->transnoentities("ProfId5".$mysoc->country_code)) && $tmp != "ProfId5".$mysoc->country_code && $tmp != '-') ? 1 : 0); - //$checkedprofid6=((($tmp = $langs->transnoentities("ProfId6".$mysoc->country_code)) && $tmp != "ProfId6".$mysoc->country_code && $tmp != '-') ? 1 : 0); - $checkprospectlevel=(in_array($contextpage, array('prospectlist')) ? 1 : 0); - $checkstcomm=(in_array($contextpage, array('prospectlist')) ? 1 : 0); - $arrayfields=array( - 's.nom'=>array('label'=>$langs->trans("Company"), 'checked'=>1), - 's.barcode'=>array('label'=>$langs->trans("Gencod"), 'checked'=>1, 'enabled'=>(! empty($conf->barcode->enabled))), - 's.code_client'=>array('label'=>$langs->trans("CustomerCodeShort"), 'checked'=>$checkedcustomercode), - 's.code_fournisseur'=>array('label'=>$langs->trans("SupplierCodeShort"), 'checked'=>$checkedsuppliercode, 'enabled'=>(! empty($conf->fournisseur->enabled))), - 's.code_compta'=>array('label'=>$langs->trans("CustomerAccountancyCodeShort"), 'checked'=>$checkedcustomeraccountcode), - 's.code_compta_fournisseur'=>array('label'=>$langs->trans("SupplierAccountancyCodeShort"), 'checked'=>$checkedsupplieraccountcode, 'enabled'=>(! empty($conf->fournisseur->enabled))), - 's.town'=>array('label'=>$langs->trans("Town"), 'checked'=>1), - 's.zip'=>array('label'=>$langs->trans("Zip"), 'checked'=>1), - 'country.code_iso'=>array('label'=>$langs->trans("Country"), 'checked'=>0), - 'typent.code'=>array('label'=>$langs->trans("ThirdPartyType"), 'checked'=>$checkedtypetiers), - 's.siren'=>array('label'=>$langs->trans("ProfId1Short"), 'checked'=>$checkedprofid1), - 's.siret'=>array('label'=>$langs->trans("ProfId2Short"), 'checked'=>$checkedprofid2), - 's.ape'=>array('label'=>$langs->trans("ProfId3Short"), 'checked'=>$checkedprofid3), - 's.idprof4'=>array('label'=>$langs->trans("ProfId4Short"), 'checked'=>$checkedprofid4), - 's.idprof5'=>array('label'=>$langs->trans("ProfId5Short"), 'checked'=>$checkedprofid5), - 's.idprof6'=>array('label'=>$langs->trans("ProfId6Short"), 'checked'=>$checkedprofid6), - 's.fk_prospectlevel'=>array('label'=>$langs->trans("ProspectLevelShort"), 'checked'=>$checkprospectlevel), - 's.fk_stcomm'=>array('label'=>$langs->trans("StatusProsp"), 'checked'=>$checkstcomm), - 's.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), - 's.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), - 's.status'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000), - ); - // Extra fields - if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) - { - foreach($extrafields->attribute_label as $key => $val) - { - $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); - } - } $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + print ''; print ''; diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 42e1617e4c1..ffd2f878adf 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -194,7 +194,8 @@ if (empty($reshook)) { $object->note = GETPOST("note"); $object->ldap_sid = GETPOST("ldap_sid"); $object->fk_user = GETPOST("fk_user") > 0 ? GETPOST("fk_user") : 0; - + $object->employee = GETPOST('employee'); + $object->thm = GETPOST("thm") != '' ? GETPOST("thm") : ''; $object->tjm = GETPOST("tjm") != '' ? GETPOST("tjm") : ''; $object->salary = GETPOST("salary") != '' ? GETPOST("salary") : ''; @@ -324,7 +325,8 @@ if (empty($reshook)) { $object->accountancy_code = GETPOST("accountancy_code"); $object->openid = GETPOST("openid"); $object->fk_user = GETPOST("fk_user") > 0 ? GETPOST("fk_user") : 0; - + $object->employee = GETPOST('employee'); + $object->thm = GETPOST("thm") != '' ? GETPOST("thm") : ''; $object->tjm = GETPOST("tjm") != '' ? GETPOST("tjm") : ''; $object->salary = GETPOST("salary") != '' ? GETPOST("salary") : ''; @@ -697,7 +699,7 @@ if (($action == 'create') || ($action == 'adduserldap')) print ''; // Lastname - print ''; + print ''; print '
'.$langs->trans("Lastname").''.$langs->trans("Lastname").''; if (! empty($ldap_lastname)) { @@ -1168,7 +1170,7 @@ else print ''; // Login - print ''; + print ''; if (! empty($object->ldap_sid) && $object->statut==0) { print ''; @@ -1362,7 +1364,7 @@ else print '
'; print '
'.$langs->trans("Login").'
'.$langs->trans("Login").''.$langs->trans("LoginAccountDisableInDolibarr").'
'; - print ''; + print ''; print ''; print "\n"; diff --git a/htdocs/user/index.php b/htdocs/user/index.php index 9c1828653ac..e19b7c8ab6a 100644 --- a/htdocs/user/index.php +++ b/htdocs/user/index.php @@ -40,21 +40,6 @@ $socid=0; if ($user->societe_id > 0) $socid = $user->societe_id; -$sall=GETPOST('sall','alpha'); -$search_user=GETPOST('search_user','alpha'); -$search_login=GETPOST('search_login','alpha'); -$search_lastname=GETPOST('search_lastname','alpha'); -$search_firstname=GETPOST('search_firstname','alpha'); -$search_accountancy_code=GETPOST('search_accountancy_code','alpha'); -$search_email=GETPOST('search_email','alpha'); -$search_statut=GETPOST('search_statut','alpha'); -$search_thirdparty=GETPOST('search_thirdparty','alpha'); -$search_supervisor=GETPOST('search_supervisor','alpha'); -$search_previousconn=GETPOST('search_previousconn','alpha'); -$optioncss = GETPOST('optioncss','alpha'); - -if ($search_statut == '') $search_statut='1'; - // Load variable for pagination $limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; $sortfield = GETPOST('sortfield','alpha'); @@ -89,6 +74,53 @@ $fieldstosearchall = array( 'u.note'=>"Note" ); +// Definition of fields for list +$arrayfields=array( + 'u.login'=>array('label'=>$langs->trans("Login"), 'checked'=>1), + 'u.lastname'=>array('label'=>$langs->trans("Lastname"), 'checked'=>1), + 'u.firstname'=>array('label'=>$langs->trans("Firstname"), 'checked'=>1), + 'u.gender'=>array('label'=>$langs->trans("Gender"), 'checked'=>0), + 'u.employee'=>array('label'=>$langs->trans("Employee"), 'checked'=>0), + 'u.accountancy_code'=>array('label'=>$langs->trans("AccountancyCode"), 'checked'=>0), + 'u.email'=>array('label'=>$langs->trans("EMail"), 'checked'=>1), + 'u.fk_soc'=>array('label'=>$langs->trans("Company"), 'checked'=>1), + 'u.entity'=>array('label'=>$langs->trans("Entity"), 'checked'=>1, 'enabled'=>(! empty($conf->multicompany->enabled) && empty($conf->multicompany->transverse_mode))), + 'u.fk_user'=>array('label'=>$langs->trans("HierarchicalResponsible"), 'checked'=>1), + 'u.datelastlogin'=>array('label'=>$langs->trans("LastConnexion"), 'checked'=>1, 'position'=>100), + 'u.datepreviouslogin'=>array('label'=>$langs->trans("PreviousConnexion"), 'checked'=>0, 'position'=>110), + 'u.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), + 'u.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), + 'u.statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000), +); +// Extra fields +if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) +{ + foreach($extrafields->attribute_label as $key => $val) + { + $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); + } +} + +// Init search fields +$sall=GETPOST('sall','alpha'); +$search_user=GETPOST('search_user','alpha'); +$search_login=GETPOST('search_login','alpha'); +$search_lastname=GETPOST('search_lastname','alpha'); +$search_firstname=GETPOST('search_firstname','alpha'); +$search_gender=GETPOST('search_gender','alpha'); +$search_employee=GETPOST('search_employee','alpha'); +$search_accountancy_code=GETPOST('search_accountancy_code','alpha'); +$search_email=GETPOST('search_email','alpha'); +$search_statut=GETPOST('search_statut','alpha'); +$search_thirdparty=GETPOST('search_thirdparty','alpha'); +$search_supervisor=GETPOST('search_supervisor','alpha'); +$search_previousconn=GETPOST('search_previousconn','alpha'); +$optioncss = GETPOST('optioncss','alpha'); + +// Default search +if ($search_statut == '') $search_statut='1'; + + /* * Actions @@ -106,6 +138,8 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") ||GETPO $search_login=""; $search_lastname=""; $search_firstname=""; + $search_gender=""; + $search_employee=""; $search_accountancy_code=""; $search_email=""; $search_statut=""; @@ -130,7 +164,7 @@ $buttonviewhierarchy='= 0) $sql.= natural_search("u.employee", $search_employee); if ($search_accountancy_code != '') $sql.= natural_search("u.accountancy_code", $search_accountancy_code); if ($search_email != '') $sql.= natural_search("u.email", $search_email); if ($search_statut != '' && $search_statut >= 0) $sql.= " AND (u.statut=".$search_statut.")"; @@ -197,6 +233,8 @@ if ($result) if ($search_login != '') $param.="&search_login=".$search_login; if ($search_lastname != '') $param.="&search_lastname=".$search_lastname; if ($search_firstname != '') $param.="&search_firstname=".$search_firstname; + if ($search_gender != '') $param.="&search_gender=".$search_gender; + if ($search_employee != '') $param.="&search_employee=".$search_employee; if ($search_accountancy_code != '') $param.="&search_accountancy_code=".$search_accountancy_code; if ($search_email != '') $param.="&search_email=".$search_email; if ($search_supervisor > 0) $param.="&search_supervisor=".$search_supervisor; @@ -224,36 +262,16 @@ if ($result) print $langs->trans("FilterOnInto", $sall, join(', ',$fieldstosearchall)); } - $arrayfields=array( - 'u.login'=>array('label'=>$langs->trans("Login"), 'checked'=>1), - 'u.lastname'=>array('label'=>$langs->trans("Lastname"), 'checked'=>1), - 'u.firstname'=>array('label'=>$langs->trans("Firstname"), 'checked'=>1), - 'u.accountancy_code'=>array('label'=>$langs->trans("AccountancyCode"), 'checked'=>0), - 'u.email'=>array('label'=>$langs->trans("EMail"), 'checked'=>1), - 'u.fk_soc'=>array('label'=>$langs->trans("Company"), 'checked'=>1), - 'u.entity'=>array('label'=>$langs->trans("Entity"), 'checked'=>1, 'enabled'=>(! empty($conf->multicompany->enabled) && empty($conf->multicompany->transverse_mode))), - 'u.fk_user'=>array('label'=>$langs->trans("HierarchicalResponsible"), 'checked'=>1), - 'u.datelastlogin'=>array('label'=>$langs->trans("LastConnexion"), 'checked'=>1, 'position'=>100), - 'u.datepreviouslogin'=>array('label'=>$langs->trans("PreviousConnexion"), 'checked'=>0, 'position'=>110), - 'u.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), - 'u.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), - 'u.statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000), - ); - // Extra fields - if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) - { - foreach($extrafields->attribute_label as $key => $val) - { - $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); - } - } - $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; - $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - print '
'.$langs->trans("LastConnexion").'
'.$langs->trans("LastConnexion").''.dol_print_date($object->datelastlogin,"dayhour").'
'; + $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; + $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + + print '
'; print ''; if (! empty($arrayfields['u.login']['checked'])) print_liste_field_titre($langs->trans("Login"),$_SERVER['PHP_SELF'],"u.login",$param,"","",$sortfield,$sortorder); if (! empty($arrayfields['u.lastname']['checked'])) print_liste_field_titre($langs->trans("Lastname"),$_SERVER['PHP_SELF'],"u.lastname",$param,"","",$sortfield,$sortorder); if (! empty($arrayfields['u.firstname']['checked'])) print_liste_field_titre($langs->trans("FirstName"),$_SERVER['PHP_SELF'],"u.firstname",$param,"","",$sortfield,$sortorder); + if (! empty($arrayfields['u.gender']['checked'])) print_liste_field_titre($langs->trans("Gender"),$_SERVER['PHP_SELF'],"u.gender",$param,"","",$sortfield,$sortorder); + if (! empty($arrayfields['u.employee']['checked'])) print_liste_field_titre($langs->trans("Employee"),$_SERVER['PHP_SELF'],"u.employee",$param,"","",$sortfield,$sortorder); if (! empty($arrayfields['u.accountancy_code']['checked'])) print_liste_field_titre($langs->trans("AccountancyCode"),$_SERVER['PHP_SELF'],"u.accountancy_code",$param,"","",$sortfield,$sortorder); if (! empty($arrayfields['u.email']['checked'])) print_liste_field_titre($langs->trans("EMail"),$_SERVER['PHP_SELF'],"u.email",$param,"","",$sortfield,$sortorder); if (! empty($arrayfields['u.fk_soc']['checked'])) print_liste_field_titre($langs->trans("Company"),$_SERVER['PHP_SELF'],"u.fk_soc",$param,"","",$sortfield,$sortorder); @@ -297,6 +315,19 @@ if ($result) { print ''; } + if (! empty($arrayfields['u.gender']['checked'])) + { + print ''; + } + if (! empty($arrayfields['u.employee']['checked'])) + { + print ''; + } if (! empty($arrayfields['u.accountancy_code']['checked'])) { print ''; @@ -382,6 +413,7 @@ if ($result) $userstatic->societe_id=$obj->fk_soc; $userstatic->firstname=$obj->firstname; $userstatic->lastname=$obj->lastname; + $userstatic->employee=$obj->employee; $userstatic->photo=$obj->photo; $li=$userstatic->getNomUrl(-1,'',0,0,24,1,'login'); @@ -409,7 +441,17 @@ if ($result) { print ''; } - if (! empty($arrayfields['u.accountancy_code']['checked'])) + if (! empty($arrayfields['u.gender']['checked'])) + { + print ''; + } + if (! empty($arrayfields['u.employee']['checked'])) + { + print ''; + } + if (! empty($arrayfields['u.accountancy_code']['checked'])) { print ''; }
'; + $arraygender=array('man'=>$langs->trans("Genderman"),'woman'=>$langs->trans("Genderwoman")); + print $form->selectarray('search_gender', $arraygender, $search_gender, 1); + print ''; + print $form->selectyesno('search_employee', $search_employee, 1, false, 1); + print ''.$obj->firstname.''; + if ($obj->gender) print $langs->trans("Gender".$obj->gender); + print ''.yn($obj->employee).''.$obj->accountancy_code.'