diff --git a/.github/workflows/exakat.yml b/.github/workflows/exakat.yml index 3cfc4f8ba23..c2f8cc12765 100644 --- a/.github/workflows/exakat.yml +++ b/.github/workflows/exakat.yml @@ -13,5 +13,5 @@ jobs: - name: Exakat uses: docker://exakat/exakat-ga with: - ignore_rules: 'Classes/UseInstanceof,Performances/PrePostIncrement,Functions/UndefinedFunctions,Functions/WrongNumberOfArguments,Functions/WrongTypeWithCall,Variables/UndefinedVariable,Classes/DontUnsetProperties,Classes/NonPpp,Classes/StaticMethodsCalledFromObject,Classes/UseClassOperator,Functions/UsesDefaultArguments,Php/NoClassInGlobal,Php/ShouldUseCoalesce,Php/WrongTypeForNativeFunction,Structures/MergeIfThen,Structures/ElseIfElseif,Structures/RepeatedPrint,Structures/SameConditions,Structures/SwitchWithoutDefault,Structures/ShouldMakeTernary,Structures/UselessParenthesis,Structures/UseConstant' + ignore_rules: 'Classes/UseInstanceof,Performances/PrePostIncrement,Functions/UndefinedFunctions,Functions/WrongNumberOfArguments,Functions/WrongTypeWithCall,Variables/UndefinedVariable,Classes/DontUnsetProperties,Classes/NonPpp,Classes/StaticMethodsCalledFromObject,Classes/UseClassOperator,Functions/UsesDefaultArguments,Php/NoClassInGlobal,Php/ShouldUseCoalesce,Php/WrongTypeForNativeFunction,Structures/AddZero,Structures/DropElseAfterReturn,Structures/IfWithSameConditions,Structures/MergeIfThen,Structures/ElseIfElseif,Structures/ExitUsage,Structures/RepeatedPrint,Structures/RepeatedRegex,Structures/SameConditions,Structures/SwitchWithoutDefault,Structures/ShouldMakeTernary,Structures/UselessParenthesis,Structures/UseConstant' ignore_dirs: '/htdocs/includes,/build,/dev,/doc,/scripts,/test' \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 2479de608ef..3ae9f554f26 100644 --- a/.travis.yml +++ b/.travis.yml @@ -120,7 +120,7 @@ install: - | echo "Adding path of binaries tools installed by composer to the PATH" - export PATH="$TRAVIS_BUILD_DIR/htdocs/includes/bin:$TRAVIS_BUILD_DIR/vendor/bin:$TRAVIS_BUILD_DIR/htdocs/includes:$PATH" + export PATH="$TRAVIS_BUILD_DIR/htdocs/includes/bin:$PATH" echo $PATH ls $TRAVIS_BUILD_DIR/vendor ls $TRAVIS_BUILD_DIR/htdocs/includes/bin diff --git a/ChangeLog b/ChangeLog index 4745cea7736..2d0fd358c2b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -18,6 +18,7 @@ NEW: Accountancy - change menu disposition NEW: Accountancy - on transfers, select the periodicity by default NEW: Accountancy - Add export for Gestinum (v3 & v5) NEW: new currency rate editor +NEW: add a widget to show the customers with outstanding limits reached NEW: add 2 rules for emailcollector: Message send/not sent from Dolibarr NEW: add a counter of number of words for pages in website module NEW: add alert before changing thirdparty in TakePOS @@ -167,7 +168,8 @@ NEW: Thirdparty module : box on customer/supplier tab for invoice outsantding am NEW: ticket classification on create from email collector NEW: Ticket message notifications when edited from public interface NEW: translate classification labels in ticket -NEW: Add VAT and juridical status for Algeria +NEW: VAT rate for Angola #15606 +NEW: VAT and juridical status for Algeria NEW: VAT report - Invert constant to show by default zero VAT in reports NEW: website page fields selection NEW: Weighing Scale compatibility with TakePOS connector @@ -178,10 +180,8 @@ NEW: #15065 Add option to put the product label in bold in the PDF templates if For developers: --------------- -NEW: Hook on propal card NEW: add __MEMBER_TYPE__ substitution key NEW: add function dolButtonToOpenUrlInDialogPopup() to be able to open page into a popup -NEW: add hooks on stats pages NEW: show line number on intervention card (via MAIN_VIEW_LINE_NUMBER) NEW: API get contacts list of a given order NEW: API endpoint getContacts and Clean results @@ -210,16 +210,20 @@ NEW: standardizes API thirdparties by email like other object NEW: Thirdparty REST API: endpoint to set price level NEW: use new category API for project list view NEW: Triggers Attributes and Attributes values -NEW: add hooks on newpayment page to allow external payment modules NEW: added incoterms data into the substitution array -NEW: add formConfirm hook on product page NEW: add send context for ticket NEW: add a message in error_log after detection of SQL or script injection -NEW: add two hooks printFieldListFrom and printFieldSearchParam NEW: add __TYPE__ substitution key NEW: add validation of MX domain for emails NEW: calculate the virtual stock in transverse mode ( not on getEntity('commande'), ... but on getEntity('stock') ) +HOOKs +NEW: Hook on propal card +NEW: add hooks on newpayment page to allow external payment modules +NEW: add hooks on stats pages +NEW: add formConfirm hook on product page +NEW: add two hooks printFieldListFrom and printFieldSearchParam + WARNING: @@ -240,6 +244,7 @@ Following changes may create regressions for some external modules, but were nec * Depreciate all methods with name ->valide(). Use instead methods ->validate(). + ***** ChangeLog for 12.0.3 compared to 12.0.2 ***** FIX: 10.0 - when the mime file name is different from the filesystem name, the attachment name should be the mime filename FIX: 11.0 - expenses lines overlapping the total amounts frame @@ -266,7 +271,7 @@ FIX: Look and feel v12: First tab must be name of object FIX: missing entity check FIX: missing param for hook FIX: Missing transaction on PO actions -FIX: MySql Strict mode +FIX: MySQL Strict mode FIX: param entity in html form file FIX: Problems on FEC format FIX: round stock value on product list diff --git a/README.md b/README.md index 139bdc00b6a..29f7da1792b 100644 --- a/README.md +++ b/README.md @@ -140,15 +140,18 @@ See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog) ### Other general features - Localization in most major languages +- Multi-Language Support - Multi-Users and groups with finely grained rights -- Multi-currency -- Multi-company by adding of an external module +- Multi-Currency +- Multi-Company (by adding of an external module) + - Very user friendly and easy to use - customizable Dashboard - Highly customizable: enable only the modules you need, add user personalized fields, choose your skin, several menu managers (can be used by internal users as a back-office with a particular menu, or by external users as a front-office with another one) -- APIs +- APIs (REST, SOAP) - Code that is easy to understand, maintain and develop (PHP with no heavy framework; trigger and hook architecture) + - Support a lot of country specific features: - Spanish Tax RE and ISPF - French NPR VAT rate (VAT called "Non Perçue Récupérable" for DOM-TOM) diff --git a/build/README b/build/README index f7e8ebfe60b..14f2b92ae39 100644 --- a/build/README +++ b/build/README @@ -1,48 +1,62 @@ README (English) + +Path: /dolibarr/build/README + ################################################## Building packages ################################################## All sub-directories of "build" directory contains files (setup or binary tools) required to build automatically Dolibarr packages. -There are several tools: +There are several tools: - To build full Dolibarr packages, launch the script > Launch command perl makepack-dolibarr.pl -Note: Prerequisites to build tgz, debian, rpm package +-------------------------------------------------------------------------------------------------- + + +Prerequisites to build tgz, debian, rpm package: + > apt-get install tar dpkg dpatch p7zip-full rpm zip -Note: Prerequisites to build autoexe DoliWamp package: + +-------------------------------------------------------------------------------------------------- + +Prerequisites to build autoexe DoliWamp package: > apt-get install wine q4wine > Launch "wine cmd" to check a drive Z: pointing to / exists. > Install InnoSetup - For example by running isetup-5.3.9.exe (http://www.jrsoftware.org) + For example by running isetup-5.5.8.exe (https://www.jrsoftware.org) https://files.jrsoftware.org/is/5/ > Install WampServer into "C:\wamp64" to have Apache, PHP and MariaDB - For example by running wampserver3.2.0_x64.exe (http://www.wampserver.com). See file build/exe/doliwamp.iss to know the doliwamp version currently setup. + For example by running wampserver3.2.0_x64.exe (https://www.wampserver.com). + See file build/exe/doliwamp.iss to know the doliwamp version currently setup. > Add path to ISCC into PATH windows var: Launch wine cmd, then regedit and add entry int HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment\PATH > To build manually the .exe from Windows (running from makepack-dolibarr.pl script is however recommanded), open file build/exe/doliwamp.iss and click on button "Compile". The .exe file will be build into directory build. - +-------------------------------------------------------------------------------------------------- - To build a theme package, launch the script > perl makepack-dolibarrtheme.pl +-------------------------------------------------------------------------------------------------- - To build a package for a module, launch the script > perl makepack-dolibarrmodule.pl +-------------------------------------------------------------------------------------------------- - To build developper documentation, launch the script > perl dolibarr-doxygen-build.pl +-------------------------------------------------------------------------------------------------- Note: The build directory and all its contents is absolutely not required to make Dolibarr working. diff --git a/build/makepack-dolibarr.pl b/build/makepack-dolibarr.pl index 85212d9c5ba..314aaff7177 100755 --- a/build/makepack-dolibarr.pl +++ b/build/makepack-dolibarr.pl @@ -503,7 +503,10 @@ if ($nboftargetok) { $ret=`rm -f $BUILDROOT/$PROJECT/htdocs/install/mysql/README`; $ret=`rm -f $BUILDROOT/$PROJECT/htdocs/install/pgsql/README`; - $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/install/mssql`; + $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/install/mssql`; + $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/install/sqlite3`; + + $ret=`rm -fr $BUILDROOT/$PROJECT/node_modules`; $ret=`rm -fr $BUILDROOT/$PROJECT/dev/ansible`; $ret=`rm -fr $BUILDROOT/$PROJECT/dev/codesniffer`; diff --git a/htdocs/accountancy/admin/accountmodel.php b/htdocs/accountancy/admin/accountmodel.php index 2bd2a84841e..6d621a7e101 100644 --- a/htdocs/accountancy/admin/accountmodel.php +++ b/htdocs/accountancy/admin/accountmodel.php @@ -187,7 +187,7 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) $msg .= $langs->transnoentities('ErrorFieldFormat', $langs->transnoentities('Code')).'
'; }*/ } - if (isset($_POST["country"]) && ($_POST["country"] == '0') && ($id != 2)) + if (GETPOSTISSET("country") && (GETPOST("country") == '0') && ($id != 2)) { $ok = 0; setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities("Country")), null, 'errors'); diff --git a/htdocs/accountancy/admin/card.php b/htdocs/accountancy/admin/card.php index cd17e5a1538..d1cee5ff59d 100644 --- a/htdocs/accountancy/admin/card.php +++ b/htdocs/accountancy/admin/card.php @@ -247,7 +247,7 @@ if ($action == 'create') { // Chart of accounts type print ''.$langs->trans("Pcgtype").''; print ''; - print ''; + print ''; print ''; print ''; @@ -309,7 +309,7 @@ if ($action == 'create') { // Chart of accounts type print ''.$langs->trans("Pcgtype").''; print ''; - print ''; + print ''; print ''; print ''; diff --git a/htdocs/accountancy/admin/categories_list.php b/htdocs/accountancy/admin/categories_list.php index 2e51d3d1b38..53dfb1cd5f9 100644 --- a/htdocs/accountancy/admin/categories_list.php +++ b/htdocs/accountancy/admin/categories_list.php @@ -168,7 +168,7 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null, 'errors'); } } - if (isset($_POST["code"])) + if (GETPOSTISSET("code")) { if ($_POST["code"] == '0') { diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php index 55797290058..232444b7d97 100644 --- a/htdocs/accountancy/bookkeeping/balance.php +++ b/htdocs/accountancy/bookkeeping/balance.php @@ -360,12 +360,12 @@ if ($action != 'export_csv') if (!empty($show_subgroup)) { - print ''.$langs->trans("SubTotal").':'.price($sous_total_debit).''.price($sous_total_credit).''.price(price2num($sous_total_debit - $sous_total_credit)).''; + print ''.$langs->trans("SubTotal").':'.price($sous_total_debit).''.price($sous_total_credit).''.price(price2num($sous_total_opening_balance + $sous_total_debit - $sous_total_credit, 'MT')).''; print "\n"; print ''; } - print ''.$langs->trans("AccountBalance").':'.price($total_debit).''.price($total_credit).''.price(price2num($total_debit - $total_credit)).''; + print ''.$langs->trans("AccountBalance").':'.price($total_debit).''.price($total_credit).''.price(price2num($total_opening_balance + $total_debit - $total_credit, 'MT')).''; print "\n"; print ''; diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 097eb38b47f..92de49d66ed 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -108,7 +108,7 @@ $hookmanager->initHooks(array('bookkeepinglist')); $formaccounting = new FormAccounting($db); $form = new Form($db); -if (!in_array($action, array('export_file', 'delmouv', 'delmouvconfirm')) && !GETPOSTISSET('begin') && !isset($_POST['formfilteraction']) && GETPOST('page', 'int') == '' && !GETPOST('noreset', 'int') && $user->rights->accounting->mouvements->export) +if (!in_array($action, array('export_file', 'delmouv', 'delmouvconfirm')) && !GETPOSTISSET('begin') && !GETPOSTISSET('formfilteraction') && GETPOST('page', 'int') == '' && !GETPOST('noreset', 'int') && $user->rights->accounting->mouvements->export) { if (empty($search_date_start) && empty($search_date_end) && !GETPOSTISSET('restore_lastsearch_values')) { @@ -632,19 +632,19 @@ $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $obj if (empty($reshook)) { // Button re-export if (!empty($conf->global->ACCOUNTING_REEXPORT)) { - $newcardbutton = '' . img_picto($langs->trans("Activated"), 'switch_on') . ' '; + $newcardbutton = ''.img_picto($langs->trans("Activated"), 'switch_on').' '; } else { - $newcardbutton = '' . img_picto($langs->trans("Disabled"), 'switch_off') . ' '; + $newcardbutton = ''.img_picto($langs->trans("Disabled"), 'switch_off').' '; } - $newcardbutton .= '' . $langs->trans("IncludeDocsAlreadyExported") . ''; + $newcardbutton .= ''.$langs->trans("IncludeDocsAlreadyExported").''; - $newcardbutton .= dolGetButtonTitle($buttonLabel, $langs->trans("ExportFilteredList") . ' (' . $listofformat[$formatexportset] . ')', 'fa fa-file-export paddingleft', $_SERVER["PHP_SELF"] . '?action=export_file' . ($param ? '&' . $param : ''), $user->rights->accounting->mouvements->export); + $newcardbutton .= dolGetButtonTitle($buttonLabel, $langs->trans("ExportFilteredList").' ('.$listofformat[$formatexportset].')', 'fa fa-file-export paddingleft', $_SERVER["PHP_SELF"].'?action=export_file'.($param ? '&'.$param : ''), $user->rights->accounting->mouvements->export); - $newcardbutton .= dolGetButtonTitle($langs->trans('ViewFlatList'), '', 'fa fa-list paddingleft imgforviewmode', DOL_URL_ROOT . '/accountancy/bookkeeping/list.php?' . $param, '', 1, array('morecss' => 'marginleftonly btnTitleSelected')); - $newcardbutton .= dolGetButtonTitle($langs->trans('GroupByAccountAccounting'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT . '/accountancy/bookkeeping/listbyaccount.php?' . $param, '', 1, array('morecss' => 'marginleftonly')); + $newcardbutton .= dolGetButtonTitle($langs->trans('ViewFlatList'), '', 'fa fa-list paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?'.$param, '', 1, array('morecss' => 'marginleftonly btnTitleSelected')); + $newcardbutton .= dolGetButtonTitle($langs->trans('GroupByAccountAccounting'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php?'.$param, '', 1, array('morecss' => 'marginleftonly')); $url = './card.php?action=create'; - if (!empty($socid)) $url .= '&socid=' . $socid; + if (!empty($socid)) $url .= '&socid='.$socid; $newcardbutton .= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', $url, '', $user->rights->accounting->mouvements->creer); } diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index 80d8b4961c8..18661f8a887 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -379,12 +379,12 @@ print ''; $parameters = array(); $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) { - $newcardbutton = dolGetButtonTitle($langs->trans('ViewFlatList'), '', 'fa fa-list paddingleft imgforviewmode', DOL_URL_ROOT . '/accountancy/bookkeeping/list.php?' . $param); - $newcardbutton .= dolGetButtonTitle($langs->trans('VueByAccountAccounting'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT . '/accountancy/bookkeeping/listbyaccount.php?' . $param, '', 1, array('morecss' => 'marginleftonly btnTitleSelected')); + $newcardbutton = dolGetButtonTitle($langs->trans('ViewFlatList'), '', 'fa fa-list paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?'.$param); + $newcardbutton .= dolGetButtonTitle($langs->trans('VueByAccountAccounting'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php?'.$param, '', 1, array('morecss' => 'marginleftonly btnTitleSelected')); $newcardbutton .= '   '; - $newcardbutton .= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', DOL_URL_ROOT . '/accountancy/bookkeeping/card.php?action=create'); + $newcardbutton .= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?action=create'); } if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); diff --git a/htdocs/accountancy/bookkeeping/listbysubaccount.php b/htdocs/accountancy/bookkeeping/listbysubaccount.php index 0a70034aaa6..3bc0351b09b 100644 --- a/htdocs/accountancy/bookkeeping/listbysubaccount.php +++ b/htdocs/accountancy/bookkeeping/listbysubaccount.php @@ -380,8 +380,8 @@ print ''; $parameters = array(); $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) { - $newcardbutton = dolGetButtonTitle($langs->trans('ViewAccountList'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT . '/accountancy/bookkeeping/listbyaccount.php', '', 1, array('morecss' => 'marginleftonly btnTitleSelected')); - $newcardbutton .= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', DOL_URL_ROOT . '/accountancy/bookkeeping/card.php?action=create'); + $newcardbutton = dolGetButtonTitle($langs->trans('ViewAccountList'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php', '', 1, array('morecss' => 'marginleftonly btnTitleSelected')); + $newcardbutton .= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?action=create'); } if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index 51e66f3360c..3423f096794 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -57,8 +57,8 @@ class AccountancyExport public static $EXPORT_TYPE_OPENCONCERTO = 100; public static $EXPORT_TYPE_LDCOMPTA = 110; public static $EXPORT_TYPE_LDCOMPTA10 = 120; - public static $EXPORT_TYPE_GESTINUMV3 = 130; - public static $EXPORT_TYPE_GESTINUMV5 = 135; + public static $EXPORT_TYPE_GESTINUMV3 = 130; + public static $EXPORT_TYPE_GESTINUMV5 = 135; public static $EXPORT_TYPE_FEC = 1000; @@ -115,11 +115,11 @@ class AccountancyExport self::$EXPORT_TYPE_AGIRIS => $langs->trans('Modelcsv_agiris'), self::$EXPORT_TYPE_OPENCONCERTO => $langs->trans('Modelcsv_openconcerto'), self::$EXPORT_TYPE_SAGE50_SWISS => $langs->trans('Modelcsv_Sage50_Swiss'), - self::$EXPORT_TYPE_CHARLEMAGNE => $langs->trans('Modelcsv_charlemagne'), + self::$EXPORT_TYPE_CHARLEMAGNE => $langs->trans('Modelcsv_charlemagne'), self::$EXPORT_TYPE_LDCOMPTA => $langs->trans('Modelcsv_LDCompta'), self::$EXPORT_TYPE_LDCOMPTA10 => $langs->trans('Modelcsv_LDCompta10'), - self::$EXPORT_TYPE_GESTINUMV3 => $langs->trans('Modelcsv_Gestinum_v3'), - self::$EXPORT_TYPE_GESTINUMV5 => $langs->trans('Modelcsv_Gestinum_v5'), + self::$EXPORT_TYPE_GESTINUMV3 => $langs->trans('Modelcsv_Gestinum_v3'), + self::$EXPORT_TYPE_GESTINUMV5 => $langs->trans('Modelcsv_Gestinum_v5'), self::$EXPORT_TYPE_FEC => $langs->trans('Modelcsv_FEC'), ); @@ -148,12 +148,12 @@ class AccountancyExport self::$EXPORT_TYPE_COGILOG => 'cogilog', self::$EXPORT_TYPE_AGIRIS => 'agiris', self::$EXPORT_TYPE_OPENCONCERTO => 'openconcerto', - self::$EXPORT_TYPE_SAGE50_SWISS => 'sage50ch', - self::$EXPORT_TYPE_CHARLEMAGNE => 'charlemagne', - self::$EXPORT_TYPE_LDCOMPTA => 'ldcompta', - self::$EXPORT_TYPE_LDCOMPTA10 => 'ldcompta10', - self::$EXPORT_TYPE_GESTINUMV3 => 'gestinumv3', - self::$EXPORT_TYPE_GESTINUMV5 => 'gestinumv5', + self::$EXPORT_TYPE_SAGE50_SWISS => 'sage50ch', + self::$EXPORT_TYPE_CHARLEMAGNE => 'charlemagne', + self::$EXPORT_TYPE_LDCOMPTA => 'ldcompta', + self::$EXPORT_TYPE_LDCOMPTA10 => 'ldcompta10', + self::$EXPORT_TYPE_GESTINUMV3 => 'gestinumv3', + self::$EXPORT_TYPE_GESTINUMV5 => 'gestinumv5', self::$EXPORT_TYPE_FEC => 'fec', ); @@ -208,9 +208,9 @@ class AccountancyExport self::$EXPORT_TYPE_AGIRIS => array( 'label' => $langs->trans('Modelcsv_agiris'), ), - self::$EXPORT_TYPE_OPENCONCERTO => array( - 'label' => $langs->trans('Modelcsv_openconcerto'), - ), + self::$EXPORT_TYPE_OPENCONCERTO => array( + 'label' => $langs->trans('Modelcsv_openconcerto'), + ), self::$EXPORT_TYPE_SAGE50_SWISS => array( 'label' => $langs->trans('Modelcsv_Sage50_Swiss'), ), @@ -218,18 +218,18 @@ class AccountancyExport 'label' => $langs->trans('Modelcsv_charlemagne'), 'ACCOUNTING_EXPORT_FORMAT' => 'txt', ), - self::$EXPORT_TYPE_LDCOMPTA => array( - 'label' => $langs->trans('Modelcsv_LDCompta'), - ), + self::$EXPORT_TYPE_LDCOMPTA => array( + 'label' => $langs->trans('Modelcsv_LDCompta'), + ), self::$EXPORT_TYPE_LDCOMPTA10 => array( - 'label' => $langs->trans('Modelcsv_LDCompta10'), - ), - self::$EXPORT_TYPE_GESTINUMV3 => array( - 'label' => $langs->trans('Modelcsv_Gestinumv3'), - ), - self::$EXPORT_TYPE_GESTINUMV5 => array( - 'label' => $langs->trans('Modelcsv_Gestinumv5'), - ), + 'label' => $langs->trans('Modelcsv_LDCompta10'), + ), + self::$EXPORT_TYPE_GESTINUMV3 => array( + 'label' => $langs->trans('Modelcsv_Gestinumv3'), + ), + self::$EXPORT_TYPE_GESTINUMV5 => array( + 'label' => $langs->trans('Modelcsv_Gestinumv5'), + ), self::$EXPORT_TYPE_FEC => array( 'label' => $langs->trans('Modelcsv_FEC'), 'ACCOUNTING_EXPORT_FORMAT' => 'txt', @@ -307,21 +307,21 @@ class AccountancyExport case self::$EXPORT_TYPE_CHARLEMAGNE : $this->exportCharlemagne($TData); break; - case self::$EXPORT_TYPE_LDCOMPTA : - $this->exportLDCompta($TData); - break; - case self::$EXPORT_TYPE_LDCOMPTA10 : - $this->exportLDCompta10($TData); - break; - case self::$EXPORT_TYPE_GESTINUMV3 : - $this->exportGestimumV3($TData); - break; - case self::$EXPORT_TYPE_GESTINUMV5 : - $this->exportGestimumV5($TData); - break; - case self::$EXPORT_TYPE_FEC : - $this->exportFEC($TData); - break; + case self::$EXPORT_TYPE_LDCOMPTA : + $this->exportLDCompta($TData); + break; + case self::$EXPORT_TYPE_LDCOMPTA10 : + $this->exportLDCompta10($TData); + break; + case self::$EXPORT_TYPE_GESTINUMV3 : + $this->exportGestimumV3($TData); + break; + case self::$EXPORT_TYPE_GESTINUMV5 : + $this->exportGestimumV5($TData); + break; + case self::$EXPORT_TYPE_FEC : + $this->exportFEC($TData); + break; default: $this->errors[] = $langs->trans('accountancy_error_modelnotfound'); break; @@ -1484,136 +1484,136 @@ class AccountancyExport } } - /** - * Export format : Gestimum V3 - * - * @param array $objectLines data - * - * @return void - */ - public function exportGestimumV3($objectLines) + /** + * Export format : Gestimum V3 + * + * @param array $objectLines data + * + * @return void + */ + public function exportGestimumV3($objectLines) { - global $langs; + global $langs; - $this->separator = ','; + $this->separator = ','; - $invoices_infos = array(); - $supplier_invoices_infos = array(); - foreach ($objectLines as $line) { - $date = dol_print_date($line->doc_date, '%d/%m/%Y'); + $invoices_infos = array(); + $supplier_invoices_infos = array(); + foreach ($objectLines as $line) { + $date = dol_print_date($line->doc_date, '%d/%m/%Y'); - $invoice_ref = $line->doc_ref; - $company_name = ""; + $invoice_ref = $line->doc_ref; + $company_name = ""; - if (($line->doc_type == 'customer_invoice' || $line->doc_type == 'supplier_invoice') && $line->fk_doc > 0) { - if (($line->doc_type == 'customer_invoice' && !isset($invoices_infos[$line->fk_doc])) || - ($line->doc_type == 'supplier_invoice' && !isset($supplier_invoices_infos[$line->fk_doc]))) { - if ($line->doc_type == 'customer_invoice') { - // Get new customer invoice ref and company name - $sql = 'SELECT f.facnumber, s.nom FROM ' . MAIN_DB_PREFIX . 'facture as f'; - $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'societe AS s ON f.fk_soc = s.rowid'; - $sql .= ' WHERE f.rowid = ' . $line->fk_doc; - $resql = $this->db->query($sql); - if ($resql) { - if ($obj = $this->db->fetch_object($resql)) { - // Save invoice infos - $invoices_infos[$line->fk_doc] = array('ref' => $obj->facnumber, 'company_name' => $obj->nom); - $invoice_ref = $obj->facnumber; - $company_name = $obj->nom; - } - } - } else { - // Get new supplier invoice ref and company name - $sql = 'SELECT ff.ref, s.nom FROM ' . MAIN_DB_PREFIX . 'facture_fourn as ff'; - $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'societe AS s ON ff.fk_soc = s.rowid'; - $sql .= ' WHERE ff.rowid = ' . $line->fk_doc; - $resql = $this->db->query($sql); - if ($resql) { - if ($obj = $this->db->fetch_object($resql)) { - // Save invoice infos - $supplier_invoices_infos[$line->fk_doc] = array('ref' => $obj->ref, 'company_name' => $obj->nom); - $invoice_ref = $obj->ref; - $company_name = $obj->nom; - } - } - } - } elseif ($line->doc_type == 'customer_invoice') { - // Retrieve invoice infos - $invoice_ref = $invoices_infos[$line->fk_doc]['ref']; - $company_name = $invoices_infos[$line->fk_doc]['company_name']; - } else { - // Retrieve invoice infos - $invoice_ref = $supplier_invoices_infos[$line->fk_doc]['ref']; - $company_name = $supplier_invoices_infos[$line->fk_doc]['company_name']; - } - } + if (($line->doc_type == 'customer_invoice' || $line->doc_type == 'supplier_invoice') && $line->fk_doc > 0) { + if (($line->doc_type == 'customer_invoice' && !isset($invoices_infos[$line->fk_doc])) || + ($line->doc_type == 'supplier_invoice' && !isset($supplier_invoices_infos[$line->fk_doc]))) { + if ($line->doc_type == 'customer_invoice') { + // Get new customer invoice ref and company name + $sql = 'SELECT f.facnumber, s.nom FROM ' . MAIN_DB_PREFIX . 'facture as f'; + $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'societe AS s ON f.fk_soc = s.rowid'; + $sql .= ' WHERE f.rowid = ' . $line->fk_doc; + $resql = $this->db->query($sql); + if ($resql) { + if ($obj = $this->db->fetch_object($resql)) { + // Save invoice infos + $invoices_infos[$line->fk_doc] = array('ref' => $obj->facnumber, 'company_name' => $obj->nom); + $invoice_ref = $obj->facnumber; + $company_name = $obj->nom; + } + } + } else { + // Get new supplier invoice ref and company name + $sql = 'SELECT ff.ref, s.nom FROM ' . MAIN_DB_PREFIX . 'facture_fourn as ff'; + $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'societe AS s ON ff.fk_soc = s.rowid'; + $sql .= ' WHERE ff.rowid = ' . $line->fk_doc; + $resql = $this->db->query($sql); + if ($resql) { + if ($obj = $this->db->fetch_object($resql)) { + // Save invoice infos + $supplier_invoices_infos[$line->fk_doc] = array('ref' => $obj->ref, 'company_name' => $obj->nom); + $invoice_ref = $obj->ref; + $company_name = $obj->nom; + } + } + } + } elseif ($line->doc_type == 'customer_invoice') { + // Retrieve invoice infos + $invoice_ref = $invoices_infos[$line->fk_doc]['ref']; + $company_name = $invoices_infos[$line->fk_doc]['company_name']; + } else { + // Retrieve invoice infos + $invoice_ref = $supplier_invoices_infos[$line->fk_doc]['ref']; + $company_name = $supplier_invoices_infos[$line->fk_doc]['company_name']; + } + } - print $line->id . $this->separator; - print $date . $this->separator; - print substr($line->code_journal, 0, 4) . $this->separator; + print $line->id . $this->separator; + print $date . $this->separator; + print substr($line->code_journal, 0, 4) . $this->separator; - if ((substr($line->numero_compte, 0, 3) == '411') || (substr($line->numero_compte, 0, 3) == '401')) { - print length_accountg($line->subledger_account) . $this->separator; - } else { - print substr(length_accountg($line->numero_compte), 0, 15) . $this->separator; - } - //Libellé Auto - print $this->separator; - //print '"'.dol_trunc(str_replace('"', '', $line->label_operation),40,'right','UTF-8',1).'"' . $this->separator; - //Libellé manuel - print dol_trunc(str_replace('"', '', $invoice_ref . (!empty($company_name) ? ' - ' : '') . $company_name), 40, 'right', 'UTF-8', 1) . $this->separator; - //Numéro de pièce - print dol_trunc(str_replace('"', '', $line->piece_num), 10, 'right', 'UTF-8', 1) . $this->separator; - //Devise - print 'EUR' . $this->separator; - //Montant - print price2num(abs($line->montant)) . $this->separator; - //Sens - print $line->sens . $this->separator; - //Code lettrage - print $this->separator; - //Date Echéance - print $date; - print $this->end_line; - } - } + if ((substr($line->numero_compte, 0, 3) == '411') || (substr($line->numero_compte, 0, 3) == '401')) { + print length_accountg($line->subledger_account) . $this->separator; + } else { + print substr(length_accountg($line->numero_compte), 0, 15) . $this->separator; + } + //Libellé Auto + print $this->separator; + //print '"'.dol_trunc(str_replace('"', '', $line->label_operation),40,'right','UTF-8',1).'"' . $this->separator; + //Libellé manuel + print dol_trunc(str_replace('"', '', $invoice_ref . (!empty($company_name) ? ' - ' : '') . $company_name), 40, 'right', 'UTF-8', 1) . $this->separator; + //Numéro de pièce + print dol_trunc(str_replace('"', '', $line->piece_num), 10, 'right', 'UTF-8', 1) . $this->separator; + //Devise + print 'EUR' . $this->separator; + //Montant + print price2num(abs($line->montant)) . $this->separator; + //Sens + print $line->sens . $this->separator; + //Code lettrage + print $this->separator; + //Date Echéance + print $date; + print $this->end_line; + } + } - /** - * Export format : Gestimum V5 - * - * @param array $objectLines data - * - * @return void - */ - public function exportGestimumV5($objectLines) + /** + * Export format : Gestimum V5 + * + * @param array $objectLines data + * + * @return void + */ + public function exportGestimumV5($objectLines) { - $this->separator = ','; + $this->separator = ','; - foreach ($objectLines as $line) { - $date = dol_print_date($line->doc_date, '%d%m%Y'); + foreach ($objectLines as $line) { + $date = dol_print_date($line->doc_date, '%d%m%Y'); - print $line->id . $this->separator; - print $date . $this->separator; - print substr($line->code_journal, 0, 4) . $this->separator; - if ((substr($line->numero_compte, 0, 3) == '411') || (substr($line->numero_compte, 0, 3) == '401')) { - print length_accountg($line->subledger_account) . $this->separator; - } else { - print substr(length_accountg($line->numero_compte), 0, 15) . $this->separator; - } - print $this->separator; - //print '"'.dol_trunc(str_replace('"', '', $line->label_operation),40,'right','UTF-8',1).'"' . $this->separator; - print '"'.dol_trunc(str_replace('"', '', $line->doc_ref), 40, 'right', 'UTF-8', 1).'"' . $this->separator; - print '"'.dol_trunc(str_replace('"', '', $line->piece_num), 10, 'right', 'UTF-8', 1).'"'.$this->separator; - print price2num($line->montant).$this->separator; - print $line->sens.$this->separator; - print $date . $this->separator; - print $this->separator; - print $this->separator; - print 'EUR'; - print $this->end_line; - } - } + print $line->id . $this->separator; + print $date . $this->separator; + print substr($line->code_journal, 0, 4) . $this->separator; + if ((substr($line->numero_compte, 0, 3) == '411') || (substr($line->numero_compte, 0, 3) == '401')) { + print length_accountg($line->subledger_account) . $this->separator; + } else { + print substr(length_accountg($line->numero_compte), 0, 15) . $this->separator; + } + print $this->separator; + //print '"'.dol_trunc(str_replace('"', '', $line->label_operation),40,'right','UTF-8',1).'"' . $this->separator; + print '"'.dol_trunc(str_replace('"', '', $line->doc_ref), 40, 'right', 'UTF-8', 1).'"' . $this->separator; + print '"'.dol_trunc(str_replace('"', '', $line->piece_num), 10, 'right', 'UTF-8', 1).'"'.$this->separator; + print price2num($line->montant).$this->separator; + print $line->sens.$this->separator; + print $date . $this->separator; + print $this->separator; + print $this->separator; + print 'EUR'; + print $this->end_line; + } + } /** * trunc diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index 4e1a64cd20c..0acb4e0bedd 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -437,13 +437,15 @@ if ($result) { // Get thirdparty $tmppayment->fetch($links[$key]['url_id']); $arrayofamounts = $tmppayment->getAmountsArray(); - foreach ($arrayofamounts as $invoiceid => $amount) - { - $tmpinvoice->fetch($invoiceid); - $tmpinvoice->fetch_thirdparty(); - if ($tmpinvoice->thirdparty->code_compta) + if (is_array($arrayofamounts)) { + foreach ($arrayofamounts as $invoiceid => $amount) { - $tabtp[$obj->rowid][$tmpinvoice->thirdparty->code_compta] += $amount; + $tmpinvoice->fetch($invoiceid); + $tmpinvoice->fetch_thirdparty(); + if ($tmpinvoice->thirdparty->code_compta) + { + $tabtp[$obj->rowid][$tmpinvoice->thirdparty->code_compta] += $amount; + } } } } diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index b1331cd1dc7..9f44e02aafa 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -621,18 +621,18 @@ if ($action == 'exportcsv') { // ISO and not UTF8 ! foreach ($arrayofvat[$key] as $k => $mt) { if ($mt) { - print '"' . $key . '"' . $sep; - print '"' . $date . '"' . $sep; - print '"' . $val["ref"] . '"' . $sep; - print '"' . utf8_decode(dol_trunc($companystatic->name, 32)) . '"' . $sep; - print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; - print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; - print '""' . $sep; - print '"' . $langs->trans("VAT") . ' - ' . join(', ', $def_tva[$key][$k]) . ' %"' . $sep; - print '"' . utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT") . join(', ', $def_tva[$key][$k]) . ' %' . ($numtax ? ' - Localtax ' . $numtax : '') . '"' . $sep; - print '"' . ($mt < 0 ? price(-$mt) : '') . '"' . $sep; - print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep; - print '"' . $journal . '"'; + print '"'.$key.'"'.$sep; + print '"'.$date.'"'.$sep; + print '"'.$val["ref"].'"'.$sep; + print '"'.utf8_decode(dol_trunc($companystatic->name, 32)).'"'.$sep; + print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; + print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; + print '""'.$sep; + print '"'.$langs->trans("VAT").' - '.join(', ', $def_tva[$key][$k]).' %"'.$sep; + print '"'.utf8_decode(dol_trunc($companystatic->name, 16)).' - '.$invoicestatic->ref.' - '.$langs->trans("VAT").join(', ', $def_tva[$key][$k]).' %'.($numtax ? ' - Localtax '.$numtax : '').'"'.$sep; + print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep; + print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; + print '"'.$journal.'"'; print "\n"; } } diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index beed55a4130..8a417765965 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -382,14 +382,12 @@ if (empty($reshook)) { if ($action == 'add' && $user->rights->adherent->creer) { if ($canvas) $object->canvas = $canvas; $birthdate = ''; - if (isset($_POST["birthday"]) && $_POST["birthday"] - && isset($_POST["birthmonth"]) && $_POST["birthmonth"] - && isset($_POST["birthyear"]) && $_POST["birthyear"]) { - $birthdate = dol_mktime(12, 0, 0, $_POST["birthmonth"], $_POST["birthday"], $_POST["birthyear"]); + if (GETPOSTISSET("birthday") && GETPOST("birthday") && GETPOSTISSET("birthmonth") && GETPOST("birthmonth") && GETPOSTISSET("birthyear") && GETPOST("birthyear")) { + $birthdate = dol_mktime(12, 0, 0, GETPOST("birthmonth", 'int'), GETPOST("birthday", 'int'), GETPOST("birthyear", 'int')); } $datesubscription = ''; - if (isset($_POST["reday"]) && isset($_POST["remonth"]) && isset($_POST["reyear"])) { - $datesubscription = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); + if (GETPOSTISSET("reday") && GETPOSTISSET("remonth") && GETPOSTISSET("reyear")) { + $datesubscription = dol_mktime(12, 0, 0, GETPOST("remonth", 'int'), GETPOST("reday", "int"), GETPOST("reyear", "int")); } $typeid = GETPOST("typeid", 'int'); @@ -1075,7 +1073,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { // Password if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { - print ''.$langs->trans("Password").'pass).'">'; + print ''.$langs->trans("Password").'pass).'">'; } // Morphy $morphys["phy"] = $langs->trans("Physical"); @@ -1134,7 +1132,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { // EMail print ''.($conf->global->ADHERENT_MAIL_REQUIRED ? '' : '').$langs->trans("EMail").($conf->global->ADHERENT_MAIL_REQUIRED ? '' : '').''; - print ''.img_picto('', 'object_email').' email).'">'; + print ''.img_picto('', 'object_email').' email).'">'; // Address print ''.$langs->trans("Address").''; @@ -1151,14 +1149,14 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { // Country //$object->country_id=$object->country_id?$object->country_id:$mysoc->country_id; // In edit mode we don't force to company country if not defined print ''.$langs->trans('Country').''; - print $form->select_country(isset($_POST["country_id"]) ? $_POST["country_id"] : $object->country_id, 'country_id'); + print $form->select_country(GETPOSTISSET("country_id") ? GETPOST("country_id", "alpha") : $object->country_id, 'country_id'); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); print ''; // State if (empty($conf->global->MEMBER_DISABLE_STATE)) { print ''.$langs->trans('State').''; - print $formcompany->select_state($object->state_id, isset($_POST["country_id"]) ?GETPOST("country_id") : $object->country_id); + print $formcompany->select_state($object->state_id, GETPOSTISSET("country_id") ? GETPOST("country_id", "alpha") : $object->country_id); print ''; } diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 6254e596b60..2637612acc0 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -79,8 +79,8 @@ class Adherent extends CommonObject public $pass; /** - * @var string Clear password in database (defined if DATABASE_PWD_ENCRYPTED=0) - */ + * @var string Clear password in database (defined if DATABASE_PWD_ENCRYPTED=0) + */ public $pass_indatabase; /** @@ -103,6 +103,7 @@ class Adherent extends CommonObject * @var int Thirdparty ID */ public $fk_soc; + public $socid; /** * @var string Address @@ -1273,14 +1274,15 @@ class Adherent extends CommonObject $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as dep ON d.state_id = dep.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON d.rowid = u.fk_member"; $sql .= " WHERE d.fk_adherent_type = t.rowid"; - if ($rowid) - $sql .= " AND d.rowid=".$rowid; - elseif ($ref || $fk_soc) { + if ($rowid) { + $sql .= " AND d.rowid=".((int) $rowid); + } elseif ($ref || $fk_soc) { $sql .= " AND d.entity IN (".getEntity('adherent').")"; - if ($ref) + if ($ref) { $sql .= " AND d.ref='".$this->db->escape($ref)."'"; - elseif ($fk_soc > 0) - $sql .= " AND d.fk_soc=".$fk_soc; + } elseif ($fk_soc > 0) { + $sql .= " AND d.fk_soc=".((int) $fk_soc); + } } elseif ($ref_ext) { $sql .= " AND d.ref_ext='".$this->db->escape($ref_ext)."'"; } diff --git a/htdocs/adherents/class/subscription.class.php b/htdocs/adherents/class/subscription.class.php index aebd48963d2..b6349bf9dc2 100644 --- a/htdocs/adherents/class/subscription.class.php +++ b/htdocs/adherents/class/subscription.class.php @@ -250,11 +250,16 @@ class Subscription extends CommonObject $this->db->begin(); + if (!is_numeric($this->amount)) { + $this->error = 'BadValueForParameterAmount'; + return -1; + } + $sql = "UPDATE ".MAIN_DB_PREFIX."subscription SET "; $sql .= " fk_type = ".$this->fk_type.","; $sql .= " fk_adherent = ".$this->fk_adherent.","; $sql .= " note=".($this->note ? "'".$this->db->escape($this->note)."'" : 'null').","; - $sql .= " subscription = '".price2num($this->amount)."',"; + $sql .= " subscription = ".price2num($this->amount).","; $sql .= " dateadh='".$this->db->idate($this->dateh)."',"; $sql .= " datef='".$this->db->idate($this->datef)."',"; $sql .= " datec='".$this->db->idate($this->datec)."',"; diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index 611542b8ebc..1c4e42da1fe 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -333,7 +333,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && ! $listofpaths = array(); $listofnames = array(); $listofmimes = array(); - if (is_object($object->invoice)) { + if (is_object($object->invoice) && (!is_object($arraydefaultmessage) || intval($arraydefaultmessage->joinfiles))) { $invoicediroutput = $conf->facture->dir_output; $fileparams = dol_most_recent_file($invoicediroutput.'/'.$object->invoice->ref, preg_quote($object->invoice->ref, '/').'[^\-]+'); $file = $fileparams['fullname']; diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index d3b918b9849..e9e6be408c8 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -719,7 +719,7 @@ if ($rowid > 0) { print ''.$langs->trans("Ref").''.$object->id.''; - print ''.$langs->trans("Label").''; + print ''.$langs->trans("Label").''; print ''.$langs->trans("Status").''; print $form->selectarray('status', array('0'=>$langs->trans('ActivityCeased'), '1'=>$langs->trans('InActivity')), $object->status); diff --git a/htdocs/adherents/type_translation.php b/htdocs/adherents/type_translation.php index e661bde6ea7..f2c3b785160 100644 --- a/htdocs/adherents/type_translation.php +++ b/htdocs/adherents/type_translation.php @@ -37,6 +37,7 @@ $langs->loadLangs(array('members', 'languages')); $id = GETPOST('rowid', 'int'); $action = GETPOST('action', 'aZ09'); $cancel = GETPOST('cancel', 'alpha'); +$ref = GETPOST('ref', 'alphanohtml'); // Security check $fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : '')); @@ -67,15 +68,17 @@ if ($action == 'vadd' && $cancel != $langs->trans("Cancel") && $user->rights->ad $object->fetch($id); $current_lang = $langs->getDefaultLang(); + $forcelangprod = GETPOST("forcelangprod", 'aZ09'); + // update of object - if ($_POST["forcelangprod"] == $current_lang) { - $object->label = $_POST["libelle"]; - $object->description = dol_htmlcleanlastbr($_POST["desc"]); - $object->other = dol_htmlcleanlastbr($_POST["other"]); + if ($forcelangprod == $current_lang) { + $object->label = GETPOST("libelle", 'alphanohtml'); + $object->description = dol_htmlcleanlastbr(GETPOST("desc", 'restricthtml')); + $object->other = dol_htmlcleanlastbr(GETPOST("other", 'restricthtml')); } else { - $object->multilangs[$_POST["forcelangprod"]]["label"] = $_POST["libelle"]; - $object->multilangs[$_POST["forcelangprod"]]["description"] = dol_htmlcleanlastbr($_POST["desc"]); - $object->multilangs[$_POST["forcelangprod"]]["other"] = dol_htmlcleanlastbr($_POST["other"]); + $object->multilangs[$forcelangprod]["label"] = GETPOST("libelle", 'alphanohtml'); + $object->multilangs[$forcelangprod]["description"] = dol_htmlcleanlastbr(GETPOST("desc", 'restricthtml')); + $object->multilangs[$forcelangprod]["other"] = dol_htmlcleanlastbr(GETPOST("other", 'restricthtml')); } // backup into database @@ -95,13 +98,13 @@ if ($action == 'vedit' && $cancel != $langs->trans("Cancel") && $user->rights->a foreach ($object->multilangs as $key => $value) { // saving new values in the object if ($key == $current_lang) { - $object->label = $_POST["libelle-".$key]; - $object->description = dol_htmlcleanlastbr($_POST["desc-".$key]); - $object->other = dol_htmlcleanlastbr($_POST["other-".$key]); + $object->label = GETPOST("libelle-".$key, 'alphanohtml'); + $object->description = dol_htmlcleanlastbr(GETPOST("desc-".$key, 'restricthtml')); + $object->other = dol_htmlcleanlastbr(GETPOST("other-".$key, 'restricthtml')); } else { - $object->multilangs[$key]["label"] = $_POST["libelle-".$key]; - $object->multilangs[$key]["description"] = dol_htmlcleanlastbr($_POST["desc-".$key]); - $object->multilangs[$key]["other"] = dol_htmlcleanlastbr($_POST["other-".$key]); + $object->multilangs[$key]["label"] = GETPOST("libelle-".$key, 'alphanohtml'); + $object->multilangs[$key]["description"] = dol_htmlcleanlastbr(GETPOST("desc-".$key, 'restricthtml')); + $object->multilangs[$key]["other"] = dol_htmlcleanlastbr(GETPOST("other-".$key, 'restricthtml')); } } @@ -205,7 +208,7 @@ if ($action == 'edit') { print '
'; print ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; print ''; print "\n"; diff --git a/htdocs/admin/bank.php b/htdocs/admin/bank.php index 88babe27385..d21ffdb1630 100644 --- a/htdocs/admin/bank.php +++ b/htdocs/admin/bank.php @@ -391,7 +391,7 @@ foreach ($dirmodels as $reldir) { // Preview print ''."\n"; @@ -412,7 +414,7 @@ foreach ($dirmodels as $reldir) print ''."\n"; diff --git a/htdocs/admin/commande.php b/htdocs/admin/commande.php index 594052500ca..25a220e8e2d 100644 --- a/htdocs/admin/commande.php +++ b/htdocs/admin/commande.php @@ -297,8 +297,10 @@ foreach ($dirmodels as $reldir) // Show example of numbering model print ''."\n"; @@ -482,7 +484,7 @@ foreach ($dirmodels as $reldir) print ''."\n"; +// Zip print ''."\n"; +print ''."\n"; print ''."\n"; +print ''."\n"; // Country print ''."\n"; @@ -410,7 +414,7 @@ foreach ($dirmodels as $reldir) print ''."\n"; @@ -397,7 +398,7 @@ foreach ($dirmodels as $reldir) print ''."\n"; @@ -414,7 +415,7 @@ foreach ($dirmodels as $reldir) print ''."\n"; @@ -409,7 +411,7 @@ foreach ($dirmodels as $reldir) print ''."\n"; @@ -547,7 +549,7 @@ foreach ($dirmodels as $reldir) print ''."\n"; @@ -465,7 +467,7 @@ foreach ($dirmodels as $reldir) print ''."\n"; @@ -423,7 +426,7 @@ foreach ($dirmodels as $reldir) print '
'.$langs->trans('Label').'
'.$langs->trans('Label').'
'.$langs->trans('Description').''; $doleditor = new DolEditor("desc-$key", $object->multilangs[$key]["description"], '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_3, '90%'); $doleditor->Create(); @@ -264,7 +267,7 @@ if ($action == 'add' && $user->rights->adherent->configurer) { print '
'.$langs->trans('Language').''; print $formadmin->select_language('', 'forcelangprod', 0, $object->multilangs, 1); print '
'.$langs->trans('Label').'
'.$langs->trans('Label').'
'.$langs->trans('Description').''; $doleditor = new DolEditor('desc', '', '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_3, '90%'); $doleditor->Create(); diff --git a/htdocs/admin/agenda_other.php b/htdocs/admin/agenda_other.php index 2ffbf15d7ce..c1f77f4995e 100644 --- a/htdocs/admin/agenda_other.php +++ b/htdocs/admin/agenda_other.php @@ -292,7 +292,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) print $form->textwithpicto('', $htmltooltip, 1, 0); print ''; - print ''.img_object($langs->trans("Preview"), 'order').''; + print ''.img_object($langs->trans("Preview"), 'pdf').''; print '
'; if ($module->type == 'pdf') { - print ''.img_object($langs->trans("Preview"), 'bill').''; + print ''.img_object($langs->trans("Preview"), 'pdf').''; } else { print img_object($langs->trans("PreviewNotAvailable"), 'generic'); } diff --git a/htdocs/admin/bom.php b/htdocs/admin/bom.php index db3bc348716..34c3af89c53 100644 --- a/htdocs/admin/bom.php +++ b/htdocs/admin/bom.php @@ -232,8 +232,10 @@ foreach ($dirmodels as $reldir) // Show example of numbering model print ''; $tmp = $module->getExample(); - if (preg_match('/^Error/', $tmp)) print '
'.$langs->trans($tmp).'
'; - elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); + if (preg_match('/^Error/', $tmp)) { + $langs->load("errors"); + print '
'.$langs->trans($tmp).'
'; + } elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); else print $tmp; print '
'; if ($module->type == 'pdf') { - print ''.img_object($langs->trans("Preview"), 'bill').''; + print ''.img_object($langs->trans("Preview"), 'pdf').''; } else { print img_object($langs->trans("PreviewNotAvailable"), 'generic'); } diff --git a/htdocs/admin/boxes.php b/htdocs/admin/boxes.php index 19450905c23..4fc1ad28da7 100644 --- a/htdocs/admin/boxes.php +++ b/htdocs/admin/boxes.php @@ -54,19 +54,18 @@ if ($action == 'addconst') if ($action == 'add') { $error = 0; + $boxids = GETPOST('boxid', 'array'); + $db->begin(); - if (isset($_POST['boxid']) && is_array($_POST['boxid'])) - { - foreach ($_POST['boxid'] as $boxid) - { + if (is_array($boxids)) { + foreach ($boxids as $boxid) { if (is_numeric($boxid['pos']) && $boxid['pos'] >= 0) // 0=Home, 1=... { $pos = $boxid['pos']; // Initialize distinct fk_user with all already existing values of fk_user (user that use a personalized view of boxes for page "pos") $distinctfkuser = array(); - if (!$error) - { + if (!$error) { $sql = "SELECT fk_user"; $sql .= " FROM ".MAIN_DB_PREFIX."user_param"; $sql .= " WHERE param = 'MAIN_BOXES_".$db->escape($pos)."' AND value = '1'"; @@ -146,7 +145,7 @@ if ($action == 'add') { if ($action == 'delete') { $sql = "SELECT box_id FROM ".MAIN_DB_PREFIX."boxes"; - $sql .= " WHERE rowid=".$rowid; + $sql .= " WHERE rowid=".((int) $rowid); $resql = $db->query($sql); $obj = $db->fetch_object($resql); diff --git a/htdocs/admin/chequereceipts.php b/htdocs/admin/chequereceipts.php index 4fee30d274e..8c2acb5dc8b 100644 --- a/htdocs/admin/chequereceipts.php +++ b/htdocs/admin/chequereceipts.php @@ -168,8 +168,10 @@ foreach ($dirmodels as $reldir) // Show example of numbering module print ''; $tmp = $module->getExample(); - if (preg_match('/^Error/', $tmp)) print '
'.$langs->trans($tmp).'
'; - elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); + if (preg_match('/^Error/', $tmp)) { + $langs->load("errors"); + print '
'.$langs->trans($tmp).'
'; + } elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); else print $tmp; print '
'; $tmp = $module->getExample(); - if (preg_match('/^Error/', $tmp)) print '
'.$langs->trans($tmp).'
'; - elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); + if (preg_match('/^Error/', $tmp)) { + $langs->load("errors"); + print '
'.$langs->trans($tmp).'
'; + } elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); else print $tmp; print '
'; if ($module->type == 'pdf') { - print ''.img_object($langs->trans("Preview"), 'bill').''; + print ''.img_object($langs->trans("Preview"), 'pdf').''; } else { print img_object($langs->trans("PreviewNotAvailable"), 'generic'); } diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index 8b900f552c8..75dcb9b179f 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -406,11 +406,12 @@ print ''; print '
'; -print '
'; -print '
'; diff --git a/htdocs/admin/contract.php b/htdocs/admin/contract.php index bfdff79cc1f..b5e4c0ddf45 100644 --- a/htdocs/admin/contract.php +++ b/htdocs/admin/contract.php @@ -229,7 +229,11 @@ foreach ($dirmodels as $reldir) // Show example of numbering model print ''; $tmp = $module->getExample(); - if (preg_match('/^Error/', $tmp)) { $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; } elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); + if (preg_match('/^Error/', $tmp)) { + $langs->load("errors"); + print '
'.$langs->trans($tmp).'
'; + } + elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); else print $tmp; print '
'; if ($module->type == 'pdf') { - print ''.img_object($langs->trans("Preview"), 'contract').''; + print ''.img_object($langs->trans("Preview"), 'pdf').''; } else { print img_object($langs->trans("PreviewNotAvailable"), 'generic'); } diff --git a/htdocs/admin/delais.php b/htdocs/admin/delais.php index 5ff7f022ba4..d605f75c511 100644 --- a/htdocs/admin/delais.php +++ b/htdocs/admin/delais.php @@ -188,7 +188,7 @@ if ($action == 'update') if (!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $plus = '_PERCENTAGE'; // Update values for ($i = 0; $i < 4; $i++) { - if (isset($_POST['MAIN_METEO'.$plus.'_LEVEL'.$i])) dolibarr_set_const($db, 'MAIN_METEO'.$plus.'_LEVEL'.$i, GETPOST('MAIN_METEO'.$plus.'_LEVEL'.$i, 'int'), 'chaine', 0, '', $conf->entity); + if (GETPOSTISSET('MAIN_METEO'.$plus.'_LEVEL'.$i)) dolibarr_set_const($db, 'MAIN_METEO'.$plus.'_LEVEL'.$i, GETPOST('MAIN_METEO'.$plus.'_LEVEL'.$i, 'int'), 'chaine', 0, '', $conf->entity); } } diff --git a/htdocs/admin/delivery.php b/htdocs/admin/delivery.php index d9c1b2ebe17..b1606268205 100644 --- a/htdocs/admin/delivery.php +++ b/htdocs/admin/delivery.php @@ -229,7 +229,8 @@ foreach ($dirmodels as $reldir) print ''; $tmp = $module->getExample(); if (preg_match('/^Error/', $tmp)) { - $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; + $langs->load("errors"); + print '
'.$langs->trans($tmp).'
'; } elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); else print $tmp; print '
'; if ($module->type == 'pdf') { - print ''.img_object($langs->trans("Preview"), 'sending').''; + print ''.img_object($langs->trans("Preview"), 'pdf').''; } else { print img_object($langs->trans("PreviewNotAvailable"), 'generic'); } diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index a185071c227..d06f8a2ce31 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -682,7 +682,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) { // Discard check of mandatory fields for country for some tables if ($value == 'country_id' && in_array($tablib[$id], array('DictionaryPublicHolidays', 'DictionaryVAT', 'DictionaryRegion', 'DictionaryCompanyType', 'DictionaryHolidayTypes', 'DictionaryRevenueStamp', 'DictionaryAccountancysystem', 'DictionaryAccountancyCategory'))) continue; // For some pages, country is not mandatory - if ($value == 'country' && in_array($tablib[$id], array('DictionaryPublicHolidays', 'DictionaryCanton', 'DictionaryCompanyType', 'DictionaryRevenueStamp'))) continue; // For some pages, country is not mandatory + if ($value == 'country' && in_array($tablib[$id], array('DictionaryPublicHolidays', 'DictionaryCanton', 'DictionaryCompanyType', 'DictionaryHolidayTypes', 'DictionaryRevenueStamp'))) continue; // For some pages, country is not mandatory // Discard check of mandatory fiedls for other fields if ($value == 'localtax1' && empty($_POST['localtax1_type'])) continue; if ($value == 'localtax2' && empty($_POST['localtax2_type'])) continue; @@ -690,7 +690,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) if ($value == 'formula' && empty($_POST['formula'])) continue; if ($value == 'dayrule' && empty($_POST['dayrule'])) continue; if ($value == 'sortorder') continue; // For a column name 'sortorder', we use the field name 'position' - if ((!isset($_POST[$value]) || $_POST[$value] == '') + if ((!GETPOSTISSET($value) || GETPOST($value) == '') && (!in_array($listfield[$f], array('decalage', 'module', 'accountancy_code', 'accountancy_code_sell', 'accountancy_code_buy', 'tracking', 'picto')) // Fields that are not mandatory && (!($id == 10 && $listfield[$f] == 'code')) // Code is mandatory fir table 10 ) @@ -719,7 +719,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) } } // Other checks - if (GETPOST('actionadd') && $tabname[$id] == MAIN_DB_PREFIX."c_actioncomm" && isset($_POST["type"]) && in_array($_POST["type"], array('system', 'systemauto'))) { + if (GETPOST('actionadd') && $tabname[$id] == MAIN_DB_PREFIX."c_actioncomm" && GETPOSTISSET("type") && in_array(GETPOST("type"), array('system', 'systemauto'))) { $ok = 0; setEventMessages($langs->transnoentities('ErrorReservedTypeSystemSystemAuto'), null, 'errors'); } @@ -757,7 +757,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) if ($_POST["accountancy_code"] <= 0) $_POST["accountancy_code"] = ''; // If empty, we force to null if ($_POST["accountancy_code_sell"] <= 0) $_POST["accountancy_code_sell"] = ''; // If empty, we force to null if ($_POST["accountancy_code_buy"] <= 0) $_POST["accountancy_code_buy"] = ''; // If empty, we force to null - if ($id == 10 && isset($_POST["code"])) // Spaces are not allowed into code + if ($id == 10 && GETPOSTISSET("code")) // Spaces are not allowed into code { $_POST["code"] = preg_replace('/\s/', '', $_POST["code"]); } diff --git a/htdocs/admin/emailcollector_card.php b/htdocs/admin/emailcollector_card.php index fd3361515fb..9e8b957d541 100644 --- a/htdocs/admin/emailcollector_card.php +++ b/htdocs/admin/emailcollector_card.php @@ -223,21 +223,6 @@ $help_url = "EN:Module_EMail_Collector|FR:Module_Collecteur_de_courrier_électro llxHeader('', 'EmailCollector', $help_url); -// Example : Adding jquery code -print ''; - // Part to create if ($action == 'create') { print load_fiche_titre($langs->trans("NewEmailCollector", $langs->transnoentitiesnoconv("EmailCollector"))); @@ -433,6 +418,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if (!$connection) { $morehtml .= 'Failed to open IMAP connection '.$connectstringsource; + $morehtml .= '
'.imap_last_error(); + //var_dump(imap_errors()) } else { $morehtml .= imap_num_msg($connection); } diff --git a/htdocs/admin/expedition.php b/htdocs/admin/expedition.php index b446851b539..9a09c62b818 100644 --- a/htdocs/admin/expedition.php +++ b/htdocs/admin/expedition.php @@ -234,7 +234,8 @@ foreach ($dirmodels as $reldir) print '
'; $tmp = $module->getExample(); if (preg_match('/^Error/', $tmp)) { - $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; + $langs->load("errors"); + print '
'.$langs->trans($tmp).'
'; } elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); else print $tmp; print '
'; if ($module->type == 'pdf') { - print 'scandir.'&label='.urlencode($module->name).'">'.img_object($langs->trans("Preview"), 'sending').''; + print 'scandir.'&label='.urlencode($module->name).'">'.img_object($langs->trans("Preview"), 'pdf').''; } else { print img_object($langs->trans("PreviewNotAvailable"), 'generic'); } diff --git a/htdocs/admin/expensereport.php b/htdocs/admin/expensereport.php index f572226c379..a93f5c3c608 100644 --- a/htdocs/admin/expensereport.php +++ b/htdocs/admin/expensereport.php @@ -238,8 +238,10 @@ foreach ($dirmodels as $reldir) // Show example of numbering model print ''; $tmp = $module->getExample(); - if (preg_match('/^Error/', $tmp)) print '
'.$langs->trans($tmp).'
'; - elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); + if (preg_match('/^Error/', $tmp)) { + $langs->load("errors"); + print '
'.$langs->trans($tmp).'
'; + } elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); else print $tmp; print '
'; if ($module->type == 'pdf') { - print ''.img_object($langs->trans("Preview"), 'intervention').''; + print ''.img_object($langs->trans("Preview"), 'pdf').''; } else { print img_object($langs->trans("PreviewNotAvailable"), 'generic'); } diff --git a/htdocs/admin/facture.php b/htdocs/admin/facture.php index 35dd1002b12..00dcb7c3180 100644 --- a/htdocs/admin/facture.php +++ b/htdocs/admin/facture.php @@ -313,8 +313,10 @@ foreach ($dirmodels as $reldir) // Show example of numbering module print ''; $tmp = $module->getExample(); - if (preg_match('/^Error/', $tmp)) print '
'.$langs->trans($tmp).'
'; - elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); + if (preg_match('/^Error/', $tmp)) { + $langs->load("errors"); + print '
'.$langs->trans($tmp).'
'; + } elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); else print $tmp; print '
'; if ($module->type == 'pdf') { - print ''.img_object($langs->trans("Preview"), 'bill').''; + print ''.img_object($langs->trans("Preview"), 'pdf').''; } else { print img_object($langs->trans("PreviewNotAvailable"), 'generic'); } diff --git a/htdocs/admin/fichinter.php b/htdocs/admin/fichinter.php index 64660b67365..e3178d946a0 100644 --- a/htdocs/admin/fichinter.php +++ b/htdocs/admin/fichinter.php @@ -291,8 +291,10 @@ foreach ($dirmodels as $reldir) // Show example of numbering model print ''; $tmp = $module->getExample(); - if (preg_match('/^Error/', $tmp)) print '
'.$langs->trans($tmp).'
'; - elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); + if (preg_match('/^Error/', $tmp)) { + $langs->load("errors"); + print '
'.$langs->trans($tmp).'
'; + } elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); else print $tmp; print '
'; if ($module->type == 'pdf') { - print ''.img_object($langs->trans("Preview"), 'intervention').''; + print ''.img_object($langs->trans("Preview"), 'pdf').''; } else { print img_object($langs->trans("PreviewNotAvailable"), 'generic'); } diff --git a/htdocs/admin/holiday.php b/htdocs/admin/holiday.php index be09a062703..eca8319d661 100644 --- a/htdocs/admin/holiday.php +++ b/htdocs/admin/holiday.php @@ -229,7 +229,10 @@ foreach ($dirmodels as $reldir) // Show example of numbering model print ''; $tmp = $module->getExample(); - if (preg_match('/^Error/', $tmp)) { $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; } elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); + if (preg_match('/^Error/', $tmp)) { + $langs->load("errors"); + print '
'.$langs->trans($tmp).'
'; + } elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); else print $tmp; print '
'; if ($module->type == 'pdf') { - print ''.img_object($langs->trans("Preview"), 'contract').''; + print ''.img_object($langs->trans("Preview"), 'pdf').''; } else { print img_object($langs->trans("PreviewNotAvailable"), 'generic'); } diff --git a/htdocs/admin/ihm.php b/htdocs/admin/ihm.php index ec6ab640125..ad2cd408471 100644 --- a/htdocs/admin/ihm.php +++ b/htdocs/admin/ihm.php @@ -241,8 +241,8 @@ print ''; clearstatcache(); print '
'; -print ''; -print ''; +print '
'.$langs->trans("Language").'
'; +print ''; print ''; // Default language diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php index a89480314a6..77f4d14dc77 100644 --- a/htdocs/admin/mails.php +++ b/htdocs/admin/mails.php @@ -178,6 +178,7 @@ if ($action == 'edit') jQuery("#MAIN_MAIL_EMAIL_DKIM_DOMAIN").prop("disabled", true); jQuery("#MAIN_MAIL_EMAIL_DKIM_SELECTOR").prop("disabled", true); jQuery("#MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").prop("disabled", true); + jQuery(".smtp_method").hide(); jQuery(".dkim").hide(); '; if ($linuxlike) @@ -191,7 +192,7 @@ if ($action == 'edit') print ' jQuery("#MAIN_MAIL_SMTP_SERVER").prop("disabled", true); jQuery("#MAIN_MAIL_SMTP_PORT").prop("disabled", true); - jQuery("#smtp_server_mess").hide(); + jQuery("#smtp_server_mess").hide(); jQuery("#smtp_port_mess").hide();'; } print ' @@ -220,7 +221,8 @@ if ($action == 'edit') jQuery("#MAIN_MAIL_SMTP_PORT").show(); jQuery("#smtp_server_mess").hide(); jQuery("#smtp_port_mess").hide(); - jQuery(".dkim").hide(); + jQuery(".smtp_method").show(); + jQuery(".dkim").hide(); } if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'swiftmailer\') { @@ -246,6 +248,7 @@ if ($action == 'edit') jQuery("#MAIN_MAIL_SMTP_PORT").show(); jQuery("#smtp_server_mess").hide(); jQuery("#smtp_port_mess").hide(); + jQuery(".smtp_method").show(); jQuery(".dkim").show(); } } @@ -318,13 +321,15 @@ if ($action == 'edit') print ''; // Host server - print ''; + if (!$conf->use_javascript_ajax && $linuxlike && $conf->global->MAIN_MAIL_SENDMODE == 'mail') { + print ''; } else { + print ''; } - print ''; + print ''; // Port print ''."\n"; @@ -413,7 +415,7 @@ foreach ($dirmodels as $reldir) print ''."\n"; diff --git a/htdocs/admin/paymentbybanktransfer.php b/htdocs/admin/paymentbybanktransfer.php index 0ea8db95aec..cd0db2a1def 100644 --- a/htdocs/admin/paymentbybanktransfer.php +++ b/htdocs/admin/paymentbybanktransfer.php @@ -340,7 +340,7 @@ foreach ($dirmodels as $reldir) print ''."\n"; @@ -442,7 +444,7 @@ foreach ($dirmodels as $reldir) print ''; print ''; print ''; print ''; diff --git a/htdocs/admin/receiptprinter.php b/htdocs/admin/receiptprinter.php index 73db1bfa040..3c878c5c664 100644 --- a/htdocs/admin/receiptprinter.php +++ b/htdocs/admin/receiptprinter.php @@ -420,7 +420,7 @@ if ($mode == 'template' && $user->admin) { print ''; } else { print ''; - print ''; + print ''; // edit icon print ''."\n"; @@ -423,7 +424,7 @@ foreach ($dirmodels as $reldir) print ''."\n"; diff --git a/htdocs/admin/stock.php b/htdocs/admin/stock.php index 134aeb663b4..031b0ef102f 100644 --- a/htdocs/admin/stock.php +++ b/htdocs/admin/stock.php @@ -638,7 +638,7 @@ foreach ($dirmodels as $reldir) print ''."\n"; @@ -425,7 +426,7 @@ foreach ($dirmodels as $reldir) print $form->textwithpicto('', $htmltooltip, 1, 0); print ''; print ''; print "\n"; diff --git a/htdocs/admin/supplier_order.php b/htdocs/admin/supplier_order.php index 60c2c4da56e..e2433c5348b 100644 --- a/htdocs/admin/supplier_order.php +++ b/htdocs/admin/supplier_order.php @@ -274,7 +274,8 @@ foreach ($dirmodels as $reldir) print ''."\n"; @@ -438,7 +439,7 @@ foreach ($dirmodels as $reldir) print $form->textwithpicto('', $htmltooltip, 1, 0); print ''; print ''; print "\n"; diff --git a/htdocs/admin/supplier_payment.php b/htdocs/admin/supplier_payment.php index 217b7d7c44a..3408496de31 100644 --- a/htdocs/admin/supplier_payment.php +++ b/htdocs/admin/supplier_payment.php @@ -256,8 +256,10 @@ foreach ($dirmodels as $reldir) // Show example of numbering module print ''."\n"; @@ -410,7 +412,7 @@ foreach ($dirmodels as $reldir) print $form->textwithpicto('', $htmltooltip, 1, 0); print ''; print ''; print "\n"; diff --git a/htdocs/admin/supplier_proposal.php b/htdocs/admin/supplier_proposal.php index 38a6d9e3ff5..0855a41cf8f 100644 --- a/htdocs/admin/supplier_proposal.php +++ b/htdocs/admin/supplier_proposal.php @@ -251,8 +251,10 @@ foreach ($dirmodels as $reldir) // Show example of numbering module print ''."\n"; @@ -435,7 +437,7 @@ foreach ($dirmodels as $reldir) print ''."\n"; print ''."\n"; print ''."\n"; diff --git a/htdocs/admin/system/phpinfo.php b/htdocs/admin/system/phpinfo.php index 78146b85a76..03f5c60f607 100644 --- a/htdocs/admin/system/phpinfo.php +++ b/htdocs/admin/system/phpinfo.php @@ -28,9 +28,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; -$langs->load("admin"); -$langs->load("install"); -$langs->load("errors"); +$langs->loadLangs(array("admin", "install", "errors")); if (!$user->admin) accessforbidden(); @@ -95,7 +93,7 @@ if (versioncompare(versionphparray(), $arrayphpminversionerror) < 0) print ''; print '
'.img_picto('', 'language').' '.$langs->trans("Language").'
'; - if (!$conf->use_javascript_ajax && $linuxlike && $conf->global->MAIN_MAIL_SENDMODE == 'mail') - { + print '
'; print $langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike"); print ''; print ''.$langs->trans("SeeLocalSendMailSetup").''; + print ''; $mainserver = (!empty($conf->global->MAIN_MAIL_SMTP_SERVER) ? $conf->global->MAIN_MAIL_SMTP_SERVER : ''); $smtpserver = ini_get('SMTP') ?ini_get('SMTP') : $langs->transnoentities("Undefined"); if ($linuxlike) print $langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike"); @@ -333,17 +338,19 @@ if ($action == 'edit') // SuperAdministrator access only if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity)) { - print ''; + print ''; print ''; print ''.$langs->trans("SeeLocalSendMailSetup").''; + print ' '.$langs->trans("SeeLinkToOnlineDocumentation").''; } else { $text = !empty($mainserver) ? $mainserver : $smtpserver; $htmltext = $langs->trans("ContactSuperAdminForChange"); print $form->textwithpicto($text, $htmltext, 1, 'superadmin'); print ''; } + print '
'; @@ -856,8 +863,8 @@ if ($action == 'edit') include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; $formmail = new FormMail($db); $formmail->trackid = (($action == 'testhtml') ? "testhtml" : "test"); - $formmail->fromname = (isset($_POST['fromname']) ? $_POST['fromname'] : $conf->global->MAIN_MAIL_EMAIL_FROM); - $formmail->frommail = (isset($_POST['frommail']) ? $_POST['frommail'] : $conf->global->MAIN_MAIL_EMAIL_FROM); + $formmail->fromname = (GETPOSTISSET('fromname') ? $_POST['fromname'] : $conf->global->MAIN_MAIL_EMAIL_FROM); + $formmail->frommail = (GETPOSTISSET('frommail') ? $_POST['frommail'] : $conf->global->MAIN_MAIL_EMAIL_FROM); $formmail->fromid = $user->id; $formmail->fromalsorobot = 1; $formmail->fromtype = (GETPOSTISSET('fromtype') ?GETPOST('fromtype', 'aZ09') : (!empty($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE) ? $conf->global->MAIN_MAIL_DEFAULT_FROMTYPE : 'user')); @@ -865,13 +872,13 @@ if ($action == 'edit') $formmail->withsubstit = 1; $formmail->withfrom = 1; $formmail->witherrorsto = 1; - $formmail->withto = (!empty($_POST['sendto']) ? $_POST['sendto'] : ($user->email ? $user->email : 1)); - $formmail->withtocc = (!empty($_POST['sendtocc']) ? $_POST['sendtocc'] : 1); // ! empty to keep field if empty - $formmail->withtoccc = (!empty($_POST['sendtoccc']) ? $_POST['sendtoccc'] : 1); // ! empty to keep field if empty - $formmail->withtopic = (isset($_POST['subject']) ? $_POST['subject'] : $langs->trans("Test")); + $formmail->withto = (!empty($_POST['sendto']) ? GETPOST('sendto', 'restricthtml') : ($user->email ? $user->email : 1)); + $formmail->withtocc = (!empty($_POST['sendtocc']) ? GETPOST('sendtocc', 'restricthtml') : 1); // ! empty to keep field if empty + $formmail->withtoccc = (!empty($_POST['sendtoccc']) ? GETPOST('sendtoccc', 'restricthtml') : 1); // ! empty to keep field if empty + $formmail->withtopic = (GETPOSTISSET('subject') ? GETPOST('subject') : $langs->trans("Test")); $formmail->withtopicreadonly = 0; $formmail->withfile = 2; - $formmail->withbody = (isset($_POST['message']) ? $_POST['message'] : ($action == 'testhtml' ? $langs->transnoentities("PredefinedMailTestHtml") : $langs->transnoentities("PredefinedMailTest"))); + $formmail->withbody = (GETPOSTISSET('message') ? GETPOST('message', 'restricthtml') : ($action == 'testhtml' ? $langs->transnoentities("PredefinedMailTestHtml") : $langs->transnoentities("PredefinedMailTest"))); $formmail->withbodyreadonly = 0; $formmail->withcancel = 1; $formmail->withdeliveryreceipt = 1; diff --git a/htdocs/admin/mails_emailing.php b/htdocs/admin/mails_emailing.php index faa72f4fc7c..84cc97d86d4 100644 --- a/htdocs/admin/mails_emailing.php +++ b/htdocs/admin/mails_emailing.php @@ -564,20 +564,20 @@ if ($action == 'edit') // Cree l'objet formulaire mail include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; $formmail = new FormMail($db); - $formmail->fromname = (isset($_POST['fromname']) ? $_POST['fromname'] : $conf->global->MAIN_MAIL_EMAIL_FROM); - $formmail->frommail = (isset($_POST['frommail']) ? $_POST['frommail'] : $conf->global->MAIN_MAIL_EMAIL_FROM); + $formmail->fromname = (GETPOSTISSET('fromname') ? GETPOST('fromname', 'restricthtml') : $conf->global->MAIN_MAIL_EMAIL_FROM); + $formmail->frommail = (GETPOSTISSET('frommail') ? GETPOST('frommail', 'restricthtml') : $conf->global->MAIN_MAIL_EMAIL_FROM); $formmail->trackid = (($action == 'testhtml') ? "testhtml" : "test"); $formmail->withfromreadonly = 0; $formmail->withsubstit = 0; $formmail->withfrom = 1; $formmail->witherrorsto = 1; - $formmail->withto = (!empty($_POST['sendto']) ? $_POST['sendto'] : ($user->email ? $user->email : 1)); - $formmail->withtocc = (!empty($_POST['sendtocc']) ? $_POST['sendtocc'] : 1); // ! empty to keep field if empty - $formmail->withtoccc = (!empty($_POST['sendtoccc']) ? $_POST['sendtoccc'] : 1); // ! empty to keep field if empty - $formmail->withtopic = (isset($_POST['subject']) ? $_POST['subject'] : $langs->trans("Test")); + $formmail->withto = (!GETPOST('sendto') ? GETPOST('sendto', 'restricthtml') : ($user->email ? $user->email : 1)); + $formmail->withtocc = (!GETPOST(['sendtocc']) ? GETPOST('sendtocc', 'restricthtml') : 1); // ! empty to keep field if empty + $formmail->withtoccc = (!GETPOST(['sendtoccc']) ? GETPOST('sendtoccc', 'restricthtml') : 1); // ! empty to keep field if empty + $formmail->withtopic = (GETPOSTISSET('subject') ? GETPOST('subject') : $langs->trans("Test")); $formmail->withtopicreadonly = 0; $formmail->withfile = 2; - $formmail->withbody = (isset($_POST['message']) ? $_POST['message'] : ($action == 'testhtml' ? $langs->transnoentities("PredefinedMailTestHtml") : $langs->transnoentities("PredefinedMailTest"))); + $formmail->withbody = (GETPOSTISSET('message') ? GETPOST('message', 'restricthtml') : ($action == 'testhtml' ? $langs->transnoentities("PredefinedMailTestHtml") : $langs->transnoentities("PredefinedMailTest"))); $formmail->withbodyreadonly = 0; $formmail->withcancel = 1; $formmail->withdeliveryreceipt = 1; diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index 872c0d414eb..de98c42b35a 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -271,7 +271,7 @@ if (empty($reshook)) { // Rename some POST variables into a generic name if (GETPOST('actionmodify', 'alpha') && $value == 'topic') $_POST['topic'] = $_POST['topic-'.$rowid]; - if ((!isset($_POST[$value]) || $_POST[$value] == '' || $_POST[$value] == '-1') && $value != 'lang' && $value != 'fk_user' && $value != 'position') + if ((!GETPOSTISSET($value) || GETPOST($value) == '' || GETPOST($value) == '-1') && $value != 'lang' && $value != 'fk_user' && $value != 'position') { $ok = 0; $fieldnamekey = $listfield[$f]; diff --git a/htdocs/admin/mails_ticket.php b/htdocs/admin/mails_ticket.php index 49dc61a270a..1e1c3db3fad 100644 --- a/htdocs/admin/mails_ticket.php +++ b/htdocs/admin/mails_ticket.php @@ -530,20 +530,20 @@ if ($action == 'edit') // Cree l'objet formulaire mail include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; $formmail = new FormMail($db); - $formmail->fromname = (isset($_POST['fromname']) ? $_POST['fromname'] : $conf->global->MAIN_MAIL_EMAIL_FROM); - $formmail->frommail = (isset($_POST['frommail']) ? $_POST['frommail'] : $conf->global->MAIN_MAIL_EMAIL_FROM); + $formmail->fromname = (GETPOSTISSET('fromname') ? $_POST['fromname'] : $conf->global->MAIN_MAIL_EMAIL_FROM); + $formmail->frommail = (GETPOSTISSET('frommail') ? $_POST['frommail'] : $conf->global->MAIN_MAIL_EMAIL_FROM); $formmail->trackid = (($action == 'testhtml') ? "testhtml" : "test"); $formmail->withfromreadonly = 0; $formmail->withsubstit = 0; $formmail->withfrom = 1; $formmail->witherrorsto = 1; - $formmail->withto = (!empty($_POST['sendto']) ? $_POST['sendto'] : ($user->email ? $user->email : 1)); - $formmail->withtocc = (!empty($_POST['sendtocc']) ? $_POST['sendtocc'] : 1); // ! empty to keep field if empty - $formmail->withtoccc = (!empty($_POST['sendtoccc']) ? $_POST['sendtoccc'] : 1); // ! empty to keep field if empty - $formmail->withtopic = (isset($_POST['subject']) ? $_POST['subject'] : $langs->trans("Test")); + $formmail->withto = (!empty($_POST['sendto']) ? GETPOST('sendto', 'restricthtml') : ($user->email ? $user->email : 1)); + $formmail->withtocc = (!empty($_POST['sendtocc']) ? GETPOST('sendtocc', 'restricthtml') : 1); // ! empty to keep field if empty + $formmail->withtoccc = (!empty($_POST['sendtoccc']) ? GETPOST('sendtoccc', 'restricthtml') : 1); // ! empty to keep field if empty + $formmail->withtopic = (GETPOSTISSET('subject') ? GETPOST('subject') : $langs->trans("Test")); $formmail->withtopicreadonly = 0; $formmail->withfile = 2; - $formmail->withbody = (isset($_POST['message']) ? $_POST['message'] : ($action == 'testhtml' ? $langs->transnoentities("PredefinedMailTestHtml") : $langs->transnoentities("PredefinedMailTest"))); + $formmail->withbody = (GETPOSTISSET('message') ? GETPOST('message', 'restricthtml') : ($action == 'testhtml' ? $langs->transnoentities("PredefinedMailTestHtml") : $langs->transnoentities("PredefinedMailTest"))); $formmail->withbodyreadonly = 0; $formmail->withcancel = 1; $formmail->withdeliveryreceipt = 1; diff --git a/htdocs/admin/mrp.php b/htdocs/admin/mrp.php index 837a77fe2a7..af6210eee1f 100644 --- a/htdocs/admin/mrp.php +++ b/htdocs/admin/mrp.php @@ -233,8 +233,10 @@ foreach ($dirmodels as $reldir) // Show example of numbering model print ''; $tmp = $module->getExample(); - if (preg_match('/^Error/', $tmp)) print '
'.$langs->trans($tmp).'
'; - elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); + if (preg_match('/^Error/', $tmp)) { + $langs->load("errors"); + print '
'.$langs->trans($tmp).'
'; + } elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); else print $tmp; print '
'; if ($module->type == 'pdf') { - print ''.img_object($langs->trans("Preview"), 'bill').''; + print ''.img_object($langs->trans("Preview"), 'pdf').''; } else { print img_object($langs->trans("PreviewNotAvailable"), 'generic'); } diff --git a/htdocs/admin/payment.php b/htdocs/admin/payment.php index d92704c211b..378e1b4fe68 100644 --- a/htdocs/admin/payment.php +++ b/htdocs/admin/payment.php @@ -171,8 +171,10 @@ foreach ($dirmodels as $reldir) // Show example of numbering module print ''; $tmp = $module->getExample(); - if (preg_match('/^Error/', $tmp)) print '
'.$langs->trans($tmp).'
'; - elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); + if (preg_match('/^Error/', $tmp)) { + $langs->load("errors"); + print '
'.$langs->trans($tmp).'
'; + } elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); else print $tmp; print '
'; if ($module->type == 'pdf') { - print ''.img_object($langs->trans("Preview"),'bill').''; + print ''.img_object($langs->trans("Preview"), 'pdf').''; } else { diff --git a/htdocs/admin/prelevement.php b/htdocs/admin/prelevement.php index 97a45c77a42..72e116ab3a7 100644 --- a/htdocs/admin/prelevement.php +++ b/htdocs/admin/prelevement.php @@ -347,7 +347,7 @@ foreach ($dirmodels as $reldir) print ''; if ($module->type == 'pdf') { - print ''.img_object($langs->trans("Preview"),'bill').''; + print ''.img_object($langs->trans("Preview"), 'pdf').''; } else { diff --git a/htdocs/admin/propal.php b/htdocs/admin/propal.php index e75a06a78ad..78c22e7b397 100644 --- a/htdocs/admin/propal.php +++ b/htdocs/admin/propal.php @@ -256,8 +256,10 @@ foreach ($dirmodels as $reldir) // Show example of numbering module print ''; $tmp = $module->getExample(); - if (preg_match('/^Error/', $tmp)) print '
'.$langs->trans($tmp).'
'; - elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); + if (preg_match('/^Error/', $tmp)) { + $langs->load("errors"); + print '
'.$langs->trans($tmp).'
'; + } elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); else print $tmp; print '
'; if ($module->type == 'pdf') { - print ''.img_object($langs->trans("Preview"), 'bill').''; + print ''.img_object($langs->trans("Preview"), 'pdf').''; } else { print img_object($langs->trans("PreviewNotAvailable"), 'generic'); } diff --git a/htdocs/admin/proxy.php b/htdocs/admin/proxy.php index 71bd50ef5ce..0349f8a3435 100644 --- a/htdocs/admin/proxy.php +++ b/htdocs/admin/proxy.php @@ -135,7 +135,7 @@ print '
'.$langs->trans("ConnectionTimeout").''; print ''; -print 'global->MAIN_USE_CONNECT_TIMEOUT).'">'; +print 'global->MAIN_USE_CONNECT_TIMEOUT).'">'; print ' '.strtolower($langs->trans("Seconds")); print '
'.$printer->listprinterstemplates[$line]['name'].''.nl2br(htmlentities($printer->listprinterstemplates[$line]['template'])).''.dol_htmlentitiesbr($printer->listprinterstemplates[$line]['template']).''; print img_picto($langs->trans("Edit"), 'edit'); diff --git a/htdocs/admin/reception_setup.php b/htdocs/admin/reception_setup.php index 6c5d9916225..5da0dd84630 100644 --- a/htdocs/admin/reception_setup.php +++ b/htdocs/admin/reception_setup.php @@ -240,7 +240,8 @@ foreach ($dirmodels as $reldir) print ''; $tmp = $module->getExample(); if (preg_match('/^Error/', $tmp)) { - $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; + $langs->load("errors"); + print '
'.$langs->trans($tmp).'
'; } elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); else print $tmp; print '
'; if ($module->type == 'pdf') { - print 'scandir.'&label='.urlencode($module->name).'">'.img_object($langs->trans("Preview"), 'reception').''; + print 'scandir.'&label='.urlencode($module->name).'">'.img_object($langs->trans("Preview"), 'pdf').''; } else { print img_object($langs->trans("PreviewNotAvailable"), 'generic'); } diff --git a/htdocs/admin/security.php b/htdocs/admin/security.php index fc479522a8b..30085d3f1f1 100644 --- a/htdocs/admin/security.php +++ b/htdocs/admin/security.php @@ -256,7 +256,10 @@ foreach ($arrayhandler as $key => $module) // Show example of numbering module print ''; $tmp = $module->getExample(); - if (preg_match('/^Error/', $tmp)) { $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; } elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); + if (preg_match('/^Error/', $tmp)) { + $langs->load("errors"); + print '
'.$langs->trans($tmp).'
'; + } elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); else print $tmp; print '
'; if ($module->type == 'pdf') { - print ''.img_object($langs->trans("Preview"), 'bill').''; + print ''.img_object($langs->trans("Preview"), 'pdf').''; } else { print img_object($langs->trans("PreviewNotAvailable"), 'generic'); } diff --git a/htdocs/admin/supplier_invoice.php b/htdocs/admin/supplier_invoice.php index 779f7ab472a..8df357df07e 100644 --- a/htdocs/admin/supplier_invoice.php +++ b/htdocs/admin/supplier_invoice.php @@ -251,7 +251,8 @@ foreach ($dirmodels as $reldir) print ''; $tmp = $module->getExample(); if (preg_match('/^Error/', $tmp)) { - $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; + $langs->load("errors"); + print '
'.$langs->trans($tmp).'
'; } elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); else print $tmp; print '
'; - print ''.img_object($langs->trans("Preview"), 'order').''; + print ''.img_object($langs->trans("Preview"), 'pdf').''; print '
'; $tmp = $module->getExample(); if (preg_match('/^Error/', $tmp)) { - $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; + $langs->load("errors"); + print '
'.$langs->trans($tmp).'
'; } elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); else print $tmp; print '
'; - print ''.img_object($langs->trans("Preview"), 'order').''; + print ''.img_object($langs->trans("Preview"), 'pdf').''; print '
'; $tmp = $module->getExample(); - if (preg_match('/^Error/', $tmp)) print '
'.$langs->trans($tmp).'
'; - elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); + if (preg_match('/^Error/', $tmp)) { + $langs->load("errors"); + print '
'.$langs->trans($tmp).'
'; + } elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); else print $tmp; print '
'; - print ''.img_object($langs->trans("Preview"), 'order').''; + print ''.img_object($langs->trans("Preview"), 'pdf').''; print '
'; $tmp = $module->getExample(); - if (preg_match('/^Error/', $tmp)) print '
'.$langs->trans($tmp).'
'; - elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); + if (preg_match('/^Error/', $tmp)) { + $langs->load("errors"); + print '
'.$langs->trans($tmp).'
'; + } elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); else print $tmp; print '
'; if ($module->type == 'pdf') { - print ''.img_object($langs->trans("Preview"), 'bill').''; + print ''.img_object($langs->trans("Preview"), 'pdf').''; } else { print img_object($langs->trans("PreviewNotAvailable"), 'generic'); } diff --git a/htdocs/admin/syslog.php b/htdocs/admin/syslog.php index 6d84b4a0e2d..45500843aed 100644 --- a/htdocs/admin/syslog.php +++ b/htdocs/admin/syslog.php @@ -85,7 +85,7 @@ if ($action == 'set') $db->begin(); $newActiveModules = array(); - $selectedModules = (isset($_POST['SYSLOG_HANDLERS']) ? $_POST['SYSLOG_HANDLERS'] : array()); + $selectedModules = (GETPOSTISSET('SYSLOG_HANDLERS') ? GETPOST('SYSLOG_HANDLERS') : array()); // Save options of handler foreach ($syslogModules as $syslogHandler) @@ -97,11 +97,10 @@ if ($action == 'set') if (in_array($syslogHandler, $selectedModules)) $newActiveModules[] = $syslogHandler; foreach ($module->configure() as $option) { - if (isset($_POST[$option['constant']])) + if (GETPOSTISSET($option['constant'])) { - $_POST[$option['constant']] = trim($_POST[$option['constant']]); dolibarr_del_const($db, $option['constant'], -1); - dolibarr_set_const($db, $option['constant'], $_POST[$option['constant']], 'chaine', 0, '', 0); + dolibarr_set_const($db, $option['constant'], trim(GETPOST($option['constant'])), 'chaine', 0, '', 0); } } } @@ -229,7 +228,7 @@ foreach ($syslogModules as $moduleName) $tmpoption = $option['constant']; if (!empty($tmpoption)) { - if (isset($_POST[$tmpoption])) $value = $_POST[$tmpoption]; + if (GETPOSTISSET($tmpoption)) $value = GETPOST($tmpoption); elseif (!empty($conf->global->$tmpoption)) $value = $conf->global->$tmpoption; } else $value = (isset($option['default']) ? $option['default'] : ''); @@ -240,7 +239,7 @@ foreach ($syslogModules as $moduleName) { $filelogparam = ' ('; $filelogparam .= $langs->trans('Download'); - $filelogparam .= $filelog.')'; + $filelogparam .= ' '.basename($value).')'; print $filelogparam; } } diff --git a/htdocs/admin/system/dolibarr.php b/htdocs/admin/system/dolibarr.php index a9726bd7baf..37aadd8c2ad 100644 --- a/htdocs/admin/system/dolibarr.php +++ b/htdocs/admin/system/dolibarr.php @@ -85,31 +85,37 @@ if (empty($conf->global->MAIN_VERSION_LAST_UPGRADE)) if (DOL_VERSION != $conf->global->MAIN_VERSION_LAST_UPGRADE) print ' '.img_warning($langs->trans("RunningUpdateProcessMayBeRequired", DOL_VERSION, $conf->global->MAIN_VERSION_LAST_UPGRADE)); } +$version = DOL_VERSION; +if (preg_match('/[a-z]+/i', $version)) $version = 'develop'; // If version contains text, it is not an official tagged version, so we use the full change log. +print '   '.$langs->trans("SeeChangeLog").''; + +$newversion = ''; if (function_exists('curl_init')) { - $conf->global->MAIN_USE_RESPONSE_TIMEOUT = 10; - print '     -     '; - if ($action == 'getlastversion') - { - if ($sfurl) - { - while (!empty($sfurl->channel[0]->item[$i]->title) && $i < 10000) - { - $title = $sfurl->channel[0]->item[$i]->title; - if (preg_match('/([0-9]+\.([0-9\.]+))/', $title, $reg)) - { - $newversion = $reg[1]; - $newversionarray = explode('.', $newversion); - $versionarray = explode('.', $version); - //var_dump($newversionarray);var_dump($versionarray); - if (versioncompare($newversionarray, $versionarray) > 0) $version = $newversion; - } - $i++; - } + $conf->global->MAIN_USE_RESPONSE_TIMEOUT = 10; + print '     -     '; + if ($action == 'getlastversion') { + if ($sfurl) { + $i = 0; + while (!empty($sfurl->channel[0]->item[$i]->title) && $i < 10000) { + $title = $sfurl->channel[0]->item[$i]->title; + $reg = array(); + if (preg_match('/([0-9]+\.([0-9\.]+))/', $title, $reg)) { + $newversion = $reg[1]; + $newversionarray = explode('.', $newversion); + $versionarray = explode('.', $version); + //var_dump($newversionarray);var_dump($versionarray); + if (versioncompare($newversionarray, $versionarray) > 0) $version = $newversion; + } + $i++; + } // Show version print $langs->trans("LastStableVersion").' : '.(($version != '0.0') ? $version : $langs->trans("Unknown")).''; - } else { + if ($version != '0.0') { + print '   '.$langs->trans("SeeChangeLog").''; + } + } else { print $langs->trans("LastStableVersion").' : '.$langs->trans("UpdateServerOffline").''; } } else { @@ -118,12 +124,11 @@ if (function_exists('curl_init')) } // Now show link to the changelog -print '     -     '; +//print '     -     '; $version = DOL_VERSION; if (preg_match('/[a-z]+/i', $version)) $version = 'develop'; // If version contains text, it is not an official tagged version, so we use the full change log. -print ''.$langs->trans("SeeChangeLog").''; print '
'.$langs->trans("VersionLastUpgrade").' ('.$langs->trans("Database").')'.$conf->global->MAIN_VERSION_LAST_UPGRADE.'
'.$langs->trans("VersionLastInstall").''.$conf->global->MAIN_VERSION_LAST_INSTALL.'
GET and POST support'; -if (!isset($_GET["testget"]) && !isset($_POST["testpost"]) && !isset($_GET["mainmenu"])) +if (!isset($_GET["testget"]) && !isset($_POST["testpost"]) && !isset($_GET["mainmenu"])) // We must keep $_GET and $_POST here { print 'Warning '.$langs->trans("PHPSupportPOSTGETKo"); print ' ('.$langs->trans("Recheck").')'; @@ -126,7 +124,7 @@ print '
'; print '
'; -$activatedExtensions = array_map('strtolower', getActivatedExtensions()); +$activatedExtensions = array(); $loadedExtensions = array_map('strtolower', get_loaded_extensions(false)); print ''; @@ -165,7 +163,6 @@ $name = "GD"; print ""; print ""; -//print getTableColumn($name, $activatedExtensions); print getTableColumn($name, $loadedExtensions); print getTableColumnFunction($functions); print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions); @@ -176,7 +173,6 @@ $name = "Curl"; print ""; print ""; -//print getTableColumn($name, $activatedExtensions); print getTableColumn($name, $loadedExtensions); print getTableColumnFunction($functions); print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions); @@ -189,7 +185,6 @@ if (empty($_SERVER["SERVER_ADMIN"]) || $_SERVER["SERVER_ADMIN"] != 'doliwamp@loc print ""; print ""; - //print getTableColumn($name, $activatedExtensions); print getTableColumn($name, $loadedExtensions); print getTableColumnFunction($functions); print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions); @@ -201,7 +196,6 @@ $name = "xDebug"; print ""; print ""; -//print getTableColumn($name, $activatedExtensions); print getTableColumn($name, $loadedExtensions); print getTableColumnFunction($functions); print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions); @@ -240,7 +234,7 @@ foreach ($phparray as $key => $value) print ''; } else { print ''; - print ''; + print ''; $i = 0; foreach ($keyvalue as $keyparam2 => $keyvalue2) { @@ -264,85 +258,6 @@ foreach ($phparray as $key => $value) llxFooter(); $db->close(); -/** - * Return all list with all activated, but possible not loaded PHP extensions - * - * @return array - */ -function getActivatedExtensions() -{ - $file = trim(getConfigFilePath()); - $handle = fopen($file, "r"); - $content = fread($handle, filesize($file)); - - fclose($handle); - - $configLines = explode("\r", $content); - - // For compatibility with LF (Line Feed) - if (empty($configLines) || count($configLines) < 2) { - $configLines = explode("\n", $content); - } - - $extensions = array(); - $lastLine = ""; - - foreach ($configLines as $line) - { - $line = trim($line); - - // ignore comment lines - if (substr($line, 0, 1) === ";" || empty($line)) - { - continue; - } - - // var_dump($line); - - // extension - if (substr($line, 0, 9) === "extension" && substr($line, 0, 10) !== "extension_") - { - $value = trim(end(explode("=", $line))); - - $extensions[] = $value === "gd2" ? "gd" : $value; - } - - // zend_extension - if (substr($line, 0, 14) === "zend_extension") - { - $extensions[] = str_replace("[", "", str_replace("]", "", $lastLine)); - } - - $lastLine = $line; - } - - return array_unique($extensions); -} - -/** - * Return the path to the current used php config file - * - * @return string - */ -function getConfigFilePath() -{ - $phparray = phpinfo_array(); - - foreach ($phparray as $value) - { - foreach ($value as $keyparam => $keyvalue) - { - if (strtolower($keyparam) !== "loaded configuration file") - { - continue; - } - - return $keyvalue; - } - } - - return ""; -} /** * Return a table column with a indicator (okay or warning), based on the given name and list @@ -411,7 +326,7 @@ function getTableColumnFunction(array $functions) * Return a result column with a translated result text * * @param string $name The name of the PHP extension - * @param array $activated A list with all activated PHP extensions + * @param array $activated A list with all activated PHP extensions. Deprecated. * @param array $loaded A list with all loaded PHP extensions * @param array $functions A list with all PHP functions to check * diff --git a/htdocs/admin/ticket.php b/htdocs/admin/ticket.php index 0614df0dd61..c1546f1da2c 100644 --- a/htdocs/admin/ticket.php +++ b/htdocs/admin/ticket.php @@ -240,6 +240,7 @@ foreach ($dirmodels as $reldir) { print '
".$name."
".$name."
".$name."
".$name."
'.$keyparam.''.$keyparam.''; $tmp = $module->getExample(); if (preg_match('/^Error/', $tmp)) { + $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; } elseif ($tmp == 'NotConfigured') { print $langs->trans($tmp); diff --git a/htdocs/admin/translation.php b/htdocs/admin/translation.php index f4d50cb6f8d..76cae0443b3 100644 --- a/htdocs/admin/translation.php +++ b/htdocs/admin/translation.php @@ -363,7 +363,7 @@ if ($mode == 'overwrite') if ($mode == 'searchkey') { - $langcode = GETPOST('langcode') ?GETPOST('langcode') : $langs->defaultlang; + $langcode = GETPOSTISSET('langcode') ? GETPOST('langcode') : $langs->defaultlang; $newlang = new Translate('', $conf); $newlang->setDefaultLang($langcode); @@ -384,8 +384,7 @@ if ($mode == 'searchkey') if (empty($langcode) || $langcode == '-1') $nbempty++; if (empty($transkey)) $nbempty++; if (empty($transvalue)) $nbempty++; - if ($action == 'search' && ($nbempty > 999)) // 999 to disable this - { + if ($action == 'search' && ($nbempty > 999)) { // 999 to disable this setEventMessages($langs->trans("WarningAtLeastKeyOrTranslationRequired"), null, 'warnings'); } else { // Search into dir of modules (the $modulesdir is already a list that loop on $conf->file->dol_document_root) diff --git a/htdocs/admin/user.php b/htdocs/admin/user.php index ea39cc1dce9..ea6cdf2b6f8 100644 --- a/htdocs/admin/user.php +++ b/htdocs/admin/user.php @@ -312,7 +312,7 @@ foreach ($dirmodels as $reldir) print '
'; if ($module->type == 'pdf') { - print ''.img_object($langs->trans("Preview"), 'contract').''; + print ''.img_object($langs->trans("Preview"), 'pdf').''; } else { print img_object($langs->trans("PreviewNotAvailable"), 'generic'); } diff --git a/htdocs/admin/usergroup.php b/htdocs/admin/usergroup.php index dd12584b276..0725cc83f18 100644 --- a/htdocs/admin/usergroup.php +++ b/htdocs/admin/usergroup.php @@ -241,7 +241,7 @@ foreach ($dirmodels as $reldir) print ''; if ($module->type == 'pdf') { - print ''.img_object($langs->trans("Preview"), 'contract').''; + print ''.img_object($langs->trans("Preview"), 'pdf').''; } else { print img_object($langs->trans("PreviewNotAvailable"), 'generic'); } diff --git a/htdocs/api/class/api_access.class.php b/htdocs/api/class/api_access.class.php index e7b8ac8536b..926a51456c7 100644 --- a/htdocs/api/class/api_access.class.php +++ b/htdocs/api/class/api_access.class.php @@ -19,9 +19,9 @@ // Create the autoloader for Luracast require_once DOL_DOCUMENT_ROOT.'/includes/restler/framework/Luracast/Restler/AutoLoader.php'; call_user_func(function () { - $loader = Luracast\Restler\AutoLoader::instance(); - spl_autoload_register($loader); - return $loader; + $loader = Luracast\Restler\AutoLoader::instance(); + spl_autoload_register($loader); + return $loader; }); require_once DOL_DOCUMENT_ROOT.'/includes/restler/framework/Luracast/Restler/iAuthenticate.php'; diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php index 9408898a984..550d78068a4 100644 --- a/htdocs/api/class/api_documents.class.php +++ b/htdocs/api/class/api_documents.class.php @@ -475,7 +475,7 @@ class Documents extends DolibarrApi $upload_dir = $conf->categorie->multidir_output[$object->entity].'/'.get_exdir($object->id, 2, 0, 0, $object, 'category').$object->id."/photos/".dol_sanitizeFileName($object->ref); } elseif ($modulepart == 'ecm') { - throw new RestException(500, 'Modulepart Ecm not implemented yet.'); + throw new RestException(500, 'Modulepart Ecm not implemented yet.'); // // require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php'; // if (!DolibarrApiAccess::$user->rights->ecm->read) { @@ -634,7 +634,7 @@ class Documents extends DolibarrApi require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; $object = new Propal($this->db); } else { - // TODO Implement additional moduleparts + // TODO Implement additional moduleparts throw new RestException(500, 'Modulepart '.$modulepart.' not implemented yet.'); } diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index 4516d2e1d45..02bb5afbafd 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -111,6 +111,71 @@ class Setup extends DolibarrApi return $list; } + /** + * Get the list of ordering origins. + * + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param int $limit Number of items per page + * @param int $page Page number {@min 0} + * @param int $active Payment type is active or not {@min 0} {@max 1} + * @param string $sqlfilters SQL criteria to filter with. Syntax example "(t.code:=:'OrderByWWW')" + * + * @url GET dictionary/ordering_origins + * + * @return array [List of ordering reasons] + * + * @throws RestException 400 + */ + public function getOrderingOrigins($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') + { + $list = array(); + + if (!DolibarrApiAccess::$user->rights->commande->lire) { + throw new RestException(401); + } + + $sql = "SELECT rowid, code, label, module"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_input_reason as t"; + $sql .= " WHERE t.active = ".$active; + // Add sql filters + if ($sqlfilters) + { + if (!DolibarrApi::_checkFilters($sqlfilters)) + { + throw new RestException(400, 'error when validating parameter sqlfilters '.$sqlfilters); + } + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + } + + + $sql .= $this->db->order($sortfield, $sortorder); + + if ($limit) { + if ($page < 0) { + $page = 0; + } + $offset = $limit * $page; + + $sql .= $this->db->plimit($limit, $offset); + } + + $result = $this->db->query($sql); + + if ($result) { + $num = $this->db->num_rows($result); + $min = min($num, ($limit <= 0 ? $num : $limit)); + for ($i = 0; $i < $min; $i++) { + $list[] = $this->db->fetch_object($result); + } + } else { + throw new RestException(400, $this->db->lasterror()); + } + + return $list; + } + /** * Get the list of payments types. * diff --git a/htdocs/api/index.php b/htdocs/api/index.php index 2fba9fbb554..2c85533fd11 100644 --- a/htdocs/api/index.php +++ b/htdocs/api/index.php @@ -46,9 +46,9 @@ if (!$res) die("Include of main fails"); require_once DOL_DOCUMENT_ROOT.'/includes/restler/framework/Luracast/Restler/AutoLoader.php'; call_user_func(function () { - $loader = Luracast\Restler\AutoLoader::instance(); - spl_autoload_register($loader); - return $loader; + $loader = Luracast\Restler\AutoLoader::instance(); + spl_autoload_register($loader); + return $loader; }); require_once DOL_DOCUMENT_ROOT.'/api/class/api.class.php'; diff --git a/htdocs/bom/bom_list.php b/htdocs/bom/bom_list.php index 1135f5df5dd..8f8c13f2556 100644 --- a/htdocs/bom/bom_list.php +++ b/htdocs/bom/bom_list.php @@ -383,21 +383,6 @@ if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $ llxHeader('', $title, $help_url); -// Example : Adding jquery code -print ''; - $arrayofselected = is_array($toselect) ? $toselect : array(); $param = ''; @@ -469,7 +454,7 @@ $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); -print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table +print '
'; print ''."\n"; diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php index e182a91d32a..03610100c9c 100644 --- a/htdocs/categories/class/api_categories.class.php +++ b/htdocs/categories/class/api_categories.class.php @@ -769,6 +769,7 @@ class Categories extends DolibarrApi $objects = $result; $cleaned_objects = array(); + $objects_api = null; if ($type == 'member') { $objects_api = new Members(); } elseif ($type == 'customer' || $type == 'supplier') { diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 3aca92708a7..f55b3403546 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -1891,13 +1891,12 @@ class Categorie extends CommonObject return ""; } + $searchCategorySqlList = array(); foreach ($searchList as $searchCategory) { if (intval($searchCategory) == -2) { $searchCategorySqlList[] = " cp.fk_categorie IS NULL"; } elseif (intval($searchCategory) > 0) { - $searchCategorySqlList[] = " ".$rowIdName - ." IN (SELECT fk_".$type." FROM ".MAIN_DB_PREFIX."categorie_".$type - ." WHERE fk_categorie = ".$searchCategory.")"; + $searchCategorySqlList[] = " ".$rowIdName." IN (SELECT fk_".$type." FROM ".MAIN_DB_PREFIX."categorie_".$type." WHERE fk_categorie = ".((int) $searchCategory).")"; } } diff --git a/htdocs/categories/edit.php b/htdocs/categories/edit.php index 49126ea1111..f634d62a6e4 100644 --- a/htdocs/categories/edit.php +++ b/htdocs/categories/edit.php @@ -145,7 +145,7 @@ print ''; // Description print ''; print ''; -print ''; // Color print ''; print ''; -print ''; diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index 7f673a1ecff..864de6e2e98 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -294,7 +294,7 @@ if ($user->rights->categorie->creer) if ($user->rights->categorie->supprimer) { - print 'id.'&type='.$type.'">'.$langs->trans("Delete").''; + print 'id.'&type='.$type.'">'.$langs->trans("Delete").''; } print ""; diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 6dfdf41e679..f26ad2a36e2 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -280,7 +280,7 @@ if (empty($reshook) && $action == 'add') } } } - $object->fk_project = isset($_POST["projectid"]) ? $_POST["projectid"] : 0; + $object->fk_project = GETPOSTISSET("projectid") ? GETPOST("projectid", 'int') : 0; $taskid = GETPOST('taskid', 'int'); if (!empty($taskid)) { @@ -324,7 +324,7 @@ if (empty($reshook) && $action == 'add') $object->note_private = trim(GETPOST("note", "restricthtml")); - if (isset($_POST["contactid"])) $object->contact = $contact; + if (GETPOSTISSET("contactid")) $object->contact = $contact; if (GETPOST('socid', 'int') > 0) { @@ -1051,8 +1051,8 @@ if ($action == 'create') print ''; print '"; } @@ -1578,7 +1578,7 @@ if ($id > 0) foreach ($cats as $cat) { $arrayselected[] = $cat->id; } - print $form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, '', 0, '100%'); + print img_picto('', 'category').$form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0); print ""; } diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index b7b25e28d3c..5a9b0afa336 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -524,7 +524,7 @@ class ActionComm extends CommonObject $resql = $this->db->query($sql); if ($resql) { - $this->ref =$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."actioncomm", "id"); + $this->ref = $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."actioncomm", "id"); // Now insert assigned users if (!$error) @@ -2186,7 +2186,7 @@ class ActionComm extends CommonObject $this->db->commit(); return 0; } else { - $this->db->commit(); // We commit also on error, to have the error message recorded. + $this->db->commit(); // We commit also on error, to have the error message recorded. $this->error = 'Nb of emails sent : '.$nbMailSend.', '.(!empty($errorsMsg)) ? join(', ', $errorsMsg) : $error; return $error; } diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index 313aaa0e2e4..83b3c0514aa 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -336,7 +336,7 @@ if ($status == 'todo') $title = $langs->trans("ToDoActions"); */ $param = ''; -if ($actioncode || isset($_GET['search_actioncode']) || isset($_POST['search_actioncode'])) { +if ($actioncode || GETPOSTISSET('search_actioncode')) { if (is_array($actioncode)) { foreach ($actioncode as $str_action) $param .= "&search_actioncode[]=".urlencode($str_action); } else $param .= "&search_actioncode=".urlencode($actioncode); @@ -1492,19 +1492,19 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa if ($nonew <= 0) { - print '
'; + print '
'."\n"; + print '
'."\n"; } if ($nonew < 0) diff --git a/htdocs/comm/action/pertype.php b/htdocs/comm/action/pertype.php index 4f292047700..c5f81e358cc 100644 --- a/htdocs/comm/action/pertype.php +++ b/htdocs/comm/action/pertype.php @@ -122,8 +122,8 @@ $tmparray = explode('-', $tmp); $begin_d = 1; $end_d = 53; -if ($status == '' && !isset($_GET['status']) && !isset($_POST['status'])) $status = (empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS); -if (empty($action) && !isset($_GET['action']) && !isset($_POST['action'])) $action = (empty($conf->global->AGENDA_DEFAULT_VIEW) ? 'show_month' : $conf->global->AGENDA_DEFAULT_VIEW); +if ($status == '' && !GETPOSTISSET('status')) $status = (empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS); +if (empty($action) && !GETPOSTISSET('action')) $action = (empty($conf->global->AGENDA_DEFAULT_VIEW) ? 'show_month' : $conf->global->AGENDA_DEFAULT_VIEW); if (GETPOST('viewcal', 'alpha') && $action != 'show_day' && $action != 'show_week' && $action != 'show_peruser') { $action = 'show_month'; $day = ''; @@ -227,13 +227,13 @@ if ($status == 'done') $title = $langs->trans("DoneActions"); if ($status == 'todo') $title = $langs->trans("ToDoActions"); $param = ''; -if ($actioncode || isset($_GET['search_actioncode']) || isset($_POST['search_actioncode'])) { +if ($actioncode || GETPOSTISSET('search_actioncode')) { if (is_array($actioncode)) { foreach ($actioncode as $str_action) $param .= "&search_actioncode[]=".urlencode($str_action); } else $param .= "&search_actioncode=".urlencode($actioncode); } if ($resourceid > 0) $param .= "&search_resourceid=".urlencode($resourceid); -if ($status || isset($_GET['status']) || isset($_POST['status'])) $param .= "&search_status=".urlencode($status); +if ($status || GETPOSTISSET('status')) $param .= "&search_status=".urlencode($status); if ($filter) $param .= "&search_filter=".urlencode($filter); if ($filtert) $param .= "&search_filtert=".urlencode($filtert); if ($usergroup) $param .= "&search_usergroup=".urlencode($usergroup); diff --git a/htdocs/comm/action/peruser.php b/htdocs/comm/action/peruser.php index 8983dbff7f6..6161b6c820b 100644 --- a/htdocs/comm/action/peruser.php +++ b/htdocs/comm/action/peruser.php @@ -125,8 +125,8 @@ if ($begin_d < 1 || $begin_d > 7) $begin_d = 1; if ($end_d < 1 || $end_d > 7) $end_d = 7; if ($end_d < $begin_d) $end_d = $begin_d + 1; -if ($status == '' && !isset($_GET['status']) && !isset($_POST['status'])) $status = (empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS); -if (empty($action) && !isset($_GET['action']) && !isset($_POST['action'])) $action = (empty($conf->global->AGENDA_DEFAULT_VIEW) ? 'show_month' : $conf->global->AGENDA_DEFAULT_VIEW); +if ($status == '' && !GETPOSTISSET('status')) $status = (empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS); +if (empty($action) && !GETPOSTISSET('action')) $action = (empty($conf->global->AGENDA_DEFAULT_VIEW) ? 'show_month' : $conf->global->AGENDA_DEFAULT_VIEW); if (GETPOST('viewcal', 'alpha') && $action != 'show_day' && $action != 'show_week' && $action != 'show_peruser') { $action = 'show_month'; $day = ''; @@ -227,13 +227,13 @@ if ($status == 'done') $title = $langs->trans("DoneActions"); if ($status == 'todo') $title = $langs->trans("ToDoActions"); $param = ''; -if ($actioncode || isset($_GET['search_actioncode']) || isset($_POST['search_actioncode'])) { +if ($actioncode || GETPOSTISSET('search_actioncode')) { if (is_array($actioncode)) { foreach ($actioncode as $str_action) $param .= "&search_actioncode[]=".urlencode($str_action); } else $param .= "&search_actioncode=".urlencode($actioncode); } if ($resourceid > 0) $param .= "&search_resourceid=".urlencode($resourceid); -if ($status || isset($_GET['status']) || isset($_POST['status'])) $param .= "&search_status=".urlencode($status); +if ($status || GETPOSTISSET('status')) $param .= "&search_status=".urlencode($status); if ($filter) $param .= "&search_filter=".urlencode($filter); if ($filtert) $param .= "&search_filtert=".urlencode($filtert); if ($usergroup) $param .= "&search_usergroup=".urlencode($usergroup); diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 47c8431072d..fe41203e946 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -86,6 +86,15 @@ $extrafields->fetch_name_optionals_label($object->table_element); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('thirdpartycomm', 'globalcard')); +// Security check +$result = restrictedArea($user, 'societe', $socid, '&societe', '', 'fk_soc', 'rowid', 0); + +if ($object->id > 0) { + if (!($object->client > 0) || empty($user->rights->societe->lire)) { + accessforbidden(); + } +} + $now = dol_now(); diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index 8ce38ba4ea3..7524de9055f 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -233,7 +233,7 @@ if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposa $supplierproposalstatic->total_ht = $obj->total_ht; $supplierproposalstatic->total_tva = $obj->total_tva; $supplierproposalstatic->total_ttc = $obj->total_ttc; - $supplierproposalstatic->statut = $obj->status; + $supplierproposalstatic->statut = $obj->status; $companystatic->id = $obj->socid; $companystatic->name = $obj->name; diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index b2f728ac5f5..db64dd65fe9 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -343,7 +343,7 @@ if (empty($reshook)) $object->ref = GETPOST('ref'); $object->datep = $datep; $object->date = $datep; - $object->date_livraison = $date_delivery; // deprecated + $object->date_livraison = $date_delivery; // deprecated $object->delivery_date = $date_delivery; $object->availability_id = GETPOST('availability_id'); $object->demand_reason_id = GETPOST('demand_reason_id'); @@ -366,9 +366,6 @@ if (empty($reshook)) $object->statut = Propal::STATUS_DRAFT; $object->fk_incoterms = GETPOST('incoterm_id', 'int'); $object->location_incoterms = GETPOST('location_incoterms', 'alpha'); - - // the create is done below and further more the existing create_from function is quite hilarating - //$id = $object->create_from($user); } else { setEventMessages($langs->trans("ErrorFailedToCopyProposal", GETPOST('copie_propal')), null, 'errors'); } @@ -550,9 +547,8 @@ if (empty($reshook)) if ($id > 0) { - // Insertion contact par defaut si defini - if (GETPOST('contactid') > 0) - { + // Insert default contacts if defined + if (GETPOST('contactid') > 0) { $result = $object->add_contact(GETPOST('contactid'), 'CUSTOMER', 'external'); if ($result < 0) { @@ -1347,7 +1343,8 @@ if (empty($reshook)) { if ($object->id > 0) { $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); - $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); + $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type')); + $result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09')); } if ($result >= 0) { @@ -2411,7 +2408,8 @@ if ($action == 'create') if ($action != 'editline') { // Validate - if ($object->statut == Propal::STATUS_DRAFT && $object->total_ttc >= 0 && count($object->lines) > 0) + if (($object->statut == Propal::STATUS_DRAFT && $object->total_ttc >= 0 && count($object->lines) > 0) + || ($object->statut == Propal::STATUS_DRAFT && !empty($conf->global->PROPAL_ENABLE_NEGATIVE) && count($object->lines) > 0)) { if ($usercanvalidate) { diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index bc588f430d9..c761f8b3321 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -155,7 +155,7 @@ class Propal extends CommonObject * @var int Date expected for delivery * @deprecated */ - public $date_livraison; // deprecated; Use delivery_date instead. + public $date_livraison; // deprecated; Use delivery_date instead. /** * @var integer|string $delivery_date; @@ -208,7 +208,6 @@ class Propal extends CommonObject public $demand_reason_id; public $demand_reason_code; - public $products = array(); public $extraparams = array(); /** @@ -355,15 +354,13 @@ class Propal extends CommonObject $this->socid = $socid; $this->id = $propalid; - $this->products = array(); - $this->duree_validite = ((int) $conf->global->PROPALE_VALIDITY_DURATION); } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Add line into array products + * Add line into array ->lines * $this->thirdparty should be loaded * * @param int $idproduct Product Id to add @@ -372,7 +369,6 @@ class Propal extends CommonObject * @return int <0 if KO, >0 if OK * * TODO Replace calls to this function by generation objet Ligne - * inserted into table $this->products */ public function add_product($idproduct, $qty, $remise_percent = 0) { @@ -1279,24 +1275,6 @@ class Propal extends CommonObject } } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Insert into DB a proposal object completely defined by its data members (ex, results from copy). - * - * @param User $user User that create - * @return int Id of the new object if ok, <0 if ko - * @see create() - */ - public function create_from($user) - { - // phpcs:enable - // i love this function because $this->products is not used in create function... - $this->products = $this->lines; - - return $this->create($user); - } - /** * Load an object from its id and create a new one in database * @@ -1525,7 +1503,7 @@ class Propal extends CommonObject $this->date = $this->db->jdate($obj->dp); // Proposal date $this->datep = $this->db->jdate($obj->dp); // deprecated $this->fin_validite = $this->db->jdate($obj->dfv); - $this->date_livraison = $this->db->jdate($obj->delivery_date); // deprecated + $this->date_livraison = $this->db->jdate($obj->delivery_date); // deprecated $this->delivery_date = $this->db->jdate($obj->delivery_date); $this->shipping_method_id = ($obj->fk_shipping_method > 0) ? $obj->fk_shipping_method : null; $this->availability_id = $obj->fk_availability; @@ -2944,7 +2922,7 @@ class Propal extends CommonObject $tabletodelete = $this->table_element_line; $sqlef = "DELETE FROM ".MAIN_DB_PREFIX.$tabletodelete."_extrafields WHERE fk_object IN (SELECT rowid FROM ".MAIN_DB_PREFIX.$tabletodelete." WHERE ".$this->fk_element." = ".$this->id.")"; $sql = "DELETE FROM ".MAIN_DB_PREFIX.$tabletodelete." WHERE ".$this->fk_element." = ".$this->id; - if (! $this->db->query($sqlef) || ! $this->db->query($sql)) { + if (!$this->db->query($sqlef) || !$this->db->query($sql)) { $error++; $this->error = $this->db->lasterror(); $this->errors[] = $this->error; @@ -2977,7 +2955,7 @@ class Propal extends CommonObject if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element." WHERE rowid = ".$this->id; $res = $this->db->query($sql); - if (! $res) { + if (!$res) { $error++; $this->error = $this->db->lasterror(); $this->errors[] = $this->error; @@ -2988,7 +2966,7 @@ class Propal extends CommonObject // Delete record into ECM index and physically if (!$error) { $res = $this->deleteEcmFiles(0); // Deleting files physically is done later with the dol_delete_dir_recursive - if (! $res) { + if (!$res) { $error++; } } diff --git a/htdocs/comm/propal/contact.php b/htdocs/comm/propal/contact.php index 4d70b11cdfe..af3679de945 100644 --- a/htdocs/comm/propal/contact.php +++ b/htdocs/comm/propal/contact.php @@ -79,7 +79,8 @@ if ($action == 'addcontact' && $user->rights->propale->creer) if ($object->id > 0) { $contactid = (GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int')); - $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); + $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type')); + $result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09')); } if ($result >= 0) diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index bba2d61a422..d8f523f16da 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -188,7 +188,7 @@ $arrayfields = array( 'p.fk_statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000), ); // Extra fields -include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_array_fields.tpl.php'; +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; /* diff --git a/htdocs/comm/propal/stats/index.php b/htdocs/comm/propal/stats/index.php index 8b9c6b34dee..34feb8bbe44 100644 --- a/htdocs/comm/propal/stats/index.php +++ b/htdocs/comm/propal/stats/index.php @@ -37,11 +37,11 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; $WIDTH = DolGraph::getDefaultGraphSizeForStats('width'); $HEIGHT = DolGraph::getDefaultGraphSizeForStats('height'); -$mode = GETPOST("mode") ?GETPOST("mode") : 'customer'; +$mode = GETPOSTISSET("mode") ? GETPOST("mode", 'aZ09') : 'customer'; if ($mode == 'customer' && !$user->rights->propale->lire) accessforbidden(); if ($mode == 'supplier' && !$user->rights->supplier_proposal->lire) accessforbidden(); -$object_status = GETPOST('object_status'); +$object_status = GETPOST('object_status', 'intcomma'); $typent_id = GETPOST('typent_id', 'int'); $categ_id = GETPOST('categ_id', 'categ_id'); @@ -55,7 +55,7 @@ if ($user->socid > 0) } $nowyear = strftime("%Y", dol_now()); -$year = GETPOST('year') > 0 ?GETPOST('year') : $nowyear; +$year = GETPOST('year') > 0 ? GETPOST('year', 'int') : $nowyear; //$startyear=$year-2; $startyear = $year - 1; $endyear = $year; diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 1d00389534d..80ff2180801 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -276,7 +276,7 @@ if (empty($reshook)) $object->fk_account = GETPOST('fk_account', 'int'); $object->availability_id = GETPOST('availability_id'); $object->demand_reason_id = GETPOST('demand_reason_id'); - $object->date_livraison = $datelivraison; // deprecated + $object->date_livraison = $datelivraison; // deprecated $object->delivery_date = $datelivraison; $object->shipping_method_id = GETPOST('shipping_method_id', 'int'); $object->warehouse_id = GETPOST('warehouse_id', 'int'); @@ -453,26 +453,14 @@ if (empty($reshook)) if (!$error) { $object_id = $object->create($user); - - // If some invoice's lines already known - $NBLINES = 8; - for ($i = 1; $i <= $NBLINES; $i++) { - if ($_POST['idprod'.$i]) { - $xid = 'idprod'.$i; - $xqty = 'qty'.$i; - $xremise = 'remise_percent'.$i; - $object->add_product($_POST[$xid], $_POST[$xqty], $_POST[$xremise]); - } - } } } // Insert default contacts if defined if ($object_id > 0) { - if (GETPOST('contactid')) - { - $result = $object->add_contact(GETPOST('contactid'), 'CUSTOMER', 'external'); + if (GETPOST('contactid', 'int')) { + $result = $object->add_contact(GETPOST('contactid', 'int'), 'CUSTOMER', 'external'); if ($result < 0) { setEventMessages($langs->trans("ErrorFailedToAddContact"), null, 'errors'); $error++; @@ -931,6 +919,7 @@ if (empty($reshook)) if ($result > 0) { $ret = $object->fetch($object->id); // Reload to get new records + $object->fetch_thirdparty(); if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { // Define output language @@ -1378,7 +1367,8 @@ if (empty($reshook)) { if ($object->id > 0) { $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); - $result = $object->add_contact($contactid, GETPOST('type'), GETPOST('source')); + $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type')); + $result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09')); } if ($result >= 0) { diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 7166a491118..0b68095c5d0 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -184,7 +184,7 @@ class Commande extends CommonOrder * @var int Date expected for delivery * @deprecated */ - public $date_livraison; // deprecated; Use delivery_date instead. + public $date_livraison; // deprecated; Use delivery_date instead. public $delivery_date; // Date expected of shipment (date starting shipment, not the reception that occurs some days after) @@ -199,6 +199,7 @@ class Commande extends CommonOrder public $rang; public $special_code; public $source; // Order mode. How we received order (by phone, by email, ...) + public $extraparams = array(); public $linked_objects = array(); @@ -368,8 +369,6 @@ class Commande extends CommonOrder $this->remise = 0; $this->remise_percent = 0; - - $this->products = array(); } /** @@ -1360,7 +1359,7 @@ class Commande extends CommonOrder $this->fk_account = $object->fk_account; $this->availability_id = $object->availability_id; $this->demand_reason_id = $object->demand_reason_id; - $this->date_livraison = $object->date_livraison; // deprecated + $this->date_livraison = $object->date_livraison; // deprecated $this->delivery_date = $object->date_livraison; $this->shipping_method_id = $object->shipping_method_id; $this->warehouse_id = $object->warehouse_id; @@ -1690,7 +1689,6 @@ class Commande extends CommonOrder * @return void * * TODO Remplacer les appels a cette fonction par generation objet Ligne - * insere dans tableau $this->products */ public function add_product($idproduct, $qty, $remise_percent = 0.0, $date_start = '', $date_end = '') { @@ -1752,15 +1750,13 @@ class Commande extends CommonOrder $prods_arbo = $prod->get_arbo_each_prod(); if(count($prods_arbo) > 0) { - foreach($prods_arbo as $key => $value) - { - // print "id : ".$value[1].' :qty: '.$value[0].'
'; - if(! in_array($value[1],$this->products)) - $this->add_product($value[1], $value[0]); - - } - } - + foreach($prods_arbo as $key => $value) + { + // print "id : ".$value[1].' :qty: '.$value[0].'
'; + if not in lines { + $this->add_product($value[1], $value[0]); + } + } } **/ } @@ -1871,7 +1867,7 @@ class Commande extends CommonOrder $this->availability = $obj->availability_label; $this->demand_reason_id = $obj->fk_input_reason; $this->demand_reason_code = $obj->demand_reason_code; - $this->date_livraison = $this->db->jdate($obj->delivery_date); // deprecated + $this->date_livraison = $this->db->jdate($obj->delivery_date); // deprecated $this->delivery_date = $this->db->jdate($obj->delivery_date); $this->shipping_method_id = ($obj->fk_shipping_method > 0) ? $obj->fk_shipping_method : null; $this->warehouse_id = ($obj->fk_warehouse > 0) ? $obj->fk_warehouse : null; @@ -3086,6 +3082,7 @@ class Commande extends CommonOrder // Clean vat code $vat_src_code = ''; + $reg = array(); if (preg_match('/\((.*)\)/', $txtva, $reg)) { $vat_src_code = $reg[1]; @@ -3276,6 +3273,7 @@ class Commande extends CommonOrder $sql .= " fk_cond_reglement=".(isset($this->cond_reglement_id) ? $this->cond_reglement_id : "null").","; $sql .= " fk_mode_reglement=".(isset($this->mode_reglement_id) ? $this->mode_reglement_id : "null").","; $sql .= " fk_account=".($this->fk_account > 0 ? $this->fk_account : "null").","; + $sql .= " fk_input_reason=".($this->demand_reason_id > 0 ? $this->demand_reason_id : "null").","; $sql .= " note_private=".(isset($this->note_private) ? "'".$this->db->escape($this->note_private)."'" : "null").","; $sql .= " note_public=".(isset($this->note_public) ? "'".$this->db->escape($this->note_public)."'" : "null").","; $sql .= " model_pdf=".(isset($this->modelpdf) ? "'".$this->db->escape($this->modelpdf)."'" : "null").","; @@ -3361,7 +3359,7 @@ class Commande extends CommonOrder $tabletodelete = $this->table_element_line; $sqlef = "DELETE FROM ".MAIN_DB_PREFIX.$tabletodelete."_extrafields WHERE fk_object IN (SELECT rowid FROM ".MAIN_DB_PREFIX.$tabletodelete." WHERE ".$this->fk_element." = ".$this->id.")"; $sql = "DELETE FROM ".MAIN_DB_PREFIX.$tabletodelete." WHERE ".$this->fk_element." = ".$this->id; - if (! $this->db->query($sqlef) || ! $this->db->query($sql)) { + if (!$this->db->query($sqlef) || !$this->db->query($sql)) { $error++; $this->error = $this->db->lasterror(); $this->errors[] = $this->error; @@ -3394,7 +3392,7 @@ class Commande extends CommonOrder if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element." WHERE rowid = ".$this->id; $res = $this->db->query($sql); - if (! $res) { + if (!$res) { $error++; $this->error = $this->db->lasterror(); $this->errors[] = $this->error; @@ -3405,7 +3403,7 @@ class Commande extends CommonOrder // Delete record into ECM index and physically if (!$error) { $res = $this->deleteEcmFiles(0); // Deleting files physically is done later with the dol_delete_dir_recursive - if (! $res) { + if (!$res) { $error++; } } diff --git a/htdocs/commande/contact.php b/htdocs/commande/contact.php index a3c31d4cf7b..7df7dbea130 100644 --- a/htdocs/commande/contact.php +++ b/htdocs/commande/contact.php @@ -56,7 +56,8 @@ if ($action == 'addcontact' && $user->rights->commande->creer) if ($result > 0 && $id > 0) { $contactid = (GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int')); - $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); + $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type')); + $result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09')); } if ($result >= 0) diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 14b05b587b3..72a5e179f25 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -109,7 +109,7 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page == -1 || !empty($search_btn) || !empty($search_remove_btn) || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 +if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; @@ -142,38 +142,38 @@ if (empty($user->socid)) $fieldstosearchall["c.note_private"] = "NotePrivate"; $checkedtypetiers = 0; $arrayfields = array( - 'c.ref'=>array('label'=>"Ref", 'checked'=>1), - 'c.ref_client'=>array('label'=>"RefCustomerOrder", 'checked'=>1), - 'p.ref'=>array('label'=>"ProjectRef", 'checked'=>1, 'enabled'=>(empty($conf->projet->enabled) ? 0 : 1)), - 'p.title'=>array('label'=>"ProjectLabel", 'checked'=>0, 'enabled'=>(empty($conf->projet->enabled) ? 0 : 1)), - 's.nom'=>array('label'=>"ThirdParty", 'checked'=>1), - 's.town'=>array('label'=>"Town", 'checked'=>1), - 's.zip'=>array('label'=>"Zip", 'checked'=>1), - 'state.nom'=>array('label'=>"StateShort", 'checked'=>0), - 'country.code_iso'=>array('label'=>"Country", 'checked'=>0), - 'typent.code'=>array('label'=>"ThirdPartyType", 'checked'=>$checkedtypetiers), - 'c.date_commande'=>array('label'=>"OrderDateShort", 'checked'=>1), - 'c.date_delivery'=>array('label'=>"DateDeliveryPlanned", 'checked'=>1, 'enabled'=>empty($conf->global->ORDER_DISABLE_DELIVERY_DATE)), - 'c.total_ht'=>array('label'=>"AmountHT", 'checked'=>1), - 'c.total_vat'=>array('label'=>"AmountVAT", 'checked'=>0), - 'c.total_ttc'=>array('label'=>"AmountTTC", 'checked'=>0), - 'c.multicurrency_code'=>array('label'=>'Currency', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)), - 'c.multicurrency_tx'=>array('label'=>'CurrencyRate', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)), - 'c.multicurrency_total_ht'=>array('label'=>'MulticurrencyAmountHT', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)), - 'c.multicurrency_total_vat'=>array('label'=>'MulticurrencyAmountVAT', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)), - 'c.multicurrency_total_ttc'=>array('label'=>'MulticurrencyAmountTTC', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)), - 'u.login'=>array('label'=>"Author", 'checked'=>1, 'position'=>10), - 'c.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500), - 'c.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500), - 'c.date_cloture'=>array('label'=>"DateClosing", 'checked'=>0, 'position'=>500), - 'c.note_public'=>array('label'=>'NotePublic', 'checked'=>0, 'position'=>510, 'enabled'=>(empty($conf->global->MAIN_LIST_ALLOW_PUBLIC_NOTES))), - 'c.note_private'=>array('label'=>'NotePrivate', 'checked'=>0, 'position'=>511, 'enabled'=>(empty($conf->global->MAIN_LIST_ALLOW_PRIVATE_NOTES))), - 'c.fk_statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000), - 'c.facture'=>array('label'=>"Billed", 'checked'=>1, 'position'=>1000, 'enabled'=>(empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))), - 'shippable'=>array('label'=>"Shippable", 'checked'=>1, 'position'=>1000, 'enabled'=>(!empty($conf->expedition->enabled))) + 'c.ref'=>array('label'=>"Ref", 'checked'=>1, 'position'=>5), + 'c.ref_client'=>array('label'=>"RefCustomerOrder", 'checked'=>-1, 'position'=>10), + 'p.ref'=>array('label'=>"ProjectRef", 'checked'=>1, 'enabled'=>(empty($conf->projet->enabled) ? 0 : 1), 'position'=>20), + 'p.title'=>array('label'=>"ProjectLabel", 'checked'=>0, 'enabled'=>(empty($conf->projet->enabled) ? 0 : 1), 'position'=>25), + 's.nom'=>array('label'=>"ThirdParty", 'checked'=>1, 'position'=>30), + 's.town'=>array('label'=>"Town", 'checked'=>1, 'position'=>35), + 's.zip'=>array('label'=>"Zip", 'checked'=>1, 'position'=>40), + 'state.nom'=>array('label'=>"StateShort", 'checked'=>0, 'position'=>45), + 'country.code_iso'=>array('label'=>"Country", 'checked'=>0, 'position'=>50), + 'typent.code'=>array('label'=>"ThirdPartyType", 'checked'=>$checkedtypetiers, 'position'=>55), + 'c.date_commande'=>array('label'=>"OrderDateShort", 'checked'=>1, 'position'=>60), + 'c.date_delivery'=>array('label'=>"DateDeliveryPlanned", 'checked'=>1, 'enabled'=>empty($conf->global->ORDER_DISABLE_DELIVERY_DATE), 'position'=>65), + 'c.total_ht'=>array('label'=>"AmountHT", 'checked'=>1, 'position'=>75), + 'c.total_vat'=>array('label'=>"AmountVAT", 'checked'=>0, 'position'=>80), + 'c.total_ttc'=>array('label'=>"AmountTTC", 'checked'=>0, 'position'=>85), + 'c.multicurrency_code'=>array('label'=>'Currency', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>90), + 'c.multicurrency_tx'=>array('label'=>'CurrencyRate', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>95), + 'c.multicurrency_total_ht'=>array('label'=>'MulticurrencyAmountHT', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>100), + 'c.multicurrency_total_vat'=>array('label'=>'MulticurrencyAmountVAT', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>105), + 'c.multicurrency_total_ttc'=>array('label'=>'MulticurrencyAmountTTC', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>110), + 'u.login'=>array('label'=>"Author", 'checked'=>1, 'position'=>10, 'position'=>115), + 'c.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500, 'position'=>120), + 'c.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500, 'position'=>125), + 'c.date_cloture'=>array('label'=>"DateClosing", 'checked'=>0, 'position'=>500, 'position'=>130), + 'c.note_public'=>array('label'=>'NotePublic', 'checked'=>0, 'position'=>510, 'enabled'=>(empty($conf->global->MAIN_LIST_ALLOW_PUBLIC_NOTES)), 'position'=>135), + 'c.note_private'=>array('label'=>'NotePrivate', 'checked'=>0, 'position'=>511, 'enabled'=>(empty($conf->global->MAIN_LIST_ALLOW_PRIVATE_NOTES)), 'position'=>140), + 'c.facture'=>array('label'=>"Billed", 'checked'=>1, 'position'=>990, 'enabled'=>(empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)), 'position'=>145), + 'shippable'=>array('label'=>"Shippable", 'checked'=>1, 'position'=>995, 'enabled'=>(!empty($conf->expedition->enabled)), 'position'=>150), + 'c.fk_statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000, 'position'=>155) ); // Extra fields -include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_array_fields.tpl.php'; +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); @@ -448,10 +448,10 @@ if ($resql) if ($search_status != '') $param .= '&search_status='.urlencode($search_status); if ($search_datecloture_start) $param .= '&search_datecloture_start='.urlencode($search_datecloture_start); if ($search_datecloture_end) $param .= '&search_datecloture_end='.urlencode($search_datecloture_end); - if ($search_dateorder_start) $param .= '&search_dateorder_start_day=' . dol_print_date($search_dateorder_start, '%d') . '&search_dateorder_start_month=' . dol_print_date($search_dateorder_start, '%m') . '&search_dateorder_start_year=' . dol_print_date($search_dateorder_start, '%Y'); - if ($search_dateorder_end) $param .= '&search_dateorder_end_day=' . dol_print_date($search_dateorder_end, '%d') . '&search_dateorder_end_month=' . dol_print_date($search_dateorder_end, '%m') . '&search_dateorder_end_year=' . dol_print_date($search_dateorder_end, '%Y'); - if ($search_datedelivery_start) $param .= '&search_datedelivery_start_day=' . dol_print_date($search_datedelivery_start, '%d') . '&search_datedelivery_start_month=' . dol_print_date($search_datedelivery_start, '%m') . '&search_datedelivery_start_year=' . dol_print_date($search_datedelivery_start, '%Y'); - if ($search_datedelivery_end) $param .= '&search_datedelivery_end_day=' . dol_print_date($search_datedelivery_end, '%d') . '&search_datedelivery_end_month=' . dol_print_date($search_datedelivery_end, '%m') . '&search_datedelivery_end_year=' . dol_print_date($search_datedelivery_end, '%Y'); + if ($search_dateorder_start) $param .= '&search_dateorder_start_day='.dol_print_date($search_dateorder_start, '%d').'&search_dateorder_start_month='.dol_print_date($search_dateorder_start, '%m').'&search_dateorder_start_year='.dol_print_date($search_dateorder_start, '%Y'); + if ($search_dateorder_end) $param .= '&search_dateorder_end_day='.dol_print_date($search_dateorder_end, '%d').'&search_dateorder_end_month='.dol_print_date($search_dateorder_end, '%m').'&search_dateorder_end_year='.dol_print_date($search_dateorder_end, '%Y'); + if ($search_datedelivery_start) $param .= '&search_datedelivery_start_day='.dol_print_date($search_datedelivery_start, '%d').'&search_datedelivery_start_month='.dol_print_date($search_datedelivery_start, '%m').'&search_datedelivery_start_year='.dol_print_date($search_datedelivery_start, '%Y'); + if ($search_datedelivery_end) $param .= '&search_datedelivery_end_day='.dol_print_date($search_datedelivery_end, '%d').'&search_datedelivery_end_month='.dol_print_date($search_datedelivery_end, '%m').'&search_datedelivery_end_year='.dol_print_date($search_datedelivery_end, '%Y'); if ($search_ref) $param .= '&search_ref='.urlencode($search_ref); if ($search_company) $param .= '&search_company='.urlencode($search_company); if ($search_ref_customer) $param .= '&search_ref_customer='.urlencode($search_ref_customer); @@ -831,27 +831,12 @@ if ($resql) print ''; } - // Status - if (!empty($arrayfields['c.fk_statut']['checked'])) - { - print ''; - } // Shippable if (!empty($arrayfields['shippable']['checked'])) { print ''; } + // Status + if (!empty($arrayfields['c.fk_statut']['checked'])) + { + print ''; + } // Action column print ''; if (!empty($arrayfields['c.ref']['checked'])) print_liste_field_titre($arrayfields['c.ref']['label'], $_SERVER["PHP_SELF"], 'c.ref', '', $param, '', $sortfield, $sortorder); if (!empty($arrayfields['c.ref_client']['checked'])) print_liste_field_titre($arrayfields['c.ref_client']['label'], $_SERVER["PHP_SELF"], 'c.ref_client', '', $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['p.title']['checked'])) print_liste_field_titre($arrayfields['p.title']['label'], $_SERVER["PHP_SELF"], "p.title", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['p.title']['checked'])) print_liste_field_titre($arrayfields['p.title']['label'], $_SERVER["PHP_SELF"], "p.title", "", $param, '', $sortfield, $sortorder); if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], 's.nom', '', $param, '', $sortfield, $sortorder); if (!empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder); if (!empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder); @@ -909,9 +909,9 @@ if ($resql) if (!empty($arrayfields['c.date_cloture']['checked'])) print_liste_field_titre($arrayfields['c.date_cloture']['label'], $_SERVER["PHP_SELF"], "c.date_cloture", "", $param, '', $sortfield, $sortorder, 'center nowrap '); if (!empty($arrayfields['c.note_public']['checked'])) print_liste_field_titre($arrayfields['c.note_public']['label'], $_SERVER["PHP_SELF"], "c.note_public", "", $param, '', $sortfield, $sortorder, 'right '); if (!empty($arrayfields['c.note_private']['checked'])) print_liste_field_titre($arrayfields['c.note_private']['label'], $_SERVER["PHP_SELF"], "c.note_private", "", $param, '', $sortfield, $sortorder, 'right '); - if (!empty($arrayfields['c.fk_statut']['checked'])) print_liste_field_titre($arrayfields['c.fk_statut']['label'], $_SERVER["PHP_SELF"], "c.fk_statut", "", $param, '', $sortfield, $sortorder, 'right '); if (!empty($arrayfields['shippable']['checked'])) print_liste_field_titre($arrayfields['shippable']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center '); if (!empty($arrayfields['c.facture']['checked'])) print_liste_field_titre($arrayfields['c.facture']['label'], $_SERVER["PHP_SELF"], 'c.facture', '', $param, '', $sortfield, $sortorder, 'center '); + if (!empty($arrayfields['c.fk_statut']['checked'])) print_liste_field_titre($arrayfields['c.fk_statut']['label'], $_SERVER["PHP_SELF"], "c.fk_statut", "", $param, '', $sortfield, $sortorder, 'center '); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'maxwidthsearch center '); print ''."\n"; @@ -950,7 +950,7 @@ if ($resql) $generic_commande->statut = $obj->fk_statut; $generic_commande->billed = $obj->billed; $generic_commande->date = $db->jdate($obj->date_commande); - $generic_commande->date_livraison = $db->jdate($obj->date_delivery); // deprecated + $generic_commande->date_livraison = $db->jdate($obj->date_delivery); // deprecated $generic_commande->delivery_date = $db->jdate($obj->date_delivery); $generic_commande->ref_client = $obj->ref_client; $generic_commande->total_ht = $obj->total_ht; @@ -1218,13 +1218,6 @@ if ($resql) if (!$i) $totalarray['nbfield']++; } - // Status - if (!empty($arrayfields['c.fk_statut']['checked'])) - { - print ''; - if (!$i) $totalarray['nbfield']++; - } - // Show shippable Icon (this creates subloops, so may be slow) if (!empty($arrayfields['shippable']['checked'])) { @@ -1242,7 +1235,7 @@ if ($resql) // Get local and virtual stock and store it into cache if (empty($productstat_cache[$generic_commande->lines[$lig]->fk_product])) { - $generic_product->load_stock('nobatch'); // ->load_virtual_stock() is already included into load_stock() + $generic_product->load_stock('nobatch'); // ->load_virtual_stock() is already included into load_stock() $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stock_reel'] = $generic_product->stock_reel; $productstat_cachevirtual[$generic_commande->lines[$lig]->fk_product]['stock_reel'] = $generic_product->stock_theorique; } else { @@ -1252,9 +1245,9 @@ if ($resql) if (empty($conf->global->SHIPPABLE_ORDER_ICON_IN_LIST)) // Default code. Default should be this case. { - $text_info .= $generic_commande->lines[$lig]->qty . ' X ' . $generic_commande->lines[$lig]->product_ref . ' ' . dol_trunc($generic_commande->lines[$lig]->product_label, 25); - $text_info .= ' - ' . $langs->trans("Stock") . ': ' . $generic_product->stock_reel . ''; - $text_info .= ' - ' . $langs->trans("VirtualStock") . ': ' . $generic_product->stock_theorique . ''; + $text_info .= $generic_commande->lines[$lig]->qty.' X '.$generic_commande->lines[$lig]->product_ref.' '.dol_trunc($generic_commande->lines[$lig]->product_label, 25); + $text_info .= ' - '.$langs->trans("Stock").': '.$generic_product->stock_reel.''; + $text_info .= ' - '.$langs->trans("VirtualStock").': '.$generic_product->stock_theorique.''; $text_info .= '
'; if ($generic_commande->lines[$lig]->qty > $generic_product->stock_reel) { @@ -1288,20 +1281,20 @@ if ($resql) $stock_order_supplier = $generic_product->stats_commande_fournisseur['qty']; } } - $text_info .= $generic_commande->lines[$lig]->qty . ' X ' . $generic_commande->lines[$lig]->ref . ' ' . dol_trunc($generic_commande->lines[$lig]->product_label, 25); - $text_stock_reel = $generic_product->stock_reel . '/' . $stock_order; + $text_info .= $generic_commande->lines[$lig]->qty.' X '.$generic_commande->lines[$lig]->ref.' '.dol_trunc($generic_commande->lines[$lig]->product_label, 25); + $text_stock_reel = $generic_product->stock_reel.'/'.$stock_order; if ($stock_order > $generic_product->stock_reel && !($generic_product->stock_reel < $generic_commande->lines[$lig]->qty)) { $warning++; - $text_warning .= '' . $langs->trans('Available') . ' : ' . $text_stock_reel . ''; + $text_warning .= ''.$langs->trans('Available').' : '.$text_stock_reel.''; } if ($generic_product->stock_reel < $generic_commande->lines[$lig]->qty) { $notshippable++; - $text_info .= '' . $langs->trans('Available') . ' : ' . $text_stock_reel . ''; + $text_info .= ''.$langs->trans('Available').' : '.$text_stock_reel.''; } else { - $text_info .= '' . $langs->trans('Available') . ' : ' . $text_stock_reel . ''; + $text_info .= ''.$langs->trans('Available').' : '.$text_stock_reel.''; } if (!empty($conf->fournisseur->enabled)) { - $text_info .= ' ' . $langs->trans('SupplierOrder') . ' : ' . $stock_order_supplier . '
'; + $text_info .= ' '.$langs->trans('SupplierOrder').' : '.$stock_order_supplier.'
'; } else { $text_info .= '
'; } @@ -1310,10 +1303,10 @@ if ($resql) } if ($notshippable == 0) { $text_icon = img_picto('', 'dolly', '', false, 0, 0, '', 'green paddingleft'); - $text_info = $langs->trans('Shippable') . '
' . $text_info; + $text_info = $langs->trans('Shippable').'
'.$text_info; } else { $text_icon = img_picto('', 'dolly', '', false, 0, 0, '', 'error paddingleft'); - $text_info = $langs->trans('NonShippable') . '
' . $text_info; + $text_info = $langs->trans('NonShippable').'
'.$text_info; } } @@ -1321,7 +1314,7 @@ if ($resql) print $form->textwithtooltip('', $text_info, 2, 1, $text_icon, '', 2); } if ($warning) { // Always false in default mode - print $form->textwithtooltip('', $langs->trans('NotEnoughForAllOrders') . '
' . $text_warning, 2, 1, img_picto('', 'error'), '', 2); + print $form->textwithtooltip('', $langs->trans('NotEnoughForAllOrders').'
'.$text_warning, 2, 1, img_picto('', 'error'), '', 2); } } print ''; @@ -1334,6 +1327,13 @@ if ($resql) if (!$i) $totalarray['nbfield']++; } + // Status + if (!empty($arrayfields['c.fk_statut']['checked'])) + { + print ''; + if (!$i) $totalarray['nbfield']++; + } + // Action column print ''; // Year diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index 02c89772e94..902a96ec16c 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -225,17 +225,16 @@ if ((GETPOST('confirm_savestatement', 'alpha') || GETPOST('confirm_reconcile', ' if ($num_releve) { $bankline = new AccountLine($db); - if (isset($_POST['rowid']) && is_array($_POST['rowid'])) - { - foreach ($_POST['rowid'] as $row) - { - if ($row > 0) - { + + $rowids = GETPOST('rowid', 'array'); + + if (!empty($rowids) && is_array($rowids)) { + foreach ($rowids as $row) { + if ($row > 0) { $result = $bankline->fetch($row); $bankline->num_releve = $num_releve; //$_POST["num_releve"]; $result = $bankline->update_conciliation($user, GETPOST("cat"), GETPOST('confirm_reconcile', 'alpha') ? 1 : 0); // If we confirm_reconcile, we set flag 'rappro' to 1. - if ($result < 0) - { + if ($result < 0) { setEventMessages($bankline->error, $bankline->errors, 'errors'); $error++; break; diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index be938d3bf70..30e483fdfa9 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -346,7 +346,7 @@ if ($action == 'create') // Type print ''; print ''; // Currency @@ -354,7 +354,7 @@ if ($action == 'create') print ''; @@ -367,9 +367,8 @@ if ($action == 'create') // Country $selectedcode = ''; - if (isset($_POST["account_country_id"])) - { - $selectedcode = $_POST["account_country_id"] ? $_POST["account_country_id"] : $object->country_code; + if (GETPOSTISSET("account_country_id")) { + $selectedcode = GETPOST("account_country_id") ? GETPOST("account_country_id") : $object->country_code; } elseif (empty($selectedcode)) $selectedcode = $mysoc->country_code; $object->country_code = getCountry($selectedcode, 2); // Force country code on account to have following field on bank fields matching country rules @@ -383,7 +382,7 @@ if ($action == 'create') print '"; } @@ -818,16 +817,16 @@ if ($action == 'create') // Ref print ''; - print ''; + print ''; // Label print ''; - print ''; + print ''; // Type print ''; print ''; // Currency @@ -837,7 +836,7 @@ if ($action == 'create') print ''; @@ -845,13 +844,13 @@ if ($action == 'create') // Status print ''; print ''; // Country $object->country_id = $object->country_id ? $object->country_id : $mysoc->country_id; $selectedcode = $object->country_code; - if (isset($_POST["account_country_id"])) $selectedcode = $_POST["account_country_id"]; + if (GETPOSTISSET("account_country_id")) $selectedcode = GETPOST("account_country_id"); elseif (empty($selectedcode)) $selectedcode = $mysoc->country_code; $object->country_code = getCountry($selectedcode, 2); // Force country code on account to have following field on bank fields matching country rules @@ -865,7 +864,7 @@ if ($action == 'create') print ''; - print ''; + print ''; print ''; - print ''; + print ''; // Web print ''; - print ''; // Tags-Categories @@ -905,7 +904,7 @@ if ($action == 'create') $arrayselected[] = $cat->id; } } - print $form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, '', 0, '100%'); + print img_picto('', 'category').$form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0); print ""; } diff --git a/htdocs/compta/bank/graph.php b/htdocs/compta/bank/graph.php index 524877746f8..f4fa779fd7d 100644 --- a/htdocs/compta/bank/graph.php +++ b/htdocs/compta/bank/graph.php @@ -771,11 +771,11 @@ print '
'.$langs->trans("Description").''; +print ''; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $doleditor = new DolEditor('description', $object->description, '', 200, 'dolibarr_notes', '', false, true, $conf->fckeditor->enabled, ROWS_6, '90%'); $doleditor->Create(); @@ -154,7 +154,7 @@ print '
'.$langs->trans("Color").''; +print ''; print $formother->selectColor($object->color, 'color'); print '
'.$langs->trans("Status").' / '.$langs->trans("Percentage").''; $percent = -1; - if (isset($_GET['status']) || isset($_POST['status'])) $percent = GETPOST('status'); - elseif (isset($_GET['percentage']) || isset($_POST['percentage'])) $percent = GETPOST('percentage'); + if (GETPOSTISSET('status')) $percent = GETPOST('status'); + elseif (GETPOSTISSET('percentage')) $percent = GETPOST('percentage'); else { if (GETPOST('complete') == '0' || GETPOST("afaire") == 1) $percent = '0'; elseif (GETPOST('complete') == 100 || GETPOST("afaire") == 2) $percent = 100; @@ -1104,7 +1104,7 @@ if ($action == 'create') // Categories print '
'.$langs->trans("Categories").''; $cate_arbo = $form->select_all_categories(Categorie::TYPE_ACTIONCOMM, '', 'parent', 64, 0, 1); - print $form->multiselectarray('categories', $cate_arbo, GETPOST('categories', 'array'), '', 0, 'minwidth300 quatrevingtpercent', 0, 0); + print img_picto('', 'category').$form->multiselectarray('categories', $cate_arbo, GETPOST('categories', 'array'), '', 0, 'minwidth300 quatrevingtpercent widthcentpercentminusx', 0, 0); print "
'; print ''; - $liststatus = array( - Commande::STATUS_DRAFT=>$langs->trans("StatusOrderDraftShort"), - Commande::STATUS_VALIDATED=>$langs->trans("StatusOrderValidated"), - Commande::STATUS_SHIPMENTONPROCESS=>$langs->trans("StatusOrderSentShort"), - Commande::STATUS_CLOSED=>$langs->trans("StatusOrderDelivered"), - -3=>$langs->trans("StatusOrderValidatedShort").'+'.$langs->trans("StatusOrderSentShort").'+'.$langs->trans("StatusOrderDelivered"), - Commande::STATUS_CANCELED=>$langs->trans("StatusOrderCanceledShort") - ); - print $form->selectarray('search_status', $liststatus, $search_status, -4, 0, 0, '', 0, 0, 0, '', 'maxwidth100', 1); - print ''; //print $form->selectyesno('search_shippable', $search_shippable, 1, 0, 1, 1); - if (! empty($conf->global->ORDER_SHIPABLE_STATUS_DISABLED_BY_DEFAULT)) { + if (!empty($conf->global->ORDER_SHIPABLE_STATUS_DISABLED_BY_DEFAULT)) { print ''; print $langs->trans('ShowShippableStatus'); } else { @@ -866,6 +851,21 @@ if ($resql) print $form->selectyesno('search_billed', $search_billed, 1, 0, 1, 1); print ''; + $liststatus = array( + Commande::STATUS_DRAFT=>$langs->trans("StatusOrderDraftShort"), + Commande::STATUS_VALIDATED=>$langs->trans("StatusOrderValidated"), + Commande::STATUS_SHIPMENTONPROCESS=>$langs->trans("StatusOrderSentShort"), + Commande::STATUS_CLOSED=>$langs->trans("StatusOrderDelivered"), + -3=>$langs->trans("StatusOrderValidatedShort").'+'.$langs->trans("StatusOrderSentShort").'+'.$langs->trans("StatusOrderDelivered"), + Commande::STATUS_CANCELED=>$langs->trans("StatusOrderCanceledShort") + ); + print $form->selectarray('search_status', $liststatus, $search_status, -4, 0, 0, '', 0, 0, 0, '', 'maxwidth100', 1); + print ''; $searchpicto = $form->showFilterButtons(); @@ -878,8 +878,8 @@ if ($resql) print '
'.$generic_commande->LibStatut($obj->fk_statut, $obj->billed, 5, 1).''.$generic_commande->LibStatut($obj->fk_statut, $obj->billed, 5, 1).''; if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined diff --git a/htdocs/commande/stats/index.php b/htdocs/commande/stats/index.php index 54846a32852..6e5e022c651 100644 --- a/htdocs/commande/stats/index.php +++ b/htdocs/commande/stats/index.php @@ -38,11 +38,11 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; $WIDTH = DolGraph::getDefaultGraphSizeForStats('width'); $HEIGHT = DolGraph::getDefaultGraphSizeForStats('height'); -$mode = GETPOST("mode") ?GETPOST("mode") : 'customer'; +$mode = GETPOSTISSET("mode") ? GETPOST("mode", 'aZ09') : 'customer'; if ($mode == 'customer' && !$user->rights->commande->lire) accessforbidden(); if ($mode == 'supplier' && !$user->rights->fournisseur->commande->lire) accessforbidden(); -$object_status = GETPOST('object_status'); +$object_status = GETPOST('object_status', 'intcomma'); $typent_id = GETPOST('typent_id', 'int'); $categ_id = GETPOST('categ_id', 'categ_id'); @@ -302,11 +302,11 @@ if ($mode == 'customer') Commande::STATUS_CLOSED=>$langs->trans("StatusOrderDelivered"), Commande::STATUS_CANCELED=>$langs->trans("StatusOrderCanceled") ); - print $form->selectarray('object_status', $liststatus, GETPOST('object_status', 'int'), -4); + print $form->selectarray('object_status', $liststatus, GETPOST('object_status', 'intcomma'), -4); } if ($mode == 'supplier') { - $formorder->selectSupplierOrderStatus((strstr($object_status, ',') ?-1 : $object_status), 0, 'object_status'); + $formorder->selectSupplierOrderStatus((strstr($object_status, ',') ? -1 : $object_status), 0, 'object_status'); } print '
'.$langs->trans("AccountType").''; - $formbank->selectTypeOfBankAccount(isset($_POST["type"]) ? $_POST["type"] : Account::TYPE_CURRENT, "type"); + $formbank->selectTypeOfBankAccount(GETPOSTISSET("type") ? GETPOST("type") : Account::TYPE_CURRENT, "type"); print '
'; $selectedcode = $object->currency_code; if (!$selectedcode) $selectedcode = $conf->currency; - print $form->selectCurrency((isset($_POST["account_currency_code"]) ? $_POST["account_currency_code"] : $selectedcode), 'account_currency_code'); + print $form->selectCurrency((GETPOSTISSET("account_currency_code") ? GETPOST("account_currency_code") : $selectedcode), 'account_currency_code'); //print $langs->trans("Currency".$conf->currency); //print ''; print '
'.$langs->trans('State').''; if ($selectedcode) { - $formcompany->select_departement(isset($_POST["account_state_id"]) ? $_POST["account_state_id"] : '', $selectedcode, 'account_state_id'); + $formcompany->select_departement(GETPOSTISSET("account_state_id") ? GETPOST("account_state_id") : '', $selectedcode, 'account_state_id'); } else { print $countrynotdefined; } @@ -408,7 +407,7 @@ if ($action == 'create') $arrayselected[] = $cat->id; } } - print $form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, '', 0, '100%'); + print img_picto('', 'category').$form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0); print "
'.$langs->trans("Ref").'ref).'">
ref).'">
'.$langs->trans("Label").'label).'">
label).'">
'.$langs->trans("AccountType").''; - $formbank->selectTypeOfBankAccount((isset($_POST["type"]) ? $_POST["type"] : $object->type), "type"); + $formbank->selectTypeOfBankAccount((GETPOSTISSET("type") ? GETPOST("type") : $object->type), "type"); print '
'; $selectedcode = $object->currency_code; if (!$selectedcode) $selectedcode = $conf->currency; - print $form->selectCurrency((isset($_POST["account_currency_code"]) ? $_POST["account_currency_code"] : $selectedcode), 'account_currency_code'); + print $form->selectCurrency((GETPOSTISSET("account_currency_code") ? GETPOST("account_currency_code") : $selectedcode), 'account_currency_code'); //print $langs->trans("Currency".$conf->currency); //print ''; print '
'.$langs->trans("Status").''; - print $form->selectarray("clos", $object->status, (isset($_POST["clos"]) ? $_POST["clos"] : $object->clos)); + print $form->selectarray("clos", $object->status, (GETPOSTISSET("clos") ? GETPOST("clos") : $object->clos)); print '
'.$langs->trans('State').''; if ($selectedcode) { - print $formcompany->select_state(isset($_POST["account_state_id"]) ? $_POST["account_state_id"] : $object->state_id, $selectedcode, 'account_state_id'); + print $formcompany->select_state(GETPOSTISSET("account_state_id") ? GETPOST("account_state_id") : $object->state_id, $selectedcode, 'account_state_id'); } else { print $countrynotdefined; } @@ -882,14 +881,14 @@ if ($action == 'create') // Balance print '
'.$langs->trans("BalanceMinimalAllowed").'min_allowed).'">
min_allowed).'">
'.$langs->trans("BalanceMinimalDesired").'min_desired).'">
min_desired).'">
'.$langs->trans("Web").'url).'">'; + print 'url).'">'; print '
'; print ''; } else { print ''; diff --git a/htdocs/compta/facture/card-rec.php b/htdocs/compta/facture/card-rec.php index c191c87f219..11dec142a17 100644 --- a/htdocs/compta/facture/card-rec.php +++ b/htdocs/compta/facture/card-rec.php @@ -117,6 +117,8 @@ $usercancreatewithdrarequest = $user->rights->prelevement->bons->creer; $now = dol_now(); +$error = 0; + /* * Actions @@ -287,13 +289,21 @@ if (empty($reshook)) elseif ($action == 'setref' && $user->rights->facture->creer) { //var_dump(GETPOST('ref', 'alpha'));exit; - $result = $object->setValueFrom('titre', GETPOST('ref', 'alpha'), '', null, 'text', '', $user, 'BILLREC_MODIFY'); + $result = $object->setValueFrom('titre', $ref, '', null, 'text', '', $user, 'BILLREC_MODIFY'); if ($result > 0) { $object->titre = GETPOST('ref', 'alpha'); // deprecated $object->title = GETPOST('ref', 'alpha'); $object->ref = $object->title; - } else dol_print_error($db, $object->error, $object->errors); + } else { + $error++; + if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { + $langs->load("errors"); + setEventMessages($langs->trans('ErrorRefAlreadyExists', $ref), null, 'errors'); + } else { + setEventMessages($object->error, $object->errors, 'errors'); + } + } } // Set bank account elseif ($action == 'setbankaccount' && $user->rights->facture->creer) { @@ -1233,7 +1243,7 @@ if ($action == 'create') print '
'; print '
'; - print '
'.$morehtml.'     '; if ($mode == 'showalltime') { - print ''; + print ''; print $langs->trans("GoBack"); print ''; } else { - print ''; + print ''; print $langs->trans("ShowAllTimeBalance"); print ''; } @@ -793,7 +793,7 @@ if ($mode == 'standard') if ($nextmonth > 12) { $nextmonth = 1; $nextyear++; } // For month - $link = "".img_previous('', 'class="valignbottom"')." ".$langs->trans("Month")." ".img_next('', 'class="valignbottom"').""; + $link = "".img_previous('', 'class="valignbottom"')." ".$langs->trans("Month")." ".img_next('', 'class="valignbottom"').""; print '
'.$link.'
'; print '
'; @@ -807,7 +807,7 @@ if ($mode == 'standard') // For year $prevyear = $year - 1; $nextyear = $year + 1; - $link = "".img_previous('', 'class="valignbottom"')." ".$langs->trans("Year")." ".img_next('', 'class="valignbottom"').""; + $link = "".img_previous('', 'class="valignbottom"')." ".$langs->trans("Year")." ".img_next('', 'class="valignbottom"').""; print '
'.$link.'
'; diff --git a/htdocs/compta/bank/line.php b/htdocs/compta/bank/line.php index 42bddce5d28..33f7f3a0352 100644 --- a/htdocs/compta/bank/line.php +++ b/htdocs/compta/bank/line.php @@ -139,17 +139,17 @@ if ($user->rights->banque->modifier && $action == "update") $sql = "UPDATE ".MAIN_DB_PREFIX."bank"; $sql .= " SET "; // Always opened - if (isset($_POST['value'])) $sql .= " fk_type='".$db->escape(GETPOST('value'))."',"; - if (isset($_POST['num_chq'])) $sql .= " num_chq='".$db->escape(GETPOST("num_chq"))."',"; - if (isset($_POST['banque'])) $sql .= " banque='".$db->escape(GETPOST("banque"))."',"; - if (isset($_POST['emetteur'])) $sql .= " emetteur='".$db->escape(GETPOST("emetteur"))."',"; + if (GETPOSTISSET('value')) $sql .= " fk_type='".$db->escape(GETPOST('value'))."',"; + if (GETPOSTISSET('num_chq')) $sql .= " num_chq='".$db->escape(GETPOST("num_chq"))."',"; + if (GETPOSTISSET('banque')) $sql .= " banque='".$db->escape(GETPOST("banque"))."',"; + if (GETPOSTISSET('emetteur')) $sql .= " emetteur='".$db->escape(GETPOST("emetteur"))."',"; // Blocked when conciliated if (!$acline->rappro) { - if (isset($_POST['label'])) $sql .= " label = '".$db->escape(GETPOST("label"))."',"; - if (isset($_POST['amount'])) $sql .= " amount= '".$db->escape($amount)."',"; - if (isset($_POST['dateomonth'])) $sql .= " dateo = '".$db->idate($dateop)."',"; - if (isset($_POST['datevmonth'])) $sql .= " datev = '".$db->idate($dateval)."',"; + if (GETPOSTISSET('label')) $sql .= " label = '".$db->escape(GETPOST("label"))."',"; + if (GETPOSTISSET('amount')) $sql .= " amount= '".$db->escape($amount)."',"; + if (GETPOSTISSET('dateomonth')) $sql .= " dateo = '".$db->idate($dateop)."',"; + if (GETPOSTISSET('datevmonth')) $sql .= " datev = '".$db->idate($dateval)."',"; } $sql .= " fk_account = ".$actarget->id; $sql .= " WHERE rowid = ".$acline->id; @@ -613,7 +613,7 @@ if ($result) if ($user->rights->banque->consolidate) { print '
'; - print 'rappro ? ' checked="checked"' : '')).'">'; + print 'rappro ? ' checked="checked"' : '')).'">'; print ''.yn($objp->rappro).'
'; + print '
'; print '"; @@ -1262,7 +1272,7 @@ if ($action == 'create') // Payment term print ''; print ''; print ''; -print ''; +print ''; print ''; print ''; diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 1edd5492a81..7d7dcbe86c3 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -97,6 +97,16 @@ if (!empty($canvas)) // Security check $result = restrictedArea($user, 'societe', $socid, '&societe', '', 'fk_soc', 'rowid', 0); +/* +if ($object->id > 0) { + if ($object->client == 0 && $object->fournisseur > 0) { + if (!empty($user->rights->fournisseur->lire)) { + accessforbidden(); + } + } +} +*/ + $permissiontoread = $user->rights->societe->lire; $permissiontoadd = $user->rights->societe->creer; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php $permissiontodelete = $user->rights->societe->delete || ($permissiontoadd && isset($object->status) && $object->status == 0); diff --git a/htdocs/societe/checkvat/checkVatService.xml b/htdocs/societe/checkvat/checkVatService.xml index 373775c2487..b6d7661cdc6 100644 --- a/htdocs/societe/checkvat/checkVatService.xml +++ b/htdocs/societe/checkvat/checkVatService.xml @@ -167,7 +167,7 @@ - + diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index e67f28c4dab..73c41aeb782 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -2070,7 +2070,7 @@ class Societe extends CommonObject $discount->amount_tva = $discount->multicurrency_amount_tva = price2num($remise * $vatrate / 100, 'MT'); $discount->amount_ttc = $discount->multicurrency_amount_ttc = price2num($discount->amount_ht + $discount->amount_tva, 'MT'); - $discount->tva_tx = price2num($vatrate, 'MT'); + $discount->tva_tx = price2num($vatrate); $discount->vat_src_code = $vat_src_code; $discount->description = $desc; @@ -2533,7 +2533,7 @@ class Societe extends CommonObject $langs->load('companies'); $statusType = 'status4'; - if ($status == 0) $statusType = 'status5'; + if ($status == 0) $statusType = 'status6'; if (empty($this->labelStatus) || empty($this->labelStatusShort)) { @@ -3115,10 +3115,10 @@ class Societe extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Returns if a profid sould be verified + * Returns if a profid sould be verified to be unique * - * @param int $idprof 1,2,3,4,5,6 (Exemple: 1=siren,2=siret,3=naf,4=rcs/rm,5=idprof5,6=idprof6) - * @return boolean true , false + * @param int $idprof 1,2,3,4,5,6 (Example: 1=siren, 2=siret, 3=naf, 4=rcs/rm, 5=eori, 6=idprof6) + * @return boolean true if the ID must be unique */ public function id_prof_verifiable($idprof) { @@ -3128,22 +3128,22 @@ class Societe extends CommonObject switch ($idprof) { case 1: - $ret = (!$conf->global->SOCIETE_IDPROF1_UNIQUE ?false:true); + $ret = (empty($conf->global->SOCIETE_IDPROF1_UNIQUE) ? false : true); break; case 2: - $ret = (!$conf->global->SOCIETE_IDPROF2_UNIQUE ?false:true); + $ret = (empty($conf->global->SOCIETE_IDPROF2_UNIQUE) ? false : true); break; case 3: - $ret = (!$conf->global->SOCIETE_IDPROF3_UNIQUE ?false:true); + $ret = (empty($conf->global->SOCIETE_IDPROF3_UNIQUE) ? false : true); break; case 4: - $ret = (!$conf->global->SOCIETE_IDPROF4_UNIQUE ?false:true); + $ret = (empty($conf->global->SOCIETE_IDPROF4_UNIQUE) ? false : true); break; case 5: - $ret = (!$conf->global->SOCIETE_IDPROF5_UNIQUE ?false:true); + $ret = (empty($conf->global->SOCIETE_IDPROF5_UNIQUE) ? false : true); break; case 6: - $ret = (!$conf->global->SOCIETE_IDPROF6_UNIQUE ?false:true); + $ret = (empty($conf->global->SOCIETE_IDPROF6_UNIQUE) ? false : true); break; default: $ret = false; @@ -3241,7 +3241,7 @@ class Societe extends CommonObject // si son index (position dans la chaîne en commence à 0 au premier caractère) est impair // on double sa valeur et si cette dernière est supérieure à 9, on lui retranche 9 // on ajoute cette valeur à la somme totale - + $sum = 0; for ($index = 0; $index < 9; $index++) { $number = (int) $chaine[$index]; @@ -3266,7 +3266,7 @@ class Societe extends CommonObject // si son index (position dans la chaîne en commence à 0 au premier caractère) est pair // on double sa valeur et si cette dernière est supérieure à 9, on lui retranche 9 // on ajoute cette valeur à la somme totale - + $sum = 0; for ($index = 0; $index < 14; $index++) { $number = (int) $chaine[$index]; @@ -3343,10 +3343,6 @@ class Societe extends CommonObject $string = trim($this->idprof1); $string = preg_replace('/(\s)/', '', $string); - for ($i = 0; $i < 9; $i++) { - $num[$i] = substr($string, $i, 1); - } - //Check NIF if (preg_match('/(^[0-9]{9}$)/', $string)) { return 1; diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 56e774e7a9b..48a01a94390 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -72,6 +72,7 @@ $search_customer_code = trim(GETPOST('search_customer_code', 'alpha')); $search_supplier_code = trim(GETPOST('search_supplier_code', 'alpha')); $search_account_customer_code = trim(GETPOST('search_account_customer_code', 'alpha')); $search_account_supplier_code = trim(GETPOST('search_account_supplier_code', 'alpha')); +$search_address = trim(GETPOST('search_address', 'alpha')); $search_town = trim(GETPOST("search_town", 'alpha')); $search_zip = trim(GETPOST("search_zip", 'alpha')); $search_state = trim(GETPOST("search_state", 'alpha')); @@ -186,6 +187,7 @@ $arrayfields = array( 's.code_fournisseur'=>array('label'=>"SupplierCodeShort", 'position'=>11, 'checked'=>$checkedsuppliercode, 'enabled'=>(!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled))), 's.code_compta'=>array('label'=>"CustomerAccountancyCodeShort", 'position'=>13, 'checked'=>$checkedcustomeraccountcode), 's.code_compta_fournisseur'=>array('label'=>"SupplierAccountancyCodeShort", 'position'=>14, 'checked'=>$checkedsupplieraccountcode, 'enabled'=>(!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled))), + 's.address'=>array('label'=>"Address", 'position'=>19, 'checked'=>1), 's.town'=>array('label'=>"Town", 'position'=>20, 'checked'=>1), 's.zip'=>array('label'=>"Zip", 'position'=>21, 'checked'=>1), 'state.nom'=>array('label'=>"State", 'position'=>22, 'checked'=>0), @@ -214,7 +216,7 @@ $arrayfields = array( 's.import_key'=>array('label'=>"ImportId", 'checked'=>0, 'position'=>1100), ); // Extra fields -include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_array_fields.tpl.php'; +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); @@ -289,6 +291,7 @@ if (empty($reshook)) $search_supplier_code = ''; $search_account_customer_code = ''; $search_account_supplier_code = ''; + $search_address = ''; $search_town = ""; $search_zip = ""; $search_state = ""; @@ -386,7 +389,7 @@ if ($resql) } } else dol_print_error($db); -$sql = "SELECT s.rowid, s.nom as name, s.name_alias, s.barcode, s.town, s.zip, s.datec, s.code_client, s.code_fournisseur, s.logo,"; +$sql = "SELECT s.rowid, s.nom as name, s.name_alias, s.barcode, s.address, s.town, s.zip, s.datec, s.code_client, s.code_fournisseur, s.logo,"; $sql .= " s.entity,"; $sql .= " st.libelle as stcomm, st.picto as stcomm_picto, s.fk_stcomm as stcomm_id, s.fk_prospectlevel, s.prefix_comm, s.client, s.fournisseur, s.canvas, s.status as status,"; $sql .= " s.email, s.phone, s.fax, s.url, s.siren as idprof1, s.siret as idprof2, s.ape as idprof3, s.idprof4 as idprof4, s.idprof5 as idprof5, s.idprof6 as idprof6, s.tva_intra, s.fk_pays,"; @@ -448,6 +451,7 @@ if ($search_customer_code) $sql .= natural_search("s.code_client", $search_custo if ($search_supplier_code) $sql .= natural_search("s.code_fournisseur", $search_supplier_code); if ($search_account_customer_code) $sql .= natural_search("s.code_compta", $search_account_customer_code); if ($search_account_supplier_code) $sql .= natural_search("s.code_compta_fournisseur", $search_account_supplier_code); +if ($search_address) $sql.= natural_search('s.address', $search_address); if ($search_town) $sql .= natural_search("s.town", $search_town); if (strlen($search_zip)) $sql .= natural_search("s.zip", $search_zip); if ($search_state) $sql .= natural_search("state.nom", $search_state); @@ -545,6 +549,7 @@ if ($search_sale > 0) $param .= '&search_sale='.urlencode($search_sale); if ($search_id > 0) $param .= "&search_id=".urlencode($search_id); if ($search_nom != '') $param .= "&search_nom=".urlencode($search_nom); if ($search_alias != '') $param .= "&search_alias=".urlencode($search_alias); +if ($search_address != '') $param .= '&search_address=' . urlencode($search_address); if ($search_town != '') $param .= "&search_town=".urlencode($search_town); if ($search_zip != '') $param .= "&search_zip=".urlencode($search_zip); if ($search_phone != '') $param .= "&search_phone=".urlencode($search_phone); @@ -766,6 +771,13 @@ if (!empty($arrayfields['s.code_compta_fournisseur']['checked'])) print ''; print ''; } +// Address +if (!empty($arrayfields['s.address']['checked'])) +{ + print ''; +} // Town if (!empty($arrayfields['s.town']['checked'])) { @@ -975,6 +987,7 @@ if (!empty($arrayfields['s.code_client']['checked'])) print_liste_fi if (!empty($arrayfields['s.code_fournisseur']['checked'])) print_liste_field_titre($arrayfields['s.code_fournisseur']['label'], $_SERVER["PHP_SELF"], "s.code_fournisseur", "", $param, '', $sortfield, $sortorder); if (!empty($arrayfields['s.code_compta']['checked'])) print_liste_field_titre($arrayfields['s.code_compta']['label'], $_SERVER["PHP_SELF"], "s.code_compta", "", $param, '', $sortfield, $sortorder); if (!empty($arrayfields['s.code_compta_fournisseur']['checked'])) print_liste_field_titre($arrayfields['s.code_compta_fournisseur']['label'], $_SERVER["PHP_SELF"], "s.code_compta_fournisseur", "", $param, '', $sortfield, $sortorder); +if (!empty($arrayfields['s.address']['checked'])) print_liste_field_titre($arrayfields['s.address']['label'], $_SERVER['PHP_SELF'], 's.address', '', $param, '', $sortfield, $sortorder); if (!empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], "s.town", "", $param, '', $sortfield, $sortorder); if (!empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], "s.zip", "", $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); @@ -1103,6 +1116,12 @@ while ($i < min($num, $limit)) print ''; if (!$i) $totalarray['nbfield']++; } + // Address + if (!empty($arrayfields['s.address']['checked'])) + { + print ''; + if (!$i) $totalarray['nbfield']++; + } // Town if (!empty($arrayfields['s.town']['checked'])) { diff --git a/htdocs/societe/societecontact.php b/htdocs/societe/societecontact.php index c40de9060ef..0d1ae48e9e3 100644 --- a/htdocs/societe/societecontact.php +++ b/htdocs/societe/societecontact.php @@ -71,7 +71,8 @@ if ($action == 'addcontact' && $user->rights->societe->creer) if ($result > 0 && $id > 0) { $contactid = (GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int')); - $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); + $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type')); + $result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09')); } if ($result >= 0) diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index b891d042e5b..ae40784aa68 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -257,7 +257,7 @@ if (empty($reshook)) { if ($object->fetch(GETPOST('copie_supplier_proposal')) > 0) { $object->ref = GETPOST('ref'); - $object->date_livraison = $date_delivery; // deprecated + $object->date_livraison = $date_delivery; // deprecated $object->delivery_date = $date_delivery; $object->shipping_method_id = GETPOST('shipping_method_id', 'int'); $object->cond_reglement_id = GETPOST('cond_reglement_id'); @@ -272,8 +272,6 @@ if (empty($reshook)) $object->note = GETPOST('note', 'restricthtml'); $object->note_private = GETPOST('note', 'restricthtml'); $object->statut = SupplierProposal::STATUS_DRAFT; - - $id = $object->create_from($user); } else { setEventMessages($langs->trans("ErrorFailedToCopyProposal", GETPOST('copie_supplier_proposal')), null, 'errors'); } @@ -547,14 +545,13 @@ if (empty($reshook)) $date_end = dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end'.$predef.'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year')); $ref_supplier = GETPOST('fourn_ref', 'alpha'); $prod_entry_mode = GETPOST('prod_entry_mode'); - if ($prod_entry_mode == 'free') - { + if ($prod_entry_mode == 'free') { $idprod = 0; $price_ht = GETPOST('price_ht'); $tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); } else { $idprod = GETPOST('idprod', 'int'); - $price_ht = ''; + $price_ht = GETPOST('price_ht'); $tva_tx = ''; } @@ -588,8 +585,8 @@ if (empty($reshook)) $error++; } if (!$error && ($qty >= 0)) { - $pu_ht = 0; - $pu_ttc = 0; + $pu_ht = price2num($price_ht, 'MU'); + $pu_ttc = price2num(GETPOST('price_ttc'), 'MU'); $price_min = 0; $price_base_type = (GETPOST('price_base_type', 'alpha') ? GETPOST('price_base_type', 'alpha') : 'HT'); @@ -654,12 +651,12 @@ if (empty($reshook)) $localtax1_tx = get_localtax($tva_tx, 1, $mysoc, $object->thirdparty, $tva_npr); $localtax2_tx = get_localtax($tva_tx, 2, $mysoc, $object->thirdparty, $tva_npr); - $pu_ht = $productsupplier->fourn_pu; if (empty($pu_ht)) $pu_ht = 0; // If pu is '' or null, we force to have a numeric value // If GETPOST('idprodfournprice') is a numeric, we can use it. If it is empty or if it is 'idprod_123', we should use -1 (not used) $fournprice = (is_numeric(GETPOST('idprodfournprice', 'alpha')) ? GETPOST('idprodfournprice', 'alpha') : -1); $buyingprice = 0; + $pu_ht_devise = price2num($price_ht_devise, 'MU'); $result = $object->addline( $desc, @@ -685,7 +682,7 @@ if (empty($reshook)) $productsupplier->fk_unit, '', 0, - $productsupplier->fourn_multicurrency_unitprice, + $pu_ht_devise, $date_start, $date_end ); diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index 914e487b594..b46ed476629 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -171,9 +171,7 @@ class SupplierProposal extends CommonObject public $remise_percent = 0; public $remise_absolue = 0; - public $products = array(); public $extraparams = array(); - public $lines = array(); public $line; @@ -237,15 +235,12 @@ class SupplierProposal extends CommonObject $this->socid = $socid; $this->id = $supplier_proposalid; - - $this->products = array(); } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Add line into array products - * $this->client doit etre charge + * Add line into array ->lines * * @param int $idproduct Product Id to add * @param int $qty Quantity @@ -253,7 +248,6 @@ class SupplierProposal extends CommonObject * @return int <0 if KO, >0 if OK * * TODO Remplacer les appels a cette fonction par generation objet Ligne - * insere dans tableau $this->products */ public function add_product($idproduct, $qty, $remise_percent = 0) { @@ -1085,23 +1079,6 @@ class SupplierProposal extends CommonObject } } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Insert into DB a supplier_proposal object completely defined by its data members (ex, results from copy). - * - * @param User $user User that create - * @return int Id of the new object if ok, <0 if ko - * @see create() - */ - public function create_from($user) - { - // phpcs:enable - $this->products = $this->lines; - - return $this->create($user); - } - /** * Load an object from its id and create a new one in database * @@ -1263,7 +1240,7 @@ class SupplierProposal extends CommonObject $this->datev = $this->db->jdate($obj->datev); // TODO deprecated $this->date_creation = $this->db->jdate($obj->datec); //Creation date $this->date_validation = $this->db->jdate($obj->datev); //Validation date - $this->date_livraison = $this->db->jdate($obj->delivery_date); // deprecated + $this->date_livraison = $this->db->jdate($obj->delivery_date); // deprecated $this->delivery_date = $this->db->jdate($obj->delivery_date); $this->shipping_method_id = ($obj->fk_shipping_method > 0) ? $obj->fk_shipping_method : null; diff --git a/htdocs/takepos/admin/setup.php b/htdocs/takepos/admin/setup.php index fd5f5a1cbc2..84efe32839e 100644 --- a/htdocs/takepos/admin/setup.php +++ b/htdocs/takepos/admin/setup.php @@ -179,8 +179,10 @@ foreach ($dirmodels as $reldir) // Show example of numbering module print ''."\n"; @@ -230,6 +232,8 @@ foreach ($dirmodels as $reldir) } print "
'.$langs->trans("Author").''.$author->getFullName($langs)."
'; - print ''; + if (!$i) $totalarray['nbfield']++; - $db->free($result); -} else { - dol_print_error($db); + print ''."\n"; + + $i++; } +// Show total line +include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; + + +// If no record found +if ($num == 0) +{ + $colspan = 1; + foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } + print ''; +} + + +$db->free($resql); + +$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); +$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; + +print '
'; + print ''; if ($action != 'editconditions' && $user->rights->facture->creer) @@ -1452,7 +1462,7 @@ if ($action == 'create') $title = $langs->trans("Recurrence"); //print load_fiche_titre($title, '', 'calendar'); - print '
'; print $langs->trans('PaymentConditionsShort'); print '
'; + print '
'; print ''; @@ -1573,7 +1583,7 @@ if ($action == 'create') } print '
'; - print '
'.$title.'
'; + print '
'; // Nb of generation already done print ''; diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index a4def0c0b9b..110db6d8166 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -358,26 +358,23 @@ if (empty($reshook)) if ($object->retained_warranty_date_limit < $object->date) $object->retained_warranty_date_limit = $object->date; $result = $object->update($user); if ($result < 0) dol_print_error($db, $object->error); - } elseif ($action == 'setretainedwarranty' && $user->rights->facture->creer) - { + } elseif ($action == 'setretainedwarranty' && $user->rights->facture->creer) { $object->fetch($id); $result = $object->setRetainedWarranty(GETPOST('retained_warranty', 'float')); if ($result < 0) dol_print_error($db, $object->error); - } elseif ($action == 'setretainedwarrantydatelimit' && $user->rights->facture->creer) - { + } elseif ($action == 'setretainedwarrantydatelimit' && $user->rights->facture->creer) { $object->fetch($id); $result = $object->setRetainedWarrantyDateLimit(GETPOST('retained_warranty_date_limit', 'float')); if ($result < 0) dol_print_error($db, $object->error); - } // Multicurrency Code + } // Multicurrency Code elseif ($action == 'setmulticurrencycode' && $usercancreate) { $result = $object->setMulticurrencyCode(GETPOST('multicurrency_code', 'alpha')); } // Multicurrency rate elseif ($action == 'setmulticurrencyrate' && $usercancreate) { $result = $object->setMulticurrencyRate(price2num(GETPOST('multicurrency_tx')), GETPOST('calculation_mode', 'int')); - } elseif ($action == 'setinvoicedate' && $usercancreate) - { + } elseif ($action == 'setinvoicedate' && $usercancreate) { $object->fetch($id); $old_date_lim_reglement = $object->date_lim_reglement; $date = dol_mktime(12, 0, 0, $_POST['invoicedatemonth'], $_POST['invoicedateday'], $_POST['invoicedateyear']); @@ -395,8 +392,7 @@ if (empty($reshook)) if ($result < 0) { dol_print_error($db, $object->error); } - } elseif ($action == 'setdate_pointoftax' && $usercancreate) - { + } elseif ($action == 'setdate_pointoftax' && $usercancreate) { $object->fetch($id); $date_pointoftax = dol_mktime(12, 0, 0, $_POST['date_pointoftaxmonth'], $_POST['date_pointoftaxday'], $_POST['date_pointoftaxyear']); $object->date_pointoftax = $date_pointoftax; @@ -2668,7 +2664,8 @@ if (empty($reshook)) if ($result > 0 && $id > 0) { $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); - $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); + $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type')); + $result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09')); } if ($result >= 0) { @@ -3419,7 +3416,7 @@ if ($action == 'create') // Payment mode print ''; // Bank Account @@ -3649,8 +3646,7 @@ if ($action == 'create') } print ''; -} elseif ($id > 0 || !empty($ref)) -{ +} elseif ($id > 0 || !empty($ref)) { /* * Show object in view mode */ @@ -3896,6 +3892,7 @@ if ($action == 'create') $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?facid='.$object->id, $langs->trans('ClassifyPaid'), $langs->trans('ConfirmClassifyPaidBill', $object->ref), 'confirm_paid', '', "yes", 1); } if ($action == 'paid' && $resteapayer > 0) { + $close = array(); // Code $i = 0; $close[$i]['code'] = 'discount_vat'; // escompte @@ -3922,7 +3919,7 @@ if ($action == 'create') $i++; // arrayreasons[code]=reason foreach ($close as $key => $val) { - $arrayreasons[$close [$key]['code']] = $close[$key]['reason']; + $arrayreasons[$close[$key]['code']] = $close[$key]['reason']; } // Cree un tableau formulaire @@ -4073,24 +4070,26 @@ if ($action == 'create') // Type print ''; @@ -4132,13 +4132,11 @@ if ($action == 'create') // Relative and absolute discounts print ''."\n"; print ''; // Date invoice @@ -4154,7 +4152,7 @@ if ($action == 'create') if ($action == 'editinvoicedate') { $form->form_date($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->date, 'invoicedate'); } else { - print dol_print_date($object->date, 'day'); + print ''.dol_print_date($object->date, 'day').''; } print ''; @@ -4173,7 +4171,7 @@ if ($action == 'create') if ($action == 'editdate_pointoftax') { $form->form_date($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->date_pointoftax, 'date_pointoftax'); } else { - print dol_print_date($object->date_pointoftax, 'day'); + print ''.dol_print_date($object->date_pointoftax, 'day').''; } print ''; } @@ -4213,7 +4211,7 @@ if ($action == 'create') if ($action == 'editpaymentterm') { $form->form_date($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->date_lim_reglement, 'paymentterm'); } else { - print dol_print_date($object->date_lim_reglement, 'day'); + print ''.dol_print_date($object->date_lim_reglement, 'day').''; if ($object->hasDelay()) { print img_warning($langs->trans('Late')); } @@ -4788,10 +4786,13 @@ if ($action == 'create') if ($object->type != Facture::TYPE_CREDIT_NOTE) { // Total already paid print ''; + } else { + print $langs->trans('AlreadyPaid'); + } + print ''; $resteapayeraffiche = $resteapayer; $cssforamountpaymentcomplete = 'amountpaymentcomplete'; @@ -4812,12 +4813,14 @@ if ($action == 'create') $obj = $db->fetch_object($resql); $invoice->fetch($obj->fk_facture_source); print ''; + print ''; + print ''; print ''; print ''; $resteapayeraffiche = 0; $cssforamountpaymentcomplete = 'amountpaymentneutral'; @@ -4843,7 +4848,9 @@ if ($action == 'create') // Paye partiellement ou Abandon 'badcustomer' if (($object->statut == Facture::STATUS_CLOSED || $object->statut == Facture::STATUS_ABANDONED) && $object->close_code == 'badcustomer') { print ''; // $resteapayeraffiche=0; $cssforamountpaymentcomplete = 'amountpaymentneutral'; @@ -4851,7 +4858,9 @@ if ($action == 'create') // Paye partiellement ou Abandon 'product_returned' if (($object->statut == Facture::STATUS_CLOSED || $object->statut == Facture::STATUS_ABANDONED) && $object->close_code == 'product_returned') { print ''; $resteapayeraffiche = 0; $cssforamountpaymentcomplete = 'amountpaymentneutral'; @@ -4862,20 +4871,27 @@ if ($action == 'create') $text = $langs->trans("HelpAbandonOther"); if ($object->close_note) $text .= '

'.$langs->trans("Reason").':'.$object->close_note; - print $form->textwithpicto($langs->trans("Abandoned").':', $text, - 1); + print ''; + print $form->textwithpicto($langs->trans("Abandoned"), $text, - 1); + print ''; print ''; $resteapayeraffiche = 0; $cssforamountpaymentcomplete = 'amountpaymentneutral'; } // Billed - print ''; + print ''; // Remainder to pay print ''; + print ''; + print ''; print ''; print ''; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index a3d64bb0c2e..20be732da17 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -74,7 +74,7 @@ class Facture extends CommonInvoice public $fk_element = 'fk_facture'; /** - * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png + * @var string String with name of icon for myobject. */ public $picto = 'bill'; @@ -119,7 +119,7 @@ class Facture extends CommonInvoice * @var int Date expected for delivery * @deprecated */ - public $date_livraison; // deprecated; Use delivery_date instead. + public $date_livraison; // deprecated; Use delivery_date instead. public $delivery_date; // Date expected of shipment (date starting shipment, not the reception that occurs some days after) @@ -176,11 +176,6 @@ class Facture extends CommonInvoice */ public $fk_bank; - /** - * @deprecated - */ - public $products = array(); - /** * @var FactureLigne[] */ @@ -1077,7 +1072,6 @@ class Facture extends CommonInvoice $facture->origin_id = $this->origin_id; $facture->lines = $this->lines; // Array of lines of invoice - $facture->products = $this->lines; // Tant que products encore utilise $facture->situation_counter = $this->situation_counter; $facture->situation_cycle_ref = $this->situation_cycle_ref; $facture->situation_final = $this->situation_final; @@ -1179,7 +1173,6 @@ class Facture extends CommonInvoice $object->ref_client = ''; $object->close_code = ''; $object->close_note = ''; - $object->products = $object->lines; // For backward compatibility if ($conf->global->MAIN_DONT_KEEP_NOTE_ON_CLONING == 1) { $object->note_private = ''; $object->note_public = ''; @@ -1191,7 +1184,6 @@ class Facture extends CommonInvoice if (($object->lines[$i]->info_bits & 0x02) == 0x02) // We do not clone line of discounts { unset($object->lines[$i]); - unset($object->products[$i]); // Tant que products encore utilise } // Bloc to update dates of service (month by month only if previously filled at 1d near start or end of month) // If it's a service with start and end dates @@ -1339,7 +1331,7 @@ class Facture extends CommonInvoice $this->availability_id = $object->availability_id; $this->demand_reason_id = $object->demand_reason_id; $this->delivery_date = (empty($object->delivery_date) ? $object->date_livraison : $object->delivery_date); - $this->date_livraison = $object->delivery_date; // deprecated + $this->date_livraison = $object->delivery_date; // deprecated $this->fk_delivery_address = $object->fk_delivery_address; // deprecated $this->contact_id = $object->contact_id; $this->ref_client = $object->ref_client; @@ -1432,11 +1424,11 @@ class Facture extends CommonInvoice $label = ''; if ($user->rights->facture->lire) { - $label = img_picto('', $this->picto).' '.$langs->trans("Invoice").''; - if ($this->type == self::TYPE_REPLACEMENT) $label = ''.$langs->transnoentitiesnoconv("ReplacementInvoice").''; - if ($this->type == self::TYPE_CREDIT_NOTE) $label = ''.$langs->transnoentitiesnoconv("CreditNote").''; - if ($this->type == self::TYPE_DEPOSIT) $label = ''.$langs->transnoentitiesnoconv("Deposit").''; - if ($this->type == self::TYPE_SITUATION) $label = ''.$langs->transnoentitiesnoconv("InvoiceSituation").''; + $label = img_picto('', $picto).' '.$langs->trans("Invoice").''; + if ($this->type == self::TYPE_REPLACEMENT) $label = img_picto('', $picto).' '.$langs->transnoentitiesnoconv("ReplacementInvoice").''; + if ($this->type == self::TYPE_CREDIT_NOTE) $label = img_picto('', $picto).' '.$langs->transnoentitiesnoconv("CreditNote").''; + if ($this->type == self::TYPE_DEPOSIT) $label = img_picto('', $picto).' '.$langs->transnoentitiesnoconv("Deposit").''; + if ($this->type == self::TYPE_SITUATION) $label = img_picto('', $picto).' '.$langs->transnoentitiesnoconv("InvoiceSituation").''; if (isset($this->statut) && isset($this->alreadypaid)) { $label .= ' '.$this->getLibStatut(5, $this->alreadypaid); } @@ -3295,6 +3287,7 @@ class Facture extends CommonInvoice $localtaxes_type = getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc); // Clean vat code + $reg = array(); $vat_src_code = ''; if (preg_match('/\((.*)\)/', $txtva, $reg)) { diff --git a/htdocs/compta/facture/contact.php b/htdocs/compta/facture/contact.php index 57532174db7..6b8758bc472 100644 --- a/htdocs/compta/facture/contact.php +++ b/htdocs/compta/facture/contact.php @@ -62,7 +62,8 @@ if ($action == 'addcontact' && $user->rights->facture->creer) if ($result > 0 && $id > 0) { $contactid = (GETPOST('userid') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int')); - $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); + $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type')); + $result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09')); } if ($result >= 0) diff --git a/htdocs/compta/facture/index.php b/htdocs/compta/facture/index.php index eb73132c69f..e96371ad4f4 100644 --- a/htdocs/compta/facture/index.php +++ b/htdocs/compta/facture/index.php @@ -192,10 +192,10 @@ function getPieChart($socid = 0) { $dolgraph = new DolGraph(); $dolgraph->SetData($dataseries); - $dolgraph->setShowLegend(1); + $dolgraph->setShowLegend(2); $dolgraph->setShowPercent(1); $dolgraph->SetType(['pie']); - $dolgraph->setWidth('100%'); + $dolgraph->setHeight('200'); $dolgraph->draw('idgraphthirdparties'); $result .= ''; diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index b693238924f..c61bfdf6819 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -128,7 +128,7 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page == -1 || !empty($search_btn) || !empty($search_remove_btn) || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 +if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters $offset = $limit * $page; if (!$sortorder && !empty($conf->global->INVOICE_DEFAULT_UNPAYED_SORT_ORDER) && $search_status == '1') $sortorder = $conf->global->INVOICE_DEFAULT_UNPAYED_SORT_ORDER; if (!$sortorder) $sortorder = 'DESC'; @@ -223,7 +223,7 @@ if ($conf->global->INVOICE_USE_SITUATION && $conf->global->INVOICE_USE_RETAINED_ } // Extra fields -include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_array_fields.tpl.php'; +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); diff --git a/htdocs/compta/facture/prelevement.php b/htdocs/compta/facture/prelevement.php index 792ff73bcd3..7e852846d5c 100644 --- a/htdocs/compta/facture/prelevement.php +++ b/htdocs/compta/facture/prelevement.php @@ -632,10 +632,10 @@ if ($object->id > 0) print "\n
\n"; $buttonlabel = $langs->trans("MakeWithdrawRequest"); - $user_perms=$user->rights->prelevement->bons->creer; + $user_perms = $user->rights->prelevement->bons->creer; if ($type == 'bank-transfer') { $buttonlabel = $langs->trans("MakeBankTransferOrder"); - $user_perms=$user->rights->paymentbybanktransfer->create; + $user_perms = $user->rights->paymentbybanktransfer->create; } // Add a transfer request diff --git a/htdocs/compta/facture/stats/index.php b/htdocs/compta/facture/stats/index.php index 9cbd826b4a1..13378979932 100644 --- a/htdocs/compta/facture/stats/index.php +++ b/htdocs/compta/facture/stats/index.php @@ -44,7 +44,7 @@ $mode = GETPOST("mode") ?GETPOST("mode") : 'customer'; if ($mode == 'customer' && !$user->rights->facture->lire) accessforbidden(); if ($mode == 'supplier' && !$user->rights->fournisseur->facture->lire) accessforbidden(); -$object_status = GETPOST('object_status'); +$object_status = GETPOST('object_status', 'intcomma'); $typent_id = GETPOST('typent_id', 'int'); $categ_id = GETPOST('categ_id', 'categ_id'); @@ -59,7 +59,7 @@ if ($user->socid > 0) } $nowyear = strftime("%Y", dol_now()); -$year = GETPOST('year') > 0 ?GETPOST('year') : $nowyear; +$year = GETPOST('year') > 0 ? GETPOST('year', 'int') : $nowyear; if (!empty($conf->global->INVOICE_STATS_GRAPHS_SHOW_2_YEARS)) $startyear = $year - 2; else $startyear = $year - 1; $endyear = $year; diff --git a/htdocs/compta/paiement_charge.php b/htdocs/compta/paiement_charge.php index b9aa625c06d..299cdf9a6c3 100644 --- a/htdocs/compta/paiement_charge.php +++ b/htdocs/compta/paiement_charge.php @@ -222,21 +222,21 @@ if ($action == 'create') print '
';*/ print '"; print ''; print '\n"; print ''; print ''; print ''; print ''; // Number diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 21bf795079a..fb2f114b579 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -164,12 +164,12 @@ class BonPrelevement extends CommonObject $result = 0; } else { $result = -1; - $this->errors[] = get_class($this)."::AddFacture " . $this->db->lasterror; + $this->errors[] = get_class($this)."::AddFacture ".$this->db->lasterror; dol_syslog(get_class($this)."::AddFacture Error $result"); } } else { $result = -2; - $this->errors[]=get_class($this)."::AddFacture linedid Empty"; + $this->errors[] = get_class($this)."::AddFacture linedid Empty"; dol_syslog(get_class($this)."::AddFacture Error $result"); } } else { @@ -247,7 +247,7 @@ class BonPrelevement extends CommonObject $line_id = $this->db->last_insert_id(MAIN_DB_PREFIX."prelevement_lignes"); $result = 0; } else { - $this->errors[]=get_class($this)."::addline Error -2 " .$this->db->lasterror; + $this->errors[] = get_class($this)."::addline Error -2 ".$this->db->lasterror; dol_syslog(get_class($this)."::addline Error -2"); $result = -2; } @@ -1124,7 +1124,7 @@ class BonPrelevement extends CommonObject if (!$resql) { $error++; - $this->errors[]=$this->db->lasterror(); + $this->errors[] = $this->db->lasterror(); dol_syslog(__METHOD__."::Update Error=".$this->db->lasterror(), LOG_ERR); } } diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index bd97f88ff65..752bdc4d642 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -893,7 +893,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) */ // We set country_id, and country_code label of the chosen country - if (isset($_POST["country_id"]) || $object->country_id) + if (GETPOSTISSET("country_id") || $object->country_id) { $tmparray = getCountry($object->country_id, 'all'); $object->country_code = $tmparray['code']; diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 59423ec2b42..6c6133e906a 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -805,19 +805,16 @@ class Contact extends CommonObject } // Mis a jour alerte birthday - if ($this->birthday_alert) - { + if (!empty($this->birthday_alert)) { //check existing $sql_check = "SELECT rowid FROM ".MAIN_DB_PREFIX."user_alert WHERE type=1 AND fk_contact=".$this->db->escape($id)." AND fk_user=".$user->id; $result_check = $this->db->query($sql_check); - if (!$result_check || ($this->db->num_rows($result_check) < 1)) - { + if (!$result_check || ($this->db->num_rows($result_check) < 1)) { //insert $sql = "INSERT INTO ".MAIN_DB_PREFIX."user_alert(type,fk_contact,fk_user) "; $sql .= "VALUES (1,".$this->db->escape($id).",".$user->id.")"; $result = $this->db->query($sql); - if (!$result) - { + if (!$result) { $error++; $this->error = $this->db->lasterror(); } @@ -828,23 +825,20 @@ class Contact extends CommonObject $sql = "DELETE FROM ".MAIN_DB_PREFIX."user_alert "; $sql .= "WHERE type=1 AND fk_contact=".$this->db->escape($id)." AND fk_user=".$user->id; $result = $this->db->query($sql); - if (!$result) - { + if (!$result) { $error++; $this->error = $this->db->lasterror(); } } - if (!$error && !$notrigger) - { + if (!$error && !$notrigger) { // Call trigger $result = $this->call_trigger('CONTACT_MODIFY', $user); if ($result < 0) { $error++; } // End call triggers } - if (!$error) - { + if (!$error) { $this->db->commit(); return 1; } else { diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index 16f7ea82f36..5b8c708b1b2 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -203,7 +203,7 @@ if (!empty($conf->socialnetworks->enabled)) { } // Extra fields -include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_array_fields.tpl.php'; +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 68582d2fb33..a92ac8a1e73 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -946,7 +946,8 @@ if (empty($reshook)) if ($action == 'addcontact') { $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); - $result = $object->add_contact($contactid, GETPOST('type'), GETPOST('source')); + $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type')); + $result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09')); if ($result >= 0) { diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 99544b1037d..9e277fd706b 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -1469,9 +1469,9 @@ class Contrat extends CommonObject } $txtva = price2num($txtva); - $txlocaltax1 = price2num($txlocaltax1); $txlocaltax2 = price2num($txlocaltax2); + $remise_percent = price2num($remise_percent); $qty = price2num($qty); if (empty($qty)) $qty = 1; diff --git a/htdocs/contrat/contact.php b/htdocs/contrat/contact.php index 24b0ff54bf6..c837769819a 100644 --- a/htdocs/contrat/contact.php +++ b/htdocs/contrat/contact.php @@ -63,7 +63,8 @@ if ($action == 'addcontact' && $user->rights->contrat->creer) if ($result > 0 && $id > 0) { $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); - $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); + $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type')); + $result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09')); } if ($result >= 0) diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index ad36a6e5ee7..80f16cb037d 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -62,7 +62,7 @@ if ($action == 'add' && !empty($permissiontoadd)) // Ignore special fields if (in_array($key, array('rowid', 'entity', 'import_key'))) continue; if (in_array($key, array('date_creation', 'tms', 'fk_user_creat', 'fk_user_modif'))) { - if (!in_array(abs($val['visible']), array(1, 3))) continue; // Only 1 and 3 that are case to create + if (!in_array(abs($val['visible']), array(1, 3))) continue; // Only 1 and 3 that are case to create } // Set value to insert @@ -146,7 +146,7 @@ if ($action == 'update' && !empty($permissiontoadd)) // Ignore special fields if (in_array($key, array('rowid', 'entity', 'import_key'))) continue; if (in_array($key, array('date_creation', 'tms', 'fk_user_creat', 'fk_user_modif'))) { - if (!in_array(abs($val['visible']), array(1, 3, 4))) continue; // Only 1 and 3 and 4 that are case to update + if (!in_array(abs($val['visible']), array(1, 3, 4))) continue; // Only 1 and 3 and 4 that are case to update } // Set value to update diff --git a/htdocs/core/actions_extrafields.inc.php b/htdocs/core/actions_extrafields.inc.php index 9ad3ce1e92e..d5936a6dadb 100644 --- a/htdocs/core/actions_extrafields.inc.php +++ b/htdocs/core/actions_extrafields.inc.php @@ -40,7 +40,7 @@ if ($type == 'select') $extrasize = ''; // Add attribute if ($action == 'add') { - if ($_POST["button"] != $langs->trans("Cancel")) + if (GETPOST("button") != $langs->trans("Cancel")) { // Check values if (!$type) @@ -132,11 +132,28 @@ if ($action == 'add') } } - if (!$error) - { + if (!$error) { + if (strlen(GETPOST('attrname', 'aZ09')) < 3) { + $error++; + $langs->load("errors"); + $mesg[] = $langs->trans("ErrorValueLength", $langs->transnoentitiesnoconv("AttributeCode"), 3); + $action = 'create'; + } + } + + // Check reserved keyword with more than 3 characters + if (!$error) { + if (in_array(GETPOST('attrname', 'aZ09'), array('and', 'keyword', 'table', 'index', 'integer', 'float', 'double', 'position'))) { + $error++; + $langs->load("errors"); + $mesg[] = $langs->trans("ErrorReservedKeyword", GETPOST('attrname', 'aZ09')); + $action = 'create'; + } + } + + if (!$error) { // attrname must be alphabetical and lower case only - if (isset($_POST["attrname"]) && preg_match("/^[a-z0-9-_]+$/", $_POST['attrname']) && !is_numeric($_POST["attrname"])) - { + if (GETPOSTISSET("attrname") && preg_match("/^[a-z0-9-_]+$/", GETPOST('attrname', 'aZ09')) && !is_numeric(GETPOST('attrname', 'aZ09'))) { // Construct array for parameter (value of select list) $default_value = GETPOST('default_value', 'alpha'); $parameters = $param; @@ -148,7 +165,7 @@ if ($action == 'add') $params['options'] = array($parameters=>null); } } else { - //Esle it's separated key/value and coma list + // Else it's separated key/value and coma list foreach ($parameters_array as $param_ligne) { list($key, $value) = explode(',', $param_ligne); @@ -161,7 +178,7 @@ if ($action == 'add') if ($type == 'separate') $visibility = 3; $result = $extrafields->addExtraField( - GETPOST('attrname', 'alpha'), + GETPOST('attrname', 'aZ09'), GETPOST('label', 'alpha'), $type, GETPOST('pos', 'int'), @@ -208,7 +225,7 @@ if ($action == 'add') // Rename field if ($action == 'update') { - if ($_POST["button"] != $langs->trans("Cancel")) + if (GETPOST("button") != $langs->trans("Cancel")) { // Check values if (!$type) @@ -293,9 +310,28 @@ if ($action == 'update') } } + if (!$error) { + if (strlen(GETPOST('attrname', 'aZ09')) < 3 && empty($conf->global->MAIN_DISABLE_EXTRAFIELDS_CHECK_FOR_UPDATE)) { + $error++; + $langs->load("errors"); + $mesg[] = $langs->trans("ErrorValueLength", $langs->transnoentitiesnoconv("AttributeCode"), 3); + $action = 'edit'; + } + } + + // Check reserved keyword with more than 3 characters + if (!$error) { + if (in_array(GETPOST('attrname', 'aZ09'), array('and', 'keyword', 'table', 'index', 'integer', 'float', 'double', 'position')) && empty($conf->global->MAIN_DISABLE_EXTRAFIELDS_CHECK_FOR_UPDATE)) { + $error++; + $langs->load("errors"); + $mesg[] = $langs->trans("ErrorReservedKeyword", GETPOST('attrname', 'aZ09')); + $action = 'edit'; + } + } + if (!$error) { - if (isset($_POST["attrname"]) && preg_match("/^\w[a-zA-Z0-9-_]*$/", $_POST['attrname'])) + if (GETPOSTISSET("attrname") && preg_match("/^\w[a-zA-Z0-9-_]*$/", GETPOST('attrname', 'aZ09')) && !is_numeric(GETPOST('attrname', 'aZ09'))) { $pos = GETPOST('pos', 'int'); // Construct array for parameter (value of select list) @@ -321,7 +357,7 @@ if ($action == 'update') if ($type == 'separate') $visibility = 3; $result = $extrafields->update( - GETPOST('attrname', 'alpha'), + GETPOST('attrname', 'aZ09'), GETPOST('label', 'alpha'), $type, $extrasize, @@ -338,12 +374,11 @@ if ($action == 'update') GETPOST('computed_value', 'alpha'), (GETPOST('entitycurrentorall', 'alpha') ? 0 : ''), GETPOST('langfile'), - GETPOST('enabled', 'alpha'), + GETPOST('enabled', 'alpha'), (GETPOST('totalizable', 'alpha') ? 1 : 0), GETPOST('printable', 'alpha') ); - if ($result > 0) - { + if ($result > 0) { setEventMessages($langs->trans('SetupSaved'), null, 'mesgs'); header("Location: ".$_SERVER["PHP_SELF"]); exit; @@ -365,13 +400,10 @@ if ($action == 'update') } // Delete attribute -if ($action == 'delete') -{ - if (isset($_GET["attrname"]) && preg_match("/^\w[a-zA-Z0-9-_]*$/", $_GET["attrname"])) - { - $result = $extrafields->delete($_GET["attrname"], $elementtype); - if ($result >= 0) - { +if ($action == 'delete') { + if (GETPOSTISSET("attrname") && preg_match("/^\w[a-zA-Z0-9-_]*$/", GETPOST("attrname", 'aZ09'))) { + $result = $extrafields->delete(GETPOST("attrname", 'aZ09'), $elementtype); + if ($result >= 0) { header("Location: ".$_SERVER["PHP_SELF"]); exit; } else $mesg = $extrafields->error; diff --git a/htdocs/core/boxes/box_birthdays.php b/htdocs/core/boxes/box_birthdays.php index 7c33ace20ab..dcb3fefe13a 100644 --- a/htdocs/core/boxes/box_birthdays.php +++ b/htdocs/core/boxes/box_birthdays.php @@ -89,7 +89,7 @@ class box_birthdays extends ModeleBoxes $sql = "SELECT u.rowid, u.firstname, u.lastname, u.birth"; $sql .= " FROM ".MAIN_DB_PREFIX."user as u"; $sql .= " WHERE u.entity IN (".getEntity('user').")"; - $sql.= " AND u.statut = 1"; + $sql .= " AND u.statut = 1"; $sql .= dolSqlDateFilter('u.birth', 0, $tmparray['mon'], 0); $sql .= " ORDER BY u.birth ASC"; $sql .= $this->db->plimit($max, 0); diff --git a/htdocs/core/boxes/box_customers_outstanding_bill_reached.php b/htdocs/core/boxes/box_customers_outstanding_bill_reached.php new file mode 100644 index 00000000000..f4f4d5015cc --- /dev/null +++ b/htdocs/core/boxes/box_customers_outstanding_bill_reached.php @@ -0,0 +1,193 @@ + + * Copyright (C) 2004-2010 Laurent Destailleur + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2015 Frederic France + * + * 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/core/boxes/box_clients.php + * \ingroup Facture + * \brief Module d'affichage pour les encours dépassés + */ + +include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; + + +/** + * Class to manage the box to show last thirdparties + */ +class box_customers_outstanding_bill_reached extends ModeleBoxes +{ + public $boxcode = "customersoutstandingbillreached"; + public $boximg = "object_company"; + public $boxlabel = "BoxCustomersOutstandingBillReached"; + public $depends = array("facture","societe"); + + /** + * @var DoliDB Database handler. + */ + public $db; + + public $enabled = 1; + + public $info_box_head = array(); + public $info_box_contents = array(); + + + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param = '') + { + global $conf, $user; + + $this->db = $db; + + // disable box for such cases + if (!empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) $this->enabled = 0; // disabled by this option + + $this->hidden = !($user->rights->societe->lire && empty($user->socid)); + } + + /** + * Load data for box to show them later + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $user, $langs, $conf; + $langs->load("boxes"); + + $this->max = $max; + + include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; + $thirdpartystatic = new Societe($this->db); + + $this->info_box_head = array('text' => $langs->trans("BoxTitleLastOutstandingBillReached", $max)); + + if ($user->rights->societe->lire) + { + $sql = "SELECT s.nom as name, s.rowid as socid"; + $sql .= ", s.code_client"; + $sql .= ", s.client"; + $sql .= ", s.code_fournisseur"; + $sql .= ", s.fournisseur"; + $sql .= ", s.code_compta"; + $sql .= ", s.code_compta_fournisseur"; + $sql .= ", s.logo"; + $sql .= ", s.email"; + $sql .= ", s.outstanding_limit"; + $sql .= ", s.datec, s.tms, s.status, s.entity"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE s.client IN (1, 3)"; + $sql .= " AND s.entity IN (".getEntity('societe').")"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($user->socid) $sql .= " AND s.rowid = $user->socid"; + $sql .= " AND s.outstanding_limit > 0"; + $sql .= " AND s.rowid IN (SELECT fk_soc from ".MAIN_DB_PREFIX."facture as f WHERE f.fk_statut = 1 and f.fk_soc = s.rowid)"; + $sql .= " ORDER BY s.tms DESC"; + //$sql .= $this->db->plimit($max, 0); + + dol_syslog(get_class($this)."::loadBox", LOG_DEBUG); + $result = $this->db->query($sql); + if ($result) + { + $num = $this->db->num_rows($result); + + $nboutstandingbillreachedcustomers = 0; + + $line = 0; + while ($line < $num) + { + $objp = $this->db->fetch_object($result); + + $datec = $this->db->jdate($objp->datec); + $datem = $this->db->jdate($objp->tms); + $thirdpartystatic->id = $objp->socid; + $thirdpartystatic->name = $objp->name; + $thirdpartystatic->code_client = $objp->code_client; + $thirdpartystatic->code_fournisseur = $objp->code_fournisseur; + $thirdpartystatic->code_compta = $objp->code_compta; + $thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur; + $thirdpartystatic->client = $objp->client; + $thirdpartystatic->fournisseur = $objp->fournisseur; + $thirdpartystatic->logo = $objp->logo; + $thirdpartystatic->email = $objp->email; + $thirdpartystatic->entity = $objp->entity; + $thirdpartystatic->outstanding_limit = $objp->outstanding_limit; + + $outstandingtotal = $thirdpartystatic->getOutstandingBills()['opened']; + $outstandinglimit = $thirdpartystatic->outstanding_limit; + + if ($outstandingtotal >= $outstandinglimit) + { + $this->info_box_contents[$nboutstandingbillreachedcustomers][] = array( + 'td' => '', + 'text' => $thirdpartystatic->getNomUrl(1, 'customer'), + 'asis' => 1, + ); + + $this->info_box_contents[$nboutstandingbillreachedcustomers][] = array( + 'td' => 'class="right" width="18"', + 'text' => $thirdpartystatic->LibStatut($objp->status, 3) + ); + $nboutstandingbillreachedcustomers++; + } + + $line++; + } + + if ($num == 0 || $nboutstandingbillreachedcustomers == 0) $this->info_box_contents[$line][0] = array( + 'td' => 'class="center opacitymedium"', + 'text'=>$langs->trans("NoRecordedCustomers") + ); + + $this->db->free($result); + } else { + $this->info_box_contents[0][0] = array( + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql) + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); + } + } + + /** + * Method to show box + * + * @param array $head Array with properties of box title + * @param array $contents Array with properties of box lines + * @param int $nooutput No print, only return string + * @return string + */ + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } +} diff --git a/htdocs/core/boxes/box_last_modified_ticket.php b/htdocs/core/boxes/box_last_modified_ticket.php index 2950eb9cfd8..94734894ad7 100644 --- a/htdocs/core/boxes/box_last_modified_ticket.php +++ b/htdocs/core/boxes/box_last_modified_ticket.php @@ -204,6 +204,6 @@ class box_last_modified_ticket extends ModeleBoxes */ public function showBox($head = null, $contents = null, $nooutput = 0) { - parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_last_ticket.php b/htdocs/core/boxes/box_last_ticket.php index 9ada300901c..268a6861524 100644 --- a/htdocs/core/boxes/box_last_ticket.php +++ b/htdocs/core/boxes/box_last_ticket.php @@ -202,6 +202,6 @@ class box_last_ticket extends ModeleBoxes */ public function showBox($head = null, $contents = null, $nooutput = 0) { - parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_lastlogin.php b/htdocs/core/boxes/box_lastlogin.php index b45986387a8..aa7b5ca2ea5 100644 --- a/htdocs/core/boxes/box_lastlogin.php +++ b/htdocs/core/boxes/box_lastlogin.php @@ -1,7 +1,7 @@ * Copyright (C) 2005-2017 Laurent Destailleur - * Copyright (C) 2014-2015 Frederic France + * Copyright (C) 2014-2020 Frederic France * * 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 @@ -107,10 +107,10 @@ class box_lastlogin extends ModeleBoxes * @param array $head Array with properties of box title * @param array $contents Array with properties of box lines * @param int $nooutput No print, only return string - * @return void + * @return string */ public function showBox($head = null, $contents = null, $nooutput = 0) { - parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } } diff --git a/htdocs/core/boxes/box_produits.php b/htdocs/core/boxes/box_produits.php index 06808ab2518..dc7f79721d1 100644 --- a/htdocs/core/boxes/box_produits.php +++ b/htdocs/core/boxes/box_produits.php @@ -87,6 +87,11 @@ class box_produits extends ModeleBoxes if ($user->rights->produit->lire || $user->rights->service->lire) { $sql = "SELECT p.rowid, p.label, p.ref, p.price, p.price_base_type, p.price_ttc, p.fk_product_type, p.tms, p.tosell, p.tobuy, p.fk_price_expression, p.entity"; + $sql .= ", p.accountancy_code_sell"; + $sql .= ", p.accountancy_code_sell_intra"; + $sql .= ", p.accountancy_code_sell_export"; + $sql .= ", p.accountancy_code_buy"; + $sql .= ', p.barcode'; $sql .= " FROM ".MAIN_DB_PREFIX."product as p"; $sql .= ' WHERE p.entity IN ('.getEntity($productstatic->element).')'; if (empty($user->rights->produit->lire)) $sql .= ' AND p.fk_product_type != 0'; @@ -133,6 +138,13 @@ class box_produits extends ModeleBoxes $productstatic->type = $objp->fk_product_type; $productstatic->label = $objp->label; $productstatic->entity = $objp->entity; + $productstatic->status = $objp->tosell; + $productstatic->status_buy = $objp->tobuy; + $productstatic->barcode = $objp->barcode; + $productstatic->accountancy_code_sell = $objp->accountancy_code_sell; + $productstatic->accountancy_code_sell_intra = $objp->accountancy_code_sell_intra; + $productstatic->accountancy_code_sell_export = $objp->accountancy_code_sell_export; + $productstatic->accountancy_code_buy = $objp->accountancy_code_buy; $this->info_box_contents[$line][] = array( 'td' => 'class="tdoverflowmax100 maxwidth100onsmartphone"', diff --git a/htdocs/core/boxes/box_task.php b/htdocs/core/boxes/box_task.php index f2bfd523d75..16b96e23466 100644 --- a/htdocs/core/boxes/box_task.php +++ b/htdocs/core/boxes/box_task.php @@ -137,7 +137,7 @@ class box_task extends ModeleBoxes $boxcontent .= ''; } $this->info_box_contents[0][] = array( - 'tr'=>'class="nohover showiffilter'.$this->boxcode.' hideobject"', + 'tr' => 'class="nohover showiffilter'.$this->boxcode.' hideobject"', 'td' => 'class="nohover"', 'textnoformat' => $boxcontent, ); diff --git a/htdocs/core/boxes/intracommreport_box.php b/htdocs/core/boxes/intracommreport_box.php deleted file mode 100644 index d7c383138b6..00000000000 --- a/htdocs/core/boxes/intracommreport_box.php +++ /dev/null @@ -1,88 +0,0 @@ - - * Copyright (C) - * - * 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 core/boxes/mybox.php - * \ingroup intracommreport - * \brief This file is a sample box definition file - * Put some comments here - */ -include_once DOL_DOCUMENT_ROOT."/core/boxes/modules_boxes.php"; - -/** - * Class to manage the box - */ -class intracommreportbox extends ModeleBoxes -{ - - public $boxcode = "mybox"; - public $boximg = "intracommreport"; - public $boxlabel; - public $depends = array("intracommreport"); - public $db; - public $param; - public $info_box_head = array(); - public $info_box_contents = array(); - - /** - * Constructor - */ - public function __construct() - { - global $langs; - $langs->load("boxes"); - - $this->boxlabel = $langs->transnoentitiesnoconv("MyBox"); - } - - /** - * Load data into info_box_contents array to show array later. - * - * @param int $max Maximum number of records to load - * @return void - */ - public function loadBox($max = 5) - { - global $conf, $user, $langs, $db; - - $this->max = $max; - - //include_once DOL_DOCUMENT_ROOT . "/intracommreport/class/intracommreport.class.php"; - - $text = $langs->trans("MyBoxDescription", $max); - $this->info_box_head = array( - 'text' => $text, - 'limit' => dol_strlen($text) - ); - - $this->info_box_contents[0][0] = array('td' => 'align="left"', - 'text' => $langs->trans("MyBoxContent")); - } - - /** - * Method to show box - * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @return void - */ - public function showBox($head = null, $contents = null) - { - parent::showBox($this->info_box_head, $this->info_box_contents); - } -} diff --git a/htdocs/core/boxes/modules_boxes.php b/htdocs/core/boxes/modules_boxes.php index 2ac7ee05c6b..1e32a28f25c 100644 --- a/htdocs/core/boxes/modules_boxes.php +++ b/htdocs/core/boxes/modules_boxes.php @@ -277,7 +277,7 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" box for ($j = 0; $j < $nbcolthisline; $j++) { // Define tdparam $tdparam = ''; - if (isset($contents[$i][$j]['td'])) $tdparam .= ' '.$contents[$i][$j]['td']; + if (!empty($contents[$i][$j]['td'])) $tdparam .= ' '.$contents[$i][$j]['td']; $text = isset($contents[$i][$j]['text']) ? $contents[$i][$j]['text'] : ''; $textwithnotags = preg_replace('/<([^>]+)>/i', '', $text); diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index 65c017e3dad..b2149cd187f 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -58,6 +58,8 @@ class CMailFile public $alternative_boundary; public $deliveryreceipt; + public $atleastonefile; + public $eol; public $eol2; @@ -171,7 +173,7 @@ class CMailFile if (!empty($this->sendcontext)) { $smtpContextKey = strtoupper($this->sendcontext); $keyForSMTPSendMode = 'MAIN_MAIL_SENDMODE_'.$smtpContextKey; - $smtpContextSendMode = $conf->global->{$keyForSMTPSendMode}; + $smtpContextSendMode = empty($conf->global->{$keyForSMTPSendMode}) ? '' : $conf->global->{$keyForSMTPSendMode}; if (!empty($smtpContextSendMode) && $smtpContextSendMode != 'default') { $this->sendmode = $smtpContextSendMode; } @@ -298,7 +300,7 @@ class CMailFile if (!empty($this->sendcontext)) { $smtpContextKey = strtoupper($this->sendcontext); $keyForSMTPSendMode = 'MAIN_MAIL_SENDMODE_'.$smtpContextKey; - $smtpContextSendMode = $conf->global->{$keyForSMTPSendMode}; + $smtpContextSendMode = empty($conf->global->{$keyForSMTPSendMode}) ? '' : $conf->global->{$keyForSMTPSendMode}; if (!empty($smtpContextSendMode) && $smtpContextSendMode != 'default') { $keyforsslseflsigned = 'MAIN_MAIL_EMAIL_SMTP_ALLOW_SELF_SIGNED_'.$smtpContextKey; } @@ -338,8 +340,7 @@ class CMailFile $text_body = $this->write_body($msg); // Add attachments to text_encoded - if ($this->atleastonefile) - { + if (!empty($this->atleastonefile)) { $files_encoded = $this->write_files($filename_list, $mimetype_list, $mimefilename_list); } @@ -401,7 +402,7 @@ class CMailFile } } - if ($this->atleastonefile) + if (!empty($this->atleastonefile)) { foreach ($filename_list as $i => $val) { @@ -530,7 +531,7 @@ class CMailFile $this->message->addPart(dol_nl2br($msg), 'text/html'); } - if ($this->atleastonefile) + if (!empty($this->atleastonefile)) { foreach ($filename_list as $i => $val) { @@ -657,7 +658,7 @@ class CMailFile if (!empty($this->sendcontext)) { $smtpContextKey = strtoupper($this->sendcontext); $keyForSMTPSendMode = 'MAIN_MAIL_SENDMODE_'.$smtpContextKey; - $smtpContextSendMode = $conf->global->{$keyForSMTPSendMode}; + $smtpContextSendMode = empty($conf->global->{$keyForSMTPSendMode}) ? '' : $conf->global->{$keyForSMTPSendMode}; if (!empty($smtpContextSendMode) && $smtpContextSendMode != 'default') { $keyforsmtpserver = 'MAIN_MAIL_SMTP_SERVER_'.$smtpContextKey; $keyforsmtpport = 'MAIN_MAIL_SMTP_PORT_'.$smtpContextKey; diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index c25519e151f..49a303208a8 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -123,7 +123,7 @@ abstract class CommonDocGenerator if ($member->photo) { $logotouse = $conf->adherent->dir_output.'/'.get_exdir(0, 0, 0, 1, $member, 'user').'/photos/'.$member->photo; } else { - $logotouse = DOL_DOCUMENT_ROOT . '/public/theme/common/nophoto.png'; + $logotouse = DOL_DOCUMENT_ROOT.'/public/theme/common/nophoto.png'; } $array_member = array( @@ -585,7 +585,7 @@ abstract class CommonDocGenerator 'line_product_ref'=>(empty($line->product_ref) ? '' : $line->product_ref), 'line_product_ref_fourn'=>(empty($line->ref_fourn) ? '' : $line->ref_fourn), // for supplier doc lines - 'line_product_label'=>(empty($line->product_label) ? '' :$line->product_label), + 'line_product_label'=>(empty($line->product_label) ? '' : $line->product_label), 'line_product_type'=>(empty($line->product_type) ? '' : $line->product_type), 'line_product_barcode'=>(empty($line->product_barcode) ? '' : $line->product_barcode), @@ -652,7 +652,7 @@ abstract class CommonDocGenerator { $columns = ""; - foreach ($extralabels as $key) + foreach ($extralabels as $key => $label) { $columns .= "$key, "; } @@ -666,7 +666,7 @@ abstract class CommonDocGenerator { $resql = $this->db->fetch_object($resql); - foreach ($extralabels as $key) + foreach ($extralabels as $key => $label) { $resarray['line_product_supplier_'.$key] = $resql->{$key}; } @@ -1389,7 +1389,7 @@ abstract class CommonDocGenerator if ($itemsInRow > 0) { // close table row and empty cols for ($i = $itemsInRow; $i <= $maxItemsInRow; $i++) { - $html .= ""; + $html .= ""; } $html .= ""; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index bc1c17d417f..33ac1aba696 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -936,11 +936,11 @@ abstract class CommonObject /** * Add a link between element $this->element and a contact * - * @param int $fk_socpeople Id of thirdparty contact (if source = 'external') or id of user (if souce = 'internal') to link - * @param int $type_contact Type of contact (code or id). Must be id or code found into table llx_c_type_contact. For example: SALESREPFOLL - * @param string $source external=Contact extern (llx_socpeople), internal=Contact intern (llx_user) - * @param int $notrigger Disable all triggers - * @return int <0 if KO, >0 if OK + * @param int $fk_socpeople Id of thirdparty contact (if source = 'external') or id of user (if souce = 'internal') to link + * @param int|string $type_contact Type of contact (code or id). Must be id or code found into table llx_c_type_contact. For example: SALESREPFOLL + * @param string $source external=Contact extern (llx_socpeople), internal=Contact intern (llx_user) + * @param int $notrigger Disable all triggers + * @return int <0 if KO, >0 if OK */ public function add_contact($fk_socpeople, $type_contact, $source = 'external', $notrigger = 0) { @@ -1817,7 +1817,11 @@ abstract class CommonObject return -2; } } else { - $this->error = $this->db->lasterror(); + if ($this->db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { + $this->error = 'DB_ERROR_RECORD_ALREADY_EXISTS'; + } else { + $this->error = $this->db->lasterror(); + } $this->db->rollback(); return -1; } @@ -5092,7 +5096,7 @@ abstract class CommonObject global $conf, $extrafields; if (empty($rowid)) $rowid = $this->id; - if (empty($rowid) && isset($this->rowid)) $rowid = $this->rowid; // deprecated + if (empty($rowid) && isset($this->rowid)) $rowid = $this->rowid; // deprecated // To avoid SQL errors. Probably not the better solution though if (!$this->table_element) { @@ -5417,26 +5421,20 @@ abstract class CommonObject $sql .= ",".$attributeKey; } // We must insert a default value for fields for other entities that are mandatory to avoid not null error - if (is_array($extrafields->attributes[$this->table_element]['mandatoryfieldsofotherentities'])) - { - foreach ($extrafields->attributes[$this->table_element]['mandatoryfieldsofotherentities'] as $tmpkey => $tmpval) - { - if (!isset($extrafields->attributes[$this->table_element]['type'][$tmpkey])) // If field not already added previously - { + if (!empty($extrafields->attributes[$this->table_element]['mandatoryfieldsofotherentities']) && is_array($extrafields->attributes[$this->table_element]['mandatoryfieldsofotherentities'])) { + foreach ($extrafields->attributes[$this->table_element]['mandatoryfieldsofotherentities'] as $tmpkey => $tmpval) { + if (!isset($extrafields->attributes[$this->table_element]['type'][$tmpkey])) { // If field not already added previously $sql .= ",".$tmpkey; } } } $sql .= ") VALUES (".$this->id; - foreach ($new_array_options as $key => $value) - { + foreach ($new_array_options as $key => $value) { $attributeKey = substr($key, 8); // Remove 'options_' prefix // Add field of attribute - if ($extrafields->attributes[$this->table_element]['type'][$attributeKey] != 'separate') // Only for other type than separator) - { - if ($new_array_options[$key] != '' || $new_array_options[$key] == '0') - { + if ($extrafields->attributes[$this->table_element]['type'][$attributeKey] != 'separate') { // Only for other type than separator) + if ($new_array_options[$key] != '' || $new_array_options[$key] == '0') { $sql .= ",'".$this->db->escape($new_array_options[$key])."'"; } else { $sql .= ",null"; @@ -5444,12 +5442,9 @@ abstract class CommonObject } } // We must insert a default value for fields for other entities that are mandatory to avoid not null error - if (is_array($extrafields->attributes[$this->table_element]['mandatoryfieldsofotherentities'])) - { - foreach ($extrafields->attributes[$this->table_element]['mandatoryfieldsofotherentities'] as $tmpkey => $tmpval) - { - if (!isset($extrafields->attributes[$this->table_element]['type'][$tmpkey])) // If field not already added previously - { + if (!empty($extrafields->attributes[$this->table_element]['mandatoryfieldsofotherentities']) && is_array($extrafields->attributes[$this->table_element]['mandatoryfieldsofotherentities'])) { + foreach ($extrafields->attributes[$this->table_element]['mandatoryfieldsofotherentities'] as $tmpkey => $tmpval) { + if (!isset($extrafields->attributes[$this->table_element]['type'][$tmpkey])) { // If field not already added previously if (in_array($tmpval, array('int', 'double', 'price'))) $sql .= ", 0"; else $sql .= ", ''"; } @@ -5939,7 +5934,7 @@ abstract class CommonObject $out = $form->selectDate($value, $keyprefix.$key.$keysuffix, $showtime, $showtime, $required, '', 1, (($keyprefix != 'search_' && $keyprefix != 'search_options_') ? 1 : 0), 0, 1); } elseif (in_array($type, array('duration'))) { $out = $form->select_duration($keyprefix.$key.$keysuffix, $value, 0, 'text', 0, 1); - } elseif (in_array($type, array('int', 'integer'))) { + } elseif (in_array($type, array('int', 'integer'))) { $tmp = explode(',', $size); $newsize = $tmp[0]; $out = ''; @@ -5949,7 +5944,7 @@ abstract class CommonObject $out = ''; } elseif (in_array($type, array('mail', 'phone', 'url'))) { $out = ''; - } elseif (preg_match('/^text/', $type)) { + } elseif (preg_match('/^text/', $type)) { 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'; @@ -6728,7 +6723,7 @@ abstract class CommonObject * @param array $params Optional parameters. Example: array('style'=>'class="oddeven"', 'colspan'=>$colspan) * @param string $keysuffix Suffix string to add after name and id of field (can be used to avoid duplicate names) * @param string $keyprefix Prefix string to add before name and id of field (can be used to avoid duplicate names) - * @param string $onetrtd All fields in same tr td (TODO field not used ?) + * @param string $onetrtd All fields in same tr td. Used by objectline_create.tpl.php for example. * @return string */ public function showOptionals($extrafields, $mode = 'view', $params = null, $keysuffix = '', $keyprefix = '', $onetrtd = 0) @@ -6894,6 +6889,9 @@ abstract class CommonObject $helptoshow = $langs->trans($extrafields->attributes[$this->table_element]['help'][$key]); $out .= ''; + if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER) && $action == 'view') { + $out .= ''; + } $out .= ''; diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index c6ffe090c52..cba0b0b3e53 100644 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -73,7 +73,7 @@ $coldisplay = 0; > global->MAIN_VIEW_LINE_NUMBER)) { ?> - + '; // Country @@ -560,9 +560,9 @@ if (!empty($id) && $action == 'edit') // Zip / Town print ''; // Country diff --git a/htdocs/ecm/class/ecmdirectory.class.php b/htdocs/ecm/class/ecmdirectory.class.php index f2b87382c76..ca2b9fec473 100644 --- a/htdocs/ecm/class/ecmdirectory.class.php +++ b/htdocs/ecm/class/ecmdirectory.class.php @@ -62,8 +62,19 @@ class EcmDirectory extends CommonObject */ public $description; + /** + * @var int cache nb of doc + */ public $cachenbofdoc = -1; // By default cache initialized with value 'not calculated' + + /** + * @var int date_c + */ public $date_c; + + /** + * @var int date_m + */ public $date_m; /** @@ -81,25 +92,31 @@ class EcmDirectory extends CommonObject */ public $ref; + /** + * @var array array of categories + */ public $cats = array(); + + /** + * @var array array of children categories + */ public $motherof = array(); + /** + * @var array array of forbidden chars + */ public $forbiddenchars = array('<', '>', ':', '/', '\\', '?', '*', '|', '"'); + + /** + * @var array array of forbidden chars for dir + */ public $forbiddencharsdir = array('<', '>', ':', '?', '*', '|', '"'); + /** + * @var int 1 if full arbo loaded + */ public $full_arbo_loaded; - /** - * @var string Error code (or message) - */ - public $error; - - /** - * @var string[] Error codes (or messages) - */ - public $errors = array(); - - /** * Constructor * @@ -131,13 +148,14 @@ class EcmDirectory extends CommonObject $this->description = trim($this->description); $this->date_c = $now; $this->fk_user_c = $user->id; - if ($this->fk_parent <= 0) $this->fk_parent = 0; + if ($this->fk_parent <= 0) { + $this->fk_parent = 0; + } // Check if same directory does not exists with this name $relativepath = $this->label; - if ($this->fk_parent) - { + if ($this->fk_parent) { $parent = new EcmDirectory($this->db); $parent->fetch($this->fk_parent); $relativepath = $parent->getRelativePath().$relativepath; @@ -148,19 +166,16 @@ class EcmDirectory extends CommonObject $cat = new EcmDirectory($this->db); $cate_arbo = $cat->get_full_arbo(1); $pathfound = 0; - foreach ($cate_arbo as $key => $categ) - { + foreach ($cate_arbo as $key => $categ) { $path = str_replace($this->forbiddencharsdir, '_', $categ['fullrelativename']); //print $relativepath.' - '.$path.'
'; - if ($path == $relativepath) - { + if ($path == $relativepath) { $pathfound = 1; break; } } - if ($pathfound) - { + if ($pathfound) { $this->error = "ErrorDirAlreadyExists"; dol_syslog(get_class($this)."::create ".$this->error, LOG_WARNING); return -1; @@ -188,21 +203,23 @@ class EcmDirectory extends CommonObject dol_syslog(get_class($this)."::create", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."ecm_directories"); $dir = $conf->ecm->dir_output.'/'.$this->getRelativePath(); $result = dol_mkdir($dir); - if ($result < 0) { $error++; $this->error = "ErrorFailedToCreateDir"; } + if ($result < 0) { + $error++; $this->error = "ErrorFailedToCreateDir"; + } // Call trigger $result = $this->call_trigger('MYECMDIR_CREATE', $user); - if ($result < 0) { $error++; } + if ($result < 0) { + $error++; + } // End call triggers - if (!$error) - { + if (!$error) { $this->db->commit(); return $this->id; } else { @@ -249,22 +266,21 @@ class EcmDirectory extends CommonObject dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); - if (!$resql) - { + if (!$resql) { $error++; $this->error = "Error ".$this->db->lasterror(); } - if (!$error && !$notrigger) - { + if (!$error && !$notrigger) { // Call trigger $result = $this->call_trigger('MYECMDIR_MODIFY', $user); - if ($result < 0) { $error++; } + if ($result < 0) { + $error++; + } // End call triggers } - if (!$error) - { + if (!$error) { $this->db->commit(); return 1; } else { @@ -284,20 +300,26 @@ class EcmDirectory extends CommonObject { // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."ecm_directories SET"; - if (preg_match('/[0-9]+/', $value)) $sql .= " cachenbofdoc = ".(int) $value; - else $sql .= " cachenbofdoc = cachenbofdoc ".$value." 1"; + if (preg_match('/[0-9]+/', $value)) { + $sql .= " cachenbofdoc = ".(int) $value; + } else { + $sql .= " cachenbofdoc = cachenbofdoc ".$value." 1"; + } $sql .= " WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::changeNbOfFiles", LOG_DEBUG); $resql = $this->db->query($sql); - if (!$resql) - { + if (!$resql) { $this->error = "Error ".$this->db->lasterror(); return -1; } else { - if (preg_match('/[0-9]+/', $value)) $this->cachenbofdoc = (int) $value; - elseif ($value == '+') $this->cachenbofdoc++; - elseif ($value == '-') $this->cachenbofdoc--; + if (preg_match('/[0-9]+/', $value)) { + $this->cachenbofdoc = (int) $value; + } elseif ($value == '+') { + $this->cachenbofdoc++; + } elseif ($value == '-') { + $this->cachenbofdoc--; + } } return 1; @@ -327,11 +349,9 @@ class EcmDirectory extends CommonObject dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $obj = $this->db->fetch_object($resql); - if ($obj) - { + if ($obj) { $this->id = $obj->rowid; $this->ref = $obj->rowid; @@ -374,7 +394,9 @@ class EcmDirectory extends CommonObject $error = 0; - if ($mode != 'databaseonly') $relativepath = $this->getRelativePath(1); // Ex: dir1/dir2/dir3 + if ($mode != 'databaseonly') { + $relativepath = $this->getRelativePath(1); // Ex: dir1/dir2/dir3 + } dol_syslog(get_class($this)."::delete remove directory id=".$this->id." mode=".$mode.(($mode == 'databaseonly') ? '' : ' relativepath='.$relativepath)); @@ -385,35 +407,30 @@ class EcmDirectory extends CommonObject dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); - if (!$resql) - { + if (!$resql) { $this->db->rollback(); $this->error = "Error ".$this->db->lasterror(); return -2; } else { // Call trigger $result = $this->call_trigger('MYECMDIR_DELETE', $user); - if ($result < 0) - { + if ($result < 0) { $this->db->rollback(); return -2; } // End call triggers } - if ($mode != 'databaseonly') - { + if ($mode != 'databaseonly') { $file = $conf->ecm->dir_output."/".$relativepath; - if ($deletedirrecursive) - { + if ($deletedirrecursive) { $result = @dol_delete_dir_recursive($file, 0, 0); } else { $result = @dol_delete_dir($file, 0); } } - if ($result || !@is_dir(dol_osencode($file))) - { + if ($result || !@is_dir(dol_osencode($file))) { $this->db->commit(); } else { $this->error = 'ErrorFailToDeleteDir'; @@ -422,8 +439,11 @@ class EcmDirectory extends CommonObject $error++; } - if (!$error) return 1; - else return -1; + if (!$error) { + return 1; + } else { + return -1; + } } @@ -465,17 +485,27 @@ class EcmDirectory extends CommonObject $linkclose = '"'.($more ? ' '.$more : '').' title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">'; $linkstart = 'picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); - if ($withpicto != 2) $result .= ($max ?dol_trunc($newref, $max, 'middle') : $newref); + if ($withpicto) { + $result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + } + if ($withpicto != 2) { + $result .= ($max ?dol_trunc($newref, $max, 'middle') : $newref); + } $result .= $linkend; return $result; @@ -497,18 +527,15 @@ class EcmDirectory extends CommonObject do { // Get index cursor in this->cats for id_mere $cursorindex = -1; - foreach ($this->cats as $key => $val) - { - if ($this->cats[$key]['id'] == $idtosearch) - { + foreach ($this->cats as $key => $val) { + if ($this->cats[$key]['id'] == $idtosearch) { $cursorindex = $key; break; } } //print "c=".$idtosearch."-".$cursorindex; - if ($cursorindex >= 0) - { + if ($cursorindex >= 0) { // Path is label sanitized (no space and no special char) and concatenated $ret = dol_sanitizeFileName($this->cats[$cursorindex]['label']).'/'.$ret; @@ -541,11 +568,9 @@ class EcmDirectory extends CommonObject dol_syslog(get_class($this)."::load_motherof", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { // This assignment in condition is not a bug. It allows walking the results. - while ($obj = $this->db->fetch_object($resql)) - { + while ($obj = $this->db->fetch_object($resql)) { $this->motherof[$obj->id_son] = $obj->id_parent; } return 1; @@ -608,8 +633,7 @@ class EcmDirectory extends CommonObject // phpcs:enable global $conf; - if (empty($force) && !empty($this->full_arbo_loaded)) - { + if (empty($force) && !empty($this->full_arbo_loaded)) { return $this->cats; } @@ -632,13 +656,11 @@ class EcmDirectory extends CommonObject dol_syslog(get_class($this)."::get_full_arbo", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $this->cats = array(); $i = 0; // This assignment in condition is not a bug. It allows walking the results. - while ($obj = $this->db->fetch_object($resql)) - { + while ($obj = $this->db->fetch_object($resql)) { $this->cats[$obj->rowid]['id'] = $obj->rowid; $this->cats[$obj->rowid]['id_mere'] = (isset($this->motherof[$obj->rowid]) ? $this->motherof[$obj->rowid] : ''); $this->cats[$obj->rowid]['label'] = $obj->label; @@ -648,10 +670,8 @@ class EcmDirectory extends CommonObject $this->cats[$obj->rowid]['fk_user_c'] = $obj->fk_user_c; $this->cats[$obj->rowid]['login_c'] = $obj->login_c; - if (!empty($obj->rowid_fille)) - { - if (isset($this->cats[$obj->rowid]['id_children']) && is_array($this->cats[$obj->rowid]['id_children'])) - { + if (!empty($obj->rowid_fille)) { + if (isset($this->cats[$obj->rowid]['id_children']) && is_array($this->cats[$obj->rowid]['id_children'])) { $newelempos = count($this->cats[$obj->rowid]['id_children']); //print "this->cats[$i]['id_children'] est deja un tableau de $newelem elements
"; $this->cats[$obj->rowid]['id_children'][$newelempos] = $obj->rowid_fille; @@ -668,9 +688,10 @@ class EcmDirectory extends CommonObject } // We add properties fullxxx to all elements - foreach ($this->cats as $key => $val) - { - if (isset($motherof[$key])) continue; + foreach ($this->cats as $key => $val) { + if (isset($motherof[$key])) { + continue; + } $this->build_path_from_id_categ($key, 0); } @@ -693,8 +714,7 @@ class EcmDirectory extends CommonObject { // phpcs:enable // Define fullpath - if (!empty($this->cats[$id_categ]['id_mere'])) - { + if (!empty($this->cats[$id_categ]['id_mere'])) { $this->cats[$id_categ]['fullpath'] = $this->cats[$this->cats[$id_categ]['id_mere']]['fullpath']; $this->cats[$id_categ]['fullpath'] .= '_'.$id_categ; $this->cats[$id_categ]['fullrelativename'] = $this->cats[$this->cats[$id_categ]['id_mere']]['fullrelativename']; @@ -711,11 +731,11 @@ class EcmDirectory extends CommonObject // Traite ces enfants $protection++; - if ($protection > 20) return; // On ne traite pas plus de 20 niveaux - if (isset($this->cats[$id_categ]['id_children']) && is_array($this->cats[$id_categ]['id_children'])) - { - foreach ($this->cats[$id_categ]['id_children'] as $key => $val) - { + if ($protection > 20) { + return; // On ne traite pas plus de 20 niveaux + } + if (isset($this->cats[$id_categ]['id_children']) && is_array($this->cats[$id_categ]['id_children'])) { + foreach ($this->cats[$id_categ]['id_children'] as $key => $val) { $this->build_path_from_id_categ($val, $protection); } } @@ -741,8 +761,7 @@ class EcmDirectory extends CommonObject // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."ecm_directories SET"; $sql .= " cachenbofdoc = '".count($filelist)."'"; - if (empty($all)) // By default - { + if (empty($all)) { // By default $sql .= " WHERE rowid = ".$this->id; } else { $sql .= " WHERE entity = ".$conf->entity; @@ -750,8 +769,7 @@ class EcmDirectory extends CommonObject dol_syslog(get_class($this)."::refreshcachenboffile", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $this->cachenbofdoc = count($filelist); return $this->cachenbofdoc; } else { @@ -782,8 +800,7 @@ class EcmDirectory extends CommonObject $interface = new Interfaces($this->db); $result = $interface->run_triggers($triggerName, $this, $user, $langs, $conf); if ($result < 0) { - if (!empty($this->errors)) - { + if (!empty($this->errors)) { $this->errors = array_merge($this->errors, $interface->errors); } else { $this->errors = $interface->errors; diff --git a/htdocs/ecm/class/ecmfiles.class.php b/htdocs/ecm/class/ecmfiles.class.php index 978b6e46d9e..c096bc27869 100644 --- a/htdocs/ecm/class/ecmfiles.class.php +++ b/htdocs/ecm/class/ecmfiles.class.php @@ -94,7 +94,15 @@ class EcmFiles extends CommonObject * @var string keywords */ public $keywords; + + /** + * @var string cover + */ public $cover; + + /** + * @var int position + */ public $position; /** @@ -131,7 +139,15 @@ class EcmFiles extends CommonObject * @var string acl */ public $acl; + + /** + * @var string src object type + */ public $src_object_type; + + /** + * @var int src object id + */ public $src_object_id; @@ -233,8 +249,7 @@ class EcmFiles extends CommonObject $sql .= " WHERE filepath ='".$this->db->escape($this->filepath)."'"; $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $obj = $this->db->fetch_object($resql); $maxposition = (int) $obj->maxposition; } else { @@ -247,13 +262,11 @@ class EcmFiles extends CommonObject } // Check parameters - if (empty($this->filename) || empty($this->filepath)) - { + if (empty($this->filename) || empty($this->filepath)) { $this->errors[] = 'Bad property filename or filepath'; return --$error; } - if (!isset($this->entity)) - { + if (!isset($this->entity)) { $this->entity = $conf->entity; } // Put here code to add control on parameters values @@ -317,11 +330,12 @@ class EcmFiles extends CommonObject $this->position = $maxposition; // Triggers - if (!$notrigger) - { + if (!$notrigger) { // Call triggers $result = $this->call_trigger(strtoupper(get_class($this)).'_CREATE', $user); - if ($result < 0) { $error++; } + if ($result < 0) { + $error++; + } // End call triggers } } @@ -401,8 +415,7 @@ class EcmFiles extends CommonObject } elseif (!empty($hashforshare)) { $sql .= " AND t.share = '".$this->db->escape($hashforshare)."'"; //$sql .= " AND t.entity = ".$conf->entity; // hashforshare already unique - } elseif ($src_object_type && $src_object_id) - { + } elseif ($src_object_type && $src_object_id) { // Warning: May return several record, and only first one is returned ! $sql .= " AND t.src_object_type ='".$this->db->escape($src_object_type)."' AND t.src_object_id = ".$this->db->escape($src_object_id); $sql .= " AND t.entity = ".$conf->entity; @@ -668,11 +681,12 @@ class EcmFiles extends CommonObject } // Triggers - if (!$error && !$notrigger) - { + if (!$error && !$notrigger) { // Call triggers $result = $this->call_trigger(strtoupper(get_class($this)).'_MODIFY', $user); - if ($result < 0) { $error++; } //Do also here what you must do to rollback action if trigger fail + if ($result < 0) { + $error++; + } //Do also here what you must do to rollback action if trigger fail // End call triggers } @@ -705,11 +719,12 @@ class EcmFiles extends CommonObject $this->db->begin(); // Triggers - if (!$notrigger) - { + if (!$notrigger) { // Call triggers $result = $this->call_trigger(strtoupper(get_class($this)).'_DELETE', $user); - if ($result < 0) { $error++; } //Do also here what you must do to rollback action if trigger fail + if ($result < 0) { + $error++; + } //Do also here what you must do to rollback action if trigger fail // End call triggers } @@ -804,7 +819,9 @@ class EcmFiles extends CommonObject global $dolibarr_main_authentication, $dolibarr_main_demo; global $menumanager; - if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips + if (!empty($conf->dol_no_mouse_hover)) { + $notooltip = 1; // Force disable tooltips + } $result = ''; @@ -815,25 +832,26 @@ class EcmFiles extends CommonObject $url = DOL_URL_ROOT.'/ecm/'.$this->table_name.'_card.php?id='.$this->id; $linkclose = ''; - if (empty($notooltip)) - { - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { + if (empty($notooltip)) { + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $label = $langs->trans("ShowProject"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; - } else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); + } else { + $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); + } $linkstart = '
'; $linkend = ''; - if ($withpicto) - { + if ($withpicto) { $result .= ($linkstart.img_object(($notooltip ? '' : $label), 'label', ($notooltip ? '' : 'class="classfortooltip"')).$linkend); - if ($withpicto != 2) $result .= ' '; + if ($withpicto != 2) { + $result .= ' '; + } } $result .= $linkstart.$this->ref.$linkend; return $result; @@ -877,16 +895,16 @@ class EcmFiles extends CommonObject global $conf, $user; $this->id = 0; - + $this->specimen = 1; $this->label = '0a1b2c3e4f59999999'; - $this->entity = '1'; + $this->entity = 1; $this->filename = 'myspecimenfilefile.pdf'; $this->filepath = '/aaa/bbb'; $this->fullpath_orig = 'c:/file on my disk.pdf'; $this->description = 'This is a long description of file'; $this->keywords = 'key1,key2'; $this->cover = '1'; - $this->position = '5'; + $this->position = 5; $this->gen_or_uploaded = 'uploaded'; $this->extraparams = ''; $this->date_c = (dol_now() - 3600 * 24 * 10); diff --git a/htdocs/ecm/dir_add_card.php b/htdocs/ecm/dir_add_card.php index a2726a1ba75..8c13c377bd6 100644 --- a/htdocs/ecm/dir_add_card.php +++ b/htdocs/ecm/dir_add_card.php @@ -41,20 +41,22 @@ $confirm = GETPOST('confirm', 'alpha'); $module = GETPOST('module', 'alpha'); $website = GETPOST('website', 'alpha'); $pageid = GETPOST('pageid', 'int'); -if (empty($module)) $module = 'ecm'; +if (empty($module)) { + $module = 'ecm'; +} // Security check -if ($user->socid > 0) -{ +if ($user->socid > 0) { $action = ''; $socid = $user->socid; } $section = $urlsection = GETPOST('section', 'alpha'); -if (empty($urlsection)) $urlsection = 'misc'; +if (empty($urlsection)) { + $urlsection = 'misc'; +} -if ($module == 'ecm') -{ +if ($module == 'ecm') { $upload_dir = $conf->ecm->dir_output.'/'.$urlsection; } else // For example $module == 'medias' { @@ -65,19 +67,23 @@ $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +if (empty($page) || $page == -1) { + $page = 0; +} // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (!$sortorder) $sortorder = "ASC"; -if (!$sortfield) $sortfield = "label"; +if (!$sortorder) { + $sortorder = "ASC"; +} +if (!$sortfield) { + $sortfield = "label"; +} $ecmdir = new EcmDirectory($db); -if (!empty($section)) -{ +if (!empty($section)) { $result = $ecmdir->fetch($section); - if (!$result > 0) - { + if (!$result > 0) { dol_print_error($db, $ecmdir->error); exit; } @@ -86,18 +92,18 @@ if (!empty($section)) // Permissions $permtoadd = 0; $permtoupload = 0; -if ($module == 'ecm') -{ +if ($module == 'ecm') { $permtoadd = $user->rights->ecm->setup; $permtoupload = $user->rights->ecm->upload; } -if ($module == 'medias') -{ +if ($module == 'medias') { $permtoadd = ($user->rights->mailing->creer || $user->rights->website->write); $permtoupload = ($user->rights->mailing->creer || $user->rights->website->write); } -if (!$permtoadd) accessforbidden(); +if (!$permtoadd) { + accessforbidden(); +} @@ -106,12 +112,9 @@ if (!$permtoadd) accessforbidden(); */ // Action ajout d'un produit ou service -if ($action == 'add' && $permtoadd) -{ - if ($cancel) - { - if (!empty($backtopage)) - { +if ($action == 'add' && $permtoadd) { + if ($cancel) { + if (!empty($backtopage)) { header("Location: ".$backtopage); exit; } else { @@ -120,33 +123,31 @@ if ($action == 'add' && $permtoadd) } } - $ref = GETPOST("ref", 'alpha'); - $label = GETPOST("label", 'alpha'); - $desc = GETPOST("desc", 'alpha'); + $ref = (string) GETPOST("ref", 'alpha'); + $label = (string) GETPOST("label", 'alpha'); + $desc = (string) GETPOST("desc", 'alpha'); $catParent = GETPOST("catParent", 'alpha'); // Can be an int (with ECM) or a string (with generic filemanager) - if ($catParent == '-1') $catParent = 0; + if ($catParent == '-1') { + $catParent = 0; + } $error = 0; - if (empty($label)) - { + if (empty($label)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), null, 'errors'); $action = 'create'; $error++; } - if (!$error) - { - if ($module == 'ecm') - { + if (!$error) { + if ($module == 'ecm') { $ecmdir->ref = $ref; $ecmdir->label = $label; $ecmdir->description = $desc; $ecmdir->fk_parent = (int) $catParent; $id = $ecmdir->create($user); - if ($id <= 0) - { + if ($id <= 0) { $error++; $langs->load("errors"); setEventMessages($ecmdir->error, $ecmdir->errors, 'errors'); @@ -155,22 +156,18 @@ if ($action == 'add' && $permtoadd) } else // For example $module == 'medias' { $dirfornewdir = ''; - if ($module == 'medias') - { + if ($module == 'medias') { $dirfornewdir = $conf->medias->multidir_output[$conf->entity]; } - if (empty($dirfornewdir)) - { + if (empty($dirfornewdir)) { $error++; dol_print_error('', 'Bad value for module. Not supported.'); } - if (!$error) - { + if (!$error) { $fullpathofdir = $dirfornewdir.'/'.($catParent ? $catParent.'/' : '').$label; $result = dol_mkdir($fullpathofdir, DOL_DATA_ROOT); - if ($result < 0) - { + if ($result < 0) { setEventMessages($langs->trans('ErrorFailToCreateDir', $label), null, 'errors'); $error++; } else { @@ -180,10 +177,8 @@ if ($action == 'add' && $permtoadd) } } - if (!$error) - { - if (!empty($backtopage)) - { + if (!$error) { + if (!empty($backtopage)) { header("Location: ".$backtopage); exit; } else { @@ -194,8 +189,7 @@ if ($action == 'add' && $permtoadd) } // Deleting file -elseif ($action == 'confirm_deletesection' && $confirm == 'yes') -{ +elseif ($action == 'confirm_deletesection' && $confirm == 'yes') { $result = $ecmdir->delete($user); setEventMessages($langs->trans("ECMSectionWasRemoved", $ecmdir->label), null, 'mesgs'); } @@ -212,8 +206,7 @@ llxHeader('', $langs->trans("ECMNewSection")); $form = new Form($db); $formecm = new FormEcm($db); -if ($action == 'create') -{ +if ($action == 'create') { //*********************** // Create //*********************** @@ -222,8 +215,12 @@ if ($action == 'create') print ''; print ''; print ''; - if ($website) print ''; - if ($pageid) print ''; + if ($website) { + print ''; + } + if ($pageid) { + print ''; + } $title = $langs->trans("ECMNewSection"); print load_fiche_titre($title); @@ -240,8 +237,7 @@ if ($action == 'create') print ''."\n"; // Description - if ($module == 'ecm') - { + if ($module == 'ecm') { print ''; + print ''; } else { print ''; } diff --git a/htdocs/reception/class/reception.class.php b/htdocs/reception/class/reception.class.php index d64c3c999a7..07e32b64432 100644 --- a/htdocs/reception/class/reception.class.php +++ b/htdocs/reception/class/reception.class.php @@ -68,7 +68,6 @@ class Reception extends CommonObject public $brouillon; public $entrepot_id; - public $lines = array(); public $tracking_number; public $tracking_url; public $billed; @@ -106,6 +105,8 @@ class Reception extends CommonObject public $meths; public $listmeths; // List of carriers + public $lines = array(); + const STATUS_DRAFT = 0; const STATUS_VALIDATED = 1; @@ -121,8 +122,6 @@ class Reception extends CommonObject public function __construct($db) { $this->db = $db; - $this->lines = array(); - $this->products = array(); // List of long language codes for status $this->statuts = array(); @@ -391,7 +390,7 @@ class Reception extends CommonObject $this->ref = $obj->ref; $this->socid = $obj->socid; $this->ref_supplier = $obj->ref_supplier; - $this->ref_ext = $obj->ref_ext; + $this->ref_ext = $obj->ref_ext; $this->statut = $obj->fk_statut; $this->user_author_id = $obj->fk_user_author; $this->date_creation = $this->db->jdate($obj->date_creation); diff --git a/htdocs/recruitment/admin/setup.php b/htdocs/recruitment/admin/setup.php index 702fa4852f5..fdd4d83e223 100644 --- a/htdocs/recruitment/admin/setup.php +++ b/htdocs/recruitment/admin/setup.php @@ -308,8 +308,10 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) { // Show example of numbering model print ''."\n"; diff --git a/htdocs/recruitment/admin/setup_candidatures.php b/htdocs/recruitment/admin/setup_candidatures.php index b829f27eb82..ef4454974e7 100644 --- a/htdocs/recruitment/admin/setup_candidatures.php +++ b/htdocs/recruitment/admin/setup_candidatures.php @@ -308,8 +308,10 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) { // Show example of numbering model print ''."\n"; diff --git a/htdocs/recruitment/core/modules/recruitment/doc/doc_generic_recruitmentjobposition_odt.modules.php b/htdocs/recruitment/core/modules/recruitment/doc/doc_generic_recruitmentjobposition_odt.modules.php index 6e9788c2e9f..be36b96682c 100644 --- a/htdocs/recruitment/core/modules/recruitment/doc/doc_generic_recruitmentjobposition_odt.modules.php +++ b/htdocs/recruitment/core/modules/recruitment/doc/doc_generic_recruitmentjobposition_odt.modules.php @@ -299,9 +299,9 @@ class doc_generic_recruitmentjobposition_odt extends ModelePDFRecruitmentJobPosi $contactobject = null; if (!empty($usecontact)) { - // On peut utiliser le nom de la societe du contact - if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; - else { + if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { + $socobject = $object->contact; + } else { $socobject = $object->thirdparty; // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use $contactobject = $object->contact; diff --git a/htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php b/htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php index af62344296b..cad6888f7c5 100644 --- a/htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php +++ b/htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php @@ -1002,7 +1002,7 @@ class pdf_standard_recruitmentjobposition extends ModelePDFRecruitmentJobPositio } // Recipient name - /*if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { + /*if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) { $thirdparty = $object->contact; } else { $thirdparty = $object->thirdparty; diff --git a/htdocs/recruitment/recruitmentcandidature_card.php b/htdocs/recruitment/recruitmentcandidature_card.php index 8c76fdbb28e..9d05674d656 100644 --- a/htdocs/recruitment/recruitmentcandidature_card.php +++ b/htdocs/recruitment/recruitmentcandidature_card.php @@ -247,7 +247,7 @@ if (empty($reshook)) $nuser->personal_mobile = $object->phone; $nuser->birth = $object->date_birth; $nuser->salary = $object->remuneration_proposed; - $nuser->fk_user = $jobposition->fk_user_supervisor; // Supervisor + $nuser->fk_user = $jobposition->fk_user_supervisor; // Supervisor $result = $nuser->create($user); diff --git a/htdocs/recruitment/recruitmentjobposition_list.php b/htdocs/recruitment/recruitmentjobposition_list.php index c942975a91d..1891d9ce822 100644 --- a/htdocs/recruitment/recruitmentjobposition_list.php +++ b/htdocs/recruitment/recruitmentjobposition_list.php @@ -269,20 +269,20 @@ $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $objec $sql .= $hookmanager->resPrint; /* If a group by is required */ -$sql.= " GROUP BY "; +$sql .= " GROUP BY "; foreach ($object->fields as $key => $val) { - $sql.='t.'.$key.', '; + $sql .= 't.'.$key.', '; } // Add fields from extrafields -if (! empty($extrafields->attributes[$object->table_element]['label'])) { - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : ''); +if (!empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.', ' : ''); } // Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListGroupBy', $parameters); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; -$sql=preg_replace('/,\s*$/', '', $sql); +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListGroupBy', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; +$sql = preg_replace('/,\s*$/', '', $sql); $sql .= $db->order($sortfield, $sortorder); diff --git a/htdocs/resource/contact.php b/htdocs/resource/contact.php index afce3dd9947..0330579f06c 100644 --- a/htdocs/resource/contact.php +++ b/htdocs/resource/contact.php @@ -55,7 +55,8 @@ if ($action == 'addcontact' && $user->rights->resource->write) if ($result > 0 && $id > 0) { $contactid = (GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int')); - $result = $object->add_contact($contactid, GETPOST('type', 'int'), GETPOST('source', 'alpha')); + $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type')); + $result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09')); } if ($result >= 0) diff --git a/htdocs/salaries/card.php b/htdocs/salaries/card.php index 487757ad567..7fb8427a517 100644 --- a/htdocs/salaries/card.php +++ b/htdocs/salaries/card.php @@ -1,6 +1,6 @@ - * Copyright (C) 2014 Laurent Destailleur + * Copyright (C) 2014-2020 Laurent Destailleur * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2015 Charlie BENKE * Copyright (C) 2018 Frédéric France @@ -265,7 +265,7 @@ if ($action == 'create') // Date payment print ''; // Date value for bank @@ -305,16 +305,6 @@ if ($action == 'create') print ''; print ''; - // Project - if (!empty($conf->projet->enabled)) - { - $formproject = new FormProjets($db); - - print ''; - } - // Bank if (!empty($conf->banque->enabled)) { @@ -340,6 +330,16 @@ if ($action == 'create') print ''."\n"; } + // Project + if (!empty($conf->projet->enabled)) + { + $formproject = new FormProjets($db); + + print ''; + } + // Other attributes $parameters = array(); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook @@ -476,9 +476,8 @@ if ($id) print dol_get_fiche_end(); - /* - * Action buttons - */ + // Action buttons + print '
'."\n"; if ($object->rappro == 0) { diff --git a/htdocs/salaries/list.php b/htdocs/salaries/list.php index 3ef6531e6fd..26477900be2 100644 --- a/htdocs/salaries/list.php +++ b/htdocs/salaries/list.php @@ -31,7 +31,42 @@ if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/account // Load translation files required by the page $langs->loadLangs(array("compta", "salaries", "bills", "hrm")); +$action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... +$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) +$show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ? +$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation +$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button +$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'bomlist'; // To manage different context of search +$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page +$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') + +// Load variable for pagination $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); +if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action +$offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; +if (!$sortfield) $sortfield = "s.datep,s.rowid"; +if (!$sortorder) $sortorder = "DESC,DESC"; + +// Initialize technical objects +$object = new PaymentSalary($db); +$extrafields = new ExtraFields($db); +$diroutputmassaction = $conf->user->dir_output.'/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('salarieslist')); // Note that conf->hooks_modules contains array + +// Fetch optionals attributes and labels +$extrafields->fetch_name_optionals_label($object->table_element); + +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); + +if (!$sortfield) $sortfield = "s.datep,s.rowid"; +if (!$sortorder) $sortorder = "DESC,DESC"; + $search_ref = GETPOST('search_ref', 'int'); $search_user = GETPOST('search_user', 'alpha'); $search_label = GETPOST('search_label', 'alpha'); @@ -40,30 +75,19 @@ $search_date_end = dol_mktime(23, 59, 59, GETPOST('search_date_endmonth', 'int') $search_amount = GETPOST('search_amount', 'alpha'); $search_account = GETPOST('search_account', 'int'); -$sortfield = GETPOST("sortfield", 'alpha'); -$sortorder = GETPOST("sortorder", 'alpha'); -$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 -$offset = $limit * $page; -$pageprev = $page - 1; -$pagenext = $page + 1; -if (!$sortfield) $sortfield = "s.datep,s.rowid"; -if (!$sortorder) $sortorder = "DESC,DESC"; -$optioncss = GETPOST('optioncss', 'alpha'); - $filtre = GETPOST("filtre", 'restricthtml'); -if (!GETPOST('typeid', 'int')) +if (!GETPOST('search_type_id', 'int')) { $newfiltre = str_replace('filtre=', '', $filtre); $filterarray = explode('-', $newfiltre); foreach ($filterarray as $val) { $part = explode(':', $val); - if ($part[0] == 's.fk_typepayment') $typeid = $part[1]; + if ($part[0] == 's.fk_typepayment') $search_type_id = $part[1]; } } else { - $typeid = GETPOST('typeid', 'int'); + $search_type_id = GETPOST('search_type_id', 'int'); } $childids = $user->getAllChildIds(1); @@ -73,36 +97,92 @@ $socid = GETPOST("socid", "int"); if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'salaries', '', '', ''); +// Initialize array of search criterias +$search_all = GETPOST("search_all", 'alpha'); +$search = array(); +foreach ($object->fields as $key => $val) +{ + if (GETPOST('search_'.$key, 'alpha') !== '') $search[$key] = GETPOST('search_'.$key, 'alpha'); +} + +// List of fields to search into when doing a "search in all" +$fieldstosearchall = array(); +foreach ($object->fields as $key => $val) +{ + if ($val['searchall']) $fieldstosearchall['t.'.$key] = $val['label']; +} + +$permissiontoread = $user->rights->salaries->read; +$permissiontoadd = $user->rights->salaries->write; +$permissiontodelete = $user->rights->salaries->delete; /* * Actions */ -if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers -{ - $search_ref = ""; - $search_user = ""; - $search_label = ""; - $search_date_start = ''; - $search_date_end = ''; - $search_amount = ""; - $search_account = ''; - $typeid = ""; -} +if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } +$parameters = array(); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +if (empty($reshook)) +{ + // Selection of new fields + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; + + // Purge search criteria + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers + { + $search_ref = ""; + $search_user = ""; + $search_label = ""; + $search_date_start = ''; + $search_date_end = ''; + $search_amount = ""; + $search_account = ''; + $search_type_id = ""; + } + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') + || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) + { + $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation + } + + // Mass actions + $objectclass = 'PaymentSalary'; + $objectlabel = 'SalariesPayments'; + $permissiontoread = $user->rights->salaries->read; + $permissiontodelete = $user->rights->salaries->delete; + $uploaddir = $conf->bom->dir_output; + include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; + + // Validate records + if (!$error && $massaction == 'buildsepa' && $permissiontoadd) + { + $objecttmp = new $objectclass($db); + + // TODO + } +} /* * View */ -llxHeader('', $langs->trans("Salaries")); - $form = new Form($db); $salstatic = new PaymentSalary($db); $userstatic = new User($db); $accountstatic = new Account($db); +$now = dol_now(); + +//$help_url="EN:Module_BillOfMaterials|FR:Module_BillOfMaterials_FR|ES:Módulo_BillOfMaterials"; +$help_url = ''; +$title = $langs->trans('SalariesPayments'); + $sql = "SELECT u.rowid as uid, u.lastname, u.firstname, u.login, u.email, u.admin, u.salary as current_salary, u.fk_soc as fk_soc, u.statut as status,"; $sql .= " s.rowid, s.fk_user, s.amount, s.salary, s.label, s.datep as datep, s.datev as datev, s.fk_typepayment as type, s.num_payment, s.fk_bank,"; $sql .= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel,"; @@ -113,210 +193,319 @@ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON s.fk_bank = b.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid,"; $sql .= " ".MAIN_DB_PREFIX."user as u"; $sql .= " WHERE u.rowid = s.fk_user"; -$sql .= " AND s.entity = ".$conf->entity; +$sql .= " AND s.entity IN (".getEntity('payment_salaries').")"; if (empty($user->rights->salaries->readall)) $sql .= " AND s.fk_user IN (".join(',', $childids).")"; // Search criteria -if ($search_ref) $sql .= " AND s.rowid=".$search_ref; +if ($search_ref) $sql .= " AND s.rowid=".((int) $search_ref); if ($search_user) $sql .= natural_search(array('u.login', 'u.lastname', 'u.firstname', 'u.email'), $search_user); if ($search_label) $sql .= natural_search(array('s.label'), $search_label); if ($search_date_start) $sql .= " AND s.datep >= '".$db->idate($search_date_start)."'"; if ($search_date_end) $sql .= " AND s.datep <= '".$db->idate($search_date_end)."'"; if ($search_amount) $sql .= natural_search("s.amount", $search_amount, 1); -if ($search_account > 0) $sql .= " AND b.fk_account=".$search_account; +if ($search_account > 0) $sql .= " AND b.fk_account=".((int) $search_account); if ($filtre) { $filtre = str_replace(":", "=", $filtre); $sql .= " AND ".$filtre; } -if ($typeid) { - $sql .= " AND s.fk_typepayment=".$typeid; +if ($search_type_id) { + $sql .= " AND s.fk_typepayment=".$search_type_id; } $sql .= $db->order($sortfield, $sortorder); -//$sql.= " GROUP BY u.rowid, u.lastname, u.firstname, s.rowid, s.fk_user, s.amount, s.label, s.datev, s.fk_typepayment, s.num_payment, pst.code"; -$totalnboflines = 0; -$result = $db->query($sql); -if ($result) +// Count total nb of records +$nbtotalofrecords = ''; +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $totalnboflines = $db->num_rows($result); + $resql = $db->query($sql); + $nbtotalofrecords = $db->num_rows($resql); + if (($page * $limit) > $nbtotalofrecords) // if total of record found is smaller than page * limit, goto and load page 0 + { + $page = 0; + $offset = 0; + } } -$sql .= $db->plimit($limit + 1, $offset); - - -$result = $db->query($sql); -if ($result) +// if total of record found is smaller than limit, no need to do paging and to restart another select with limits set. +if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) { - $num = $db->num_rows($result); - $i = 0; - $total = 0; + $num = $nbtotalofrecords; +} else { + if ($limit) $sql .= $db->plimit($limit + 1, $offset); - $param = ''; - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; - if ($typeid) $param .= '&typeid='.$typeid; - if ($optioncss != '') $param .= '&optioncss='.$optioncss; + $resql = $db->query($sql); + if (!$resql) + { + dol_print_error($db); + exit; + } - $url = DOL_URL_ROOT.'/salaries/card.php?action=create'; - if (!empty($socid)) $url .= '&socid='.$socid; - $newcardbutton = dolGetButtonTitle($langs->trans('NewSalaryPayment'), '', 'fa fa-plus-circle', $url, '', $user->rights->salaries->write); + $num = $db->num_rows($resql); +} - print '
'; - if ($optioncss != '') print ''; - print ''; - print ''; - print ''; - print ''; - print ''; +// Output page +// -------------------------------------------------------------------- - print_barre_liste($langs->trans("SalariesPayments"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines, 'object_payment', 0, $newcardbutton, '', $limit, 0, 0, 1); +llxHeader('', $title, $help_url); - print '
'; - print '
'.$langs->trans("NbOfGenerationDone").'
'.$langs->trans('PaymentMode').''; - $form->select_types_paiements(isset($_POST['mode_reglement_id']) ? $_POST['mode_reglement_id'] : $mode_reglement_id, 'mode_reglement_id', 'CRDT'); + $form->select_types_paiements(GETPOSTISSET('mode_reglement_id') ? GETPOST('mode_reglement_id') : $mode_reglement_id, 'mode_reglement_id', 'CRDT'); print '
'.$langs->trans('Type').''; + print ''; print $object->getLibType(); + print ''; if ($object->module_source) { - print ' ('.$langs->trans("POS").' '.$object->module_source.' - '.$langs->trans("Terminal").' '.$object->pos_source.')'; + print ' ('.$langs->trans("POS").' '.ucfirst($object->module_source).' - '.$langs->trans("Terminal").' '.$object->pos_source.')'; } if ($object->type == Facture::TYPE_REPLACEMENT) { $facreplaced = new Facture($db); $facreplaced->fetch($object->fk_facture_source); - print ' ('.$langs->transnoentities("ReplaceInvoice", $facreplaced->getNomUrl(1)).')'; + print ' ('.$langs->transnoentities("ReplaceInvoice", $facreplaced->getNomUrl(1)).')'; } if ($object->type == Facture::TYPE_CREDIT_NOTE && !empty($object->fk_facture_source)) { $facusing = new Facture($db); $facusing->fetch($object->fk_facture_source); - print ' ('.$langs->transnoentities("CorrectInvoice", $facusing->getNomUrl(1)).')'; + print ' ('.$langs->transnoentities("CorrectInvoice", $facusing->getNomUrl(1)).')'; } $facidavoir = $object->getListIdAvoirFromInvoice(); if (count($facidavoir) > 0) { - print ' ('.$langs->transnoentities("InvoiceHasAvoir"); + print ' ('.$langs->transnoentities("InvoiceHasAvoir"); $i = 0; foreach ($facidavoir as $id) { if ($i == 0) @@ -4105,14 +4104,16 @@ if ($action == 'create') if ($objectidnext > 0) { $facthatreplace = new Facture($db); $facthatreplace->fetch($objectidnext); - print ' ('.$langs->transnoentities("ReplacedByInvoice", $facthatreplace->getNomUrl(1)).')'; + print ' ('.$langs->transnoentities("ReplacedByInvoice", $facthatreplace->getNomUrl(1)).')'; } if ($object->type == Facture::TYPE_CREDIT_NOTE || $object->type == Facture::TYPE_DEPOSIT) { $discount = new DiscountAbsolute($db); $result = $discount->fetch(0, $object->id); if ($result > 0) { - print '. '.$langs->trans("CreditNoteConvertedIntoDiscount", $object->getLibType(1), $discount->getNomUrl(1, 'discount')).'
'; + print ' '; + print $langs->transnoentities("CreditNoteConvertedIntoDiscount", $object->getLibType(1), $discount->getNomUrl(1, 'discount')); + print '
'; } } @@ -4121,10 +4122,9 @@ if ($action == 'create') $tmptemplate = new FactureRec($db); $result = $tmptemplate->fetch($object->fk_fac_rec_source); if ($result > 0) { - print '. '.$langs->trans( - "GeneratedFromTemplate", - ''.$tmptemplate->ref.'' - ).''; + print ' '; + print $langs->transnoentities("GeneratedFromTemplate", ''.dol_escape_htmltag($tmptemplate->ref).''); + print ''; } } print '
'.$langs->trans('Discounts'); - print ''; $thirdparty = $soc; $discount_type = 0; $backtopage = urlencode($_SERVER["PHP_SELF"].'?facid='.$object->id); include DOL_DOCUMENT_ROOT.'/core/tpl/object_discounts.tpl.php'; - print '
'; - if ($object->type != Facture::TYPE_DEPOSIT) + print ''; + if ($object->type != Facture::TYPE_DEPOSIT) { print $langs->trans('AlreadyPaidNoCreditNotesNoDeposits'); - else print $langs->trans('AlreadyPaid'); - print ' :'.price($totalpaye).' 
'.price($totalpaye).' 
'; + print ''; if ($invoice->type == Facture::TYPE_CREDIT_NOTE) print $langs->trans("CreditNote").' '; if ($invoice->type == Facture::TYPE_DEPOSIT) print $langs->trans("Deposit").' '; print $invoice->getNomUrl(0); - print ' :'.price($obj->amount_ttc).''; print 'rowid.'">'.img_delete().''; @@ -4835,7 +4838,9 @@ if ($action == 'create') // Paye partiellement 'escompte' if (($object->statut == Facture::STATUS_CLOSED || $object->statut == Facture::STATUS_ABANDONED) && $object->close_code == 'discount_vat') { print '
'; - print $form->textwithpicto($langs->trans("Discount").':', $langs->trans("HelpEscompte"), - 1); + print ''; + print $form->textwithpicto($langs->trans("Discount"), $langs->trans("HelpEscompte"), - 1); + print ''; print ''.price(price2num($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye, 'MT')).' 
'; - print $form->textwithpicto($langs->trans("Abandoned").':', $langs->trans("HelpAbandonBadCustomer"), - 1); + print ''; + print $form->textwithpicto($langs->trans("Abandoned"), $langs->trans("HelpAbandonBadCustomer"), - 1); + print ''; print ''.price(price2num($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye, 'MT')).' 
'; - print $form->textwithpicto($langs->trans("ProductReturned").':', $langs->trans("HelpAbandonProductReturned"), - 1); + print ''; + print $form->textwithpicto($langs->trans("ProductReturned"), $langs->trans("HelpAbandonProductReturned"), - 1); + print ''; print ''.price(price2num($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye, 'MT')).' 
'.price(price2num($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye, 'MT')).' 
'.$langs->trans("Billed").' :'.price($object->total_ttc).' 
'; + print ''; + print $langs->trans("Billed"); + print ''.price($object->total_ttc).' 
'; + print ''; print $langs->trans('RemainderToPay'); if ($resteapayeraffiche < 0) print ' ('.$langs->trans('ExcessReceived').')'; - print ' :'.price($resteapayeraffiche).' 
'.$langs->trans("RemainderToPay").''.price($total-$sumpaid,0,$outputlangs,1,-1,-1,$conf->currency).'
'.$langs->trans("Date").''; - $datepaye = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); - $datepayment = empty($conf->global->MAIN_AUTOFILL_DATE) ? (empty($_POST["remonth"]) ?-1 : $datepaye) : 0; + $datepaye = dol_mktime(12, 0, 0, GETPOST("remonth", 'int'), GETPOST("reday", 'int'), GETPOST("reyear", 'int')); + $datepayment = empty($conf->global->MAIN_AUTOFILL_DATE) ? (GETPOSTISSET("remonth") ? $datepaye : -1) : 0; print $form->selectDate($datepayment, '', '', '', 0, "add_payment", 1, 1, 0, '', '', $charge->date_ech, '', 1, $langs->trans("DateOfSocialContribution")); print "
'.$langs->trans("PaymentMode").''; - $form->select_types_paiements(isset($_POST["paiementtype"]) ? $_POST["paiementtype"] : $charge->paiementtype, "paiementtype"); + $form->select_types_paiements(GETPOSTISSET("paiementtype") ? GETPOST("paiementtype") : $charge->paiementtype, "paiementtype"); print "
'.$langs->trans('AccountToDebit').''; - $form->select_comptes(isset($_POST["accountid"]) ? $_POST["accountid"] : $charge->accountid, "accountid", 0, '', 2); // Show opend bank account list + $form->select_comptes(GETPOSTISSET("accountid") ? GETPOST("accountid") : $charge->accountid, "accountid", 0, '', 2); // Show opend bank account list print '
deleteEcmFiles(1); // Deleting files physically is done later with the dol_delete_dir_recursive - if (! $res) { + if (!$res) { $error++; } } @@ -8489,7 +8487,7 @@ abstract class CommonObject // Delete ecm_files extrafields $sql = "DELETE FROM ".MAIN_DB_PREFIX."ecm_files_extrafields WHERE fk_object IN ("; $sql .= " SELECT rowid FROM ".MAIN_DB_PREFIX."ecm_files WHERE filename LIKE '".$this->db->escape($this->ref)."%'"; - $sql .= " AND filepath = '".$this->db->escape($element)."/".$this->db->escape($this->ref)."' AND entity = ".$conf->entity; // No need of getEntity here + $sql .= " AND filepath = '".$this->db->escape($element)."/".$this->db->escape($this->ref)."' AND entity = ".$conf->entity; // No need of getEntity here $sql .= ")"; if (!$this->db->query($sql)) { @@ -8501,7 +8499,7 @@ abstract class CommonObject // Delete ecm_files $sql = "DELETE FROM ".MAIN_DB_PREFIX."ecm_files"; $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%'"; - $sql .= " AND filepath = '".$this->db->escape($element)."/".$this->db->escape($this->ref)."' AND entity = ".$conf->entity; // No need of getEntity here + $sql .= " AND filepath = '".$this->db->escape($element)."/".$this->db->escape($this->ref)."' AND entity = ".$conf->entity; // No need of getEntity here if (!$this->db->query($sql)) { $this->error = $this->db->lasterror(); diff --git a/htdocs/core/class/dolgeoip.class.php b/htdocs/core/class/dolgeoip.class.php index 215a1710b82..98fbe62e4c5 100644 --- a/htdocs/core/class/dolgeoip.class.php +++ b/htdocs/core/class/dolgeoip.class.php @@ -98,7 +98,7 @@ class DolGeoIP //print 'function_exists(geoip_country_code_by_name))='.function_exists('geoip_country_code_by_name'); //print geoip_database_info(); } else { - $this->gi = ''; // For avoid error + $this->gi = ''; // For avoid error } } diff --git a/htdocs/core/class/dolreceiptprinter.class.php b/htdocs/core/class/dolreceiptprinter.class.php index ec8d9fa15bd..e075005b437 100644 --- a/htdocs/core/class/dolreceiptprinter.class.php +++ b/htdocs/core/class/dolreceiptprinter.class.php @@ -631,11 +631,18 @@ class dolReceiptPrinter extends Printer break; case 'DOL_PRINT_OBJECT_LINES': foreach ($object->lines as $line) { - //var_dump($line); - $spacestoadd = $nbcharactbyline - strlen($line->ref) - strlen($line->qty) - 10 - 1; - $spaces = str_repeat(' ', $spacestoadd); - $this->printer->text($line->ref.$spaces.$line->qty.' '.str_pad(price($line->total_ttc), 10, ' ', STR_PAD_LEFT)."\n"); - $this->printer->text(strip_tags(htmlspecialchars_decode($line->product_label))."\n"); + if ($line->fk_product) + { + $spacestoadd = $nbcharactbyline - strlen($line->ref) - strlen($line->qty) - 10 - 1; + $spaces = str_repeat(' ', $spacestoadd); + $this->printer->text($line->ref.$spaces.$line->qty.' '.str_pad(price($line->total_ttc), 10, ' ', STR_PAD_LEFT)."\n"); + $this->printer->text(strip_tags(htmlspecialchars_decode($line->product_label))."\n"); + } + else { + $spacestoadd = $nbcharactbyline - strlen($line->description) - strlen($line->qty) - 10 - 1; + $spaces = str_repeat(' ', $spacestoadd); + $this->printer->text($line->description.$spaces.$line->qty.' '.str_pad(price($line->total_ttc), 10, ' ', STR_PAD_LEFT)."\n"); + } } break; case 'DOL_PRINT_OBJECT_TAX': diff --git a/htdocs/core/class/events.class.php b/htdocs/core/class/events.class.php index 1b8a9eb3291..16c133f9dab 100644 --- a/htdocs/core/class/events.class.php +++ b/htdocs/core/class/events.class.php @@ -141,7 +141,7 @@ class Events // extends CommonObject // Clean parameters $this->description = trim($this->description); - if (empty($this->user_agent)) $this->user_agent = (empty($_SERVER['HTTP_USER_AGENT'])?'':$_SERVER['HTTP_USER_AGENT']); + if (empty($this->user_agent)) $this->user_agent = (empty($_SERVER['HTTP_USER_AGENT']) ? '' : $_SERVER['HTTP_USER_AGENT']); // Check parameters if (empty($this->description)) { $this->error = 'ErrorBadValueForParameterCreateEventDesc'; return -1; } diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 87cee951170..d041aba45f4 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1937,10 +1937,10 @@ class ExtraFields $out .= ''; print ''; } print '
select_resource_list('', 'fk_resource', '', 1, 1, 0, $events, '', 2, null); $out .= ''; -$out .= '
'.$form->selectyesno('busy', (isset($_POST['busy']) ? $_POST['busy'] : 1), 1).'
'; -$out .= '
'.$form->selectyesno('mandatory', (isset($_POST['mandatory']) ? $_POST['mandatory'] : 0), 1).'
'; +$out .= '
'.$form->selectyesno('busy', (GETPOSTISSET('busy') ? GETPOST('busy') : 1), 1).'
'; +$out .= '
'.$form->selectyesno('mandatory', (GETPOSTISSET('mandatory') ? GETPOST('mandatory') : 0), 1).'
'; $out .= '
'; $out .= ''; diff --git a/htdocs/core/triggers/interface_20_all_Logevents.class.php b/htdocs/core/triggers/interface_20_all_Logevents.class.php index e1bcaf85034..48c9614dea6 100644 --- a/htdocs/core/triggers/interface_20_all_Logevents.class.php +++ b/htdocs/core/triggers/interface_20_all_Logevents.class.php @@ -174,7 +174,7 @@ class InterfaceLogevents extends DolibarrTriggers $event->dateevent = $date; $event->label = $text; $event->description = $desc; - $event->user_agent = (empty($_SERVER["HTTP_USER_AGENT"])?'':$_SERVER["HTTP_USER_AGENT"]); + $event->user_agent = (empty($_SERVER["HTTP_USER_AGENT"]) ? '' : $_SERVER["HTTP_USER_AGENT"]); $result = $event->create($user); if ($result > 0) { diff --git a/htdocs/delivery/class/delivery.class.php b/htdocs/delivery/class/delivery.class.php index 3c4d53f53e7..394e86fdd78 100644 --- a/htdocs/delivery/class/delivery.class.php +++ b/htdocs/delivery/class/delivery.class.php @@ -102,6 +102,8 @@ class Delivery extends CommonObject */ public $model_pdf; + public $lines = array(); + /** * Constructor @@ -111,8 +113,6 @@ class Delivery extends CommonObject public function __construct($db) { $this->db = $db; - $this->lines = array(); - $this->products = array(); // List of short language codes for status $this->statuts[-1] = 'StatusDeliveryCanceled'; diff --git a/htdocs/document.php b/htdocs/document.php index c48a0363f78..060722e8d5b 100644 --- a/htdocs/document.php +++ b/htdocs/document.php @@ -245,7 +245,7 @@ if (!file_exists($fullpath_original_file_osencoded)) // Hooks if (!is_object($hookmanager)) { - include_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php'; + include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; $hookmanager = new HookManager($this->db); } $hookmanager->initHooks(array('document')); @@ -254,9 +254,9 @@ $parameters = array('ecmfile' => $ecmfile, 'modulepart' => $modulepart, 'origina 'filename' => $filename, 'fullpath_original_file_osencoded' => $fullpath_original_file_osencoded); $reshook = $hookmanager->executeHooks('downloadDocument', $parameters); // Note that $action and $object may have been if ($reshook < 0) { - $errors = $hookmanager->error . (is_array($hookmanager->errors) ? (!empty($hookmanager->error) ? ', ' : '') . join($separator, $hookmanager->errors) : ''); - dol_syslog("document.php - Errors when executing the hook 'downloadDocument' : " . $errors); - print "ErrorDownloadDocumentHooks: " . $errors; + $errors = $hookmanager->error.(is_array($hookmanager->errors) ? (!empty($hookmanager->error) ? ', ' : '').join($separator, $hookmanager->errors) : ''); + dol_syslog("document.php - Errors when executing the hook 'downloadDocument' : ".$errors); + print "ErrorDownloadDocumentHooks: ".$errors; exit; } diff --git a/htdocs/don/card.php b/htdocs/don/card.php index 0f4b2054619..c55751e913f 100644 --- a/htdocs/don/card.php +++ b/htdocs/don/card.php @@ -418,9 +418,9 @@ if ($action == 'create') // Zip / Town print '
'.$langs->trans("Zip").' / '.$langs->trans("Town").''; - print $formcompany->select_ziptown((isset($_POST["zipcode"]) ? $_POST["zipcode"] : $object->zip), 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6); + print $formcompany->select_ziptown((GETPOSTISSET("zipcode") ? GETPOST("zipcode") : $object->zip), 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6); print ' '; - print $formcompany->select_ziptown((isset($_POST["town"]) ? $_POST["town"] : $object->town), 'town', array('zipcode', 'selectcountry_id', 'state_id')); + print $formcompany->select_ziptown((GETPOSTISSET("town") ? GETPOST("town") : $object->town), 'town', array('zipcode', 'selectcountry_id', 'state_id')); print '
'.$langs->trans("Zip").' / '.$langs->trans("Town").''; - print $formcompany->select_ziptown((isset($_POST["zipcode"]) ? $_POST["zipcode"] : $object->zip), 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6); + print $formcompany->select_ziptown((GETPOSTISSET("zipcode") ? GETPOSTISSET("zipcode") : $object->zip), 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6); print ' '; - print $formcompany->select_ziptown((isset($_POST["town"]) ? $_POST["town"] : $object->town), 'town', array('zipcode', 'selectcountry_id', 'state_id')); + print $formcompany->select_ziptown((GETPOSTISSET("town") ? GETPOST("town") : $object->town), 'town', array('zipcode', 'selectcountry_id', 'state_id')); print '
'.$langs->trans("Description").''; print ''.$lines[$i]->comment.''; $tmp = $module->getExample(); - if (preg_match('/^Error/', $tmp)) print '
'.$langs->trans($tmp).'
'; - elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); + if (preg_match('/^Error/', $tmp)) { + $langs->load("errors"); + print '
'.$langs->trans($tmp).'
'; + } elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); else print $tmp; print '
'; $tmp = $module->getExample(); - if (preg_match('/^Error/', $tmp)) print '
'.$langs->trans($tmp).'
'; - elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); + if (preg_match('/^Error/', $tmp)) { + $langs->load("errors"); + print '
'.$langs->trans($tmp).'
'; + } elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); else print $tmp; print '
'; print $form->editfieldkey('DatePayment', 'datep', '', $object, 0, 'string', '', 1).''; - print $form->selectDate((empty($datep) ?-1 : $datep), "datep", '', '', '', 'add', 1, 1); + print $form->selectDate((empty($datep) ? '' : $datep), "datep", 0, 0, 0, 'add', 1, 1); print '
'.$langs->trans("Project").''; - $formproject->select_projects(-1, $projectid, 'fk_project', 0, 0, 1, 1); - print '
'.$langs->trans("Project").''; + $formproject->select_projects(-1, $projectid, 'fk_project', 0, 0, 1, 1); + print '
'."\n"; +$arrayofselected = is_array($toselect) ? $toselect : array(); - print ''; - // Ref - print ''; - // Employee +$param = ''; +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); +if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); +if ($search_type_id) $param .= '&search_type_id='.urlencode($search_type_id); +if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); +if ($search_ref) $param .= '&search_ref='.urlencode($search_ref); +if ($search_user > 0) $param .= '&search_user='.urlencode($search_user); +if ($search_label) $param .= '&search_label='.urlencode($search_label); +if ($search_account) $param .= '&search_account='.urlencode($search_account); +if ($search_date_start) $param .= '&search_date_startday='.urlencode(GETPOST('search_date_startday', 'int')).'&search_date_startmonth='.urlencode(GETPOST('search_date_startmonth', 'int')).'&search_date_startyear='.urlencode(GETPOST('search_date_startyear', 'int')); +if ($search_date_end) $param .= '&search_date_endday='.urlencode(GETPOST('search_date_endday', 'int')).'&search_date_endmonth='.urlencode(GETPOST('search_date_endmonth', 'int')).'&search_date_endyear='.urlencode(GETPOST('search_date_endyear', 'int')); +// Add $param from extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; + +// List of mass actions available +$arrayofmassactions = array( + //'presend'=>$langs->trans("SendByMail"), + //'buildsepa'=>$langs->trans("BuildSepa"), // TODO +); +//if ($permissiontodelete) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); +if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); +$massactionbutton = $form->selectMassAction('', $arrayofmassactions); + +print ''; +if ($optioncss != '') print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; + +$url = DOL_URL_ROOT.'/salaries/card.php?action=create'; +if (!empty($socid)) $url .= '&socid='.$socid; +$newcardbutton = dolGetButtonTitle($langs->trans('NewSalaryPayment'), '', 'fa fa-plus-circle', $url, '', $user->rights->salaries->write); + +print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $totalnboflines, 'object_payment', 0, $newcardbutton, '', $limit, 0, 0, 1); + +$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; +//$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +$selectedfields = ''; +$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); + +print '
'; +print '
'; - print ''; - print '
'."\n"; + +// Fields title search +// -------------------------------------------------------------------- +print ''; +// Ref +print ''; +// Employee +print ''; +// Label +print ''; +// Date +print ''; +// Type +print ''; +// Account +if (!empty($conf->banque->enabled)) +{ print ''; - // Label - print ''; - // Date - print ''; +} +// Amount +print ''; + +// Extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; + +// Fields from hook +$parameters = array('arrayfields'=>$arrayfields); +$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; +// Action column +print ''; +print ''."\n"; + + +// Fields title label +// -------------------------------------------------------------------- +print ''; +print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "s.rowid", "", $param, "", $sortfield, $sortorder); +print_liste_field_titre("Employee", $_SERVER["PHP_SELF"], "u.rowid", "", $param, "", $sortfield, $sortorder); +print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "s.label", "", $param, 'class="left"', $sortfield, $sortorder); +print_liste_field_titre("DatePayment", $_SERVER["PHP_SELF"], "s.datep,s.rowid", "", $param, 'align="center"', $sortfield, $sortorder); +print_liste_field_titre("PaymentMode", $_SERVER["PHP_SELF"], "type", "", $param, 'class="left"', $sortfield, $sortorder); +if (!empty($conf->banque->enabled)) print_liste_field_titre("BankAccount", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder); +print_liste_field_titre("PayedByThisPayment", $_SERVER["PHP_SELF"], "s.amount", "", $param, 'class="right"', $sortfield, $sortorder); +// Extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; +// Hook fields +$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); +$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; +// Action column +print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; +print ''."\n"; + + +// Detect if we need a fetch on each output line +$needToFetchEachLine = 0; +if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) +{ + foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) + { + if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object + } +} + +// Loop on record +// -------------------------------------------------------------------- +$i = 0; +$total = 0; +$totalarray = array(); +while ($i < ($limit ? min($num, $limit) : $num)) +{ + $obj = $db->fetch_object($resql); + if (empty($obj)) break; // Should not happen + + // Store properties in $object + $object->setVarsFromFetchObj($obj); + + // Show here line of result + print ''; + + $userstatic->id = $obj->uid; + $userstatic->lastname = $obj->lastname; + $userstatic->firstname = $obj->firstname; + $userstatic->admin = $obj->admin; + $userstatic->login = $obj->login; + $userstatic->email = $obj->email; + $userstatic->socid = $obj->fk_soc; + $userstatic->statut = $obj->status; + + $salstatic->id = $obj->rowid; + $salstatic->ref = $obj->rowid; + + // Ref + print "\n"; + if (!$i) $totalarray['nbfield']++; + + // Employee + print "\n"; + if (!$i) $totalarray['nbfield']++; + + // Label payment + print "\n"; + if (!$i) $totalarray['nbfield']++; + + // Date payment + print '\n"; + if (!$i) $totalarray['nbfield']++; + // Type - print ''; + print ''; + if (!$i) $totalarray['nbfield']++; + // Account if (!empty($conf->banque->enabled)) { - print ''; - } - // Amount - print ''; - - print ''; - - print ''; - print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "s.rowid", "", $param, "", $sortfield, $sortorder); - print_liste_field_titre("Employee", $_SERVER["PHP_SELF"], "u.rowid", "", $param, "", $sortfield, $sortorder); - print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "s.label", "", $param, 'class="left"', $sortfield, $sortorder); - print_liste_field_titre("DatePayment", $_SERVER["PHP_SELF"], "s.datep,s.rowid", "", $param, 'align="center"', $sortfield, $sortorder); - print_liste_field_titre("PaymentMode", $_SERVER["PHP_SELF"], "type", "", $param, 'class="left"', $sortfield, $sortorder); - if (!empty($conf->banque->enabled)) print_liste_field_titre("BankAccount", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder); - print_liste_field_titre("PayedByThisPayment", $_SERVER["PHP_SELF"], "s.amount", "", $param, 'class="right"', $sortfield, $sortorder); - print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'maxwidthsearch '); - print "\n"; - - print "\n"; - - while ($i < min($num, $limit)) - { - $obj = $db->fetch_object($result); - - print ''; - - $userstatic->id = $obj->uid; - $userstatic->lastname = $obj->lastname; - $userstatic->firstname = $obj->firstname; - $userstatic->admin = $obj->admin; - $userstatic->login = $obj->login; - $userstatic->email = $obj->email; - $userstatic->socid = $obj->fk_soc; - $userstatic->statut = $obj->status; - - $salstatic->id = $obj->rowid; - $salstatic->ref = $obj->rowid; - - // Ref - print "\n"; - if (!$i) $totalarray['nbfield']++; - - // Employee - print "\n"; - if (!$i) $totalarray['nbfield']++; - - // Label payment - print "\n"; - if (!$i) $totalarray['nbfield']++; - - // Date payment - print '\n"; - if (!$i) $totalarray['nbfield']++; - - // Type - print ''; - if (!$i) $totalarray['nbfield']++; - - // Account - if (!empty($conf->banque->enabled)) + print ''; - if (!$i) $totalarray['nbfield']++; - } - - // Amount - print ''; + $accountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1, '', 1); + } + $accountstatic->label = $obj->blabel; + print $accountstatic->getNomUrl(1); + } else print ' '; + print ''; if (!$i) $totalarray['nbfield']++; - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'totalttcfield'; - $totalarray['val']['totalttcfield'] += $obj->amount; - - print ''; - - if (!$i) $totalarray['nbfield']++; - - print "\n"; - - $i++; } - // Show total line - include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; + // Amount + print ''; + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'totalttcfield'; + $totalarray['val']['totalttcfield'] += $obj->amount; - print "
'; +print ''; +print ''; +print ''; +print ''; +print '
'; +print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); +print '
'; +print '
'; +print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); +print '
'; +print '
'; +$form->select_types_paiements($search_type_id, 'search_type_id', '', 0, 1, 1, 16); +print ''; - print ''; - print ''; - print '
'; - print $form->selectDate($search_date_start ? $search_date_start : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); - print '
'; - print '
'; - print $form->selectDate($search_date_end ? $search_date_end : -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); - print '
'; + $form->select_comptes($search_account, 'search_account', 0, '', 1); print '
'; +$searchpicto = $form->showFilterButtons(); +print $searchpicto; +print '
".$salstatic->getNomUrl(1)."".$userstatic->getNomUrl(1)."".dol_trunc($obj->label, 40)."'.dol_print_date($db->jdate($obj->datep), 'day')."'; - $form->select_types_paiements($typeid, 'typeid', '', 0, 1, 1, 16); - print ''.$langs->trans("PaymentTypeShort".$obj->payment_code).' '.$obj->num_payment.''; - $form->select_comptes($search_account, 'search_account', 0, '', 1); - print ''; - $searchpicto = $form->showFilterAndCheckAddButtons(0); - print $searchpicto; - print '
".$salstatic->getNomUrl(1)."".$userstatic->getNomUrl(1)."".dol_trunc($obj->label, 40)."'.dol_print_date($db->jdate($obj->datep), 'day')."'.$langs->trans("PaymentTypeShort".$obj->payment_code).' '.$obj->num_payment.''; + if ($obj->fk_bank > 0) { - print ''; - if ($obj->fk_bank > 0) + //$accountstatic->fetch($obj->fk_bank); + $accountstatic->id = $obj->bid; + $accountstatic->ref = $obj->bref; + $accountstatic->number = $obj->bnumber; + + if (!empty($conf->accounting->enabled)) { - //$accountstatic->fetch($obj->fk_bank); - $accountstatic->id = $obj->bid; - $accountstatic->ref = $obj->bref; - $accountstatic->number = $obj->bnumber; + $accountstatic->account_number = $obj->account_number; - if (!empty($conf->accounting->enabled)) - { - $accountstatic->account_number = $obj->account_number; + $accountingjournal = new AccountingJournal($db); + $accountingjournal->fetch($obj->fk_accountancy_journal); - $accountingjournal = new AccountingJournal($db); - $accountingjournal->fetch($obj->fk_accountancy_journal); - - $accountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1, '', 1); - } - $accountstatic->label = $obj->blabel; - print $accountstatic->getNomUrl(1); - } else print ' '; - print ''.price($obj->amount).'
'.price($obj->amount).'
"; - print ''; - print ''; + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Action column + print '
'; + if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + { + $selected = 0; + if (in_array($object->id, $arrayofselected)) $selected = 1; + print ''; + } + print '
'.$langs->trans("NoRecordFound").'
'."\n"; +print ''."\n"; + +print ''."\n"; + + + // End of page llxFooter(); $db->close(); diff --git a/htdocs/societe/admin/societe.php b/htdocs/societe/admin/societe.php index ac26eed537a..49b58d61d08 100644 --- a/htdocs/societe/admin/societe.php +++ b/htdocs/societe/admin/societe.php @@ -813,14 +813,14 @@ print '
' . $langs->trans("AddEmailPhoneTownInContactList") . ''.$langs->trans("AddEmailPhoneTownInContactList").' '; if (!empty($conf->global->CONTACT_SHOW_EMAIL_PHONE_TOWN_SELECTLIST)) { - print ''; + print ''; print img_picto($langs->trans("Activated"), 'switch_on'); } else { - print ''; + print ''; print img_picto($langs->trans("Disabled"), 'switch_off'); } print ' '; + print ''; + print ''.$obj->code_compta_fournisseur.''.$obj->address.''; $tmp = $module->getExample(); - if (preg_match('/^Error/', $tmp)) print '
'.$langs->trans($tmp).'
'; - elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); + if (preg_match('/^Error/', $tmp)) { + $langs->load("errors"); + print '
'.$langs->trans($tmp).'
'; + } elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); else print $tmp; print '

\n"; +print '
'; + // Mode print '
'; print ''; @@ -239,7 +243,7 @@ print '
'; print ''; print ''; -print ''; +print ''; print "\n"; // Terminals @@ -299,11 +303,12 @@ print $form->selectarray('TAKEPOS_NUMPAD', $array, (empty($conf->global->TAKEPOS print "\n"; // Numpad use payment icons -print '\n"; +*/ // Direct Payment print ''; $htmlforlines .= ''; $htmlforlines .= ''; $htmlforlines .= ''; } elseif ($key == 'fk_user_assign' || $key == 'fk_user_create') { - print ''; + print ''; } elseif ($key == 'fk_statut') { $arrayofstatus = array(); $arrayofstatus['openall'] = '-- '.$langs->trans('OpenAll').' --'; diff --git a/htdocs/ticket/messaging.php b/htdocs/ticket/messaging.php index af6f78fe98c..49f15412965 100644 --- a/htdocs/ticket/messaging.php +++ b/htdocs/ticket/messaging.php @@ -41,8 +41,8 @@ $socid = GETPOST('socid', 'int'); $action = GETPOST('action', 'aZ09'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", "alpha"); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST("sortfield", "aZ09comma"); +$sortorder = GETPOST("sortorder", 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $page = is_numeric($page) ? $page : 0; $page = $page == -1 ? 0 : $page; diff --git a/htdocs/ticket/stats/index.php b/htdocs/ticket/stats/index.php index 4273979d45e..045943bbfda 100644 --- a/htdocs/ticket/stats/index.php +++ b/htdocs/ticket/stats/index.php @@ -32,7 +32,7 @@ $HEIGHT = DolGraph::getDefaultGraphSizeForStats('height'); if (!$user->rights->ticket->read) accessforbidden(); -$object_status = GETPOST('object_status'); +$object_status = GETPOST('object_status', 'intcomma'); $userid = GETPOST('userid', 'int'); $socid = GETPOST('socid', 'int'); @@ -44,7 +44,7 @@ if ($user->socid > 0) } $nowyear = strftime("%Y", dol_now()); -$year = GETPOST('year') > 0 ?GETPOST('year') : $nowyear; +$year = GETPOST('year') > 0 ? GETPOST('year', 'int') : $nowyear; //$startyear=$year-2; $startyear = $year - 1; $endyear = $year; @@ -235,7 +235,7 @@ print $form->select_dolusers($userid, 'userid', 1, '', 0, '', '', 0, 0, 0, '', 0 // Status print ''; // Year print ''; } +// Supervisor +if (!empty($arrayfields['u.fk_user']['checked'])) +{ + print ''; +} if (!empty($arrayfields['u.accountancy_code']['checked'])) { print ''; @@ -561,12 +558,9 @@ if (!empty($arrayfields['u.entity']['checked'])) { print ''; } -// Supervisor -if (!empty($arrayfields['u.fk_user']['checked'])) +if (!empty($arrayfields['u.salary']['checked'])) { - print ''; + print ''; } if (!empty($arrayfields['u.datelastlogin']['checked'])) { @@ -615,12 +609,13 @@ if (!empty($arrayfields['u.lastname']['checked'])) print_liste_field_titre if (!empty($arrayfields['u.firstname']['checked'])) print_liste_field_titre("FirstName", $_SERVER['PHP_SELF'], "u.firstname", $param, "", "", $sortfield, $sortorder); if (!empty($arrayfields['u.gender']['checked'])) print_liste_field_titre("Gender", $_SERVER['PHP_SELF'], "u.gender", $param, "", "", $sortfield, $sortorder); if (!empty($arrayfields['u.employee']['checked'])) print_liste_field_titre("Employee", $_SERVER['PHP_SELF'], "u.employee", $param, "", "", $sortfield, $sortorder); +if (!empty($arrayfields['u.fk_user']['checked'])) print_liste_field_titre("HierarchicalResponsible", $_SERVER['PHP_SELF'], "u.fk_user", $param, "", "", $sortfield, $sortorder); if (!empty($arrayfields['u.accountancy_code']['checked'])) print_liste_field_titre("AccountancyCode", $_SERVER['PHP_SELF'], "u.accountancy_code", $param, "", "", $sortfield, $sortorder); if (!empty($arrayfields['u.email']['checked'])) print_liste_field_titre("EMail", $_SERVER['PHP_SELF'], "u.email", $param, "", "", $sortfield, $sortorder); if (!empty($arrayfields['u.api_key']['checked'])) print_liste_field_titre("ApiKey", $_SERVER['PHP_SELF'], "u.api_key", $param, "", "", $sortfield, $sortorder); if (!empty($arrayfields['u.fk_soc']['checked'])) print_liste_field_titre("Company", $_SERVER['PHP_SELF'], "u.fk_soc", $param, "", "", $sortfield, $sortorder); if (!empty($arrayfields['u.entity']['checked'])) print_liste_field_titre("Entity", $_SERVER['PHP_SELF'], "u.entity", $param, "", "", $sortfield, $sortorder); -if (!empty($arrayfields['u.fk_user']['checked'])) print_liste_field_titre("HierarchicalResponsible", $_SERVER['PHP_SELF'], "u.fk_user", $param, "", "", $sortfield, $sortorder); +if (!empty($arrayfields['u.salary']['checked'])) print_liste_field_titre("Salary", $_SERVER['PHP_SELF'], "u.salary", $param, "", "", $sortfield, $sortorder, 'right '); if (!empty($arrayfields['u.datelastlogin']['checked'])) print_liste_field_titre("LastConnexion", $_SERVER['PHP_SELF'], "u.datelastlogin", $param, "", '', $sortfield, $sortorder, 'center '); if (!empty($arrayfields['u.datepreviouslogin']['checked'])) print_liste_field_titre("PreviousConnexion", $_SERVER['PHP_SELF'], "u.datepreviouslogin", $param, "", '', $sortfield, $sortorder, 'center '); // Extra fields @@ -713,6 +708,37 @@ while ($i < ($limit ? min($num, $limit) : $num)) print ''; if (!$i) $totalarray['nbfield']++; } + + // Supervisor + if (!empty($arrayfields['u.fk_user']['checked'])) + { + // Resp + print ''; + if (!$i) $totalarray['nbfield']++; + } + if (!empty($arrayfields['u.accountancy_code']['checked'])) { print ''; @@ -763,34 +789,12 @@ while ($i < ($limit ? min($num, $limit) : $num)) if (!$i) $totalarray['nbfield']++; } } - // Supervisor - if (!empty($arrayfields['u.fk_user']['checked'])) + + // Salary + if (!empty($arrayfields['u.salary']['checked'])) { - // Resp - print ''; - if (!$i) $totalarray['nbfield']++; + print ''; + if (!$i) $totalarray['nbfield']++; } // Date last login diff --git a/htdocs/variants/admin/admin.php b/htdocs/variants/admin/admin.php index 7e5683e710b..64209076916 100644 --- a/htdocs/variants/admin/admin.php +++ b/htdocs/variants/admin/admin.php @@ -22,44 +22,57 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; $langs->loadLangs(array("admin", "products")); +$action = GETPOST('action', 'alphanohtml'); + // Security check if (!$user->admin || (empty($conf->product->enabled) && empty($conf->service->enabled))) accessforbidden(); -if ($_POST) { +$error = 0; + + +/* + * Actions + */ + +if ($action) { $value = GETPOST('PRODUIT_ATTRIBUTES_HIDECHILD'); - if (dolibarr_set_const($db, 'PRODUIT_ATTRIBUTES_HIDECHILD', $value, 'chaine', 0, '', $conf->entity)) { - setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); - } else { + if (!dolibarr_set_const($db, 'PRODUIT_ATTRIBUTES_HIDECHILD', $value, 'chaine', 0, '', $conf->entity)) { setEventMessages($langs->trans('CoreErrorMessage'), null, 'errors'); + $error++; } - if (dolibarr_set_const($db, 'PRODUIT_ATTRIBUTES_SEPARATOR', GETPOST('PRODUIT_ATTRIBUTES_SEPARATOR'), 'chaine', 0, '', $conf->entity)) { - setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); - } else { + if (!dolibarr_set_const($db, 'PRODUIT_ATTRIBUTES_SEPARATOR', GETPOST('PRODUIT_ATTRIBUTES_SEPARATOR'), 'chaine', 0, '', $conf->entity)) { setEventMessages($langs->trans('CoreErrorMessage'), null, 'errors'); + $error++; + } + + if (!$error) { + setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); } } -$title = $langs->trans('ModuleSetup').' '.$langs->trans('ProductAttributes'); +$title = $langs->trans('ModuleSetup').' '.$langs->trans('Module610Name'); llxHeader('', $title); $linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($title, $linkback, 'title_setup'); -print dol_get_fiche_head(array(), 'general', $tab, 0, 'product'); - print ''; print ''; +print ''; print '
'.$langs->trans("Parameters").''.$langs->trans("Value").''.$langs->trans("Parameters").''.$langs->trans("Value").'
'; +/*print '
'; print $langs->trans('TakeposNumpadUsePaymentIcon'); print ''; print ajax_constantonoff("TAKEPOS_NUMPAD_USE_PAYMENT_ICON", array(), $conf->entity, 0, 0, 1, 0); print "
'; diff --git a/htdocs/takepos/css/pos.css.php b/htdocs/takepos/css/pos.css.php index 416980633ca..6cd6073eb48 100644 --- a/htdocs/takepos/css/pos.css.php +++ b/htdocs/takepos/css/pos.css.php @@ -125,6 +125,10 @@ button.calcbutton2 { border-radius: 3px; } +button.calcbutton2 .iconwithlabel { + padding-bottom: 10px; +} + button.calcbutton3 { display: inline-block; position: relative; @@ -463,7 +467,7 @@ div.description_content { .header{ margin: 0 auto; width: 100%; - height: 50px; + height: 52px; background: rgb(60,70,100); } diff --git a/htdocs/takepos/floors.php b/htdocs/takepos/floors.php index 9e6f9d2a448..72f25a86ce4 100644 --- a/htdocs/takepos/floors.php +++ b/htdocs/takepos/floors.php @@ -64,8 +64,8 @@ if ($action == "getTables") $rows = array(); while ($row = $db->fetch_array($resql)) { $invoice = new Facture($db); - $result=$invoice->fetch('', '(PROV-POS'.$_SESSION['takeposterminal'].'-'.$row['rowid'].')'); - if ($result>0) $row['occupied']="red"; + $result = $invoice->fetch('', '(PROV-POS'.$_SESSION['takeposterminal'].'-'.$row['rowid'].')'); + if ($result > 0) $row['occupied'] = "red"; $rows[] = $row; } echo json_encode($rows); diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php index f76f46fa579..a2293786924 100644 --- a/htdocs/takepos/index.php +++ b/htdocs/takepos/index.php @@ -813,7 +813,9 @@ if (empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) { multicurrency->enabled)) { - print ''.$langs->trans("Currency").''; + print ''; + print ''.$langs->trans("Currency").''; + print ''; } ?> @@ -830,7 +832,7 @@ if (empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) { dol_use_jmobile)) { ?> - +   '; + if ($_SESSION["basiclayout"] == 1) { + $htmlforlines .= '  '; + } if ($_SESSION["basiclayout"] != 1) { $moreinfo = ''; @@ -1315,32 +1328,40 @@ if ($placeid > 0) $moreinfo .= '
'.$langs->transcountry("TotalLT2", $mysoc->country_code).': '.price($line->total_localtax2); $moreinfo .= '
'.$langs->transcountry("TotalTTC", $mysoc->country_code).': '.price($line->total_ttc); //$moreinfo .= $langs->trans("TotalHT").': '.$line->total_ht; - if ($line->date_start || $line->date_end) $htmlforlines .= '
'.get_date_range($line->date_start, $line->date_end, $format).'
'; + if ($line->date_start || $line->date_end) $htmlforlines .= '
'.get_date_range($line->date_start, $line->date_end).'
'; $htmlforlines .= '
'.vatrate($line->remise_percent, true).''; if (!empty($conf->stock->enabled) && !empty($user->rights->stock->mouvement->lire)) { $constantforkey = 'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal"]; - $sql = "SELECT e.rowid, e.ref, e.lieu, e.fk_parent, e.statut, ps.reel, ps.rowid as product_stock_id, p.pmp"; - $sql .= " FROM ".MAIN_DB_PREFIX."entrepot as e,"; - $sql .= " ".MAIN_DB_PREFIX."product_stock as ps"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = ps.fk_product"; - $sql .= " WHERE ps.reel != 0"; - $sql .= " AND ps.fk_entrepot = ".$conf->global->$constantforkey; - $sql .= " AND e.entity IN (".getEntity('stock').")"; - $sql .= " AND ps.fk_product = ".$line->fk_product; - $resql = $db->query($sql); - if ($resql) { - $obj = $db->fetch_object($resql); - $stock_real = price2num($obj->reel, 'MS'); + if (!empty($conf->global->$constantforkey)) { + $sql = "SELECT e.rowid, e.ref, e.lieu, e.fk_parent, e.statut, ps.reel, ps.rowid as product_stock_id, p.pmp"; + $sql .= " FROM ".MAIN_DB_PREFIX."entrepot as e,"; + $sql .= " ".MAIN_DB_PREFIX."product_stock as ps"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = ps.fk_product"; + $sql .= " WHERE ps.reel != 0"; + $sql .= " AND ps.fk_entrepot = ".$conf->global->$constantforkey; + $sql .= " AND e.entity IN (".getEntity('stock').")"; + $sql .= " AND ps.fk_product = ".$line->fk_product; + $resql = $db->query($sql); + if ($resql) { + $obj = $db->fetch_object($resql); + $stock_real = price2num($obj->reel, 'MS'); + $htmlforlines .= $line->qty; + if ($line->qty && $line->qty > $stock_real) $htmlforlines .= ''; + $htmlforlines .= ' ('.$langs->trans("Stock").' '.$stock_real.')'; + if ($line->qty && $line->qty > $stock_real) $htmlforlines .= ""; + } else { + dol_print_error($db); + } + } else { $htmlforlines .= $line->qty; - if ($line->qty && $line->qty > $stock_real) $htmlforlines .= ''; - $htmlforlines .= ' ('.$langs->trans("Stock").' '.$stock_real.')'; - if ($line->qty && $line->qty > $stock_real) $htmlforlines .= ""; } + } else { + $htmlforlines .= $line->qty; } - else $htmlforlines .= $line->qty; + $htmlforlines .= ''; $htmlforlines .= price($line->total_ttc, 1, '', 1, -1, -1, $conf->currency); diff --git a/htdocs/takepos/pay.php b/htdocs/takepos/pay.php index b0e745e2211..c1683073371 100644 --- a/htdocs/takepos/pay.php +++ b/htdocs/takepos/pay.php @@ -192,8 +192,14 @@ else print "var received=0;"; } console.log("We click on the payment mode to pay amount = "+amountpayed); parent.$("#poslines").load("invoice.php?place=&action=valid&pay="+payment+"&amount="+amountpayed+"&excess="+excess+"&invoiceid="+invoiceid+"&accountid="+accountid, function() { - if (amountpayed > || amountpayed == || amountpayed==0 ) parent.$.colorbox.close(); - else location.reload(); + if (amountpayed > || amountpayed == || amountpayed==0 ) { + console.log("Close popup"); + parent.$.colorbox.close(); + } + else { + console.log("Amount is not comple, so we do NOT close popup and reload it."); + location.reload(); + } }); } @@ -288,16 +294,16 @@ print ''; + print ''; } else { print ''; } @@ -311,16 +317,16 @@ print ''; + print ''; } else { $button = array_pop($action_buttons); print ''; @@ -335,16 +341,16 @@ print ''; + print ''; } else { $button = array_pop($action_buttons); print ''; diff --git a/htdocs/takepos/reduction.php b/htdocs/takepos/reduction.php index fa458d96318..dd808d9a19d 100644 --- a/htdocs/takepos/reduction.php +++ b/htdocs/takepos/reduction.php @@ -74,9 +74,9 @@ top_htmlhead($head, '', 0, 0, $arrayofjs, $arrayofcss); $langs->loadLangs(array('main', 'bills', 'cashdesk')); -if (!empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) { +if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || !empty($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON)) { $htmlReductionPercent = ''; - $htmlReductionAmount = ''; + $htmlReductionAmount = '
'.$langs->trans('Amount'); } else { $htmlReductionPercent = $langs->trans('ReductionShort').'
%'; $htmlReductionAmount = $langs->trans('ReductionShort').'
'.$langs->trans('Amount'); diff --git a/htdocs/theme/common/flags/unknown.png b/htdocs/theme/common/flags/unknown.png new file mode 100644 index 00000000000..08efc7b264d Binary files /dev/null and b/htdocs/theme/common/flags/unknown.png differ diff --git a/htdocs/theme/eldy/badges.inc.php b/htdocs/theme/eldy/badges.inc.php index 36296bb0b8a..86f5971891e 100644 --- a/htdocs/theme/eldy/badges.inc.php +++ b/htdocs/theme/eldy/badges.inc.php @@ -59,6 +59,13 @@ a.badge:focus, a.badge:hover { color: #fff; } +span.badgeneutral { + padding: 2px 7px 2px 7px; + background-color: #e4e4e4; + color: #666; + border-radius: 10px; +} + /* PRIMARY */ .badge-primary{ diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 1cba4c96dd6..3a849c33b3a 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -108,6 +108,7 @@ body { margin-bottom: 0; margin-right: 0; margin-left: 0; + font-weight: 400; trans("DIRECTION").";\n"; ?> } @@ -366,6 +367,10 @@ input.pageplusone { padding-top: 4px; } +.saturatemedium { + filter: saturate(0.8); +} + .optionblue { color: var(--colortextlink); } @@ -1031,27 +1036,34 @@ select.flat.selectlimit { .tablelistofcalendars { margin-top: 25px !important; } + +/* Styles for amount on card */ +table.paymenttable td.amountpaymentcomplete, table.paymenttable td.amountremaintopay { + padding-top: 0px; + padding-bottom: 0px; +} .amountalreadypaid { } .amountpaymentcomplete { color: var(--amountpaymentcomplete); font-weight: bold; - font-size: 1.2em; + font-size: 1.7em; } .amountremaintopay { color: var(--amountremaintopaycolor); font-weight: bold; - font-size: 1.2em; + font-size: 1.7em; } .amountremaintopayback { color: var(--amountremaintopaybackcolor); font-weight: bold; - font-size: 1.2em; + font-size: 1.7em; } .amountpaymentneutral { font-weight: bold; - font-size: 1.2em; + font-size: 1.7em; } + .onlinepaymentbody .amountpaymentcomplete { background-color: var(--amountpaymentcomplete); color: #fff; @@ -1953,8 +1965,8 @@ div.statusrefbis { } img.photoref, div.photoref { /* border: 1px solid #DDD; */ - -webkit-box-shadow: 1px 1px 5px rgba(0, 0, 0, 0.2); - box-shadow: 1px 1px 5px rgba(0, 0, 0, 0.2); + -webkit-box-shadow: 1px 1px 8px rgba(0, 0, 0, 0.2); + box-shadow: 1px 1px 8px rgba(0, 0, 0, 0.2); padding: 4px; height: 80px; width: 80px; @@ -2066,7 +2078,7 @@ a.tmenudisabled:link, a.tmenudisabled:visited, a.tmenudisabled:hover, a.tmenudis } a.tmenu:link, a.tmenu:visited, a.tmenu:hover, a.tmenu:active { - padding: 0px 4px 0px 4px; + padding: 0px 2px 0px 2px; white-space: nowrap; color: var(--colortextbackhmenu); text-decoration: none; @@ -2161,6 +2173,8 @@ div.menu_titre { { padding-: 2px; padding-: 2px; + font-family: Roboto,; + font-weight: 400; } div.mainmenu { @@ -2516,11 +2530,13 @@ img.login, img.printer, img.entity { font-weight: bold; } .userimg.atoplogin img.userphoto, .userimgatoplogin img.userphoto { /* size for user photo in login bar */ - width: px; - height: px; + width: px; + height: px; border-radius: 50%; background-size: contain; background-size: contain; + border: 1px solid; + border-color: rgba(255, 255, 255, 0.2); } img.userphoto { /* size for user photo in lists */ border-radius: 0.72em; @@ -2537,7 +2553,7 @@ img.userphotosmall { /* size for user photo in lists */ vertical-align: middle; background-color: #FFF; } -img.userphoto[alt="Gravatar avatar"] { +img.userphoto[alt="Gravatar avatar"], img.photouserphoto.dropdown-user-image[alt="Gravatar avatar"] { background: #fff; } .span-icon-user { @@ -2931,7 +2947,7 @@ a.tab:link, a.tab:visited, a.tab:hover, a.tab#active { border-right: 1px solid #CCC !important; border-left: 1px solid #CCC !important; - border-top: px solid var(--colorbackhmenu1) !important; + border-top: 3px solid var(--colorbackhmenu1) !important; } a.tab:hover { @@ -3011,6 +3027,10 @@ tr.nocellnopadd td.nobordernopadding, tr.nocellnopadd td.nocellnopadd .unsetcolor { color: unset !important; } + +.smallpaddingimp { + padding: 4px !important; +} .nopaddingleft { padding-: 0px; } @@ -4159,7 +4179,7 @@ div.titre { text-decoration: none; padding-top: 5px; padding-bottom: 5px; - /* text-transform: capitalize; */ + font-weight: 400; } div.fiche > table.table-fiche-title:first-of-type div { color: var(--colortexttitlenotab); @@ -5326,6 +5346,10 @@ div.dataTables_length select { /* Select2 */ /* ============================================================================== */ +span.select2-selection--single.flat[aria-disabled="true"] span.select2-selection__rendered { + opacity: 0.5; +} + span#select2-taskid-container[title^='--'] { opacity: 0.3; } diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 7a86c52ff1e..319789b6fde 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -81,7 +81,7 @@ $theme = 'eldy'; // Value of theme if (!empty($conf->global->MAIN_OVERWRITE_THEME_RES)) { $path = '/'.$conf->global->MAIN_OVERWRITE_THEME_RES; $theme = $conf->global->MAIN_OVERWRITE_THEME_RES; } // Define image path files and other constants -$fontlist = 'roboto,arial,tahoma,verdana,helvetica'; //$fontlist='helvetica, verdana, arial, sans-serif'; +$fontlist = 'arial,tahoma,verdana,helvetica'; //$fontlist='helvetica, verdana, arial, sans-serif'; //$fontlist='"open sans", "Helvetica Neue", Helvetica, Arial, sans-serif;'; $img_head = ''; $img_button = dol_buildpath($path.'/theme/'.$theme.'/img/button_bg.png', 1); @@ -199,7 +199,7 @@ if ($conf->browser->layout == 'phone') $nbtopmenuentries = max($nbtopmenuentries $minwidthtmenu = 66; /* minimum width for one top menu entry */ -$heightmenu = 48; /* height of top menu, part with image */ +$heightmenu = 50; /* height of top menu, part with image */ $heightmenu2 = 49; /* height of top menu, part with login */ $disableimages = 0; $maxwidthloginblock = 180; diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 29d01b55bb1..8d0721e8aad 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -499,6 +499,10 @@ input.pageplusone { padding-top: 4px; } +.saturatemedium { + filter: saturate(0.8); +} + .optionblue { color: rgb(); } @@ -2994,6 +2998,10 @@ tr.nocellnopadd td.nobordernopadding, tr.nocellnopadd td.nocellnopadd .unsetcolor { color: unset !important; } + +.smallpaddingimp { + padding: 4px !important; +} .nopaddingleft { padding-: 0px; } diff --git a/htdocs/ticket/agenda.php b/htdocs/ticket/agenda.php index b14e5b718ba..be68e1f68ee 100644 --- a/htdocs/ticket/agenda.php +++ b/htdocs/ticket/agenda.php @@ -41,8 +41,8 @@ $socid = GETPOST('socid', 'int'); $action = GETPOST('action', 'aZ09'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", "alpha"); -$sortorder = GETPOST("sortorder", 'alpha'); +$sortfield = GETPOST("sortfield", "aZ09comma"); +$sortorder = GETPOST("sortorder", 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $page = is_numeric($page) ? $page : 0; $page = $page == -1 ? 0 : $page; diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index a7bb7f0e955..c67476f8c00 100644 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -194,7 +194,8 @@ if (empty($reshook)) { $type_contact = GETPOST("type", 'alpha'); if ($contactid > 0 && $type_contact) { - $result = $object->add_contact($contactid, GETPOST("type"), 'external'); + $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type')); + $result = $object->add_contact($contactid, $typeid, 'external'); } // altairis: link ticket to project diff --git a/htdocs/ticket/class/api_tickets.class.php b/htdocs/ticket/class/api_tickets.class.php index 5ba67060552..4a0bcbe7b92 100644 --- a/htdocs/ticket/class/api_tickets.class.php +++ b/htdocs/ticket/class/api_tickets.class.php @@ -29,544 +29,544 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/ticket.lib.php'; */ class Tickets extends DolibarrApi { - /** - * @var array $FIELDS Mandatory fields, checked when create and update object - */ - public static $FIELDS = array( - 'subject', - 'message' - ); + /** + * @var array $FIELDS Mandatory fields, checked when create and update object + */ + public static $FIELDS = array( + 'subject', + 'message' + ); - /** - * @var array $FIELDS_MESSAGES Mandatory fields, checked when create and update object - */ - public static $FIELDS_MESSAGES = array( - 'track_id', - 'message' - ); + /** + * @var array $FIELDS_MESSAGES Mandatory fields, checked when create and update object + */ + public static $FIELDS_MESSAGES = array( + 'track_id', + 'message' + ); - /** - * @var Ticket $ticket {@type Ticket} - */ - public $ticket; + /** + * @var Ticket $ticket {@type Ticket} + */ + public $ticket; - /** - * Constructor - */ - public function __construct() - { - global $db; - $this->db = $db; - $this->ticket = new Ticket($this->db); - } + /** + * Constructor + */ + public function __construct() + { + global $db; + $this->db = $db; + $this->ticket = new Ticket($this->db); + } - /** - * Get properties of a Ticket object. - * - * Return an array with ticket informations - * - * @param int $id ID of ticket - * @return array|mixed Data without useless information - * - * @throws RestException 401 - * @throws RestException 403 - * @throws RestException 404 - */ - public function get($id) - { - return $this->getCommon($id, '', ''); - } + /** + * Get properties of a Ticket object. + * + * Return an array with ticket informations + * + * @param int $id ID of ticket + * @return array|mixed Data without useless information + * + * @throws RestException 401 + * @throws RestException 403 + * @throws RestException 404 + */ + public function get($id) + { + return $this->getCommon($id, '', ''); + } - /** - * Get properties of a Ticket object from track id - * - * Return an array with ticket informations - * - * @param string $track_id Tracking ID of ticket - * @return array|mixed Data without useless information - * - * @url GET track_id/{track_id} - * - * @throws RestException 401 - * @throws RestException 403 - * @throws RestException 404 - */ - public function getByTrackId($track_id) - { - return $this->getCommon(0, $track_id, ''); - } + /** + * Get properties of a Ticket object from track id + * + * Return an array with ticket informations + * + * @param string $track_id Tracking ID of ticket + * @return array|mixed Data without useless information + * + * @url GET track_id/{track_id} + * + * @throws RestException 401 + * @throws RestException 403 + * @throws RestException 404 + */ + public function getByTrackId($track_id) + { + return $this->getCommon(0, $track_id, ''); + } - /** - * Get properties of a Ticket object from ref - * - * Return an array with ticket informations - * - * @param string $ref Reference for ticket - * @return array|mixed Data without useless information - * - * @url GET ref/{ref} - * - * @throws RestException 401 - * @throws RestException 403 - * @throws RestException 404 - */ - public function getByRef($ref) - { - try { - return $this->getCommon(0, '', $ref); - } catch (Exception $e) - { - throw $e; - } - } + /** + * Get properties of a Ticket object from ref + * + * Return an array with ticket informations + * + * @param string $ref Reference for ticket + * @return array|mixed Data without useless information + * + * @url GET ref/{ref} + * + * @throws RestException 401 + * @throws RestException 403 + * @throws RestException 404 + */ + public function getByRef($ref) + { + try { + return $this->getCommon(0, '', $ref); + } catch (Exception $e) + { + throw $e; + } + } - /** - * Get properties of a Ticket object - * Return an array with ticket informations - * - * @param int $id ID of ticket - * @param string $track_id Tracking ID of ticket - * @param string $ref Reference for ticket - * @return array|mixed Data without useless information - */ - private function getCommon($id = 0, $track_id = '', $ref = '') - { - if (!DolibarrApiAccess::$user->rights->ticket->read) { - throw new RestException(403); - } + /** + * Get properties of a Ticket object + * Return an array with ticket informations + * + * @param int $id ID of ticket + * @param string $track_id Tracking ID of ticket + * @param string $ref Reference for ticket + * @return array|mixed Data without useless information + */ + private function getCommon($id = 0, $track_id = '', $ref = '') + { + if (!DolibarrApiAccess::$user->rights->ticket->read) { + throw new RestException(403); + } - // Check parameters - if (($id < 0) && !$track_id && !$ref) { - throw new RestException(401, 'Wrong parameters'); - } + // Check parameters + if (($id < 0) && !$track_id && !$ref) { + throw new RestException(401, 'Wrong parameters'); + } if ($id == 0) { $result = $this->ticket->initAsSpecimen(); } else { $result = $this->ticket->fetch($id, $ref, $track_id); } - if (!$result) { - throw new RestException(404, 'Ticket not found'); - } + if (!$result) { + throw new RestException(404, 'Ticket not found'); + } - // String for user assigned - if ($this->ticket->fk_user_assign > 0) { - $userStatic = new User($this->db); - $userStatic->fetch($this->ticket->fk_user_assign); - $this->ticket->fk_user_assign_string = $userStatic->firstname.' '.$userStatic->lastname; - } + // String for user assigned + if ($this->ticket->fk_user_assign > 0) { + $userStatic = new User($this->db); + $userStatic->fetch($this->ticket->fk_user_assign); + $this->ticket->fk_user_assign_string = $userStatic->firstname.' '.$userStatic->lastname; + } - // Messages of ticket - $messages = array(); - $this->ticket->loadCacheMsgsTicket(); - if (is_array($this->ticket->cache_msgs_ticket) && count($this->ticket->cache_msgs_ticket) > 0) { - $num = count($this->ticket->cache_msgs_ticket); - $i = 0; - while ($i < $num) { - if ($this->ticket->cache_msgs_ticket[$i]['fk_user_author'] > 0) { - $user_action = new User($this->db); - $user_action->fetch($this->ticket->cache_msgs_ticket[$i]['fk_user_author']); - } + // Messages of ticket + $messages = array(); + $this->ticket->loadCacheMsgsTicket(); + if (is_array($this->ticket->cache_msgs_ticket) && count($this->ticket->cache_msgs_ticket) > 0) { + $num = count($this->ticket->cache_msgs_ticket); + $i = 0; + while ($i < $num) { + if ($this->ticket->cache_msgs_ticket[$i]['fk_user_author'] > 0) { + $user_action = new User($this->db); + $user_action->fetch($this->ticket->cache_msgs_ticket[$i]['fk_user_author']); + } - // Now define messages - $messages[] = array( - 'id' => $this->ticket->cache_msgs_ticket[$i]['id'], - 'fk_user_action' => $this->ticket->cache_msgs_ticket[$i]['fk_user_author'], - 'fk_user_action_socid' => $user_action->socid, - 'fk_user_action_string' => dolGetFirstLastname($user_action->firstname, $user_action->lastname), - 'message' => $this->ticket->cache_msgs_ticket[$i]['message'], - 'datec' => $this->ticket->cache_msgs_ticket[$i]['datec'], - 'private' => $this->ticket->cache_msgs_ticket[$i]['private'] - ); - $i++; - } - $this->ticket->messages = $messages; - } + // Now define messages + $messages[] = array( + 'id' => $this->ticket->cache_msgs_ticket[$i]['id'], + 'fk_user_action' => $this->ticket->cache_msgs_ticket[$i]['fk_user_author'], + 'fk_user_action_socid' => $user_action->socid, + 'fk_user_action_string' => dolGetFirstLastname($user_action->firstname, $user_action->lastname), + 'message' => $this->ticket->cache_msgs_ticket[$i]['message'], + 'datec' => $this->ticket->cache_msgs_ticket[$i]['datec'], + 'private' => $this->ticket->cache_msgs_ticket[$i]['private'] + ); + $i++; + } + $this->ticket->messages = $messages; + } - // History - $history = array(); - $this->ticket->loadCacheLogsTicket(); - if (is_array($this->ticket->cache_logs_ticket) && count($this->ticket->cache_logs_ticket) > 0) { - $num = count($this->ticket->cache_logs_ticket); - $i = 0; - while ($i < $num) { - if ($this->ticket->cache_logs_ticket[$i]['fk_user_create'] > 0) { - $user_action = new User($this->db); - $user_action->fetch($this->ticket->cache_logs_ticket[$i]['fk_user_create']); - } + // History + $history = array(); + $this->ticket->loadCacheLogsTicket(); + if (is_array($this->ticket->cache_logs_ticket) && count($this->ticket->cache_logs_ticket) > 0) { + $num = count($this->ticket->cache_logs_ticket); + $i = 0; + while ($i < $num) { + if ($this->ticket->cache_logs_ticket[$i]['fk_user_create'] > 0) { + $user_action = new User($this->db); + $user_action->fetch($this->ticket->cache_logs_ticket[$i]['fk_user_create']); + } - // Now define messages - $history[] = array( - 'id' => $this->ticket->cache_logs_ticket[$i]['id'], - 'fk_user_author' => $this->ticket->cache_msgs_ticket[$i]['fk_user_author'], - 'fk_user_action' => $this->ticket->cache_logs_ticket[$i]['fk_user_create'], - 'fk_user_action_string' => dolGetFirstLastname($user_action->firstname, $user_action->lastname), - 'message' => $this->ticket->cache_logs_ticket[$i]['message'], - 'datec' => $this->ticket->cache_logs_ticket[$i]['datec'], - ); - $i++; - } - $this->ticket->history = $history; - } + // Now define messages + $history[] = array( + 'id' => $this->ticket->cache_logs_ticket[$i]['id'], + 'fk_user_author' => $this->ticket->cache_msgs_ticket[$i]['fk_user_author'], + 'fk_user_action' => $this->ticket->cache_logs_ticket[$i]['fk_user_create'], + 'fk_user_action_string' => dolGetFirstLastname($user_action->firstname, $user_action->lastname), + 'message' => $this->ticket->cache_logs_ticket[$i]['message'], + 'datec' => $this->ticket->cache_logs_ticket[$i]['datec'], + ); + $i++; + } + $this->ticket->history = $history; + } - if (!DolibarrApi::_checkAccessToResource('ticket', $this->ticket->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } - return $this->_cleanObjectDatas($this->ticket); - } + if (!DolibarrApi::_checkAccessToResource('ticket', $this->ticket->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + return $this->_cleanObjectDatas($this->ticket); + } - /** - * List tickets - * - * Get a list of tickets - * - * @param int $socid Filter list with thirdparty ID - * @param string $sortfield Sort field - * @param string $sortorder Sort order - * @param int $limit Limit for list - * @param int $page Page number - * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101') and (t.fk_statut:=:1)" - * - * @return array Array of ticket objects - * - */ - public function index($socid = 0, $sortfield = "t.rowid", $sortorder = "ASC", $limit = 100, $page = 0, $sqlfilters = '') - { - global $db, $conf; + /** + * List tickets + * + * Get a list of tickets + * + * @param int $socid Filter list with thirdparty ID + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param int $limit Limit for list + * @param int $page Page number + * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101') and (t.fk_statut:=:1)" + * + * @return array Array of ticket objects + * + */ + public function index($socid = 0, $sortfield = "t.rowid", $sortorder = "ASC", $limit = 100, $page = 0, $sqlfilters = '') + { + global $db, $conf; - $obj_ret = array(); + $obj_ret = array(); - if (!$socid && DolibarrApiAccess::$user->socid) { - $socid = DolibarrApiAccess::$user->socid; - } + if (!$socid && DolibarrApiAccess::$user->socid) { + $socid = DolibarrApiAccess::$user->socid; + } - // If the internal user must only see his customers, force searching by him - if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) { - $search_sale = DolibarrApiAccess::$user->id; - } + // If the internal user must only see his customers, force searching by him + if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) { + $search_sale = DolibarrApiAccess::$user->id; + } - $sql = "SELECT t.rowid"; - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) { - $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) - } - $sql .= " FROM ".MAIN_DB_PREFIX."ticket as t"; + $sql = "SELECT t.rowid"; + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) { + $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) + } + $sql .= " FROM ".MAIN_DB_PREFIX."ticket as t"; - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) { - $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale - } + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale + } - $sql .= ' WHERE t.entity IN ('.getEntity('ticket', 1).')'; - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) { - $sql .= " AND t.fk_soc = sc.fk_soc"; - } - if ($socid > 0) { - $sql .= " AND t.fk_soc = ".$socid; - } - if ($search_sale > 0) { - $sql .= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale - } + $sql .= ' WHERE t.entity IN ('.getEntity('ticket', 1).')'; + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) { + $sql .= " AND t.fk_soc = sc.fk_soc"; + } + if ($socid > 0) { + $sql .= " AND t.fk_soc = ".$socid; + } + if ($search_sale > 0) { + $sql .= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale + } - // Insert sale filter - if ($search_sale > 0) { - $sql .= " AND sc.fk_user = ".$search_sale; - } - // Add sql filters - if ($sqlfilters) { - if (!DolibarrApi::_checkFilters($sqlfilters)) { - throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); - } - $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; - $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; - } + // Insert sale filter + if ($search_sale > 0) { + $sql .= " AND sc.fk_user = ".$search_sale; + } + // Add sql filters + if ($sqlfilters) { + if (!DolibarrApi::_checkFilters($sqlfilters)) { + throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); + } + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + } - $sql .= $this->db->order($sortfield, $sortorder); + $sql .= $this->db->order($sortfield, $sortorder); - if ($limit) { - if ($page < 0) { - $page = 0; - } - $offset = $limit * $page; + if ($limit) { + if ($page < 0) { + $page = 0; + } + $offset = $limit * $page; - $sql .= $this->db->plimit($limit, $offset); - } + $sql .= $this->db->plimit($limit, $offset); + } - $result = $this->db->query($sql); - if ($result) { - $num = $this->db->num_rows($result); - $i = 0; - while ($i < $num) { - $obj = $this->db->fetch_object($result); - $ticket_static = new Ticket($this->db); - if ($ticket_static->fetch($obj->rowid)) { - if ($ticket_static->fk_user_assign > 0) { - $userStatic = new User($this->db); - $userStatic->fetch($ticket_static->fk_user_assign); - $ticket_static->fk_user_assign_string = $userStatic->firstname.' '.$userStatic->lastname; - } - $obj_ret[] = $this->_cleanObjectDatas($ticket_static); - } - $i++; - } - } else { - throw new RestException(503, 'Error when retrieve ticket list'); - } - if (!count($obj_ret)) { - throw new RestException(404, 'No ticket found'); - } - return $obj_ret; - } + $result = $this->db->query($sql); + if ($result) { + $num = $this->db->num_rows($result); + $i = 0; + while ($i < $num) { + $obj = $this->db->fetch_object($result); + $ticket_static = new Ticket($this->db); + if ($ticket_static->fetch($obj->rowid)) { + if ($ticket_static->fk_user_assign > 0) { + $userStatic = new User($this->db); + $userStatic->fetch($ticket_static->fk_user_assign); + $ticket_static->fk_user_assign_string = $userStatic->firstname.' '.$userStatic->lastname; + } + $obj_ret[] = $this->_cleanObjectDatas($ticket_static); + } + $i++; + } + } else { + throw new RestException(503, 'Error when retrieve ticket list'); + } + if (!count($obj_ret)) { + throw new RestException(404, 'No ticket found'); + } + return $obj_ret; + } - /** - * Create ticket object - * - * @param array $request_data Request datas - * @return int ID of ticket - */ - public function post($request_data = null) - { - $ticketstatic = new Ticket($this->db); - if (!DolibarrApiAccess::$user->rights->ticket->write) { - throw new RestException(401); - } - // Check mandatory fields - $result = $this->_validate($request_data); + /** + * Create ticket object + * + * @param array $request_data Request datas + * @return int ID of ticket + */ + public function post($request_data = null) + { + $ticketstatic = new Ticket($this->db); + if (!DolibarrApiAccess::$user->rights->ticket->write) { + throw new RestException(401); + } + // Check mandatory fields + $result = $this->_validate($request_data); - foreach ($request_data as $field => $value) { - $this->ticket->$field = $value; - } - if (empty($this->ticket->ref)) { - $this->ticket->ref = $ticketstatic->getDefaultRef(); - } - if (empty($this->ticket->track_id)) { - $this->ticket->track_id = generate_random_id(16); - } + foreach ($request_data as $field => $value) { + $this->ticket->$field = $value; + } + if (empty($this->ticket->ref)) { + $this->ticket->ref = $ticketstatic->getDefaultRef(); + } + if (empty($this->ticket->track_id)) { + $this->ticket->track_id = generate_random_id(16); + } - if ($this->ticket->create(DolibarrApiAccess::$user) < 0) { - throw new RestException(500, "Error creating ticket", array_merge(array($this->ticket->error), $this->ticket->errors)); - } + if ($this->ticket->create(DolibarrApiAccess::$user) < 0) { + throw new RestException(500, "Error creating ticket", array_merge(array($this->ticket->error), $this->ticket->errors)); + } - return $this->ticket->id; - } + return $this->ticket->id; + } - /** - * Create ticket object - * - * @param array $request_data Request datas - * @return int ID of ticket - * - */ - public function postNewMessage($request_data = null) - { - $ticketstatic = new Ticket($this->db); - if (!DolibarrApiAccess::$user->rights->ticket->write) { - throw new RestException(401); - } - // Check mandatory fields - $result = $this->_validateMessage($request_data); + /** + * Create ticket object + * + * @param array $request_data Request datas + * @return int ID of ticket + * + */ + public function postNewMessage($request_data = null) + { + $ticketstatic = new Ticket($this->db); + if (!DolibarrApiAccess::$user->rights->ticket->write) { + throw new RestException(401); + } + // Check mandatory fields + $result = $this->_validateMessage($request_data); - foreach ($request_data as $field => $value) { - $this->ticket->$field = $value; - } - $ticketMessageText = $this->ticket->message; - $result = $this->ticket->fetch('', '', $this->ticket->track_id); - if (!$result) { - throw new RestException(404, 'Ticket not found'); - } - $this->ticket->message = $ticketMessageText; - if (!$this->ticket->createTicketMessage(DolibarrApiAccess::$user)) { - throw new RestException(500); - } - return $this->ticket->id; - } + foreach ($request_data as $field => $value) { + $this->ticket->$field = $value; + } + $ticketMessageText = $this->ticket->message; + $result = $this->ticket->fetch('', '', $this->ticket->track_id); + if (!$result) { + throw new RestException(404, 'Ticket not found'); + } + $this->ticket->message = $ticketMessageText; + if (!$this->ticket->createTicketMessage(DolibarrApiAccess::$user)) { + throw new RestException(500); + } + return $this->ticket->id; + } - /** - * Update ticket - * - * @param int $id Id of ticket to update - * @param array $request_data Datas - * @return int - * - */ - public function put($id, $request_data = null) - { - if (!DolibarrApiAccess::$user->rights->ticket->write) { - throw new RestException(401); - } + /** + * Update ticket + * + * @param int $id Id of ticket to update + * @param array $request_data Datas + * @return int + * + */ + public function put($id, $request_data = null) + { + if (!DolibarrApiAccess::$user->rights->ticket->write) { + throw new RestException(401); + } - $result = $this->ticket->fetch($id); - if (!$result) { - throw new RestException(404, 'Ticket not found'); - } + $result = $this->ticket->fetch($id); + if (!$result) { + throw new RestException(404, 'Ticket not found'); + } - if (!DolibarrApi::_checkAccessToResource('ticket', $this->ticket->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if (!DolibarrApi::_checkAccessToResource('ticket', $this->ticket->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - foreach ($request_data as $field => $value) { - $this->ticket->$field = $value; - } + foreach ($request_data as $field => $value) { + $this->ticket->$field = $value; + } - if ($this->ticket->update($id, DolibarrApiAccess::$user)) { - return $this->get($id); - } + if ($this->ticket->update($id, DolibarrApiAccess::$user)) { + return $this->get($id); + } - return false; - } + return false; + } - /** - * Delete ticket - * - * @param int $id Ticket ID - * @return array - * - */ - public function delete($id) - { - if (!DolibarrApiAccess::$user->rights->ticket->delete) { - throw new RestException(401); - } - $result = $this->ticket->fetch($id); - if (!$result) { - throw new RestException(404, 'Ticket not found'); - } + /** + * Delete ticket + * + * @param int $id Ticket ID + * @return array + * + */ + public function delete($id) + { + if (!DolibarrApiAccess::$user->rights->ticket->delete) { + throw new RestException(401); + } + $result = $this->ticket->fetch($id); + if (!$result) { + throw new RestException(404, 'Ticket not found'); + } - if (!DolibarrApi::_checkAccessToResource('ticket', $this->ticket->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if (!DolibarrApi::_checkAccessToResource('ticket', $this->ticket->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - if (!$this->ticket->delete($id)) { - throw new RestException(500); - } + if (!$this->ticket->delete($id)) { + throw new RestException(500); + } - return array( - 'success' => array( - 'code' => 200, - 'message' => 'Ticket deleted' - ) - ); - } + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Ticket deleted' + ) + ); + } - /** - * Validate fields before create or update object - * - * @param array $data Data to validate - * @return array - * - * @throws RestException - */ - private function _validate($data) - { - $ticket = array(); - foreach (Tickets::$FIELDS as $field) { - if (!isset($data[$field])) { - throw new RestException(400, "$field field missing"); - } - $ticket[$field] = $data[$field]; - } - return $ticket; - } + /** + * Validate fields before create or update object + * + * @param array $data Data to validate + * @return array + * + * @throws RestException + */ + private function _validate($data) + { + $ticket = array(); + foreach (Tickets::$FIELDS as $field) { + if (!isset($data[$field])) { + throw new RestException(400, "$field field missing"); + } + $ticket[$field] = $data[$field]; + } + return $ticket; + } - /** - * Validate fields before create or update object message - * - * @param array $data Data to validate - * @return array - * - * @throws RestException - */ - private function _validateMessage($data) - { - $ticket = array(); - foreach (Tickets::$FIELDS_MESSAGES as $field) { - if (!isset($data[$field])) { - throw new RestException(400, "$field field missing"); - } - $ticket[$field] = $data[$field]; - } - return $ticket; - } + /** + * Validate fields before create or update object message + * + * @param array $data Data to validate + * @return array + * + * @throws RestException + */ + private function _validateMessage($data) + { + $ticket = array(); + foreach (Tickets::$FIELDS_MESSAGES as $field) { + if (!isset($data[$field])) { + throw new RestException(400, "$field field missing"); + } + $ticket[$field] = $data[$field]; + } + return $ticket; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore - /** - * Clean sensible object datas - * - * @param Object $object Object to clean - * @return Object Object with cleaned properties - * - * @todo use an array for properties to clean - * - */ - protected function _cleanObjectDatas($object) - { - // phpcs:enable - $object = parent::_cleanObjectDatas($object); + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + /** + * Clean sensible object datas + * + * @param Object $object Object to clean + * @return Object Object with cleaned properties + * + * @todo use an array for properties to clean + * + */ + protected function _cleanObjectDatas($object) + { + // phpcs:enable + $object = parent::_cleanObjectDatas($object); - // Other attributes to clean - $attr2clean = array( - "contact", - "contact_id", - "ref_previous", - "ref_next", - "ref_ext", - "table_element_line", - "statut", - "country", - "country_id", - "country_code", - "barcode_type", - "barcode_type_code", - "barcode_type_label", - "barcode_type_coder", - "mode_reglement_id", - "cond_reglement_id", - "cond_reglement", - "fk_delivery_address", - "shipping_method_id", - "modelpdf", - "fk_account", - "note_public", - "note_private", - "note", - "total_ht", - "total_tva", - "total_localtax1", - "total_localtax2", - "total_ttc", - "fk_incoterms", - "label_incoterms", - "location_incoterms", - "name", - "lastname", - "firstname", - "civility_id", - "canvas", - "cache_msgs_ticket", - "cache_logs_ticket", - "cache_types_tickets", - "cache_category_tickets", - "regeximgext", - "statuts_short", - "statuts" - ); - foreach ($attr2clean as $toclean) { - unset($object->$toclean); - } + // Other attributes to clean + $attr2clean = array( + "contact", + "contact_id", + "ref_previous", + "ref_next", + "ref_ext", + "table_element_line", + "statut", + "country", + "country_id", + "country_code", + "barcode_type", + "barcode_type_code", + "barcode_type_label", + "barcode_type_coder", + "mode_reglement_id", + "cond_reglement_id", + "cond_reglement", + "fk_delivery_address", + "shipping_method_id", + "modelpdf", + "fk_account", + "note_public", + "note_private", + "note", + "total_ht", + "total_tva", + "total_localtax1", + "total_localtax2", + "total_ttc", + "fk_incoterms", + "label_incoterms", + "location_incoterms", + "name", + "lastname", + "firstname", + "civility_id", + "canvas", + "cache_msgs_ticket", + "cache_logs_ticket", + "cache_types_tickets", + "cache_category_tickets", + "regeximgext", + "statuts_short", + "statuts" + ); + foreach ($attr2clean as $toclean) { + unset($object->$toclean); + } - // If object has lines, remove $db property - if (isset($object->lines) && count($object->lines) > 0) { - $nboflines = count($object->lines); - for ($i = 0; $i < $nboflines; $i++) { - $this->_cleanObjectDatas($object->lines[$i]); - } - } + // If object has lines, remove $db property + if (isset($object->lines) && count($object->lines) > 0) { + $nboflines = count($object->lines); + for ($i = 0; $i < $nboflines; $i++) { + $this->_cleanObjectDatas($object->lines[$i]); + } + } - // If object has linked objects, remove $db property - if (isset($object->linkedObjects) && count($object->linkedObjects) > 0) { - foreach ($object->linkedObjects as $type_object => $linked_object) { - foreach ($linked_object as $object2clean) { - $this->_cleanObjectDatas($object2clean); - } - } - } - return $object; - } + // If object has linked objects, remove $db property + if (isset($object->linkedObjects) && count($object->linkedObjects) > 0) { + foreach ($object->linkedObjects as $type_object => $linked_object) { + foreach ($linked_object as $object2clean) { + $this->_cleanObjectDatas($object2clean); + } + } + } + return $object; + } } diff --git a/htdocs/ticket/contact.php b/htdocs/ticket/contact.php index dacac9f5225..13419cf795e 100644 --- a/htdocs/ticket/contact.php +++ b/htdocs/ticket/contact.php @@ -71,7 +71,8 @@ if ($action == 'addcontact' && $user->rights->ticket->write) { if ($result > 0 && ($id > 0 || (!empty($track_id)))) { $contactid = (GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int')); - $result = $object->add_contact($contactid, $type, $source); + $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type')); + $result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09')); } if ($result >= 0) { diff --git a/htdocs/ticket/list.php b/htdocs/ticket/list.php index bd28149627f..fc1cca1aa0f 100644 --- a/htdocs/ticket/list.php +++ b/htdocs/ticket/list.php @@ -112,7 +112,7 @@ foreach ($object->fields as $key => $val) if (!empty($val['visible'])) $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>$val['enabled'], 'position'=>$val['position']); } // Extra fields -include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_array_fields.tpl.php'; +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); @@ -316,7 +316,7 @@ if ($socid > 0) foreach ($search as $key => $val) { - if ($key == 'fk_statut' && !empty($search['fk_statut'])) + if ($key == 'fk_statut' && !empty($search['fk_statut'])) { $newarrayofstatus = array(); foreach ($search['fk_statut'] as $key2 => $val2) { @@ -636,9 +636,9 @@ foreach ($object->fields as $key => $val) $formTicket->selectSeveritiesTickets(dol_escape_htmltag($search[$key]), 'search_'.$key.'', '', 2, 1, 1, 0, ($val['css'] ? $val['css'] : 'maxwidth150')); print '
'; - print $form->select_dolusers($search[$key], 'search_'.$key, 1, null, 0, '', '', '0', 0, 0, '', 0, '', ($val['css'] ? $val['css'] : 'maxwidth150')); - print ''; + print $form->select_dolusers($search[$key], 'search_'.$key, 1, null, 0, '', '', '0', 0, 0, '', 0, '', ($val['css'] ? $val['css'] : 'maxwidth150')); + print '
'.$langs->trans("Status").''; $liststatus = $object->fields['fk_statut']['arrayofkeyval']; -print $form->selectarray('object_status', $liststatus, GETPOST('object_status', 'int'), -4, 0, 0, '', 1); +print $form->selectarray('object_status', $liststatus, GETPOST('object_status', 'intcomma'), -4, 0, 0, '', 1); print '
'.$langs->trans("Year").''; diff --git a/htdocs/user/class/api_users.class.php b/htdocs/user/class/api_users.class.php index 9a89ad8e81c..e68ecb8bc1d 100644 --- a/htdocs/user/class/api_users.class.php +++ b/htdocs/user/class/api_users.class.php @@ -246,12 +246,13 @@ class Users extends DolibarrApi * * @url GET /info * + * @param int $includepermissions Set this to 1 to have the array of permissions loaded (not done by default for performance purpose) * @return array|mixed Data without useless information * * @throws RestException 401 Insufficient rights * @throws RestException 404 User or group not found */ - public function getInfo() + public function getInfo($includepermissions = 0) { $apiUser = DolibarrApiAccess::$user; @@ -264,6 +265,10 @@ class Users extends DolibarrApi throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } + if ($includepermissions) { + $this->useraccount->getRights(); + } + $usergroup = new UserGroup($this->db); $userGroupList = $usergroup->listGroupsForUser($apiUser->id, false); if (!is_array($userGroupList)) { diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 41e1d55ea7c..3288571d2a7 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -342,8 +342,8 @@ class User extends CommonObject public $fields = array( 'rowid'=>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'), - 'lastname'=>array('type'=>'varchar(50)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>20, 'searchall'=>1, 'comment'=>'Reference of object'), - 'firstname'=>array('type'=>'varchar(50)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'), + 'lastname'=>array('type'=>'varchar(50)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>20, 'searchall'=>1), + 'firstname'=>array('type'=>'varchar(50)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1), ); @@ -412,6 +412,7 @@ class User extends CommonObject $sql .= " u.tms as datem,"; $sql .= " u.datelastlogin as datel,"; $sql .= " u.datepreviouslogin as datep,"; + $sql .= " u.datelastpassvalidation,"; $sql .= " u.datestartvalidity,"; $sql .= " u.dateendvalidity,"; $sql .= " u.photo as photo,"; diff --git a/htdocs/user/list.php b/htdocs/user/list.php index 257bcd4c6be..ef2ad8c1ed6 100644 --- a/htdocs/user/list.php +++ b/htdocs/user/list.php @@ -109,45 +109,32 @@ if (!empty($conf->api->enabled)) // Definition of fields for list $arrayfields = array( - 'u.login'=>array('label'=>$langs->trans("Login"), 'checked'=>1), - 'u.lastname'=>array('label'=>$langs->trans("Lastname"), 'checked'=>1), - 'u.firstname'=>array('label'=>$langs->trans("Firstname"), 'checked'=>1), - 'u.gender'=>array('label'=>$langs->trans("Gender"), 'checked'=>0), - 'u.employee'=>array('label'=>$langs->trans("Employee"), 'checked'=>($mode == 'employee' ? 1 : 0)), - 'u.accountancy_code'=>array('label'=>$langs->trans("AccountancyCode"), 'checked'=>0), - 'u.email'=>array('label'=>$langs->trans("EMail"), 'checked'=>1), - 'u.api_key'=>array('label'=>$langs->trans("ApiKey"), 'checked'=>0, "enabled"=>($conf->api->enabled && $user->admin)), - 'u.fk_soc'=>array('label'=>$langs->trans("Company"), 'checked'=>1), - 'u.entity'=>array('label'=>$langs->trans("Entity"), 'checked'=>1, 'enabled'=>(!empty($conf->multicompany->enabled) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))), - 'u.fk_user'=>array('label'=>$langs->trans("HierarchicalResponsible"), 'checked'=>1), - 'u.datelastlogin'=>array('label'=>$langs->trans("LastConnexion"), 'checked'=>1, 'position'=>100), - 'u.datepreviouslogin'=>array('label'=>$langs->trans("PreviousConnexion"), 'checked'=>0, 'position'=>110), - 'u.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), - 'u.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), - 'u.statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000), + 'u.login'=>array('label'=>"Login", 'checked'=>1, 'position'=>10), + 'u.lastname'=>array('label'=>"Lastname", 'checked'=>1, 'position'=>15), + 'u.firstname'=>array('label'=>"Firstname", 'checked'=>1, 'position'=>20), + 'u.entity'=>array('label'=>"Entity", 'checked'=>1, 'position'=>50, 'enabled'=>(!empty($conf->multicompany->enabled) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))), + 'u.gender'=>array('label'=>"Gender", 'checked'=>0, 'position'=>22), + 'u.employee'=>array('label'=>"Employee", 'checked'=>($mode == 'employee' ? 1 : 0), 'position'=>25), + 'u.fk_user'=>array('label'=>"HierarchicalResponsible", 'checked'=>1, 'position'=>27), + 'u.accountancy_code'=>array('label'=>"AccountancyCode", 'checked'=>0, 'position'=>30), + 'u.email'=>array('label'=>"EMail", 'checked'=>1, 'position'=>35), + 'u.api_key'=>array('label'=>"ApiKey", 'checked'=>0, 'position'=>40, "enabled"=>($conf->api->enabled && $user->admin)), + 'u.fk_soc'=>array('label'=>"Company", 'checked'=>1, 'position'=>45), + 'u.salary'=>array('label'=>"Salary", 'checked'=>1, 'position'=>80, 'enabled'=>($conf->salaries->enabled && !empty($user->rights->salaries->readall))), + 'u.datelastlogin'=>array('label'=>"LastConnexion", 'checked'=>1, 'position'=>100), + 'u.datepreviouslogin'=>array('label'=>"PreviousConnexion", 'checked'=>0, 'position'=>110), + 'u.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500), + 'u.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500), + 'u.statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000), ); // Extra fields -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) -{ - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) - { - if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) { - $arrayfields["ef.".$key] = array( - 'label'=>$extrafields->attributes[$object->table_element]['label'][$key], - 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), - 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], - 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key]), - 'langfile'=>$extrafields->attributes[$object->table_element]['langfile'][$key], - 'help'=>$extrafields->attributes[$object->table_element]['help'][$key] - ); - } - } -} +include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_array_fields.tpl.php'; + $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); // Init search fields -$sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); +$sall = trim((GETPOST('search_all', 'alphanohtml') != '') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); $search_user = GETPOST('search_user', 'alpha'); $search_login = GETPOST('search_login', 'alpha'); $search_lastname = GETPOST('search_lastname', 'alpha'); @@ -183,6 +170,8 @@ if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) $error = 0; +$childids = $user->getAllChildIds(1); + /* * Actions @@ -308,7 +297,7 @@ if ($contextpage == 'employeelist' && $search_employee == 1) { $user2 = new User($db); $sql = "SELECT DISTINCT u.rowid, u.lastname, u.firstname, u.admin, u.fk_soc, u.login, u.email, u.api_key, u.accountancy_code, u.gender, u.employee, u.photo,"; -$sql .= " u.datelastlogin, u.datepreviouslogin,"; +$sql .= " u.salary, u.datelastlogin, u.datepreviouslogin,"; $sql .= " u.ldap_sid, u.statut, u.entity,"; $sql .= " u.tms as date_update, u.datec as date_creation,"; $sql .= " u2.rowid as id2, u2.login as login2, u2.firstname as firstname2, u2.lastname as lastname2, u2.admin as admin2, u2.fk_soc as fk_soc2, u2.email as email2, u2.gender as gender2, u2.photo as photo2, u2.entity as entity2, u2.statut as statut2,"; @@ -343,7 +332,7 @@ if ($search_thirdparty != '') $sql .= natural_search(array('s.nom'), $search_thi if ($search_login != '') $sql .= natural_search("u.login", $search_login); if ($search_lastname != '') $sql .= natural_search("u.lastname", $search_lastname); if ($search_firstname != '') $sql .= natural_search("u.firstname", $search_firstname); -if ($search_gender != '' && $search_gender != '-1') $sql .= natural_search("u.gender", $search_gender); +if ($search_gender != '' && $search_gender != '-1') $sql .= " AND u.gender = '".$db->escape($search_gender)."'"; // Cannot use natural_search as looking for %man% also includes woman if (is_numeric($search_employee) && $search_employee >= 0) { $sql .= ' AND u.employee = '.(int) $search_employee; } @@ -356,6 +345,7 @@ if ($catid > 0) $sql .= " AND cu.fk_categorie = ".((int) $catid); if ($catid == -2) $sql .= " AND cu.fk_categorie IS NULL"; if ($search_categ > 0) $sql .= " AND cu.fk_categorie = ".$db->escape($search_categ); if ($search_categ == -2) $sql .= " AND cu.fk_categorie IS NULL"; +if ($mode == 'employee' && empty($user->rights->salaries->readall)) $sql .= " AND s.fk_user IN (".join(',', $childids).")"; // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks @@ -541,6 +531,13 @@ if (!empty($arrayfields['u.employee']['checked'])) print $form->selectyesno('search_employee', $search_employee, 1, false, 1); print ''; + print $form->select_dolusers($search_supervisor, 'search_supervisor', 1, array(), 0, '', 0, 0, 0, 0, '', 0, '', 'maxwidth200'); + print ''; - print $form->select_dolusers($search_supervisor, 'search_supervisor', 1, array(), 0, '', 0, 0, 0, 0, '', 0, '', 'maxwidth200'); - print ''.yn($obj->employee).''; + if ($obj->login2) + { + $user2->id = $obj->id2; + $user2->login = $obj->login2; + $user2->lastname = $obj->lastname2; + $user2->firstname = $obj->firstname2; + $user2->gender = $obj->gender2; + $user2->photo = $obj->photo2; + $user2->admin = $obj->admin2; + $user2->email = $obj->email2; + $user2->socid = $obj->fk_soc2; + $user2->statut = $obj->statut2; + print $user2->getNomUrl(-1, '', 0, 0, 24, 0, '', '', 1); + if (!empty($conf->multicompany->enabled) && $obj->admin2 && !$obj->entity2) + { + print img_picto($langs->trans("SuperAdministrator"), 'redstar', 'class="valignmiddle paddingleft"'); + } elseif ($obj->admin2) + { + print img_picto($langs->trans("Administrator"), 'star', 'class="valignmiddle paddingleft"'); + } + } + print ''.$obj->accountancy_code.''; - if ($obj->login2) - { - $user2->id = $obj->id2; - $user2->login = $obj->login2; - $user2->lastname = $obj->lastname2; - $user2->firstname = $obj->firstname2; - $user2->gender = $obj->gender2; - $user2->photo = $obj->photo2; - $user2->admin = $obj->admin2; - $user2->email = $obj->email2; - $user2->socid = $obj->fk_soc2; - $user2->statut = $obj->statut2; - print $user2->getNomUrl(-1, '', 0, 0, 24, 0, '', '', 1); - if (!empty($conf->multicompany->enabled) && $obj->admin2 && !$obj->entity2) - { - print img_picto($langs->trans("SuperAdministrator"), 'redstar', 'class="valignmiddle paddingleft"'); - } elseif ($obj->admin2) - { - print img_picto($langs->trans("Administrator"), 'star', 'class="valignmiddle paddingleft"'); - } - } - print ''.($obj->salary ? price($obj->salary) : '').'
'; + print ''; -print ''."\n"; +print ''."\n"; +print ''."\n"; +print ''."\n"; + print ''; + print ''; if (isset($conf->global->PRODUIT_ATTRIBUTES_SEPARATOR)) { $separator = $conf->global->PRODUIT_ATTRIBUTES_SEPARATOR; @@ -67,8 +80,11 @@ if (isset($conf->global->PRODUIT_ATTRIBUTES_SEPARATOR)) { $separator = "_"; } print ''; + print '
'.$langs->trans("Parameters").''."\n"; -print ''.$langs->trans("Value").''."\n"; -print ' 
'.$langs->trans("Parameters").''.$langs->trans("Value").'
'.$langs->trans('HideProductCombinations').''; print $form->selectyesno("PRODUIT_ATTRIBUTES_HIDECHILD", $conf->global->PRODUIT_ATTRIBUTES_HIDECHILD, 1).'
'.$langs->trans('CombinationsSeparator').'
'; + print '
'; + print ''; // End of page diff --git a/htdocs/variants/card.php b/htdocs/variants/card.php index 057e184d184..6cda745056a 100644 --- a/htdocs/variants/card.php +++ b/htdocs/variants/card.php @@ -43,7 +43,7 @@ if ($object->fetch($id) < 1) { if ($cancel) $action = ''; -if ($_POST) { +if ($action) { if ($action == 'edit') { $object->ref = $ref; $object->label = $label; diff --git a/htdocs/variants/combinations.php b/htdocs/variants/combinations.php index b0d5ebadda8..3a2936d0df5 100644 --- a/htdocs/variants/combinations.php +++ b/htdocs/variants/combinations.php @@ -72,7 +72,7 @@ $selectedvariant = $_SESSION['addvariant_'.$object->id]; if ($cancel) { $action = ''; - $massactions = ''; + $massaction = ''; unset($_SESSION['addvariant_'.$object->id]); } @@ -101,179 +101,177 @@ $prodcomb2val = new ProductCombination2ValuePair($db); $productCombination2ValuePairs1 = array(); -if ($_POST) { - if (($action == 'add' || $action == 'create') && empty($massaction) && !GETPOST('selectvariant', 'alpha')) // We click on Create all defined combinations - { - //$features = GETPOST('features', 'array'); - $features = $_SESSION['addvariant_'.$object->id]; +if (($action == 'add' || $action == 'create') && empty($massaction) && !GETPOST('selectvariant', 'alpha')) // We click on Create all defined combinations +{ + //$features = GETPOST('features', 'array'); + $features = $_SESSION['addvariant_'.$object->id]; - if (!$features) { - setEventMessages($langs->trans('ErrorFieldsRequired'), null, 'errors'); - } else { - $reference = trim($reference); - if (empty($reference)) { - $reference = false; - } - $weight_impact = price2num($weight_impact); - $price_impact = price2num($price_impact); - - // for conf PRODUIT_MULTIPRICES - if ($conf->global->PRODUIT_MULTIPRICES) { - $level_price_impact = array_map('price2num', $level_price_impact); - } - else { - $level_price_impact = array(1 => $price_impact); - $level_price_impact_percent = array(1 => $price_impact_percent); - } - - $sanit_features = array(); - - //First, sanitize - foreach ($features as $feature) { - $explode = explode(':', $feature); - - if ($prodattr->fetch($explode[0]) < 0) { - continue; - } - - if ($prodattr_val->fetch($explode[1]) < 0) { - continue; - } - - // Valuepair - $sanit_features[$explode[0]] = $explode[1]; - - $tmp = new ProductCombination2ValuePair($db); - $tmp->fk_prod_attr = $explode[0]; - $tmp->fk_prod_attr_val = $explode[1]; - - $productCombination2ValuePairs1[] = $tmp; - } - - $db->begin(); - - // sanit_feature is an array with 1 (and only 1) value per attribute. - // For example: Color->blue, Size->Small, Option->2 - //var_dump($sanit_features); - if (!$prodcomb->fetchByProductCombination2ValuePairs($id, $sanit_features)) - { - $result = $prodcomb->createProductCombination($user, $object, $sanit_features, array(), $level_price_impact_percent, $level_price_impact, $weight_impact, $reference); - if ($result > 0) - { - setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); - unset($_SESSION['addvariant_'.$object->id]); - - $db->commit(); - header('Location: '.dol_buildpath('/variants/combinations.php?id='.$id, 2)); - exit(); - } else { - $langs->load("errors"); - setEventMessages($prodcomb->error, $prodcomb->errors, 'errors'); - } - } else { - setEventMessages($langs->trans('ErrorRecordAlreadyExists'), null, 'errors'); - } - - $db->rollback(); + if (!$features) { + setEventMessages($langs->trans('ErrorFieldsRequired'), null, 'errors'); + } else { + $reference = trim($reference); + if (empty($reference)) { + $reference = false; } - } elseif (!empty($massaction)) - { - $bulkaction = $massaction; - $error = 0; - - - - $db->begin(); - - foreach ($toselect as $prodid) { - // need create new of Product to prevent rename dir behavior - $prodstatic = new Product($db); - - if ($prodstatic->fetch($prodid) < 0) { - continue; - } - - if ($bulkaction == 'on_sell') { - $prodstatic->status = 1; - $res = $prodstatic->update($prodstatic->id, $user); - } elseif ($bulkaction == 'on_buy') { - $prodstatic->status_buy = 1; - $res = $prodstatic->update($prodstatic->id, $user); - } elseif ($bulkaction == 'not_sell') { - $prodstatic->status = 0; - $res = $prodstatic->update($prodstatic->id, $user); - } elseif ($bulkaction == 'not_buy') { - $prodstatic->status_buy = 0; - $res = $prodstatic->update($prodstatic->id, $user); - } elseif ($bulkaction == 'delete') { - $res = $prodstatic->delete($user, $prodstatic->id); - } else { - break; - } - - if ($res <= 0) { - $error++; - break; - } - } - - if ($error) { - $db->rollback(); - - if ($prodstatic->error) { - setEventMessages($prodstatic->error, $prodstatic->errors, 'errors'); - } else { - setEventMessages($langs->trans('CoreErrorMessage'), null, 'errors'); - } - } else { - $db->commit(); - setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); - } - } elseif ($valueid > 0) { - if ($prodcomb->fetch($valueid) < 0) { - dol_print_error($db, $langs->trans('ErrorRecordNotFound')); - exit(); - } - - $prodcomb->variation_weight = $weight_impact; + $weight_impact = price2num($weight_impact); + $price_impact = price2num($price_impact); // for conf PRODUIT_MULTIPRICES if ($conf->global->PRODUIT_MULTIPRICES) { $level_price_impact = array_map('price2num', $level_price_impact); - - $prodcomb->variation_price = $level_price_impact[1]; - $prodcomb->variation_price_percentage = (bool) $level_price_impact_percent[1]; } else { $level_price_impact = array(1 => $price_impact); $level_price_impact_percent = array(1 => $price_impact_percent); - - $prodcomb->variation_price = $price_impact; - $prodcomb->variation_price_percentage = $price_impact_percent; } - if ($conf->global->PRODUIT_MULTIPRICES) { - $prodcomb->combination_price_levels = array(); - for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) { - $productCombinationLevel = new ProductCombinationLevel($db); - $productCombinationLevel->fk_product_attribute_combination = $prodcomb->id; - $productCombinationLevel->fk_price_level = $i; - $productCombinationLevel->variation_price = $level_price_impact[$i]; - $productCombinationLevel->variation_price_percentage = (bool) $level_price_impact_percent[$i]; - $prodcomb->combination_price_levels[$i] = $productCombinationLevel; + $sanit_features = array(); + + //First, sanitize + foreach ($features as $feature) { + $explode = explode(':', $feature); + + if ($prodattr->fetch($explode[0]) < 0) { + continue; } + + if ($prodattr_val->fetch($explode[1]) < 0) { + continue; + } + + // Valuepair + $sanit_features[$explode[0]] = $explode[1]; + + $tmp = new ProductCombination2ValuePair($db); + $tmp->fk_prod_attr = $explode[0]; + $tmp->fk_prod_attr_val = $explode[1]; + + $productCombination2ValuePairs1[] = $tmp; } - if ($prodcomb->update($user) > 0) { - setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); - header('Location: '.dol_buildpath('/variants/combinations.php?id='.$id, 2)); - exit(); + $db->begin(); + + // sanit_feature is an array with 1 (and only 1) value per attribute. + // For example: Color->blue, Size->Small, Option->2 + //var_dump($sanit_features); + if (!$prodcomb->fetchByProductCombination2ValuePairs($id, $sanit_features)) + { + $result = $prodcomb->createProductCombination($user, $object, $sanit_features, array(), $level_price_impact_percent, $level_price_impact, $weight_impact, $reference); + if ($result > 0) + { + setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); + unset($_SESSION['addvariant_'.$object->id]); + + $db->commit(); + header('Location: '.dol_buildpath('/variants/combinations.php?id='.$id, 2)); + exit(); + } else { + $langs->load("errors"); + setEventMessages($prodcomb->error, $prodcomb->errors, 'errors'); + } } else { - setEventMessages($prodcomb->error, $prodcomb->errors, 'errors'); + setEventMessages($langs->trans('ErrorRecordAlreadyExists'), null, 'errors'); + } + + $db->rollback(); + } +} elseif (!empty($massaction)) { + $bulkaction = $massaction; + $error = 0; + + + + $db->begin(); + + foreach ($toselect as $prodid) { + // need create new of Product to prevent rename dir behavior + $prodstatic = new Product($db); + + if ($prodstatic->fetch($prodid) < 0) { + continue; + } + + if ($bulkaction == 'on_sell') { + $prodstatic->status = 1; + $res = $prodstatic->update($prodstatic->id, $user); + } elseif ($bulkaction == 'on_buy') { + $prodstatic->status_buy = 1; + $res = $prodstatic->update($prodstatic->id, $user); + } elseif ($bulkaction == 'not_sell') { + $prodstatic->status = 0; + $res = $prodstatic->update($prodstatic->id, $user); + } elseif ($bulkaction == 'not_buy') { + $prodstatic->status_buy = 0; + $res = $prodstatic->update($prodstatic->id, $user); + } elseif ($bulkaction == 'delete') { + $res = $prodstatic->delete($user, $prodstatic->id); + } else { + break; + } + + if ($res <= 0) { + $error++; + break; } } + + if ($error) { + $db->rollback(); + + if ($prodstatic->error) { + setEventMessages($prodstatic->error, $prodstatic->errors, 'errors'); + } else { + setEventMessages($langs->trans('CoreErrorMessage'), null, 'errors'); + } + } else { + $db->commit(); + setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); + } +} elseif ($valueid > 0) { + if ($prodcomb->fetch($valueid) < 0) { + dol_print_error($db, $langs->trans('ErrorRecordNotFound')); + exit(); + } + + $prodcomb->variation_weight = $weight_impact; + + // for conf PRODUIT_MULTIPRICES + if ($conf->global->PRODUIT_MULTIPRICES) { + $level_price_impact = array_map('price2num', $level_price_impact); + + $prodcomb->variation_price = $level_price_impact[1]; + $prodcomb->variation_price_percentage = (bool) $level_price_impact_percent[1]; + } + else { + $level_price_impact = array(1 => $price_impact); + $level_price_impact_percent = array(1 => $price_impact_percent); + + $prodcomb->variation_price = $price_impact; + $prodcomb->variation_price_percentage = $price_impact_percent; + } + + if ($conf->global->PRODUIT_MULTIPRICES) { + $prodcomb->combination_price_levels = array(); + for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) { + $productCombinationLevel = new ProductCombinationLevel($db); + $productCombinationLevel->fk_product_attribute_combination = $prodcomb->id; + $productCombinationLevel->fk_price_level = $i; + $productCombinationLevel->variation_price = $level_price_impact[$i]; + $productCombinationLevel->variation_price_percentage = (bool) $level_price_impact_percent[$i]; + $prodcomb->combination_price_levels[$i] = $productCombinationLevel; + } + } + + if ($prodcomb->update($user) > 0) { + setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); + header('Location: '.dol_buildpath('/variants/combinations.php?id='.$id, 2)); + exit(); + } else { + setEventMessages($prodcomb->error, $prodcomb->errors, 'errors'); + } } + // Reload variants $productCombinations = $prodcomb->fetchAllByFkProductParent($object->id); @@ -772,11 +770,6 @@ if (!empty($id) || !empty($ref)) print ''.$langs->trans('PropagateVariant').''; } - // Too much bugged page. - /* - print ''.$langs->trans('ProductCombinationGenerator').''; - */ - print '
'; print '
'; diff --git a/htdocs/variants/create.php b/htdocs/variants/create.php index ce00ac51a1a..84530e01cb5 100644 --- a/htdocs/variants/create.php +++ b/htdocs/variants/create.php @@ -22,13 +22,14 @@ require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductAttribute.class.php'; $ref = GETPOST('ref', 'alpha'); $label = GETPOST('label', 'alpha'); $backtopage = GETPOST('backtopage', 'alpha'); +$action = GETPOST('action', 'alpha'); /* * Actions */ -if ($_POST) { +if ($action == 'create') { if (empty($ref) || empty($label)) { setEventMessages($langs->trans('ErrorFieldsRequired'), null, 'errors'); } else { diff --git a/htdocs/variants/generator.php b/htdocs/variants/generator.php deleted file mode 100644 index 9c41335c867..00000000000 --- a/htdocs/variants/generator.php +++ /dev/null @@ -1,385 +0,0 @@ - - * Copyright (C) 2018 Frédéric France - * - * 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 . - */ - -require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; -require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductAttribute.class.php'; -require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductAttributeValue.class.php'; -require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductCombination.class.php'; -require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductCombination2ValuePair.class.php'; - -$langs->loadLangs(array("products", "other")); - -$id = GETPOST('id', 'int'); -$ref = GETPOST('ref'); -$form = new Form($db); - -// Security check -$fieldvalue = (!empty($id) ? $id : $ref); -$fieldtype = (!empty($ref) ? 'ref' : 'rowid'); -$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); - -$prodattr = new ProductAttribute($db); -$prodattrval = new ProductAttributeValue($db); -$product = new Product($db); - -$product->fetch($id); - -$error = 0; - - -/* - * Actions - */ - -if (!$product->isProduct()) { - header('Location: '.dol_buildpath('/product/card.php?id='.$product->id, 2)); - exit(); -} - -/** - * Posible combinations. Format. - * attrval => array( - * valueid => array( - * price => '' - * weight => '' - * ) - * ) - */ -$combinations = GETPOST('combinations', 'array'); -$price_var_percent = (bool) GETPOST('price_var_percent'); -$donotremove = true; - -if ($_POST) -{ - $donotremove = (bool) GETPOST('donotremove'); - - //We must check if all those given combinations actually exist - $sanitized_values = array(); - - foreach ($combinations as $attr => $val) { - if ($prodattr->fetch($attr) > 0) { - foreach ($val as $valueid => $content) { - if ($prodattrval->fetch($valueid) > 0) { - $sanitized_values[$attr][$valueid] = $content; - } - } - } - } - - if ($sanitized_values) { - require DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - - $adapted_values = array(); - - //Adapt the array to the cartesian function - foreach ($sanitized_values as $attr => $val) { - $adapted_values[$attr] = array_keys($val); - } - - $db->begin(); - - $combination = new ProductCombination($db); - - $delete_prev_comb_res = 1; - - if (!$donotremove) { - $delete_prev_comb_res = $combination->deleteByFkProductParent($user, $id); - } - - //Current combinations will be deleted - if ($delete_prev_comb_res > 0) { - $res = 1; - - $cartesianarray = cartesianArray($adapted_values); - foreach ($cartesianarray as $currcomb) - { - $res = $combination->createProductCombination($user, $product, $currcomb, $sanitized_values, $price_var_percent); - if ($res < 0) { - $error++; - setEventMessages($combination->error, $combination->errors, 'errors'); - break; - } - } - - if ($res > 0) { - $db->commit(); - setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); - header('Location: '.dol_buildpath('/variants/combinations.php?id='.$id, 2)); - exit; - } - } else { - setEventMessages($langs->trans('ErrorDeletingGeneratedProducts'), null, 'errors'); - } - - $db->rollback(); - } else { - setEventMessages($langs->trans('ErrorFieldsRequired'), null, 'errors'); - } -} - - - -/* - * View - */ - -if (!empty($id) || !empty($ref)) { - $object = new Product($db); - $result = $object->fetch($id, $ref); - - llxHeader("", "", $langs->trans("CardProduct".$object->type)); - - if ($result > 0) - { - $showbarcode = empty($conf->barcode->enabled) ? 0 : 1; - if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) $showbarcode = 0; - - $head = product_prepare_head($object); - $titre = $langs->trans("CardProduct".$object->type); - $picto = ($object->type == Product::TYPE_SERVICE ? 'service' : 'product'); - print dol_get_fiche_head($head, 'combinations', $titre, 0, $picto); - - $linkback = ''.$langs->trans("BackToList").''; - $object->next_prev_filter = " fk_product_type = ".$object->type; - - dol_banner_tab($object, 'ref', $linkback, ($user->socid ? 0 : 1), 'ref', '', '', '', 0, '', '', 1); - - print dol_get_fiche_end(); - } - - print load_fiche_titre($langs->trans('ProductCombinationGenerator')); - - $dictionary_attr = array(); - - foreach ($prodattr->fetchAll() as $attr) { - $dictionary_attr[$attr->id] = $attr; - foreach ($prodattrval->fetchAllByProductAttribute($attr->id) as $attrval) { - $dictionary_attr[$attr->id]->values[$attrval->id] = $attrval; - } - } - ?> - - - -
- -
- -
- -

trans('TooMuchCombinationsWarning', $langs->transnoentitiesnoconv('DoNotRemovePreviousCombinations')) ?>

- > -
- > - -
-
- - trans('ProductCombinationGeneratorWarning') ?> -
-
- -
- -
- -
- -
-
- - - -

- - - -
- -
- - - close(); diff --git a/htdocs/website/class/website.class.php b/htdocs/website/class/website.class.php index 631de0a5fa8..42b39e7e902 100644 --- a/htdocs/website/class/website.class.php +++ b/htdocs/website/class/website.class.php @@ -882,7 +882,7 @@ class Website extends CommonObject global $user; $this->id = 0; - $this->specimen =1; + $this->specimen = 1; $this->entity = 1; $this->ref = 'myspecimenwebsite'; $this->description = 'A specimen website'; diff --git a/htdocs/website/index.php b/htdocs/website/index.php index d8f93da3ba1..d8ad8163dde 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -2300,7 +2300,7 @@ if (!GETPOST('hide_websitemenu')) //var_dump($objectpage);exit; - print '
'; + print '
'; // // Toolbar for websites @@ -3009,7 +3009,7 @@ if ($action == 'editcss') print dol_get_fiche_head(); - print ''."\n"; + print ''."\n"; print ''; // Website @@ -3039,8 +3039,8 @@ if ($action == 'editcss') // Other languages print ''; @@ -3049,10 +3049,11 @@ if ($action == 'editcss') // VirtualHost print '"; } diff --git a/htdocs/zapier/class/api_zapier.class.php b/htdocs/zapier/class/api_zapier.class.php index bb3e42f5f05..945a6a69a8f 100644 --- a/htdocs/zapier/class/api_zapier.class.php +++ b/htdocs/zapier/class/api_zapier.class.php @@ -244,7 +244,7 @@ class ZapierApi extends DolibarrApi $fields = array( 'url', ); - dol_syslog("API Zapier create hook receive : " . print_r($request_data, true), LOG_DEBUG); + dol_syslog("API Zapier create hook receive : ".print_r($request_data, true), LOG_DEBUG); $result = $this->validate($request_data, $fields); foreach ($request_data as $field => $value) { diff --git a/htdocs/zapier/class/hook.class.php b/htdocs/zapier/class/hook.class.php index 8e6d3fa725f..5d5a9c84eda 100644 --- a/htdocs/zapier/class/hook.class.php +++ b/htdocs/zapier/class/hook.class.php @@ -212,9 +212,14 @@ class Hook extends CommonObject public $label; /** - * @var string amount + * @var string url of webhook */ - public $amount; + public $url; + + /** + * @var int ID of user owner webhook + */ + public $fk_user; /** * @var int Status diff --git a/scripts/emailings/reset-invalid-emails.php b/scripts/emailings/reset-invalid-emails.php index ed10aded257..bc35f0f4240 100755 --- a/scripts/emailings/reset-invalid-emails.php +++ b/scripts/emailings/reset-invalid-emails.php @@ -35,14 +35,15 @@ if (substr($sapi_type, 0, 3) == 'cgi') { exit(-1); } -if (!isset($argv[2]) || !$argv[2]) { - print "Usage: ".$script_file." inputfile-with-invalid-emails type\n"; +if (!isset($argv[3]) || !$argv[3]) { + print "Usage: ".$script_file." inputfile-with-invalid-emails type [test|confirm]\n"; print "- inputfile-with-invalid-emails is a file with list of invalid email\n"; print "- type can be 'all' or 'thirdparties', 'contacts', 'members', 'users'\n"; exit(-1); } $fileofinvalidemail = $argv[1]; $type = $argv[2]; +$mode = $argv[3]; require_once $path."../../htdocs/master.inc.php"; require_once DOL_DOCUMENT_ROOT."/core/class/CMailFile.class.php"; @@ -56,15 +57,15 @@ $error = 0; * Main */ +$user = new User($db); + @set_time_limit(0); print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n"; - -$user = new User($db); -// for signature, we use user send as parameter -if (!empty($login)) - $user->fetch('', $login); - +if (!in_array($type, array('thirdparties', 'contacts', 'users', 'members'))) { + print "Bad value for parameter type.\n"; + exit(-1); +} $db->begin(); @@ -77,12 +78,15 @@ if (!$myfile) } $tmp = 1; -while ($tmp!=null) +$counter = 1; +$numerasedtotal = 0; + +while ($tmp != null) { - $groupofemails=array(); - for ($i=0; $i < MAXEMAILS; $i++) + $groupofemails = array(); + for ($i = 0; $i < MAXEMAILS; $i++) { - $tmp =fgets($myfile); + $tmp = fgets($myfile); if ($tmp == null) { break; @@ -90,49 +94,82 @@ while ($tmp!=null) $groupofemails[$i] = trim($tmp, "\n"); } + // Generate the string tp allow a mass update (with a limit of MAXEMAILS per request). + $emailsin = ''; + foreach ($groupofemails as $email) { + $emailsin .= ($emailsin ? ", " : "")."'".$db->escape($email)."'"; + } + // For each groupofemail, we update tables to set email field to empty + $nbingroup = count($groupofemails); + + print "Process group of ".$nbingroup." emails (".$counter." - ".($counter + $nbingroup - 1)."), type = ".$type."\n"; + + $numerased = 0; $sql_base = "UPDATE ".MAIN_DB_PREFIX; - foreach ($groupofemails as $email) + + if ($type == 'all' || $type == 'users') { - if ($type == 'all' || $type == 'thirdparty') - { - // Loop on each record and update the email to null if email into $groupofemails - - $sql=$sql_base."societe as s SET s.email = NULL WHERE s.email = '".$db->escape($email)."';"; - $db->query($sql); + // Loop on each record and update the email to null if email into $groupofemails + $sql = $sql_base."user as u SET u.email = NULL WHERE u.email IN (".$emailsin.");"; + print "Try to update users, "; + $resql = $db->query($sql); + if (!$resql) { + dol_print_error($db); } - - if ($type == 'all' || $type == 'contact') - { - // Loop on each record and update the email to null if email into $groupofemails - - $sql=$sql_base."socpeople as s SET s.email = NULL WHERE s.email = '".$db->escape($email)."';"; - $db->query($sql); - } - - if ($type == 'all' || $type == 'user') - { - // Loop on each record and update the email to null if email into $groupofemails - - $sql=$sql_base."user as u SET u.email = NULL WHERE u.email = '".$db->escape($email)."';"; - $db->query($sql); - } - - if ($type == 'all' || $type == 'member') - { - // Loop on each record and update the email to null if email into $groupofemails - - $sql=$sql_base."adherent as a SET a.email = NULL WHERE a.email = '".$db->escape($email)."';"; - $resql=$db->query($sql); - } - echo $email; + $numerased += $db->affected_rows($resql); } + + if ($type == 'all' || $type == 'thirdparties') + { + // Loop on each record and update the email to null if email into $groupofemails + $sql = $sql_base."societe as s SET s.email = NULL WHERE s.email IN (".$emailsin.");"; + print "Try to update thirdparties, "; + $resql = $db->query($sql); + if (!$resql) { + dol_print_error($db); + } + $numerased += $db->affected_rows($resql); + } + + if ($type == 'all' || $type == 'contacts') + { + // Loop on each record and update the email to null if email into $groupofemails + + $sql = $sql_base."socpeople as s SET s.email = NULL WHERE s.email IN (".$emailsin.");"; + print "Try to update contacts, "; + $resql = $db->query($sql); + if (!$resql) { + dol_print_error($db); + } + $numerased += $db->affected_rows($resql); + } + + if ($type == 'all' || $type == 'members') + { + // Loop on each record and update the email to null if email into $groupofemails + + $sql = $sql_base."adherent as a SET a.email = NULL WHERE a.email IN (".$emailsin.");"; + print "Try to update members, "; + $resql = $db->query($sql); + if (!$resql) { + dol_print_error($db); + } + $numerased += $db->affected_rows($resql); + } + + $numerasedtotal += $numerased; + + print $numerased." emails cleared.\n"; + $counter = $counter + $nbingroup; } -if (!$error) { +if (!$error && $mode == 'confirm') { + print "Commit - ".$numerasedtotal." operations validated.\n"; $db->commit(); } else { + print "Rollback - ".$numerasedtotal." Operations canceled.\n"; $db->rollback(); } diff --git a/test/phpunit/AllTests.php b/test/phpunit/AllTests.php index d07cc34a544..09c075c1083 100644 --- a/test/phpunit/AllTests.php +++ b/test/phpunit/AllTests.php @@ -77,8 +77,8 @@ class AllTests $suite = new PHPUnit\Framework\TestSuite('PHPUnit Framework'); - require_once dirname(__FILE__).'/CoreTest.php'; - $suite->addTestSuite('CoreTest'); + //require_once dirname(__FILE__).'/CoreTest.php'; + //$suite->addTestSuite('CoreTest'); require_once dirname(__FILE__).'/AdminLibTest.php'; $suite->addTestSuite('AdminLibTest'); require_once dirname(__FILE__).'/CompanyLibTest.php'; diff --git a/test/phpunit/CoreTest.php b/test/phpunit/CoreTest.php index 3169c4063c0..22649a80724 100644 --- a/test/phpunit/CoreTest.php +++ b/test/phpunit/CoreTest.php @@ -236,198 +236,4 @@ class CoreTest extends PHPUnit\Framework\TestCase return true; } - - - /** - * testSqlAndScriptInjectWithPHPUnit - * - * @return void - */ - public function testSqlAndScriptInjectWithPHPUnit() - { - // This is code copied from main.inc.php !!!!!!!!!!!!!!! - - /** - * Security: WAF layer for SQL Injection and XSS Injection (scripts) protection (Filters on GET, POST, PHP_SELF). - * - * @param string $val Value brut found int $_GET, $_POST or PHP_SELF - * @param string $type 1=GET, 0=POST, 2=PHP_SELF, 3=GET without sql reserved keywords (the less tolerant test) - * @return int >0 if there is an injection, 0 if none - */ - function testSqlAndScriptInject($val, $type) - { - // Decode string first - // So error=alert(1) - $val = preg_replace('//', '', $val); - - $inj = 0; - // For SQL Injection (only GET are used to be included into bad escaped SQL requests) - if ($type == 1 || $type == 3) - { - $inj += preg_match('/delete\s+from/i', $val); - $inj += preg_match('/create\s+table/i', $val); - $inj += preg_match('/insert\s+into/i', $val); - $inj += preg_match('/select\s+from/i', $val); - $inj += preg_match('/into\s+(outfile|dumpfile)/i', $val); - $inj += preg_match('/user\s*\(/i', $val); // avoid to use function user() that return current database login - $inj += preg_match('/information_schema/i', $val); // avoid to use request that read information_schema database - $inj += preg_match('/ - $inj += preg_match('/ondrag([a-z]*)\s*=/i', $val); // - $inj += preg_match('/ontouch([a-z]*)\s*=/i', $val); // - $inj += preg_match('/on(abort|afterprint|beforeprint|beforeunload|blur|canplay|canplaythrough|change|click|contextmenu|copy|cut)\s*=/i', $val); - $inj += preg_match('/on(dblclick|drop|durationchange|ended|error|focus|focusin|focusout|hashchange|input|invalid)\s*=/i', $val); - $inj += preg_match('/on(keydown|keypress|keyup|load|loadeddata|loadedmetadata|loadstart|offline|online|pagehide|pageshow)\s*=/i', $val); - $inj += preg_match('/on(paste|pause|play|playing|progress|ratechange|resize|reset|scroll|search|seeking|select|show|stalled|start|submit|suspend)\s*=/i', $val); - $inj += preg_match('/on(timeupdate|toggle|unload|volumechange|waiting)\s*=/i', $val); - //$inj += preg_match('/on[A-Z][a-z]+\*=/', $val); // To lock event handlers onAbort(), ... - $inj += preg_match('/:|:|:/i', $val); // refused string ':' encoded (no reason to have it encoded) to lock 'javascript:...' - $inj += preg_match('/javascript\s*:/i', $val); - $inj += preg_match('/vbscript\s*:/i', $val); - // For XSS Injection done by adding javascript closing html tags like with onmousemove, etc... (closing a src or href tag with not cleaned param) - if ($type == 1) { - $val = str_replace('enclosure="', 'enclosure=X', $val); // We accept enclosure=" - $inj += preg_match('/"/i', $val); // We refused " in GET parameters value. - } - if ($type == 2) $inj += preg_match('/[;"]/', $val); // PHP_SELF is a file system path. It can contains spaces. - return $inj; - } - - - // Run tests - // More on https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet - - // Should be OK - $expectedresult=0; - - $_SERVER["PHP_SELF"]='/DIR WITH SPACE/htdocs/admin/index.php?mainmenu=home&leftmenu=setup&username=weservices'; - $result=testSqlAndScriptInject($_SERVER["PHP_SELF"], 2); - $this->assertEquals($expectedresult, $result, 'Error on testSqlAndScriptInject 1a'); - - // Should detect XSS - $expectedresult=1; - - $_SERVER["PHP_SELF"]='/DIR WITH SPACE/htdocs/admin/index.php?mainmenu=home&leftmenu=setup&username=weservices;badaction'; - $result=testSqlAndScriptInject($_SERVER["PHP_SELF"], 2); - $this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject 1b'); - - $test=""; - $result=testSqlAndScriptInject($test, 0); - $this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject aaa'); - - $test=""; - $result=testSqlAndScriptInject($test, 2); - $this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject aaa2'); - - $test=''; - $result=testSqlAndScriptInject($test, 0); - $this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject aaa3'); - $test=''; - $result=testSqlAndScriptInject($test, 0); - $this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject aaa4'); - $test=''; - $result=testSqlAndScriptInject($test, 0); - $this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject aaa5'); - $test=''; - $result=testSqlAndScriptInject($test, 0); - $this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject aaa6'); - $test=''; - $result=testSqlAndScriptInject($test, 0); - $this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject aaa7'); - - $test=''; - $result=testSqlAndScriptInject($test, 0); - $this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject bbb'); - - $test=''; - $result=testSqlAndScriptInject($test, 0); - $this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject ccc'); - - $test=''; - $result=testSqlAndScriptInject($test, 1); - $this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject ddd'); - - $test='">'; - $result=testSqlAndScriptInject($test, 0); - $this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject eee'); - - $test=' - '; - $result=testSqlAndScriptInject($test, 0); - $this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject eee'); - - $test=""; // Is locked by some browser like chrome because the default directive no-referrer-when-downgrade is sent when requesting the SRC and then refused because of browser protection on img src load without referrer. - $test=""; // Same - - $test=''; - $result=testSqlAndScriptInject($test, 0); - $this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject fff1'); - $test=''; - $result=testSqlAndScriptInject($test, 0); - $this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject fff2'); - - // This case seems to be filtered by browsers now. - $test=''; - //$result=testSqlAndScriptInject($test, 0); - //$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject ggg'); - - $test='
'; - $htmltext = ''; - print $form->textwithpicto($langs->trans('OtherLanguages'), $htmltext, 1, 'help', '', 0, 2, 'WEBSITE_OTHERLANG'); + $htmltext = $langs->trans("Example").': fr,de,sv,it,pt'; + print $form->textwithpicto($langs->trans('OtherLanguages'), $htmltext, 1, 'help', '', 0, 2); print ''; print ''; print '
'; - $htmltext = $langs->trans("SetHereVirtualHost", DOL_DATA_ROOT.'/website/'.$websitekey.''); + $htmltext = $langs->trans("SetHereVirtualHost", DOL_DATA_ROOT.'/website/{s1}'.$websitekey.'{s2}'); + $htmltext = str_replace(array('{s1}', '{s2}'), array('', ''), $htmltext); $htmltext .= '
'; - $htmltext .= '
'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("ReadPerm"), DOL_DOCUMENT_ROOT); - $htmltext .= '
'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("WritePerm"), DOL_DATA_ROOT.'/website
'.DOL_DATA_ROOT.'/medias'); + $htmltext .= '
'.$langs->transnoentitiesnoconv("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("ReadPerm"), DOL_DOCUMENT_ROOT); + $htmltext .= '
'.$langs->transnoentitiesnoconv("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("WritePerm"), DOL_DATA_ROOT.'/website
'.DOL_DATA_ROOT.'/medias'); print $form->textwithpicto($langs->trans('Virtualhost'), $htmltext, 1, 'help', '', 0, 2, 'virtualhosttooltip'); print '
'; @@ -3573,7 +3574,7 @@ if ($action == 'editmeta' || $action == 'createcontainer') // Edit properties of } print '
'.$form->editfieldkey('Categories', 'categories', '', $objectpage, 0).''; - print img_picto('', 'category', 'class="paddingright"').$form->multiselectarray('categories', $cate_arbo, (GETPOSTISSET('categories') ? GETPOST('categories', 'array') : $arrayselected), null, null, null, null, "90%"); + print img_picto('', 'category', 'class="paddingright"').$form->multiselectarray('categories', $cate_arbo, (GETPOSTISSET('categories') ? GETPOST('categories', 'array') : $arrayselected), null, null, 'quatrevingtpercent widthcentpercentminusx'); print "