diff --git a/.travis.yml b/.travis.yml index 51b62e240e9..5e3f1511266 100644 --- a/.travis.yml +++ b/.travis.yml @@ -207,8 +207,7 @@ before_script: mysql -D travis < dev/initdemo/mysqldump_dolibarr_3.5.0.sql fi if [ "$DB" = 'postgresql' ]; then - #pgsql travis < dev/initdemo/mysqldump_dolibarr_3.5.0.sql - #pgloader mysql://root:pass@127.0.0.1/base postgresql://dolibarrowner@127.0.0.1/dolibarr + #pgloader mysql://root:pass@127.0.0.1/dolibarr_35 postgresql://dolibarrowner:dolibarrownerpass@127.0.0.1/dolibarr_dev pgloader mysql://root@127.0.0.1/travis postgresql:///travis fi # TODO: SQLite @@ -238,8 +237,9 @@ before_script: - | echo "Create documents directory and set permissions" # and admin/temp subdirectory needed for unit tests - mkdir -p documents/admin/temp - echo "first line" > documents/dolibarr.log + mkdir -p $TRAVIS_BUILD_DIR/documents/admin/temp + sudo chmod -R a+rwx $TRAVIS_BUILD_DIR/documents + echo "***** First line of dolibarr.log" > $TRAVIS_BUILD_DIR/documents/dolibarr.log echo @@ -334,32 +334,28 @@ script: php upgrade.php 7.0.0 8.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade700800.log php upgrade2.php 7.0.0 8.0.0 MAIN_MODULE_TICKETSUP > $TRAVIS_BUILD_DIR/upgrade700800-2.log php step5.php 7.0.0 8.0.0 > $TRAVIS_BUILD_DIR/upgrade700800-3.log + php upgrade.php 8.0.0 9.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade800900.log + php upgrade2.php 8.0.0 9.0.0 > $TRAVIS_BUILD_DIR/upgrade800900-2.log + php step5.php 8.0.0 9.0.0 > $TRAVIS_BUILD_DIR/upgrade800900-3.log cd - set +e echo - #cat $TRAVIS_BUILD_DIR/upgrade400500-2.log - #cat $TRAVIS_BUILD_DIR/upgrade500600.log - #cat $TRAVIS_BUILD_DIR/upgrade500600-2.log - #cat $TRAVIS_BUILD_DIR/upgrade500600-3.log #cat /tmp/dolibarr_install.log - + - | echo "Unit testing" # Ensure we catch errors. Set this to +e if you want to go to the end to see dolibarr.log file. set -e phpunit -d memory_limit=-1 -c test/phpunit/phpunittest.xml test/phpunit/AllTests.php + phpunitresult=$? + echo "Phpunit return code = $phpunitresult" set +e -- | - #echo "Output dolibarr.log" - #cat documents/dolibarr.log - after_script: - | - # Dolibarr log file - #echo "After script" - #cat documents/dolibarr.log - + echo "After script - Output 50 latest lines of dolibarr.log" + ls $TRAVIS_BUILD_DIR/documents + tail -n 50 $TRAVIS_BUILD_DIR/documents/dolibarr.log after_success: - | @@ -367,19 +363,24 @@ after_success: after_failure: - | - echo Failure - # This part of code seems to be never executed, error or not ??? - echo "Debugging informations" + echo Failure detected, so we show samples of log to help diagnose + # This part of code is executed only if previous commande that fails are enclosed with set +e # Upgrade log files - cat *.log - echo "Debugging informations" + for ficlog in `ls $TRAVIS_BUILD_DIR/*.log` + do + echo "Debugging informations for file $ficlog" + #cat $ficlog + done # Apache log file + echo "Debugging informations for file apache error.log" sudo cat /var/log/apache2/error.log - # Dolibarr log file - cat documents/dolibarr.log if [ "$DEBUG" = true ]; then + # Dolibarr log file + echo "Debugging informations for file dolibarr.log (latest 50 lines)" + tail -n 50 $TRAVIS_BUILD_DIR/documents/dolibarr.log # MariaDB log file - sudo cat /var/log/mysql/error.log + echo "Debugging informations for file mysql error.log" + sudo tail -n 50 /var/log/mysql/error.log # TODO: PostgreSQL log file echo fi diff --git a/ChangeLog b/ChangeLog index fac6c0a3c06..4adf6192acd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,28 @@ English Dolibarr ChangeLog -------------------------------------------------------------- +***** ChangeLog for 8.0.0 compared to 7.0.3 ***** + +WARNING: + +Following changes may create regressions for some external modules, but were necessary to make Dolibarr better: +* Remove old deprecated hook 'insertExtraFields'. Triggers must be used for action on CRUD events. +* Hook 'maildao' was renamed into 'mail' into the method sendfile that send emails, and method was renamed from + 'doaction' into 'sendMail'. +* Rename trigger CONTRACT_SERVICE_ACTIVATE into LINECONTRACT_ACTIVATE and + CONTRACT_SERVICE_CLOSE into LINECONTRACT_CLOSE +* Remove triggers *_CLONE. The trigger CREATE with context 'createfromclone' is already called so this is + a duplicated feature. Cloning is not a business event, the business event is CREATE, so no trigger required. +* PHP 5.3 is no more supported. Minimum PHP is now 5.4+ +* Remove the old deprecated code of doActions and getInstanceDao in canvas. The doActions of standard hooks are + already available and are better. +* Removed method fetch_prods() and get_each_prod() not used, keep only get_arbo_each_prod() that is better. +* The hook contaxt commcard has been renamed thirdpartycomm +* The hook contaxt thirdpartycard has been renamed thirdpartycontact +* Remove method Categorie:get_nb_categories() that was not used. +* Hook getnomurltooltip provide a duplicate feature compared to hook getNomUrl so all hooks getnomurltooltip + are now replaced with hook getNomUrl. + ***** ChangeLog for 7.0.3 compared to 7.0.2 ***** FIX: 7.0 task contact card without withproject parameters FIX: #8722 @@ -40,29 +62,6 @@ FIX: supplier order: product supplier ref not saved on addline FIX: test is_erasable() must be done before call function delete() too to avoid delete invoice with &action=delete in url FIX: wrong var name $search_month_lim -***** ChangeLog for 8.0.0 compared to 7.0.0 ***** - -WARNING: - -Following changes may create regressions for some external modules, but were necessary to make Dolibarr better: -* Remove old deprecated hook 'insertExtraFields'. Triggers must be used for action on CRUD events. -* Hook 'maildao' was renamed into 'mail' into the method sendfile that send emails, and method was renamed from - 'doaction' into 'sendMail'. -* Rename trigger CONTRACT_SERVICE_ACTIVATE into LINECONTRACT_ACTIVATE and - CONTRACT_SERVICE_CLOSE into LINECONTRACT_CLOSE -* Remove triggers *_CLONE. The trigger CREATE with context 'createfromclone' is already called so this is - a duplicated feature. Cloning is not a business event, the business event is CREATE, so no trigger required. -* PHP 5.3 is no more supported. Minimum PHP is now 5.4+ -* Remove the old deprecated code of doActions and getInstanceDao in canvas. The doActions of standard hooks are - already available and are better. -* Removed method fetch_prods() and get_each_prod() not used, keep only get_arbo_each_prod() that is better. -* The hook contaxt commcard has been renamed thirdpartycomm -* The hook contaxt thirdpartycard has been renamed thirdpartycontact -* Remove method Categorie:get_nb_categories() that was not used. -* Hook getnomurltooltip provide a duplicate feature compared to hook getNomUrl so all hooks getnomurltooltip - are now replaced with hook getNomUrl. - - ***** ChangeLog for 7.0.2 compared to 7.0.1 ***** FIX: #8023 FIX: #8259 can't update contact birthday with REST API @@ -220,7 +219,7 @@ FIX: Use of undefined constant _ROWS_2 FIX: warning when adding ECM files using old photo path -***** ChangeLog for 7.0.0 compared to 6.0.5 ***** +***** ChangeLog for 7.0.0 compared to 6.0.7 ***** For users: NEW: Add a preview icon after files that can be previewed (pdf + images) NEW: When payment is registered, PDF of invoices are also regenerated so payments diff --git a/htdocs/admin/agenda_extrafields.php b/htdocs/admin/agenda_extrafields.php index fadb144b883..69e834e22e2 100644 --- a/htdocs/admin/agenda_extrafields.php +++ b/htdocs/admin/agenda_extrafields.php @@ -85,7 +85,7 @@ dol_fiche_end(); if ($action != 'create' && $action != 'edit') { print '
'; - print "".$langs->trans("NewAttribute").""; + print "".$langs->trans("NewAttribute").""; print "
"; } @@ -98,7 +98,7 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { - print "
"; + print '
'; print load_fiche_titre($langs->trans('NewAttribute')); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; diff --git a/htdocs/admin/bank_extrafields.php b/htdocs/admin/bank_extrafields.php index 19446092923..99b8d09f277 100644 --- a/htdocs/admin/bank_extrafields.php +++ b/htdocs/admin/bank_extrafields.php @@ -82,7 +82,7 @@ dol_fiche_end(); if ($action != 'create' && $action != 'edit') { print '
'; - print "".$langs->trans("NewAttribute").""; + print "".$langs->trans("NewAttribute").""; print "
"; } @@ -95,7 +95,7 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { - print "
"; + print '
'; print load_fiche_titre($langs->trans('NewAttribute')); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index c50985be5fc..e4f9fa1dd90 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -261,7 +261,7 @@ $tabfield[10]= "country_id,country,code,taux,localtax1_type,localtax1,localtax2_ $tabfield[11]= "element,source,code,libelle,position"; $tabfield[12]= "code,libelle,libelle_facture,nbjour,type_cdr,decalage,sortorder,entity"; $tabfield[13]= "code,libelle,type,entity"; -$tabfield[14]= "code,label,price,organization,country_id,country"; +$tabfield[14]= "code,label,price,organization,country"; $tabfield[15]= "code,libelle,width,height,unit"; $tabfield[16]= "code,libelle,sortorder"; $tabfield[17]= "code,label,accountancy_code"; diff --git a/htdocs/admin/expedition_extrafields.php b/htdocs/admin/expedition_extrafields.php index af49e5bf064..12365f1801d 100644 --- a/htdocs/admin/expedition_extrafields.php +++ b/htdocs/admin/expedition_extrafields.php @@ -87,7 +87,7 @@ dol_fiche_end(); if ($action != 'create' && $action != 'edit') { print '
'; - print "".$langs->trans("NewAttribute").""; + print "".$langs->trans("NewAttribute").""; print "
"; } @@ -100,7 +100,7 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { - print "
"; + print '
'; print load_fiche_titre($langs->trans('NewAttribute')); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; diff --git a/htdocs/admin/expeditiondet_extrafields.php b/htdocs/admin/expeditiondet_extrafields.php index 5567e9480e8..89b270d10fc 100644 --- a/htdocs/admin/expeditiondet_extrafields.php +++ b/htdocs/admin/expeditiondet_extrafields.php @@ -88,7 +88,7 @@ dol_fiche_end(); if ($action != 'create' && $action != 'edit') { print '
'; - print "".$langs->trans("NewAttribute").""; + print "".$langs->trans("NewAttribute").""; print "
"; } @@ -101,7 +101,7 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { - print "
"; + print '
'; print load_fiche_titre($langs->trans('NewAttribute')); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; diff --git a/htdocs/admin/expensereport_extrafields.php b/htdocs/admin/expensereport_extrafields.php index 8db81edb869..99d1bd0e8da 100644 --- a/htdocs/admin/expensereport_extrafields.php +++ b/htdocs/admin/expensereport_extrafields.php @@ -83,7 +83,7 @@ dol_fiche_end(); if ($action != 'create' && $action != 'edit') { print '
'; - print "".$langs->trans("NewAttribute").""; + print "".$langs->trans("NewAttribute").""; print "
"; } @@ -96,7 +96,7 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { - print "
"; + print '
'; print load_fiche_titre($langs->trans('NewAttribute')); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; diff --git a/htdocs/admin/holiday.php b/htdocs/admin/holiday.php new file mode 100644 index 00000000000..b199505d214 --- /dev/null +++ b/htdocs/admin/holiday.php @@ -0,0 +1,521 @@ + + * Copyright (C) 2011-2015 Philippe Grand + * Copyright (C) 2013 Juanjo Menent + * Copyright (C) 2018 Charlene Benke + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/admin/contract.php + * \ingroup contract + * \brief Setup page of module Contracts + */ + +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/holiday.lib.php'; + +$langs->load("admin"); +$langs->load("errors"); +$langs->load("holiday"); + +if (!$user->admin) accessforbidden(); + +$action = GETPOST('action','alpha'); +$value = GETPOST('value','alpha'); +$label = GETPOST('label','alpha'); +$scandir = GETPOST('scan_dir','alpha'); +$type='contract'; + +if (empty($conf->global->HOLIDAY_ADDON)) +{ + $conf->global->HOLIDAY_ADDON='mod_holiday_madona'; +} + + +/* + * Actions + */ + +include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; + +if ($action == 'updateMask') +{ + $maskconst = GETPOST('maskconstholidaty','alpha'); + $maskvalue = GETPOST('maskholiday','alpha'); + if ($maskconst) $res = dolibarr_set_const($db,$maskconst,$maskvalue,'chaine',0,'',$conf->entity); + + if (! $res > 0) $error++; + + if (! $error) + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } + else + { + setEventMessages($langs->trans("Error"), null, 'errors'); + } +} + +else if ($action == 'specimen') // For contract +{ + $modele= GETPOST('module','alpha'); + + $contract = new Contrat($db); + $contract->initAsSpecimen(); + + // Search template files + $file=''; $classname=''; $filefound=0; + $dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']); + foreach($dirmodels as $reldir) + { + $file=dol_buildpath($reldir."core/modules/holiday/doc/pdf_".$modele.".modules.php",0); + if (file_exists($file)) + { + $filefound=1; + $classname = "pdf_".$modele; + break; + } + } + + if ($filefound) + { + require_once $file; + + $module = new $classname($db); + + if ($module->write_file($contract,$langs) > 0) + { + header("Location: ".DOL_URL_ROOT."/document.php?modulepart=holiday&file=SPECIMEN.pdf"); + return; + } + else + { + setEventMessages($obj->error, $obj->errors, 'errors'); + dol_syslog($obj->error, LOG_ERR); + } + } + else + { + setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); + dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); + } +} + +// Activate a model +else if ($action == 'set') +{ + $ret = addDocumentModel($value, $type, $label, $scandir); +} + +else if ($action == 'del') +{ + $ret = delDocumentModel($value, $type); + if ($ret > 0) + { + if ($conf->global->HOLIDAY_ADDON_PDF == "$value") dolibarr_del_const($db, 'HOLIDAY_ADDON_PDF',$conf->entity); + } +} + +// Set default model +else if ($action == 'setdoc') +{ + if (dolibarr_set_const($db, "HOLIDAY_ADDON_PDF",$value,'chaine',0,'',$conf->entity)) + { + // La constante qui a ete lue en avant du nouveau set + // on passe donc par une variable pour avoir un affichage coherent + $conf->global->HOLIDAY_ADDON_PDF = $value; + } + + // On active le modele + $ret = delDocumentModel($value, $type); + if ($ret > 0) + { + $ret = addDocumentModel($value, $type, $label, $scandir); + } +} + +else if ($action == 'setmod') +{ + // TODO Verifier si module numerotation choisi peut etre active + // par appel methode canBeActivated + + dolibarr_set_const($db, "HOLIDAY_ADDON",$value,'chaine',0,'',$conf->entity); +} + +else if ($action == 'set_other') +{ + $freetext= GETPOST('HOLIDAY_FREE_TEXT','none'); // No alpha here, we want exact string + $res1 = dolibarr_set_const($db, "HOLIDAY_FREE_TEXT",$freetext,'chaine',0,'',$conf->entity); + + $draft= GETPOST('HOLIDAY_DRAFT_WATERMARK','alpha'); + $res2 = dolibarr_set_const($db, "HOLIDAY_DRAFT_WATERMARK",trim($draft),'chaine',0,'',$conf->entity); + + if (! $res1 > 0 || ! $res2 > 0) $error++; + + if (! $error) + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } + else + { + setEventMessages($langs->trans("Error"), null, 'errors'); + } +} + + +/* + * View + */ + +$dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']); + +llxHeader(); + +$form=new Form($db); + +$linkback=''.$langs->trans("BackToModuleList").''; +print load_fiche_titre($langs->trans("HolidaySetup"),$linkback,'title_setup'); + +$head=holiday_admin_prepare_head(); + +dol_fiche_head($head, 'holiday', $langs->trans("Holidays"), -1, 'holiday'); + +/* + * Holiday Numbering model + */ + +print load_fiche_titre($langs->trans("HolidaysNumberingModules"),'',''); + +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print "\n"; + +clearstatcache(); + +foreach ($dirmodels as $reldir) +{ + $dir = dol_buildpath($reldir."core/modules/holiday/"); + + if (is_dir($dir)) + { + $handle = opendir($dir); + if (is_resource($handle)) + { + $var=true; + + while (($file = readdir($handle))!==false) + { + if (substr($file, 0, 12) == 'mod_holiday_' && substr($file, dol_strlen($file)-3, 3) == 'php') + { + $file = substr($file, 0, dol_strlen($file)-4); + + require_once $dir.$file.'.php'; + + $module = new $file($db); + + // Show modules according to features level + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; + + if ($module->isEnabled()) + { + + print ''; + + // Show example of numbering model + print ''."\n"; + + print ''; + + $holiday=new Holiday($db); + $holiday->initAsSpecimen(); + + // Info + $htmltooltip=''; + $htmltooltip.=''.$langs->trans("Version").': '.$module->getVersion().'
'; + $nextval=$module->getNextValue($mysoc,$contract); + if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval + $htmltooltip.=''.$langs->trans("NextValue").': '; + if ($nextval) { + if (preg_match('/^Error/',$nextval) || $nextval=='NotConfigured') + $nextval = $langs->trans($nextval); + $htmltooltip.=$nextval.'
'; + } else { + $htmltooltip.=$langs->trans($module->error).'
'; + } + } + + print ''; + + print ''; + } + } + } + closedir($handle); + } + } +} + +print '
'.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("Example").''.$langs->trans("Status").''.$langs->trans("ShortInfo").'
'.$module->nom."\n"; + print $module->info(); + print ''; + $tmp=$module->getExample(); + if (preg_match('/^Error/',$tmp)) { $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; } + elseif ($tmp=='NotConfigured') print $langs->trans($tmp); + else print $tmp; + print '
'; + if ($conf->global->HOLIDAY_ADDON == "$file") + { + print img_picto($langs->trans("Activated"),'switch_on'); + } + else + { + print ''; + print img_picto($langs->trans("Disabled"),'switch_off'); + print ''; + } + print ''; + print $form->textwithpicto('',$htmltooltip,1,0); + print '

'; + +/* + * Documents models for Contracts + */ + +print load_fiche_titre($langs->trans("TemplatePDFHolidays"),'',''); + +// Defini tableau def des modeles +$def = array(); +$sql = "SELECT nom"; +$sql.= " FROM ".MAIN_DB_PREFIX."document_model"; +$sql.= " WHERE type = '".$type."'"; +$sql.= " AND entity = ".$conf->entity; +$resql=$db->query($sql); +if ($resql) +{ + $i = 0; + $num_rows=$db->num_rows($resql); + while ($i < $num_rows) + { + $array = $db->fetch_array($resql); + array_push($def, $array[0]); + $i++; + } +} +else +{ + dol_print_error($db); +} + + +print ''; +print ''; +print ''; +print ''; +print '\n"; +print '\n"; +print ''; +print ''; +print "\n"; + +clearstatcache(); + +$var=true; +foreach ($dirmodels as $reldir) +{ + foreach (array('','/doc') as $valdir) + { + $dir = dol_buildpath($reldir."core/modules/holiday".$valdir); + + if (is_dir($dir)) + { + $handle=opendir($dir); + if (is_resource($handle)) + { + while (($file = readdir($handle))!==false) + { + $filelist[]=$file; + } + closedir($handle); + arsort($filelist); + + foreach($filelist as $file) + { + if (preg_match('/\.modules\.php$/i',$file) && preg_match('/^(pdf_|doc_)/',$file)) + { + + if (file_exists($dir.'/'.$file)) + { + $name = substr($file, 4, dol_strlen($file) -16); + $classname = substr($file, 0, dol_strlen($file) -12); + + require_once $dir.'/'.$file; + $module = new $classname($db); + + $modulequalified=1; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0; + + if ($modulequalified) + { + $var = !$var; + print ''; + + // Active + if (in_array($name, $def)) + { + print ''; + } + else + { + print '"; + } + + // Defaut + print ''; + + // Info + $htmltooltip = ''.$langs->trans("Name").': '.$module->name; + $htmltooltip.='
'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown")); + if ($module->type == 'pdf') + { + $htmltooltip.='
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; + } + $htmltooltip.='

'.$langs->trans("FeaturesSupported").':'; + $htmltooltip.='
'.$langs->trans("Logo").': '.yn($module->option_logo,1,1); + $htmltooltip.='
'.$langs->trans("PaymentMode").': '.yn($module->option_modereg,1,1); + $htmltooltip.='
'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg,1,1); + $htmltooltip.='
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang,1,1); + $htmltooltip.='
'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark,1,1); + + + print ''; + + // Preview + print ''; + + print "\n"; + } + } + } + } + } + } + } +} + +print '
'.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("Status")."'.$langs->trans("Default")."'.$langs->trans("ShortInfo").''.$langs->trans("Preview").'
'; + print (empty($module->name)?$name:$module->name); + print "\n"; + if (method_exists($module,'info')) print $module->info($langs); + else print $module->description; + print ''."\n"; + print ''; + print img_picto($langs->trans("Enabled"),'switch_on'); + print ''; + print ''."\n"; + print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').''; + print "'; + if ($conf->global->HOLIDAY_ADDON_PDF == $name) + { + print img_picto($langs->trans("Default"),'on'); + } + else + { + print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').''; + } + print ''; + print $form->textwithpicto('',$htmltooltip,1,0); + print ''; + if ($module->type == 'pdf') + { + print ''.img_object($langs->trans("Preview"),'contract').''; + } + else + { + print img_object($langs->trans("PreviewNotAvailable"),'generic'); + } + print '
'; +print "
"; + +/* + * Other options + * + */ + +print '
'; +print ''; +print ''; + +print load_fiche_titre($langs->trans("OtherOptions"),'',''); +print ''; +print ''; +print ''; +print ''; +print "\n"; +$var=true; + +$substitutionarray=pdf_getSubstitutionArray($langs, array('objectamount'), null, 2); +$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); +$htmltext = ''.$langs->trans("AvailableVariables").':
'; +foreach($substitutionarray as $key => $val) $htmltext.=$key.'
'; +$htmltext.='
'; + +$var=! $var; +print ''."\n"; + +//Use draft Watermark + +print ''."\n"; + +print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; +print $form->textwithpicto($langs->trans("FreeLegalTextOnHolidays"), $langs->trans("AddCRIfTooLong").'

'.$htmltext, 1, 'help', '', 0, 2, 'tooltiphelp'); +print '
'; +$variablename='HOLIDAY_FREE_TEXT'; +if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) +{ + print ''; +} +else +{ + include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_notes'); + print $doleditor->Create(); +} +print '
'; +print $form->textwithpicto($langs->trans("WatermarkOnDraftHolidayCards"), $htmltext, 1, 'help', '', 0, 2, 'watermarktooltip').'
'; +print '
'; +print ''; +print '
'; + +print '
'; +print ''; +print '
'; + +print '
'; + +dol_fiche_end(); + +llxFooter(); +$db->close(); diff --git a/htdocs/admin/livraison_extrafields.php b/htdocs/admin/livraison_extrafields.php index 6ccf798bc93..c9fed1c6554 100644 --- a/htdocs/admin/livraison_extrafields.php +++ b/htdocs/admin/livraison_extrafields.php @@ -87,7 +87,7 @@ dol_fiche_end(); if ($action != 'create' && $action != 'edit') { print '"; } @@ -100,7 +100,7 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { - print "
"; + print '
'; print load_fiche_titre($langs->trans('NewAttribute')); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; diff --git a/htdocs/admin/livraisondet_extrafields.php b/htdocs/admin/livraisondet_extrafields.php index 431d5c3c170..921e9cfee41 100644 --- a/htdocs/admin/livraisondet_extrafields.php +++ b/htdocs/admin/livraisondet_extrafields.php @@ -88,7 +88,7 @@ dol_fiche_end(); if ($action != 'create' && $action != 'edit') { print '"; } @@ -101,7 +101,7 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { - print "
"; + print '
'; print load_fiche_titre($langs->trans('NewAttribute')); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index 588bdb856db..036e6100449 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -7,7 +7,8 @@ * Copyright (C) 2011 Juanjo Menent * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2015 Raphaël Doursenaud - * + * Copyright (C) 2018 Nicolas ZABOURI + * * 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 @@ -637,6 +638,7 @@ if ($mode == 'common') } print ''."\n"; + if (!empty($conf->global->MAIN_MODULES_SHOW_LINENUMBERS)) print ''.++$linenum.''; // Picto + Name of module print ' '; @@ -669,6 +671,17 @@ if ($mode == 'common') // Version print ''; print $versiontrans; + if(!empty($conf->global->CHECKLASTVERSION_EXTERNALMODULE)){ + require_once(DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php'); + if (!empty($objMod->url_last_version)) { + $newversion = getURLContent($objMod->url_last_version); + if(isset($newversion['content'])){ + if (version_compare($newversion['content'], $versiontrans) > 0) { + print " ".$newversion['content'].""; + } + } + } + } print "\n"; // Activate/Disable and Setup (2 columns) diff --git a/htdocs/admin/order_extrafields.php b/htdocs/admin/order_extrafields.php index 361fc5b67bb..a8031c915a9 100644 --- a/htdocs/admin/order_extrafields.php +++ b/htdocs/admin/order_extrafields.php @@ -85,7 +85,7 @@ dol_fiche_end(); if ($action != 'create' && $action != 'edit') { print '"; } @@ -98,7 +98,7 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { - print "
"; + print '
'; print load_fiche_titre($langs->trans('NewAttribute')); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; diff --git a/htdocs/admin/orderdet_extrafields.php b/htdocs/admin/orderdet_extrafields.php index c75551cf9f0..2e1b00025cd 100644 --- a/htdocs/admin/orderdet_extrafields.php +++ b/htdocs/admin/orderdet_extrafields.php @@ -86,7 +86,7 @@ dol_fiche_end(); if ($action != 'create' && $action != 'edit') { print '"; } @@ -99,7 +99,7 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { - print "
"; + print '
'; print load_fiche_titre($langs->trans('NewAttribute')); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; diff --git a/htdocs/admin/prelevement.php b/htdocs/admin/prelevement.php index 6fd40cf2825..56e1e7f2039 100644 --- a/htdocs/admin/prelevement.php +++ b/htdocs/admin/prelevement.php @@ -80,6 +80,16 @@ if ($action == "set") $res = dolibarr_set_const($db, "PRELEVEMENT_USER", GETPOST("PRELEVEMENT_USER"),'chaine',0,'',$conf->entity); if (! $res > 0) $error++; } + if (GETPOST("PRELEVEMENT_END_TO_END") || GETPOST("PRELEVEMENT_END_TO_END")=="") + { + $res = dolibarr_set_const($db, "END_TO_END", GETPOST("PRELEVEMENT_END_TO_END"),'chaine',0,'',$conf->entity); + if (! $res > 0) $error++; + } + if (GETPOST("PRELEVEMENT_USTRD") || GETPOST("PRELEVEMENT_USTRD")=="") + { + $res = dolibarr_set_const($db, "USTRD", GETPOST("PRELEVEMENT_USTRD"),'chaine',0,'',$conf->entity); + if (! $res > 0) $error++; + } if (! $error) { @@ -221,6 +231,18 @@ print $form->select_dolusers($conf->global->PRELEVEMENT_USER, 'PRELEVEMENT_USER' print ''; print ''; +//EntToEnd +print ''.$langs->trans("END_TO_END").''; +print ''; +print ''; +print ''; + +//USTRD +print ''.$langs->trans("USTRD").''; +print ''; +print ''; +print ''; + print ''; print '
'; diff --git a/htdocs/admin/resource_extrafields.php b/htdocs/admin/resource_extrafields.php index 8193d146aaa..722e5d88a9c 100644 --- a/htdocs/admin/resource_extrafields.php +++ b/htdocs/admin/resource_extrafields.php @@ -84,7 +84,7 @@ dol_fiche_end(); if ($action != 'create' && $action != 'edit') { print '"; } @@ -97,7 +97,7 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { - print "
"; + print '
'; print load_fiche_titre($langs->trans('NewAttribute')); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; diff --git a/htdocs/admin/supplierinvoice_extrafields.php b/htdocs/admin/supplierinvoice_extrafields.php index 7e913772e2c..16da8bf7a5c 100644 --- a/htdocs/admin/supplierinvoice_extrafields.php +++ b/htdocs/admin/supplierinvoice_extrafields.php @@ -91,7 +91,7 @@ dol_fiche_end(); if ($action != 'create' && $action != 'edit') { print '"; } @@ -104,7 +104,7 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { - print "
"; + print '
'; print load_fiche_titre($langs->trans('NewAttribute')); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; diff --git a/htdocs/admin/supplierinvoicedet_extrafields.php b/htdocs/admin/supplierinvoicedet_extrafields.php index d8156d54779..4ca9fd516d7 100644 --- a/htdocs/admin/supplierinvoicedet_extrafields.php +++ b/htdocs/admin/supplierinvoicedet_extrafields.php @@ -87,7 +87,7 @@ dol_fiche_end(); if ($action != 'create' && $action != 'edit') { print '"; } @@ -100,7 +100,7 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { - print "
"; + print '
'; print load_fiche_titre($langs->trans('NewAttribute')); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; diff --git a/htdocs/admin/supplierorder_extrafields.php b/htdocs/admin/supplierorder_extrafields.php index 30cf4d983e4..58c0408510d 100644 --- a/htdocs/admin/supplierorder_extrafields.php +++ b/htdocs/admin/supplierorder_extrafields.php @@ -85,7 +85,7 @@ dol_fiche_end(); if ($action != 'create' && $action != 'edit') { print '"; } @@ -98,7 +98,7 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { - print "
"; + print '
'; print load_fiche_titre($langs->trans('NewAttribute')); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; diff --git a/htdocs/admin/supplierorderdet_extrafields.php b/htdocs/admin/supplierorderdet_extrafields.php index 85106bf84f0..7dfaa02545e 100644 --- a/htdocs/admin/supplierorderdet_extrafields.php +++ b/htdocs/admin/supplierorderdet_extrafields.php @@ -86,7 +86,7 @@ dol_fiche_end(); if ($action != 'create' && $action != 'edit') { print '"; } @@ -99,7 +99,7 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { - print "
"; + print '
'; print load_fiche_titre($langs->trans('NewAttribute')); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; diff --git a/htdocs/admin/workflow.php b/htdocs/admin/workflow.php index da87cfd32c9..b5bdec73f3e 100644 --- a/htdocs/admin/workflow.php +++ b/htdocs/admin/workflow.php @@ -39,7 +39,7 @@ $action = GETPOST('action', 'alpha'); */ if (preg_match('/set(.*)/',$action,$reg)) { - if (! dolibarr_set_const($db, $reg[1], 1, 'chaine', 0, '', $conf->entity) > 0) + if (! dolibarr_set_const($db, $reg[1], '1', 'chaine', 0, '', $conf->entity) > 0) { dol_print_error($db); } @@ -75,14 +75,12 @@ $workflowcodes=array( 'WORKFLOW_PROPAL_AUTOCREATE_ORDER'=>array('family'=>'create', 'position'=>10, 'enabled'=>'! empty($conf->propal->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'order'), 'WORKFLOW_ORDER_AUTOCREATE_INVOICE'=>array('family'=>'create', 'position'=>20, 'enabled'=>'! empty($conf->commande->enabled) && ! empty($conf->facture->enabled)', 'picto'=>'bill'), 'separator1'=>array('family'=>'separator', 'position'=>25), - // Automatic classification proposal + // Automatic classification of proposal 'WORKFLOW_ORDER_CLASSIFY_BILLED_PROPAL'=>array('family'=>'classify_proposal', 'position'=>30, 'enabled'=>'! empty($conf->propal->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'propal','warning'=>''), 'WORKFLOW_INVOICE_CLASSIFY_BILLED_PROPAL'=>array('family'=>'classify_proposal', 'position'=>31, 'enabled'=>'! empty($conf->propal->enabled) && ! empty($conf->facture->enabled)', 'picto'=>'propal','warning'=>''), - // Automatic classification invoice + // Automatic classification of order 'WORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING'=>array('family'=>'classify_order', 'position'=>40, 'enabled'=>'! empty($conf->expedition->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'order'), - // For the following 2 options, if module invoice is disabled, they does not exists, so "Classify billed" for order must be done manually from order card. - 'WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER'=>array('family'=>'classify_order', 'position'=>41, 'enabled'=>'! empty($conf->facture->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'order','warning'=>''), - //Moved as hidden feature: 'WORKFLOW_INVOICE_CLASSIFY_BILLED_ORDER'=>array('family'=>'classify_order', 'position'=>42, 'enabled'=>'! empty($conf->facture->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'order','warning'=>''), + 'WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER'=>array('family'=>'classify_order', 'position'=>41, 'enabled'=>'! empty($conf->facture->enabled) && ! empty($conf->commande->enabled)', 'picto'=>'order','warning'=>''), // For this option, if module invoice is disabled, it does not exists, so "Classify billed" for order must be done manually from order card. 'separator2'=>array('family'=>'separator', 'position'=>50), // Automatic classification supplier proposal 'WORKFLOW_ORDER_CLASSIFY_BILLED_SUPPLIER_PROPOSAL'=>array('family'=>'classify_supplier_proposal', 'position'=>60, 'enabled'=>'! empty($conf->supplier_proposal->enabled) && ! empty($conf->fournisseur->enabled)', 'picto'=>'propal','warning'=>''), diff --git a/htdocs/asset/card.php b/htdocs/asset/card.php index a34169ea0ac..1cb580c8c8d 100644 --- a/htdocs/asset/card.php +++ b/htdocs/asset/card.php @@ -218,13 +218,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if ($action == 'xxx') { $formquestion=array(); - /* - $formquestion = array( - // 'text' => $langs->trans("ConfirmClone"), - // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), - // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), - // array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1))); - }*/ $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220); } diff --git a/htdocs/categories/admin/categorie_extrafields.php b/htdocs/categories/admin/categorie_extrafields.php index 3fd7d1c69b5..3fbd29a640b 100644 --- a/htdocs/categories/admin/categorie_extrafields.php +++ b/htdocs/categories/admin/categorie_extrafields.php @@ -79,7 +79,7 @@ dol_fiche_end(); if ($action != 'create' && $action != 'edit') { print '"; } @@ -92,7 +92,7 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { - print "
"; + print '
'; print load_fiche_titre($langs->trans('NewAttribute')); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; diff --git a/htdocs/comm/admin/propaldet_extrafields.php b/htdocs/comm/admin/propaldet_extrafields.php index 49784228fe6..0816a4c035c 100644 --- a/htdocs/comm/admin/propaldet_extrafields.php +++ b/htdocs/comm/admin/propaldet_extrafields.php @@ -86,7 +86,7 @@ dol_fiche_end(); if ($action != 'create' && $action != 'edit') { print '"; } @@ -99,7 +99,7 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { - print "
"; + print '
'; print load_fiche_titre($langs->trans('NewAttribute')); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 817115d93af..dfde7ce613f 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -108,9 +108,21 @@ if ($id > 0 || ! empty($ref)) { // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('propalcard','globalcard')); -$permissionnote = $user->rights->propale->creer; // Used by the include of actions_setnotes.inc.php -$permissiondellink=$user->rights->propale->creer; // Used by the include of actions_dellink.inc.php -$permissiontoedit = $user->rights->propale->creer; // Used by the include of actions_lineupdown.inc.php +$usercanread = $user->rights->propal->lire; +$usercancreate = $user->rights->propal->creer; +$usercanclose = $user->rights->propal->cloturer; +$usercandelete = $user->rights->propal->supprimer; +$usercanvalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->propal->propal_advance->validate))); +$usercansend = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->propal->propal_advance->send); + +$usercancreateorder = $user->rights->commande->creer; +$usercancreateinvoice = $user->rights->facture->creer; +$usercancreatecontract = $user->rights->contrat->creer; +$usercancreateintervention = $user->rights->ficheinter->creer; + +$permissionnote = $usercancreate; // Used by the include of actions_setnotes.inc.php +$permissiondellink = $usercancreate; // Used by the include of actions_dellink.inc.php +$permissiontoedit = $usercancreate; // Used by the include of actions_lineupdown.inc.php /* @@ -140,7 +152,7 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once // Action clone object - if ($action == 'confirm_clone' && $confirm == 'yes') + if ($action == 'confirm_clone' && $confirm == 'yes' && $usercancreate) { if (! GETPOST('socid', 3)) { @@ -191,7 +203,7 @@ if (empty($reshook)) } // Delete proposal - else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->propal->supprimer) + else if ($action == 'confirm_delete' && $confirm == 'yes' && $usercandelete) { $result = $object->delete($user); if ($result > 0) { @@ -204,7 +216,7 @@ if (empty($reshook)) } // Remove line - else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->propal->creer) + else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $usercancreate) { $result = $object->deleteline($lineid); // reorder lines @@ -228,10 +240,7 @@ if (empty($reshook)) } // Validation - else if ($action == 'confirm_validate' && $confirm == 'yes' && - ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->propal->creer)) - || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->propal->propal_advance->validate))) - ) + else if ($action == 'confirm_validate' && $confirm == 'yes' && $usercanvalidate) { $result = $object->valid($user); if ($result >= 0) @@ -258,7 +267,7 @@ if (empty($reshook)) } } - else if ($action == 'setdate' && $user->rights->propal->creer) + else if ($action == 'setdate' && $usercancreate) { $datep = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); @@ -273,13 +282,13 @@ if (empty($reshook)) dol_print_error($db, $object->error); } } - else if ($action == 'setecheance' && $user->rights->propal->creer) + else if ($action == 'setecheance' && $usercancreate) { $result = $object->set_echeance($user, dol_mktime(12, 0, 0, $_POST['echmonth'], $_POST['echday'], $_POST['echyear'])); if ($result < 0) dol_print_error($db, $object->error); } - else if ($action == 'setdate_livraison' && $user->rights->propal->creer) + else if ($action == 'setdate_livraison' && $usercancreate) { $result = $object->set_date_livraison($user, dol_mktime(12, 0, 0, $_POST['date_livraisonmonth'], $_POST['date_livraisonday'], $_POST['date_livraisonyear'])); if ($result < 0) @@ -287,7 +296,7 @@ if (empty($reshook)) } // Positionne ref client - else if ($action == 'setref_client' && $user->rights->propal->creer) + else if ($action == 'setref_client' && $usercancreate) { $result = $object->set_ref_client($user, GETPOST('ref_client')); if ($result < 0) @@ -297,13 +306,13 @@ if (empty($reshook)) } // Set incoterm - elseif ($action == 'set_incoterms' && !empty($conf->incoterm->enabled)) + elseif ($action == 'set_incoterms' && !empty($conf->incoterm->enabled) && $usercancreate) { $result = $object->setIncoterms(GETPOST('incoterm_id', 'int'), GETPOST('location_incoterms', 'alpha')); } // Create proposal - else if ($action == 'add' && $user->rights->propal->creer) + else if ($action == 'add' && $usercancreate) { $object->socid = $socid; $object->fetch_thirdparty(); @@ -597,7 +606,7 @@ if (empty($reshook)) } // Classify billed - else if ($action == 'classifybilled' && $user->rights->propal->cloturer) + else if ($action == 'classifybilled' && $usercanclose) { $result=$object->cloture($user, 4, ''); if ($result < 0) @@ -608,7 +617,7 @@ if (empty($reshook)) } // Close proposal - else if ($action == 'setstatut' && $user->rights->propal->cloturer && ! GETPOST('cancel','alpha')) + else if ($action == 'setstatut' && $usercanclose && ! GETPOST('cancel','alpha')) { if (! (GETPOST('statut','int') > 0)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CloseAs")), null, 'errors'); @@ -628,7 +637,7 @@ if (empty($reshook)) } // Reopen proposal - else if ($action == 'confirm_reopen' && $user->rights->propal->cloturer && ! GETPOST('cancel','alpha')) + else if ($action == 'confirm_reopen' && $usercanclose && ! GETPOST('cancel','alpha')) { // prevent browser refresh from reopening proposal several times if ($object->statut == Propal::STATUS_SIGNED || $object->statut == Propal::STATUS_NOTSIGNED || $object->statut == Propal::STATUS_BILLED) @@ -653,7 +662,7 @@ if (empty($reshook)) // Go back to draft - if ($action == 'modif' && $user->rights->propal->creer) + if ($action == 'modif' && $usercancreate) { $object->set_draft($user); @@ -671,7 +680,7 @@ if (empty($reshook)) } } - else if ($action == "setabsolutediscount" && $user->rights->propal->creer) { + else if ($action == "setabsolutediscount" && $usercancreate) { if ($_POST["remise_id"]) { if ($object->id > 0) { $result = $object->insert_discount($_POST["remise_id"]); @@ -683,7 +692,7 @@ if (empty($reshook)) } // Add line - else if ($action == 'addline' && $user->rights->propal->creer) { + else if ($action == 'addline' && $usercancreate) { // Set if we used free entry or predefined product $predef=''; @@ -1046,7 +1055,7 @@ if (empty($reshook)) } // Update a line within proposal - else if ($action == 'updateligne' && $user->rights->propal->creer && GETPOST('save')) + else if ($action == 'updateligne' && $usercancreate && GETPOST('save')) { // Define info_bits $info_bits = 0; @@ -1183,62 +1192,62 @@ if (empty($reshook)) } } - else if ($action == 'updateligne' && $user->rights->propal->creer && GETPOST('cancel','alpha')) + else if ($action == 'updateligne' && $usercancreate && GETPOST('cancel','alpha')) { header('Location: ' . $_SERVER['PHP_SELF'] . '?id=' . $object->id); // Pour reaffichage de la fiche en cours d'edition exit(); } // Set project - else if ($action == 'classin' && $user->rights->propal->creer) { + else if ($action == 'classin' && $usercancreate) { $object->setProject(GETPOST('projectid','int')); } // Delai de livraison - else if ($action == 'setavailability' && $user->rights->propal->creer) { + else if ($action == 'setavailability' && $usercancreate) { $result = $object->set_availability($user, GETPOST('availability_id','int')); } // Origine de la propale - else if ($action == 'setdemandreason' && $user->rights->propal->creer) { + else if ($action == 'setdemandreason' && $usercancreate) { $result = $object->set_demand_reason($user, GETPOST('demand_reason_id','int')); } // Conditions de reglement - else if ($action == 'setconditions' && $user->rights->propal->creer) { + else if ($action == 'setconditions' && $usercancreate) { $result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int')); } - else if ($action == 'setremisepercent' && $user->rights->propal->creer) { + else if ($action == 'setremisepercent' && $usercancreate) { $result = $object->set_remise_percent($user, $_POST['remise_percent']); } - else if ($action == 'setremiseabsolue' && $user->rights->propal->creer) { + else if ($action == 'setremiseabsolue' && $usercancreate) { $result = $object->set_remise_absolue($user, $_POST['remise_absolue']); } // Mode de reglement - else if ($action == 'setmode' && $user->rights->propal->creer) { + else if ($action == 'setmode' && $usercancreate) { $result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int')); } // Multicurrency Code - else if ($action == 'setmulticurrencycode' && $user->rights->propal->creer) { + else if ($action == 'setmulticurrencycode' && $usercancreate) { $result = $object->setMulticurrencyCode(GETPOST('multicurrency_code', 'alpha')); } // Multicurrency rate - else if ($action == 'setmulticurrencyrate' && $user->rights->propal->creer) { + else if ($action == 'setmulticurrencyrate' && $usercancreate) { $result = $object->setMulticurrencyRate(price2num(GETPOST('multicurrency_tx'))); } // bank account - else if ($action == 'setbankaccount' && $user->rights->propal->creer) { + else if ($action == 'setbankaccount' && $usercancreate) { $result=$object->setBankAccount(GETPOST('fk_account', 'int')); } // shipping method - else if ($action == 'setshippingmethod' && $user->rights->propal->creer) { + else if ($action == 'setshippingmethod' && $usercancreate) { $result=$object->setShippingMethod(GETPOST('shipping_method_id', 'int')); } @@ -1261,7 +1270,7 @@ if (empty($reshook)) if ($error) $action = 'edit_extras'; } - if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->propal->creer) + if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $usercancreate) { if ($action == 'addcontact') { @@ -1308,7 +1317,7 @@ if (empty($reshook)) // Actions to build doc $upload_dir = $conf->propal->multidir_output[$object->entity]; - $permissioncreate=$user->rights->propal->creer; + $permissioncreate=$usercancreate; include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; } @@ -1837,8 +1846,8 @@ if ($action == 'create') $morehtmlref='
'; // Ref customer - $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->propal->creer, 'string', '', 0, 1); - $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->propal->creer, 'string', '', null, null, '', 1); + $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $usercancreate, 'string', '', 0, 1); + $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $usercancreate, 'string', '', null, null, '', 1); // Thirdparty $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1,'customer'); if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref.=' ('.$langs->trans("OtherProposals").')'; @@ -1847,7 +1856,7 @@ if ($action == 'create') { $langs->load("projects"); $morehtmlref.='
'.$langs->trans('Project') . ' '; - if ($user->rights->propal->creer) + if ($usercancreate) { if ($action != 'classify') $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; @@ -1915,11 +1924,11 @@ if ($action == 'create') print ''; - if ($action != 'editdate' && ! empty($object->brouillon)) + if ($action != 'editdate' && ! empty($object->brouillon) && $usercancreate) print ''; print '
'; print $langs->trans('Date'); print 'id . '">' . img_edit($langs->trans('SetDate'), 1) . '
'; print ''; - if (! empty($object->brouillon) && $action == 'editdate') { + if (! empty($object->brouillon) && $action == 'editdate' && $usercancreate) { print '
'; print ''; print ''; @@ -1941,11 +1950,11 @@ if ($action == 'create') print ''; - if ($action != 'editecheance' && ! empty($object->brouillon)) + if ($action != 'editecheance' && ! empty($object->brouillon) && $usercancreate) print ''; print '
'; print $langs->trans('DateEndPropal'); print 'id . '">' . img_edit($langs->trans('SetConditions'), 1) . '
'; print ''; - if (! empty($object->brouillon) && $action == 'editecheance') { + if (! empty($object->brouillon) && $action == 'editecheance' && $usercancreate) { print ''; print ''; print ''; @@ -1969,11 +1978,11 @@ if ($action == 'create') print ''; - if ($action != 'editconditions' && ! empty($object->brouillon)) + if ($action != 'editconditions' && ! empty($object->brouillon) && $usercancreate) print ''; print '
'; print $langs->trans('PaymentConditionsShort'); print 'id . '">' . img_edit($langs->transnoentitiesnoconv('SetConditions'), 1) . '
'; print ''; - if ($action == 'editconditions') { + if (! empty($object->brouillon) && $action == 'editconditions' && $usercancreate) { $form->form_conditions_reglement($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->cond_reglement_id, 'cond_reglement_id'); } else { $form->form_conditions_reglement($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->cond_reglement_id, 'none'); @@ -1984,9 +1993,9 @@ if ($action == 'create') // Delivery date $langs->load('deliveries'); print ''; - print $form->editfieldkey($langs->trans('DeliveryDate'), 'date_livraison', $object->date_livraison, $object, $user->rights->propal->creer, 'datepicker'); + print $form->editfieldkey($langs->trans('DeliveryDate'), 'date_livraison', $object->date_livraison, $object, $usercancreate, 'datepicker'); print ''; - print $form->editfieldval($langs->trans('DeliveryDate'), 'date_livraison', $object->date_livraison, $object, $user->rights->propal->creer, 'datepicker'); + print $form->editfieldval($langs->trans('DeliveryDate'), 'date_livraison', $object->date_livraison, $object, $usercancreate, 'datepicker'); print ''; print ''; @@ -1997,11 +2006,11 @@ if ($action == 'create') if (! empty($conf->commande->enabled)) print ' (' . $langs->trans('AfterOrder') . ')'; print ''; - if ($action != 'editavailability' && ! empty($object->brouillon)) + if ($action != 'editavailability' && ! empty($object->brouillon) && $usercancreate) print 'id . '">' . img_edit($langs->transnoentitiesnoconv('SetAvailability'), 1) . ''; print ''; print ''; - if ($action == 'editavailability') { + if (! empty($object->brouillon) && $action == 'editavailability' && $usercancreate) { $form->form_availability($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->availability_id, 'availability_id', 1); } else { $form->form_availability($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->availability_id, 'none', 1); @@ -2016,11 +2025,11 @@ if ($action == 'create') print ''; - if ($action != 'editshippingmethod' && $user->rights->propal->creer) + if ($action != 'editshippingmethod' && $usercancreate) print ''; print '
'; print $langs->trans('SendingMethod'); print 'id.'">'.img_edit($langs->trans('SetShippingMode'),1).'
'; print ''; - if ($action == 'editshippingmethod') { + if ($action == 'editshippingmethod' && $usercancreate) { $form->formSelectShippingMethod($_SERVER['PHP_SELF'].'?id='.$object->id, $object->shipping_method_id, 'shipping_method_id', 1); } else { $form->formSelectShippingMethod($_SERVER['PHP_SELF'].'?id='.$object->id, $object->shipping_method_id, 'none'); @@ -2034,11 +2043,11 @@ if ($action == 'create') print ''; - if ($action != 'editdemandreason' && ! empty($object->brouillon)) + if ($action != 'editdemandreason' && ! empty($object->brouillon) && $usercancreate) print ''; print '
'; print $langs->trans('Source'); print 'id . '">' . img_edit($langs->transnoentitiesnoconv('SetDemandReason'), 1) . '
'; print ''; - if ($action == 'editdemandreason') { + if (! empty($object->brouillon) && $action == 'editdemandreason' && $usercancreate) { $form->formInputReason($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->demand_reason_id, 'demand_reason_id', 1); } else { $form->formInputReason($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->demand_reason_id, 'none'); @@ -2052,11 +2061,11 @@ if ($action == 'create') print ''; - if ($action != 'editmode' && ! empty($object->brouillon)) + if ($action != 'editmode' && ! empty($object->brouillon) && $usercancreate) print ''; print '
'; print $langs->trans('PaymentMode'); print 'id . '">' . img_edit($langs->transnoentitiesnoconv('SetMode'), 1) . '
'; print ''; - if ($action == 'editmode') { + if (! empty($object->brouillon) && $action == 'editmode' && $usercancreate) { $form->form_modes_reglement($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->mode_reglement_id, 'mode_reglement_id'); } else { $form->form_modes_reglement($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->mode_reglement_id, 'none'); @@ -2072,11 +2081,11 @@ if ($action == 'create') print ''; - if ($action != 'editmulticurrencycode' && ! empty($object->brouillon)) + if ($action != 'editmulticurrencycode' && ! empty($object->brouillon) && $usercancreate) print ''; print '
'; print fieldLabel('Currency','multicurrency_code'); print 'id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . '
'; print ''; - if ($action == 'editmulticurrencycode') { + if (! empty($object->brouillon) && $action == 'editmulticurrencycode' && $usercancreate) { $form->form_multicurrency_code($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_code, 'multicurrency_code'); } else { $form->form_multicurrency_code($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_code, 'none'); @@ -2089,11 +2098,11 @@ if ($action == 'create') print ''; - if ($action != 'editmulticurrencyrate' && ! empty($object->brouillon) && $object->multicurrency_code && $object->multicurrency_code != $conf->currency) + if ($action != 'editmulticurrencyrate' && ! empty($object->brouillon) && $object->multicurrency_code && $object->multicurrency_code != $conf->currency && $usercancreate) print ''; print '
'; print fieldLabel('CurrencyRate','multicurrency_tx'); print 'id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . '
'; print ''; - if ($action == 'editmulticurrencyrate' || $action == 'actualizemulticurrencyrate') { + if (! empty($object->brouillon) && ($action == 'editmulticurrencyrate' || $action == 'actualizemulticurrencyrate') && $usercancreate) { if($action == 'actualizemulticurrencyrate') { list($object->fk_multicurrency, $object->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($object->db, $object->multicurrency_code); } @@ -2128,7 +2137,7 @@ if ($action == 'create') print ''; - if ($action != 'editbankaccount' && $user->rights->propal->creer) + if ($action != 'editbankaccount' && $usercancreate) print ''; print '
'; print $langs->trans('BankAccount'); print 'id.'">'.img_edit($langs->trans('SetBankAccount'),1).'
'; print ''; @@ -2164,7 +2173,7 @@ if ($action == 'create') print '
'; print $langs->trans('IncotermLabel'); print ''; - if ($user->rights->propal->creer) print ''.img_edit().''; + if ($usercancreate) print ''.img_edit().''; else print ' '; print '
'; print ''; @@ -2293,7 +2302,7 @@ if ($action == 'create') $ret = $object->printObjectLines($action, $mysoc, $soc, $lineid, 1); // Form to add new line - if ($object->statut == Propal::STATUS_DRAFT && $user->rights->propal->creer && $action != 'selectlines') + if ($object->statut == Propal::STATUS_DRAFT && $usercancreate && $action != 'selectlines') { if ($action != 'editline') { @@ -2328,8 +2337,7 @@ if ($action == 'create') // Validate if ($object->statut == Propal::STATUS_DRAFT && $object->total_ttc >= 0 && count($object->lines) > 0) { - if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->propal->creer)) - || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->propal->propal_advance->validate))) + if ($usercanvalidate) { print ''; } @@ -2342,19 +2350,19 @@ if ($action == 'create') print ''; }*/ // Edit - if ($object->statut == Propal::STATUS_VALIDATED && $user->rights->propal->creer) { + if ($object->statut == Propal::STATUS_VALIDATED && $usercancreate) { print ''; } // ReOpen - if (($object->statut == Propal::STATUS_SIGNED || $object->statut == Propal::STATUS_NOTSIGNED || $object->statut == Propal::STATUS_BILLED) && $user->rights->propal->cloturer) { + if (($object->statut == Propal::STATUS_SIGNED || $object->statut == Propal::STATUS_NOTSIGNED || $object->statut == Propal::STATUS_BILLED) && $usercanclose) { print ''; } // Send if ($object->statut == Propal::STATUS_VALIDATED || $object->statut == Propal::STATUS_SIGNED) { - if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->propal->propal_advance->send) { + if ($usercansend) { print ''; } else print ''; @@ -2362,14 +2370,14 @@ if ($action == 'create') // Create an order if (! empty($conf->commande->enabled) && $object->statut == Propal::STATUS_SIGNED) { - if ($user->rights->commande->creer) { + if ($usercancreateorder) { print ''; } } // Create an intervention if (! empty($conf->service->enabled) && ! empty($conf->ficheinter->enabled) && $object->statut == Propal::STATUS_SIGNED) { - if ($user->rights->ficheinter->creer) { + if ($usercancreateintervention) { $langs->load("interventions"); print ''; } @@ -2379,7 +2387,7 @@ if ($action == 'create') if ($conf->contrat->enabled && $object->statut == Propal::STATUS_SIGNED) { $langs->load("contracts"); - if ($user->rights->contrat->creer) { + if ($usercancreatecontract) { print ''; } } @@ -2387,7 +2395,7 @@ if ($action == 'create') // Create an invoice and classify billed if ($object->statut == Propal::STATUS_SIGNED) { - if (! empty($conf->facture->enabled) && $user->rights->facture->creer) + if (! empty($conf->facture->enabled) && $usercancreateinvoice) { print ''; } @@ -2400,18 +2408,18 @@ if ($action == 'create') } // Set accepted/refused - if ($object->statut == Propal::STATUS_VALIDATED && $user->rights->propal->cloturer) { + if ($object->statut == Propal::STATUS_VALIDATED && $usercanclose) { print ''; } // Clone - if ($user->rights->propal->creer) { + if ($usercancreate) { print ''; } // Delete - if ($user->rights->propal->supprimer) { + if ($usercandelete) { print ''; } @@ -2434,8 +2442,8 @@ if ($action == 'create') $filename = dol_sanitizeFileName($object->ref); $filedir = $conf->propal->multidir_output[$object->entity] . "/" . dol_sanitizeFileName($object->ref); $urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id; - $genallowed = $user->rights->propal->lire; - $delallowed = $user->rights->propal->creer; + $genallowed = $usercanread; + $delallowed = $usercancreate; print $formfile->showdocuments('propal', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', 0, '', $soc->default_lang, '', $object); diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 703ed95a1b2..562032de9fa 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1328,15 +1328,19 @@ class Propal extends CommonObject $sql.= ", dr.code as demand_reason_code, dr.label as demand_reason"; $sql.= ", cr.code as cond_reglement_code, cr.libelle as cond_reglement, cr.libelle_facture as cond_reglement_libelle_doc"; $sql.= ", cp.code as mode_reglement_code, cp.libelle as mode_reglement"; - $sql.= " FROM ".MAIN_DB_PREFIX."c_propalst as c, ".MAIN_DB_PREFIX."propal as p"; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as cp ON p.fk_mode_reglement = cp.id'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as cr ON p.fk_cond_reglement = cr.rowid'; + $sql.= " FROM ".MAIN_DB_PREFIX."propal as p"; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_propalst as c ON p.fk_statut = c.id'; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as cp ON p.fk_mode_reglement = cp.id AND cp.entity IN ('.getEntity('c_paiement').')'; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as cr ON p.fk_cond_reglement = cr.rowid AND cr.entity IN ('.getEntity('c_payment_term').')'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_availability as ca ON p.fk_availability = ca.rowid'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_input_reason as dr ON p.fk_input_reason = dr.rowid'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON p.fk_incoterms = i.rowid'; $sql.= " WHERE p.fk_statut = c.id"; - $sql.= " AND p.entity IN (".getEntity('propal').")"; - if ($ref) $sql.= " AND p.ref='".$ref."'"; + + if ($ref) { + $sql.= " AND p.entity IN (".getEntity('propal').")"; // Dont't use entity if you use rowid + $sql.= " AND p.ref='".$ref."'"; + } else $sql.= " AND p.rowid=".$rowid; dol_syslog(get_class($this)."::fetch", LOG_DEBUG); @@ -3347,12 +3351,19 @@ class Propal extends CommonObject global $conf,$langs; $langs->load("propal"); - if (! empty($conf->global->PROPALE_ADDON)) + $constant = 'PROPALE_ADDON_'.$this->entity; + + if (! empty($conf->global->$constant)) { + $classname = $conf->global->$constant; // for multicompany proposal sharing + } else { + $classname = $conf->global->PROPALE_ADDON; + } + + if (! empty($classname)) { $mybool=false; - $file = $conf->global->PROPALE_ADDON.".php"; - $classname = $conf->global->PROPALE_ADDON; + $file = $classname.".php"; // Include file with class $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index b0cea3318cb..0fe49cf9f12 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1858,13 +1858,14 @@ if ($action == 'create' && $user->rights->commande->creer) $langs->load("stocks"); require_once DOL_DOCUMENT_ROOT . '/product/class/html.formproduct.class.php'; $formproduct = new FormProduct($db); + $forcecombo=0; + if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy $formquestion = array( - // 'text' => $langs->trans("ConfirmClone"), - // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' - // => 1), - // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), - // 'value' => 1), - array('type' => 'other','name' => 'idwarehouse','label' => $langs->trans("SelectWarehouseForStockDecrease"),'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1))); + // 'text' => $langs->trans("ConfirmClone"), + // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), + // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), + array('type' => 'other','name' => 'idwarehouse','label' => $langs->trans("SelectWarehouseForStockDecrease"),'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse','int')?GETPOST('idwarehouse','int'):'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo)) + ); } $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('ValidateOrder'), $text, 'confirm_validate', $formquestion, 0, 1, 220); @@ -1890,13 +1891,14 @@ if ($action == 'create' && $user->rights->commande->creer) $langs->load("stocks"); require_once DOL_DOCUMENT_ROOT . '/product/class/html.formproduct.class.php'; $formproduct = new FormProduct($db); + $forcecombo=0; + if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy $formquestion = array( - // 'text' => $langs->trans("ConfirmClone"), - // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' - // => 1), - // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), - // 'value' => 1), - array('type' => 'other','name' => 'idwarehouse','label' => $langs->trans("SelectWarehouseForStockIncrease"),'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1))); + // 'text' => $langs->trans("ConfirmClone"), + // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), + // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), + array('type' => 'other','name' => 'idwarehouse','label' => $langs->trans("SelectWarehouseForStockIncrease"),'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo)) + ); } $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('UnvalidateOrder'), $text, 'confirm_modif', $formquestion, "yes", 1, 220); @@ -1931,13 +1933,14 @@ if ($action == 'create' && $user->rights->commande->creer) $langs->load("stocks"); require_once DOL_DOCUMENT_ROOT . '/product/class/html.formproduct.class.php'; $formproduct = new FormProduct($db); + $forcecombo=0; + if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy $formquestion = array( - // 'text' => $langs->trans("ConfirmClone"), - // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' - // => 1), - // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), - // 'value' => 1), - array('type' => 'other','name' => 'idwarehouse','label' => $langs->trans("SelectWarehouseForStockIncrease"),'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1))); + // 'text' => $langs->trans("ConfirmClone"), + // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), + // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), + array('type' => 'other','name' => 'idwarehouse','label' => $langs->trans("SelectWarehouseForStockIncrease"),'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1, 0, 0, '', 0, $forcecombo)) + ); } $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('Cancel'), $text, 'confirm_cancel', $formquestion, 0, 1); diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index a9970a95a51..17e4387c4de 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1591,8 +1591,10 @@ class Commande extends CommonOrder $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_availability as ca ON c.fk_availability = ca.rowid'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_input_reason as dr ON c.fk_input_reason = ca.rowid'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON c.fk_incoterms = i.rowid'; - $sql.= " WHERE c.entity IN (".getEntity('commande').")"; - if ($id) $sql.= " AND c.rowid=".$id; + + if ($id) $sql.= " WHERE c.rowid=".$id; + else $sql.= " WHERE c.entity IN (".getEntity('commande').")"; // Dont't use entity if you use rowid + if ($ref) $sql.= " AND c.ref='".$this->db->escape($ref)."'"; if ($ref_ext) $sql.= " AND c.ref_ext='".$this->db->escape($ref_ext)."'"; if ($ref_int) $sql.= " AND c.ref_int='".$this->db->escape($ref_int)."'"; diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index a63847421eb..2b86ad2f18a 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -509,7 +509,7 @@ if ($resql) { print $form->selectyesno('valdate_invoices', 0, 1); } - if (! empty($conf->global->WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER)) print '     '.$langs->trans("IfValidateInvoiceIsNoOrderStayUnbilled").''; + if (! empty($conf->workflow->enabled) && ! empty($conf->global->WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER)) print '     '.$langs->trans("IfValidateInvoiceIsNoOrderStayUnbilled").''; else print '     '.$langs->trans("OptionToSetOrderBilledNotEnabled").''; print ''; print ''; diff --git a/htdocs/compta/facture/admin/facture_cust_extrafields.php b/htdocs/compta/facture/admin/facture_cust_extrafields.php index 2c676e399de..4e44774e0c4 100644 --- a/htdocs/compta/facture/admin/facture_cust_extrafields.php +++ b/htdocs/compta/facture/admin/facture_cust_extrafields.php @@ -80,7 +80,7 @@ dol_fiche_end(); if ($action != 'create' && $action != 'edit') { print '"; } @@ -93,7 +93,7 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { - print "
"; + print '
'; print load_fiche_titre($langs->trans('NewAttribute')); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; diff --git a/htdocs/compta/facture/admin/facture_rec_cust_extrafields.php b/htdocs/compta/facture/admin/facture_rec_cust_extrafields.php index 18aa3c99442..54d3da8e18a 100644 --- a/htdocs/compta/facture/admin/facture_rec_cust_extrafields.php +++ b/htdocs/compta/facture/admin/facture_rec_cust_extrafields.php @@ -81,7 +81,7 @@ dol_fiche_end(); if ($action != 'create' && $action != 'edit') { print '"; } @@ -94,7 +94,7 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { - print "
"; + print '
'; print load_fiche_titre($langs->trans('NewAttribute')); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; diff --git a/htdocs/compta/facture/admin/facturedet_cust_extrafields.php b/htdocs/compta/facture/admin/facturedet_cust_extrafields.php index 2b90ae7fe05..c2490da4f42 100644 --- a/htdocs/compta/facture/admin/facturedet_cust_extrafields.php +++ b/htdocs/compta/facture/admin/facturedet_cust_extrafields.php @@ -81,7 +81,7 @@ dol_fiche_end(); if ($action != 'create' && $action != 'edit') { print '"; } @@ -94,7 +94,7 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { - print "
"; + print '
'; print load_fiche_titre($langs->trans('NewAttribute')); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; diff --git a/htdocs/compta/facture/admin/facturedet_rec_cust_extrafields.php b/htdocs/compta/facture/admin/facturedet_rec_cust_extrafields.php index 97f8b78b195..28c70ea9024 100644 --- a/htdocs/compta/facture/admin/facturedet_rec_cust_extrafields.php +++ b/htdocs/compta/facture/admin/facturedet_rec_cust_extrafields.php @@ -81,7 +81,7 @@ dol_fiche_end(); if ($action != 'create' && $action != 'edit') { print '"; } @@ -94,7 +94,7 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { - print "
"; + print '
'; print load_fiche_titre($langs->trans('NewAttribute')); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 68a24a20933..457f03c6afc 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -3200,7 +3200,7 @@ if ($action == 'create') print ''; print ''; - switch ($classname) { + switch (get_class($objectsrc)) { case 'Propal': $newclassname = 'CommercialProposal'; break; @@ -3217,7 +3217,7 @@ if ($action == 'create') $newclassname = 'Intervention'; break; default: - $newclassname = $classname; + $newclassname = get_class($objectsrc); } print '' . $langs->trans($newclassname) . '' . $objectsrc->getNomUrl(1); @@ -3376,13 +3376,14 @@ else if ($id > 0 || ! empty($ref)) require_once DOL_DOCUMENT_ROOT . '/product/class/html.formproduct.class.php'; $formproduct = new FormProduct($db); $label = $object->type == Facture::TYPE_CREDIT_NOTE ? $langs->trans("SelectWarehouseForStockDecrease") : $langs->trans("SelectWarehouseForStockIncrease"); + $forcecombo=0; + if ($conf->browser->name == 'ie') $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy $formquestion = array( - // 'text' => $langs->trans("ConfirmClone"), - // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => - // 1), - // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' - // => 1), - array('type' => 'other','name' => 'idwarehouse','label' => $label,'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1, 0, 0, $langs->trans("NoStockAction")))); + // 'text' => $langs->trans("ConfirmClone"), + // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), + // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), + array('type' => 'other','name' => 'idwarehouse','label' => $label,'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1, 0, 0, $langs->trans("NoStockAction"), 0, $forcecombo)) + ); $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $langs->trans('DeleteBill'), $text, 'confirm_delete', $formquestion, "yes", 1); } else { $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'] . '?facid=' . $object->id, $langs->trans('DeleteBill'), $text, 'confirm_delete', '', 'no', 1); @@ -4632,7 +4633,7 @@ else if ($id > 0 || ! empty($ref)) if ($objectidnext) { print '
' . $langs->trans('DoPayment') . '
'; } else { - //if ($resteapayer == 0) { + //if ($resteapayer == 0) { // Sometimes we can receive more, so we accept to enter more and will offer a button to convert into discount (but it is not a credit note, just a prepayment done) // print '
' . $langs->trans('DoPayment') . '
'; //} else { print ''; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index b7d86cf630a..c6e43206c78 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1274,8 +1274,10 @@ class Facture extends CommonInvoice $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as c ON f.fk_cond_reglement = c.rowid'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON f.fk_mode_reglement = p.id'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON f.fk_incoterms = i.rowid'; - $sql.= ' WHERE f.entity IN ('.getEntity('facture').')'; - if ($rowid) $sql.= " AND f.rowid=".$rowid; + + if ($rowid) $sql.= " WHERE f.rowid=".$rowid; + else $sql.= ' WHERE f.entity IN ('.getEntity('facture').')'; // Dont't use entity if you use rowid + if ($ref) $sql.= " AND f.facnumber='".$this->db->escape($ref)."'"; if ($ref_ext) $sql.= " AND f.ref_ext='".$this->db->escape($ref_ext)."'"; if ($ref_int) $sql.= " AND f.ref_int='".$this->db->escape($ref_int)."'"; diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 245b25be3b6..a6b0ec84317 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -1575,7 +1575,8 @@ class BonPrelevement extends CommonObject $XML_DEBITOR =''; $XML_DEBITOR .=' '.$CrLf; $XML_DEBITOR .=' '.$CrLf; - $XML_DEBITOR .=' '.('AS-'.dol_trunc($row_facnumber,20).'-'.$Rowing).''.$CrLf; // ISO20022 states that EndToEndId has a MaxLength of 35 characters + // $XML_DEBITOR .=' '.('AS-'.dol_trunc($row_facnumber,20).'-'.$Rowing).''.$CrLf; // ISO20022 states that EndToEndId has a MaxLength of 35 characters + $XML_DEBITOR .=' '.(($conf->global->END_TO_END != "" ) ? $conf->global->END_TO_END : ('AS-'.dol_trunc($row_facnumber,20)).'-'.$Rowing).''.$CrLf; // ISO20022 states that EndToEndId has a MaxLength of 35 characters $XML_DEBITOR .=' '.$CrLf; $XML_DEBITOR .=' '.round($row_somme, 2).''.$CrLf; $XML_DEBITOR .=' '.$CrLf; @@ -1607,7 +1608,8 @@ class BonPrelevement extends CommonObject $XML_DEBITOR .=' '.$CrLf; $XML_DEBITOR .=' '.$CrLf; // $XML_DEBITOR .=' '.($row_facnumber.'/'.$Rowing.'/'.$Rum).''.$CrLf; - $XML_DEBITOR .=' '.dol_trunc($row_facnumber, 135).''.$CrLf; // 140 max + // $XML_DEBITOR .=' '.dol_trunc($row_facnumber, 135).''.$CrLf; // 140 max + $XML_DEBITOR .=' '.(($conf->global->USTRD != "" ) ? $conf->global->USTRD : dol_trunc($row_facnumber, 135) ).''.$CrLf; // 140 max $XML_DEBITOR .=' '.$CrLf; $XML_DEBITOR .=' '.$CrLf; return $XML_DEBITOR; diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index d837a6c6421..30b7c5158ba 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -32,6 +32,7 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; // Load translation files required by the page @@ -76,6 +77,7 @@ $search_type=GETPOST('search_type','alpha'); $search_zip=GETPOST('search_zip','alpha'); $search_town=GETPOST('search_town','alpha'); $search_import_key=GETPOST("search_import_key","alpha"); +$search_country=GETPOST("search_country",'intcomma'); if ($search_status=='') $search_status=1; // always display activ customer first @@ -148,6 +150,7 @@ $arrayfields=array( 'p.poste'=>array('label'=>"PostOrFunction", 'checked'=>1), 'p.town'=>array('label'=>"Town", 'checked'=>0), 'p.zip'=>array('label'=>"Zip", 'checked'=>0), + 'country.code_iso'=>array('label'=>"Country", 'checked'=>0), 'p.phone'=>array('label'=>"Phone", 'checked'=>1), 'p.phone_perso'=>array('label'=>"PhonePerso", 'checked'=>0), 'p.phone_mobile'=>array('label'=>"PhoneMobile", 'checked'=>1), @@ -203,6 +206,9 @@ if (empty($reshook)) $search_lastname=""; $search_firstname=""; $search_societe=""; + $search_town=""; + $search_zip=""; + $search_country=""; $search_poste=""; $search_phone=""; $search_phone_perso=""; @@ -298,6 +304,7 @@ if ($search_id > 0) $sql.= natural_search("p.rowid",$search_id,1 if ($search_lastname) $sql.= natural_search('p.lastname', $search_lastname); if ($search_firstname) $sql.= natural_search('p.firstname', $search_firstname); if ($search_societe) $sql.= natural_search('s.nom', $search_societe); +if ($search_country) $sql .= " AND p.fk_pays IN (".$search_country.')'; if (strlen($search_poste)) $sql.= natural_search('p.poste', $search_poste); if (strlen($search_phone_perso)) $sql.= natural_search('p.phone_perso', $search_phone_perso); if (strlen($search_phone_pro)) $sql.= natural_search('p.phone', $search_phone); @@ -396,6 +403,7 @@ if ($search_firstname != '') $param.='&search_firstname='.urlencode($search_ if ($search_societe != '') $param.='&search_societe='.urlencode($search_societe); if ($search_zip != '') $param.='&search_zip='.urlencode($search_zip); if ($search_town != '') $param.='&search_town='.urlencode($search_town); +if ($search_country != '') $param.= "&search_country=".urlencode($search_country); if ($search_job != '') $param.='&search_job='.urlencode($search_job); if ($search_phone_pro != '') $param.='&search_phone_pro='.urlencode($search_phone_pro); if ($search_phone_perso != '') $param.='&search_phone_perso='.urlencode($search_phone_perso); @@ -518,6 +526,12 @@ if (! empty($arrayfields['p.firstname']['checked'])) print ''; print ''; } +if (! empty($arrayfields['p.poste']['checked'])) +{ + print ''; + print ''; + print ''; +} if (! empty($arrayfields['p.zip']['checked'])) { print ''; @@ -530,10 +544,25 @@ if (! empty($arrayfields['p.town']['checked'])) print ''; print ''; } -if (! empty($arrayfields['p.poste']['checked'])) +// State +/*if (! empty($arrayfields['state.nom']['checked'])) + { + print ''; + print ''; + print ''; + } + // Region + if (! empty($arrayfields['region.nom']['checked'])) + { + print ''; + print ''; + print ''; + }*/ +// Country +if (! empty($arrayfields['country.code_iso']['checked'])) { - print ''; - print ''; + print ''; + print $form->select_country($search_country,'search_country','',0,'maxwidth100'); print ''; } if (! empty($arrayfields['p.phone']['checked'])) @@ -630,9 +659,12 @@ print ''; if (! empty($arrayfields['p.rowid']['checked'])) print_liste_field_titre($arrayfields['p.rowid']['label'], $_SERVER["PHP_SELF"],"p.rowid","",$param,"",$sortfield,$sortorder); if (! empty($arrayfields['p.lastname']['checked'])) print_liste_field_titre($arrayfields['p.lastname']['label'],$_SERVER["PHP_SELF"],"p.lastname", $begin, $param, '', $sortfield,$sortorder); if (! empty($arrayfields['p.firstname']['checked'])) print_liste_field_titre($arrayfields['p.firstname']['label'],$_SERVER["PHP_SELF"],"p.firstname", $begin, $param, '', $sortfield,$sortorder); +if (! empty($arrayfields['p.poste']['checked'])) print_liste_field_titre($arrayfields['p.poste']['label'],$_SERVER["PHP_SELF"],"p.poste", $begin, $param, '', $sortfield,$sortorder); if (! empty($arrayfields['p.zip']['checked'])) print_liste_field_titre($arrayfields['p.zip']['label'],$_SERVER["PHP_SELF"],"p.zip", $begin, $param, '', $sortfield,$sortorder); if (! empty($arrayfields['p.town']['checked'])) print_liste_field_titre($arrayfields['p.town']['label'],$_SERVER["PHP_SELF"],"p.town", $begin, $param, '', $sortfield,$sortorder); -if (! empty($arrayfields['p.poste']['checked'])) print_liste_field_titre($arrayfields['p.poste']['label'],$_SERVER["PHP_SELF"],"p.poste", $begin, $param, '', $sortfield,$sortorder); +//if (! empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'],$_SERVER["PHP_SELF"],"state.nom","",$param,'',$sortfield,$sortorder); +//if (! empty($arrayfields['region.nom']['checked'])) print_liste_field_titre($arrayfields['region.nom']['label'],$_SERVER["PHP_SELF"],"region.nom","",$param,'',$sortfield,$sortorder); +if (! empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'],$_SERVER["PHP_SELF"],"co.code_iso","",$param,'align="center"',$sortfield,$sortorder); if (! empty($arrayfields['p.phone']['checked'])) print_liste_field_titre($arrayfields['p.phone']['label'],$_SERVER["PHP_SELF"],"p.phone", $begin, $param, '', $sortfield,$sortorder); if (! empty($arrayfields['p.phone_perso']['checked'])) print_liste_field_titre($arrayfields['p.phone_perso']['label'],$_SERVER["PHP_SELF"],"p.phone_perso", $begin, $param, '', $sortfield,$sortorder); if (! empty($arrayfields['p.phone_mobile']['checked'])) print_liste_field_titre($arrayfields['p.phone_mobile']['label'],$_SERVER["PHP_SELF"],"p.phone_mobile", $begin, $param, '', $sortfield,$sortorder); @@ -697,6 +729,12 @@ while ($i < min($num,$limit)) print ''.$obj->firstname.''; if (! $i) $totalarray['nbfield']++; } + // Job position + if (! empty($arrayfields['p.poste']['checked'])) + { + print ''.dol_trunc($obj->poste,20).''; + if (! $i) $totalarray['nbfield']++; + } // Zip if (! empty($arrayfields['p.zip']['checked'])) { @@ -709,10 +747,25 @@ while ($i < min($num,$limit)) print ''.$obj->town.''; if (! $i) $totalarray['nbfield']++; } - // Function - if (! empty($arrayfields['p.poste']['checked'])) + // State + /*if (! empty($arrayfields['state.nom']['checked'])) { - print ''.dol_trunc($obj->poste,20).''; + print "".$obj->state_name."\n"; + if (! $i) $totalarray['nbfield']++; + } + // Region + if (! empty($arrayfields['region.nom']['checked'])) + { + print "".$obj->region_name."\n"; + if (! $i) $totalarray['nbfield']++; + }*/ + // Country + if (! empty($arrayfields['country.code_iso']['checked'])) + { + print ''; + $tmparray=getCountry($obj->fk_pays,'all'); + print $tmparray['label']; + print ''; if (! $i) $totalarray['nbfield']++; } // Phone diff --git a/htdocs/contrat/admin/contract_extrafields.php b/htdocs/contrat/admin/contract_extrafields.php index b9b0d51c162..d19c91e0bf2 100644 --- a/htdocs/contrat/admin/contract_extrafields.php +++ b/htdocs/contrat/admin/contract_extrafields.php @@ -81,7 +81,7 @@ dol_fiche_end(); if ($action != 'create' && $action != 'edit') { print '"; } @@ -94,7 +94,7 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { - print '

'; + print '
'; print load_fiche_titre($langs->trans('NewAttribute')); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; diff --git a/htdocs/contrat/admin/contractdet_extrafields.php b/htdocs/contrat/admin/contractdet_extrafields.php index 42a8ed589d7..af2585eaf3a 100644 --- a/htdocs/contrat/admin/contractdet_extrafields.php +++ b/htdocs/contrat/admin/contractdet_extrafields.php @@ -81,7 +81,7 @@ dol_fiche_end(); if ($action != 'create' && $action != 'edit') { print '"; } @@ -94,8 +94,8 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { - print "
"; - print load_fiche_titre($langs->trans('NewAttribute')); + print '
'; + print load_fiche_titre($langs->trans('NewAttribute')); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; } diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index 58161aef6f5..f5382a91550 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -628,6 +628,7 @@ class CMailFile if (! $res) { + $langs->load("errors"); $this->error="Failed to send mail with php mail"; $linuxlike=1; if (preg_match('/^win/i',PHP_OS)) $linuxlike=0; diff --git a/htdocs/core/class/canvas.class.php b/htdocs/core/class/canvas.class.php index 6851c124743..d9c496add4f 100644 --- a/htdocs/core/class/canvas.class.php +++ b/htdocs/core/class/canvas.class.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2010-2018 Regis Houssin * Copyright (C) 2011 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify @@ -145,7 +145,7 @@ class Canvas { if (empty($this->template_dir)) return 0; - if (file_exists($this->template_dir.($this->card?$this->card.'_':'').$this->_cleanaction($action).'.tpl.php')) return 1; + if (file_exists($this->template_dir.(!empty($this->card)?$this->card.'_':'').$this->_cleanaction($action).'.tpl.php')) return 1; else return 0; } @@ -161,7 +161,7 @@ class Canvas global $db, $conf, $langs, $user, $canvas; global $form, $formfile; - include $this->template_dir.($this->card?$this->card.'_':'').$this->_cleanaction($action).'.tpl.php'; // Include native PHP template + include $this->template_dir.(!empty($this->card)?$this->card.'_':'').$this->_cleanaction($action).'.tpl.php'; // Include native PHP template } diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index 9ce569edb35..9bab103d2e4 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -173,7 +173,7 @@ abstract class CommonInvoice extends CommonObject } /** - * Return amount (with tax) of all credit notes and deposits invoices used by invoice + * Return amount (with tax) of all credit notes invoices + excess received used by invoice * * @param int $multicurrency Return multicurrency_amount instead of amount * @return int <0 if KO, Sum of credit notes and deposits amount otherwise diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index a165704c058..771f9fc4456 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1500,7 +1500,7 @@ abstract class CommonObject */ function load_previous_next_ref($filter, $fieldid, $nodbprefix=0) { - global $user; + global $conf, $user; if (! $this->table_element) { @@ -1520,6 +1520,9 @@ abstract class CommonObject $sql = "SELECT MAX(te.".$fieldid.")"; $sql.= " FROM ".(empty($nodbprefix)?MAIN_DB_PREFIX:'').$this->table_element." as te"; + if ($this->element == 'user' && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { + $sql.= ",".MAIN_DB_PREFIX."usergroup_user as ug"; + } if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 2) $sql.= ", ".MAIN_DB_PREFIX."societe as s"; // If we need to link to societe to limit select to entity else if ($this->restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe as s"; // If we need to link to societe to limit select to socid else if ($this->restrictiononfksoc == 2 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON te.fk_soc = s.rowid"; // If we need to link to societe to limit select to socid @@ -1534,7 +1537,18 @@ abstract class CommonObject } if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 2) $sql.= ' AND te.fk_soc = s.rowid'; // If we need to link to societe to limit select to entity else if ($this->restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql.= ' AND te.fk_soc = s.rowid'; // If we need to link to societe to limit select to socid - if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) $sql.= ' AND te.entity IN ('.getEntity($this->element).')'; + if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) { + if ($this->element == 'user' && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { + if (! empty($user->admin) && empty($user->entity) && $conf->entity == 1) { + $sql.= " AND te.entity IS NOT NULL"; // Show all users + } else { + $sql.= " AND ug.fk_user = te.rowid"; + $sql.= " AND ug.entity IN (".getEntity($this->element).")"; + } + } else { + $sql.= ' AND te.entity IN ('.getEntity($this->element).')'; + } + } if ($this->restrictiononfksoc == 1 && $socid && $this->element != 'societe') $sql.= ' AND te.fk_soc = ' . $socid; if ($this->restrictiononfksoc == 2 && $socid && $this->element != 'societe') $sql.= ' AND (te.fk_soc = ' . $socid.' OR te.fk_soc IS NULL)'; if ($this->restrictiononfksoc && $socid && $this->element == 'societe') $sql.= ' AND te.rowid = ' . $socid; @@ -1552,6 +1566,9 @@ abstract class CommonObject $sql = "SELECT MIN(te.".$fieldid.")"; $sql.= " FROM ".(empty($nodbprefix)?MAIN_DB_PREFIX:'').$this->table_element." as te"; + if ($this->element == 'user' && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { + $sql.= ",".MAIN_DB_PREFIX."usergroup_user as ug"; + } if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 2) $sql.= ", ".MAIN_DB_PREFIX."societe as s"; // If we need to link to societe to limit select to entity else if ($this->restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe as s"; // If we need to link to societe to limit select to socid else if ($this->restrictiononfksoc == 2 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON te.fk_soc = s.rowid"; // If we need to link to societe to limit select to socid @@ -1566,7 +1583,18 @@ abstract class CommonObject } if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 2) $sql.= ' AND te.fk_soc = s.rowid'; // If we need to link to societe to limit select to entity else if ($this->restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql.= ' AND te.fk_soc = s.rowid'; // If we need to link to societe to limit select to socid - if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) $sql.= ' AND te.entity IN ('.getEntity($this->element).')'; + if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) { + if ($this->element == 'user' && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { + if (! empty($user->admin) && empty($user->entity) && $conf->entity == 1) { + $sql.= " AND te.entity IS NOT NULL"; // Show all users + } else { + $sql.= " AND ug.fk_user = te.rowid"; + $sql.= " AND ug.entity IN (".getEntity($this->element).")"; + } + } else { + $sql.= ' AND te.entity IN ('.getEntity($this->element).')'; + } + } if ($this->restrictiononfksoc == 1 && $socid && $this->element != 'societe') $sql.= ' AND te.fk_soc = ' . $socid; if ($this->restrictiononfksoc == 2 && $socid && $this->element != 'societe') $sql.= ' AND (te.fk_soc = ' . $socid.' OR te.fk_soc IS NULL)'; if ($this->restrictiononfksoc && $socid && $this->element == 'societe') $sql.= ' AND te.rowid = ' . $socid; @@ -3838,7 +3866,7 @@ abstract class CommonObject { global $conf,$langs,$user,$object,$hookmanager; global $form,$bc,$bcdd; - global $object_rights, $disableedit, $disablemove; // TODO We should not use global var for this ! + global $object_rights, $disableedit, $disablemove, $disableremove; // TODO We should not use global var for this ! $object_rights = $this->getRights(); @@ -5082,10 +5110,10 @@ abstract class CommonObject * @param string $moreparam To add more parameters on html input tag * @param string $keysuffix Prefix string to add into name and id of field (can be used to avoid duplicate names) * @param string $keyprefix Suffix string to add into name and id of field (can be used to avoid duplicate names) - * @param string|int $showsize Value for css to define size. May also be a numeric. + * @param string|int $morecss Value for css to define style/length of field. May also be a numeric. * @return string */ - function showInputField($val, $key, $value, $moreparam='', $keysuffix='', $keyprefix='', $showsize=0) + function showInputField($val, $key, $value, $moreparam='', $keysuffix='', $keyprefix='', $morecss=0) { global $conf,$langs,$form; @@ -5094,39 +5122,55 @@ abstract class CommonObject require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; $form=new Form($this->db); } + + $val=$this->fields[$key]; + + $out=''; + $type=''; + $param['options']=array(); + $size =$this->fields[$key]['size']; + // Because we work on extrafields + if(preg_match('/^integer:(.*):(.*)/i', $val['type'], $reg)){ + $param['options']=array($reg[1].':'.$reg[2]=>'N'); + $type ='link'; + }else if(preg_match('/^link:(.*):(.*)/i', $val['type'], $reg)){ + $param['options']=array($reg[1].':'.$reg[2]=>'N'); + $type ='link'; + }else if(preg_match('/^sellist:(.*):(.*):(.*):(.*)/i', $val['type'], $reg)){ + + $param['options']=array($reg[1].':'.$reg[2].':'.$reg[3].':'.$reg[4]=>'N'); + $type ='sellist'; + }else if(preg_match('/varchar\((\d+)\)/', $val['type'],$reg)){ + + $param['options']=array(); + $type ='varchar'; + $size=$reg[1]; + }else if(preg_match('/varchar/', $val['type'])){ + + $param['options']=array(); + $type ='varchar'; + }else if(is_array($this->fields[$key]['arrayofkeyval'])){ + + $param['options']=$this->fields[$key]['arrayofkeyval']; + $type ='select'; + }else { + $param['options']=array(); + $type =$this->fields[$key]['type']; + } + + $label=$this->fields[$key]['label']; + //$elementtype=$this->fields[$key]['elementtype']; // Seems not used + $default=$this->fields[$key]['default']; + $computed=$this->fields[$key]['computed']; + $unique=$this->fields[$key]['unique']; + $required=$this->fields[$key]['required']; + + $langfile=$this->fields[$key]['langfile']; + $list=$this->fields[$key]['list']; + $hidden=abs($this->fields[$key]['visible'])!=1?1:0; $objectid = $this->id; - $label= $val['label']; - $type = $val['type']; - $size = $val['css']; - - // Convert var to be able to share same code than showInputField of extrafields - if (preg_match('/varchar\((\d+)\)/', $type, $reg)) - { - $type = 'varchar'; // convert varchar(xx) int varchar - $size = $reg[1]; - } - elseif (preg_match('/varchar/', $type)) $type = 'varchar'; // convert varchar(xx) into varchar - elseif (preg_match('/double/', $type)) $type = 'double'; // convert double(xx) into double - if (is_array($val['arrayofkeyval'])) $type='select'; - if (preg_match('/^integer:(.*):(.*)/i', $val['type'], $reg)) $type='link'; - - $default=$val['default']; - $computed=$val['computed']; - $unique=$val['unique']; - $required=$val['required']; - $param=$val['param']; - if (is_array($val['arrayofkeyval'])) $param['options'] = $val['arrayofkeyval']; - if (preg_match('/^integer:(.*):(.*)/i', $val['type'], $reg)) - { - $type='link'; - $param['options']=array($reg[1].':'.$reg[2]=>$reg[1].':'.$reg[2]); - } - $langfile=$val['langfile']; - $list=$val['list']; - $hidden=(abs($val['visible'])!=1 ? 1 : 0); - $help=$val['help']; if ($computed) { @@ -5134,54 +5178,50 @@ abstract class CommonObject else return ''; } + // Use in priority showsize from parameters, then $val['css'] then autodefine - if (empty($showsize) && ! empty($val['css'])) + if (empty($morecss) && ! empty($val['css'])) { $showsize = $val['css']; } - if (empty($showsize)) + if (empty($morecss)) { if ($type == 'date') { - //$showsize=10; - $showsize = 'minwidth100imp'; + $morecss = 'minwidth100imp'; } elseif ($type == 'datetime') { - //$showsize=19; - $showsize = 'minwidth200imp'; + $morecss = 'minwidth200imp'; } - elseif (in_array($type,array('int','double','price'))) + elseif (in_array($type,array('int','integer','price')) || preg_match('/^double(\([0-9],[0-9]\)){0,1}/',$type)) { - //$showsize=10; - $showsize = 'maxwidth75'; - } - elseif ($type == 'url') + $morecss = 'maxwidth75'; + }elseif ($type == 'url') { - $showsize='minwidth400'; + $morecss='minwidth400'; } elseif ($type == 'boolean') { - $showsize=''; + $morecss=''; } else { if (round($size) < 12) { - $showsize = 'minwidth100'; + $morecss = 'minwidth100'; } else if (round($size) <= 48) { - $showsize = 'minwidth200'; + $morecss = 'minwidth200'; } else { - //$showsize=48; - $showsize = 'minwidth400'; + $morecss = 'minwidth400'; } } } - //var_dump($showsize.' '.$size); + if (in_array($type,array('date','datetime'))) { $tmp=explode(',',$size); @@ -5193,33 +5233,47 @@ abstract class CommonObject if (!$required && $value == '') $value = '-1'; // TODO Must also support $moreparam - $out = $form->select_date($value, $keyprefix.$key.$keysuffix, $showtime, $showtime, $required, '', 1, ($keyprefix != 'search_' ? 1 : 0), 1, 0, 1); + $out = $form->select_date($value, $keyprefix.$key.$keysuffix, $showtime, $showtime, $required, '', 1, (($keyprefix != 'search_' && $keyprefix != 'search_options_') ? 1 : 0), 1, 0, 1); } elseif (in_array($type,array('int','integer'))) { $tmp=explode(',',$size); $newsize=$tmp[0]; - $out=''; + $out=''; } elseif (preg_match('/varchar/', $type)) { - $out=''; + $out=''; } elseif (in_array($type, array('mail', 'phone', 'url'))) { - $out=''; + $out=''; } elseif ($type == 'text') { - require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor($keyprefix.$key.$keysuffix,$value,'',200,'dolibarr_notes','In',false,false,0,ROWS_5,'90%'); - $out=$doleditor->Create(1); + if (! preg_match('/search_/', $keyprefix)) // If keyprefix is search_ or search_options_, we must just use a simple text field + { + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor=new DolEditor($keyprefix.$key.$keysuffix,$value,'',200,'dolibarr_notes','In',false,false,false,ROWS_5,'90%'); + $out=$doleditor->Create(1); + } + else + { + $out=''; + } } elseif ($type == 'html') { - require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor($keyprefix.$key.$keysuffix,$value,'',200,'dolibarr_notes','In',false,false,! empty($conf->fckeditor->enabled) && $conf->global->FCKEDITOR_ENABLE_SOCIETE,ROWS_5,'90%'); - $out=$doleditor->Create(1); + if (! preg_match('/search_/', $keyprefix)) // If keyprefix is search_ or search_options_, we must just use a simple text field + { + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor=new DolEditor($keyprefix.$key.$keysuffix,$value,'',200,'dolibarr_notes','In',false,false,! empty($conf->fckeditor->enabled) && $conf->global->FCKEDITOR_ENABLE_SOCIETE,ROWS_5,'90%'); + $out=$doleditor->Create(1); + } + else + { + $out=''; + } } elseif ($type == 'boolean') { @@ -5229,21 +5283,21 @@ abstract class CommonObject } else { $checked=' value="1" '; } - $out=''; + $out=''; } elseif ($type == 'price') { if (!empty($value)) { // $value in memory is a php numeric, we format it into user number format. $value=price($value); } - $out=' '.$langs->getCurrencySymbol($conf->currency); + $out=' '.$langs->getCurrencySymbol($conf->currency); } - elseif ($type == 'double') + elseif (preg_match('/^double(\([0-9],[0-9]\)){0,1}/',$type)) { if (!empty($value)) { // $value in memory is a php numeric, we format it into user number format. $value=price($value); } - $out=' '; + $out=' '; } elseif ($type == 'select') { @@ -5254,8 +5308,8 @@ abstract class CommonObject $out.= ajax_combobox($keyprefix.$key.$keysuffix, array(), 0); } - $out.=''; + if((! isset($this->fields[$key]['default'])) ||($this->fields[$key]['notnull']!=1))$out.=''; foreach ($param['options'] as $key => $val) { if ((string) $key == '') continue; @@ -5276,11 +5330,13 @@ abstract class CommonObject $out.= ajax_combobox($keyprefix.$key.$keysuffix, array(), 0); } - $out.=''; if (is_array($param['options'])) { $param_list=array_keys($param['options']); $InfoFieldList = explode(":", $param_list[0]); + $parentName=''; + $parentField=''; // 0 : tableName // 1 : label field name // 2 : key fields name (if differ of rowid) @@ -5365,8 +5421,9 @@ abstract class CommonObject $obj = $this->db->fetch_object($resql); // Several field into label (eq table:code|libelle:rowid) + $notrans = false; $fields_label = explode('|',$InfoFieldList[1]); - if(is_array($fields_label)) + if (is_array($fields_label)) { $notrans = true; foreach ($fields_label as $field_toshow) @@ -5380,7 +5437,7 @@ abstract class CommonObject } $labeltoshow=dol_trunc($labeltoshow,45); - if ($value==$obj->rowid) + if ($value == $obj->rowid) { foreach ($fields_label as $field_toshow) { @@ -5395,7 +5452,7 @@ abstract class CommonObject } else { - if(!$notrans) + if (! $notrans) { $translabel=$langs->trans($obj->{$InfoFieldList[1]}); if ($translabel!=$obj->{$InfoFieldList[1]}) { @@ -5411,7 +5468,7 @@ abstract class CommonObject $out.=''; } - if (!empty($InfoFieldList[3])) + if (!empty($InfoFieldList[3]) && $parentField) { $parent = $parentName.':'.$obj->{$parentField}; } @@ -5442,7 +5499,7 @@ abstract class CommonObject $out=''; foreach ($param['options'] as $keyopt => $val) { - $out.='db->fetch_object($resql); + $notrans = false; // Several field into label (eq table:code|libelle:rowid) $fields_label = explode('|', $InfoFieldList[1]); if (is_array($fields_label)) { @@ -5574,7 +5634,7 @@ abstract class CommonObject $data[$obj->rowid]=$labeltoshow; } - if (! empty($InfoFieldList[3])) { + if (! empty($InfoFieldList[3]) && $parentField) { $parent = $parentName . ':' . $obj->{$parentField}; } @@ -5591,18 +5651,17 @@ abstract class CommonObject print 'Error in request ' . $sql . ' ' . $this->db->lasterror() . '. Check setup of extra parameters.
'; } } - $out .= ''; } elseif ($type == 'link') { $param_list=array_keys($param['options']); // $param_list='ObjectName:classPath' - $showempty=(($val['notnull'] == 1 && $val['default'] != '')?0:1); + $showempty=(($required && $default != '')?0:1); $out=$form->selectForForms($param_list[0], $keyprefix.$key.$keysuffix, $value, $showempty); } elseif ($type == 'password') { // If prefix is 'search_', field is used as a filter, we use a common text field. - $out=''; + $out=''; } elseif ($type == 'array') { @@ -5648,8 +5707,7 @@ abstract class CommonObject */ return $out; } - - + /** * Return HTML string to show a field into a page * Code very similar with showOutputField of extra fields diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 264d3e9c236..3b33b1f16f1 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -39,6 +39,8 @@ class Conf var $db; //! To store properties found into database var $global; + //! To store browser info + var $browser; //! To store if javascript/ajax is enabked public $use_javascript_ajax; @@ -506,7 +508,7 @@ class Conf if (! isset($this->global->MAIN_SHOW_LOGO)) $this->global->MAIN_SHOW_LOGO=1; // Default max file size for upload - $this->maxfilesize = (empty($this->global->MAIN_UPLOAD_DOC) ? 0 : $this->global->MAIN_UPLOAD_DOC * 1024); + $this->maxfilesize = (empty($this->global->MAIN_UPLOAD_DOC) ? 0 : (int) $this->global->MAIN_UPLOAD_DOC * 1024); // By default, we propagate contacts if (! isset($this->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN)) $this->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN='*'; // Can be also '*' or '^(BILLING|SHIPPING|CUSTOMER|.*)$' (regex not yet implemented) diff --git a/htdocs/core/class/discount.class.php b/htdocs/core/class/discount.class.php index 5cb7d3e6882..9fc1921aa60 100644 --- a/htdocs/core/class/discount.class.php +++ b/htdocs/core/class/discount.class.php @@ -509,11 +509,11 @@ class DiscountAbsolute } /** - * Return amount (with tax) of all credit notes and deposits invoices used by invoice as a payment + * Return amount (with tax) of all credit notes invoices + excess received used by invoice as a payment * * @param CommonInvoice $invoice Object invoice * @param int $multicurrency Return multicurrency_amount instead of amount - * @return int <0 if KO, Sum of credit notes and deposits amount otherwise + * @return int <0 if KO, Sum of credit notes and excess received amount otherwise */ function getSumCreditNotesUsed($invoice, $multicurrency=0) { diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 839528ddc20..174e01bf74c 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -156,14 +156,14 @@ class ExtraFields * @param int $alwayseditable Is attribute always editable regardless of the document status * @param string $perms Permission to check * @param string $list Visibilty ('0'=never visible, '1'=visible on list+forms, '2'=list only, '3'=form only or 'eval string') - * @param int $notused Deprecated. + * @param string $help Text with help tooltip * @param string $computed Computed value * @param string $entity Entity of extrafields (for multicompany modules) * @param string $langfile Language file * @param string $enabled Condition to have the field enabled or not * @return int <=0 if KO, >0 if OK */ - function addExtraField($attrname, $label, $type, $pos, $size, $elementtype, $unique=0, $required=0, $default_value='', $param='', $alwayseditable=0, $perms='', $list='-1', $notused=0, $computed='', $entity='', $langfile='', $enabled='1') + function addExtraField($attrname, $label, $type, $pos, $size, $elementtype, $unique=0, $required=0, $default_value='', $param='', $alwayseditable=0, $perms='', $list='-1', $help='', $computed='', $entity='', $langfile='', $enabled='1') { if (empty($attrname)) return -1; if (empty($label)) return -1; @@ -174,13 +174,13 @@ class ExtraFields // Create field into database except for separator type which is not stored in database if ($type != 'separate') { - $result=$this->create($attrname, $type, $size, $elementtype, $unique, $required, $default_value, $param, $perms, $list, $computed); + $result=$this->create($attrname, $type, $size, $elementtype, $unique, $required, $default_value, $param, $perms, $list, $computed, $help); } $err1=$this->errno; if ($result > 0 || $err1 == 'DB_ERROR_COLUMN_ALREADY_EXISTS' || $type == 'separate') { // Add declaration of field into table - $result2=$this->create_label($attrname, $label, $type, $pos, $size, $elementtype, $unique, $required, $param, $alwayseditable, $perms, $list, $notused, $default_value, $computed, $entity, $langfile, $enabled); + $result2=$this->create_label($attrname, $label, $type, $pos, $size, $elementtype, $unique, $required, $param, $alwayseditable, $perms, $list, $help, $default_value, $computed, $entity, $langfile, $enabled); $err2=$this->errno; if ($result2 > 0 || ($err1 == 'DB_ERROR_COLUMN_ALREADY_EXISTS' && $err2 == 'DB_ERROR_RECORD_ALREADY_EXISTS')) { @@ -300,7 +300,7 @@ class ExtraFields * @param int $alwayseditable Is attribute always editable regardless of the document status * @param string $perms Permission to check * @param string $list Visibily - * @param int $notused Deprecated. + * @param string $help Help on tooltip * @param string $default Default value (in database. use the default_value feature for default value on screen). * @param string $computed Computed value * @param string $entity Entity of extrafields @@ -308,7 +308,7 @@ class ExtraFields * @param string $enabled Condition to have the field enabled or not * @return int <=0 if KO, >0 if OK */ - private function create_label($attrname, $label='', $type='', $pos=0, $size=0, $elementtype='member', $unique=0, $required=0, $param='', $alwayseditable=0, $perms='', $list='-1', $notused=0, $default='', $computed='',$entity='', $langfile='', $enabled='1') + private function create_label($attrname, $label='', $type='', $pos=0, $size=0, $elementtype='member', $unique=0, $required=0, $param='', $alwayseditable=0, $perms='', $list='-1', $help='', $default='', $computed='',$entity='', $langfile='', $enabled='1') { global $conf,$user; @@ -357,7 +357,8 @@ class ExtraFields $sql.= " fk_user_author,"; $sql.= " fk_user_modif,"; $sql.= " datec,"; - $sql.= " enabled"; + $sql.= " enabled,"; + $sql.= " help"; $sql.= " )"; $sql.= " VALUES('".$attrname."',"; $sql.= " '".$this->db->escape($label)."',"; @@ -378,7 +379,8 @@ class ExtraFields $sql .= " " . $user->id . ","; $sql .= " " . $user->id . ","; $sql .= "'" . $this->db->idate(dol_now()) . "',"; - $sql.= " ".($enabled?"'".$this->db->escape($enabled)."'":"1"); + $sql.= " ".($enabled?"'".$this->db->escape($enabled)."'":"1").","; + $sql.= " ".($help?"'".$this->db->escape($help)."'":"null"); $sql.=')'; dol_syslog(get_class($this)."::create_label", LOG_DEBUG); @@ -508,7 +510,7 @@ class ExtraFields * @param int $alwayseditable Is attribute always editable regardless of the document status * @param string $perms Permission to check * @param string $list Visibility - * @param int $notused Deprecated. + * @param string $help Help on tooltip * @param string $default Default value (in database. use the default_value feature for default value on screen). * @param string $computed Computed value * @param string $entity Entity of extrafields @@ -516,7 +518,7 @@ class ExtraFields * @param string $enabled Condition to have the field enabled or not * @return int >0 if OK, <=0 if KO */ - function update($attrname, $label, $type, $length, $elementtype, $unique=0, $required=0, $pos=0, $param='', $alwayseditable=0, $perms='', $list='', $notused=0, $default='', $computed='', $entity='', $langfile='', $enabled='1') + function update($attrname, $label, $type, $length, $elementtype, $unique=0, $required=0, $pos=0, $param='', $alwayseditable=0, $perms='', $list='', $help='', $default='', $computed='', $entity='', $langfile='', $enabled='1') { if ($elementtype == 'thirdparty') $elementtype='societe'; if ($elementtype == 'contact') $elementtype='socpeople'; @@ -566,7 +568,7 @@ class ExtraFields { if ($label) { - $result=$this->update_label($attrname,$label,$type,$length,$elementtype,$unique,$required,$pos,$param,$alwayseditable,$perms,$list,$notused,$default,$computed,$entity,$langfile,$enabled); + $result=$this->update_label($attrname,$label,$type,$length,$elementtype,$unique,$required,$pos,$param,$alwayseditable,$perms,$list,$help,$default,$computed,$entity,$langfile,$enabled); } if ($result > 0) { @@ -617,7 +619,7 @@ class ExtraFields * @param int $alwayseditable Is attribute always editable regardless of the document status * @param string $perms Permission to check * @param string $list Visiblity - * @param int $notused Deprecated. + * @param string $help Help on tooltip. * @param string $default Default value (in database. use the default_value feature for default value on screen). * @param string $computed Computed value * @param string $entity Entity of extrafields @@ -625,7 +627,7 @@ class ExtraFields * @param string $enabled Condition to have the field enabled or not * @return int <=0 if KO, >0 if OK */ - private function update_label($attrname,$label,$type,$size,$elementtype,$unique=0,$required=0,$pos=0,$param='',$alwayseditable=0,$perms='',$list='0',$notused=0,$default='',$computed='',$entity='',$langfile='',$enabled='1') + private function update_label($attrname,$label,$type,$size,$elementtype,$unique=0,$required=0,$pos=0,$param='',$alwayseditable=0,$perms='',$list='0',$help='',$default='',$computed='',$entity='',$langfile='',$enabled='1') { global $conf, $user; dol_syslog(get_class($this)."::update_label ".$attrname.", ".$label.", ".$type.", ".$size.", ".$elementtype.", ".$unique.", ".$required.", ".$pos.", ".$alwayseditable.", ".$perms.", ".$list.", ".$notused.", ".$default.", ".$computed.", ".$entity.", ".$langfile.", ".$enabled); @@ -684,7 +686,8 @@ class ExtraFields $sql.= " fk_user_author,"; $sql.= " fk_user_modif,"; $sql.= " datec,"; - $sql.= " enabled"; + $sql.= " enabled,"; + $sql.= " help"; $sql.= ") VALUES ("; $sql.= "'".$attrname."',"; $sql.= " ".($entity===''?$conf->entity:$entity).","; @@ -705,7 +708,8 @@ class ExtraFields $sql .= " " . $user->id . ","; $sql .= " " . $user->id . ","; $sql .= "'" . $this->db->idate(dol_now()) . "',"; - $sql .= "'" . $this->db->escape($enabled). "'"; + $sql .= "'" . $this->db->escape($enabled). "',"; + $sql.= " ".($help?"'".$this->db->escape($help)."'":"null"); $sql.= ")"; $resql2=$this->db->query($sql); @@ -769,7 +773,7 @@ class ExtraFields // We should not have several time this log. If we have, there is some optimization to do by calling a simple $object->fetch_optionals() that include cache management. dol_syslog("fetch_name_optionals_label elementtype=".$elementtype); - $sql = "SELECT rowid,name,label,type,size,elementtype,fieldunique,fieldrequired,param,pos,alwayseditable,perms,langs,list,fielddefault,fieldcomputed,entity,enabled"; + $sql = "SELECT rowid,name,label,type,size,elementtype,fieldunique,fieldrequired,param,pos,alwayseditable,perms,langs,list,fielddefault,fieldcomputed,entity,enabled,help"; $sql.= " FROM ".MAIN_DB_PREFIX."extrafields"; $sql.= " WHERE entity IN (0,".$conf->entity.")"; if ($elementtype) $sql.= " AND elementtype = '".$elementtype."'"; // Filed with object->table_element @@ -824,6 +828,7 @@ class ExtraFields $this->attributes[$tab->elementtype]['entityid'][$tab->name]=$tab->entity; $this->attributes[$tab->elementtype]['entitylabel'][$tab->name]=(empty($labelmulticompany[$tab->entity])?'Entity'.$tab->entity:$labelmulticompany[$tab->entity]); $this->attributes[$tab->elementtype]['enabled'][$tab->name]=$tab->enabled; + $this->attributes[$tab->elementtype]['help'][$tab->name]=$tab->help; $this->attributes[$tab->elementtype]['loaded']=1; } @@ -881,6 +886,7 @@ class ExtraFields $perms=dol_eval($this->attributes[$extrafieldsobjectkey]['perms'][$key], 1); $langfile=$this->attributes[$extrafieldsobjectkey]['langfile'][$key]; $list=dol_eval($this->attributes[$extrafieldsobjectkey]['list'][$key], 1); + $help=$this->attributes[$extrafieldsobjectkey]['help'][$key]; $hidden=(empty($list) ? 1 : 0); // If empty, we are sure it is hidden, otherwise we show. If it depends on mode (view/create/edit form or list, this must be filtered by caller) } else // Old usage diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index cd33f1d8d02..439e31caae1 100644 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -186,7 +186,8 @@ class HookManager 'sendMail', 'sendMailAfter', 'showLinkToObjectBlock', - 'setContentSecurityPolicy' + 'setContentSecurityPolicy', + 'setHtmlTitle' ) )) $hooktype='addreplace'; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 9a9d3279e03..88377edfad9 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -291,7 +291,7 @@ class Form $out=''; // Check parameters - if ($inputType == 'textarea') $value = dol_nl2br($value); + if (preg_match('/^text/',$inputType)) $value = dol_nl2br($value); else if (preg_match('/^numeric/',$inputType)) $value = price($value); else if ($inputType == 'day' || $inputType == 'datepicker') $value = dol_print_date($value, 'day'); @@ -1001,9 +1001,10 @@ class Form * @param string $selected_input_value Value of preselected input text (for use with ajax) * @param int $hidelabel Hide label (0=no, 1=yes, 2=show search icon (before) and placeholder, 3 search icon after) * @param array $ajaxoptions Options for ajax_autocompleter + * @param bool $multiple add [] in the name of element and add 'multiple' attribut (not working with ajax_autocompleter) * @return string HTML string with select box for thirdparty. */ - function select_company($selected='', $htmlname='socid', $filter='', $showempty='', $showtype=0, $forcecombo=0, $events=array(), $limit=0, $morecss='minwidth100', $moreparam='', $selected_input_value='', $hidelabel=1, $ajaxoptions=array()) + function select_company($selected='', $htmlname='socid', $filter='', $showempty='', $showtype=0, $forcecombo=0, $events=array(), $limit=0, $morecss='minwidth100', $moreparam='', $selected_input_value='', $hidelabel=1, $ajaxoptions=array(), $multiple=false) { global $conf,$user,$langs; @@ -1040,7 +1041,7 @@ class Form else { // Immediate load of all database - $out.=$this->select_thirdparty_list($selected, $htmlname, $filter, $showempty, $showtype, $forcecombo, $events, '', 0, $limit, $morecss, $moreparam); + $out.=$this->select_thirdparty_list($selected, $htmlname, $filter, $showempty, $showtype, $forcecombo, $events, '', 0, $limit, $morecss, $moreparam, $multiple); } return $out; @@ -1062,16 +1063,20 @@ class Form * @param int $limit Limit number of answers * @param string $morecss Add more css styles to the SELECT component * @param string $moreparam Add more parameters onto the select tag. For example 'style="width: 95%"' to avoid select2 component to go over parent container + * @param bool $multiple add [] in the name of element and add 'multiple' attribut * @return string HTML string with */ - function select_thirdparty_list($selected='',$htmlname='socid',$filter='',$showempty='', $showtype=0, $forcecombo=0, $events=array(), $filterkey='', $outputmode=0, $limit=0, $morecss='minwidth100', $moreparam='') + function select_thirdparty_list($selected='',$htmlname='socid',$filter='',$showempty='', $showtype=0, $forcecombo=0, $events=array(), $filterkey='', $outputmode=0, $limit=0, $morecss='minwidth100', $moreparam='', $multiple=false) { global $conf,$user,$langs; $out=''; $num=0; $outarray=array(); - + + if ($selected === '') $selected = array(); + else if (!is_array($selected)) $selected = array($selected); + // Clean $filter that may contains sql conditions so sql code if (function_exists('test_sql_and_script_inject')) $filter = test_sql_and_script_inject($filter, 3); @@ -1120,7 +1125,7 @@ class Form } // Construct $out and $outarray - $out.= ''."\n"; $textifempty=''; // Do not use textifempty = ' ' or ' ' here, or search on key will search on ' key'. @@ -1169,7 +1174,7 @@ class Form if (empty($outputmode)) { - if ($selected > 0 && $selected == $obj->rowid) + if (in_array($obj->rowid,$selected)) { $out.= ''; } @@ -1320,15 +1325,19 @@ class Form * @param array $events Event options. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled'))) * @param string $moreparam Add more parameters onto the select tag. For example 'style="width: 95%"' to avoid select2 component to go over parent container * @param string $htmlid Html id to use instead of htmlname + * @param bool $multiple add [] in the name of element and add 'multiple' attribut * @return int <0 if KO, Nb of contact in list if OK */ - function selectcontacts($socid, $selected='', $htmlname='contactid', $showempty=0, $exclude='', $limitto='', $showfunction=0, $moreclass='', $options_only=false, $showsoc=0, $forcecombo=0, $events=array(), $moreparam='', $htmlid='') + function selectcontacts($socid, $selected='', $htmlname='contactid', $showempty=0, $exclude='', $limitto='', $showfunction=0, $moreclass='', $options_only=false, $showsoc=0, $forcecombo=0, $events=array(), $moreparam='', $htmlid='', $multiple=false) { global $conf,$langs; $langs->load('companies'); if (empty($htmlid)) $htmlid = $htmlname; + + if ($selected === '') $selected = array(); + else if (!is_array($selected)) $selected = array($selected); $out=''; // On recherche les societes @@ -1353,9 +1362,9 @@ class Form $out .= ajax_combobox($htmlid, $events, $conf->global->CONTACT_USE_SEARCH_TO_SELECT); } - if ($htmlname != 'none' || $options_only) $out.= ''; + if ($showempty == 1 && !$multiple) $out.= ''; + if ($showempty == 2) $out.= ''; $num = $this->db->num_rows($resql); $i = 0; if ($num) @@ -1363,7 +1372,6 @@ class Form include_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; $contactstatic=new Contact($this->db); - if (!is_array($selected)) $selected = array($selected); while ($i < $num) { $obj = $this->db->fetch_object($resql); @@ -1413,7 +1421,7 @@ class Form } else { - $out.= ''; + $out.= ''; } if ($htmlname != 'none' || $options_only) { @@ -1469,16 +1477,20 @@ class Form * @param string $morecss More css * @param int $noactive Show only active users (this will also happened whatever is this option if USER_HIDE_INACTIVE_IN_COMBOBOX is on). * @param int $outputmode 0=HTML select string, 1=Array + * @param bool $multiple add [] in the name of element and add 'multiple' attribut * @return string HTML select string * @see select_dolgroups */ - function select_dolusers($selected='', $htmlname='userid', $show_empty=0, $exclude=null, $disabled=0, $include='', $enableonly='', $force_entity='0', $maxlength=0, $showstatus=0, $morefilter='', $show_every=0, $enableonlytext='', $morecss='', $noactive=0, $outputmode=0) + function select_dolusers($selected='', $htmlname='userid', $show_empty=0, $exclude=null, $disabled=0, $include='', $enableonly='', $force_entity='0', $maxlength=0, $showstatus=0, $morefilter='', $show_every=0, $enableonlytext='', $morecss='', $noactive=0, $outputmode=0, $multiple=false) { global $conf,$user,$langs; - + // If no preselected user defined, we take current user if ((is_numeric($selected) && ($selected < -2 || empty($selected))) && empty($conf->global->SOCIETE_DISABLE_DEFAULT_SALESREPRESENTATIVE)) $selected=$user->id; + if ($selected === '') $selected = array(); + else if (!is_array($selected)) $selected = array($selected); + $excludeUsers=null; $includeUsers=null; @@ -1551,12 +1563,12 @@ class Form $out .= ajax_combobox($htmlname); // do not use maxwidthonsmartphone by default. Set it by caller so auto size to 100% will work when not defined - $out.= ''; + if ($show_empty && !$multiple) $out.= ''."\n"; + if ($show_every) $out.= ''."\n"; $userstatic=new User($this->db); - + while ($i < $num) { $obj = $this->db->fetch_object($resql); @@ -1568,7 +1580,7 @@ class Form $disableline=''; if (is_array($enableonly) && count($enableonly) && ! in_array($obj->rowid,$enableonly)) $disableline=($enableonlytext?$enableonlytext:'1'); - if ((is_object($selected) && $selected->id == $obj->rowid) || (! is_object($selected) && $selected == $obj->rowid)) + if ((is_object($selected) && $selected->id == $obj->rowid) || (! is_object($selected) && in_array($obj->rowid,$selected) )) { $out.= ''."\n"; + if ($show_empty && !$multiple) $out.= ''."\n"; while ($i < $num) { @@ -6786,7 +6802,7 @@ class Form $out.= ''."\n"; + if ($show_empty) $out.= ''."\n"; $out.= ''; } $out.= ''; diff --git a/htdocs/core/class/html.formcontract.class.php b/htdocs/core/class/html.formcontract.class.php index f4902e4912e..a3a3696e5f4 100644 --- a/htdocs/core/class/html.formcontract.class.php +++ b/htdocs/core/class/html.formcontract.class.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2012-2018 Charlene BENKE * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -57,15 +57,25 @@ class FormContract global $db,$user,$conf,$langs; $hideunselectables = false; - if (! empty($conf->global->PROJECT_HIDE_UNSELECTABLES)) $hideunselectables = true; + if (! empty($conf->global->CONTRACT_HIDE_UNSELECTABLES)) $hideunselectables = true; // Search all contacts $sql = 'SELECT c.rowid, c.ref, c.fk_soc, c.statut'; $sql.= ' FROM '.MAIN_DB_PREFIX .'contrat as c'; $sql.= " WHERE c.entity = ".$conf->entity; //if ($contratListId) $sql.= " AND c.rowid IN (".$contratListId.")"; + if ($socid > 0) + { + // CONTRACT_ALLOW_TO_LINK_FROM_OTHER_COMPANY is 'all' or a list of ids separated by coma. + if (empty($conf->global->CONTRACT_ALLOW_TO_LINK_FROM_OTHER_COMPANY)) + $sql.= " AND (c.fk_soc=".$socid." OR c.fk_soc IS NULL)"; + else if ($conf->global->CONTRACT_ALLOW_TO_LINK_FROM_OTHER_COMPANY != 'all') + { + $sql.= " AND (c.fk_soc IN (".$socid.", ".$conf->global->CONTRACT_ALLOW_TO_LINK_FROM_OTHER_COMPANY.") "; + $sql.= " OR c.fk_soc IS NULL)"; + } + } if ($socid == 0) $sql.= " AND (c.fk_soc = 0 OR c.fk_soc IS NULL)"; - if ($socid > 0) $sql.= " AND (c.fk_soc=".$socid." OR c.fk_soc IS NULL)"; $sql.= " ORDER BY c.ref "; dol_syslog(get_class($this)."::select_contract", LOG_DEBUG); @@ -98,12 +108,12 @@ class FormContract else { $disabled=0; - if (! $obj->statut > 0) + if ( $obj->statut == 0) { $disabled=1; $labeltoshow.=' ('.$langs->trans("Draft").')'; } - if ($socid > 0 && (! empty($obj->fk_soc) && $obj->fk_soc != $socid)) + if ( empty($conf->global->CONTRACT_ALLOW_TO_LINK_FROM_OTHER_COMPANY) && $socid > 0 && (! empty($obj->fk_soc) && $obj->fk_soc != $socid)) { $disabled=1; $labeltoshow.=' - '.$langs->trans("LinkedToAnotherCompany"); diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index 098b75a81b6..69fe03ecaa1 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -193,7 +193,7 @@ class FormOther print ''; $i++; diff --git a/htdocs/core/class/html.formprojet.class.php b/htdocs/core/class/html.formprojet.class.php index a572d546ca7..f437920caf9 100644 --- a/htdocs/core/class/html.formprojet.class.php +++ b/htdocs/core/class/html.formprojet.class.php @@ -1,6 +1,7 @@ * Copyright (C) 2015 Marcos García + * Copyright (C) 2018 Charlene Benke * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -139,10 +140,10 @@ class FormProjets if (empty($htmlid)) $htmlid = $htmlname; $out=''; - $outarray=array(); + $outarray=array(); $hideunselectables = false; - if (! empty($conf->global->PROJECT_HIDE_UNSELECTABLES)) $hideunselectables = true; + if (! empty($conf->global->CONTRACT_HIDE_UNSELECTABLES)) $hideunselectables = true; $projectsListId = false; if (empty($user->rights->projet->all->lire)) @@ -317,7 +318,7 @@ class FormProjets $out=''; $hideunselectables = false; - if (! empty($conf->global->PROJECT_HIDE_UNSELECTABLES)) $hideunselectables = true; + if (! empty($conf->global->CONTRACT_HIDE_UNSELECTABLES)) $hideunselectables = true; if (empty($projectsListId)) { diff --git a/htdocs/core/class/menubase.class.php b/htdocs/core/class/menubase.class.php index c123356f9ab..48880633563 100644 --- a/htdocs/core/class/menubase.class.php +++ b/htdocs/core/class/menubase.class.php @@ -124,61 +124,86 @@ class Menubase else dol_print_error($this->db); } - // TODO // Check that entry does not exists yet on key menu_handler-fk_menu-position-url-entity, to avoid errors with postgresql + $sql = "SELECT count(*)"; + $sql.= " FROM ".MAIN_DB_PREFIX."menu"; + $sql.= " WHERE menu_handler = '".$this->db->escape($this->menu_handler)."'"; + $sql.= " AND fk_menu = ".((int) $this->db->escape($this->fk_menu)); + $sql.= " AND position = ".((int) $this->position); + $sql.= " AND url = '".$this->db->escape($this->url)."'"; + $sql.= " AND entity = ".$conf->entity; - // Insert request - $sql = "INSERT INTO ".MAIN_DB_PREFIX."menu("; - $sql.= "menu_handler,"; - $sql.= "entity,"; - $sql.= "module,"; - $sql.= "type,"; - $sql.= "mainmenu,"; - $sql.= "leftmenu,"; - $sql.= "fk_menu,"; - $sql.= "fk_mainmenu,"; - $sql.= "fk_leftmenu,"; - $sql.= "position,"; - $sql.= "url,"; - $sql.= "target,"; - $sql.= "titre,"; - $sql.= "langs,"; - $sql.= "perms,"; - $sql.= "enabled,"; - $sql.= "usertype"; - $sql.= ") VALUES ("; - $sql.= " '".$this->db->escape($this->menu_handler)."',"; - $sql.= " '".$this->db->escape($conf->entity)."',"; - $sql.= " '".$this->db->escape($this->module)."',"; - $sql.= " '".$this->db->escape($this->type)."',"; - $sql.= " ".($this->mainmenu?"'".$this->db->escape($this->mainmenu)."'":"''").","; // Can't be null - $sql.= " ".($this->leftmenu?"'".$this->db->escape($this->leftmenu)."'":"null").","; - $sql.= " '".$this->db->escape($this->fk_menu)."',"; - $sql.= " ".($this->fk_mainmenu?"'".$this->db->escape($this->fk_mainmenu)."'":"null").","; - $sql.= " ".($this->fk_leftmenu?"'".$this->db->escape($this->fk_leftmenu)."'":"null").","; - $sql.= " '".(int) $this->position."',"; - $sql.= " '".$this->db->escape($this->url)."',"; - $sql.= " '".$this->db->escape($this->target)."',"; - $sql.= " '".$this->db->escape($this->titre)."',"; - $sql.= " '".$this->db->escape($this->langs)."',"; - $sql.= " '".$this->db->escape($this->perms)."',"; - $sql.= " '".$this->db->escape($this->enabled)."',"; - $sql.= " '".$this->db->escape($this->user)."'"; - $sql.= ")"; - - dol_syslog(get_class($this)."::create", LOG_DEBUG); - $resql=$this->db->query($sql); - if ($resql) + $result=$this->db->query($sql); + if ($result) { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."menu"); - dol_syslog(get_class($this)."::create record added has rowid=".$this->id, LOG_DEBUG); + $row = $this->db->fetch_row($result); - return $this->id; + if ($row[0] == 0) // If not found + { + // Insert request + $sql = "INSERT INTO ".MAIN_DB_PREFIX."menu("; + $sql.= "menu_handler,"; + $sql.= "entity,"; + $sql.= "module,"; + $sql.= "type,"; + $sql.= "mainmenu,"; + $sql.= "leftmenu,"; + $sql.= "fk_menu,"; + $sql.= "fk_mainmenu,"; + $sql.= "fk_leftmenu,"; + $sql.= "position,"; + $sql.= "url,"; + $sql.= "target,"; + $sql.= "titre,"; + $sql.= "langs,"; + $sql.= "perms,"; + $sql.= "enabled,"; + $sql.= "usertype"; + $sql.= ") VALUES ("; + $sql.= " '".$this->db->escape($this->menu_handler)."',"; + $sql.= " '".$this->db->escape($conf->entity)."',"; + $sql.= " '".$this->db->escape($this->module)."',"; + $sql.= " '".$this->db->escape($this->type)."',"; + $sql.= " ".($this->mainmenu?"'".$this->db->escape($this->mainmenu)."'":"''").","; // Can't be null + $sql.= " ".($this->leftmenu?"'".$this->db->escape($this->leftmenu)."'":"null").","; + $sql.= " ".((int) $this->fk_menu).","; + $sql.= " ".($this->fk_mainmenu?"'".$this->db->escape($this->fk_mainmenu)."'":"null").","; + $sql.= " ".($this->fk_leftmenu?"'".$this->db->escape($this->fk_leftmenu)."'":"null").","; + $sql.= " ".((int) $this->position).","; + $sql.= " '".$this->db->escape($this->url)."',"; + $sql.= " '".$this->db->escape($this->target)."',"; + $sql.= " '".$this->db->escape($this->titre)."',"; + $sql.= " '".$this->db->escape($this->langs)."',"; + $sql.= " '".$this->db->escape($this->perms)."',"; + $sql.= " '".$this->db->escape($this->enabled)."',"; + $sql.= " '".$this->db->escape($this->user)."'"; + $sql.= ")"; + + dol_syslog(get_class($this)."::create", LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."menu"); + dol_syslog(get_class($this)."::create record added has rowid=".$this->id, LOG_DEBUG); + + return $this->id; + } + else + { + $this->error="Error ".$this->db->lasterror(); + return -1; + } + } + else + { + dol_syslog(get_class($this)."::create menu entry already exists", LOG_WARNING); + $this->error = 'Error Menu entry already exists'; + return 0; + } } else { - $this->error="Error ".$this->db->lasterror(); - return -1; + return -1; } } diff --git a/htdocs/core/lib/fichinter.lib.php b/htdocs/core/lib/fichinter.lib.php index 8507a85292a..fcb14be9c67 100644 --- a/htdocs/core/lib/fichinter.lib.php +++ b/htdocs/core/lib/fichinter.lib.php @@ -2,8 +2,9 @@ /* Copyright (C) 2006-2007 Laurent Destailleur * Copyright (C) 2007 Rodolphe Quiedeville * Copyright (C) 2012 Regis Houssin - * Copyright (C) 2016 Gilles Poirier - + * Copyright (C) 2016 Gilles Poirier + * Copyright (C) 2018 charlene Benke + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -162,4 +163,23 @@ function fichinter_admin_prepare_head() return $head; } +function fichinter_rec_prepare_head ($object) +{ + global $langs, $conf; //, $user; + + $h = 0; + $head = array(); + + $head[$h][0] = DOL_URL_ROOT.'/fichinter/card-rec.php?id='.$object->id; + $head[$h][1] = $langs->trans("CardFichinter"); + $head[$h][2] = 'card'; + $h++; + + complete_head_from_modules($conf, $langs, $object, $head, $h, 'intervention-rec'); + + complete_head_from_modules($conf, $langs, $object, $head, $h,'intervention-rec','remove'); + + + return $head; +} diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 54bbbc837a1..51e64c22878 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2782,6 +2782,35 @@ function isValidEmail($address, $acceptsupervisorkey=0) return false; } +/** + * Return if the domain name has a valid MX record. + * WARNING: This need function idn_to_ascii, checkdnsrr and getmxrr + * + * @param string $domain Domain name (Ex: "yahoo.com", "yhaoo.com", "dolibarr.fr") + * @return int -1 if error (function not available), 0=Not valid, 1=Valid + */ +function isValidMXRecord($domain) +{ + if (function_exists('idn_to_ascii') && function_exists('checkdnsrr')) + { + if (! checkdnsrr(idn_to_ascii($domain), 'MX')) + { + return 0; + } + if (function_exists('getmxrr')) + { + $mxhosts=array(); + $weight=array(); + getmxrr(idn_to_ascii($domain), $mxhosts, $weight); + if (count($mxhosts) > 1) return 1; + if (count($mxhosts) == 1 && ! empty($mxhosts[0])) return 1; + + return 0; + } + } + return -1; +} + /** * Return true if phone number syntax is ok * TODO Decide what to do with this diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index 80ba3039abe..e7eb9eb259d 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -708,9 +708,10 @@ function array2table($data,$tableMarkup=1,$tableoptions='',$troptions='',$tdopti * @param string $mode 'next' for next value or 'last' for last value * @param bool $bentityon Activate the entity filter. Default is true (for modules not compatible with multicompany) * @param User $objuser Object user we need data from. + * @param int $forceentity Entity id to force * @return string New value (numeric) or error message */ -function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$mode='next', $bentityon=true, $objuser=null) +function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$mode='next', $bentityon=true, $objuser=null, $forceentity=null) { global $conf,$user; @@ -987,7 +988,8 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m $sql.= " AND ".$field." NOT LIKE '(PROV%)'"; if ($bentityon) // only if entity enable $sql.= " AND entity IN (".getEntity($sharetable).")"; - + else if (! empty($forceentity)) + $sql.= " AND entity = ".(int) $forceentity; if ($where) $sql.=$where; if ($sqlwhere) $sql.=' AND '.$sqlwhere; @@ -1035,6 +1037,8 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m $sql.= " AND ".$field." NOT LIKE '%PROV%'"; if ($bentityon) // only if entity enable $sql.= " AND entity IN (".getEntity($sharetable).")"; + else if (! empty($forceentity)) + $sql.= " AND entity = ".(int) $forceentity; if ($where) $sql.=$where; if ($sqlwhere) $sql.=' AND '.$sqlwhere; @@ -1089,6 +1093,8 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m $maskrefclient_sql.= " WHERE ".$field." LIKE '".$maskrefclient_maskLike."'"; if ($bentityon) // only if entity enable $maskrefclient_sql.= " AND entity IN (".getEntity($sharetable).")"; + else if (! empty($forceentity)) + $sql.= " AND entity = ".(int) $forceentity; if ($where) $maskrefclient_sql.=$where; //use the same optional where as general mask if ($sqlwhere) $maskrefclient_sql.=' AND '.$sqlwhere; //use the same sqlwhere as general mask $maskrefclient_sql.=' AND (SUBSTRING('.$field.', '.(strpos($maskwithnocode,$maskrefclient)+1).', '.dol_strlen($maskrefclient_maskclientcode).")='".$maskrefclient_clientcode."')"; diff --git a/htdocs/core/lib/holiday.lib.php b/htdocs/core/lib/holiday.lib.php index 56d19d0e0f1..b0653968c5f 100644 --- a/htdocs/core/lib/holiday.lib.php +++ b/htdocs/core/lib/holiday.lib.php @@ -61,3 +61,32 @@ function holiday_prepare_head($object) return $head; } + + +/** + * Return array head with list of tabs to view object informations + * + * @return array head + */ +function holiday_admin_prepare_head() +{ + global $db, $langs, $conf, $user; + + $h = 0; + $head = array(); + + $head[$h][0] = DOL_URL_ROOT.'/admin/holiday.php'; + $head[$h][1] = $langs->trans("Setup"); + $head[$h][2] = 'holiday'; + $h++; + + // Show more tabs from modules + // Entries must be declared in modules descriptor with line + // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab + // $this->tabs = array('entity:-tabname); to remove a tab + complete_head_from_modules($conf,$langs,$object,$head,$h,'holiday_admin'); + + complete_head_from_modules($conf,$langs,$object,$head,$h,'holiday_admin','remove'); + + return $head; +} diff --git a/htdocs/core/lib/modulebuilder.lib.php b/htdocs/core/lib/modulebuilder.lib.php index 8187c15f684..7e8bf3ae8d7 100644 --- a/htdocs/core/lib/modulebuilder.lib.php +++ b/htdocs/core/lib/modulebuilder.lib.php @@ -63,7 +63,9 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir=' setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Label")), null, 'errors'); return -2; } - if (! preg_match('/^(integer|date|timestamp|varchar|double|html|price)/', $addfieldentry['type'])) + + if (! preg_match('/^(price|boolean|sellist|integer|date|timestamp|varchar|double|text|html)/', $addfieldentry['type'])) + { setEventMessages($langs->trans('BadFormatForType', $objectname), null, 'errors'); return -2; @@ -256,11 +258,13 @@ function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir='', foreach($object->fields as $key => $val) { $i++; - - $type = $val['type']; + + $type = $val['type']; $type = preg_replace('/:.*$/', '', $type); // For case type = 'integer:Societe:societe/class/societe.class.php' + if ($type == 'html') $type = 'text'; // html modulebuilder type is a text type in database - if ($type == 'price') $type = 'double'; // html modulebuilder type is a text type in database + else if ($type == 'price') $type = 'double'; // html modulebuilder type is a text type in database + else if ($type == 'link' || $type == 'sellist') $type = 'integer'; $texttoinsert.= "\t".$key." ".$type; if ($key == 'rowid') $texttoinsert.= ' AUTO_INCREMENT PRIMARY KEY'; if ($key == 'entity') $texttoinsert.= ' DEFAULT 1'; @@ -269,7 +273,7 @@ function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir='', if ($val['default'] != '') { if (preg_match('/^null$/i', $val['default'])) $texttoinsert.= " DEFAULT NULL"; - else if (preg_match('/varchar/', $val['type'])) $texttoinsert.= " DEFAULT '".$db->escape($val['default'])."'"; + else if (preg_match('/varchar/', $type )) $texttoinsert.= " DEFAULT '".$db->escape($val['default'])."'"; else $texttoinsert.= (($val['default'] > 0)?' DEFAULT '.$val['default']:''); } } diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 30d6b82bb21..047e7285b0d 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1231,7 +1231,17 @@ function pdf_getlinedesc($object,$i,$outputlangs,$hideref=0,$hidedesc=0,$issuppl { if ($idprod) { - if (empty($hidedesc)) $libelleproduitservice.=$desc; + if (empty($hidedesc)) + { + if (!empty($conf->global->MAIN_DOCUMENTS_DESCRIPTION_FIRST)) + { + $libelleproduitservice=$desc."\n".$libelleproduitservice; + } + else + { + $libelleproduitservice.=$desc; + } + } } else { diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index d157cafd5f8..73bb51d464a 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -174,11 +174,10 @@ function dol_verifyHash($chain, $hash, $type='0') * @param string $feature2 Feature to check, second level of permission (optional). Can be a 'or' check with 'level1|level2'. * @param string $dbt_keyfield Field name for socid foreign key if not fk_soc. Not used if objectid is null (optional) * @param string $dbt_select Field name for select if not rowid. Not used if objectid is null (optional) - * @param Canvas $objcanvas Object canvas * @return int Always 1, die process if not allowed * @see dol_check_secure_access_document */ -function restrictedArea($user, $features, $objectid=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $objcanvas=null) +function restrictedArea($user, $features, $objectid=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid') { global $db, $conf; global $hookmanager; @@ -470,13 +469,32 @@ function checkUserAccessToObject($user, $featuresarray, $objectid=0, $tableandsh { $sql = "SELECT COUNT(dbt.".$dbt_select.") as nb"; $sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; - $sql.= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; - if (($feature == 'user' || $feature == 'usergroup') && ! empty($conf->multicompany->enabled) && $conf->entity == 1 && $user->admin && ! $user->entity) + if (($feature == 'user' || $feature == 'usergroup') && ! empty($conf->multicompany->enabled)) { - $sql.= " AND dbt.entity IS NOT NULL"; + if (! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) + { + if ($conf->entity == 1 && $user->admin && ! $user->entity) + { + $sql.= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; + $sql.= " AND dbt.entity IS NOT NULL"; + } + else + { + $sql.= ",".MAIN_DB_PREFIX."usergroup_user as ug"; + $sql.= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; + $sql.= " AND (ug.fk_user = dbt.rowid"; + $sql.= " AND ug.entity IN (".getEntity('user')."))"; + $sql.= " OR dbt.entity = 0"; // Show always superadmin + } + } + else { + $sql.= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; + $sql.= " AND dbt.entity IN (".getEntity($sharedelement, 1).")"; + } } else { + $sql.= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; $sql.= " AND dbt.entity IN (".getEntity($sharedelement, 1).")"; } } @@ -510,12 +528,12 @@ function checkUserAccessToObject($user, $featuresarray, $objectid=0, $tableandsh else if (in_array($feature,$checkother)) // Test on entity and link to societe. Allowed if link is empty (Ex: contacts...). { // If external user: Check permission for external users - if ($user->societe_id > 0) + if ($user->socid > 0) { $sql = "SELECT COUNT(dbt.".$dbt_select.") as nb"; $sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; $sql.= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; - $sql.= " AND dbt.fk_soc = ".$user->societe_id; + $sql.= " AND dbt.fk_soc = ".$user->socid; } // If internal user: Check permission for internal users that are restricted on their objects else if (! empty($conf->societe->enabled) && ($user->rights->societe->lire && ! $user->rights->societe->client->voir)) @@ -578,13 +596,13 @@ function checkUserAccessToObject($user, $featuresarray, $objectid=0, $tableandsh else if (! in_array($feature,$nocheck)) // By default (case of $checkdefault), we check on object entity + link to third party on field $dbt_keyfield { // If external user: Check permission for external users - if ($user->societe_id > 0) + if ($user->socid > 0) { if (empty($dbt_keyfield)) dol_print_error('','Param dbt_keyfield is required but not defined'); $sql = "SELECT COUNT(dbt.".$dbt_keyfield.") as nb"; $sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; $sql.= " WHERE dbt.rowid IN (".$objectid.")"; - $sql.= " AND dbt.".$dbt_keyfield." = ".$user->societe_id; + $sql.= " AND dbt.".$dbt_keyfield." = ".$user->socid; } // If internal user: Check permission for internal users that are restricted on their objects else if (! empty($conf->societe->enabled) && ($user->rights->societe->lire && ! $user->rights->societe->client->voir)) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index a6f19a68086..7c4437116f3 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -122,6 +122,7 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$mode if (! empty($conf->propal->enabled)) $menuqualified++; if (! empty($conf->commande->enabled)) $menuqualified++; if (! empty($conf->supplier_order->enabled)) $menuqualified++; + if (! empty($conf->supplier_proposal->enabled)) $menuqualified++; if (! empty($conf->contrat->enabled)) $menuqualified++; if (! empty($conf->ficheinter->enabled)) $menuqualified++; $tmpentry=array( @@ -660,11 +661,11 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu } // Suppliers - if (! empty($conf->societe->enabled) && ! empty($conf->fournisseur->enabled)) + if (! empty($conf->societe->enabled) && (! empty($conf->fournisseur->enabled) || ! empty($conf->supplier_proposal->enabled))) { $langs->load("suppliers"); - $newmenu->add("/societe/list.php?type=f&leftmenu=suppliers", $langs->trans("ListSuppliersShort"), 1, $user->rights->fournisseur->lire, '', $mainmenu, 'suppliers'); - $newmenu->add("/societe/card.php?leftmenu=suppliers&action=create&type=f",$langs->trans("MenuNewSupplier"), 2, $user->rights->societe->creer && $user->rights->fournisseur->lire); + $newmenu->add("/societe/list.php?type=f&leftmenu=suppliers", $langs->trans("ListSuppliersShort"), 1, ($user->rights->fournisseur->lire || $user->rights->supplier_proposal->lire), '', $mainmenu, 'suppliers'); + $newmenu->add("/societe/card.php?leftmenu=suppliers&action=create&type=f",$langs->trans("MenuNewSupplier"), 2, $user->rights->societe->creer && ($user->rights->fournisseur->lire || $user->rights->supplier_proposal->lire)); } // Contacts @@ -785,7 +786,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu $newmenu->add("/fichinter/index.php?leftmenu=ficheinter", $langs->trans("Interventions"), 0, $user->rights->ficheinter->lire, '', $mainmenu, 'ficheinter', 2200); $newmenu->add("/fichinter/card.php?action=create&leftmenu=ficheinter", $langs->trans("NewIntervention"), 1, $user->rights->ficheinter->creer, '', '', '', 201); $newmenu->add("/fichinter/list.php?leftmenu=ficheinter", $langs->trans("List"), 1, $user->rights->ficheinter->lire, '', '', '', 202); - + $newmenu->add("/fichinter/card-red.php?leftmenu=ficheinter", $langs->trans("ModelList"), 1, $user->rights->ficheinter->lire, '', '', '', 203); $newmenu->add("/fichinter/stats/index.php?leftmenu=ficheinter", $langs->trans("Statistics"), 1, $user->rights->fournisseur->commande->lire); } diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index a5211b11b5e..562f9eed374 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -953,7 +953,7 @@ class DolibarrModules // Can not be abstract, because we need to insta $sql.= " WHERE ".$this->db->decrypt('name')." = '".$this->db->escape($this->const_name)."'"; $sql.= " AND entity IN (0, ".$entity.")"; - dol_syslog(get_class($this)."::_active delect activation constant", LOG_DEBUG); + dol_syslog(get_class($this)."::_active delete activation constant", LOG_DEBUG); $resql=$this->db->query($sql); if (! $resql) $err++; @@ -1671,55 +1671,58 @@ class DolibarrModules // Can not be abstract, because we need to insta // Search if perm already present $sql = "SELECT count(*) as nb FROM ".MAIN_DB_PREFIX."rights_def"; $sql.= " WHERE id = ".$r_id." AND entity = ".$entity; - $resqlselect=$this->db->query($sql); - $obj = $this->db->fetch_object($resqlselect); - if ($obj->nb == 0) + $resqlselect=$this->db->query($sql); + if ($resqlselect) { - if (dol_strlen($r_perms) ) + $objcount = $this->db->fetch_object($resqlselect); + if ($objcount && $objcount->nb == 0) { - if (dol_strlen($r_subperms) ) + if (dol_strlen($r_perms) ) { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."rights_def"; - $sql.= " (id, entity, libelle, module, type, bydefault, perms, subperms)"; - $sql.= " VALUES "; - $sql.= "(".$r_id.",".$entity.",'".$this->db->escape($r_desc)."','".$r_modul."','".$r_type."',".$r_def.",'".$r_perms."','".$r_subperms."')"; + if (dol_strlen($r_subperms) ) + { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."rights_def"; + $sql.= " (id, entity, libelle, module, type, bydefault, perms, subperms)"; + $sql.= " VALUES "; + $sql.= "(".$r_id.",".$entity.",'".$this->db->escape($r_desc)."','".$r_modul."','".$r_type."',".$r_def.",'".$r_perms."','".$r_subperms."')"; + } + else + { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."rights_def"; + $sql.= " (id, entity, libelle, module, type, bydefault, perms)"; + $sql.= " VALUES "; + $sql.= "(".$r_id.",".$entity.",'".$this->db->escape($r_desc)."','".$r_modul."','".$r_type."',".$r_def.",'".$r_perms."')"; + } } else { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."rights_def"; - $sql.= " (id, entity, libelle, module, type, bydefault, perms)"; - $sql.= " VALUES "; - $sql.= "(".$r_id.",".$entity.",'".$this->db->escape($r_desc)."','".$r_modul."','".$r_type."',".$r_def.",'".$r_perms."')"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."rights_def "; + $sql .= " (id, entity, libelle, module, type, bydefault)"; + $sql .= " VALUES "; + $sql .= "(".$r_id.",".$entity.",'".$this->db->escape($r_desc)."','".$r_modul."','".$r_type."',".$r_def.")"; } - } - else - { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."rights_def "; - $sql .= " (id, entity, libelle, module, type, bydefault)"; - $sql .= " VALUES "; - $sql .= "(".$r_id.",".$entity.",'".$this->db->escape($r_desc)."','".$r_modul."','".$r_type."',".$r_def.")"; - } - $resqlinsert=$this->db->query($sql,1); + $resqlinsert=$this->db->query($sql,1); - if (! $resqlinsert) - { - if ($this->db->errno() != "DB_ERROR_RECORD_ALREADY_EXISTS") + if (! $resqlinsert) { - $this->error=$this->db->lasterror(); - $err++; - break; - } - else dol_syslog(get_class($this)."::insert_permissions record already exists", LOG_INFO); + if ($this->db->errno() != "DB_ERROR_RECORD_ALREADY_EXISTS") + { + $this->error=$this->db->lasterror(); + $err++; + break; + } + else dol_syslog(get_class($this)."::insert_permissions record already exists", LOG_INFO); + } + + $this->db->free($resqlinsert); } - $this->db->free($resqlinsert); + $this->db->free($resqlselect); } - $this->db->free($resqlselect); - // If we want to init permissions on admin users if ($reinitadminperms) { @@ -1737,23 +1740,33 @@ class DolibarrModules // Can not be abstract, because we need to insta { $obj2=$this->db->fetch_object($resqlseladmin); dol_syslog(get_class($this)."::insert_permissions Add permission to user id=".$obj2->rowid); + $tmpuser=new User($this->db); - $tmpuser->fetch($obj2->rowid); - if (!empty($tmpuser->id)) { + $result = $tmpuser->fetch($obj2->rowid); + if ($result > 0) { $tmpuser->addrights($r_id, '', '', 0, 1); } + else + { + dol_syslog(get_class($this)."::insert_permissions Failed to add the permission to user because fetch return an error", LOG_ERR); + } $i++; } - if (! empty($user->admin)) // Reload permission for current user if defined - { - // We reload permissions - $user->clearrights(); - $user->getrights(); - } } - else dol_print_error($this->db); + else + { + dol_print_error($this->db); + } } } + + if ($reinitadminperms && ! empty($user->admin)) // Reload permission for current user if defined + { + // We reload permissions + $user->clearrights(); + $user->getrights(); + } + } $this->db->free($resql); } diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 6c8fcf2f07e..a16e783d465 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -795,7 +795,7 @@ class pdf_crabe extends ModelePDFFactures $pdf->SetFont('','', $default_font_size - 4); - // Loop on each deposits and credit notes included + // Loop on each discount available (deposits and credit notes and excess of payment included) $sql = "SELECT re.rowid, re.amount_ht, re.multicurrency_amount_ht, re.amount_tva, re.multicurrency_amount_tva, re.amount_ttc, re.multicurrency_amount_ttc,"; $sql.= " re.description, re.fk_facture_source,"; $sql.= " f.type, f.datef"; @@ -812,9 +812,10 @@ class pdf_crabe extends ModelePDFFactures $y+=3; $obj = $this->db->fetch_object($resql); - if ($obj->type == 2) $text=$outputlangs->trans("CreditNote"); - elseif ($obj->type == 3) $text=$outputlangs->trans("Deposit"); - else $text=$outputlangs->trans("UnknownType"); + if ($obj->type == 2) $text=$outputlangs->transnoentities("CreditNote"); + elseif ($obj->type == 3) $text=$outputlangs->transnoentities("Deposit"); + elseif ($obj->type == 0) $text=$outputlangs->transnoentities("ExcessReceived"); + else $text=$outputlangs->transnoentities("UnknownType"); $invoice->fetch($obj->fk_facture_source); @@ -1304,7 +1305,7 @@ class pdf_crabe extends ModelePDFFactures $pdf->SetTextColor(0,0,0); - $creditnoteamount=$object->getSumCreditNotesUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0); + $creditnoteamount=$object->getSumCreditNotesUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0); // Warning, this also include excess received $depositsamount=$object->getSumDepositsUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0); //print "x".$creditnoteamount."-".$depositsamount;exit; $resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT'); @@ -1322,9 +1323,10 @@ class pdf_crabe extends ModelePDFFactures // Credit note if ($creditnoteamount) { + $labeltouse = ($outputlangs->transnoentities("CreditNotesOrExcessReceived") != "CreditNotesOrExcessReceived") ? $outputlangs->transnoentities("CreditNotesOrExcessReceived") : $outputlangs->transnoentities("CreditNotes"); $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("CreditNotes"), 0, 'L', 0); + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $labeltouse, 0, 'L', 0); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($creditnoteamount, 0, $outputlangs), 0, 'R', 0); } diff --git a/htdocs/core/modules/holiday/index.html b/htdocs/core/modules/holiday/index.html new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/htdocs/core/modules/holiday/index.html @@ -0,0 +1 @@ + diff --git a/htdocs/core/modules/holiday/mod_holiday_immaculate.php b/htdocs/core/modules/holiday/mod_holiday_immaculate.php new file mode 100644 index 00000000000..a00c3825f47 --- /dev/null +++ b/htdocs/core/modules/holiday/mod_holiday_immaculate.php @@ -0,0 +1,132 @@ + + * Copyright (C) 2018 Charlene Benke + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * or see http://www.gnu.org/ + */ + +/** + * \file htdocs/core/modules/holiday/mod_holiday_immaculate.php + * \ingroup contract + * \brief File of class to manage contract numbering rules Magre + */ + +require_once DOL_DOCUMENT_ROOT .'/core/modules/holiday/modules_holiday.php'; + +/** + * Class to manage contract numbering rules Magre + */ +class mod_holiday_immaculate extends ModelNumRefHolidays +{ + var $version='dolibarr'; + var $error = ''; + var $nom = 'Immaculate'; + var $code_auto=1; + + /** + * Return default description of numbering model + * + * @return string text description + */ + function info() + { + global $conf,$langs; + + $langs->load("bills"); + + $form = new Form($this->db); + + $texte = $langs->trans('GenericNumRefModelDesc')."
\n"; + $texte.= ''; + $texte.= ''; + $texte.= ''; + $texte.= ''; + $texte.= ''; + + $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Holiday"),$langs->transnoentities("Holiday")); + $tooltip.=$langs->trans("GenericMaskCodes2"); + $tooltip.=$langs->trans("GenericMaskCodes3"); + $tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Holiday"),$langs->transnoentities("Holiday")); + $tooltip.=$langs->trans("GenericMaskCodes5"); + + $texte.= ''; + $texte.= ''; + $texte.= ''; + $texte.= ''; + $texte.= '
'.$langs->trans("Mask").':'.$form->textwithpicto('',$tooltip,1,1).' 
'; + $texte.= ''; + + return $texte; + } + + /** + * Return numbering example + * + * @return string Example + */ + function getExample() + { + global $conf,$langs,$user; + + $old_login=$user->login; + $user->login='UUUUUUU'; + $numExample = $this->getNextValue($user, ''); + $user->login=$old_login; + + if (! $numExample) + { + $numExample = $langs->trans('NotConfigured'); + } + return $numExample; + } + + /** + * Return next value + * + * @param Societe $user user object + * @param Object $holiday holiday object + * @return string Value if OK, 0 if KO + */ + function getNextValue($user, $holiday) + { + global $db,$conf; + + require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; + + $mask=$conf->global->HOLIDAY_IMMACULATE_MASK; + + if (! $mask) + { + $this->error='NotConfigured'; + return 0; + } + + $numFinal=get_next_value($db,$mask,'holiday','ref','', $user, $holiday->date_create); + + return $numFinal; + } + + /** + * Return next value + * + * @param User $fuser User object + * @param Object $objforref Holiday object + * @return string Value if OK, 0 if KO + */ + function holiday_get_num($fuser, $objforref) + { + return $this->getNextValue($fuser, $objforref); + } +} diff --git a/htdocs/core/modules/holiday/mod_holiday_madonna.php b/htdocs/core/modules/holiday/mod_holiday_madonna.php new file mode 100644 index 00000000000..3b77230f77f --- /dev/null +++ b/htdocs/core/modules/holiday/mod_holiday_madonna.php @@ -0,0 +1,148 @@ + + * Copyright (C) 2018 Charlene Benke + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * or see http://www.gnu.org/ + */ + +/** + * \file htdocs/core/modules/holiday/mod_holiday_madonna.php + * \ingroup contract + * \brief File of class to manage contract numbering rules Serpis + */ +require_once DOL_DOCUMENT_ROOT .'/core/modules/holiday/modules_holiday.php'; + +/** + * Class to manage contract numbering rules madonna + */ +class mod_holiday_madonna extends ModelNumRefHolidays +{ + var $version='dolibarr'; + var $prefix='HL'; + var $error=''; + var $nom='Madonna'; + var $code_auto=1; + + + /** + * Return default description of numbering model + * + * @return string text description + */ + function info() + { + global $langs; + return $langs->trans("SimpleNumRefModelDesc",$this->prefix); + } + + + /** + * Return numbering example + * + * @return string Example + */ + function getExample() + { + return $this->prefix."0501-0001"; + } + + + /** + * Test if existing numbers make problems with numbering + * + * @return boolean false if conflit, true if ok + */ + function canBeActivated() + { + global $conf,$langs,$db; + + $coyymm=''; $max=''; + + $posindice=8; + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; + $sql.= " FROM ".MAIN_DB_PREFIX."holiday"; + $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; + $sql.= " AND entity = ".$conf->entity; + + $resql=$db->query($sql); + if ($resql) + { + $row = $db->fetch_row($resql); + if ($row) { $coyymm = substr($row[0],0,6); $max=$row[0]; } + } + if ($coyymm && ! preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$coyymm)) + { + $langs->load("errors"); + $this->error=$langs->trans('ErrorNumRefModel', $max); + return false; + } + + return true; + } + + /** + * Return next value + * + * @param Societe $objsoc third party object + * @param Object $contract contract object + * @return string Value if OK, 0 if KO + */ + function getNextValue($objsoc,$contract) + { + global $db,$conf; + + $posindice=8; + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; + $sql.= " FROM ".MAIN_DB_PREFIX."holiday"; + $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; + $sql.= " AND entity = ".$conf->entity; + + $resql=$db->query($sql); + if ($resql) + { + $obj = $db->fetch_object($resql); + if ($obj) $max = intval($obj->max); + else $max=0; + } + else + { + dol_syslog("mod_holiday_madonna::getNextValue", LOG_DEBUG); + return -1; + } + + $date=$contract->date_contrat; + $yymm = strftime("%y%m",$date); + + if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is + else $num = sprintf("%04s",$max+1); + + dol_syslog("mod_holiday_madonna::getNextValue return ".$this->prefix.$yymm."-".$num); + return $this->prefix.$yymm."-".$num; + } + + + /** + * Return next value + * + * @param User $fuser User object + * @param Object $objforref Holiday object + * @return string Value if OK, 0 if KO + */ + function holiday_get_num($fuser,$objforref) + { + return $this->getNextValue($fuser,$objforref); + } + +} diff --git a/htdocs/core/modules/holiday/modules_holiday.php b/htdocs/core/modules/holiday/modules_holiday.php new file mode 100644 index 00000000000..7e7865c87e8 --- /dev/null +++ b/htdocs/core/modules/holiday/modules_holiday.php @@ -0,0 +1,146 @@ + + * Copyright (C) 2004-2007 Laurent Destailleur + * Copyright (C) 2004 Eric Seigne + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2006 Andre Cianfarani + * Copyright (C) 2011 Juanjo Menent + * Copyright (C) 2013 Philippe Grand + * Copyright (C) 2014 Marcos García + * Copyright (C) 2018 Charlene Benke + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * or see http://www.gnu.org/ + */ + +/** + * \file htdocs/core/modules/holiday/modules_holiday.php + * \ingroup contract + * \brief File with parent class for generating holiday to PDF and File of class to manage contract numbering + */ + + require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; + + +/** + * Parent class to manage intervention document templates + */ +abstract class ModelePDFHoliday extends CommonDocGenerator +{ + var $error=''; + + + /** + * Return list of active generation modules + * + * @param DoliDB $db Database handler + * @param integer $maxfilenamelength Max length of value to show + * @return array List of templates + */ + static function liste_modeles($db,$maxfilenamelength=0) + { + global $conf; + + $type='contract'; + $liste=array(); + + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + $liste=getListOfModels($db,$type,$maxfilenamelength); + + return $liste; + } +} + + +/** + * Parent class for all contract numbering modules + */ +class ModelNumRefHolidays +{ + var $error=''; + + /** + * Return if a module can be used or not + * + * @return boolean true if module can be used + */ + function isEnabled() + { + return true; + } + + /** + * Return default description of numbering model + * + * @return string text description + */ + function info() + { + global $langs; + $langs->load("holidays"); + return $langs->trans("NoDescription"); + } + + /** + * Return numbering example + * + * @return string Example + */ + function getExample() + { + global $langs; + $langs->load("holidays"); + return $langs->trans("NoExample"); + } + + /** + * Test if existing numbers make problems with numbering + * + * @return boolean false if conflict, true if ok + */ + function canBeActivated() + { + return true; + } + + /** + * Return next value + * + * @param Societe $objsoc third party object + * @param Object $contract contract object + * @return string Value + */ + function getNextValue($objsoc, $contract) + { + global $langs; + return $langs->trans("NotAvailable"); + } + + /** + * Return numbering version module + * + * @return string Value + */ + function getVersion() + { + global $langs; + $langs->load("admin"); + + if ($this->version == 'development') return $langs->trans("VersionDevelopment"); + if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); + if ($this->version == 'dolibarr') return DOL_VERSION; + if ($this->version) return $this->version; + return $langs->trans("NotAvailable"); + } +} diff --git a/htdocs/core/modules/modHoliday.class.php b/htdocs/core/modules/modHoliday.class.php index be078b92a8e..ffaba49e36e 100644 --- a/htdocs/core/modules/modHoliday.class.php +++ b/htdocs/core/modules/modHoliday.class.php @@ -4,6 +4,7 @@ * Copyright (C) 2005-2010 Regis Houssin * Copyright (C) 2011 Dimitri Mouillard * Copyright (C) 2013 Juanjo Menent + * Copyright (C) 2018 Charlene Benke * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -69,9 +70,13 @@ class modHoliday extends DolibarrModules // Data directories to create when module is enabled. // Example: this->dirs = array("/mymodule/temp"); - $this->dirs = array(); + $this->dirs = array("/holiday/temp"); $r=0; + // Config pages + $this->config_page_url = array("holiday.php"); + + // Config pages. Put here list of php page names stored in admmin directory used to setup module. // $this->config_page_url = array("holiday.php?leftmenu=setup@holiday"); @@ -87,7 +92,29 @@ class modHoliday extends DolibarrModules // 1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0) ); // 2=>array('MAIN_MODULE_MYMODULE_NEEDSMARTY','chaine',1,'Constant to say module need smarty',0) $this->const = array(); // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 0 or 'allentities') - + $r=0; + + $this->const[$r][0] = "HOLIDAY_ADDON"; + $this->const[$r][1] = "chaine"; + $this->const[$r][2] = "mod_holiday_madonna"; + $this->const[$r][3] = 'Nom du gestionnaire de numerotation des congés'; + $this->const[$r][4] = 0; + $r++; + + $this->const[$r][0] = "HOLIDAY_ADDON_PDF"; + $this->const[$r][1] = "chaine"; + $this->const[$r][2] = "celebrate"; + $this->const[$r][3] = 'Name of PDF model of holiday'; + $this->const[$r][4] = 0; + $r++; + + $this->const[$r][0] = "HOLIDAY_ADDON_PDF_ODT_PATH"; + $this->const[$r][1] = "chaine"; + $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/holiday"; + $this->const[$r][3] = ""; + $this->const[$r][4] = 0; + $r++; + // Array to add new pages in new tabs $this->tabs[] = array('data'=>'user:+paidholidays:CPTitreMenu:holiday:$user->rights->holiday->read:/holiday/list.php?mainmenu=hrm&id=__ID__'); // To add a new tab identified by code tabname1 diff --git a/htdocs/core/modules/modModuleBuilder.class.php b/htdocs/core/modules/modModuleBuilder.class.php index b6ba08a84a5..875820c9b6b 100644 --- a/htdocs/core/modules/modModuleBuilder.class.php +++ b/htdocs/core/modules/modModuleBuilder.class.php @@ -1,5 +1,6 @@ + * Copyright (C) 2018 Nicolas ZABOURI * * 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 @@ -59,7 +60,7 @@ class modModuleBuilder extends DolibarrModules // Config pages //------------- - $this->config_page_url = array(); + $this->config_page_url = array('setup@modulebuilder'); // Dependancies //------------- diff --git a/htdocs/core/modules/modSupplierProposal.class.php b/htdocs/core/modules/modSupplierProposal.class.php index 34584ea3ffa..fa7553fd6df 100644 --- a/htdocs/core/modules/modSupplierProposal.class.php +++ b/htdocs/core/modules/modSupplierProposal.class.php @@ -32,7 +32,7 @@ include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; /** - * Class to describe and enable module AskPriceSupllier + * Class to describe and enable module SupplierProposal */ class modSupplierProposal extends DolibarrModules { @@ -246,7 +246,7 @@ class modSupplierProposal extends DolibarrModules public function remove($options = '') { $sql = array( - "DELETE FROM ".MAIN_DB_PREFIX."rights_def WHERE module = 'askpricesupplier'" + "DELETE FROM ".MAIN_DB_PREFIX."rights_def WHERE module = 'askpricesupplier'" // To delete/clean deprecated entries ); return $this->_remove($sql, $options); diff --git a/htdocs/core/modules/propale/mod_propale_marbre.php b/htdocs/core/modules/propale/mod_propale_marbre.php index 13bbf9f3d84..0e1700da500 100644 --- a/htdocs/core/modules/propale/mod_propale_marbre.php +++ b/htdocs/core/modules/propale/mod_propale_marbre.php @@ -108,12 +108,15 @@ class mod_propale_marbre extends ModeleNumRefPropales { global $db,$conf; + // Use object entity ID + $entity = ((isset($propal->entity) && is_numeric($propal->entity)) ? $propal->entity : $conf->entity); + // D'abord on recupere la valeur max $posindice=8; $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL $sql.= " FROM ".MAIN_DB_PREFIX."propal"; $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; - $sql.= " AND entity = ".$conf->entity; + $sql.= " AND entity = ".$entity; $resql=$db->query($sql); if ($resql) diff --git a/htdocs/core/modules/propale/mod_propale_saphir.php b/htdocs/core/modules/propale/mod_propale_saphir.php index ec0b0b241e2..54d894c20b5 100644 --- a/htdocs/core/modules/propale/mod_propale_saphir.php +++ b/htdocs/core/modules/propale/mod_propale_saphir.php @@ -115,8 +115,14 @@ class mod_propale_saphir extends ModeleNumRefPropales require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; + $constant = 'PROPALE_SAPHIR_MASK_'.$propal->entity; + // On defini critere recherche compteur - $mask=$conf->global->PROPALE_SAPHIR_MASK; + if (! empty($conf->global->$constant)) { + $mask = $conf->global->$constant; // for multicompany proposal sharing + } else { + $mask = $conf->global->PROPALE_SAPHIR_MASK; + } if (! $mask) { @@ -124,9 +130,12 @@ class mod_propale_saphir extends ModeleNumRefPropales return 0; } + // Use object entity ID + $entity = ((isset($propal->entity) && is_numeric($propal->entity)) ? $propal->entity : $conf->entity); + $date = $propal->date; - $numFinal=get_next_value($db,$mask,'propal','ref','',$objsoc,$date); + $numFinal=get_next_value($db,$mask,'propal','ref','',$objsoc,$date,'next',false,null,$entity); return $numFinal; } diff --git a/htdocs/core/tpl/advtarget.tpl.php b/htdocs/core/tpl/advtarget.tpl.php index e1104ef84f6..a25abbdde6a 100644 --- a/htdocs/core/tpl/advtarget.tpl.php +++ b/htdocs/core/tpl/advtarget.tpl.php @@ -60,7 +60,7 @@ print '