diff --git a/.travis.yml b/.travis.yml
index 5e3f1511266..4b17ebaf0c8 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -2,7 +2,7 @@
# from Dolibarr GitHub repository.
# For syntax, see http://about.travis-ci.org/docs/user/languages/php/
-# We use dist: precise to have php 5.3 available
+# We use dist: trusty to have php 5.4+ available
dist: trusty
sudo: required
@@ -20,7 +20,7 @@ addons:
# To use the last version of pgloader, we add repo of postgresql
- postgresql
- sourceline: 'deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main'
- - key_url: 'https://www.postgresql.org/media/keys/ACCC4CF8.asc'
+ - key_url: 'https://www.postgresql.org/media/keys/ACCC4CF8.asc'
packages:
# We need a webserver to test the webservices
# Let's install Apache with.
@@ -37,7 +37,6 @@ php:
- '7.0'
- '7.1'
- '7.2'
-#- hhvm only with dist: trusty
- nightly
env:
@@ -59,10 +58,17 @@ env:
matrix:
fast_finish: true
allow_failures:
- - php: hhvm
- php: nightly
# We exclude some combinations not usefull to save Travis CPU
exclude:
+ - php: '5.5'
+ env: DB=mariadb
+ - php: '5.6'
+ env: DB=mariadb
+ - php: '7.0'
+ env: DB=mariadb
+ - php: '7.1'
+ env: DB=mariadb
- php: '5.5'
env: DB=postgresql
- php: '5.6'
@@ -71,8 +77,6 @@ matrix:
env: DB=postgresql
- php: '7.1'
env: DB=postgresql
- - php: hhvm
- env: DB=postgresql
- php: nightly
env: DB=postgresql
@@ -101,7 +105,7 @@ before_install:
pgloader --version
echo
fi
-
+
install:
- |
echo "Updating Composer"
@@ -133,7 +137,7 @@ install:
- |
echo "Installing PHP CodeSniffer"
- composer -n require squizlabs/php_codesniffer ^2
+ composer -n require squizlabs/php_codesniffer ^3
echo
- |
@@ -195,7 +199,7 @@ before_script:
mysql --version | head -
mysql -e "SELECT VERSION();" | head -
echo
-
+
- |
echo "Setting up database"
if [ "$DB" = 'mysql' ] || [ "$DB" = 'mariadb' ] || [ "$DB" = 'postgresql' ]; then
@@ -203,7 +207,7 @@ before_script:
mysql -e 'DROP DATABASE IF EXISTS travis;'
mysql -e 'CREATE DATABASE IF NOT EXISTS travis;'
mysql -e 'GRANT ALL PRIVILEGES ON travis.* TO travis@127.0.0.1;'
- mysql -e 'FLUSH PRIVILEGES;'
+ mysql -e 'FLUSH PRIVILEGES;'
mysql -D travis < dev/initdemo/mysqldump_dolibarr_3.5.0.sql
fi
if [ "$DB" = 'postgresql' ]; then
@@ -216,7 +220,7 @@ before_script:
- |
export CONF_FILE=htdocs/conf/conf.php
echo "Setting up Dolibarr $CONF_FILE"
- echo ' $CONF_FILE
+ echo ' $CONF_FILE
echo '$'dolibarr_main_url_root=\'http://127.0.0.1\'';' >> $CONF_FILE
echo '$'dolibarr_main_document_root=\'$TRAVIS_BUILD_DIR/htdocs\'';' >> $CONF_FILE
echo '$'dolibarr_main_data_root=\'$TRAVIS_BUILD_DIR/documents\'';' >> $CONF_FILE
@@ -384,4 +388,3 @@ after_failure:
# TODO: PostgreSQL log file
echo
fi
-
diff --git a/.tx/config b/.tx/config
index db380163540..27327f033ea 100644
--- a/.tx/config
+++ b/.tx/config
@@ -38,6 +38,12 @@ source_file = htdocs/langs/en_US/bills.lang
source_lang = en_US
type = MOZILLAPROPERTIES
+[dolibarr.blockedlog]
+file_filter = htdocs/langs/
';
-
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/accountancy/admin/card.php b/htdocs/accountancy/admin/card.php
index 9643227da64..6a92a3f6080 100644
--- a/htdocs/accountancy/admin/card.php
+++ b/htdocs/accountancy/admin/card.php
@@ -397,6 +397,6 @@ else if ($id > 0 || $ref) {
}
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/accountancy/admin/categories.php b/htdocs/accountancy/admin/categories.php
index aec34469559..735c5595ddc 100644
--- a/htdocs/accountancy/admin/categories.php
+++ b/htdocs/accountancy/admin/categories.php
@@ -184,6 +184,6 @@ if ($action == 'display' || $action == 'delete') {
print "";
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/accountancy/admin/categories_list.php b/htdocs/accountancy/admin/categories_list.php
index 15a50e7b8e8..900205b7588 100644
--- a/htdocs/accountancy/admin/categories_list.php
+++ b/htdocs/accountancy/admin/categories_list.php
@@ -800,7 +800,7 @@ if ($id)
print '
';
-
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/accountancy/admin/defaultaccounts.php b/htdocs/accountancy/admin/defaultaccounts.php
index c33d4326836..8cd45c1cfda 100644
--- a/htdocs/accountancy/admin/defaultaccounts.php
+++ b/htdocs/accountancy/admin/defaultaccounts.php
@@ -190,5 +190,6 @@ print '';
// Param
- $label = $key[label];
+ $label = $key['label'];
print ' ';
@@ -278,5 +278,6 @@ print '' . $langs->trans($label) . ' ';
// Value
print '';
- if (is_array($key[param])) {
- print $form->selectarray($label, $key[param], $conf->global->$label, 0);
+ if (is_array($key['param'])) {
+ print $form->selectarray($label, $key['param'], $conf->global->$label, 0);
} else {
- print '';
+ print '';
}
print ' ';
- print $form->select_date(($date_start ? $date_start : ''), 'fiscalyear');
+ print $form->selectDate(($date_start ? $date_start : ''), 'fiscalyear');
print ' ';
// Date end
print ' ';
/*
@@ -225,12 +226,12 @@ if ($action == 'create')
// Date start
print '' . $langs->trans("DateEnd") . ' ';
- print $form->select_date(($date_end ? $date_end : - 1), 'fiscalyearend');
+ print $form->selectDate(($date_end ? $date_end : - 1), 'fiscalyearend');
print ' ';
// Date end
print '' . $langs->trans("DateStart") . ' ';
- print $form->select_date($object->date_start ? $object->date_start : - 1, 'fiscalyear');
+ print $form->selectDate($object->date_start ? $object->date_start : - 1, 'fiscalyear');
print ' ';
// Statut
@@ -318,5 +319,6 @@ if ($action == 'create')
}
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/accountancy/admin/fiscalyear_info.php b/htdocs/accountancy/admin/fiscalyear_info.php
index f16e3b9ca0e..3141a624194 100644
--- a/htdocs/accountancy/admin/fiscalyear_info.php
+++ b/htdocs/accountancy/admin/fiscalyear_info.php
@@ -58,5 +58,6 @@ if ($id) {
print '' . $langs->trans("DateEnd") . ' ';
- print $form->select_date($object->date_end ? $object->date_end : - 1, 'fiscalyearend');
+ print $form->selectDate($object->date_end ? $object->date_end : - 1, 'fiscalyearend');
print ' ';
-
+
print '';
print '';
} else {
print $db->error();
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/accountancy/admin/index.php b/htdocs/accountancy/admin/index.php
index e39d07fc35d..a17ee45ae4d 100644
--- a/htdocs/accountancy/admin/index.php
+++ b/htdocs/accountancy/admin/index.php
@@ -295,5 +295,6 @@ print '
';
print '
';
print '';
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/accountancy/admin/journals_list.php b/htdocs/accountancy/admin/journals_list.php
index ff3a38769b8..20d0a5200a5 100644
--- a/htdocs/accountancy/admin/journals_list.php
+++ b/htdocs/accountancy/admin/journals_list.php
@@ -128,16 +128,16 @@ complete_dictionary_with_modules($taborder,$tabname,$tablib,$tabsql,$tabsqlsort,
// Define elementList and sourceList (used for dictionary type of contacts "llx_c_type_contact")
$elementList = array();
- // Must match ids defined into eldy.lib.php
- $sourceList = array(
- '1' => $langs->trans('AccountingJournalType1'),
- '2' => $langs->trans('AccountingJournalType2'),
- '3' => $langs->trans('AccountingJournalType3'),
- '4' => $langs->trans('AccountingJournalType4'),
- '5' => $langs->trans('AccountingJournalType5'),
- '8' => $langs->trans('AccountingJournalType8'),
- '9' => $langs->trans('AccountingJournalType9')
- );
+// Must match ids defined into eldy.lib.php
+$sourceList = array(
+ '1' => $langs->trans('AccountingJournalType1'),
+ '2' => $langs->trans('AccountingJournalType2'),
+ '3' => $langs->trans('AccountingJournalType3'),
+ '4' => $langs->trans('AccountingJournalType4'),
+ '5' => $langs->trans('AccountingJournalType5'),
+ '8' => $langs->trans('AccountingJournalType8'),
+ '9' => $langs->trans('AccountingJournalType9'),
+);
/*
* Actions
@@ -294,10 +294,10 @@ if (GETPOST('actionadd') || GETPOST('actionmodify'))
//$_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition
}
-if (GETPOST('actioncancel'))
-{
- //$_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition
-}
+//if (GETPOST('actioncancel'))
+//{
+// $_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition
+//}
if ($action == 'confirm_delete' && $confirm == 'yes') // delete
{
@@ -683,7 +683,7 @@ if ($id)
print '
';
-
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php
index 070e2f353c3..2467b89b108 100644
--- a/htdocs/accountancy/admin/productaccount.php
+++ b/htdocs/accountancy/admin/productaccount.php
@@ -495,5 +495,6 @@ if ($result)
dol_print_error($db);
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php
index 284ead4fb56..e3290f1e542 100644
--- a/htdocs/accountancy/bookkeeping/balance.php
+++ b/htdocs/accountancy/bookkeeping/balance.php
@@ -1,7 +1,8 @@
- * Copyright (C) 2016 Florian Henry ';
print ' ';
@@ -432,7 +433,7 @@ if ($action == 'create')
print '';
print '';
print '';
- $form->select_date($object->doc_date ? $object->doc_date : - 1, 'doc_date', '', '', '', "setdate");
+ print $form->selectDate($object->doc_date ? $object->doc_date : - 1, 'doc_date', '', '', '', "setdate");
print '';
print '';
} else {
@@ -714,5 +715,6 @@ if ($action == 'create')
dol_fiche_end();
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php
index b0a91f7ce36..132aa4e0afa 100644
--- a/htdocs/accountancy/bookkeeping/list.php
+++ b/htdocs/accountancy/bookkeeping/list.php
@@ -3,6 +3,7 @@
* Copyright (C) 2013-2016 Florian Henry ' . $langs->trans("Docdate") . ' ';
print '';
- print $html->select_date('', 'doc_date', '', '', '', "create_mvt", 1, 1);
+ print $html->selectDate('', 'doc_date', '', '', '', "create_mvt", 1, 1);
print ' ';
print '';
print ' ';
}
@@ -556,11 +557,11 @@ if (! empty($arrayfields['t.date_creation']['checked']))
print '';
print ' ';
}
@@ -570,11 +571,11 @@ if (! empty($arrayfields['t.tms']['checked']))
print '';
print ' ';
}
@@ -748,6 +749,6 @@ print '';
print ' ';
print $langs->trans('From') . ': ';
-print $form->select_date($search_date_start, 'search_date_start', 0, 0, 1);
+print $form->selectDate($search_date_start, 'search_date_start', 0, 0, 1);
print ' ';
print '
';
print $langs->trans('to') . ': ';
-print $form->select_date($search_date_end, 'search_date_end', 0, 0, 1);
+print $form->selectDate($search_date_end, 'search_date_end', 0, 0, 1);
print '';
print ' ';
@@ -421,5 +422,6 @@ print '';
print "";
print '';
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/accountancy/bookkeeping/thirdparty_lettrage.php b/htdocs/accountancy/bookkeeping/thirdparty_lettrage.php
index 9bf287bf3c9..be335107839 100644
--- a/htdocs/accountancy/bookkeeping/thirdparty_lettrage.php
+++ b/htdocs/accountancy/bookkeeping/thirdparty_lettrage.php
@@ -2,7 +2,7 @@
/* Copyright (C) 2004-2005 Rodolphe Quiedeville ";
+ print ' ';
if (empty($obj->lettering_code)) {
print ' ';
@@ -293,14 +292,13 @@ if ($resql) {
}
print ' ';
-
print ' \n";
- print "Mouvement totaux ' . "\n";
print '' . price($debit) . ' ';
print '' . price($credit) . ' ';
print '';
print " ";
+ print ' ';
print ' ';
- $var = false;
$solde = 0;
$tmp = '';
while ($obj = $db->fetch_object($resql)) {
@@ -281,11 +281,10 @@ if ($resql) {
$tmp = $obj->lettering_code;
if ($tmp != $obj->lettering_code || empty($obj->lettering_code))
- $var = ! $var;
$solde += ($obj->credit - $obj->debit);
- print "Solde Comptable ' . "\n";
print '' . price($credit - $debit) . ' ';
print '';
diff --git a/htdocs/accountancy/bookkeeping/thirdparty_lettrage_supplier.php b/htdocs/accountancy/bookkeeping/thirdparty_lettrage_supplier.php
index cf278c26903..905361b4c8e 100644
--- a/htdocs/accountancy/bookkeeping/thirdparty_lettrage_supplier.php
+++ b/htdocs/accountancy/bookkeeping/thirdparty_lettrage_supplier.php
@@ -2,7 +2,7 @@
/* Copyright (C) 2004-2005 Rodolphe Quiedeville ";
+ print ' ';
if (empty($obj->lettering_code)) {
print ' \n";
- print "';
@@ -320,7 +319,7 @@ if ($resql) {
print ' ';
print " ";
+ print ' ';
print ' Solde Comptable ' . "\n";
print '' . price($credit - $debit) . ' ';
print '';
diff --git a/htdocs/accountancy/class/accountancycategory.class.php b/htdocs/accountancy/class/accountancycategory.class.php
index 27254ef31d1..b0c3adb7edd 100644
--- a/htdocs/accountancy/class/accountancycategory.class.php
+++ b/htdocs/accountancy/class/accountancycategory.class.php
@@ -28,27 +28,97 @@ require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
/**
* Class to manage categories of an accounting account
*/
-class AccountancyCategory // extends CommonObject
+class AccountancyCategory // extends CommonObject
{
- public $db; //!< To store db handler
- public $error; //!< To return error code (or message)
- public $errors=array(); //!< To return several error codes (or messages)
- public $element='c_accounting_category'; //!< Id that identify managed objects
- public $table_element='c_accounting_category'; //!< Name of table without prefix where object is stored
+ /**
+ * @var DoliDB Database handler.
+ */
+ public $db;
- public $id;
+ /**
+ * @var string Error string
+ * @see errors
+ */
+ public $error;
+
+ /**
+ * @var string[] Error codes (or messages)
+ */
+ public $errors = array();
+
+ /**
+ * @var string ID to identify managed object
+ */
+ public $element='c_accounting_category';
+
+ /**
+ * @var string Name of table without prefix where object is stored
+ */
+ public $table_element='c_accounting_category';
+
+ /**
+ * @var int ID
+ */
+ public $id;
+
+ /**
+ * @var mixed Sample property 1
+ */
public $code;
- public $label;
+
+ /**
+ * @var string Accountancy Category label
+ */
+ public $label;
+
+ /**
+ * @var mixed Sample property 1
+ */
public $range_account;
+
+ /**
+ * @var mixed Sample property 1
+ */
public $sens;
+
+ /**
+ * @var mixed Sample property 1
+ */
public $category_type;
+
+ /**
+ * @var mixed Sample property 1
+ */
public $formula;
+
+ /**
+ * @var mixed Sample property 1
+ */
public $position;
+
+ /**
+ * @var mixed Sample property 1
+ */
public $fk_country;
+
+ /**
+ * @var mixed Sample property 1
+ */
public $active;
+ /**
+ * @var mixed Sample property 1
+ */
public $lines_cptbk;
+
+ /**
+ * @var mixed Sample property 1
+ */
public $lines_display;
+
+ /**
+ * @var mixed Sample property 1
+ */
public $sdc;
@@ -125,18 +195,18 @@ class AccountancyCategory // extends CommonObject
{
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."c_accounting_category");
- if (! $notrigger)
- {
- // Uncomment this and change MYOBJECT to your own tag if you
- // want this action call a trigger.
+ // Uncomment this and change MYOBJECT to your own tag if you
+ // want this action call a trigger.
+ //if (! $notrigger)
+ //{
- //// Call triggers
- //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
- //$interface=new Interfaces($this->db);
- //$result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf);
- //if ($result < 0) { $error++; $this->errors=$interface->errors; }
- //// End call triggers
- }
+ // // Call triggers
+ // include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
+ // $interface=new Interfaces($this->db);
+ // $result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf);
+ // if ($result < 0) { $error++; $this->errors=$interface->errors; }
+ // // End call triggers
+ //}
}
// Commit or rollback
@@ -264,18 +334,17 @@ class AccountancyCategory // extends CommonObject
if (! $error)
{
- if (! $notrigger)
- {
- // Uncomment this and change MYOBJECT to your own tag if you
- // want this action call a trigger.
-
- //// Call triggers
- //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
- //$interface=new Interfaces($this->db);
- //$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf);
- //if ($result < 0) { $error++; $this->errors=$interface->errors; }
- //// End call triggers
- }
+ // Uncomment this and change MYOBJECT to your own tag if you
+ // want this action call a trigger.
+ //if (! $notrigger)
+ //{
+ // // Call triggers
+ // include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
+ // $interface=new Interfaces($this->db);
+ // $result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf);
+ // if ($result < 0) { $error++; $this->errors=$interface->errors; }
+ // // End call triggers
+ //}
}
// Commit or rollback
@@ -320,18 +389,17 @@ class AccountancyCategory // extends CommonObject
if (! $error)
{
- if (! $notrigger)
- {
- // Uncomment this and change MYOBJECT to your own tag if you
- // want this action call a trigger.
-
- //// Call triggers
- //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
- //$interface=new Interfaces($this->db);
- //$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf);
- //if ($result < 0) { $error++; $this->errors=$interface->errors; }
- //// End call triggers
- }
+ // Uncomment this and change MYOBJECT to your own tag if you
+ // want this action call a trigger.
+ //if (! $notrigger)
+ //{
+ // // Call triggers
+ // include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
+ // $interface=new Interfaces($this->db);
+ // $result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf);
+ // if ($result < 0) { $error++; $this->errors=$interface->errors; }
+ // // End call triggers
+ //}
}
// Commit or rollback
@@ -359,7 +427,8 @@ class AccountancyCategory // extends CommonObject
* @param int $id Id
* @return int <0 if KO, 0 if not found, >0 if OK
*/
- public function display($id) {
+ public function display($id)
+ {
global $conf;
$sql = "SELECT t.rowid, t.account_number, t.label";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as t";
@@ -394,7 +463,8 @@ class AccountancyCategory // extends CommonObject
*
* @return int <0 if KO, 0 if not found, >0 if OK
*/
- public function getCptBK($id) {
+ public function getCptBK($id)
+ {
global $conf;
$sql = "SELECT t.numero_compte, t.label_operation, t.doc_ref";
@@ -442,8 +512,9 @@ class AccountancyCategory // extends CommonObject
*
* @return int <0 if KO, 0 if not found, >0 if OK
*/
- public function getAccountsWithNoCategory($id) {
- global $conf;
+ public function getAccountsWithNoCategory($id)
+ {
+ global $conf;
$sql = "SELECT aa.account_number as numero_compte, aa.label as label_compte";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa";
@@ -485,7 +556,8 @@ class AccountancyCategory // extends CommonObject
*
* @return int <0 if KO, >0 if OK
*/
- public function updateAccAcc($id_cat, $cpts = array()) {
+ public function updateAccAcc($id_cat, $cpts = array())
+ {
global $conf;
$error = 0;
@@ -548,7 +620,8 @@ class AccountancyCategory // extends CommonObject
*
* @return int <0 if KO, >0 if OK
*/
- public function deleteCptCat($cpt_id) {
+ public function deleteCptCat($cpt_id)
+ {
$error = 0;
$sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_account as aa";
@@ -799,5 +872,4 @@ class AccountancyCategory // extends CommonObject
return -1;
}
}
-
}
diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php
index 52b5f1c411f..40427d68034 100644
--- a/htdocs/accountancy/class/accountancyexport.class.php
+++ b/htdocs/accountancy/class/accountancyexport.class.php
@@ -55,11 +55,11 @@ class AccountancyExport
public static $EXPORT_TYPE_AGIRIS = 9;
public static $EXPORT_TYPE_CONFIGURABLE = 10;
+
/**
- *
* @var string[] Error codes (or messages)
*/
- public $errors = array ();
+ public $errors = array();
/**
*
@@ -78,7 +78,8 @@ class AccountancyExport
*
* @param DoliDb $db Database handler
*/
- public function __construct(DoliDB &$db) {
+ public function __construct(DoliDB &$db)
+ {
global $conf;
$this->db = &$db;
@@ -91,7 +92,8 @@ class AccountancyExport
*
* @return array of type
*/
- public static function getType() {
+ public static function getType()
+ {
global $langs;
return array (
@@ -113,7 +115,8 @@ class AccountancyExport
*
* @return array of type
*/
- public static function getTypeConfig() {
+ public static function getTypeConfig()
+ {
global $conf, $langs;
return array (
@@ -175,7 +178,8 @@ class AccountancyExport
*
* @return void
*/
- public static function downloadFile() {
+ public static function downloadFile()
+ {
global $conf;
$filename = 'general_ledger';
include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php';
@@ -185,8 +189,10 @@ class AccountancyExport
* Function who chose which export to use with the default config
*
* @param unknown $TData data
+ * @return void
*/
- public function export(&$TData) {
+ public function export(&$TData)
+ {
global $conf, $langs;
self::downloadFile();
@@ -235,7 +241,8 @@ class AccountancyExport
*
* @return void
*/
- public function exportNormal($objectLines) {
+ public function exportNormal($objectLines)
+ {
global $conf;
foreach ( $objectLines as $line ) {
@@ -259,7 +266,8 @@ class AccountancyExport
*
* @return void
*/
- public function exportCegid($objectLines) {
+ public function exportCegid($objectLines)
+ {
foreach ( $objectLines as $line ) {
$date = dol_print_date($line->doc_date, '%d%m%Y');
$separator = ";";
@@ -284,7 +292,8 @@ class AccountancyExport
*
* @return void
*/
- public function exportCogilog($objectLines) {
+ public function exportCogilog($objectLines)
+ {
foreach ( $objectLines as $line ) {
$date = dol_print_date($line->doc_date, '%d%m%Y');
$separator = ";";
@@ -317,7 +326,8 @@ class AccountancyExport
*
* @return void
*/
- public function exportCoala($objectLines) {
+ public function exportCoala($objectLines)
+ {
// Coala export
$separator = ";";
$end_line = "\n";
@@ -344,7 +354,8 @@ class AccountancyExport
*
* @return void
*/
- public function exportBob50($objectLines) {
+ public function exportBob50($objectLines)
+ {
// Bob50
$separator = ";";
@@ -382,7 +393,8 @@ class AccountancyExport
*
* @return void
*/
- public function exportCiel(&$TData) {
+ public function exportCiel(&$TData)
+ {
global $conf;
$end_line ="\r\n";
@@ -422,7 +434,8 @@ class AccountancyExport
*
* @return void
*/
- public function exportQuadratus(&$TData) {
+ public function exportQuadratus(&$TData)
+ {
global $conf;
$end_line ="\r\n";
@@ -505,7 +518,8 @@ class AccountancyExport
*
* @return void
*/
- public function exportEbp($objectLines) {
+ public function exportEbp($objectLines)
+ {
$separator = ',';
$end_line = "\n";
@@ -537,7 +551,8 @@ class AccountancyExport
*
* @return void
*/
- public function exportAgiris($objectLines) {
+ public function exportAgiris($objectLines)
+ {
$separator = ';';
$end_line = "\n";
@@ -574,7 +589,8 @@ class AccountancyExport
*
* @return void
*/
- public function exportConfigurable($objectLines) {
+ public function exportConfigurable($objectLines)
+ {
global $conf;
foreach ($objectLines as $line) {
@@ -602,8 +618,10 @@ class AccountancyExport
*
* @param unknown $str data
* @param integer $size data
+ * @return string
*/
- public static function trunc($str, $size) {
+ public static function trunc($str, $size)
+ {
return dol_trunc($str, $size, 'right', 'UTF-8', 1);
}
}
diff --git a/htdocs/accountancy/class/accountancysystem.class.php b/htdocs/accountancy/class/accountancysystem.class.php
index f14a3e7f761..d126bd84acc 100644
--- a/htdocs/accountancy/class/accountancysystem.class.php
+++ b/htdocs/accountancy/class/accountancysystem.class.php
@@ -28,13 +28,26 @@
*/
class AccountancySystem
{
- var $db;
- var $error;
+ /**
+ * @var DoliDB Database handler.
+ */
+ public $db;
+
+ /**
+ * @var string Error code (or message)
+ */
+ public $error='';
+
var $rowid;
var $fk_pcg_version;
var $pcg_type;
var $pcg_subtype;
- var $label;
+
+ /**
+ * @var string Accountancy System label
+ */
+ public $label;
+
var $account_number;
var $account_parent;
@@ -43,7 +56,8 @@ class AccountancySystem
*
* @param DoliDB $db handler
*/
- function __construct($db) {
+ function __construct($db)
+ {
$this->db = $db;
}
@@ -102,7 +116,8 @@ class AccountancySystem
* @param User $user making insert
* @return int if KO, Id of line if OK
*/
- function create($user) {
+ function create($user)
+ {
$now = dol_now();
$sql = "INSERT INTO " . MAIN_DB_PREFIX . "accounting_system";
@@ -130,4 +145,4 @@ class AccountancySystem
return $result;
}
-}
\ No newline at end of file
+}
diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php
index 257c2af0111..4929e118a3b 100644
--- a/htdocs/accountancy/class/accountingaccount.class.php
+++ b/htdocs/accountancy/class/accountingaccount.class.php
@@ -31,7 +31,15 @@
class AccountingAccount extends CommonObject
{
public $element='accounting_account';
+
+ /**
+ * @var string Name of table without prefix where object is stored
+ */
public $table_element='accounting_account';
+
+ /**
+ * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
+ */
public $picto = 'billr';
/**
@@ -39,29 +47,63 @@ class AccountingAccount extends CommonObject
* @var int
*/
public $ismultientitymanaged = 1;
+
/**
* 0=Default, 1=View may be restricted to sales representative only if no permission to see all or to company of external user if external user
* @var integer
*/
public $restrictiononfksoc = 1;
- var $db;
- var $error;
- var $errors;
- var $id;
- var $rowid;
- var $datec; // Creation date
- var $fk_pcg_version;
- var $pcg_type;
- var $pcg_subtype;
- var $account_number;
- var $account_parent;
- var $account_category;
- var $label;
- var $fk_user_author;
- var $fk_user_modif;
- var $active; // duplicate with status
- var $status;
+ /**
+ * @var DoliDB Database handler.
+ */
+ public $db;
+
+ /**
+ * @var string Error code (or message)
+ */
+ public $error='';
+
+ /**
+ * @var string[] Error codes (or messages)
+ */
+ public $errors = array();
+
+ /**
+ * @var int ID
+ */
+ public $id;
+
+ /**
+ * @var int ID
+ */
+ public $rowid;
+
+ public $datec; // Creation date
+ public $fk_pcg_version;
+ public $pcg_type;
+ public $pcg_subtype;
+ public $account_number;
+ public $account_parent;
+ public $account_category;
+ public $status;
+
+ /**
+ * @var string Label of account
+ */
+ public $label;
+
+ /**
+ * @var int ID
+ */
+ public $fk_user_author;
+
+ /**
+ * @var int ID
+ */
+ public $fk_user_modif;
+
+ public $active; // duplicate with status
/**
@@ -69,7 +111,8 @@ class AccountingAccount extends CommonObject
*
* @param DoliDB $db Database handle
*/
- function __construct($db) {
+ function __construct($db)
+ {
global $conf;
$this->db = $db;
@@ -146,7 +189,8 @@ class AccountingAccount extends CommonObject
* @param int $notrigger Disable triggers
* @return int <0 if KO, >0 if OK
*/
- function create($user, $notrigger = 0) {
+ function create($user, $notrigger = 0)
+ {
global $conf;
$error = 0;
$now = dol_now();
@@ -297,7 +341,8 @@ class AccountingAccount extends CommonObject
*
* @return int <0 if KO, >0 if OK
*/
- function checkUsage() {
+ function checkUsage()
+ {
global $langs;
$sql = "(SELECT fk_code_ventilation FROM " . MAIN_DB_PREFIX . "facturedet";
@@ -330,7 +375,8 @@ class AccountingAccount extends CommonObject
* @param int $notrigger 0=triggers after, 1=disable triggers
* @return int <0 if KO, >0 if OK
*/
- function delete($user, $notrigger = 0) {
+ function delete($user, $notrigger = 0)
+ {
$error = 0;
$result = $this->checkUsage();
@@ -391,7 +437,7 @@ class AccountingAccount extends CommonObject
* @param string $moretitle Add more text to title tooltip
* @param int $notooltip 1=Disable tooltip
* @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
- * @return string String with URL
+ * @return string String with URL
*/
function getNomUrl($withpicto = 0, $withlabel = 0, $nourl = 0, $moretitle='',$notooltip=0, $save_lastsearch_value=-1)
{
@@ -457,7 +503,8 @@ class AccountingAccount extends CommonObject
* @param int $id of record
* @return void
*/
- function info($id) {
+ function info($id)
+ {
$sql = 'SELECT a.rowid, a.datec, a.fk_user_author, a.fk_user_modif, a.tms';
$sql .= ' FROM ' . MAIN_DB_PREFIX . 'accounting_account as a';
$sql .= ' WHERE a.rowid = ' . $id;
@@ -488,13 +535,16 @@ class AccountingAccount extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Account deactivated
*
* @param int $id Id
* @return int <0 if KO, >0 if OK
*/
- function account_desactivate($id) {
+ function account_desactivate($id)
+ {
+ // phpcs:enable
$result = $this->checkUsage();
if ($result > 0) {
@@ -520,13 +570,16 @@ class AccountingAccount extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Account activated
*
* @param int $id Id
* @return int <0 if KO, >0 if OK
*/
- function account_activate($id) {
+ function account_activate($id)
+ {
+ // phpcs:enable
$this->db->begin();
$sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_account ";
@@ -557,6 +610,7 @@ class AccountingAccount extends CommonObject
return $this->LibStatut($this->status,$mode);
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Renvoi le libelle d'un statut donne
*
@@ -566,6 +620,7 @@ class AccountingAccount extends CommonObject
*/
function LibStatut($statut,$mode=0)
{
+ // phpcs:enable
global $langs;
$langs->loadLangs(array("users"));
@@ -575,27 +630,27 @@ class AccountingAccount extends CommonObject
if ($statut == 1) return $langs->trans('Enabled');
if ($statut == 0) return $langs->trans('Disabled');
}
- if ($mode == 1)
+ elseif ($mode == 1)
{
if ($statut == 1) return $langs->trans('Enabled');
if ($statut == 0) return $langs->trans('Disabled');
}
- if ($mode == 2)
+ elseif ($mode == 2)
{
if ($statut == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled');
if ($statut == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled');
}
- if ($mode == 3)
+ elseif ($mode == 3)
{
if ($statut == 1) return img_picto($langs->trans('Enabled'),'statut4');
if ($statut == 0) return img_picto($langs->trans('Disabled'),'statut5');
}
- if ($mode == 4)
+ elseif ($mode == 4)
{
if ($statut == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled');
if ($statut == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled');
}
- if ($mode == 5)
+ elseif ($mode == 5)
{
if ($statut == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4');
if ($statut == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5');
diff --git a/htdocs/accountancy/class/accountingjournal.class.php b/htdocs/accountancy/class/accountingjournal.class.php
index 454de6d7b84..058bdb3dddb 100644
--- a/htdocs/accountancy/class/accountingjournal.class.php
+++ b/htdocs/accountancy/class/accountingjournal.class.php
@@ -26,16 +26,40 @@
*/
class AccountingJournal extends CommonObject
{
+ /**
+ * @var string ID to identify managed object
+ */
public $element='accounting_journal';
+
+ /**
+ * @var string Name of table without prefix where object is stored
+ */
public $table_element='accounting_journal';
+
+ /**
+ * @var int Field with ID of parent key if this field has a parent
+ */
public $fk_element = '';
+
public $ismultientitymanaged = 0; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
+
+ /**
+ * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
+ */
public $picto = 'generic';
- var $rowid;
+ /**
+ * @var int ID
+ */
+ public $rowid;
public $code;
- public $label;
+
+ /**
+ * @var string Accounting Journal label
+ */
+ public $label;
+
public $nature; // 1:various operations, 2:sale, 3:purchase, 4:bank, 5:expense-report, 8:inventory, 9: has-new
public $active;
@@ -46,7 +70,8 @@ class AccountingJournal extends CommonObject
*
* @param DoliDB $db Database handle
*/
- function __construct($db) {
+ function __construct($db)
+ {
$this->db = $db;
}
@@ -117,7 +142,8 @@ class AccountingJournal extends CommonObject
*
* @return int <0 if KO, >0 if OK
*/
- function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') {
+ function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND')
+ {
$sql = "SELECT rowid, code, label, nature, active";
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t';
// Manage filter
@@ -245,6 +271,7 @@ class AccountingJournal extends CommonObject
return $this->LibType($this->nature,$mode);
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Return type of an accounting journal
*
@@ -254,6 +281,7 @@ class AccountingJournal extends CommonObject
*/
function LibType($nature,$mode=0)
{
+ // phpcs:enable
global $langs;
$langs->loadLangs(array("accountancy"));
diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php
index f7fed2e2b5b..5d9572da684 100644
--- a/htdocs/accountancy/class/bookkeeping.class.php
+++ b/htdocs/accountancy/class/bookkeeping.class.php
@@ -35,19 +35,25 @@ class BookKeeping extends CommonObject
* @var string Error code (or message)
*/
public $error;
+
/**
* @var string[] Error codes (or messages)
*/
- public $errors = array ();
+ public $errors = array();
+
/**
* @var string Id to identify managed objects
*/
public $element = 'accountingbookkeeping';
+
/**
* @var string Name of table without prefix where object is stored
*/
public $table_element = 'accounting_bookkeeping';
+ /**
+ * @var int Entity
+ */
public $entity;
/**
@@ -59,8 +65,7 @@ class BookKeeping extends CommonObject
* @var int ID
*/
public $id;
- /**
- */
+
public $doc_date;
public $date_lim_reglement;
public $doc_type;
@@ -88,7 +93,8 @@ class BookKeeping extends CommonObject
*
* @param DoliDb $db Database handler
*/
- public function __construct(DoliDB $db) {
+ public function __construct(DoliDB $db)
+ {
$this->db = $db;
}
@@ -99,7 +105,8 @@ class BookKeeping extends CommonObject
* @param bool $notrigger false=launch triggers after, true=disable triggers
* @return int <0 if KO, Id of created object if OK
*/
- public function create(User $user, $notrigger = false) {
+ public function create(User $user, $notrigger = false)
+ {
global $conf, $langs;
dol_syslog(__METHOD__, LOG_DEBUG);
@@ -328,18 +335,15 @@ class BookKeeping extends CommonObject
dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR);
}
- if (! $error) {
+ // Uncomment this and change MYOBJECT to your own tag if you
+ // want this action to call a trigger.
+ //if (! $error && ! $notrigger) {
- if (! $notrigger) {
- // Uncomment this and change MYOBJECT to your own tag if you
- // want this action to call a trigger.
-
- // // Call triggers
- // $result=$this->call_trigger('MYOBJECT_CREATE',$user);
- // if ($result < 0) $error++;
- // // End call triggers
- }
- }
+ // // Call triggers
+ // $result=$this->call_trigger('MYOBJECT_CREATE',$user);
+ // if ($result < 0) $error++;
+ // // End call triggers
+ //}
// Commit or rollback
if ($error) {
@@ -420,7 +424,8 @@ class BookKeeping extends CommonObject
* @param string $mode Mode
* @return int <0 if KO, Id of created object if OK
*/
- public function createStd(User $user, $notrigger = false, $mode='') {
+ public function createStd(User $user, $notrigger = false, $mode='')
+ {
global $conf;
dol_syslog(__METHOD__, LOG_DEBUG);
@@ -558,15 +563,15 @@ class BookKeeping extends CommonObject
if (! $error) {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element . $mode);
- if (! $notrigger) {
- // Uncomment this and change MYOBJECT to your own tag if you
- // want this action to call a trigger.
+ // Uncomment this and change MYOBJECT to your own tag if you
+ // want this action to call a trigger.
+ //if (! $notrigger) {
- // // Call triggers
- // $result=$this->call_trigger('MYOBJECT_CREATE',$user);
- // if ($result < 0) $error++;
- // // End call triggers
- }
+ // // Call triggers
+ // $result=$this->call_trigger('MYOBJECT_CREATE',$user);
+ // if ($result < 0) $error++;
+ // // End call triggers
+ //}
}
// Commit or rollback
@@ -590,7 +595,8 @@ class BookKeeping extends CommonObject
*
* @return int <0 if KO, 0 if not found, >0 if OK
*/
- public function fetch($id, $ref = null, $mode='') {
+ public function fetch($id, $ref = null, $mode='')
+ {
global $conf;
dol_syslog(__METHOD__, LOG_DEBUG);
@@ -687,7 +693,8 @@ class BookKeeping extends CommonObject
*
* @return int <0 if KO, >=0 if OK
*/
- public function fetchAllByAccount($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') {
+ public function fetchAllByAccount($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND')
+ {
global $conf;
dol_syslog(__METHOD__, LOG_DEBUG);
@@ -811,7 +818,8 @@ class BookKeeping extends CommonObject
*
* @return int <0 if KO, >0 if OK
*/
- public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') {
+ public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND')
+ {
global $conf;
dol_syslog(__METHOD__, LOG_DEBUG);
@@ -1016,7 +1024,8 @@ class BookKeeping extends CommonObject
* @param string $mode Mode
* @return int <0 if KO, >0 if OK
*/
- public function update(User $user, $notrigger = false, $mode='') {
+ public function update(User $user, $notrigger = false, $mode='')
+ {
$error = 0;
dol_syslog(__METHOD__, LOG_DEBUG);
@@ -1119,15 +1128,15 @@ class BookKeeping extends CommonObject
dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR);
}
- if (! $error && ! $notrigger) {
- // Uncomment this and change MYOBJECT to your own tag if you
- // want this action calls a trigger.
+ // Uncomment this and change MYOBJECT to your own tag if you
+ // want this action calls a trigger.
+ //if (! $error && ! $notrigger) {
- // // Call triggers
- // $result=$this->call_trigger('MYOBJECT_MODIFY',$user);
- // if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail}
- // // End call triggers
- }
+ // // Call triggers
+ // $result=$this->call_trigger('MYOBJECT_MODIFY',$user);
+ // if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail}
+ // // End call triggers
+ //}
// Commit or rollback
if ($error) {
@@ -1185,24 +1194,23 @@ class BookKeeping extends CommonObject
* @param string $mode Mode
* @return int <0 if KO, >0 if OK
*/
- public function delete(User $user, $notrigger = false, $mode='') {
+ public function delete(User $user, $notrigger = false, $mode='')
+ {
dol_syslog(__METHOD__, LOG_DEBUG);
$error = 0;
$this->db->begin();
- if (! $error) {
- if (! $notrigger) {
- // Uncomment this and change MYOBJECT to your own tag if you
- // want this action calls a trigger.
+ // Uncomment this and change MYOBJECT to your own tag if you
+ // want this action calls a trigger.
+ //if (! $error && ! $notrigger) {
- // // Call triggers
- // $result=$this->call_trigger('MYOBJECT_DELETE',$user);
- // if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail}
- // // End call triggers
- }
- }
+ // // Call triggers
+ // $result=$this->call_trigger('MYOBJECT_DELETE',$user);
+ // if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail}
+ // // End call triggers
+ //}
if (! $error) {
$sql = 'DELETE FROM ' . MAIN_DB_PREFIX . $this->table_element.$mode;
@@ -1234,7 +1242,8 @@ class BookKeeping extends CommonObject
* @param string $importkey Import key
* @return int Result
*/
- function deleteByImportkey($importkey) {
+ function deleteByImportkey($importkey)
+ {
$this->db->begin();
// first check if line not yet in bookkeeping
@@ -1263,7 +1272,8 @@ class BookKeeping extends CommonObject
* @param string $mode Mode
* @return int <0 if KO, >0 if OK
*/
- function deleteByYearAndJournal($delyear='', $journal='', $mode='') {
+ function deleteByYearAndJournal($delyear='', $journal='', $mode='')
+ {
global $conf;
if (empty($delyear) && empty($journal))
@@ -1302,7 +1312,8 @@ class BookKeeping extends CommonObject
* @param int $piecenum Piecenum to delete
* @return int Result
*/
- function deleteMvtNum($piecenum) {
+ function deleteMvtNum($piecenum)
+ {
global $conf;
$this->db->begin();
@@ -1336,7 +1347,8 @@ class BookKeeping extends CommonObject
*
* @return int New id of clone
*/
- public function createFromClone($fromid) {
+ public function createFromClone($fromid)
+ {
dol_syslog(__METHOD__, LOG_DEBUG);
global $user;
@@ -1381,7 +1393,8 @@ class BookKeeping extends CommonObject
*
* @return void
*/
- public function initAsSpecimen() {
+ public function initAsSpecimen()
+ {
global $user;
$now=dol_now();
@@ -1417,7 +1430,8 @@ class BookKeeping extends CommonObject
* @param string $mode Mode
* @return int <0 if KO, >0 if OK
*/
- public function fetchPerMvt($piecenum, $mode='') {
+ public function fetchPerMvt($piecenum, $mode='')
+ {
global $conf;
$sql = "SELECT piece_num,doc_date,code_journal,journal_label,doc_ref,doc_type,date_creation";
@@ -1481,7 +1495,8 @@ class BookKeeping extends CommonObject
* @param string $mode Mode
* @return int <0 if KO, >0 if OK
*/
- function fetchAllPerMvt($piecenum, $mode='') {
+ function fetchAllPerMvt($piecenum, $mode='')
+ {
global $conf;
$sql = "SELECT rowid, doc_date, doc_type,";
@@ -1533,13 +1548,16 @@ class BookKeeping extends CommonObject
return 1;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Export bookkeping
*
* @param string $model Model
* @return int Result
*/
- function export_bookkeping($model = 'ebp') {
+ function export_bookkeping($model = 'ebp')
+ {
+ // phpcs:enable
global $conf;
$sql = "SELECT rowid, doc_date, doc_type,";
@@ -1684,19 +1702,22 @@ class BookKeeping extends CommonObject
*/
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Return list of accounts with label by chart of accounts
*
- * @param string $selectid Preselected chart of accounts
- * @param string $htmlname Name of field in html form
+ * @param string $selectid Preselected chart of accounts
+ * @param string $htmlname Name of field in html form
* @param int $showempty Add an empty field
* @param array $event Event options
* @param int $select_in Value is a aa.rowid (0 default) or aa.account_number (1)
* @param int $select_out Set value returned by select 0=rowid (default), 1=account_number
* @param int $aabase Set accounting_account base class to display empty=all or from 1 to 8 will display only account beginning by this number
* @return string String with HTML select
- */
- function select_account($selectid, $htmlname = 'account', $showempty = 0, $event = array(), $select_in = 0, $select_out = 0, $aabase = '') {
+ */
+ function select_account($selectid, $htmlname = 'account', $showempty = 0, $event = array(), $select_in = 0, $select_out = 0, $aabase = '')
+ {
+ // phpcs:enable
global $conf;
require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
@@ -1753,6 +1774,7 @@ class BookKeeping extends CommonObject
return $out;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Description of a root accounting account
*
@@ -1761,6 +1783,7 @@ class BookKeeping extends CommonObject
*/
function get_compte_racine($account = null)
{
+ // phpcs:enable
global $conf;
$pcgver = $conf->global->CHARTOFACCOUNTS;
@@ -1793,6 +1816,7 @@ class BookKeeping extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Description of accounting account
*
@@ -1801,6 +1825,7 @@ class BookKeeping extends CommonObject
*/
function get_compte_desc($account = null)
{
+ // phpcs:enable
global $conf;
$pcgver = $conf->global->CHARTOFACCOUNTS;
@@ -1838,7 +1863,11 @@ class BookKeeping extends CommonObject
*/
class BookKeepingLine
{
+ /**
+ * @var int ID
+ */
public $id;
+
public $doc_date = '';
public $doc_type;
public $doc_ref;
diff --git a/htdocs/accountancy/customer/card.php b/htdocs/accountancy/customer/card.php
index 7e1387db951..677bc627c80 100644
--- a/htdocs/accountancy/customer/card.php
+++ b/htdocs/accountancy/customer/card.php
@@ -159,5 +159,6 @@ if (! empty($id)) {
print "Error ID incorrect";
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php
index 18e23826314..4f4932fe08f 100644
--- a/htdocs/accountancy/customer/index.php
+++ b/htdocs/accountancy/customer/index.php
@@ -89,7 +89,7 @@ if ($action == 'clean' || $action == 'validatehistory')
if (! $resql1) {
$error ++;
$db->rollback();
- setEventMessage($db->lasterror(), 'errors');
+ setEventMessages($db->lasterror(), null, 'errors');
} else {
$db->commit();
}
@@ -153,7 +153,7 @@ $y = $year_current;
$buttonbind = '' . $langs->trans("ValidateHistory") . '';
print_barre_liste($langs->trans("OverviewOfAmountOfLinesNotBound"), '', '', '', '', '', '', -1, '', '', 0, $buttonbind, '', 0, 1, 1);
-//print_fiche_titre($langs->trans("OverviewOfAmountOfLinesNotBound"), $buttonbind, '');
+//print load_fiche_titre($langs->trans("OverviewOfAmountOfLinesNotBound"), $buttonbind, '');
print ' ';
@@ -138,6 +143,6 @@ $message.=img_picto('','object_globe.png').' '.$langs->trans("WebDavServer",'Web
$message.='';
print $form->textwithpicto($langs->trans($key), $langs->trans($key.'Tooltip'));
print '
';
print $message;
-
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/admin/defaultvalues.php b/htdocs/admin/defaultvalues.php
index 0633ee90965..984ddfbefd7 100644
--- a/htdocs/admin/defaultvalues.php
+++ b/htdocs/admin/defaultvalues.php
@@ -34,7 +34,7 @@ if (!$user->admin) accessforbidden();
$id=GETPOST('rowid','int');
$action=GETPOST('action','alpha');
-$mode = GETPOST('mode')?GETPOST('mode'):'createform'; // 'createform', 'filters', 'sortorder', 'focus'
+$mode = GETPOST('mode','aZ09')?GETPOST('mode','aZ09'):'createform'; // 'createform', 'filters', 'sortorder', 'focus'
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha');
@@ -412,7 +412,6 @@ dol_fiche_end();
print "\n";
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/delais.php b/htdocs/admin/delais.php
index ae3c43c5b24..19fa67abcff 100644
--- a/htdocs/admin/delais.php
+++ b/htdocs/admin/delais.php
@@ -122,6 +122,13 @@ $modules=array(
),
);
+$labelmeteo = array(0=>$langs->trans("No"), 1=>$langs->trans("Yes"), 2=>$langs->trans("OnMobileOnly"));
+
+
+/*
+ * Actions
+ */
+
if ($action == 'update')
{
foreach($modules as $module => $delays)
@@ -201,9 +208,10 @@ if ($action == 'edit')
print '';
print '
';
}
@@ -241,7 +249,9 @@ else
print ' ';
- $var=false;
print ''.$langs->trans("Parameter").' '.$langs->trans("Value").' ';
- print ' ';
+ print ''.$langs->trans("MAIN_DISABLE_METEO").' ' .$form->selectyesno('MAIN_DISABLE_METEO',(empty($conf->global->MAIN_DISABLE_METEO)?0:1),1) . ' '.$langs->trans("MAIN_DISABLE_METEO").' ';
+ print $form->selectarray('MAIN_DISABLE_METEO', $labelmeteo, (empty($conf->global->MAIN_DISABLE_METEO)?0:$conf->global->MAIN_DISABLE_METEO));
+ print ' ';
print ' ';
print ''.$langs->trans("Parameter").' '.$langs->trans("Value").' ';
- print ' ';
+ print ''.$langs->trans("MAIN_DISABLE_METEO").' ' . yn($conf->global->MAIN_DISABLE_METEO) . ' '.$langs->trans("MAIN_DISABLE_METEO").' ';
+ print $labelmeteo[$conf->global->MAIN_DISABLE_METEO];
+ print ' ';
print '';
@@ -415,5 +425,6 @@ if($action == 'edit') {
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php
index e4f9fa1dd90..0c25f3a5bd8 100644
--- a/htdocs/admin/dict.php
+++ b/htdocs/admin/dict.php
@@ -379,7 +379,7 @@ $tabrowid[9] = "code_iso";
$tabrowid[10]= "";
$tabrowid[11]= "rowid";
$tabrowid[12]= "";
-$tabrowid[13]= "";
+$tabrowid[13]= "id";
$tabrowid[14]= "";
$tabrowid[15]= "";
$tabrowid[16]= "code";
@@ -1735,7 +1735,7 @@ else
print '
';
-
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/admin/dolistore/ajax/image.php b/htdocs/admin/dolistore/ajax/image.php
index 14d05a036e8..c1bb4e997dc 100644
--- a/htdocs/admin/dolistore/ajax/image.php
+++ b/htdocs/admin/dolistore/ajax/image.php
@@ -20,22 +20,11 @@ if (!defined('REQUIRE_JQUERY_BLOCKUI')) define('REQUIRE_JQUERY_BLOCKUI', 1);
/**
- * \file htdocs/commande/info.php
- * \ingroup commande
- * \brief Page des informations d'une commande
+ * \file htdocs/admin/dolistore/ajax/image.php
+ * \ingroup admin
+ * \brief Page des informations dolistore
*/
-$res = 0;
-if (!$res && file_exists("../main.inc.php")) $res = @include("../main.inc.php");
-if (!$res && file_exists("../../main.inc.php")) $res = @include("../../main.inc.php");
-if (!$res && file_exists("../../../main.inc.php")) $res = @include("../../../main.inc.php");
-if (!$res && file_exists("../../../../main.inc.php")) $res = @include("../../../../main.inc.php");
-if (!$res && file_exists("../../../dolibarr/htdocs/main.inc.php"))
- $res = @include("../../../dolibarr/htdocs/main.inc.php"); // Used on dev env only
-if (!$res && file_exists("../../../../dolibarr/htdocs/main.inc.php"))
- $res = @include("../../../../dolibarr/htdocs/main.inc.php"); // Used on dev env only
-if (!$res && file_exists("../../../../../dolibarr/htdocs/main.inc.php"))
- $res = @include("../../../../../dolibarr/htdocs/main.inc.php"); // Used on dev env only
-if (!$res) die("Include of main fails");
+require "../../../main.inc.php";
// CORE
@@ -52,8 +41,10 @@ $quality = GETPOST('quality', 'alpha');
try {
$url = $conf->global->MAIN_MODULE_DOLISTORE_API_SRV.'/api/images/products/'.$id_product.'/'.$id_image.'/'.$quality;
- $api = new PrestaShopWebservice($conf->global->MAIN_MODULE_DOLISTORE_API_SRV,
- $conf->global->MAIN_MODULE_DOLISTORE_API_KEY, $dolistore->debug_api);
+ $api = new PrestaShopWebservice(
+ $conf->global->MAIN_MODULE_DOLISTORE_API_SRV,
+ $conf->global->MAIN_MODULE_DOLISTORE_API_KEY, $dolistore->debug_api
+ );
//echo $url;
$request = $api->executeRequest($url, array(CURLOPT_CUSTOMREQUEST => 'GET'));
header('Content-type:image');
@@ -65,4 +56,3 @@ try {
else if ($trace[0]['args'][0] == 401) die('Bad auth key');
else die('Can not access to '.$conf->global->MAIN_MODULE_DOLISTORE_API_SRV);
}
-
diff --git a/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php b/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php
index de3ca683519..4617481d04d 100644
--- a/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php
+++ b/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php
@@ -53,7 +53,7 @@ class PrestaShopWebservice
* PrestaShopWebservice constructor. Throw an exception when CURL is not installed/activated
*
* url = $url;
@@ -82,6 +83,7 @@ class PrestaShopWebservice
* Take the status code and throw an exception if the server didn't return 200 or 201 code
*
* @param int $status_code Status code of an HTTP return
+ * @return void
*/
protected function checkStatusCode($status_code)
{
@@ -279,7 +281,7 @@ class PrestaShopWebservice
*
* 'PUT', CURLOPT_POSTFIELDS => $xml));
+ $request = self::executeRequest($url, array(CURLOPT_CUSTOMREQUEST => 'PUT', CURLOPT_POSTFIELDS => $xml));
self::checkStatusCode($request['status_code']);// check the response validity
return self::parseXML($request['response']);
}
diff --git a/htdocs/admin/dolistore/class/dolistore.class.php b/htdocs/admin/dolistore/class/dolistore.class.php
index 07dbec4b902..859b9140f86 100644
--- a/htdocs/admin/dolistore/class/dolistore.class.php
+++ b/htdocs/admin/dolistore/class/dolistore.class.php
@@ -25,9 +25,18 @@ include_once DOL_DOCUMENT_ROOT.'/admin/dolistore/class/PSWebServiceLibrary.class
*/
class Dolistore
{
- // params
- public $start; // beginning of pagination
- public $end; // end of pagination
+ /**
+ * beginning of pagination
+ * @var int
+ */
+
+ public $start;
+ /**
+ * end of pagination
+ * @var int
+ */
+ public $end;
+
public $per_page; // pagination: display per page
public $categorie; // the current categorie
public $search; // the search keywords
@@ -42,19 +51,21 @@ class Dolistore
/**
* Constructor
+ *
+ * @param boolean $debug Enable debug of request on screen
*/
- function __construct()
+ function __construct($debug=false)
{
global $conf, $langs;
$this->url = DOL_URL_ROOT.'/admin/modules.php?mode=marketplace';
$this->shop_url = 'https://www.dolistore.com/index.php?controller=product&id_product=';
$this->vat_rate = 1.2; // 20% de TVA
- $this->debug_api = false;
+ $this->debug_api = $debug;
$langtmp = explode('_', $langs->defaultlang);
$lang = $langtmp[0];
- $lang_array = array('en'=>0, 'fr'=>1, 'es'=>2, 'it'=>3, 'de'=>4); // Into table ps_lang of Prestashop - 1
+ $lang_array = array('en'=>1, 'fr'=>2, 'es'=>3, 'it'=>4, 'de'=>5); // Into table ps_lang of Prestashop - 1
if (! in_array($lang, array_keys($lang_array))) $lang = 'en';
$this->lang = $lang_array[$lang];
}
@@ -81,18 +92,25 @@ class Dolistore
}
try {
- $this->api = new PrestaShopWebservice($conf->global->MAIN_MODULE_DOLISTORE_API_SRV,
- $conf->global->MAIN_MODULE_DOLISTORE_API_KEY, $this->debug_api);
+ $this->api = new PrestaShopWebservice($conf->global->MAIN_MODULE_DOLISTORE_API_SRV, $conf->global->MAIN_MODULE_DOLISTORE_API_KEY, $this->debug_api);
+ dol_syslog("Call API with MAIN_MODULE_DOLISTORE_API_SRV = ".$conf->global->MAIN_MODULE_DOLISTORE_API_SRV);
+ // $conf->global->MAIN_MODULE_DOLISTORE_API_KEY is for the login of basic auth. There is no password as it is public data.
// Here we set the option array for the Webservice : we want products resources
$opt = array();
$opt['resource'] = 'products';
+ $opt2 = array();
// make a search to limit the id returned.
if ($this->search != '') {
- $opt2 = array();
$opt2['url'] = $conf->global->MAIN_MODULE_DOLISTORE_API_SRV.'/api/search?query='.$this->search.'&language='.$this->lang;
+
// Call
+ //var_dump($this->api);
+
+ dol_syslog("Call API with opt = ".var_export($opt, true));
+ dol_syslog("Call API with opt2 = ".var_export($opt2, true));
+
$xml = $this->api->get($opt2);
$products = array();
foreach ($xml->products->children() as $product) {
@@ -100,7 +118,6 @@ class Dolistore
}
$opt['filter[id]'] = '['.implode('|', $products).']';
} elseif ($this->categorie != 0) {
- $opt2 = array();
$opt2['resource'] = 'categories';
$opt2['id'] = $this->categorie;
// Call
@@ -117,7 +134,10 @@ class Dolistore
$opt['limit'] = "$this->start,$this->end";
// $opt['filter[id]'] contais list of product id that are result of search
+
// Call API to get the detail
+ dol_syslog("Call API with opt = ".var_export($opt, true));
+ dol_syslog("Call API with opt2 = ".var_export($opt2, true));
$xml = $this->api->get($opt);
$this->products = $xml->products->children();
@@ -135,10 +155,15 @@ class Dolistore
$trace = $e->getTrace();
if ($trace[0]['args'][0] == 404) die('Bad ID');
else if ($trace[0]['args'][0] == 401) die('Bad auth key');
- else die('Can not access to '.$conf->global->MAIN_MODULE_DOLISTORE_API_SRV);
+ else
+ {
+ print 'Can not access to '.$conf->global->MAIN_MODULE_DOLISTORE_API_SRV.'
';
+ print $e->getMessage();
+ }
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Return tree of Dolistore categories. $this->categories must have been loaded before.
*
@@ -147,6 +172,7 @@ class Dolistore
*/
function get_categories($parent = 0)
{
+ // phpcs:enable
if (!isset($this->categories)) die('not possible');
if ($parent != 0) {
$html = '';
@@ -186,6 +212,7 @@ class Dolistore
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Return list of product formated for output
*
@@ -193,6 +220,7 @@ class Dolistore
*/
function get_products()
{
+ // phpcs:enable
global $langs, $conf;
$html = "";
$parity = "pair";
@@ -267,18 +295,41 @@ class Dolistore
return $html;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
+ /**
+ * get previous link
+ *
+ * @param string $text symbol previous
+ * @return string html previous link
+ */
function get_previous_link($text = '<<')
{
+ // phpcs:enable
return ''.$text.'';
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
+ /**
+ * get next link
+ *
+ * @param string $text symbol next
+ * @return string html next link
+ */
function get_next_link($text = '>>')
{
+ // phpcs:enable
return ''.$text.'';
}
- function get_previous_url()
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
+ /**
+ * get previous url
+ *
+ * @return string previous url
+ */
+ function get_previous_url()
{
+ // phpcs:enable
$param_array = array();
if ($this->start < $this->per_page) {
$sub = 0;
@@ -294,8 +345,15 @@ class Dolistore
return $this->url."&".$param;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
+ /**
+ * get next url
+ *
+ * @return string next url
+ */
function get_next_url()
{
+ // phpcs:enable
$param_array = array();
if (count($this->products) < $this->per_page) {
$add = 0;
@@ -311,8 +369,17 @@ class Dolistore
return $this->url."&".$param;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
+ /**
+ * version compare
+ *
+ * @param string $v1 version 1
+ * @param string $v2 version 2
+ * @return int result of compare
+ */
function version_compare($v1, $v2)
{
+ // phpcs:enable
$v1 = explode('.', $v1);
$v2 = explode('.', $v2);
$ret = 0;
@@ -340,4 +407,3 @@ class Dolistore
return $ret;
}
}
-
diff --git a/htdocs/admin/dolistore/css/dolistore.css b/htdocs/admin/dolistore/css/dolistore.css
index bba808a21a0..fb4dc2d5bb1 100644
--- a/htdocs/admin/dolistore/css/dolistore.css
+++ b/htdocs/admin/dolistore/css/dolistore.css
@@ -6,10 +6,10 @@ div.divsearchfield {
}
.margeCoteGauche,.margeCote{
- padding-right: 20px!important;
+ padding-right: 20px!important;
}
.margeCote,.margeCoteDroite{
- padding-left: 20px!important;
+ padding-left: 20px!important;
}
.nomargesupinf{
margin-top: 0;
@@ -26,13 +26,13 @@ div.divsearchfield {
width: 100%;
}
.tree{
- margin: 0px 0px 0px 0px;
+ margin: 0px 0px 0px 0px;
padding:0px;
list-style: none; line-height: 2em; font-family: Arial;
}
.tree li{
font-size: 16px;
- position: relative;list-style: none;
+ position: relative;list-style: none;
}
.tree li:before{
position: absolute;
@@ -65,7 +65,7 @@ div.divsearchfield {
.tree li.root:after{
display: none;
}
-.tree li:last-child:after{
+.tree li:last-child:after{
display: none
}
.blockUI {
@@ -159,7 +159,7 @@ textarea.row4{
.reviewList {
max-height: 150px;
- overflow-y: scroll;
+ overflow-y: scroll;
}
.reviewRow{
diff --git a/htdocs/admin/ecm.php b/htdocs/admin/ecm.php
index dc2f3e489f7..3126f432938 100644
--- a/htdocs/admin/ecm.php
+++ b/htdocs/admin/ecm.php
@@ -109,5 +109,6 @@ print '';
print '';
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/admin/events.php b/htdocs/admin/events.php
index 1d1ec548853..dd3b1c5bff7 100644
--- a/htdocs/admin/events.php
+++ b/htdocs/admin/events.php
@@ -94,7 +94,7 @@ print "\n";
foreach ($eventstolog as $key => $arr)
{
if ($arr['id'])
- {
+ {
print '';
print ''.$arr['id'].' ';
print '';
@@ -114,6 +114,6 @@ print "";
print "\n";
-
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/admin/expedition.php b/htdocs/admin/expedition.php
index eb18f904229..c851010635e 100644
--- a/htdocs/admin/expedition.php
+++ b/htdocs/admin/expedition.php
@@ -507,5 +507,6 @@ print ''.$conf->currency.' ';
echo ''.$form->selectyesno('restrictive', 0, 1).' ';
echo ' ';
@@ -270,7 +271,7 @@ foreach ($rules as $rule)
echo '';
if ($action == 'edit' && $object->id == $rule->id)
{
- echo $form->select_date(strtotime(date('Y-m-d', $object->dates)), 'start', '', '', 0, '', 1, 0, 1);
+ print $form->selectDate(strtotime(date('Y-m-d', $object->dates)), 'start', '', '', 0, '', 1, 0);
}
else
{
@@ -282,7 +283,7 @@ foreach ($rules as $rule)
echo ' ';
if ($action == 'edit' && $object->id == $rule->id)
{
- echo $form->select_date(strtotime(date('Y-m-d', $object->datee)), 'end', '', '', 0, '', 1, 0, 1);
+ print $form->selectDate(strtotime(date('Y-m-d', $object->datee)), 'end', '', '', 0, '', 1, 0);
}
else
{
@@ -354,6 +355,7 @@ echo '';
dol_fiche_end();
-llxFooter();
+// End of page
+llxFooter();
$db->close();
diff --git a/htdocs/admin/export.php b/htdocs/admin/export.php
index b6f12a723ff..292c3604799 100644
--- a/htdocs/admin/export.php
+++ b/htdocs/admin/export.php
@@ -6,7 +6,7 @@
* Copyright (C) 2004 Eric Seigne
* Copyright (C) 2005-2012 Regis Houssin
* Copyright (C) 2011-2012 Juanjo Menent
- * Copyright (C) 2011-2015 Philippe Grand
+ * Copyright (C) 2011-2018 Philippe Grand
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -32,9 +32,7 @@ require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
// Load translation files required by the page
-$langs->loadLangs(array('admin', 'exports'));
-
-$langs->load('other');
+$langs->loadLangs(array('admin', 'exports', 'other'));
if (! $user->admin)
accessforbidden();
@@ -73,7 +71,7 @@ dol_fiche_head(
// Setup page goes here
$form=new Form($db);
-$var=false;
+
print '';
print '';
print ''.$langs->trans("ExportModel").' '."\n";
@@ -82,8 +80,7 @@ print ' '."\n";
// Example with a yes / no select
-$var=!$var;
-print ' ';
+print ' ';
print ''.$langs->trans("set_EXPORTS_SHARE_MODELS").' ';
print ' ';
print '';
@@ -94,9 +91,8 @@ echo ajax_constantonoff('EXPORTS_SHARE_MODELS');
print '';
print ' ';
-
print '
';
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/external_rss.php b/htdocs/admin/external_rss.php
index e8683dfc4ee..e0f3f72f927 100644
--- a/htdocs/admin/external_rss.php
+++ b/htdocs/admin/external_rss.php
@@ -325,6 +325,6 @@ else
dol_print_error($db);
}
-
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/admin/facture.php b/htdocs/admin/facture.php
index f00d125a4d5..6c28081e6fc 100644
--- a/htdocs/admin/facture.php
+++ b/htdocs/admin/facture.php
@@ -782,7 +782,6 @@ print '';
dol_fiche_end();
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/fckeditor.php b/htdocs/admin/fckeditor.php
index 19d4a4cc772..bed1d4d9bcb 100644
--- a/htdocs/admin/fckeditor.php
+++ b/htdocs/admin/fckeditor.php
@@ -234,6 +234,6 @@ else
*/
}
-
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/admin/fichinter.php b/htdocs/admin/fichinter.php
index a216f2d4ab7..c714c0c6c1b 100644
--- a/htdocs/admin/fichinter.php
+++ b/htdocs/admin/fichinter.php
@@ -6,7 +6,7 @@
* Copyright (C) 2005-2014 Regis Houssin
* Copyright (C) 2008 Raphael Bertrand (Resultic)
* Copyright (C) 2011-2013 Juanjo Menent
- * Copyright (C) 2011-2017 Philippe Grand
+ * Copyright (C) 2011-2018 Philippe Grand
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -560,7 +560,6 @@ print " \n";
print '';
//Use draft Watermark
-
print "
';
-
-
-
print '';
print '
';
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/admin/geoipmaxmind.php b/htdocs/admin/geoipmaxmind.php
index 9c944324527..9f154591f0f 100644
--- a/htdocs/admin/geoipmaxmind.php
+++ b/htdocs/admin/geoipmaxmind.php
@@ -153,6 +153,6 @@ if ($geoip)
$geoip->close();
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/holiday.php b/htdocs/admin/holiday.php
index b199505d214..f6306f787c3 100644
--- a/htdocs/admin/holiday.php
+++ b/htdocs/admin/holiday.php
@@ -1,8 +1,7 @@
- * Copyright (C) 2011-2015 Philippe Grand
- * Copyright (C) 2013 Juanjo Menent
- * Copyright (C) 2018 Charlene Benke
+ * Copyright (C) 2011-2018 Philippe Grand
+ * Copyright (C) 2018 Charlene Benke
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -30,9 +29,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/holiday.lib.php';
-$langs->load("admin");
-$langs->load("errors");
-$langs->load("holiday");
+// Load translation files required by the page
+$langs->loadLangs(array("admin", "errors", "holiday"));
if (!$user->admin) accessforbidden();
@@ -341,7 +339,6 @@ print "\n";
clearstatcache();
-$var=true;
foreach ($dirmodels as $reldir)
{
foreach (array('','/doc') as $valdir)
@@ -379,7 +376,6 @@ foreach ($dirmodels as $reldir)
if ($modulequalified)
{
- $var = !$var;
print '';
print (empty($module->name)?$name:$module->name);
print " \n";
@@ -474,7 +470,6 @@ print ' ';
print ''.$langs->trans("Parameter").' ';
print ''.$langs->trans("Value").' ';
print " \n";
-$var=true;
$substitutionarray=pdf_getSubstitutionArray($langs, array('objectamount'), null, 2);
$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation");
@@ -482,7 +477,6 @@ $htmltext = ''.$langs->trans("AvailableVariables").':
';
foreach($substitutionarray as $key => $val) $htmltext.=$key.'
';
$htmltext.='';
-$var=! $var;
print '';
print $form->textwithpicto($langs->trans("FreeLegalTextOnHolidays"), $langs->trans("AddCRIfTooLong").'
'.$htmltext, 1, 'help', '', 0, 2, 'tooltiphelp');
print '
';
@@ -517,5 +511,6 @@ print '';
dol_fiche_end();
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/admin/ihm.php b/htdocs/admin/ihm.php
index 62f17d5cb1d..e15e6d0f91f 100644
--- a/htdocs/admin/ihm.php
+++ b/htdocs/admin/ihm.php
@@ -3,6 +3,7 @@
* Copyright (C) 2004-2015 Laurent Destailleur
* Copyright (C) 2005-2017 Regis Houssin
* Copyright (C) 2016 Juanjo Menent
+ * Copyright (C) 2018 Ferran Marcet
*
* 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
@@ -79,10 +80,10 @@ if ($action == 'removebackgroundlogin' && ! empty($conf->global->MAIN_LOGIN_BACK
if ($action == 'update')
{
- dolibarr_set_const($db, "MAIN_LANG_DEFAULT", $_POST["MAIN_LANG_DEFAULT"],'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_MULTILANGS", $_POST["MAIN_MULTILANGS"],'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_LANG_DEFAULT", $_POST["MAIN_LANG_DEFAULT"],'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_MULTILANGS", $_POST["MAIN_MULTILANGS"],'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_THEME", $_POST["main_theme"],'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_THEME", $_POST["main_theme"],'chaine',0,'',$conf->entity);
$val=GETPOST('THEME_TOPMENU_DISABLE_IMAGE');
if (! $val) dolibarr_del_const($db, 'THEME_TOPMENU_DISABLE_IMAGE', $conf->entity);
@@ -133,21 +134,24 @@ if ($action == 'update')
if (GETPOST('THEME_ELDY_USE_HOVER') == '') dolibarr_set_const($db, "THEME_ELDY_USE_HOVER", '0', 'chaine', 0, '', $conf->entity); // If empty, we set to '0' ('000000' is for black)
else dolibarr_set_const($db, "THEME_ELDY_USE_HOVER", $_POST["THEME_ELDY_USE_HOVER"], 'chaine', 0, '', $conf->entity);
- dolibarr_set_const($db, "MAIN_SIZE_LISTE_LIMIT", $_POST["main_size_liste_limit"],'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_SIZE_SHORTLIST_LIMIT", $_POST["main_size_shortliste_limit"],'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_DISABLE_JAVASCRIPT", $_POST["main_disable_javascript"],'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_BUTTON_HIDE_UNAUTHORIZED", $_POST["MAIN_BUTTON_HIDE_UNAUTHORIZED"],'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_START_WEEK", $_POST["MAIN_START_WEEK"],'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_DEFAULT_WORKING_DAYS", $_POST["MAIN_DEFAULT_WORKING_DAYS"],'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_DEFAULT_WORKING_HOURS", $_POST["MAIN_DEFAULT_WORKING_HOURS"],'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_SHOW_LOGO", $_POST["MAIN_SHOW_LOGO"],'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_FIRSTNAME_NAME_POSITION", $_POST["MAIN_FIRSTNAME_NAME_POSITION"],'chaine',0,'',$conf->entity);
+ if (GETPOST('THEME_ELDY_USE_CHECKED') == '') dolibarr_set_const($db, "THEME_ELDY_USE_CHECKED", '0', 'chaine', 0, '', $conf->entity);
+ else dolibarr_set_const($db, "THEME_ELDY_USE_CHECKED", $_POST["THEME_ELDY_USE_CHECKED"], 'chaine', 0, '', $conf->entity);
- dolibarr_set_const($db, "MAIN_HELPCENTER_DISABLELINK", $_POST["MAIN_HELPCENTER_DISABLELINK"],'chaine',0,'',0); // Param for all entities
- dolibarr_set_const($db, "MAIN_MOTD", dol_htmlcleanlastbr($_POST["main_motd"]),'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_HOME", dol_htmlcleanlastbr($_POST["main_home"]),'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_HELP_DISABLELINK", $_POST["MAIN_HELP_DISABLELINK"],'chaine',0,'',0); // Param for all entities
- dolibarr_set_const($db, "MAIN_BUGTRACK_ENABLELINK", $_POST["MAIN_BUGTRACK_ENABLELINK"],'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_SIZE_LISTE_LIMIT", $_POST["main_size_liste_limit"],'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_SIZE_SHORTLIST_LIMIT", $_POST["main_size_shortliste_limit"],'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_DISABLE_JAVASCRIPT", $_POST["main_disable_javascript"],'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_BUTTON_HIDE_UNAUTHORIZED", $_POST["MAIN_BUTTON_HIDE_UNAUTHORIZED"],'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_START_WEEK", $_POST["MAIN_START_WEEK"],'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_DEFAULT_WORKING_DAYS", $_POST["MAIN_DEFAULT_WORKING_DAYS"],'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_DEFAULT_WORKING_HOURS", $_POST["MAIN_DEFAULT_WORKING_HOURS"],'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_SHOW_LOGO", $_POST["MAIN_SHOW_LOGO"],'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_FIRSTNAME_NAME_POSITION", $_POST["MAIN_FIRSTNAME_NAME_POSITION"],'chaine',0,'',$conf->entity);
+
+ dolibarr_set_const($db, "MAIN_HELPCENTER_DISABLELINK", $_POST["MAIN_HELPCENTER_DISABLELINK"],'chaine',0,'',0); // Param for all entities
+ dolibarr_set_const($db, "MAIN_MOTD", dol_htmlcleanlastbr($_POST["main_motd"]),'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_HOME", dol_htmlcleanlastbr($_POST["main_home"]),'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_HELP_DISABLELINK", $_POST["MAIN_HELP_DISABLELINK"],'chaine',0,'',0); // Param for all entities
+ dolibarr_set_const($db, "MAIN_BUGTRACK_ENABLELINK", $_POST["MAIN_BUGTRACK_ENABLELINK"],'chaine',0,'',$conf->entity);
$varforimage='imagebackground'; $dirforimage=$conf->mycompany->dir_output.'/logos/';
if ($_FILES[$varforimage]["tmp_name"])
@@ -309,8 +313,8 @@ if ($action == 'edit') // Edit
// Firstname/Name
print ''.$langs->trans("FirstnameNamePosition").' ';
- $array=array(0=>$langs->trans("Firstname").' '.$langs->trans("Lastname"),1=>$langs->trans("Lastname").' '.$langs->trans("Firstname"));
- print $form->selectarray('MAIN_FIRSTNAME_NAME_POSITION',$array,(isset($conf->global->MAIN_FIRSTNAME_NAME_POSITION)?$conf->global->MAIN_FIRSTNAME_NAME_POSITION:0));
+ $array=array(0=>$langs->trans("Firstname").' '.$langs->trans("Lastname"), 1=>$langs->trans("Lastname").' '.$langs->trans("Firstname"));
+ print $form->selectarray('MAIN_FIRSTNAME_NAME_POSITION', $array, (isset($conf->global->MAIN_FIRSTNAME_NAME_POSITION)?$conf->global->MAIN_FIRSTNAME_NAME_POSITION:0));
print ' ';
print ' ';
print ' ';
@@ -413,7 +417,7 @@ if ($action == 'edit') // Edit
print ''.img_delete($langs->trans("Delete")).'';
if (file_exists($conf->mycompany->dir_output.'/logos/'.$conf->global->MAIN_LOGIN_BACKGROUND)) {
print ' ';
- print '
';
+ print '
';
}
} else {
print '
';
@@ -561,7 +565,7 @@ else // Show
print $conf->global->MAIN_LOGIN_BACKGROUND;
if ($conf->global->MAIN_LOGIN_BACKGROUND && is_file($conf->mycompany->dir_output.'/logos/'.$conf->global->MAIN_LOGIN_BACKGROUND))
{
- print '
';
+ print '
';
}
else
{
@@ -578,6 +582,6 @@ else // Show
print '';
}
-
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/admin/index.php b/htdocs/admin/index.php
index 6542cec1174..2f64793c28b 100644
--- a/htdocs/admin/index.php
+++ b/htdocs/admin/index.php
@@ -114,7 +114,6 @@ if (empty($reshook))
print '';
}
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/ldap.php b/htdocs/admin/ldap.php
index 6776cfb1480..052b2f38988 100644
--- a/htdocs/admin/ldap.php
+++ b/htdocs/admin/ldap.php
@@ -340,5 +340,6 @@ if (function_exists("ldap_connect"))
}
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/admin/ldap_contacts.php b/htdocs/admin/ldap_contacts.php
index 3188bf6e58a..dd85a998383 100644
--- a/htdocs/admin/ldap_contacts.php
+++ b/htdocs/admin/ldap_contacts.php
@@ -318,6 +318,7 @@ if (function_exists("ldap_connect"))
}
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/admin/ldap_groups.php b/htdocs/admin/ldap_groups.php
index 4ae6ce9ad97..2650fe4fe6e 100644
--- a/htdocs/admin/ldap_groups.php
+++ b/htdocs/admin/ldap_groups.php
@@ -251,5 +251,6 @@ if (function_exists("ldap_connect"))
}
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/admin/ldap_members.php b/htdocs/admin/ldap_members.php
index 616eb99a8da..2f36f239257 100644
--- a/htdocs/admin/ldap_members.php
+++ b/htdocs/admin/ldap_members.php
@@ -80,9 +80,9 @@ if ($action == 'setvalue' && $user->admin)
if (! dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION', GETPOST("fieldendlastsubscription"),'chaine',0,'',$conf->entity)) $error++;
// Subscriptions
- if (! dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE', GETPOST("fieldfirstsubscriptiondate"),'chaine',0,'',$conf->entity)) $error++;
+ if (! dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE', GETPOST("fieldfirstsubscriptiondate"),'chaine',0,'',$conf->entity)) $error++;
if (! dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT',GETPOST("fieldfirstsubscriptionamount"),'chaine',0,'',$conf->entity)) $error++;
- if (! dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE', GETPOST("fieldlastsubscriptiondate"),'chaine',0,'',$conf->entity)) $error++;
+ if (! dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE', GETPOST("fieldlastsubscriptiondate"),'chaine',0,'',$conf->entity)) $error++;
if (! dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT', GETPOST("fieldlastsubscriptionamount"),'chaine',0,'',$conf->entity)) $error++;
// This one must be after the others
@@ -442,7 +442,6 @@ if (function_exists("ldap_connect"))
}
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/ldap_members_types.php b/htdocs/admin/ldap_members_types.php
index e45857f2f38..e845fd37adc 100644
--- a/htdocs/admin/ldap_members_types.php
+++ b/htdocs/admin/ldap_members_types.php
@@ -241,5 +241,6 @@ if (function_exists("ldap_connect"))
}
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/admin/ldap_users.php b/htdocs/admin/ldap_users.php
index 8b11069fc61..513aa63f035 100644
--- a/htdocs/admin/ldap_users.php
+++ b/htdocs/admin/ldap_users.php
@@ -470,5 +470,6 @@ if (function_exists("ldap_connect"))
}
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/admin/limits.php b/htdocs/admin/limits.php
index e9389b0271d..f9fe219afef 100644
--- a/htdocs/admin/limits.php
+++ b/htdocs/admin/limits.php
@@ -66,11 +66,11 @@ if ($action == 'update')
if (! $error)
{
- dolibarr_set_const($db, "MAIN_MAX_DECIMALS_UNIT", $_POST["MAIN_MAX_DECIMALS_UNIT"],'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_MAX_DECIMALS_TOT", $_POST["MAIN_MAX_DECIMALS_TOT"],'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_MAX_DECIMALS_SHOWN", $_POST["MAIN_MAX_DECIMALS_SHOWN"],'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_MAX_DECIMALS_UNIT", $_POST["MAIN_MAX_DECIMALS_UNIT"],'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_MAX_DECIMALS_TOT", $_POST["MAIN_MAX_DECIMALS_TOT"],'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_MAX_DECIMALS_SHOWN", $_POST["MAIN_MAX_DECIMALS_SHOWN"],'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_ROUNDING_RULE_TOT", $_POST["MAIN_ROUNDING_RULE_TOT"],'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_ROUNDING_RULE_TOT", $_POST["MAIN_ROUNDING_RULE_TOT"],'chaine',0,'',$conf->entity);
header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup");
exit;
@@ -306,7 +306,6 @@ else
*/
}
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/livraison.php b/htdocs/admin/livraison.php
index 88ce717f005..91fb9f964e4 100644
--- a/htdocs/admin/livraison.php
+++ b/htdocs/admin/livraison.php
@@ -478,6 +478,7 @@ print '';
print '';
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/admin/livraison_extrafields.php b/htdocs/admin/livraison_extrafields.php
index c9fed1c6554..55fe6f10362 100644
--- a/htdocs/admin/livraison_extrafields.php
+++ b/htdocs/admin/livraison_extrafields.php
@@ -119,6 +119,6 @@ if ($action == 'edit' && ! empty($attrname))
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php';
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/livraisondet_extrafields.php b/htdocs/admin/livraisondet_extrafields.php
index 921e9cfee41..e70b4f2d09b 100644
--- a/htdocs/admin/livraisondet_extrafields.php
+++ b/htdocs/admin/livraisondet_extrafields.php
@@ -120,6 +120,6 @@ if ($action == 'edit' && ! empty($attrname))
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php';
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/loan.php b/htdocs/admin/loan.php
index 3349ac0056a..419f6efbee9 100644
--- a/htdocs/admin/loan.php
+++ b/htdocs/admin/loan.php
@@ -122,5 +122,6 @@ print "\n";
print '
';
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/admin/mailing.php b/htdocs/admin/mailing.php
index 32fbdd4aeb6..d5b866d9d20 100644
--- a/htdocs/admin/mailing.php
+++ b/htdocs/admin/mailing.php
@@ -152,6 +152,6 @@ print 'entity);
- dolibarr_set_const($db, "MAIN_MAIL_FORCE_SENDTO", GETPOST("MAIN_MAIL_FORCE_SENDTO"),'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_MAIL_ENABLED_USER_DEST_SELECT", GETPOST("MAIN_MAIL_ENABLED_USER_DEST_SELECT"),'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_DISABLE_ALL_MAILS", GETPOST("MAIN_DISABLE_ALL_MAILS"), 'chaine', 0, '', $conf->entity);
+ dolibarr_set_const($db, "MAIN_MAIL_FORCE_SENDTO", GETPOST("MAIN_MAIL_FORCE_SENDTO"), 'chaine', 0, '', $conf->entity);
+ dolibarr_set_const($db, "MAIN_MAIL_ENABLED_USER_DEST_SELECT", GETPOST("MAIN_MAIL_ENABLED_USER_DEST_SELECT"), 'chaine', 0, '', $conf->entity);
// Send mode parameters
- dolibarr_set_const($db, "MAIN_MAIL_SENDMODE", GETPOST("MAIN_MAIL_SENDMODE"),'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_MAIL_SMTP_PORT", GETPOST("MAIN_MAIL_SMTP_PORT"),'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_MAIL_SMTP_SERVER", GETPOST("MAIN_MAIL_SMTP_SERVER"),'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_MAIL_SMTPS_ID", GETPOST("MAIN_MAIL_SMTPS_ID"), 'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_MAIL_SMTPS_PW", GETPOST("MAIN_MAIL_SMTPS_PW"), 'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_MAIL_EMAIL_TLS", GETPOST("MAIN_MAIL_EMAIL_TLS"),'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_MAIL_EMAIL_STARTTLS", GETPOST("MAIN_MAIL_EMAIL_STARTTLS"),'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_MAIL_SENDMODE", GETPOST("MAIN_MAIL_SENDMODE"), 'chaine', 0, '', $conf->entity);
+ dolibarr_set_const($db, "MAIN_MAIL_SMTP_PORT", GETPOST("MAIN_MAIL_SMTP_PORT"), 'chaine', 0, '', $conf->entity);
+ dolibarr_set_const($db, "MAIN_MAIL_SMTP_SERVER", GETPOST("MAIN_MAIL_SMTP_SERVER"), 'chaine', 0, '', $conf->entity);
+ dolibarr_set_const($db, "MAIN_MAIL_SMTPS_ID", GETPOST("MAIN_MAIL_SMTPS_ID"), 'chaine', 0, '', $conf->entity);
+ dolibarr_set_const($db, "MAIN_MAIL_SMTPS_PW", GETPOST("MAIN_MAIL_SMTPS_PW"), 'chaine', 0, '', $conf->entity);
+ dolibarr_set_const($db, "MAIN_MAIL_EMAIL_TLS", GETPOST("MAIN_MAIL_EMAIL_TLS"), 'chaine', 0, '', $conf->entity);
+ dolibarr_set_const($db, "MAIN_MAIL_EMAIL_STARTTLS", GETPOST("MAIN_MAIL_EMAIL_STARTTLS"), 'chaine', 0, '', $conf->entity);
- dolibarr_set_const($db, "MAIN_MAIL_EMAIL_DKIM_ENABLED", GETPOST("MAIN_MAIL_EMAIL_DKIM_ENABLED"),'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_MAIL_EMAIL_DKIM_DOMAIN", GETPOST("MAIN_MAIL_EMAIL_DKIM_DOMAIN"),'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_MAIL_EMAIL_DKIM_SELECTOR", GETPOST("MAIN_MAIL_EMAIL_DKIM_SELECTOR"),'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY", GETPOST("MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY"),'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_MAIL_EMAIL_DKIM_ENABLED", GETPOST("MAIN_MAIL_EMAIL_DKIM_ENABLED"), 'chaine', 0, '', $conf->entity);
+ dolibarr_set_const($db, "MAIN_MAIL_EMAIL_DKIM_DOMAIN", GETPOST("MAIN_MAIL_EMAIL_DKIM_DOMAIN"), 'chaine', 0, '', $conf->entity);
+ dolibarr_set_const($db, "MAIN_MAIL_EMAIL_DKIM_SELECTOR", GETPOST("MAIN_MAIL_EMAIL_DKIM_SELECTOR"), 'chaine', 0, '', $conf->entity);
+ dolibarr_set_const($db, "MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY", GETPOST("MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY"), 'chaine', 0, '', $conf->entity);
// Content parameters
- dolibarr_set_const($db, "MAIN_MAIL_EMAIL_FROM", GETPOST("MAIN_MAIL_EMAIL_FROM"), 'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_MAIL_ERRORS_TO", GETPOST("MAIN_MAIL_ERRORS_TO"), 'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_MAIL_AUTOCOPY_TO", GETPOST("MAIN_MAIL_AUTOCOPY_TO"),'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, 'MAIN_MAIL_DEFAULT_FROMTYPE', GETPOST('MAIN_MAIL_DEFAULT_FROMTYPE'),'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_MAIL_EMAIL_FROM", GETPOST("MAIN_MAIL_EMAIL_FROM"), 'chaine', 0, '', $conf->entity);
+ dolibarr_set_const($db, "MAIN_MAIL_ERRORS_TO", GETPOST("MAIN_MAIL_ERRORS_TO"), 'chaine', 0, '', $conf->entity);
+ dolibarr_set_const($db, "MAIN_MAIL_AUTOCOPY_TO", GETPOST("MAIN_MAIL_AUTOCOPY_TO"),'chaine', 0, '', $conf->entity);
+ dolibarr_set_const($db, 'MAIN_MAIL_DEFAULT_FROMTYPE', GETPOST('MAIN_MAIL_DEFAULT_FROMTYPE'), 'chaine', 0, '', $conf->entity);
header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup");
exit;
@@ -366,7 +366,7 @@ if ($action == 'edit')
{
$mainstmpid=(! empty($conf->global->MAIN_MAIL_SMTPS_ID)?$conf->global->MAIN_MAIL_SMTPS_ID:'');
- print ''.$langs->trans("MAIN_MAIL_SMTPS_ID").' ';
+ print ' '.$langs->trans("MAIN_MAIL_SMTPS_ID").' ';
// SuperAdministrator access only
if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity))
{
@@ -386,7 +386,7 @@ if ($action == 'edit')
{
$mainsmtppw=(! empty($conf->global->MAIN_MAIL_SMTPS_PW)?$conf->global->MAIN_MAIL_SMTPS_PW:'');
- print ' '.$langs->trans("MAIN_MAIL_SMTPS_PW").' ';
+ print ' '.$langs->trans("MAIN_MAIL_SMTPS_PW").' ';
// SuperAdministrator access only
if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity))
{
@@ -854,7 +854,6 @@ else
}
}
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/mails_emailing.php b/htdocs/admin/mails_emailing.php
index 91826f2be1d..59fc0ade0cd 100644
--- a/htdocs/admin/mails_emailing.php
+++ b/htdocs/admin/mails_emailing.php
@@ -61,12 +61,12 @@ complete_substitutions_array($substitutionarrayfortest, $langs);
if ($action == 'update' && empty($_POST["cancel"]))
{
// Send mode parameters
- dolibarr_set_const($db, "MAIN_MAIL_SENDMODE_EMAILING", GETPOST("MAIN_MAIL_SENDMODE_EMAILING"),'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_MAIL_SMTP_PORT_EMAILING", GETPOST("MAIN_MAIL_SMTP_PORT_EMAILING"),'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_MAIL_SMTP_SERVER_EMAILING", GETPOST("MAIN_MAIL_SMTP_SERVER_EMAILING"),'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_MAIL_SMTPS_ID_EMAILING", GETPOST("MAIN_MAIL_SMTPS_ID_EMAILING"), 'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_MAIL_SMTPS_PW_EMAILING", GETPOST("MAIN_MAIL_SMTPS_PW_EMAILING"), 'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_MAIL_EMAIL_TLS_EMAILING", GETPOST("MAIN_MAIL_EMAIL_TLS_EMAILING"),'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_MAIL_SENDMODE_EMAILING", GETPOST("MAIN_MAIL_SENDMODE_EMAILING"),'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_MAIL_SMTP_PORT_EMAILING", GETPOST("MAIN_MAIL_SMTP_PORT_EMAILING"),'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_MAIL_SMTP_SERVER_EMAILING", GETPOST("MAIN_MAIL_SMTP_SERVER_EMAILING"),'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_MAIL_SMTPS_ID_EMAILING", GETPOST("MAIN_MAIL_SMTPS_ID_EMAILING"), 'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_MAIL_SMTPS_PW_EMAILING", GETPOST("MAIN_MAIL_SMTPS_PW_EMAILING"), 'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_MAIL_EMAIL_TLS_EMAILING", GETPOST("MAIN_MAIL_EMAIL_TLS_EMAILING"),'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_MAIL_EMAIL_STARTTLS_EMAILING", GETPOST("MAIN_MAIL_EMAIL_STARTTLS_EMAILING"),'chaine',0,'',$conf->entity);
header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup");
@@ -601,7 +601,6 @@ else
}
}
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/mails_senderprofile_list.php b/htdocs/admin/mails_senderprofile_list.php
index b6268e7fc1e..4914152f680 100644
--- a/htdocs/admin/mails_senderprofile_list.php
+++ b/htdocs/admin/mails_senderprofile_list.php
@@ -23,7 +23,7 @@
*/
require '../main.inc.php';
-require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php');
+require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
@@ -498,7 +498,7 @@ print ''."\n";
if (in_array('builddoc',$arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords))
{
- require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php');
+ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
$formfile = new FormFile($db);
$hidegeneratedfilelistifempty=1;
diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php
index af7d29c0fd6..da6989b41fd 100644
--- a/htdocs/admin/mails_templates.php
+++ b/htdocs/admin/mails_templates.php
@@ -1,6 +1,6 @@
- * Copyright (C) 2004-2015 Laurent Destailleur
+ * Copyright (C) 2004-2018 Laurent Destailleur
* Copyright (C) 2004 Benoit Mortier
* Copyright (C) 2005-2012 Regis Houssin
* Copyright (C) 2010-2016 Juanjo Menent
@@ -556,7 +556,7 @@ foreach ($fieldsforcontent as $tmpfieldlist)
print '';
}
else if ($tmpfieldlist == 'joinfiles') {
- print '';
+ print '';
}
else
{
@@ -925,6 +925,7 @@ print '';
dol_fiche_end();
+// End of page
llxFooter();
$db->close();
@@ -989,7 +990,7 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='')
print '';
if (! empty($conf->global->MAIN_MULTILANGS))
{
- $selectedlang = $langs->defaultlang;
+ $selectedlang = GETPOSTISSET('langcode','aZ09')?GETPOST('langcode','aZ09'):$langs->defaultlang;
if ($context == 'edit') $selectedlang = $obj->{$fieldlist[$field]};
print $formadmin->select_language($selectedlang, 'langcode', 0, null, 1, 0, 0, 'maxwidth150');
}
diff --git a/htdocs/admin/menus.php b/htdocs/admin/menus.php
index 083d78c03e5..09907652df0 100644
--- a/htdocs/admin/menus.php
+++ b/htdocs/admin/menus.php
@@ -64,10 +64,10 @@ if ($action == 'update' && ! $cancel)
{
$_SESSION["mainmenu"]="home"; // Le gestionnaire de menu a pu changer
- dolibarr_set_const($db, "MAIN_MENU_STANDARD", GETPOST('MAIN_MENU_STANDARD','alpha'),'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_MENU_SMARTPHONE", GETPOST('MAIN_MENU_SMARTPHONE','alpha'),'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_MENU_STANDARD", GETPOST('MAIN_MENU_STANDARD','alpha'),'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_MENU_SMARTPHONE", GETPOST('MAIN_MENU_SMARTPHONE','alpha'),'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_MENUFRONT_STANDARD", GETPOST('MAIN_MENUFRONT_STANDARD','alpha'),'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_MENUFRONT_STANDARD", GETPOST('MAIN_MENUFRONT_STANDARD','alpha'),'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_MENUFRONT_SMARTPHONE", GETPOST('MAIN_MENUFRONT_SMARTPHONE','alpha'),'chaine',0,'',$conf->entity);
// Define list of menu handlers to initialize
@@ -269,7 +269,6 @@ if ($action != 'edit')
print '';
}
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/menus/edit.php b/htdocs/admin/menus/edit.php
index cd236d85122..0db2d3cd6d1 100644
--- a/htdocs/admin/menus/edit.php
+++ b/htdocs/admin/menus/edit.php
@@ -28,9 +28,8 @@ require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/menubase.class.php';
-
-$langs->load("admin");
-$langs->load('other');
+// Load translation files required by the page
+$langs->loadLangs(array("other","admin"));
if (! $user->admin) accessforbidden();
@@ -89,7 +88,7 @@ if ($action == 'update')
if ($result > 0)
{
$menu->titre=GETPOST('titre', 'alpha');
- $menu->leftmenu=GETPOST('leftmenu', 'alpha');
+ $menu->leftmenu=GETPOST('leftmenu', 'aZ09');
$menu->url=GETPOST('url','alpha');
$menu->langs=GETPOST('langs','alpha');
$menu->position=GETPOST('position','int');
@@ -514,5 +513,6 @@ elseif ($action == 'edit')
print '
';
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/admin/menus/index.php b/htdocs/admin/menus/index.php
index c3211fc2d75..9d0178c956d 100644
--- a/htdocs/admin/menus/index.php
+++ b/htdocs/admin/menus/index.php
@@ -27,8 +27,8 @@ require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php';
-$langs->load("other");
-$langs->load("admin");
+// Load translation files required by the page
+$langs->loadLangs(array("other","admin"));
if (! $user->admin) accessforbidden();
@@ -410,6 +410,6 @@ else
print '
';
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/menus/other.php b/htdocs/admin/menus/other.php
index 7789c3fb21c..7b1a73f2f09 100644
--- a/htdocs/admin/menus/other.php
+++ b/htdocs/admin/menus/other.php
@@ -24,9 +24,8 @@
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
-$langs->load("users");
-$langs->load("admin");
-$langs->load("other");
+// Load translation files required by the page
+$langs->loadLangs(array("user","other","admin"));
if (! $user->admin) accessforbidden();
@@ -105,6 +104,6 @@ print ' ';
print '';
-
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/admin/modulehelp.php b/htdocs/admin/modulehelp.php
index cf4596ccda2..b5b33be77aa 100644
--- a/htdocs/admin/modulehelp.php
+++ b/htdocs/admin/modulehelp.php
@@ -313,7 +313,9 @@ if ($mode == 'desc')
{
$textexternal.='
'.$langs->trans("Origin").': '.$langs->trans("ExternalModule",$dirofmodule);
if ($objMod->editor_name != 'dolibarr') $textexternal.='
'.$langs->trans("Publisher").': '.(empty($objMod->editor_name)?$langs->trans("Unknown"):$objMod->editor_name);
- if (! empty($objMod->editor_url) && ! preg_match('/dolibarr\.org/i',$objMod->editor_url)) $textexternal.='
'.$langs->trans("Url").': '.$objMod->editor_url.'';
+ $editor_url = $objMod->editor_url;
+ if (! preg_match('/^http/', $editor_url)) $editor_url = 'http://'.$editor_url;
+ if (! empty($objMod->editor_url) && ! preg_match('/dolibarr\.org/i',$objMod->editor_url)) $textexternal.='
'.$langs->trans("Url").': '.$objMod->editor_url.'';
$text.=$textexternal;
$text.='
';
}
@@ -592,7 +594,6 @@ dol_fiche_end();
print '';
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php
index 036e6100449..89f0f028e1e 100644
--- a/htdocs/admin/modules.php
+++ b/htdocs/admin/modules.php
@@ -8,7 +8,7 @@
* Copyright (C) 2015 Jean-François Ferry
* Copyright (C) 2015 Raphaël Doursenaud
* Copyright (C) 2018 Nicolas ZABOURI
- *
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
@@ -56,7 +56,7 @@ $options['categorie'] = ((GETPOST('categorie', 'int')?GETPOST('categorie', 'int'
$options['start'] = ((GETPOST('start', 'int')?GETPOST('start', 'int'):0) + 0);
$options['end'] = ((GETPOST('end', 'int')?GETPOST('end', 'int'):0) + 0);
$options['search'] = GETPOST('search_keyword', 'alpha');
-$dolistore = new Dolistore();
+$dolistore = new Dolistore(false);
if (! $user->admin)
@@ -598,17 +598,18 @@ if ($mode == 'common')
}
// Print a separator if we change family
- if ($familykey!=$oldfamily)
- {
- if ($oldfamily) print '
';
+ if ($familykey != $oldfamily) {
+ if ($oldfamily) {
+ print '
';
+ }
- $familytext=empty($familyinfo[$familykey]['label'])?$familykey:$familyinfo[$familykey]['label'];
- print_fiche_titre($familytext, '', '');
+ $familytext = empty($familyinfo[$familykey]['label'])?$familykey:$familyinfo[$familykey]['label'];
+ print load_fiche_titre($familytext, '', '');
print '';
- print ''."\n";
+ print ''."\n";
- $atleastoneforfamily=0;
+ $atleastoneforfamily=0;
}
$atleastoneforfamily++;
@@ -672,7 +673,7 @@ if ($mode == 'common')
print '';
print $versiontrans;
if(!empty($conf->global->CHECKLASTVERSION_EXTERNALMODULE)){
- require_once(DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php');
+ require_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php';
if (!empty($objMod->url_last_version)) {
$newversion = getURLContent($objMod->url_last_version);
if(isset($newversion['content'])){
@@ -1080,8 +1081,6 @@ if ($mode == 'develop')
dol_fiche_end();
}
-
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/multicurrency.php b/htdocs/admin/multicurrency.php
index d4a031a6148..9843c6a4fb0 100644
--- a/htdocs/admin/multicurrency.php
+++ b/htdocs/admin/multicurrency.php
@@ -19,14 +19,11 @@
/**
* \file admin/multicurrency.php
* \ingroup multicurrency
- * \brief This file is an example module setup page
- * Put some comments here
+ * \brief Page to setup multicurrency module
*/
+
// Dolibarr environment
-
require '../main.inc.php';
-
-// Libraries
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/multicurrency.lib.php';
require_once DOL_DOCUMENT_ROOT.'/multicurrency/class/multicurrency.class.php';
@@ -42,6 +39,8 @@ if (! $user->admin) {
// Parameters
$action = GETPOST('action', 'alpha');
+
+
/*
* Actions
*/
@@ -164,33 +163,30 @@ if ($resql)
* View
*/
+$form=new Form($db);
+
$page_name = "MultiCurrencySetup";
llxHeader('', $langs->trans($page_name));
// Subheader
$linkback = '' . $langs->trans("BackToModuleList") . '';
-print_fiche_titre($langs->trans($page_name), $linkback);
+print load_fiche_titre($langs->trans($page_name), $linkback);
// Configuration header
$head = multicurrencyAdminPrepareHead();
dol_fiche_head($head, 'settings', $langs->trans("ModuleSetup"), -1, "multicurrency");
-// Setup page goes here
-$form=new Form($db);
-$var=false;
print '';
print '';
print ''.$langs->trans("Parameters").' '."\n";
-print ' ';
-print ''.$langs->trans("Value").' '."\n";
-
+print ''.$langs->trans("Value").' '."\n";
+print ' ';
print '';
print ''.$langs->transnoentitiesnoconv("MULTICURRENCY_USE_RATE_ON_DOCUMENT_DATE").' ';
-print ' ';
-print '';
+print ' ';
print '';
print ' ';
-
print '';
print ''.$langs->transnoentitiesnoconv("multicurrency_useOriginTx").' ';
-print ' ';
-print '';
+print ' ';
print ' ';
print '';
print ''.$langs->transnoentitiesnoconv("multicurrency_buyPriceInCurrency").' ';
-print ' ';
-print '';
+print ' ';
print ' ';
print '';
print ''.$langs->transnoentitiesnoconv("multicurrency_modifyRateApplication").' ';
-print ' ';
-print '';
+print ' ';
print ' ';
*/
print '
';
+
print '
';
if (!empty($conf->global->MAIN_MULTICURRENCY_ALLOW_SYNCHRONIZATION))
{
- $var=false;
+ print '';
print '';
+
print '';
print ''.$form->textwithpicto($langs->trans("CurrencyLayerAccount"), $langs->trans("CurrencyLayerAccount_help_to_synchronize")).' '."\n";
- print ' ';
- print '';
+ print ' ';
print ' ';
-
print '';
print ''.$langs->transnoentitiesnoconv("multicurrency_appId").' ';
- print ' ';
- print '';
+ print ' ';
print '
';
+ print '';
print '
';
}
+print '';
print '';
print '';
print ''.$form->textwithpicto($langs->trans("CurrenciesUsed"), $langs->transnoentitiesnoconv("CurrenciesUsed_help_to_add")).' '."\n";
-print ' ';
-print ''.$langs->trans("Rate").' '."\n";
+print ''.$langs->trans("Rate").' '."\n";
+print ' ';
-
-print '';
print '';
+print '';
+print ''.$form->selectCurrency('', 'code').' ';
+print '';
print '';
print '';
-print ' '.$form->selectCurrency('', 'code').' ';
-print ' ';
-print '';
print ' ';
print '';
-print ' ';
-
+print '';
+print ' ';
+print '';
print '';
print ''.$conf->currency.$form->textwithpicto(' ', $langs->trans("BaseCurrency")).' ';
-print ' ';
-print '1';
-print ' ';
+print '1 ';
+print '';
foreach ($TCurrency as &$currency)
{
@@ -338,8 +327,7 @@ foreach ($TCurrency as &$currency)
print '';
print ''.$currency->code.' - '.$currency->name.' ';
- print ' ';
- print '';
+ print ' ';
print '';
print '';
print '';
@@ -349,13 +337,11 @@ foreach ($TCurrency as &$currency)
print ' ';
print '';
print ' ';
-
print ' ';
}
print '
';
-
-
+print '';
print '
';
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/notification.php b/htdocs/admin/notification.php
index 43782816202..d93421ef6fb 100644
--- a/htdocs/admin/notification.php
+++ b/htdocs/admin/notification.php
@@ -272,7 +272,6 @@ print 'load("products");
-$langs->load("members");
+$langs->loadLangs(array('admin', 'languages', 'other', 'companies', 'products', 'members'));
if (! $user->admin) accessforbidden();
@@ -54,29 +50,29 @@ if ($cancel) {
if ($action == 'update')
{
- dolibarr_set_const($db, "MAIN_PDF_FORMAT", $_POST["MAIN_PDF_FORMAT"],'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_PDF_FORMAT", $_POST["MAIN_PDF_FORMAT"],'chaine',0,'', $conf->entity);
- dolibarr_set_const($db, "MAIN_PDF_MARGIN_LEFT", $_POST["MAIN_PDF_MARGIN_LEFT"],'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_PDF_MARGIN_RIGHT", $_POST["MAIN_PDF_MARGIN_RIGHT"],'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_PDF_MARGIN_TOP", $_POST["MAIN_PDF_MARGIN_TOP"],'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_PDF_MARGIN_BOTTOM", $_POST["MAIN_PDF_MARGIN_BOTTOM"],'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_PDF_MARGIN_LEFT", $_POST["MAIN_PDF_MARGIN_LEFT"],'chaine',0,'', $conf->entity);
+ dolibarr_set_const($db, "MAIN_PDF_MARGIN_RIGHT", $_POST["MAIN_PDF_MARGIN_RIGHT"],'chaine',0,'', $conf->entity);
+ dolibarr_set_const($db, "MAIN_PDF_MARGIN_TOP", $_POST["MAIN_PDF_MARGIN_TOP"],'chaine',0,'', $conf->entity);
+ dolibarr_set_const($db, "MAIN_PDF_MARGIN_BOTTOM", $_POST["MAIN_PDF_MARGIN_BOTTOM"],'chaine',0,'', $conf->entity);
- dolibarr_set_const($db, "MAIN_PROFID1_IN_ADDRESS", $_POST["MAIN_PROFID1_IN_ADDRESS"],'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_PROFID2_IN_ADDRESS", $_POST["MAIN_PROFID2_IN_ADDRESS"],'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_PROFID3_IN_ADDRESS", $_POST["MAIN_PROFID3_IN_ADDRESS"],'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_PROFID4_IN_ADDRESS", $_POST["MAIN_PROFID4_IN_ADDRESS"],'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT", $_POST["MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT"],'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_PROFID1_IN_ADDRESS", $_POST["MAIN_PROFID1_IN_ADDRESS"],'chaine',0,'', $conf->entity);
+ dolibarr_set_const($db, "MAIN_PROFID2_IN_ADDRESS", $_POST["MAIN_PROFID2_IN_ADDRESS"],'chaine',0,'', $conf->entity);
+ dolibarr_set_const($db, "MAIN_PROFID3_IN_ADDRESS", $_POST["MAIN_PROFID3_IN_ADDRESS"],'chaine',0,'', $conf->entity);
+ dolibarr_set_const($db, "MAIN_PROFID4_IN_ADDRESS", $_POST["MAIN_PROFID4_IN_ADDRESS"],'chaine',0,'', $conf->entity);
+ dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT", $_POST["MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT"],'chaine',0,'', $conf->entity);
- dolibarr_set_const($db, "MAIN_TVAINTRA_NOT_IN_ADDRESS", $_POST["MAIN_TVAINTRA_NOT_IN_ADDRESS"],'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS", $_POST["MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS"],'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_HIDE_DESC", $_POST["MAIN_GENERATE_DOCUMENTS_HIDE_DESC"],'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_HIDE_REF", $_POST["MAIN_GENERATE_DOCUMENTS_HIDE_REF"],'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_PDF_USE_ISO_LOCATION", $_POST["MAIN_PDF_USE_ISO_LOCATION"],'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS", $_POST["MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS"],'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_TVAINTRA_NOT_IN_ADDRESS", $_POST["MAIN_TVAINTRA_NOT_IN_ADDRESS"],'chaine',0,'', $conf->entity);
+ dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS", $_POST["MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS"],'chaine',0,'', $conf->entity);
+ dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_HIDE_DESC", $_POST["MAIN_GENERATE_DOCUMENTS_HIDE_DESC"],'chaine',0,'', $conf->entity);
+ dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_HIDE_REF", $_POST["MAIN_GENERATE_DOCUMENTS_HIDE_REF"],'chaine',0,'', $conf->entity);
+ dolibarr_set_const($db, "MAIN_PDF_USE_ISO_LOCATION", $_POST["MAIN_PDF_USE_ISO_LOCATION"],'chaine',0,'', $conf->entity);
+ dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS", $_POST["MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS"],'chaine',0,'', $conf->entity);
- dolibarr_set_const($db, "MAIN_PDF_MAIN_HIDE_SECOND_TAX", $_POST["MAIN_PDF_MAIN_HIDE_SECOND_TAX"],'chaine',0,'',$conf->entity);
- dolibarr_set_const($db, "MAIN_PDF_MAIN_HIDE_THIRD_TAX", $_POST["MAIN_PDF_MAIN_HIDE_THIRD_TAX"],'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_PDF_MAIN_HIDE_SECOND_TAX", $_POST["MAIN_PDF_MAIN_HIDE_SECOND_TAX"],'chaine',0,'', $conf->entity);
+ dolibarr_set_const($db, "MAIN_PDF_MAIN_HIDE_THIRD_TAX", $_POST["MAIN_PDF_MAIN_HIDE_THIRD_TAX"],'chaine',0,'', $conf->entity);
header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup");
exit;
@@ -668,7 +664,6 @@ else // Show
print '
';
}
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/perms.php b/htdocs/admin/perms.php
index 50bf939c07f..db4e1f33553 100644
--- a/htdocs/admin/perms.php
+++ b/htdocs/admin/perms.php
@@ -218,5 +218,6 @@ print '';
dol_fiche_end();
+// End of page
llxFooter();
-$db->close();
+$db->close();
\ No newline at end of file
diff --git a/htdocs/admin/prelevement.php b/htdocs/admin/prelevement.php
index 56e1e7f2039..c40eca7380e 100644
--- a/htdocs/admin/prelevement.php
+++ b/htdocs/admin/prelevement.php
@@ -533,5 +533,6 @@ if (! empty($conf->global->MAIN_MODULE_NOTIFICATION))
}
*/
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/admin/propal.php b/htdocs/admin/propal.php
index 94b1d1dac67..bc91729829f 100644
--- a/htdocs/admin/propal.php
+++ b/htdocs/admin/propal.php
@@ -649,7 +649,6 @@ print " \n";
print '
';
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/proxy.php b/htdocs/admin/proxy.php
index 87a89f5d99b..9490a291729 100644
--- a/htdocs/admin/proxy.php
+++ b/htdocs/admin/proxy.php
@@ -205,5 +205,6 @@ print '';
print '';
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/admin/receiptprinter.php b/htdocs/admin/receiptprinter.php
index 4465017bdc6..9205d49deae 100644
--- a/htdocs/admin/receiptprinter.php
+++ b/htdocs/admin/receiptprinter.php
@@ -52,6 +52,12 @@ if (!$mode) $mode='config';
// used in library escpos maybe useful if php doesn't support gzdecode
if (!function_exists('gzdecode')) {
+ /**
+ * Gzdecode
+ *
+ * @param string $data data to deflate
+ * @return string data deflated
+ */
function gzdecode($data)
{
return gzinflate(substr($data,10,-8));
@@ -243,14 +249,14 @@ if ($mode == 'config' && $user->admin)
print "\n";
$ret = $printer->listprinters();
$nbofprinters = count($printer->listprinters);
-
+
if ($ret > 0) {
setEventMessages($printer->error, $printer->errors, 'errors');
} else {
- for ($line=0; $line < $nbofprinters; $line++)
+ for ($line=0; $line < $nbofprinters; $line++)
{
print '';
- if ($action=='editprinter' && $printer->listprinters[$line]['rowid']==$printerid)
+ if ($action=='editprinter' && $printer->listprinters[$line]['rowid']==$printerid)
{
print '';
print ' ';
@@ -285,7 +291,7 @@ if ($mode == 'config' && $user->admin)
}
}
- if ($action!='editprinter')
+ if ($action!='editprinter')
{
if ($nbofprinters > 0)
{
@@ -299,7 +305,7 @@ if ($mode == 'config' && $user->admin)
print ' ';
print " \n";
}
-
+
print '';
print ' ';
$ret = $printer->selectTypePrinter();
@@ -315,7 +321,7 @@ if ($mode == 'config' && $user->admin)
print '
';
dol_fiche_end();
-
+
if ($action!='editprinter') {
print '';
} else {
@@ -324,9 +330,9 @@ if ($mode == 'config' && $user->admin)
print '';
print '';
-
+
dol_fiche_head();
-
+
print $langs->trans("ReceiptPrinterTypeDesc")."
\n";
print ''."\n";
print ''.$langs->trans("CONNECTOR_DUMMY").': '.$langs->trans("CONNECTOR_DUMMY_HELP").' ';
@@ -338,7 +344,7 @@ if ($mode == 'config' && $user->admin)
dol_fiche_end();
print '';
-
+
dol_fiche_head();
print $langs->trans("ReceiptPrinterProfileDesc")."
\n";
print ''."\n";
@@ -378,7 +384,7 @@ if ($mode == 'template' && $user->admin)
setEventMessages($printer->error, $printer->errors, 'errors');
} else {
$max = count($printer->listprinterstemplates);
- for ($line=0; $line < $max; $line++)
+ for ($line=0; $line < $max; $line++)
{
print '';
if ($action=='edittemplate' && $printer->listprinterstemplates[$line]['rowid']==$templateid) {
@@ -423,7 +429,7 @@ if ($mode == 'template' && $user->admin)
print ''.$langs->trans("Description").' ';
print " \n";
$max = count($printer->tags);
- for ($tag=0; $tag < $max; $tag++)
+ for ($tag=0; $tag < $max; $tag++)
{
print '';
print '<'.$printer->tags[$tag].'> '.$langs->trans(strtoupper($printer->tags[$tag])).' ';
@@ -436,18 +442,17 @@ if ($mode == 'template' && $user->admin)
}
// to remove after test
-$object=new stdClass();
-$object->date_time = '2015-11-02 22:30:25';
-$object->id = 1234;
-$object->customer_firstname = 'John';
-$object->customer_lastname = 'Deuf';
-$object->vendor_firstname = 'Jim';
-$object->vendor_lastname = 'Big';
-$object->barcode = '3700123862396';
+// $object=new stdClass();
+// $object->date_time = '2015-11-02 22:30:25';
+// $object->id = 1234;
+// $object->customer_firstname = 'John';
+// $object->customer_lastname = 'Deuf';
+// $object->vendor_firstname = 'Jim';
+// $object->vendor_lastname = 'Big';
+// $object->barcode = '3700123862396';
//$printer->sendToPrinter($object, 1, 16);
//setEventMessages($printer->error, $printer->errors, 'errors');
+// End of page
llxFooter();
-
$db->close();
-
diff --git a/htdocs/admin/resource.php b/htdocs/admin/resource.php
index e8f8bdba204..566e57e587b 100644
--- a/htdocs/admin/resource.php
+++ b/htdocs/admin/resource.php
@@ -137,6 +137,6 @@ print '';
dol_fiche_end();
-
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/admin/resource_extrafields.php b/htdocs/admin/resource_extrafields.php
index 722e5d88a9c..b8ea860ac25 100644
--- a/htdocs/admin/resource_extrafields.php
+++ b/htdocs/admin/resource_extrafields.php
@@ -116,6 +116,6 @@ if ($action == 'edit' && ! empty($attrname))
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php';
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/salaries.php b/htdocs/admin/salaries.php
index 6c5281173c3..a68a4bda5a6 100644
--- a/htdocs/admin/salaries.php
+++ b/htdocs/admin/salaries.php
@@ -75,7 +75,7 @@ if ($action == 'update')
llxHeader('',$langs->trans('SalariesSetup'));
$form = new Form($db);
-if (! empty($conf->accounting->enabled)) $formaccounting = New FormAccounting($db);
+if (! empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db);
$linkback=''.$langs->trans("BackToModuleList").'';
print load_fiche_titre($langs->trans('SalariesSetup'),$linkback,'title_setup');
@@ -127,5 +127,6 @@ print '';
-
// Form to test upload
print '
';
$formfile=new FormFile($db);
@@ -188,5 +187,6 @@ $formfile->form_attach_new_file($_SERVER['PHP_SELF'], $langs->trans("FormToTestF
$filearray=dol_dir_list($upload_dir, "files", 0, '', '', 'name', SORT_ASC, 1);
$formfile->list_of_documents($filearray, null, 'admin_temp', '');
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/admin/security_other.php b/htdocs/admin/security_other.php
index 6503ab10f77..0e3da947fa8 100644
--- a/htdocs/admin/security_other.php
+++ b/htdocs/admin/security_other.php
@@ -206,6 +206,6 @@ print '';
-
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/admin/sms.php b/htdocs/admin/sms.php
index db1cb20b5e3..45071117c89 100644
--- a/htdocs/admin/sms.php
+++ b/htdocs/admin/sms.php
@@ -48,12 +48,12 @@ $action=GETPOST('action','aZ09');
if ($action == 'update' && empty($_POST["cancel"]))
{
- dolibarr_set_const($db, "MAIN_DISABLE_ALL_SMS", $_POST["MAIN_DISABLE_ALL_SMS"],'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_DISABLE_ALL_SMS", $_POST["MAIN_DISABLE_ALL_SMS"], 'chaine', 0, '', $conf->entity);
- dolibarr_set_const($db, "MAIN_SMS_SENDMODE", $_POST["MAIN_SMS_SENDMODE"],'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_SMS_SENDMODE", $_POST["MAIN_SMS_SENDMODE"], 'chaine', 0, '', $conf->entity);
- dolibarr_set_const($db, "MAIN_MAIL_SMS_FROM", $_POST["MAIN_MAIL_SMS_FROM"],'chaine',0,'',$conf->entity);
- //dolibarr_set_const($db, "MAIN_MAIL_AUTOCOPY_TO", $_POST["MAIN_MAIL_AUTOCOPY_TO"],'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_MAIL_SMS_FROM", $_POST["MAIN_MAIL_SMS_FROM"], 'chaine', 0, '', $conf->entity);
+ //dolibarr_set_const($db, "MAIN_MAIL_AUTOCOPY_TO", $_POST["MAIN_MAIL_AUTOCOPY_TO"], 'chaine', 0, '', $conf->entity);
header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup");
exit;
@@ -169,21 +169,21 @@ if ($action == 'edit')
print '';
print ''.$langs->trans("Parameter").' '.$langs->trans("Value").' ';
- // Disable
+ // Disable
print ''.$langs->trans("MAIN_DISABLE_ALL_SMS").' ';
print $form->selectyesno('MAIN_DISABLE_ALL_SMS',$conf->global->MAIN_DISABLE_ALL_SMS,1);
print ' ';
- // Separator
+ // Separator
print ' ';
- // Method
+ // Method
print ''.$langs->trans("MAIN_SMS_SENDMODE").' ';
if (count($listofmethods)) print $form->selectarray('MAIN_SMS_SENDMODE',$listofmethods,$conf->global->MAIN_SMS_SENDMODE,1);
else print ''.$langs->trans("None").'';
print ' ';
- // From
+ // From
print ''.$langs->trans("MAIN_MAIL_SMS_FROM",$langs->transnoentities("Undefined")).' ';
print ' ';
@@ -213,20 +213,20 @@ else
print '';
print ''.$langs->trans("Parameter").' '.$langs->trans("Value").' ';
- // Disable
+ // Disable
print ''.$langs->trans("MAIN_DISABLE_ALL_SMS").' '.yn($conf->global->MAIN_DISABLE_ALL_SMS).' ';
- // Separator
+ // Separator
print ' ';
- // Method
+ // Method
print ''.$langs->trans("MAIN_SMS_SENDMODE").' ';
$text=$listofmethods[$conf->global->MAIN_SMS_SENDMODE];
if (empty($text)) $text=$langs->trans("Undefined").' '.img_warning();
print $text;
print ' ';
- // From
+ // From
print ''.$langs->trans("MAIN_MAIL_SMS_FROM",$langs->transnoentities("Undefined")).' ';
print ''.$conf->global->MAIN_MAIL_SMS_FROM;
if (!empty($conf->global->MAIN_MAIL_SMS_FROM) && ! isValidPhone($conf->global->MAIN_MAIL_SMS_FROM)) print ' '.img_warning($langs->trans("ErrorBadPhone"));
@@ -331,7 +331,6 @@ else
}
}
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/spip.php b/htdocs/admin/spip.php
index b9892fdf2a9..d179c66d58d 100644
--- a/htdocs/admin/spip.php
+++ b/htdocs/admin/spip.php
@@ -163,6 +163,6 @@ else
dol_fiche_end();
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/stock.php b/htdocs/admin/stock.php
index e1098ef262d..858422c598c 100644
--- a/htdocs/admin/stock.php
+++ b/htdocs/admin/stock.php
@@ -160,7 +160,7 @@ print '
';
print '';
print '';
print " ".$langs->trans("RuleForStockManagementDecrease")." \n";
-print " \n";
+print " \n";
print ' '."\n";
$found=0;
@@ -262,7 +262,7 @@ print '
';
print '';
print '';
print " ".$langs->trans("RuleForStockManagementIncrease")." \n";
-print " \n";
+print " \n";
print ' '."\n";
$found=0;
@@ -341,7 +341,7 @@ print '
';
print '';
print '';
print " ".$langs->trans("RuleForStockAvailability")." \n";
-print " \n";
+print " \n";
print ' '."\n";
@@ -373,7 +373,7 @@ if($conf->invoice->enabled)
print "\n";
}
-if($conf->order->enabled)
+if($conf->order->enabled)
{
print '';
print ''.$langs->trans("StockMustBeEnoughForOrder").' ';
@@ -388,7 +388,7 @@ if($conf->order->enabled)
print " \n";
}
-if($conf->expedition->enabled)
+if($conf->expedition->enabled)
{
print '';
print ''.$langs->trans("StockMustBeEnoughForShipment").' ';
@@ -416,7 +416,7 @@ if ($virtualdiffersfromphysical)
print '';
print '';
print " ".$langs->trans("RuleForStockReplenishment")." ".img_help('help',$langs->trans("VirtualDiffersFromPhysical"))." \n";
- print " \n";
+ print " \n";
print ' '."\n";
print '';
@@ -439,12 +439,12 @@ print '';
print '';
print " ".$langs->trans("Other")." \n";
-print " \n";
+print " \n";
print ' '."\n";
print '';
print ''.$langs->trans("UserWarehouseAutoCreate").' ';
-print '';
+print ' ';
print "";
print '';
print "";
@@ -456,7 +456,8 @@ print " \n";
print '';
print '';
-print $form->textwithpicto($langs->trans("StockSupportServices"), $langs->trans("StockSupportServicesDesc")).' ';
+print $form->textwithpicto($langs->trans("StockSupportServices"), $langs->trans("StockSupportServicesDesc"));
+print '';
print '';
print "";
print '';
@@ -502,7 +503,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
print '';
print ''.$langs->trans("Inventory").' '."\n";
print ' ';
- print ' '."\n";
+ print ' '."\n";
// Example with a yes / no select
print ' ';
@@ -566,7 +567,6 @@ if ($conf->global->PRODUIT_SOUSPRODUITS)
}
*/
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/supplier_invoice.php b/htdocs/admin/supplier_invoice.php
index 75a917dd185..367d1fe0d36 100644
--- a/htdocs/admin/supplier_invoice.php
+++ b/htdocs/admin/supplier_invoice.php
@@ -516,7 +516,6 @@ print " \n";
print '
';
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/supplier_order.php b/htdocs/admin/supplier_order.php
index 695d25a963c..72050867dfa 100644
--- a/htdocs/admin/supplier_order.php
+++ b/htdocs/admin/supplier_order.php
@@ -589,7 +589,6 @@ print " \n";
print '
';
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/supplier_payment.php b/htdocs/admin/supplier_payment.php
index c1f3a7cb25d..55fb311ccda 100644
--- a/htdocs/admin/supplier_payment.php
+++ b/htdocs/admin/supplier_payment.php
@@ -430,7 +430,6 @@ print '
';
dol_fiche_end();
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/supplier_proposal.php b/htdocs/admin/supplier_proposal.php
index 99069447e81..eeb148e9d99 100644
--- a/htdocs/admin/supplier_proposal.php
+++ b/htdocs/admin/supplier_proposal.php
@@ -582,6 +582,7 @@ print "\n";
print "\n ".$langs->trans("PathDirectory")." \n ".$conf->supplier_proposal->dir_output." \n \n";
print "
\n
";
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/admin/supplierinvoice_extrafields.php b/htdocs/admin/supplierinvoice_extrafields.php
index 16da8bf7a5c..bbda698a778 100644
--- a/htdocs/admin/supplierinvoice_extrafields.php
+++ b/htdocs/admin/supplierinvoice_extrafields.php
@@ -4,7 +4,7 @@
* Copyright (C) 2004-2013 Laurent Destailleur
* Copyright (C) 2012 Regis Houssin
* Copyright (C) 2012 Florian Henry
- * Copyright (C) 2013 Philippe Grand
+ * Copyright (C) 2013-2018 Philippe Grand
* Copyright (C) 2013 Juanjo Menent
*
* This program is free software; you can redistribute it and/or modify
@@ -32,17 +32,11 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/fourn.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
// Load translation files required by the page
-$langs->load("orders");
+$langs->loadLangs(array("admin", "other", "bills", "orders", "suppliers"));
if (!$user->admin)
accessforbidden();
-$langs->load("admin");
-$langs->load("other");
-$langs->load("bills");
-$langs->load("orders");
-$langs->load("suppliers");
-
$extrafields = new ExtraFields($db);
$form = new Form($db);
@@ -123,6 +117,6 @@ if ($action == 'edit' && ! empty($attrname))
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php';
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/supplierinvoicedet_extrafields.php b/htdocs/admin/supplierinvoicedet_extrafields.php
index 4ca9fd516d7..cdf128871fd 100644
--- a/htdocs/admin/supplierinvoicedet_extrafields.php
+++ b/htdocs/admin/supplierinvoicedet_extrafields.php
@@ -119,6 +119,6 @@ if ($action == 'edit' && ! empty($attrname))
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php';
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/supplierorder_extrafields.php b/htdocs/admin/supplierorder_extrafields.php
index 58c0408510d..640b6375c57 100644
--- a/htdocs/admin/supplierorder_extrafields.php
+++ b/htdocs/admin/supplierorder_extrafields.php
@@ -117,6 +117,6 @@ if ($action == 'edit' && ! empty($attrname))
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php';
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/supplierorderdet_extrafields.php b/htdocs/admin/supplierorderdet_extrafields.php
index 7dfaa02545e..65fe0537ba7 100644
--- a/htdocs/admin/supplierorderdet_extrafields.php
+++ b/htdocs/admin/supplierorderdet_extrafields.php
@@ -118,6 +118,6 @@ if ($action == 'edit' && ! empty($attrname))
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php';
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/syslog.php b/htdocs/admin/syslog.php
index 45dc91a8b95..e163fc83de5 100644
--- a/htdocs/admin/syslog.php
+++ b/htdocs/admin/syslog.php
@@ -302,6 +302,6 @@ if(! empty($conf->loghandlers['mod_syslog_file']) && ! empty($conf->cron->enable
print '
';
print "\n";
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/system/about.php b/htdocs/admin/system/about.php
index 61780d51386..ba61203191a 100644
--- a/htdocs/admin/system/about.php
+++ b/htdocs/admin/system/about.php
@@ -28,10 +28,8 @@ require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
-$langs->load("admin");
-$langs->load("help");
-$langs->load("members");
-$langs->load("other");
+// Load translation files required by the page
+$langs->loadLangs(array("help","members","other","admin"));
$action=GETPOST('action','alpha');
@@ -196,7 +194,7 @@ if ($showpromotemessage)
{
print '
';
print '
';
-
+
if ((empty($tmp[2]) && (strpos($tmp[1], '0') === 0)) || (strpos($tmp[2], '0') === 0))
{
print $langs->trans("TitleExampleForMajorRelease").':
';
@@ -214,7 +212,6 @@ if ($showpromotemessage)
}
}
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/system/browser.php b/htdocs/admin/system/browser.php
index 4f2a53de88d..9df49489e34 100644
--- a/htdocs/admin/system/browser.php
+++ b/htdocs/admin/system/browser.php
@@ -26,9 +26,8 @@ require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
-$langs->load("admin");
-$langs->load("install");
-$langs->load("other");
+// Load translation files required by the page
+$langs->loadLangs(array("install","other","admin"));
if (! $user->admin)
accessforbidden();
@@ -66,7 +65,6 @@ print '
';
print '';
print '
';
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/system/constall.php b/htdocs/admin/system/constall.php
index 82e8481c2dd..d510cc07773 100644
--- a/htdocs/admin/system/constall.php
+++ b/htdocs/admin/system/constall.php
@@ -24,9 +24,8 @@
require '../../main.inc.php';
-$langs->load("admin");
-$langs->load("user");
-$langs->load("install");
+// Load translation files required by the page
+$langs->loadLangs(array("install","user","admin"));
if (!$user->admin)
@@ -249,7 +248,6 @@ if ($resql)
print '
';
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/system/database-tables.php b/htdocs/admin/system/database-tables.php
index 556961cb565..17d72edf20a 100644
--- a/htdocs/admin/system/database-tables.php
+++ b/htdocs/admin/system/database-tables.php
@@ -212,5 +212,6 @@ else
}
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/admin/system/database.php b/htdocs/admin/system/database.php
index 45ce3c087e6..d5a7bbcdbfd 100644
--- a/htdocs/admin/system/database.php
+++ b/htdocs/admin/system/database.php
@@ -126,6 +126,6 @@ else
}
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/system/dbtable.php b/htdocs/admin/system/dbtable.php
index cef493c95f8..392c083c382 100644
--- a/htdocs/admin/system/dbtable.php
+++ b/htdocs/admin/system/dbtable.php
@@ -138,6 +138,6 @@ else
}
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/system/dolibarr.php b/htdocs/admin/system/dolibarr.php
index c0a1c610fe6..9c2ee62565d 100644
--- a/htdocs/admin/system/dolibarr.php
+++ b/htdocs/admin/system/dolibarr.php
@@ -29,9 +29,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
-$langs->load("admin");
-$langs->load("install");
-$langs->load("other");
+// Load translation files required by the page
+$langs->loadLangs(array("install","other","admin"));
$action=GETPOST('action','alpha');
@@ -157,7 +156,7 @@ $i=0;
foreach($_SESSION as $key => $val)
{
if ($i > 0) print ', ';
- print $key.' => '.$val;
+ print $key.' => '.dol_escape_htmltag($val);
$i++;
}
print ' '."\n";
@@ -453,7 +452,6 @@ if ($resql)
print '
';
print '';
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/system/filecheck.php b/htdocs/admin/system/filecheck.php
index 3cef158c2ea..0418830cce8 100644
--- a/htdocs/admin/system/filecheck.php
+++ b/htdocs/admin/system/filecheck.php
@@ -366,11 +366,11 @@ if (! $error && $xml)
// Show warning
if (empty($tmpfilelist) && empty($tmpfilelist2) && empty($tmpfilelist3))
{
- setEventMessage($langs->trans("FileIntegrityIsStrictlyConformedWithReference"));
+ setEventMessages($langs->trans("FileIntegrityIsStrictlyConformedWithReference"), null, 'mesgs');
}
else
{
- setEventMessage($langs->trans("FileIntegritySomeFilesWereRemovedOrModified"), 'warnings');
+ setEventMessages($langs->trans("FileIntegritySomeFilesWereRemovedOrModified"), null, 'warnings');
}
}
else
@@ -422,7 +422,7 @@ if (! $error && $xml)
$outcurrentchecksum = ''.$checksumget.'';
}
- print_fiche_titre($langs->trans("GlobalChecksum")).'
';
+ print load_fiche_titre($langs->trans("GlobalChecksum")).'
';
print $langs->trans("ExpectedChecksum").' = '. $outexpectedchecksum .'
';
print $langs->trans("CurrentChecksum").' = '. $outcurrentchecksum;
@@ -433,12 +433,8 @@ if (! $error && $xml)
print $out;
}
-
-
-
+// End of page
llxFooter();
-
$db->close();
exit($error);
-
diff --git a/htdocs/admin/system/index.php b/htdocs/admin/system/index.php
index 3d473640618..cf79ae910b3 100644
--- a/htdocs/admin/system/index.php
+++ b/htdocs/admin/system/index.php
@@ -25,9 +25,8 @@
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
-$langs->load("admin");
-$langs->load("user");
-$langs->load("install");
+// Load translation files required by the page
+$langs->loadLangs(array("admin", "user", "install"));
if (! $user->admin) accessforbidden();
@@ -106,7 +105,7 @@ print '
';
print '';
print "".$langs->trans("Browser")." \n";
print "".$langs->trans("UserAgent")." " .$_SERVER["HTTP_USER_AGENT"]." \n";
-print "".$langs->trans("Smartphone")." ".(empty($conf->browser->phone)?$langs->trans("No"):$conf->browser->phone)." \n";
+print "".$langs->trans("Smartphone")." ".(($conf->browser->layout != 'phone')?$langs->trans("No"):$langs->trans("Yes"))." \n";
print '
';
print '
';
@@ -114,6 +113,6 @@ print '
';
//print "
\n";
print info_admin($langs->trans("SystemInfoDesc")).'
';
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/system/modules.php b/htdocs/admin/system/modules.php
index 4a6967089e2..c70ad1b7fba 100644
--- a/htdocs/admin/system/modules.php
+++ b/htdocs/admin/system/modules.php
@@ -25,9 +25,8 @@
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
-$langs->load("admin");
-$langs->load("install");
-$langs->load("other");
+// Load translation files required by the page
+$langs->loadLangs(array("install","other","admin"));
if (! $user->admin)
accessforbidden();
@@ -79,17 +78,17 @@ foreach($modulesdir as $dir)
{
try {
$objMod = new $modName($db);
-
+
$modules[$objMod->numero]=$objMod;
$modules_names[$objMod->numero]=$objMod->name;
$modules_files[$objMod->numero]=$file;
$modules_fullpath[$file]=$dir.$file;
$picto[$objMod->numero]=(isset($objMod->picto) && $objMod->picto)?$objMod->picto:'generic';
- }
+ }
catch(Exception $e)
{
dol_syslog("Failed to load ".$dir.$file." ".$e->getMessage(), LOG_ERR);
- }
+ }
}
else
{
@@ -159,5 +158,6 @@ foreach($rights_ids as $right_id)
$old = $right_id;
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/admin/system/os.php b/htdocs/admin/system/os.php
index 01d48f2444d..251025a4c9e 100644
--- a/htdocs/admin/system/os.php
+++ b/htdocs/admin/system/os.php
@@ -49,6 +49,6 @@ $osversion=version_os();
print "".$langs->trans("Version")." ".$osversion." \n";
print '
';
-
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/admin/system/perf.php b/htdocs/admin/system/perf.php
index 1e757b72f63..d69723f1299 100644
--- a/htdocs/admin/system/perf.php
+++ b/htdocs/admin/system/perf.php
@@ -26,9 +26,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
-$langs->load("admin");
-$langs->load("install");
-$langs->load("other");
+// Load translation files required by the page
+$langs->loadLangs(array("install","other","admin"));
if (! $user->admin)
accessforbidden();
@@ -491,7 +490,6 @@ print ''.$langs->trans("DatabaseStatistics").': ';
print '
';
*/
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/system/phpinfo.php b/htdocs/admin/system/phpinfo.php
index 8664a28b28a..aa502cde421 100644
--- a/htdocs/admin/system/phpinfo.php
+++ b/htdocs/admin/system/phpinfo.php
@@ -116,7 +116,6 @@ foreach($phparray as $key => $value)
print '
';
}
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/system/xcache.php b/htdocs/admin/system/xcache.php
index 53eaeec085f..b582e61619b 100644
--- a/htdocs/admin/system/xcache.php
+++ b/htdocs/admin/system/xcache.php
@@ -76,6 +76,6 @@ if ($action == 'clear')
}
*/
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/taxes.php b/htdocs/admin/taxes.php
index 7c4bf64909f..304f9b79bd0 100644
--- a/htdocs/admin/taxes.php
+++ b/htdocs/admin/taxes.php
@@ -273,6 +273,6 @@ if (! empty($conf->accounting->enabled))
print '
'.$langs->trans("AccountingAccountForSalesTaxAreDefinedInto", $langs->transnoentitiesnoconv("MenuAccountancy"), $langs->transnoentitiesnoconv("Setup")).'';
}
-
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/admin/ticket.php b/htdocs/admin/ticket.php
index c6f5e49ff01..5cf72b302c9 100644
--- a/htdocs/admin/ticket.php
+++ b/htdocs/admin/ticket.php
@@ -54,10 +54,13 @@ if ($action == 'updateMask') {
$error++;
}
- if (!$error) {
- setEventMessage($langs->trans("SetupSaved"));
- } else {
- setEventMessage($langs->trans("Error"), 'errors');
+ if (!$error)
+ {
+ setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+ }
+ else
+ {
+ setEventMessages($langs->trans("Error"), null, 'errors');
}
} elseif ($action == 'setmod') {
// TODO Verifier si module numerotation choisi peut etre active
@@ -67,92 +70,92 @@ if ($action == 'updateMask') {
} elseif ($action == 'setvar') {
include_once DOL_DOCUMENT_ROOT . "/core/lib/files.lib.php";
- $notification_email = GETPOST('TICKETS_NOTIFICATION_EMAIL_FROM', 'alpha');
+ $notification_email = GETPOST('TICKET_NOTIFICATION_EMAIL_FROM', 'alpha');
if (!empty($notification_email)) {
- $res = dolibarr_set_const($db, 'TICKETS_NOTIFICATION_EMAIL_FROM', $notification_email, 'chaine', 0, '', $conf->entity);
+ $res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_EMAIL_FROM', $notification_email, 'chaine', 0, '', $conf->entity);
} else {
- $res = dolibarr_set_const($db, 'TICKETS_NOTIFICATION_EMAIL_FROM', '', 'chaine', 0, '', $conf->entity);
+ $res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_EMAIL_FROM', '', 'chaine', 0, '', $conf->entity);
}
if (!$res > 0) {
$error++;
}
// altairis : differentiate notification email FROM and TO
- $notification_email_to = GETPOST('TICKETS_NOTIFICATION_EMAIL_TO', 'alpha');
+ $notification_email_to = GETPOST('TICKET_NOTIFICATION_EMAIL_TO', 'alpha');
if (!empty($notification_email_to)) {
- $res = dolibarr_set_const($db, 'TICKETS_NOTIFICATION_EMAIL_TO', $notification_email_to, 'chaine', 0, '', $conf->entity);
+ $res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_EMAIL_TO', $notification_email_to, 'chaine', 0, '', $conf->entity);
} else {
- $res = dolibarr_set_const($db, 'TICKETS_NOTIFICATION_EMAIL_TO', '', 'chaine', 0, '', $conf->entity);
+ $res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_EMAIL_TO', '', 'chaine', 0, '', $conf->entity);
}
if (!$res > 0) {
$error++;
}
- $mail_new_ticket = GETPOST('TICKETS_MESSAGE_MAIL_NEW', 'alpha');
+ $mail_new_ticket = GETPOST('TICKET_MESSAGE_MAIL_NEW', 'alpha');
if (!empty($mail_new_ticket)) {
- $res = dolibarr_set_const($db, 'TICKETS_MESSAGE_MAIL_NEW', $mail_new_ticket, 'chaine', 0, '', $conf->entity);
+ $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_NEW', $mail_new_ticket, 'chaine', 0, '', $conf->entity);
} else {
- $res = dolibarr_set_const($db, 'TICKETS_MESSAGE_MAIL_NEW', $langs->trans('TicketMessageMailNewText'), 'chaine', 0, '', $conf->entity);
+ $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_NEW', $langs->trans('TicketMessageMailNewText'), 'chaine', 0, '', $conf->entity);
}
if (!$res > 0) {
$error++;
}
- $mail_intro = GETPOST('TICKETS_MESSAGE_MAIL_INTRO', 'alpha');
+ $mail_intro = GETPOST('TICKET_MESSAGE_MAIL_INTRO', 'alpha');
if (!empty($mail_intro)) {
- $res = dolibarr_set_const($db, 'TICKETS_MESSAGE_MAIL_INTRO', $mail_intro, 'chaine', 0, '', $conf->entity);
+ $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_INTRO', $mail_intro, 'chaine', 0, '', $conf->entity);
} else {
- $res = dolibarr_set_const($db, 'TICKETS_MESSAGE_MAIL_INTRO', $langs->trans('TicketMessageMailIntroText'), 'chaine', 0, '', $conf->entity);
+ $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_INTRO', $langs->trans('TicketMessageMailIntroText'), 'chaine', 0, '', $conf->entity);
}
if (!$res > 0) {
$error++;
}
- $mail_signature = GETPOST('TICKETS_MESSAGE_MAIL_SIGNATURE', 'alpha');
+ $mail_signature = GETPOST('TICKET_MESSAGE_MAIL_SIGNATURE', 'alpha');
if (!empty($mail_signature)) {
- $res = dolibarr_set_const($db, 'TICKETS_MESSAGE_MAIL_SIGNATURE', $mail_signature, 'chaine', 0, '', $conf->entity);
+ $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_SIGNATURE', $mail_signature, 'chaine', 0, '', $conf->entity);
} else {
- $res = dolibarr_set_const($db, 'TICKETS_MESSAGE_MAIL_SIGNATURE', $langs->trans('TicketMessageMailSignatureText'), 'chaine', 0, '', $conf->entity);
+ $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_SIGNATURE', $langs->trans('TicketMessageMailSignatureText'), 'chaine', 0, '', $conf->entity);
}
if (!$res > 0) {
$error++;
}
- $url_interface = GETPOST('TICKETS_URL_PUBLIC_INTERFACE', 'alpha');
+ $url_interface = GETPOST('TICKET_URL_PUBLIC_INTERFACE', 'alpha');
if (!empty($mail_signature)) {
- $res = dolibarr_set_const($db, 'TICKETS_URL_PUBLIC_INTERFACE', $url_interface, 'chaine', 0, '', $conf->entity);
+ $res = dolibarr_set_const($db, 'TICKET_URL_PUBLIC_INTERFACE', $url_interface, 'chaine', 0, '', $conf->entity);
} else {
- $res = dolibarr_set_const($db, 'TICKETS_URL_PUBLIC_INTERFACE', '', 'chaine', 0, '', $conf->entity);
+ $res = dolibarr_set_const($db, 'TICKET_URL_PUBLIC_INTERFACE', '', 'chaine', 0, '', $conf->entity);
}
if (!$res > 0) {
$error++;
}
- $topic_interface = GETPOST('TICKETS_PUBLIC_INTERFACE_TOPIC', 'alpha');
+ $topic_interface = GETPOST('TICKET_PUBLIC_INTERFACE_TOPIC', 'alpha');
if (!empty($mail_signature)) {
- $res = dolibarr_set_const($db, 'TICKETS_PUBLIC_INTERFACE_TOPIC', $topic_interface, 'chaine', 0, '', $conf->entity);
+ $res = dolibarr_set_const($db, 'TICKET_PUBLIC_INTERFACE_TOPIC', $topic_interface, 'chaine', 0, '', $conf->entity);
} else {
- $res = dolibarr_set_const($db, 'TICKETS_PUBLIC_INTERFACE_TOPIC', '', 'chaine', 0, '', $conf->entity);
+ $res = dolibarr_set_const($db, 'TICKET_PUBLIC_INTERFACE_TOPIC', '', 'chaine', 0, '', $conf->entity);
}
if (!$res > 0) {
$error++;
}
- $text_home = GETPOST('TICKETS_PUBLIC_TEXT_HOME', 'alpha');
+ $text_home = GETPOST('TICKET_PUBLIC_TEXT_HOME', 'alpha');
if (!empty($mail_signature)) {
- $res = dolibarr_set_const($db, 'TICKETS_PUBLIC_TEXT_HOME', $text_home, 'chaine', 0, '', $conf->entity);
+ $res = dolibarr_set_const($db, 'TICKET_PUBLIC_TEXT_HOME', $text_home, 'chaine', 0, '', $conf->entity);
} else {
- $res = dolibarr_set_const($db, 'TICKETS_PUBLIC_TEXT_HOME', $langs->trans('TicketPublicInterfaceTextHome'), 'chaine', 0, '', $conf->entity);
+ $res = dolibarr_set_const($db, 'TICKET_PUBLIC_TEXT_HOME', $langs->trans('TicketPublicInterfaceTextHome'), 'chaine', 0, '', $conf->entity);
}
if (!$res > 0) {
$error++;
}
- $text_help = GETPOST('TICKETS_PUBLIC_TEXT_HELP_MESSAGE', 'alpha');
+ $text_help = GETPOST('TICKET_PUBLIC_TEXT_HELP_MESSAGE', 'alpha');
if (!empty($text_help)) {
- $res = dolibarr_set_const($db, 'TICKETS_PUBLIC_TEXT_HELP_MESSAGE', $text_help, 'chaine', 0, '', $conf->entity);
+ $res = dolibarr_set_const($db, 'TICKET_PUBLIC_TEXT_HELP_MESSAGE', $text_help, 'chaine', 0, '', $conf->entity);
} else {
- $res = dolibarr_set_const($db, 'TICKETS_PUBLIC_TEXT_HELP_MESSAGE', $langs->trans('TicketPublicPleaseBeAccuratelyDescribe'), 'chaine', 0, '', $conf->entity);
+ $res = dolibarr_set_const($db, 'TICKET_PUBLIC_TEXT_HELP_MESSAGE', $langs->trans('TicketPublicPleaseBeAccuratelyDescribe'), 'chaine', 0, '', $conf->entity);
}
if (!$res > 0) {
$error++;
@@ -160,34 +163,34 @@ if ($action == 'updateMask') {
}
if ($action == 'setvarother') {
- $param_enable_public_interface = GETPOST('TICKETS_ENABLE_PUBLIC_INTERFACE', 'alpha');
- $res = dolibarr_set_const($db, 'TICKETS_ENABLE_PUBLIC_INTERFACE', $param_enable_public_interface, 'chaine', 0, '', $conf->entity);
+ $param_enable_public_interface = GETPOST('TICKET_ENABLE_PUBLIC_INTERFACE', 'alpha');
+ $res = dolibarr_set_const($db, 'TICKET_ENABLE_PUBLIC_INTERFACE', $param_enable_public_interface, 'chaine', 0, '', $conf->entity);
if (!$res > 0) {
$error++;
}
- $param_must_exists = GETPOST('TICKETS_EMAIL_MUST_EXISTS', 'alpha');
- $res = dolibarr_set_const($db, 'TICKETS_EMAIL_MUST_EXISTS', $param_must_exists, 'chaine', 0, '', $conf->entity);
+ $param_must_exists = GETPOST('TICKET_EMAIL_MUST_EXISTS', 'alpha');
+ $res = dolibarr_set_const($db, 'TICKET_EMAIL_MUST_EXISTS', $param_must_exists, 'chaine', 0, '', $conf->entity);
if (!$res > 0) {
$error++;
}
- $param_disable_email = GETPOST('TICKETS_DISABLE_ALL_MAILS', 'alpha');
- $res = dolibarr_set_const($db, 'TICKETS_DISABLE_ALL_MAILS', $param_disable_email, 'chaine', 0, '', $conf->entity);
+ $param_disable_email = GETPOST('TICKET_DISABLE_ALL_MAILS', 'alpha');
+ $res = dolibarr_set_const($db, 'TICKET_DISABLE_ALL_MAILS', $param_disable_email, 'chaine', 0, '', $conf->entity);
if (!$res > 0) {
$error++;
}
- $param_activate_log_by_email = GETPOST('TICKETS_ACTIVATE_LOG_BY_EMAIL', 'alpha');
- $res = dolibarr_set_const($db, 'TICKETS_ACTIVATE_LOG_BY_EMAIL', $param_activate_log_by_email, 'chaine', 0, '', $conf->entity);
+ $param_activate_log_by_email = GETPOST('TICKET_ACTIVATE_LOG_BY_EMAIL', 'alpha');
+ $res = dolibarr_set_const($db, 'TICKET_ACTIVATE_LOG_BY_EMAIL', $param_activate_log_by_email, 'chaine', 0, '', $conf->entity);
if (!$res > 0) {
$error++;
}
if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
{
- $param_show_module_logo = GETPOST('TICKETS_SHOW_MODULE_LOGO', 'alpha');
- $res = dolibarr_set_const($db, 'TICKETS_SHOW_MODULE_LOGO', $param_show_module_logo, 'chaine', 0, '', $conf->entity);
+ $param_show_module_logo = GETPOST('TICKET_SHOW_MODULE_LOGO', 'alpha');
+ $res = dolibarr_set_const($db, 'TICKET_SHOW_MODULE_LOGO', $param_show_module_logo, 'chaine', 0, '', $conf->entity);
if (!$res > 0) {
$error++;
}
@@ -195,21 +198,21 @@ if ($action == 'setvarother') {
if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
{
- $param_notification_also_main_addressemail = GETPOST('TICKETS_NOTIFICATION_ALSO_MAIN_ADDRESS', 'alpha');
- $res = dolibarr_set_const($db, 'TICKETS_NOTIFICATION_ALSO_MAIN_ADDRESS', $param_notification_also_main_addressemail, 'chaine', 0, '', $conf->entity);
+ $param_notification_also_main_addressemail = GETPOST('TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS', 'alpha');
+ $res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS', $param_notification_also_main_addressemail, 'chaine', 0, '', $conf->entity);
if (!$res > 0) {
$error++;
}
}
- $param_limit_view = GETPOST('TICKETS_LIMIT_VIEW_ASSIGNED_ONLY', 'alpha');
- $res = dolibarr_set_const($db, 'TICKETS_LIMIT_VIEW_ASSIGNED_ONLY', $param_limit_view, 'chaine', 0, '', $conf->entity);
+ $param_limit_view = GETPOST('TICKET_LIMIT_VIEW_ASSIGNED_ONLY', 'alpha');
+ $res = dolibarr_set_const($db, 'TICKET_LIMIT_VIEW_ASSIGNED_ONLY', $param_limit_view, 'chaine', 0, '', $conf->entity);
if (!$res > 0) {
$error++;
}
- $param_auto_assign = GETPOST('TICKETS_AUTO_ASSIGN_USER_CREATE', 'alpha');
- $res = dolibarr_set_const($db, 'TICKETS_AUTO_ASSIGN_USER_CREATE', $param_auto_assign, 'chaine', 0, '', $conf->entity);
+ $param_auto_assign = GETPOST('TICKET_AUTO_ASSIGN_USER_CREATE', 'alpha');
+ $res = dolibarr_set_const($db, 'TICKET_AUTO_ASSIGN_USER_CREATE', $param_auto_assign, 'chaine', 0, '', $conf->entity);
if (!$res > 0) {
$error++;
}
@@ -358,10 +361,10 @@ print '';
print '' . $langs->trans("TicketsActivatePublicInterface") . ' ';
print '';
if ($conf->use_javascript_ajax) {
- print ajax_constantonoff('TICKETS_ENABLE_PUBLIC_INTERFACE');
+ print ajax_constantonoff('TICKET_ENABLE_PUBLIC_INTERFACE');
} else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
- print $form->selectarray("TICKETS_ENABLE_PUBLIC_INTERFACE", $arrval, $conf->global->TICKETS_ENABLE_PUBLIC_INTERFACE);
+ print $form->selectarray("TICKET_ENABLE_PUBLIC_INTERFACE", $arrval, $conf->global->TICKET_ENABLE_PUBLIC_INTERFACE);
}
print ' ';
print '';
@@ -373,10 +376,10 @@ print ' ';
print '' . $langs->trans("TicketsEmailMustExist") . ' ';
print '';
if ($conf->use_javascript_ajax) {
- print ajax_constantonoff('TICKETS_EMAIL_MUST_EXISTS');
+ print ajax_constantonoff('TICKET_EMAIL_MUST_EXISTS');
} else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
- print $form->selectarray("TICKETS_EMAIL_MUST_EXISTS", $arrval, $conf->global->TICKETS_EMAIL_MUST_EXISTS);
+ print $form->selectarray("TICKET_EMAIL_MUST_EXISTS", $arrval, $conf->global->TICKET_EMAIL_MUST_EXISTS);
}
print ' ';
print '';
@@ -390,10 +393,10 @@ print ' ';
print '' . $langs->trans("TicketsShowModuleLogo") . ' ';
print '';
if ($conf->use_javascript_ajax) {
- print ajax_constantonoff('TICKETS_SHOW_MODULE_LOGO');
+ print ajax_constantonoff('TICKET_SHOW_MODULE_LOGO');
} else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
- print $form->selectarray("TICKETS_SHOW_MODULE_LOGO", $arrval, $conf->global->TICKETS_SHOW_MODULE_LOGO);
+ print $form->selectarray("TICKET_SHOW_MODULE_LOGO", $arrval, $conf->global->TICKET_SHOW_MODULE_LOGO);
}
print ' ';
print '';
@@ -406,10 +409,10 @@ print ' ';
print '' . $langs->trans("TicketsShowCompanyLogo") . ' ';
print '';
if ($conf->use_javascript_ajax) {
- print ajax_constantonoff('TICKETS_SHOW_COMPANY_LOGO');
+ print ajax_constantonoff('TICKET_SHOW_COMPANY_LOGO');
} else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
- print $form->selectarray("TICKETS_SHOW_COMPANY_LOGO", $arrval, $conf->global->TICKETS_SHOW_COMPANY_LOGO);
+ print $form->selectarray("TICKET_SHOW_COMPANY_LOGO", $arrval, $conf->global->TICKET_SHOW_COMPANY_LOGO);
}
print ' ';
print '';
@@ -426,10 +429,10 @@ print '';
print '' . $langs->trans("TicketsDisableEmail") . ' ';
print '';
if ($conf->use_javascript_ajax) {
- print ajax_constantonoff('TICKETS_DISABLE_ALL_MAILS');
+ print ajax_constantonoff('TICKET_DISABLE_ALL_MAILS');
} else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
- print $form->selectarray("TICKETS_DISABLE_ALL_MAILS", $arrval, $conf->global->TICKETS_DISABLE_ALL_MAILS);
+ print $form->selectarray("TICKET_DISABLE_ALL_MAILS", $arrval, $conf->global->TICKET_DISABLE_ALL_MAILS);
}
print ' ';
print '';
@@ -441,10 +444,10 @@ print ' ';
print '' . $langs->trans("TicketsLogEnableEmail") . ' ';
print '';
if ($conf->use_javascript_ajax) {
- print ajax_constantonoff('TICKETS_ACTIVATE_LOG_BY_EMAIL');
+ print ajax_constantonoff('TICKET_ACTIVATE_LOG_BY_EMAIL');
} else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
- print $form->selectarray("TICKETS_ACTIVATE_LOG_BY_EMAIL", $arrval, $conf->global->TICKETS_ACTIVATE_LOG_BY_EMAIL);
+ print $form->selectarray("TICKET_ACTIVATE_LOG_BY_EMAIL", $arrval, $conf->global->TICKET_ACTIVATE_LOG_BY_EMAIL);
}
print ' ';
print '';
@@ -458,10 +461,10 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
print ' ' . $langs->trans("TicketsEmailAlsoSendToMainAddress") . ' ';
print '';
if ($conf->use_javascript_ajax) {
- print ajax_constantonoff('TICKETS_NOTIFICATION_ALSO_MAIN_ADDRESS');
+ print ajax_constantonoff('TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS');
} else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
- print $form->selectarray("TICKETS_NOTIFICATION_ALSO_MAIN_ADDRESS", $arrval, $conf->global->TICKETS_NOTIFICATION_ALSO_MAIN_ADDRESS);
+ print $form->selectarray("TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS", $arrval, $conf->global->TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS);
}
print ' ';
print '';
@@ -474,10 +477,10 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
print ' ' . $langs->trans("TicketsLimitViewAssignedOnly") . ' ';
print '';
if ($conf->use_javascript_ajax) {
- print ajax_constantonoff('TICKETS_LIMIT_VIEW_ASSIGNED_ONLY');
+ print ajax_constantonoff('TICKET_LIMIT_VIEW_ASSIGNED_ONLY');
} else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
- print $form->selectarray("TICKETS_LIMIT_VIEW_ASSIGNED_ONLY", $arrval, $conf->global->TICKETS_LIMIT_VIEW_ASSIGNED_ONLY);
+ print $form->selectarray("TICKET_LIMIT_VIEW_ASSIGNED_ONLY", $arrval, $conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY);
}
print ' ';
print '';
@@ -494,10 +497,10 @@ if (!$conf->use_javascript_ajax) {
print ' ' . $langs->trans("TicketsAutoAssignTicket") . ' ';
print '';
if ($conf->use_javascript_ajax) {
- print ajax_constantonoff('TICKETS_AUTO_ASSIGN_USER_CREATE');
+ print ajax_constantonoff('TICKET_AUTO_ASSIGN_USER_CREATE');
} else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
- print $form->selectarray("TICKETS_AUTO_ASSIGN_USER_CREATE", $arrval, $conf->global->TICKETS_AUTO_ASSIGN_USER_CREATE);
+ print $form->selectarray("TICKET_AUTO_ASSIGN_USER_CREATE", $arrval, $conf->global->TICKET_AUTO_ASSIGN_USER_CREATE);
}
print ' ';
print '';
@@ -533,7 +536,7 @@ if (empty($conf->global->FCKEDITOR_ENABLE_MAIL)) {
// Email d'envoi des notifications
print ' ' . $langs->trans("TicketEmailNotificationFrom") . ' ';
print '';
-print ' ';
+print '';
print '';
print $form->textwithpicto('', $langs->trans("TicketEmailNotificationFromHelp"), 1, 'help');
print ' ';
@@ -542,18 +545,18 @@ print ' ';
// Email de réception des notifications
print '' . $langs->trans("TicketEmailNotificationTo") . ' ';
print '';
-print ' ';
+print '';
print '';
print $form->textwithpicto('', $langs->trans("TicketEmailNotificationToHelp"), 1, 'help');
print ' ';
print ' ';
// Texte de création d'un ticket
-$mail_mesg_new = $conf->global->TICKETS_MESSAGE_MAIL_NEW ? $conf->global->TICKETS_MESSAGE_MAIL_NEW : $langs->trans('TicketNewEmailBody');
+$mail_mesg_new = $conf->global->TICKET_MESSAGE_MAIL_NEW ? $conf->global->TICKET_MESSAGE_MAIL_NEW : $langs->trans('TicketNewEmailBody');
print '' . $langs->trans("TicketNewEmailBodyLabel") . '';
print ' ';
require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
-$doleditor = new DolEditor('TICKETS_MESSAGE_MAIL_NEW', $mail_mesg_new, '100%', 120, 'dolibarr_mailings', '', false, true, $conf->global->FCKEDITOR_ENABLE_MAIL, ROWS_2, 70);
+$doleditor = new DolEditor('TICKET_MESSAGE_MAIL_NEW', $mail_mesg_new, '100%', 120, 'dolibarr_mailings', '', false, true, $conf->global->FCKEDITOR_ENABLE_MAIL, ROWS_2, 70);
$doleditor->Create();
print ' ';
print '';
@@ -561,11 +564,11 @@ print $form->textwithpicto('', $langs->trans("TicketNewEmailBodyHelp"), 1, 'help
print ' ';
// Texte d'introduction
-$mail_intro = $conf->global->TICKETS_MESSAGE_MAIL_INTRO ? $conf->global->TICKETS_MESSAGE_MAIL_INTRO : $langs->trans('TicketMessageMailIntroText');
+$mail_intro = $conf->global->TICKET_MESSAGE_MAIL_INTRO ? $conf->global->TICKET_MESSAGE_MAIL_INTRO : $langs->trans('TicketMessageMailIntroText');
print '' . $langs->trans("TicketMessageMailIntroLabelAdmin") . '';
print ' ';
require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
-$doleditor = new DolEditor('TICKETS_MESSAGE_MAIL_INTRO', $mail_intro, '100%', 120, 'dolibarr_mailings', '', false, true, $conf->global->FCKEDITOR_ENABLE_MAIL, ROWS_2, 70);
+$doleditor = new DolEditor('TICKET_MESSAGE_MAIL_INTRO', $mail_intro, '100%', 120, 'dolibarr_mailings', '', false, true, $conf->global->FCKEDITOR_ENABLE_MAIL, ROWS_2, 70);
$doleditor->Create();
print ' ';
print '';
@@ -573,11 +576,11 @@ print $form->textwithpicto('', $langs->trans("TicketMessageMailIntroHelpAdmin"),
print ' ';
// Texte de signature
-$mail_signature = $conf->global->TICKETS_MESSAGE_MAIL_SIGNATURE ? $conf->global->TICKETS_MESSAGE_MAIL_SIGNATURE : $langs->trans('TicketMessageMailSignatureText');
+$mail_signature = $conf->global->TICKET_MESSAGE_MAIL_SIGNATURE ? $conf->global->TICKET_MESSAGE_MAIL_SIGNATURE : $langs->trans('TicketMessageMailSignatureText');
print '' . $langs->trans("TicketMessageMailSignatureLabelAdmin") . '';
print ' ';
require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
-$doleditor = new DolEditor('TICKETS_MESSAGE_MAIL_SIGNATURE', $mail_signature, '100%', 120, 'dolibarr_mailings', '', false, true, $conf->global->FCKEDITOR_ENABLE_MAIL, ROWS_2, 70);
+$doleditor = new DolEditor('TICKET_MESSAGE_MAIL_SIGNATURE', $mail_signature, '100%', 120, 'dolibarr_mailings', '', false, true, $conf->global->FCKEDITOR_ENABLE_MAIL, ROWS_2, 70);
$doleditor->Create();
print ' ';
print '';
@@ -589,31 +592,31 @@ print ' ' . $langs->trans("PublicInterface") . ' ';
print " \n";
// Url public interface
-$url_interface = $conf->global->TICKETS_URL_PUBLIC_INTERFACE;
+$url_interface = $conf->global->TICKET_URL_PUBLIC_INTERFACE;
print '' . $langs->trans("TicketUrlPublicInterfaceLabelAdmin") . '';
print ' ';
-print ' ';
+print '';
print '';
print '';
print $form->textwithpicto('', $langs->trans("TicketUrlPublicInterfaceHelpAdmin"), 1, 'help');
print ' ';
// Interface topic
-$url_interface = $conf->global->TICKETS_PUBLIC_INTERFACE_TOPIC;
+$url_interface = $conf->global->TICKET_PUBLIC_INTERFACE_TOPIC;
print '' . $langs->trans("TicketPublicInterfaceTopicLabelAdmin") . '';
print ' ';
-print ' ';
+print '';
print '';
print '';
print $form->textwithpicto('', $langs->trans("TicketPublicInterfaceTopicHelp"), 1, 'help');
print ' ';
// Texte d'accueil homepage
-$public_text_home = $conf->global->TICKETS_PUBLIC_TEXT_HOME ? $conf->global->TICKETS_PUBLIC_TEXT_HOME : $langs->trans('TicketPublicInterfaceTextHome');
+$public_text_home = $conf->global->TICKET_PUBLIC_TEXT_HOME ? $conf->global->TICKET_PUBLIC_TEXT_HOME : $langs->trans('TicketPublicInterfaceTextHome');
print '' . $langs->trans("TicketPublicInterfaceTextHomeLabelAdmin") . '';
print ' ';
require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
-$doleditor = new DolEditor('TICKETS_PUBLIC_TEXT_HOME', $public_text_home, '100%', 180, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_2, 70);
+$doleditor = new DolEditor('TICKET_PUBLIC_TEXT_HOME', $public_text_home, '100%', 180, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_2, 70);
$doleditor->Create();
print ' ';
print '';
@@ -621,11 +624,11 @@ print $form->textwithpicto('', $langs->trans("TicketPublicInterfaceTextHomeHelpA
print ' ';
// Texte d'aide à la saisie du message
-$public_text_help_message = $conf->global->TICKETS_PUBLIC_TEXT_HELP_MESSAGE ? $conf->global->TICKETS_PUBLIC_TEXT_HELP_MESSAGE : $langs->trans('TicketPublicPleaseBeAccuratelyDescribe');
+$public_text_help_message = $conf->global->TICKET_PUBLIC_TEXT_HELP_MESSAGE ? $conf->global->TICKET_PUBLIC_TEXT_HELP_MESSAGE : $langs->trans('TicketPublicPleaseBeAccuratelyDescribe');
print '' . $langs->trans("TicketPublicInterfaceTextHelpMessageLabelAdmin") . '';
print ' ';
require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
-$doleditor = new DolEditor('TICKETS_PUBLIC_TEXT_HELP_MESSAGE', $public_text_help_message, '100%', 180, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_2, 70);
+$doleditor = new DolEditor('TICKET_PUBLIC_TEXT_HELP_MESSAGE', $public_text_help_message, '100%', 180, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_2, 70);
$doleditor->Create();
print ' ';
print '';
@@ -638,6 +641,6 @@ print ' ';
print '
';
print '';
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/ticket_extrafields.php b/htdocs/admin/ticket_extrafields.php
index 0687a33c52b..6fa70808ec8 100644
--- a/htdocs/admin/ticket_extrafields.php
+++ b/htdocs/admin/ticket_extrafields.php
@@ -16,9 +16,9 @@
*/
/**
- * \file ticket/admin/ticket_extrafields.php
- * \ingroup ticket
- * \brief Page to setup extra fields of ticket
+ * \file admin/ticket_extrafields.php
+ * \ingroup ticket
+ * \brief Page to setup extra fields of ticket
*/
require '../main.inc.php';
@@ -109,6 +109,6 @@ if ($action == 'edit' && !empty($attrname)) {
include DOL_DOCUMENT_ROOT . '/core/tpl/admin_extrafields_edit.tpl.php';
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/tools/dolibarr_export.php b/htdocs/admin/tools/dolibarr_export.php
index 1c985e23090..c9ef19dae98 100644
--- a/htdocs/admin/tools/dolibarr_export.php
+++ b/htdocs/admin/tools/dolibarr_export.php
@@ -522,6 +522,6 @@ print $langs->trans("BackupDescX").'
';
close();
diff --git a/htdocs/admin/tools/dolibarr_import.php b/htdocs/admin/tools/dolibarr_import.php
index f390c192159..9dc3deec5ac 100644
--- a/htdocs/admin/tools/dolibarr_import.php
+++ b/htdocs/admin/tools/dolibarr_import.php
@@ -24,8 +24,8 @@
require '../../main.inc.php';
-$langs->load("admin");
-$langs->load("other");
+// Load translation files required by the page
+$langs->loadLangs(array("other","admin"));
if (! $user->admin)
accessforbidden();
@@ -212,6 +212,6 @@ else if (in_array($type, array('pgsql')))
close();
diff --git a/htdocs/admin/tools/eaccelerator.php b/htdocs/admin/tools/eaccelerator.php
index d3253c02514..a3205c11a27 100644
--- a/htdocs/admin/tools/eaccelerator.php
+++ b/htdocs/admin/tools/eaccelerator.php
@@ -181,7 +181,6 @@ function create_script_table($list)
print ' ';
}
print '
';
-
}
/**
@@ -335,7 +334,6 @@ if (function_exists('eaccelerator_get')) {
print "
";
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/tools/index.php b/htdocs/admin/tools/index.php
index 98a490550ca..aed25ae45a3 100644
--- a/htdocs/admin/tools/index.php
+++ b/htdocs/admin/tools/index.php
@@ -24,8 +24,8 @@
require '../../main.inc.php';
-$langs->load("admin");
-$langs->load("companies");
+// Load translation files required by the page
+$langs->loadLangs(array("companies","admin"));
if (! $user->admin)
accessforbidden();
@@ -56,6 +56,6 @@ print '
';
//print '';
print ' '; // For a reason I don't know, the div class="center does not works, we must keep the
-
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/admin/tools/listevents.php b/htdocs/admin/tools/listevents.php
index 48d3ef57fd5..9afe7c5fcb3 100644
--- a/htdocs/admin/tools/listevents.php
+++ b/htdocs/admin/tools/listevents.php
@@ -2,6 +2,7 @@
/* Copyright (C) 2004-2017 Laurent Destailleur
* Copyright (C) 2005-2012 Regis Houssin
* Copyright (C) 2015 Bahfir Abbes
+ * 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
@@ -40,10 +41,8 @@ if ($user->societe_id > 0)
$socid = $user->societe_id;
}
-$langs->load("admin");
-$langs->load("companies");
-$langs->load("users");
-$langs->load("other");
+// Load translation files required by the page
+$langs->loadLangs(array("companies","admin","users","other"));
// Load variable for pagination
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
@@ -237,7 +236,7 @@ if ($result)
// Lignes des champs de filtres
print '';
- print ''.$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).$form->select_date($date_end,'date_end',0,0,0,'',1,0,1).' ';
+ print ''.$form->selectDate($date_start,'date_start',0,0,0,'',1,0).$form->selectDate($date_end,'date_end',0,0,0,'',1,0).' ';
print '';
print '';
@@ -339,6 +338,6 @@ else
dol_print_error($db);
}
-
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/admin/tools/listsessions.php b/htdocs/admin/tools/listsessions.php
index 70b0987732b..b1732e0883b 100644
--- a/htdocs/admin/tools/listsessions.php
+++ b/htdocs/admin/tools/listsessions.php
@@ -25,7 +25,8 @@
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
-$langs->load("install");
+// Load translation files required by the page
+$langs->loadLangs(array("companies","install","users","other"));
if (! $user->admin)
accessforbidden();
@@ -40,10 +41,6 @@ if ($user->societe_id > 0)
$socid = $user->societe_id;
}
-$langs->load("companies");
-$langs->load("users");
-$langs->load("other");
-
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');
@@ -208,5 +205,6 @@ print '';
print '
';
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/admin/tools/purge.php b/htdocs/admin/tools/purge.php
index f415ed1692c..097fc507240 100644
--- a/htdocs/admin/tools/purge.php
+++ b/htdocs/admin/tools/purge.php
@@ -119,7 +119,6 @@ if (preg_match('/^confirm/i',$choice))
print $form->formconfirm($_SERVER["PHP_SELF"].'?choice=allfiles', $langs->trans('Purge'), $langs->trans('ConfirmPurge').img_warning().' ', 'purge', $formquestion, 'no', 2);
}
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/tools/update.php b/htdocs/admin/tools/update.php
index d0802d6b473..1ec7c98552e 100644
--- a/htdocs/admin/tools/update.php
+++ b/htdocs/admin/tools/update.php
@@ -27,8 +27,8 @@ require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/geturl.lib.php';
-$langs->load("admin");
-$langs->load("other");
+// Load translation files required by the page
+$langs->loadLangs(array("admin","other"));
$action=GETPOST('action','alpha');
@@ -76,7 +76,7 @@ print $langs->trans("CurrentVersion").' : '.DOL_VERSION.'
';
if (function_exists('curl_init'))
{
$conf->global->MAIN_USE_RESPONSE_TIMEOUT = 10;
-
+
if ($action == 'getlastversion')
{
if ($sfurl)
@@ -95,7 +95,7 @@ if (function_exists('curl_init'))
}
$i++;
}
-
+
// Show version
print $langs->trans("LastStableVersion").' : '. (($version != '0.0')?$version:$langs->trans("Unknown")) .'
';
}
@@ -142,7 +142,6 @@ print '
';
print $langs->trans("GoModuleSetupArea", DOL_URL_ROOT.'/admin/modules.php?mode=deploy', $langs->transnoentities("Home").' - '.$langs->transnoentities("Setup").' - '.$langs->transnoentities("Modules"));
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/translation.php b/htdocs/admin/translation.php
index 55a407c3e61..4c215e9ae52 100644
--- a/htdocs/admin/translation.php
+++ b/htdocs/admin/translation.php
@@ -40,7 +40,7 @@ $transkey=GETPOST('transkey','alpha');
$transvalue=GETPOST('transvalue','alpha');
-$mode = GETPOST('mode')?GETPOST('mode'):'overwrite';
+$mode = GETPOST('mode','aZ09')?GETPOST('mode','aZ09'):'overwrite';
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha');
@@ -584,6 +584,6 @@ if (! empty($langcode))
dol_set_focus('#transvalue');
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/triggers.php b/htdocs/admin/triggers.php
index 1a1893e2eb0..cd2f33b4cb0 100644
--- a/htdocs/admin/triggers.php
+++ b/htdocs/admin/triggers.php
@@ -84,6 +84,6 @@ foreach ($triggers as $trigger)
print '';
print '';
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/admin/user.php b/htdocs/admin/user.php
index f888c8410bb..2cf8fc5b6f3 100644
--- a/htdocs/admin/user.php
+++ b/htdocs/admin/user.php
@@ -337,5 +337,6 @@ print "
";
dol_fiche_end();
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/admin/usergroup.php b/htdocs/admin/usergroup.php
index 28f1ad6af2f..c1b55dcec6a 100644
--- a/htdocs/admin/usergroup.php
+++ b/htdocs/admin/usergroup.php
@@ -282,5 +282,6 @@ print "
";
dol_fiche_end();
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/admin/website.php b/htdocs/admin/website.php
index 80144f93c1f..fcdeee79249 100644
--- a/htdocs/admin/website.php
+++ b/htdocs/admin/website.php
@@ -322,10 +322,16 @@ if ($action == 'confirm_delete' && $confirm == 'yes') // delete
if ($website->id > 0)
{
- $sql = "DELETE from ".MAIN_DB_PREFIX."website_page WHERE fk_website ='".$rowid."'";
- $result = $db->query($sql);
+ $sql = "DELETE from ".MAIN_DB_PREFIX."website_account WHERE fk_website ='".$rowid."'";
+ $result = $db->query($sql);
- $sql = "DELETE from ".MAIN_DB_PREFIX."website WHERE rowid ='".$rowid."'";
+ $sql = "DELETE from ".MAIN_DB_PREFIX."website_page WHERE fk_website ='".$rowid."'";
+ $result = $db->query($sql);
+
+ $sql = "DELETE from ".MAIN_DB_PREFIX."website_extrafields WHERE fk_object ='".$rowid."'";
+ $result = $db->query($sql);
+
+ $sql = "DELETE from ".MAIN_DB_PREFIX."website WHERE rowid ='".$rowid."'";
$result = $db->query($sql);
if (! $result)
{
@@ -640,9 +646,7 @@ if ($id)
dol_fiche_end();
-//print '
';
-
-
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/admin/website_options.php b/htdocs/admin/website_options.php
index c688da0e550..9d724b86390 100644
--- a/htdocs/admin/website_options.php
+++ b/htdocs/admin/website_options.php
@@ -143,9 +143,8 @@ else
dol_fiche_end();
-//print '
';
-
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/admin/workflow.php b/htdocs/admin/workflow.php
index b5bdec73f3e..24a39ce827a 100644
--- a/htdocs/admin/workflow.php
+++ b/htdocs/admin/workflow.php
@@ -187,7 +187,6 @@ if ($nbqualified == 0)
}
print '';
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/api/class/api.class.php b/htdocs/api/class/api.class.php
index 92391a14dc0..6ddb4dae1b3 100644
--- a/htdocs/api/class/api.class.php
+++ b/htdocs/api/class/api.class.php
@@ -65,6 +65,8 @@ class DolibarrApi
$this->r->setBaseUrls($urlwithouturlroot, $urlwithouturlrootautodetect);
$this->r->setAPIVersion(1);
+ //$this->r->setSupportedFormats('json');
+ //$this->r->setSupportedFormats('jsonFormat');
}
/**
@@ -92,10 +94,12 @@ class DolibarrApi
* @param object $object Object to clean
* @return array Array of cleaned object properties
*/
- function _cleanObjectDatas($object) {
+ function _cleanObjectDatas($object)
+ {
// Remove $db object property for object
unset($object->db);
+ unset($object->isextrafieldmanaged);
unset($object->ismultientitymanaged);
unset($object->restrictiononfksoc);
@@ -215,9 +219,11 @@ class DolibarrApi
* @param string $feature2 Feature to check, second level of permission (optional). Can be or check with 'level1|level2'.
* @param string $dbt_keyfield Field name for socid foreign key if not fk_soc. Not used if objectid is null (optional)
* @param string $dbt_select Field name for select if not rowid. Not used if objectid is null (optional)
+ * @return bool
* @throws RestException
*/
- static function _checkAccessToResource($resource, $resource_id=0, $dbtablename='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid') {
+ static function _checkAccessToResource($resource, $resource_id=0, $dbtablename='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid')
+ {
// Features/modules to check
$featuresarray = array($resource);
@@ -265,6 +271,7 @@ class DolibarrApi
return true;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Function to forge a SQL criteria
*
@@ -273,6 +280,7 @@ class DolibarrApi
*/
static function _forge_criteria_callback($matches)
{
+ // phpcs:enable
global $db;
//dol_syslog("Convert matches ".$matches[1]);
diff --git a/htdocs/api/class/api_access.class.php b/htdocs/api/class/api_access.class.php
index d067d6e2ad6..e453bd331c2 100644
--- a/htdocs/api/class/api_access.class.php
+++ b/htdocs/api/class/api_access.class.php
@@ -59,8 +59,7 @@ class DolibarrApiAccess implements iAuthenticate
*/
public static $user = '';
- // @codingStandardsIgnoreStart
-
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName
/**
* Check access
*
@@ -69,6 +68,7 @@ class DolibarrApiAccess implements iAuthenticate
*/
public function __isAllowed()
{
+ // phpcs:enable
global $conf, $db;
$login = '';
@@ -166,6 +166,7 @@ class DolibarrApiAccess implements iAuthenticate
return in_array(static::$role, (array) $requirefortest) || static::$role == 'admin';
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName
/**
* @return string string to be used with WWW-Authenticate header
* @example Basic
@@ -174,9 +175,9 @@ class DolibarrApiAccess implements iAuthenticate
*/
public function __getWWWAuthenticateString()
{
+ // phpcs:enable
return '';
}
- // @codingStandardsIgnoreEnd
/**
* Verify access
@@ -196,6 +197,5 @@ class DolibarrApiAccess implements iAuthenticate
return $requires
? static::$role == 'admin' || in_array(static::$role, (array) $requires)
: true;
-
}
}
diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php
index 07f124741fe..66c293f2cb0 100644
--- a/htdocs/api/class/api_documents.class.php
+++ b/htdocs/api/class/api_documents.class.php
@@ -356,6 +356,22 @@ class Documents extends DolibarrApi
$upload_dir = $conf->facture->dir_output . "/" . get_exdir(0, 0, 0, 1, $object, 'invoice');
}
+ else if ($modulepart == 'agenda' || $modulepart == 'action' || $modulepart == 'event')
+ {
+ require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
+
+ if (!DolibarrApiAccess::$user->rights->agenda->myactions->read && !DolibarrApiAccess::$user->rights->agenda->allactions->read) {
+ throw new RestException(401);
+ }
+
+ $object = new ActionComm($this->db);
+ $result=$object->fetch($id, $ref);
+ if ( ! $result ) {
+ throw new RestException(404, 'Event not found');
+ }
+
+ $upload_dir = $conf->agenda->dir_output.'/'.dol_sanitizeFileName($object->ref);
+ }
else
{
throw new RestException(500, 'Modulepart '.$modulepart.' not implemented yet.');
diff --git a/htdocs/api/class/api_login.class.php b/htdocs/api/class/api_login.class.php
index 56808819b3f..86d1cfff87c 100644
--- a/htdocs/api/class/api_login.class.php
+++ b/htdocs/api/class/api_login.class.php
@@ -26,7 +26,11 @@ require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
class Login
{
- function __construct() {
+ /**
+ * Constructor of the class
+ */
+ function __construct()
+ {
global $db;
$this->db = $db;
}
@@ -51,7 +55,8 @@ class Login
* @url GET /
* @url POST /
*/
- public function index($login, $password, $entity='', $reset=0) {
+ public function index($login, $password, $entity='', $reset=0)
+ {
global $conf, $dolibarr_main_authentication, $dolibarr_auto_user;
diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php
index ef2b4c8bb6d..9389e2ff5ed 100644
--- a/htdocs/api/class/api_setup.class.php
+++ b/htdocs/api/class/api_setup.class.php
@@ -1,8 +1,8 @@
* Copyright (C) 2016 Laurent Destailleur
- * Copyright (C) 2017 Regis Houssin
- * Copyright (C) 2017 Neil Orley
+ * Copyright (C) 2017 Regis Houssin
+ * Copyright (C) 2017 Neil Orley
*
*
* This program is free software; you can redistribute it and/or modify
@@ -188,6 +188,7 @@ class Setup extends DolibarrApi
* @param int $id ID of country
* @param string $lang Code of the language the name of the
* country must be translated to
+ * @return array Array of cleaned object properties
*
* @url GET dictionary/countries/{id}
*
@@ -293,6 +294,7 @@ class Setup extends DolibarrApi
* @param Ccountry $country Country
* @param string $lang Code of the language the name of the
* country must be translated to
+ * @return void
*/
private function translateLabel($country, $lang)
{
@@ -863,11 +865,11 @@ class Setup extends DolibarrApi
// Show warning
if (empty($tmpfilelist) && empty($tmpfilelist2) && empty($tmpfilelist3))
{
- //setEventMessage($langs->trans("FileIntegrityIsStrictlyConformedWithReference"));
+ //setEventMessages($langs->trans("FileIntegrityIsStrictlyConformedWithReference"), null, 'mesgs');
}
else
{
- //setEventMessage($langs->trans("FileIntegritySomeFilesWereRemovedOrModified"), 'warnings');
+ //setEventMessages($langs->trans("FileIntegritySomeFilesWereRemovedOrModified"), null, 'warnings');
}
}
else
@@ -916,5 +918,4 @@ class Setup extends DolibarrApi
return array('resultcode'=>$resultcode, 'resultcomment'=>$resultcomment, 'expectedchecksum'=> $outexpectedchecksum, 'currentchecksum'=> $outcurrentchecksum, 'out'=>$out);
}
-
}
diff --git a/htdocs/api/class/api_status.class.php b/htdocs/api/class/api_status.class.php
index ea61731b51a..3ade4ea51b8 100644
--- a/htdocs/api/class/api_status.class.php
+++ b/htdocs/api/class/api_status.class.php
@@ -26,18 +26,21 @@ require_once DOL_DOCUMENT_ROOT . '/core/lib/functions.lib.php';
*/
class Status
{
- /**
+ /**
* Get status (Dolibarr version)
- */
- function index() {
- global $conf;
+ *
+ * @return array
+ */
+ function index()
+ {
+ global $conf;
- return array(
- 'success' => array(
- 'code' => 200,
- 'dolibarr_version' => DOL_VERSION,
- 'access_locked' => (empty($conf->global->MAIN_ONLY_LOGIN_ALLOWED)?'0':$conf->global->MAIN_ONLY_LOGIN_ALLOWED)
- )
- );
+ return array(
+ 'success' => array(
+ 'code' => 200,
+ 'dolibarr_version' => DOL_VERSION,
+ 'access_locked' => (empty($conf->global->MAIN_ONLY_LOGIN_ALLOWED)?'0':$conf->global->MAIN_ONLY_LOGIN_ALLOWED),
+ ),
+ );
}
}
diff --git a/htdocs/asset/admin/assets_extrafields.php b/htdocs/asset/admin/assets_extrafields.php
index 1cdf78df4bf..109b0f1e94f 100644
--- a/htdocs/asset/admin/assets_extrafields.php
+++ b/htdocs/asset/admin/assets_extrafields.php
@@ -109,6 +109,6 @@ if ($action == 'edit' && ! empty($attrname))
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php';
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/asset/admin/assets_type_extrafields.php b/htdocs/asset/admin/assets_type_extrafields.php
index d828bffa4de..e8f1d71370b 100644
--- a/htdocs/asset/admin/assets_type_extrafields.php
+++ b/htdocs/asset/admin/assets_type_extrafields.php
@@ -107,6 +107,6 @@ if ($action == 'edit' && ! empty($attrname))
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php';
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/asset/admin/setup.php b/htdocs/asset/admin/setup.php
index c240f350590..1168fd3ada3 100644
--- a/htdocs/asset/admin/setup.php
+++ b/htdocs/asset/admin/setup.php
@@ -107,9 +107,8 @@ else
print '';
}
-
-// Page end
dol_fiche_end();
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/asset/card.php b/htdocs/asset/card.php
index 1cb580c8c8d..9af7638316f 100644
--- a/htdocs/asset/card.php
+++ b/htdocs/asset/card.php
@@ -17,7 +17,7 @@
*/
/**
- * \file card.php
+ * \file htdocs/asset/card.php
* \ingroup asset
* \brief Page to create/edit/view asset
*/
@@ -25,8 +25,8 @@
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/asset.lib.php';
require_once DOL_DOCUMENT_ROOT.'/asset/class/asset.class.php';
-include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php');
-include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php');
+require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
// Load translation files required by the page
$langs->loadLangs(array("asset"));
@@ -95,8 +95,8 @@ if (empty($reshook))
include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
// Actions to send emails
- $trigger_name='MYOBJECT_SENTBYMAIL';
- $autocopy='MAIN_MAIL_AUTOCOPY_MYOBJECT_TO';
+ $trigger_name='ASSET_SENTBYMAIL';
+ $autocopy='MAIN_MAIL_AUTOCOPY_ASSET_TO';
$trackid='asset'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
}
@@ -221,12 +221,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220);
}
- if (! $formconfirm) {
- $parameters = array('lineid' => $lineid);
- $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
- if (empty($reshook)) $formconfirm.=$hookmanager->resPrint;
- elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint;
- }
+ // Call Hook formConfirm
+ $parameters = array('lineid' => $lineid);
+ $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
+ if (empty($reshook)) $formconfirm.=$hookmanager->resPrint;
+ elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint;
// Print form confirm
print $formconfirm;
diff --git a/htdocs/asset/class/asset.class.php b/htdocs/asset/class/asset.class.php
index 4ab05ce675c..596b795999d 100644
--- a/htdocs/asset/class/asset.class.php
+++ b/htdocs/asset/class/asset.class.php
@@ -35,18 +35,22 @@ class Asset extends CommonObject
* @var string ID to identify managed object
*/
public $element = 'asset';
+
/**
* @var string Name of table without prefix where object is stored
*/
public $table_element = 'asset';
+
/**
* @var int Does module support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
*/
public $ismultientitymanaged = 0;
+
/**
* @var int Does asset support extrafields ? 0=No, 1=Yes
*/
public $isextrafieldmanaged = 1;
+
/**
* @var string String with name of icon for asset. Must be the part after the 'object_' into object_asset.png
*/
@@ -91,13 +95,36 @@ class Asset extends CommonObject
'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'visible'=>-2, 'enabled'=>1, 'position'=>1000, 'notnull'=>-1,),
'status' => array('type'=>'integer', 'label'=>'Status', 'visible'=>1, 'enabled'=>1, 'position'=>1000, 'notnull'=>1, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Draft', '1'=>'Active', '-1'=>'Cancel')),
);
+
+ /**
+ * @var int ID
+ */
public $rowid;
+
+ /**
+ * @var string Ref
+ */
public $ref;
+
public $entity;
- public $label;
+
+ /**
+ * @var string Asset label
+ */
+ public $label;
+
public $amount;
- public $fk_soc;
+
+ /**
+ * @var int Thirdparty ID
+ */
+ public $fk_soc;
+
+ /**
+ * @var string description
+ */
public $description;
+
public $note_public;
public $note_private;
public $date_creation;
@@ -329,6 +356,7 @@ class Asset extends CommonObject
return $this->LibStatut($this->status,$mode);
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Return the status
*
@@ -338,40 +366,35 @@ class Asset extends CommonObject
*/
static function LibStatut($status,$mode=0)
{
+ // phpcs:enable
global $langs;
- if ($mode == 0)
- {
- $prefix='';
- if ($status == 1) return $langs->trans('Enabled');
- if ($status == 0) return $langs->trans('Disabled');
- }
- if ($mode == 1)
+ if ($mode == 0 || $mode == 1)
{
if ($status == 1) return $langs->trans('Enabled');
if ($status == 0) return $langs->trans('Disabled');
}
- if ($mode == 2)
+ elseif ($mode == 2)
{
if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled');
if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled');
}
- if ($mode == 3)
+ elseif ($mode == 3)
{
if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4');
if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5');
}
- if ($mode == 4)
+ elseif ($mode == 4)
{
if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled');
if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled');
}
- if ($mode == 5)
+ elseif ($mode == 5)
{
if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4');
if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5');
}
- if ($mode == 6)
+ elseif ($mode == 6)
{
if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4');
if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5');
@@ -461,4 +484,4 @@ class Asset extends CommonObject
return 0;
}
-}
\ No newline at end of file
+}
diff --git a/htdocs/asset/class/asset_type.class.php b/htdocs/asset/class/asset_type.class.php
index 51ea3a0c799..df2f4c1415e 100644
--- a/htdocs/asset/class/asset_type.class.php
+++ b/htdocs/asset/class/asset_type.class.php
@@ -29,21 +29,38 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
*/
class AssetType extends CommonObject
{
+ /**
+ * @var string Name of table without prefix where object is stored
+ */
public $table_element = 'asset_type';
+
+ /**
+ * @var string ID to identify managed object
+ */
public $element = 'asset_type';
+
+ /**
+ * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
+ */
public $picto = 'group';
+
public $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
/** @var string Label */
public $label;
+
/** @var string Accountancy code asset */
public $accountancy_code_asset;
+
/** @var string Accountancy code depreciation asset */
public $accountancy_code_depreciation_asset;
+
/** @var string Accountancy code depreciation expense */
public $accountancy_code_depreciation_expense;
+
/** @var string Public note */
public $note;
+
/** @var array Array of asset */
public $asset=array();
@@ -274,6 +291,7 @@ class AssetType extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Return list of asset's type
*
@@ -281,6 +299,7 @@ class AssetType extends CommonObject
*/
function liste_array()
{
+ // phpcs:enable
global $conf,$langs;
$assettypes = array();
@@ -429,5 +448,4 @@ class AssetType extends CommonObject
{
return '';
}
-
}
diff --git a/htdocs/asset/document.php b/htdocs/asset/document.php
index 66baaae196c..784f65aa220 100644
--- a/htdocs/asset/document.php
+++ b/htdocs/asset/document.php
@@ -17,7 +17,7 @@
*/
/**
- * \file document.php
+ * \file htdocs/asset/document.php
* \ingroup asset
* \brief Tab for documents linked to Assets
*/
@@ -100,7 +100,7 @@ if ($object->id)
dol_fiche_head($head, 'document', $langs->trans("Asset"), -1, 'generic');
- // Construit liste des fichiers
+ // Build file list
$filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
$totalsize=0;
foreach($filearray as $key => $file)
@@ -148,6 +148,6 @@ else
accessforbidden('',0,0);
}
-
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/asset/info.php b/htdocs/asset/info.php
index 71460f31a2c..9cc9495c1b9 100644
--- a/htdocs/asset/info.php
+++ b/htdocs/asset/info.php
@@ -16,7 +16,7 @@
*/
/**
- * \file info.php
+ * \file htdocs/asset/info.php
* \ingroup asset
* \brief Page to show an asset information
*/
@@ -79,5 +79,6 @@ print '';
dol_fiche_end();
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/asset/list.php b/htdocs/asset/list.php
index bcc2329f870..7e59ad4647f 100644
--- a/htdocs/asset/list.php
+++ b/htdocs/asset/list.php
@@ -18,7 +18,7 @@
*/
/**
- * \file list.php
+ * \file htdocs/asset/list.php
* \ingroup asset
* \brief List page for asset
*/
diff --git a/htdocs/asset/note.php b/htdocs/asset/note.php
index cf0166df96f..e95e62aeaa4 100644
--- a/htdocs/asset/note.php
+++ b/htdocs/asset/note.php
@@ -17,7 +17,7 @@
*/
/**
- * \file note.php
+ * \file htdocs/asset/note.php
* \ingroup asset
* \brief Card with notes on Asset
*/
@@ -144,6 +144,6 @@ if ($id > 0 || ! empty($ref))
dol_fiche_end();
}
-
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/asset/type.php b/htdocs/asset/type.php
index f4409ee5417..001912f7de3 100644
--- a/htdocs/asset/type.php
+++ b/htdocs/asset/type.php
@@ -851,7 +851,6 @@ if ($rowid > 0)
}
}
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/asterisk/cidlookup.php b/htdocs/asterisk/cidlookup.php
index e6b4985f6b8..56e90c1a639 100644
--- a/htdocs/asterisk/cidlookup.php
+++ b/htdocs/asterisk/cidlookup.php
@@ -31,9 +31,9 @@ include '../master.inc.php';
$phone = GETPOST('phone');
$notfound = $langs->trans("Unknown");
-
+
// Security check
-if (empty($conf->clicktodial->enabled))
+if (empty($conf->clicktodial->enabled))
{
print "Error: Module Click to dial is not enabled.\n";
exit;
diff --git a/htdocs/asterisk/wrapper.php b/htdocs/asterisk/wrapper.php
index 8cd5ff979a0..66ff541d499 100644
--- a/htdocs/asterisk/wrapper.php
+++ b/htdocs/asterisk/wrapper.php
@@ -190,5 +190,6 @@ else {
print 'Bad parameters in URL. Must be '.$_SERVER['PHP_SELF'].'?caller=99999&called=99999&login=xxxxx&password=xxxxx';
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/barcode/codeinit.php b/htdocs/barcode/codeinit.php
index 26386052480..7086af7f17e 100644
--- a/htdocs/barcode/codeinit.php
+++ b/htdocs/barcode/codeinit.php
@@ -319,6 +319,6 @@ if ($conf->product->enabled || $conf->product->service)
print '';
print '
';
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/barcode/printsheet.php b/htdocs/barcode/printsheet.php
index 7dfec76b39e..a1f3632fd2f 100644
--- a/htdocs/barcode/printsheet.php
+++ b/htdocs/barcode/printsheet.php
@@ -178,19 +178,19 @@ if ($action == 'builddoc')
{
// List of values to scan for a replacement
$substitutionarray = array (
- '%LOGIN%'=>$user->login,
- '%COMPANY%'=>$mysoc->name,
- '%ADDRESS%'=>$mysoc->address,
- '%ZIP%'=>$mysoc->zip,
- '%TOWN%'=>$mysoc->town,
- '%COUNTRY%'=>$mysoc->country,
- '%COUNTRY_CODE%'=>$mysoc->country_code,
- '%EMAIL%'=>$mysoc->email,
- '%YEAR%'=>$year,
- '%MONTH%'=>$month,
- '%DAY%'=>$day,
- '%DOL_MAIN_URL_ROOT%'=>DOL_MAIN_URL_ROOT,
- '%SERVER%'=>"http://".$_SERVER["SERVER_NAME"]."/"
+ '%LOGIN%' => $user->login,
+ '%COMPANY%' => $mysoc->name,
+ '%ADDRESS%' => $mysoc->address,
+ '%ZIP%' => $mysoc->zip,
+ '%TOWN%' => $mysoc->town,
+ '%COUNTRY%' => $mysoc->country,
+ '%COUNTRY_CODE%' => $mysoc->country_code,
+ '%EMAIL%' => $mysoc->email,
+ '%YEAR%' => $year,
+ '%MONTH%' => $month,
+ '%DAY%' => $day,
+ '%DOL_MAIN_URL_ROOT%' => DOL_MAIN_URL_ROOT,
+ '%SERVER%' => "http://".$_SERVER["SERVER_NAME"]."/",
);
complete_substitutions_array($substitutionarray, $langs);
@@ -416,7 +416,7 @@ print $langs->trans("BarcodeType").' ';
print '';
// Barcode value
@@ -441,6 +441,6 @@ print '
';
print '
';
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/blockedlog/admin/blockedlog.php b/htdocs/blockedlog/admin/blockedlog.php
index 326fea79c5d..8c2835d856c 100644
--- a/htdocs/blockedlog/admin/blockedlog.php
+++ b/htdocs/blockedlog/admin/blockedlog.php
@@ -178,5 +178,6 @@ if (GETPOST('withtab','alpha'))
print '
';
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/blockedlog/admin/blockedlog_list.php b/htdocs/blockedlog/admin/blockedlog_list.php
index dbb0affdbdf..cd558c020a6 100644
--- a/htdocs/blockedlog/admin/blockedlog_list.php
+++ b/htdocs/blockedlog/admin/blockedlog_list.php
@@ -1,6 +1,7 @@
- * Copyright (C) 2017-2018 Laurent Destailleur
+/* Copyright (C) 2017 ATM Consulting
+ * Copyright (C) 2017-2018 Laurent Destailleur
+ * 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
@@ -117,10 +118,10 @@ else if (GETPOST('downloadcsv','alpha'))
$sql = "SELECT rowid,date_creation,tms,user_fullname,action,amounts,element,fk_object,date_object,ref_object,signature,fk_user,object_data";
$sql.= " FROM ".MAIN_DB_PREFIX."blockedlog";
$sql.= " WHERE entity = ".$conf->entity;
- if (GETPOST('yeartoexport','int') > 0)
+ if (GETPOST('monthtoexport','int') > 0 || GETPOST('yeartoexport','int') > 0)
{
- $dates = dol_get_first_day(GETPOST('yeartoexport','int'), 1);
- $datee = dol_get_last_day(GETPOST('yeartoexport','int'), 12);
+ $dates = dol_get_first_day(GETPOST('yeartoexport','int'), GETPOST('monthtoexport','int')?GETPOST('monthtoexport','int'):1);
+ $datee = dol_get_last_day(GETPOST('yeartoexport','int'), GETPOST('monthtoexport','int')?GETPOST('monthtoexport','int'):12);
$sql.= " AND date_creation BETWEEN '".$db->idate($dates)."' AND '".$db->idate($datee)."'";
}
$sql.= " ORDER BY rowid ASC"; // Required so we get the first one
@@ -131,27 +132,34 @@ else if (GETPOST('downloadcsv','alpha'))
{
// Make the first fetch to get first line
$obj = $db->fetch_object($res);
-
- $previoushash = $block_static->getPreviousHash(0, $obj->rowid);
- $firstid = $obj->rowid;
+ if ($obj)
+ {
+ $previoushash = $block_static->getPreviousHash(0, $obj->rowid);
+ $firstid = $obj->rowid;
+ }
+ else
+ { // If not data found for filter, we do not need previoushash neither firstid
+ $previoushash = 'nodata';
+ $firstid = '';
+ }
}
else
{
$error++;
- setEventMessage($db->lasterror, 'errors');
+ setEventMessages($db->lasterror, null, 'errors');
}
}
if (! $error)
{
- // Now restart request with all data
+ // Now restart request with all data = no limit(1) in sql request
$sql = "SELECT rowid,date_creation,tms,user_fullname,action,amounts,element,fk_object,date_object,ref_object,signature,fk_user,object_data";
$sql.= " FROM ".MAIN_DB_PREFIX."blockedlog";
$sql.= " WHERE entity = ".$conf->entity;
- if (GETPOST('yeartoexport','int') > 0)
+ if (GETPOST('monthtoexport','int') > 0 || GETPOST('yeartoexport','int') > 0)
{
- $dates = dol_get_first_day(GETPOST('yeartoexport','int'), 1);
- $datee = dol_get_last_day(GETPOST('yeartoexport','int'), 12);
+ $dates = dol_get_first_day(GETPOST('yeartoexport','int'), GETPOST('monthtoexport','int')?GETPOST('monthtoexport','int'):1);
+ $datee = dol_get_last_day(GETPOST('yeartoexport','int'), GETPOST('monthtoexport','int')?GETPOST('monthtoexport','int'):12);
$sql.= " AND date_creation BETWEEN '".$db->idate($dates)."' AND '".$db->idate($datee)."'";
}
$sql.= " ORDER BY rowid ASC"; // Required so later we can use the parameter $previoushash of checkSignature()
@@ -161,7 +169,7 @@ else if (GETPOST('downloadcsv','alpha'))
{
header('Content-Type: application/octet-stream');
header("Content-Transfer-Encoding: Binary");
- header("Content-disposition: attachment; filename=\"unalterable-log-archive-" .$dolibarr_main_db_name."-".(GETPOST('yeartoexport','int')>0?GETPOST('yeartoexport','int').'-':'').$previoushash. ".csv\"");
+ header("Content-disposition: attachment; filename=\"unalterable-log-archive-" .$dolibarr_main_db_name."-".(GETPOST('yeartoexport','int')>0 ? GETPOST('yeartoexport','int').(GETPOST('monthtoexport','int')>0?sprintf("%02d",GETPOST('monthtoexport','int')):'').'-':'').$previoushash. ".csv\"");
print $langs->transnoentities('Id')
.';'.$langs->transnoentities('Date')
@@ -243,7 +251,7 @@ else if (GETPOST('downloadcsv','alpha'))
}
else
{
- setEventMessage($db->lasterror, 'errors');
+ setEventMessages($db->lasterror, null, 'errors');
}
}
}
@@ -321,7 +329,20 @@ print '';
print $langs->trans("RestrictYearToExport").': ';
-print '';
+$smonth=GETPOST('monthtoexport','int');
+// Month
+$retstring='';
+$retstring.='";
+print $retstring;
+print '';
print '';
print '';
if (!empty($conf->global->BLOCKEDLOG_USE_REMOTE_AUTHORITY)) print ' | '.$langs->trans('DownloadBlockChain').'';
@@ -352,15 +373,15 @@ print ' ';
print '';
//print $langs->trans("from").': ';
-$form->select_date($search_start,'search_start');
+print $form->selectDate($search_start,'search_start');
//print '
';
//print $langs->trans("to").': ';
-$form->select_date($search_end,'search_end');
+print $form->selectDate($search_end,'search_end');
print ' ';
// User
print '';
-print $form->select_dolusers($search_fk_user, 'search_fk_user', 1, null, 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300');
+print $form->select_dolusers($search_fk_user, 'search_fk_user', 1, null, 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200');
print ' ';
@@ -373,6 +394,7 @@ print ' ';
// Ref
print ' ';
+// Link to ref
print ' ';
// Amount
@@ -463,7 +485,6 @@ if (is_array($blocks))
// User
print '';
-
//print $block->getUser()
print $block->user_fullname;
print ' ';
@@ -475,7 +496,7 @@ if (is_array($blocks))
print ''.$block->ref_object.' ';
// Link to source object
- print ''.$object_link.' ';
+ print ''.$object_link.' ';
// Amount
print ''.price($block->amounts).' ';
@@ -484,8 +505,8 @@ if (is_array($blocks))
print ''.img_info($langs->trans('ShowDetails')).' ';
// Fingerprint
- print '';
- print $form->textwithpicto(dol_trunc($block->signature, '12'), $block->signature, 1, 'help', '', 0, 2, 'fingerprint');
+ print ' ';
+ print $form->textwithpicto(dol_trunc($block->signature, '8'), $block->signature, 1, 'help', '', 0, 2, 'fingerprint'.$block->id);
print ' ';
// Status
@@ -587,5 +608,6 @@ if (GETPOST('withtab','alpha'))
print '
';
+// End of page
llxFooter();
-$db->close();
+$db->close();
\ No newline at end of file
diff --git a/htdocs/blockedlog/class/authority.class.php b/htdocs/blockedlog/class/authority.class.php
index b1084b01a54..b976857a522 100644
--- a/htdocs/blockedlog/class/authority.class.php
+++ b/htdocs/blockedlog/class/authority.class.php
@@ -50,10 +50,10 @@ class BlockedLogAuthority
*
* @param DoliDB $db Database handler
*/
- public function __construct($db) {
+ public function __construct($db)
+ {
$this->db = $db;
-
}
/**
@@ -61,7 +61,8 @@ class BlockedLogAuthority
*
* @return string blockchain
*/
- public function getLocalBlockChain() {
+ public function getLocalBlockChain()
+ {
$block_static = new BlockedLog($this->db);
@@ -84,10 +85,10 @@ class BlockedLogAuthority
*
* @return string hash md5 of blockchain
*/
- public function getBlockchainHash() {
+ public function getBlockchainHash()
+ {
return md5($this->signature.$this->blockchain);
-
}
/**
@@ -96,21 +97,22 @@ class BlockedLogAuthority
* @param string $hash hash md5 of blockchain to test
* @return boolean
*/
- public function checkBlockchain($hash) {
+ public function checkBlockchain($hash)
+ {
return ($hash === $this->getBlockchainHash() );
-
}
/**
* Add a new block to the chain
*
- * @param string $block new block to chain
+ * @param string $block new block to chain
+ * @return void
*/
- public function addBlock($block) {
+ public function addBlock($block)
+ {
$this->blockchain.=$block;
-
}
/**
@@ -119,7 +121,8 @@ class BlockedLogAuthority
* @param string $block new block to chain
* @return boolean
*/
- public function checkBlock($block) {
+ public function checkBlock($block)
+ {
if(strlen($block)!=64) return false;
@@ -141,7 +144,8 @@ class BlockedLogAuthority
* @param string $signature Signature of object to load
* @return int >0 if OK, <0 if KO, 0 if not found
*/
- public function fetch($id, $signature='') {
+ public function fetch($id, $signature='')
+ {
global $langs;
@@ -189,7 +193,6 @@ class BlockedLogAuthority
$this->error=$this->db->error();
return -1;
}
-
}
/**
@@ -198,7 +201,8 @@ class BlockedLogAuthority
* @param User $user Object user that create
* @return int <0 if KO, >0 if OK
*/
- public function create($user) {
+ public function create($user)
+ {
global $conf,$langs,$hookmanager;
@@ -243,7 +247,6 @@ class BlockedLogAuthority
$this->db->rollback();
return -1;
}
-
}
/**
@@ -252,7 +255,8 @@ class BlockedLogAuthority
* @param User $user Object user that create
* @return int <0 if KO, >0 if OK
*/
- public function update($user) {
+ public function update($user)
+ {
global $conf,$langs,$hookmanager;
@@ -281,7 +285,6 @@ class BlockedLogAuthority
$this->db->rollback();
return -1;
}
-
}
/**
@@ -289,7 +292,8 @@ class BlockedLogAuthority
*
* @return int <0 if KO, >0 if OK
*/
- public function syncSignatureWithAuthority() {
+ public function syncSignatureWithAuthority()
+ {
global $conf, $langs;
//TODO create cron task on activation
@@ -329,5 +333,4 @@ class BlockedLogAuthority
return 1;
}
-
-}
\ No newline at end of file
+}
diff --git a/htdocs/blockedlog/class/blockedlog.class.php b/htdocs/blockedlog/class/blockedlog.class.php
index 0210491fba7..dab99d80bc9 100644
--- a/htdocs/blockedlog/class/blockedlog.class.php
+++ b/htdocs/blockedlog/class/blockedlog.class.php
@@ -18,9 +18,6 @@
* See https://medium.com/@lhartikk/a-blockchain-in-200-lines-of-code-963cc1cc0e54
*/
-
-
-
/*ini_set('unserialize_callback_func', 'mycallback');
function mycallback($classname)
@@ -42,6 +39,7 @@ class BlockedLog
* @var int
*/
public $id;
+
/**
* Entity
* @var int
@@ -49,6 +47,10 @@ class BlockedLog
public $entity;
public $error = '';
+
+ /**
+ * @var string[] Error codes (or messages)
+ */
public $errors = array();
/**
@@ -171,6 +173,7 @@ class BlockedLog
/**
* Try to retrieve source object (it it still exists)
+ * @return string
*/
public function getObjectLink()
{
@@ -281,11 +284,11 @@ class BlockedLog
}
return ''.$langs->trans('ImpossibleToReloadObject', $this->element, $this->fk_object).'';
-
}
/**
* try to retrieve user author
+ * @return string
*/
public function getUser()
{
@@ -609,7 +612,8 @@ class BlockedLog
* @param int $id Id of object to load
* @return int >0 if OK, <0 if KO, 0 if not found
*/
- public function fetch($id) {
+ public function fetch($id)
+ {
global $langs;
@@ -672,7 +676,6 @@ class BlockedLog
$this->error=$this->db->error();
return -1;
}
-
}
@@ -705,14 +708,13 @@ class BlockedLog
*
* @return boolean
*/
- public function setCertified() {
+ public function setCertified()
+ {
$res = $this->db->query("UPDATE ".MAIN_DB_PREFIX."blockedlog SET certified=1 WHERE rowid=".$this->id);
if($res===false) return false;
return true;
-
-
}
/**
@@ -722,7 +724,8 @@ class BlockedLog
* @param int $forcesignature Force signature (for example '0000000000' when we disabled the module)
* @return int <0 if KO, >0 if OK
*/
- public function create($user, $forcesignature='') {
+ public function create($user, $forcesignature='')
+ {
global $conf,$langs,$hookmanager;
@@ -1029,6 +1032,7 @@ class BlockedLog
* Check if module was already used or not for at least one recording.
*
* @param int $ignoresystem Ignore system events for the test
+ * @return bool
*/
function alreadyUsed($ignoresystem=0)
{
@@ -1053,6 +1057,4 @@ class BlockedLog
return $result;
}
-
}
-
diff --git a/htdocs/bookmarks/admin/bookmark.php b/htdocs/bookmarks/admin/bookmark.php
index 25fa032902f..ed20f619b25 100644
--- a/htdocs/bookmarks/admin/bookmark.php
+++ b/htdocs/bookmarks/admin/bookmark.php
@@ -81,5 +81,6 @@ print '';
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/bookmarks/card.php b/htdocs/bookmarks/card.php
index d450e476506..b82c2b11b6c 100644
--- a/htdocs/bookmarks/card.php
+++ b/htdocs/bookmarks/card.php
@@ -336,7 +336,6 @@ if ($id > 0 && ! preg_match('/^add/i',$action))
}
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/bookmarks/class/bookmark.class.php b/htdocs/bookmarks/class/bookmark.class.php
index 1beb4b36871..b7846cd0864 100644
--- a/htdocs/bookmarks/class/bookmark.class.php
+++ b/htdocs/bookmarks/class/bookmark.class.php
@@ -28,21 +28,44 @@
*/
class Bookmark extends CommonObject
{
- public $element='bookmark';
+ /**
+ * @var string ID to identify managed object
+ */
+ public $element='bookmark';
+
+ /**
+ * @var string Name of table without prefix where object is stored
+ */
public $table_element='bookmark';
+
public $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
- public $picto = 'bookmark';
- var $db;
+ /**
+ * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
+ */
+ public $picto = 'bookmark';
- var $id;
- var $fk_user;
- var $datec;
- var $url;
- var $target; // 0=replace, 1=new window
- var $title;
- var $position;
- var $favicon;
+ /**
+ * @var DoliDB Database handler.
+ */
+ public $db;
+
+ /**
+ * @var int ID
+ */
+ public $id;
+
+ /**
+ * @var int User ID
+ */
+ public $fk_user;
+
+ public $datec;
+ public $url;
+ public $target; // 0=replace, 1=new window
+ public $title;
+ public $position;
+ public $favicon;
/**
@@ -211,7 +234,6 @@ class Bookmark extends CommonObject
$this->error=$this->db->lasterror();
return -1;
}
-
}
/**
@@ -241,5 +263,4 @@ class Bookmark extends CommonObject
{
return '';
}
-
}
diff --git a/htdocs/bookmarks/list.php b/htdocs/bookmarks/list.php
index ac5a89c66f3..10ce877c7e0 100644
--- a/htdocs/bookmarks/list.php
+++ b/htdocs/bookmarks/list.php
@@ -209,7 +209,7 @@ else
dol_print_error($db);
}
-
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/cashdesk/admin/cashdesk.php b/htdocs/cashdesk/admin/cashdesk.php
index f4af16b3739..62867d855cb 100644
--- a/htdocs/cashdesk/admin/cashdesk.php
+++ b/htdocs/cashdesk/admin/cashdesk.php
@@ -185,5 +185,6 @@ print '\n";
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/cashdesk/affContenu.php b/htdocs/cashdesk/affContenu.php
index bd778f3422e..2a3c0279df8 100644
--- a/htdocs/cashdesk/affContenu.php
+++ b/htdocs/cashdesk/affContenu.php
@@ -87,7 +87,7 @@ print '';
print '';
print '';
-require ('tpl/liste_articles.tpl.php');
+require 'tpl/liste_articles.tpl.php';
print '';
print '';
diff --git a/htdocs/cashdesk/affIndex.php b/htdocs/cashdesk/affIndex.php
index a2e467a35e3..9ff676531f1 100644
--- a/htdocs/cashdesk/affIndex.php
+++ b/htdocs/cashdesk/affIndex.php
@@ -36,9 +36,8 @@ if ( $_SESSION['uid'] <= 0 )
exit;
}
-$langs->load("companies");
-$langs->load("compta");
-$langs->load("cashdesk");
+// Load translation files required by the page
+$langs->loadLangs(array("companies","compta","cashdesk"));
/*
diff --git a/htdocs/cashdesk/class/Auth.class.php b/htdocs/cashdesk/class/Auth.class.php
index 5e431514d1c..78b76e20d11 100644
--- a/htdocs/cashdesk/class/Auth.class.php
+++ b/htdocs/cashdesk/class/Auth.class.php
@@ -138,6 +138,5 @@ class Auth
return $ret;
}
-
}
diff --git a/htdocs/cashdesk/class/Facturation.class.php b/htdocs/cashdesk/class/Facturation.class.php
index a0e992e9da9..3051035813a 100644
--- a/htdocs/cashdesk/class/Facturation.class.php
+++ b/htdocs/cashdesk/class/Facturation.class.php
@@ -37,7 +37,12 @@ class Facturation
* int $prix => Prix HT du produit en cours
* int $tva => 'rowid' du taux de tva dans llx_c_tva
*/
- public $id;
+
+ /**
+ * @var int ID
+ */
+ public $id;
+
protected $ref;
protected $qte;
protected $stock;
@@ -167,7 +172,6 @@ class Facturation
$_SESSION['poscart']=$newcartarray;
$this->raz();
-
}
/**
@@ -269,7 +273,6 @@ class Facturation
$this->prixTotalHt('RESET');
$this->montantTva('RESET');
$this->prixTotalTtc('RESET');
-
}
@@ -310,7 +313,7 @@ class Facturation
* @return string Ref
*/
public function ref($aRef=null)
- {
+ {
if (is_null($aRef))
{
@@ -324,7 +327,6 @@ class Facturation
{
$this->ref = $aRef;
}
-
}
/**
@@ -348,7 +350,6 @@ class Facturation
{
$this->qte = $aQte;
}
-
}
/**
@@ -372,7 +373,6 @@ class Facturation
{
$this->stock = $aStock;
}
-
}
/**
@@ -396,7 +396,6 @@ class Facturation
{
$this->remise_percent = $aRemisePercent;
}
-
}
/**
@@ -421,7 +420,6 @@ class Facturation
$this->montant_remise = $aMontantRemise;
}
-
}
/**
@@ -446,7 +444,6 @@ class Facturation
$this->prix = $aPrix;
}
-
}
/**
@@ -470,7 +467,6 @@ class Facturation
$this->tva = $aTva;
}
-
}
/**
@@ -518,7 +514,6 @@ class Facturation
$this->mode_reglement = $aModeReglement;
}
-
}
/**
@@ -543,7 +538,6 @@ class Facturation
$this->montant_encaisse = $aMontantEncaisse;
}
-
}
/**
@@ -567,7 +561,6 @@ class Facturation
$this->montant_rendu = $aMontantRendu;
}
-
}
/**
@@ -637,7 +630,6 @@ class Facturation
$this->montant_tva = $aMontantTva;
}
-
}
/**
@@ -652,7 +644,7 @@ class Facturation
{
return $this->prix_total_ttc;
}
- else if ( $aTotalTtc == 'RESET' )
+ elseif ( $aTotalTtc == 'RESET' )
{
$this->prix_total_ttc = null;
}
@@ -661,6 +653,4 @@ class Facturation
$this->prix_total_ttc = $aTotalTtc;
}
}
-
}
-
diff --git a/htdocs/cashdesk/css/style.css b/htdocs/cashdesk/css/style.css
index d4149619aae..dc579711aa3 100644
--- a/htdocs/cashdesk/css/style.css
+++ b/htdocs/cashdesk/css/style.css
@@ -52,7 +52,7 @@ p {
}
.logopos {
padding-top: 20px;
- max-height: 40px;
+ max-height: 40px;
}
/* ------------------- Header ------------------- */
diff --git a/htdocs/cashdesk/facturation.php b/htdocs/cashdesk/facturation.php
index f52890b68d2..6a2889f6e71 100644
--- a/htdocs/cashdesk/facturation.php
+++ b/htdocs/cashdesk/facturation.php
@@ -163,4 +163,4 @@ $obj_facturation->paiementLe('RESET');
// Affichage des templates
-require ('tpl/facturation1.tpl.php');
+require 'tpl/facturation1.tpl.php';
diff --git a/htdocs/cashdesk/index.php b/htdocs/cashdesk/index.php
index 24b94562915..d2ea5160ca8 100644
--- a/htdocs/cashdesk/index.php
+++ b/htdocs/cashdesk/index.php
@@ -28,8 +28,8 @@
require_once '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
-$langs->load("admin");
-$langs->load("cashdesk");
+// Load translation files required by the page
+$langs->loadLangs(array("admin","cashdesk"));
// Test if user logged
if ( $_SESSION['uid'] > 0 )
@@ -63,7 +63,7 @@ top_htmlhead('','',0,0,'',$arrayofcss);
logo_small))
{
- print '
';
+ print '
';
}
else
{
diff --git a/htdocs/cashdesk/index_verif.php b/htdocs/cashdesk/index_verif.php
index 238a73f6ef7..cd354293022 100644
--- a/htdocs/cashdesk/index_verif.php
+++ b/htdocs/cashdesk/index_verif.php
@@ -30,9 +30,8 @@ include '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/cashdesk/include/environnement.php';
require_once DOL_DOCUMENT_ROOT.'/cashdesk/class/Auth.class.php';
-$langs->load("main");
-$langs->load("admin");
-$langs->load("cashdesk");
+// Load translation files required by the page
+$langs->loadLangs(array("main","admin","cashdesk"));
$username = GETPOST("txtUsername");
$password = GETPOST("pwdPassword");
@@ -119,7 +118,7 @@ if ( $retour >= 0 )
$_SESSION['firstname'] = $tab['firstname'];
$_SESSION['CASHDESK_ID_THIRDPARTY'] = ($thirdpartyid > 0 ? $thirdpartyid : '');
$_SESSION['CASHDESK_ID_WAREHOUSE'] = ($warehouseid > 0 ? $warehouseid : '');
-
+
$_SESSION['CASHDESK_ID_BANKACCOUNT_CASH'] = ($bankid_cash > 0 ? $bankid_cash : '');
$_SESSION['CASHDESK_ID_BANKACCOUNT_CHEQUE'] = ($bankid_cheque > 0 ? $bankid_cheque : '');
$_SESSION['CASHDESK_ID_BANKACCOUNT_CB'] = ($bankid_cb > 0 ? $bankid_cb : '');
@@ -135,8 +134,8 @@ if ( $retour >= 0 )
}
else
{
- $langs->load("errors");
- $langs->load("other");
+ // Load translation files required by the page
+ $langs->loadLangs(array("other","errors"));
$retour=$langs->trans("ErrorBadLoginPassword");
header('Location: '.DOL_URL_ROOT.'/cashdesk/index.php?err='.urlencode($retour).'&user='.$username.'&socid='.$thirdpartyid.'&warehouseid='.$warehouseid);
exit;
diff --git a/htdocs/cashdesk/tpl/facturation1.tpl.php b/htdocs/cashdesk/tpl/facturation1.tpl.php
index 146ae3d40b6..4ddafd17c44 100644
--- a/htdocs/cashdesk/tpl/facturation1.tpl.php
+++ b/htdocs/cashdesk/tpl/facturation1.tpl.php
@@ -3,6 +3,7 @@
* Copyright (C) 2011 Laurent Destailleur
* Copyright (C) 2011 Juanjo Menent
* Copyright (C) 2015 Regis Houssin
+ * 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
@@ -26,10 +27,8 @@ if (empty($langs) || ! is_object($langs))
exit;
}
-
-$langs->load("main");
-$langs->load("bills");
-$langs->load("cashdesk");
+// Load translation files required by the page
+$langs->loadLangs(array("main","bills","cashdesk"));
// Object $form must de defined
@@ -204,7 +203,7 @@ $langs->load("cashdesk");
" onclick="javascript: verifClic('DIF');" />
trans("DateDue").' :';
- print $form->select_date(-1,'txtDatePaiement',0,0,0,'paymentmode',1,0,1);
+ print $form->selectDate(-1,'txtDatePaiement',0,0,0,'paymentmode',1,0);
print '';
?>
diff --git a/htdocs/cashdesk/tpl/liste_articles.tpl.php b/htdocs/cashdesk/tpl/liste_articles.tpl.php
index 65f48b0603c..266c5e5840b 100644
--- a/htdocs/cashdesk/tpl/liste_articles.tpl.php
+++ b/htdocs/cashdesk/tpl/liste_articles.tpl.php
@@ -28,9 +28,8 @@ if (empty($langs) || ! is_object($langs))
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
-$langs->load("main");
-$langs->load("bills");
-$langs->load("cashdesk");
+// Load translation files required by the page
+$langs->loadLangs(array("main","bills","cashdesk"));
?>
diff --git a/htdocs/cashdesk/tpl/menu.tpl.php b/htdocs/cashdesk/tpl/menu.tpl.php
index 250aaa18cc2..afe2c0da4ec 100644
--- a/htdocs/cashdesk/tpl/menu.tpl.php
+++ b/htdocs/cashdesk/tpl/menu.tpl.php
@@ -63,9 +63,8 @@ if (!empty($_SESSION["CASHDESK_ID_WAREHOUSE"]) && ! empty($conf->stock->enabled)
$warehouseLink = $warehouse->getNomUrl(1);
}
-
-$langs->load("cashdesk");
-$langs->load("main");
+// Load translation files required by the page
+$langs->loadLangs(array("main","cashdesk"));
print "\n".''."\n";
print ' ';
print '';
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/categories/admin/categorie_extrafields.php b/htdocs/categories/admin/categorie_extrafields.php
index 3fbd29a640b..abea3f41eeb 100644
--- a/htdocs/categories/admin/categorie_extrafields.php
+++ b/htdocs/categories/admin/categorie_extrafields.php
@@ -111,6 +111,6 @@ if ($action == 'edit' && ! empty($attrname))
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php';
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/categories/card.php b/htdocs/categories/card.php
index db56902347b..ce3324505eb 100644
--- a/htdocs/categories/card.php
+++ b/htdocs/categories/card.php
@@ -288,7 +288,6 @@ if ($user->rights->categorie->creer)
}
}
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php
index c559d760f0f..843e2fc0ee6 100644
--- a/htdocs/categories/class/api_categories.class.php
+++ b/htdocs/categories/class/api_categories.class.php
@@ -103,7 +103,8 @@ class Categories extends DolibarrApi
*
* @throws RestException
*/
- function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $type = '', $sqlfilters = '') {
+ function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $type = '', $sqlfilters = '')
+ {
global $db, $conf;
$obj_ret = array();
@@ -266,7 +267,8 @@ class Categories extends DolibarrApi
* @param Categorie $object Object to clean
* @return array Array of cleaned object properties
*/
- function _cleanObjectDatas($object) {
+ function _cleanObjectDatas($object)
+ {
$object = parent::_cleanObjectDatas($object);
diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php
index 70b2108dd4c..8f09710854f 100644
--- a/htdocs/categories/class/categorie.class.php
+++ b/htdocs/categories/class/categorie.class.php
@@ -6,7 +6,7 @@
* Copyright (C) 2006-2012 Laurent Destailleur
* Copyright (C) 2007 Patrick Raguin
* Copyright (C) 2013-2016 Juanjo Menent
- * Copyright (C) 2013-2016 Philippe Grand
+ * Copyright (C) 2013-2018 Philippe Grand
* Copyright (C) 2015 Marcos García
* Copyright (C) 2015 Raphaël Doursenaud
* Copyright (C) 2016 Charlie Benke
@@ -53,6 +53,9 @@ class Categorie extends CommonObject
const TYPE_ACCOUNT = 'bank_account';
const TYPE_BANK_LINE = 'bank_line';
+ /**
+ * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
+ */
public $picto = 'category';
@@ -148,12 +151,28 @@ class Categorie extends CommonObject
'project' => 'projet',
);
+ /**
+ * @var string ID to identify managed object
+ */
public $element='category';
+
+ /**
+ * @var string Name of table without prefix where object is stored
+ */
public $table_element='categorie';
public $fk_parent;
- public $label;
+
+ /**
+ * @var string Category label
+ */
+ public $label;
+
+ /**
+ * @var string description
+ */
public $description;
+
/**
* @var string Color
*/
@@ -498,112 +517,27 @@ class Categorie extends CommonObject
$error++;
}
}
- if (! $error)
- {
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_societe";
- $sql .= " WHERE fk_categorie = ".$this->id;
- if (!$this->db->query($sql))
- {
- $this->error=$this->db->lasterror();
- $error++;
- }
- }
- if (! $error)
- {
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_fournisseur";
- $sql .= " WHERE fk_categorie = ".$this->id;
- if (!$this->db->query($sql))
- {
- $this->error=$this->db->lasterror();
- $error++;
- }
- }
- if (! $error)
- {
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_product";
- $sql .= " WHERE fk_categorie = ".$this->id;
- if (!$this->db->query($sql))
- {
- $this->error=$this->db->lasterror();
- $error++;
- }
- }
- if (! $error)
- {
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_member";
- $sql .= " WHERE fk_categorie = ".$this->id;
- if (!$this->db->query($sql))
- {
- $this->error=$this->db->lasterror();
- $error++;
- }
- }
- if (! $error)
- {
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_contact";
- $sql .= " WHERE fk_categorie = ".$this->id;
- if (!$this->db->query($sql))
- {
- $this->error=$this->db->lasterror();
- $error++;
- }
- }
- if (! $error)
- {
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_contact";
- $sql .= " WHERE fk_categorie = ".$this->id;
- if (!$this->db->query($sql))
- {
- $this->error=$this->db->lasterror();
- $error++;
- }
- }
- if (! $error)
- {
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_account";
- $sql .= " WHERE fk_categorie = ".$this->id;
- if (!$this->db->query($sql))
- {
- $this->error=$this->db->lasterror();
- dol_syslog("Error sql=".$sql." ".$this->error, LOG_ERR);
- $error++;
- }
- }
- if (! $error)
- {
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_class";
- $sql .= " WHERE fk_categ = ".$this->id;
- if (!$this->db->query($sql))
- {
- $this->error=$this->db->lasterror();
- dol_syslog("Error sql=".$sql." ".$this->error, LOG_ERR);
- $error++;
- }
- }
- if (! $error)
- {
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_lang";
- $sql .= " WHERE fk_category = ".$this->id;
- if (!$this->db->query($sql))
- {
- $this->error=$this->db->lasterror();
- dol_syslog("Error sql=".$sql." ".$this->error, LOG_ERR);
- $error++;
- }
- }
-
- // Delete category
- if (! $error)
- {
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie";
- $sql .= " WHERE rowid = ".$this->id;
- if (!$this->db->query($sql))
- {
- $this->error=$this->db->lasterror();
- $error++;
- }
- }
+ $arraydelete = array(
+ 'categorie_societe' => 'fk_categorie',
+ 'categorie_fournisseur' => 'fk_categorie',
+ 'categorie_product' => 'fk_categorie',
+ 'categorie_member' => 'fk_categorie',
+ 'categorie_contact' => 'fk_categorie',
+ 'categorie_account' => 'fk_categorie',
+ 'bank_class' => 'fk_categ',
+ 'categorie_lang' => 'fk_category',
+ 'categorie' => 'rowid',
+ );
+ foreach ($arraydelete as $key => $value) {
+ $sql = "DELETE FROM " . MAIN_DB_PREFIX . $key;
+ $sql .= " WHERE ".$value." = ".$this->id;
+ if (!$this->db->query($sql)) {
+ $this->errors[] = $this->db->lasterror();
+ dol_syslog("Error sql=".$sql." ".$this->error, LOG_ERR);
+ $error++;
+ }
+ }
// Removed extrafields
if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
@@ -628,6 +562,7 @@ class Categorie extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Link an object to the category
*
@@ -637,6 +572,7 @@ class Categorie extends CommonObject
*/
function add_type($obj, $type)
{
+ // phpcs:enable
global $user,$langs,$conf;
$error=0;
@@ -729,6 +665,7 @@ class Categorie extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Delete object from category
*
@@ -739,6 +676,7 @@ class Categorie extends CommonObject
*/
function del_type($obj,$type)
{
+ // phpcs:enable
global $user,$langs,$conf;
$error=0;
@@ -791,7 +729,7 @@ class Categorie extends CommonObject
*
* @param string $type Type of category ('customer', 'supplier', 'contact', 'product', 'member')
* @param int $onlyids Return only ids of objects (consume less memory)
- * @return mixed -1 if KO, array of instance of object if OK
+ * @return array|int -1 if KO, array of instance of object if OK
* @see containsObject
*/
function getObjectsInCateg($type, $onlyids=0)
@@ -952,6 +890,7 @@ class Categorie extends CommonObject
return $categories;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Return childs of a category
*
@@ -959,6 +898,7 @@ class Categorie extends CommonObject
*/
function get_filles()
{
+ // phpcs:enable
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."categorie";
$sql.= " WHERE fk_parent = ".$this->id;
@@ -981,6 +921,7 @@ class Categorie extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Load this->motherof that is array(id_son=>id_parent, ...)
*
@@ -988,6 +929,7 @@ class Categorie extends CommonObject
*/
private function load_motherof()
{
+ // phpcs:enable
global $conf;
$this->motherof=array();
@@ -1015,6 +957,7 @@ class Categorie extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Rebuilding the category tree as an array
* Return an array of table('id','id_mere',...) trie selon arbre et avec:
@@ -1032,6 +975,7 @@ class Categorie extends CommonObject
*/
function get_full_arbo($type, $markafterid=0)
{
+ // phpcs:enable
global $conf, $langs;
if (! is_numeric($type)) $type = $this->MAP_ID[$type];
@@ -1106,6 +1050,7 @@ class Categorie extends CommonObject
return $this->cats;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* For category id_categ and its childs available in this->cats, define property fullpath and fulllabel
*
@@ -1115,6 +1060,7 @@ class Categorie extends CommonObject
*/
function build_path_from_id_categ($id_categ,$protection=1000)
{
+ // phpcs:enable
dol_syslog(get_class($this)."::build_path_from_id_categ id_categ=".$id_categ." protection=".$protection, LOG_DEBUG);
if (! empty($this->cats[$id_categ]['fullpath']))
@@ -1148,6 +1094,7 @@ class Categorie extends CommonObject
return;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Display content of $this->cats
*
@@ -1155,6 +1102,7 @@ class Categorie extends CommonObject
*/
function debug_cats()
{
+ // phpcs:enable
// Display $this->cats
foreach($this->cats as $key => $val)
{
@@ -1169,6 +1117,7 @@ class Categorie extends CommonObject
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Returns all categories
*
@@ -1178,6 +1127,7 @@ class Categorie extends CommonObject
*/
function get_all_categories($type=null, $parent=false)
{
+ // phpcs:enable
if (! is_numeric($type)) $type = $this->MAP_ID[$type];
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."categorie";
@@ -1206,6 +1156,7 @@ class Categorie extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Check if no category with same label already exists for this cat's parent or root and for this cat's type
*
@@ -1213,6 +1164,7 @@ class Categorie extends CommonObject
*/
function already_exists()
{
+ // phpcs:enable
$type=$this->type;
if (! is_numeric($type)) $type=$this->MAP_ID[$type];
@@ -1255,6 +1207,7 @@ class Categorie extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Returns the top level categories (which are not girls)
*
@@ -1263,9 +1216,11 @@ class Categorie extends CommonObject
*/
function get_main_categories($type=null)
{
+ // phpcs:enable
return $this->get_all_categories($type, true);
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Returns the path of the category, with the names of the categories
* separated by $sep (" >> " by default)
@@ -1277,6 +1232,7 @@ class Categorie extends CommonObject
*/
function print_all_ways($sep = " >> ", $url='', $nocolor=0)
{
+ // phpcs:enable
$ways = array();
$allways = $this->get_all_ways(); // Load array of categories
@@ -1323,6 +1279,7 @@ class Categorie extends CommonObject
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Returns an array containing the list of parent categories
*
@@ -1330,6 +1287,7 @@ class Categorie extends CommonObject
*/
function get_meres()
{
+ // phpcs:enable
$parents = array();
$sql = "SELECT fk_parent FROM ".MAIN_DB_PREFIX."categorie";
@@ -1357,6 +1315,7 @@ class Categorie extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Returns in a table all possible paths to get to the category
* starting with the major categories represented by Tables of categories
@@ -1365,6 +1324,7 @@ class Categorie extends CommonObject
*/
function get_all_ways()
{
+ // phpcs:enable
$ways = array();
$parents=$this->get_meres();
@@ -1571,6 +1531,7 @@ class Categorie extends CommonObject
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Deplace fichier uploade sous le nom $files dans le repertoire sdir
*
@@ -1580,6 +1541,7 @@ class Categorie extends CommonObject
*/
function add_photo($sdir, $file)
{
+ // phpcs:enable
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
$dir = $sdir .'/'. get_exdir($this->id,2,0,0,$this,'category') . $this->id ."/";
@@ -1620,6 +1582,7 @@ class Categorie extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Return tableau de toutes les photos de la categorie
*
@@ -1629,6 +1592,7 @@ class Categorie extends CommonObject
*/
function liste_photos($dir,$nbmax=0)
{
+ // phpcs:enable
include_once DOL_DOCUMENT_ROOT .'/core/lib/files.lib.php';
$nbphoto=0;
@@ -1675,6 +1639,7 @@ class Categorie extends CommonObject
return $tabobj;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Efface la photo de la categorie et sa vignette
*
@@ -1683,6 +1648,7 @@ class Categorie extends CommonObject
*/
function delete_photo($file)
{
+ // phpcs:enable
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
$dir = dirname($file).'/'; // Chemin du dossier contenant l'image d'origine
@@ -1703,6 +1669,7 @@ class Categorie extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Load size of image file
*
@@ -1711,6 +1678,7 @@ class Categorie extends CommonObject
*/
function get_image_size($file)
{
+ // phpcs:enable
$infoImg = getimagesize($file); // Recuperation des infos de l'image
$this->imgWidth = $infoImg[0]; // Largeur de l'image
$this->imgHeight = $infoImg[1]; // Hauteur de l'image
diff --git a/htdocs/categories/edit.php b/htdocs/categories/edit.php
index b420847f6fd..cdfac54fb9d 100644
--- a/htdocs/categories/edit.php
+++ b/htdocs/categories/edit.php
@@ -192,7 +192,6 @@ print '';
-
-
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/categories/index.php b/htdocs/categories/index.php
index e57e51caf62..e634da4fe80 100644
--- a/htdocs/categories/index.php
+++ b/htdocs/categories/index.php
@@ -202,6 +202,6 @@ print "";
print '';
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/categories/photos.php b/htdocs/categories/photos.php
index 472a8eb9b95..095c0c611c5 100644
--- a/htdocs/categories/photos.php
+++ b/htdocs/categories/photos.php
@@ -273,6 +273,6 @@ else
print $langs->trans("ErrorUnknown");
}
-
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/categories/traduction.php b/htdocs/categories/traduction.php
index 7d71b43a81b..dbcfca198d2 100644
--- a/htdocs/categories/traduction.php
+++ b/htdocs/categories/traduction.php
@@ -334,5 +334,6 @@ if ($action == 'add' && ($user->rights->produit->creer || $user->rights->service
print '
';
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php
index 24e70e7d587..ba3580cea87 100644
--- a/htdocs/categories/viewcat.php
+++ b/htdocs/categories/viewcat.php
@@ -697,6 +697,6 @@ if ($type == Categorie::TYPE_PROJECT)
}
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/collab/index.php b/htdocs/collab/index.php
index 2c056cd0e07..e7b2ab51d7c 100644
--- a/htdocs/collab/index.php
+++ b/htdocs/collab/index.php
@@ -28,9 +28,8 @@ require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
-$langs->load("admin");
-$langs->load("other");
-$langs->load("website");
+// Load translation files required by the page
+$langs->loadLangs(array("admin","other","website"));
if (! $user->admin) accessforbidden();
@@ -456,9 +455,6 @@ if ($action == 'editcontent')
print " \n\n";
-
-
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php
index 1d6a0286b68..8fd1f1b0030 100644
--- a/htdocs/comm/action/card.php
+++ b/htdocs/comm/action/card.php
@@ -1,12 +1,13 @@
- * Copyright (C) 2004-2017 Laurent Destailleur
+ * Copyright (C) 2004-2018 Laurent Destailleur
* Copyright (C) 2005 Simon TOSSER
* Copyright (C) 2005-2017 Regis Houssin
* Copyright (C) 2010-2013 Juanjo Menent
* Copyright (C) 2013 Florian Henry
* Copyright (C) 2014 Cedric GROSS
- * Copyright (C) 2015 Alexandre Spangaro
+ * Copyright (C) 2015 Alexandre Spangaro
+ * 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
@@ -689,9 +690,13 @@ if ($action == 'create')
$datep=($datep?$datep:$object->datep);
if (GETPOST('datep','int',1)) $datep=dol_stringtotime(GETPOST('datep','int',1),0);
print ''.$langs->trans("DateActionStart").' ';
- if (GETPOST("afaire") == 1) $form->select_date($datep,'ap',1,1,0,"action",1,1,0,0,'fulldayend');
- else if (GETPOST("afaire") == 2) $form->select_date($datep,'ap',1,1,1,"action",1,1,0,0,'fulldayend');
- else $form->select_date($datep,'ap',1,1,1,"action",1,1,0,0,'fulldaystart');
+ if (GETPOST("afaire") == 1) {
+ print $form->selectDate($datep, 'ap', 1, 1, 0, "action", 1, 1, 0, 'fulldayend');
+ } elseif (GETPOST("afaire") == 2) {
+ print $form->selectDate($datep, 'ap', 1, 1, 1, "action", 1, 1, 0, 'fulldayend');
+ } else {
+ print $form->selectDate($datep, 'ap', 1, 1, 1, "action", 1, 1, 0, 'fulldaystart');
+ }
print ' ';
// Date end
@@ -702,12 +707,17 @@ if ($action == 'create')
$datef=dol_time_plus_duree($datep, $conf->global->AGENDA_AUTOSET_END_DATE_WITH_DELTA_HOURS, 'h');
}
print ''.$langs->trans("DateActionEnd").' ';
- if (GETPOST("afaire") == 1) $form->select_date($datef,'p2',1,1,1,"action",1,1,0,0,'fulldayend');
- else if (GETPOST("afaire") == 2) $form->select_date($datef,'p2',1,1,1,"action",1,1,0,0,'fulldayend');
- else $form->select_date($datef,'p2',1,1,1,"action",1,1,0,0,'fulldayend');
+ if (GETPOST("afaire") == 1) {
+ print $form->selectDate($datef, 'p2', 1, 1, 1, "action", 1, 1, 0, 'fulldayend');
+ } elseif (GETPOST("afaire") == 2) {
+ print $form->selectDate($datef, 'p2', 1, 1, 1, "action", 1, 1, 0, 'fulldayend');
+ } else {
+ print $form->selectDate($datef, 'p2', 1, 1, 1, "action", 1, 1, 0, 'fulldayend');
+ }
print ' ';
- $userepeatevent=($conf->global->MAIN_FEATURES_LEVEL == 2 ? 1 : 0); // Dev in progress
+ // Dev in progress
+ $userepeatevent=($conf->global->MAIN_FEATURES_LEVEL == 2 ? 1 : 0);
if ($userepeatevent)
{
// Repeat
@@ -927,6 +937,15 @@ if ($action == 'create')
if ($id > 0)
{
$result1=$object->fetch($id);
+ if ($result1 <= 0)
+ {
+ $langs->load("errors");
+ print $langs->trans("ErrorRecordNotFound");
+
+ llxFooter();
+ exit;
+ }
+
$result2=$object->fetch_thirdparty();
$result2=$object->fetch_projet();
$result3=$object->fetch_contact();
@@ -957,7 +976,7 @@ if ($id > 0)
$object->note = GETPOST("note",'none');
}
- if ($result1 < 0 || $result2 < 0 || $result3 < 0 || $result4 < 0 || $result5 < 0)
+ if ($result2 < 0 || $result3 < 0 || $result4 < 0 || $result5 < 0)
{
dol_print_error($db,$object->error);
exit;
@@ -1048,30 +1067,38 @@ if ($id > 0)
// Date start
print ''.$langs->trans("DateActionStart").' ';
- if (GETPOST("afaire") == 1) $form->select_date($datep?$datep:$object->datep,'ap',1,1,0,"action",1,1,0,0,'fulldaystart');
- else if (GETPOST("afaire") == 2) $form->select_date($datep?$datep:$object->datep,'ap',1,1,1,"action",1,1,0,0,'fulldaystart');
- else $form->select_date($datep?$datep:$object->datep,'ap',1,1,1,"action",1,1,0,0,'fulldaystart');
+ if (GETPOST("afaire") == 1) {
+ print $form->selectDate($datep?$datep:$object->datep, 'ap', 1, 1, 0, "action", 1, 1, 0, 'fulldaystart');
+ } elseif (GETPOST("afaire") == 2) {
+ print $form->selectDate($datep?$datep:$object->datep, 'ap', 1, 1, 1, "action", 1, 1, 0, 'fulldaystart');
+ } else {
+ print $form->selectDate($datep?$datep:$object->datep, 'ap', 1, 1, 1, "action", 1, 1, 0, 'fulldaystart');
+ }
print ' ';
// Date end
print ''.$langs->trans("DateActionEnd").' ';
- if (GETPOST("afaire") == 1) $form->select_date($datef?$datef:$object->datef,'p2',1,1,1,"action",1,1,0,0,'fulldayend');
- else if (GETPOST("afaire") == 2) $form->select_date($datef?$datef:$object->datef,'p2',1,1,1,"action",1,1,0,0,'fulldayend');
- //else $form->select_date($datef?$datef:$object->datef,'p2',1,1,1,"action",1,1,0,0,'fulldayend','ap');
- else $form->select_date($datef?$datef:$object->datef,'p2',1,1,1,"action",1,1,0,0,'fulldayend');
+ if (GETPOST("afaire") == 1) {
+ print $form->selectDate($datef?$datef:$object->datef, 'p2', 1, 1, 1, "action", 1, 1, 0, 'fulldayend');
+ } elseif (GETPOST("afaire") == 2) {
+ print $form->selectDate($datef?$datef:$object->datef,'p2', 1, 1, 1, "action", 1, 1, 0, 'fulldayend');
+ } else {
+ print $form->selectDate($datef?$datef:$object->datef,'p2', 1, 1, 1, "action", 1, 1, 0, 'fulldayend');
+ }
print ' ';
- $userepeatevent=($conf->global->MAIN_FEATURES_LEVEL == 2 ? 1 : 0); // Dev in progress
+ // Dev in progress
+ $userepeatevent=($conf->global->MAIN_FEATURES_LEVEL == 2 ? 1 : 0);
if ($userepeatevent)
{
// Repeat
print ''.$langs->trans("RepeatEvent").' ';
print '';
- $arrayrecurrulefreq=array(
- 'no'=>$langs->trans("No"),
- 'MONTHLY'=>$langs->trans("EveryMonth"),
- 'WEEKLY'=>$langs->trans("EveryWeek"),
- //'DAYLY'=>$langs->trans("EveryDay")
- );
+ $arrayrecurrulefreq = array(
+ 'no'=>$langs->trans("No"),
+ 'MONTHLY'=>$langs->trans("EveryMonth"),
+ 'WEEKLY'=>$langs->trans("EveryWeek"),
+ //'DAYLY'=>$langs->trans("EveryDay"),
+ );
$selectedrecurrulefreq='no';
$selectedrecurrulebymonthday='';
$selectedrecurrulebyday='';
@@ -1241,8 +1268,13 @@ if ($id > 0)
if (! empty($object->fk_element) && ! empty($object->elementtype))
{
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
- print ' '.$langs->trans("LinkedObject").' ';
- print ''.dolGetElementUrl($object->fk_element,$object->elementtype,1).' ';
+ print '';
+ print ''.$langs->trans("LinkedObject").' ';
+ print ''.dolGetElementUrl($object->fk_element,$object->elementtype,1);
+ print '';
+ print '';
+ print ' ';
+ print ' ';
}
// Description
@@ -1611,7 +1643,6 @@ if ($id > 0)
}
}
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php
index 0c7ad11cb3c..7b9caabb8a9 100644
--- a/htdocs/comm/action/class/actioncomm.class.php
+++ b/htdocs/comm/action/class/actioncomm.class.php
@@ -4,6 +4,7 @@
* Copyright (C) 2005-2012 Regis Houssin
* Copyright (C) 2011-2017 Juanjo Menent
* Copyright (C) 2015 Marcos García
+ * Copyright (C) 2018 Nicolas ZABOURI
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -33,15 +34,29 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
*/
class ActionComm extends CommonObject
{
+ /**
+ * @var string ID to identify managed object
+ */
public $element='action';
+
+ /**
+ * @var string Name of table without prefix where object is stored
+ */
public $table_element = 'actioncomm';
+
public $table_rowid = 'id';
- public $picto='action';
+
+ /**
+ * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
+ */
+ public $picto = 'action';
+
/**
* 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
* @var int
*/
public $ismultientitymanaged = 1;
+
/**
* 0=Default, 1=View may be restricted to sales representative only if no permission to see all or to company of external user if external user, 2=Same than 1 but accept record if fksoc is empty
* @var integer
@@ -52,7 +67,7 @@ class ActionComm extends CommonObject
* Id of the event
* @var int
*/
- var $id;
+ public $id;
/**
* Id of the event. Use $id as possible
@@ -66,7 +81,10 @@ class ActionComm extends CommonObject
var $type_color; // Color into parent table llx_c_actioncomm (used only if option to use type is set)
var $code; // Free code to identify action. Ie: Agenda trigger add here AC_TRIGGERNAME ('AC_COMPANY_CREATE', 'AC_PROPAL_VALIDATE', ...)
- var $label;
+ /**
+ * @var string Agenda event label
+ */
+ public $label;
/**
* @var string
@@ -423,7 +441,6 @@ class ActionComm extends CommonObject
$this->error=$this->db->lasterror();
return -1;
}
-
}
/**
@@ -620,7 +637,7 @@ class ActionComm extends CommonObject
$this->contact->id = $obj->fk_contact; // deprecated
$this->fk_element = $obj->elementid;
- $this->elementid = $obj->elementid;
+ $this->elementid = $obj->elementid;
$this->elementtype = $obj->elementtype;
$this->fetchResources();
@@ -634,7 +651,6 @@ class ActionComm extends CommonObject
}
return $num;
-
}
/**
@@ -682,6 +698,7 @@ class ActionComm extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Initialize this->userassigned array with list of id of user assigned to event
*
@@ -689,6 +706,7 @@ class ActionComm extends CommonObject
*/
function fetch_userassigned()
{
+ // phpcs:enable
$sql ="SELECT fk_actioncomm, element_type, fk_element, answer_status, mandatory, transparency";
$sql.=" FROM ".MAIN_DB_PREFIX."actioncomm_resources";
$sql.=" WHERE element_type = 'user' AND fk_actioncomm = ".$this->id;
@@ -883,7 +901,7 @@ class ActionComm extends CommonObject
$val=array('id'=>$val);
}
$sql ="INSERT INTO ".MAIN_DB_PREFIX."actioncomm_resources(fk_actioncomm, element_type, fk_element, mandatory, transparency, answer_status)";
- $sql.=" VALUES(".$this->id.", 'user', ".$val['id'].", ".(empty($val['manadatory'])?'0':$val['manadatory']).", ".(empty($val['transparency'])?'0':$val['transparency']).", ".(empty($val['answer_status'])?'0':$val['answer_status']).")";
+ $sql.=" VALUES(".$this->id.", 'user', ".$val['id'].", ".(empty($val['mandatory'])?'0':$val['mandatory']).", ".(empty($val['transparency'])?'0':$val['transparency']).", ".(empty($val['answer_status'])?'0':$val['answer_status']).")";
$resql = $this->db->query($sql);
if (! $resql)
@@ -1004,6 +1022,7 @@ class ActionComm extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Load indicators for dashboard (this->nbtodo and this->nbtodolate)
*
@@ -1013,7 +1032,8 @@ class ActionComm extends CommonObject
*/
function load_board($user, $load_state_board=0)
{
- global $conf, $langs;
+ // phpcs:enable
+ global $conf, $langs;
if(empty($load_state_board)) $sql = "SELECT a.id, a.datep as dp";
else {
@@ -1128,6 +1148,7 @@ class ActionComm extends CommonObject
return $this->LibStatut($this->percentage,$mode,$hidenastatus,$this->datep);
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Return label of action status
*
@@ -1139,6 +1160,7 @@ class ActionComm extends CommonObject
*/
function LibStatut($percent,$mode,$hidenastatus=0,$datestart='')
{
+ // phpcs:enable
global $langs;
if ($mode == 0)
@@ -1220,7 +1242,10 @@ class ActionComm extends CommonObject
if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips
- $label = $this->label;
+ if ((!$user->rights->agenda->allactions->read && $this->author->id != $user->id) || (!$user->rights->agenda->myactions->read && $this->author->id == $user->id))
+ $option = 'nolink';
+
+ $label = $this->label;
if (empty($label)) $label=$this->libelle; // For backward compatibility
$result='';
@@ -1286,6 +1311,10 @@ class ActionComm extends CommonObject
$linkstart.=$linkclose.'>';
$linkend='';
+ if ($option == 'nolink') {
+ $linkstart = '';
+ $linkend = '';
+ }
//print 'rrr'.$this->libelle.'rrr'.$this->label.'rrr'.$withpicto;
if ($withpicto == 2)
@@ -1329,6 +1358,7 @@ class ActionComm extends CommonObject
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Export events from database into a cal file.
*
@@ -1341,11 +1371,12 @@ class ActionComm extends CommonObject
*/
function build_exportfile($format,$type,$cachedelay,$filename,$filters)
{
+ // phpcs:enable
global $conf,$langs,$dolibarr_main_url_root,$mysoc;
- require_once (DOL_DOCUMENT_ROOT ."/core/lib/xcal.lib.php");
- require_once (DOL_DOCUMENT_ROOT ."/core/lib/date.lib.php");
- require_once (DOL_DOCUMENT_ROOT ."/core/lib/files.lib.php");
+ require_once DOL_DOCUMENT_ROOT ."/core/lib/xcal.lib.php";
+ require_once DOL_DOCUMENT_ROOT ."/core/lib/date.lib.php";
+ require_once DOL_DOCUMENT_ROOT ."/core/lib/files.lib.php";
dol_syslog(get_class($this)."::build_exportfile Build export file format=".$format.", type=".$type.", cachedelay=".$cachedelay.", filename=".$filename.", filters size=".count($filters), LOG_DEBUG);
@@ -1659,8 +1690,6 @@ class ActionComm extends CommonObject
// TODO Scan events of type 'email' into table llx_actioncomm_reminder with status todo, send email, then set status to done
-
-
// Delete also very old past events (we do not keep more than 1 month record in past)
$sql = "DELETE FROM ".MAIN_DB_PREFIX."actioncomm_reminder WHERE dateremind < '".$this->db->jdate($now - (3600 * 24 * 32))."'";
$this->db->query($sql);
@@ -1669,6 +1698,4 @@ class ActionComm extends CommonObject
return $error;
}
-
}
-
diff --git a/htdocs/comm/action/class/actioncommreminder.class.php b/htdocs/comm/action/class/actioncommreminder.class.php
index 4873db461f6..63773661cbd 100644
--- a/htdocs/comm/action/class/actioncommreminder.class.php
+++ b/htdocs/comm/action/class/actioncommreminder.class.php
@@ -34,14 +34,17 @@ class ActionCommReminder extends CommonObject
* @var string ID to identify managed object
*/
public $element = 'actioncomm_reminder';
+
/**
* @var string Name of table without prefix where object is stored
*/
public $table_element = 'actioncomm_reminder';
+
/**
* @var array Does actioncommreminder support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
*/
public $ismultientitymanaged = 0;
+
/**
* @var string String with name of icon for actioncommreminder. Must be the part after the 'object_' into object_actioncommreminder.png
*/
@@ -81,7 +84,12 @@ class ActionCommReminder extends CommonObject
public $rowid;
public $dateremind;
public $typeremind;
+
+ /**
+ * @var int User ID
+ */
public $fk_user;
+
public $offsetvalue;
public $offsetunit;
public $status;
@@ -165,6 +173,7 @@ class ActionCommReminder extends CommonObject
return $this->LibStatut($this->status,$mode);
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Return the status
*
@@ -174,40 +183,35 @@ class ActionCommReminder extends CommonObject
*/
static function LibStatut($status,$mode=0)
{
+ // phpcs:enable
global $langs;
- if ($mode == 0)
- {
- $prefix='';
- if ($status == 1) return $langs->trans('Done');
- if ($status == 0) return $langs->trans('ToDo');
- }
- if ($mode == 1)
+ if ($mode == 0 || $mode == 1)
{
if ($status == 1) return $langs->trans('Done');
if ($status == 0) return $langs->trans('ToDo');
}
- if ($mode == 2)
+ elseif ($mode == 2)
{
if ($status == 1) return img_picto($langs->trans('Done'),'statut4').' '.$langs->trans('Done');
if ($status == 0) return img_picto($langs->trans('ToDo'),'statut5').' '.$langs->trans('ToDo');
}
- if ($mode == 3)
+ elseif ($mode == 3)
{
if ($status == 1) return img_picto($langs->trans('Done'),'statut4');
if ($status == 0) return img_picto($langs->trans('ToDo'),'statut5');
}
- if ($mode == 4)
+ elseif ($mode == 4)
{
if ($status == 1) return img_picto($langs->trans('Done'),'statut4').' '.$langs->trans('Done');
if ($status == 0) return img_picto($langs->trans('ToDo'),'statut5').' '.$langs->trans('ToDo');
}
- if ($mode == 5)
+ elseif ($mode == 5)
{
if ($status == 1) return $langs->trans('Done').' '.img_picto($langs->trans('Done'),'statut4');
if ($status == 0) return $langs->trans('ToDo').' '.img_picto($langs->trans('ToDo'),'statut5');
}
- if ($mode == 6)
+ elseif ($mode == 6)
{
if ($status == 1) return $langs->trans('Done').' '.img_picto($langs->trans('Done'),'statut4');
if ($status == 0) return $langs->trans('ToDo').' '.img_picto($langs->trans('ToDo'),'statut5');
@@ -224,6 +228,4 @@ class ActionCommReminder extends CommonObject
{
$this->initAsSpecimenCommon();
}
-
}
-
diff --git a/htdocs/comm/action/class/api_agendaevents.class.php b/htdocs/comm/action/class/api_agendaevents.class.php
index f5d9c7db762..677e477cd89 100644
--- a/htdocs/comm/action/class/api_agendaevents.class.php
+++ b/htdocs/comm/action/class/api_agendaevents.class.php
@@ -46,8 +46,8 @@ class AgendaEvents extends DolibarrApi
*/
function __construct()
{
- global $db, $conf;
- $this->db = $db;
+ global $db, $conf;
+ $this->db = $db;
$this->actioncomm = new ActionComm($this->db);
}
@@ -99,13 +99,14 @@ class AgendaEvents extends DolibarrApi
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.label:like:'%dol%') and (t.datec:<:'20160101')"
* @return array Array of Agenda Events objects
*/
- function index($sortfield = "t.id", $sortorder = 'ASC', $limit = 100, $page = 0, $user_ids = 0, $sqlfilters = '') {
+ function index($sortfield = "t.id", $sortorder = 'ASC', $limit = 100, $page = 0, $user_ids = 0, $sqlfilters = '')
+ {
global $db, $conf;
$obj_ret = array();
if (! DolibarrApiAccess::$user->rights->agenda->myactions->read) {
- throw new RestException(401, "Insuffisant rights to read events");
+ throw new RestException(401, "Insuffisant rights to read events");
}
// case of external user
@@ -218,7 +219,7 @@ class AgendaEvents extends DolibarrApi
/**
- * Update Agenda Event general fields (won't touch lines of expensereport)
+ * Update Agenda Event general fields
*
* @param int $id Id of Agenda Event to update
* @param array $request_data Datas
@@ -226,7 +227,8 @@ class AgendaEvents extends DolibarrApi
* @return int
*/
/*
- function put($id, $request_data = null) {
+ function put($id, $request_data = null)
+ {
if (! DolibarrApiAccess::$user->rights->agenda->myactions->create) {
throw new RestException(401, "Insuffisant rights to create your Agenda Event");
}
@@ -234,20 +236,20 @@ class AgendaEvents extends DolibarrApi
throw new RestException(401, "Insuffisant rights to create an Agenda Event for owner id ".$request_data['userownerid'].' Your id is '.DolibarrApiAccess::$user->id);
}
- $result = $this->expensereport->fetch($id);
+ $result = $this->actioncomm->fetch($id);
if ( ! $result ) {
- throw new RestException(404, 'expensereport not found');
+ throw new RestException(404, 'actioncomm not found');
}
- if ( ! DolibarrApi::_checkAccessToResource('expensereport',$this->expensereport->id)) {
+ if ( ! DolibarrApi::_checkAccessToResource('actioncomm',$this->actioncomm->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
foreach($request_data as $field => $value) {
if ($field == 'id') continue;
- $this->expensereport->$field = $value;
+ $this->actioncomm->$field = $value;
}
- if ($this->expensereport->update($id, DolibarrApiAccess::$user,1,'','','update'))
+ if ($this->actioncomm->update($id, DolibarrApiAccess::$user,1,'','','update'))
return $this->get($id);
return false;
@@ -291,7 +293,6 @@ class AgendaEvents extends DolibarrApi
'message' => 'Agenda Event deleted'
)
);
-
}
/**
@@ -319,7 +320,8 @@ class AgendaEvents extends DolibarrApi
* @param object $object Object to clean
* @return array Array of cleaned object properties
*/
- function _cleanObjectDatas($object) {
+ function _cleanObjectDatas($object)
+ {
$object = parent::_cleanObjectDatas($object);
diff --git a/htdocs/comm/action/class/cactioncomm.class.php b/htdocs/comm/action/class/cactioncomm.class.php
index d8496a9a4ff..d6c25f6d4c1 100644
--- a/htdocs/comm/action/class/cactioncomm.class.php
+++ b/htdocs/comm/action/class/cactioncomm.class.php
@@ -24,24 +24,43 @@
/**
- * Class to manage different types of events
+ * Class to manage different types of events
*/
class CActionComm
{
- var $error;
- var $db;
+ /**
+ * @var string Error code (or message)
+ */
+ public $error='';
- var $id;
+ /**
+ * @var DoliDB Database handler.
+ */
+ public $db;
- var $code;
- var $type;
- var $libelle; // deprecated
- var $label;
- var $active;
- var $color;
- var $picto;
+ /**
+ * @var int ID
+ */
+ public $id;
- var $type_actions=array();
+ public $code;
+ public $type;
+ public $libelle; // deprecated
+
+ /**
+ * @var string Type of agenda event label
+ */
+ public $label;
+
+ public $active;
+ public $color;
+
+ /**
+ * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
+ */
+ public $picto;
+
+ public $type_actions=array();
/**
@@ -99,6 +118,7 @@ class CActionComm
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Return list of event types: array(id=>label) or array(code=>label)
*
@@ -112,6 +132,7 @@ class CActionComm
*/
function liste_array($active='',$idorcode='id',$excludetype='',$onlyautoornot=0, $morefilter='', $shortlabel=0)
{
+ // phpcs:enable
global $langs,$conf;
$langs->load("commercial");
@@ -210,5 +231,4 @@ class CActionComm
$transcode=$langs->trans("Action".$this->code);
if ($transcode != "Action".$this->code) return $transcode;
}
-
}
diff --git a/htdocs/comm/action/class/ical.class.php b/htdocs/comm/action/class/ical.class.php
index 708b52c9151..d3c2070d321 100644
--- a/htdocs/comm/action/class/ical.class.php
+++ b/htdocs/comm/action/class/ical.class.php
@@ -27,7 +27,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/xcal.lib.php';
/**
- * Class to read/parse ICal calendars
+ * Class to read/parse ICal calendars
*/
class ICal
{
@@ -39,15 +39,15 @@ class ICal
var $last_key; //Help variable save last key (multiline string)
- /**
- * Constructor
- */
- public function __construct()
- {
+ /**
+ * Constructor
+ */
+ public function __construct()
+ {
+ }
- }
-
- /**
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
+ /**
* Read text file, icalender text file
*
* @param string $file File
@@ -55,6 +55,7 @@ class ICal
*/
function read_file($file)
{
+ // phpcs:enable
$this->file = $file;
$file_text='';
@@ -67,6 +68,7 @@ class ICal
return $file_text; // return all text
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Returns the number of calendar events
*
@@ -74,9 +76,11 @@ class ICal
*/
function get_event_count()
{
+ // phpcs:enable
return $this->event_count;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Returns the number of to do
*
@@ -84,6 +88,7 @@ class ICal
*/
function get_todo_count()
{
+ // phpcs:enable
return $this->todo_count;
}
@@ -195,6 +200,7 @@ class ICal
return $this->cal;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Add to $this->ical array one value and key.
*
@@ -205,6 +211,7 @@ class ICal
*/
function add_to_array($type, $key, $value)
{
+ // phpcs:enable
//print 'type='.$type.' key='.$key.' value='.$value.'
'."\n";
@@ -255,6 +262,7 @@ class ICal
$this->last_key = $key;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Parse text "XXXX:value text some with : " and return array($key = "XXXX", $value="value");
*
@@ -263,7 +271,8 @@ class ICal
*/
function retun_key_value($text)
{
- /*
+ // phpcs:enable
+ /*
preg_match("/([^:]+)[:]([\w\W]+)/", $text, $matches);
if (empty($matches))
@@ -275,9 +284,10 @@ class ICal
$matches = array_splice($matches, 1, 2);
return $matches;
}*/
- return explode(':',$text,2);
+ return explode(':',$text,2);
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Parse RRULE return array
*
@@ -286,7 +296,8 @@ class ICal
*/
function ical_rrule($value)
{
- $result=array();
+ // phpcs:enable
+ $result = array();
$rrule = explode(';',$value);
foreach ($rrule as $line)
{
@@ -295,6 +306,8 @@ class ICal
}
return $result;
}
+
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Return Unix time from ical date time fomrat (YYYYMMDD[T]HHMMSS[Z] or YYYYMMDD[T]HHMMSS)
*
@@ -303,6 +316,7 @@ class ICal
*/
function ical_date_to_unix($ical_date)
{
+ // phpcs:enable
$ical_date = str_replace('T', '', $ical_date);
$ical_date = str_replace('Z', '', $ical_date);
@@ -316,6 +330,7 @@ class ICal
return $ntime; // ntime is a GTM time
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Return unix date from iCal date format
*
@@ -325,7 +340,8 @@ class ICal
*/
function ical_dt_date($key, $value)
{
- $return_value=array();
+ // phpcs:enable
+ $return_value = array();
$value = $this->ical_date_to_unix($value);
// Analyse TZID
@@ -345,6 +361,7 @@ class ICal
return array($key,$return_value);
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Return sorted eventlist as array or false if calenar is empty
*
@@ -352,6 +369,7 @@ class ICal
*/
function get_sort_event_list()
{
+ // phpcs:enable
$temp = $this->get_event_list();
if (!empty($temp))
{
@@ -364,6 +382,7 @@ class ICal
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Compare two unix timestamp
*
@@ -373,9 +392,11 @@ class ICal
*/
function ical_dtstart_compare($a, $b)
{
+ // phpcs:enable
return strnatcasecmp($a['DTSTART']['unixtime'], $b['DTSTART']['unixtime']);
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Return eventlist array (not sort eventlist array)
*
@@ -383,9 +404,11 @@ class ICal
*/
function get_event_list()
{
+ // phpcs:enable
return (! empty($this->cal['VEVENT'])?$this->cal['VEVENT']:'');
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Return eventlist array (not sort eventlist array)
*
@@ -393,9 +416,11 @@ class ICal
*/
function get_freebusy_list()
{
+ // phpcs:enable
return $this->cal['VFREEBUSY'];
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Return to do array (not sort to do array)
*
@@ -403,9 +428,11 @@ class ICal
*/
function get_todo_list()
{
+ // phpcs:enable
return $this->cal['VTODO'];
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Return base calendar data
*
@@ -413,9 +440,11 @@ class ICal
*/
function get_calender_data()
{
+ // phpcs:enable
return $this->cal['VCALENDAR'];
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Return array with all data
*
@@ -423,6 +452,7 @@ class ICal
*/
function get_all_data()
{
+ // phpcs:enable
return $this->cal;
}
}
diff --git a/htdocs/comm/action/document.php b/htdocs/comm/action/document.php
index 43e5b89f115..a5998e220f7 100644
--- a/htdocs/comm/action/document.php
+++ b/htdocs/comm/action/document.php
@@ -239,7 +239,7 @@ if ($object->id > 0)
print '';
- // Construit liste des fichiers
+ // Build file list
$filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
$totalsize=0;
foreach($filearray as $key => $file)
@@ -268,7 +268,6 @@ else
print $langs->trans("ErrorUnknown");
}
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php
index 79b9d30d948..7e27c0d924c 100644
--- a/htdocs/comm/action/index.php
+++ b/htdocs/comm/action/index.php
@@ -101,11 +101,15 @@ else
if ($actioncode == '' && empty($actioncodearray)) $actioncode=(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE);
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 ($action == 'default')
+
+$defaultview = (empty($conf->global->AGENDA_DEFAULT_VIEW) ? 'show_month' : $conf->global->AGENDA_DEFAULT_VIEW);
+$defaultview = (empty($user->conf->AGENDA_DEFAULT_VIEW) ? $defaultview : $user->conf->AGENDA_DEFAULT_VIEW);
+if (empty($action) && ! isset($_GET['action']) && ! isset($_POST['action'])) $action=$defaultview;
+if ($action == 'default') // When action is default, we want a calendar view and not the list
{
- $action = ((! empty($conf->global->AGENDA_DEFAULT_VIEW) && $conf->global->AGENDA_DEFAULT_VIEW!='show_list') ? $conf->global->AGENDA_DEFAULT_VIEW : 'show_month');
+ $action = (($defaultview != 'show_list') ? $defaultview : 'show_month');
}
+
if (GETPOST('viewcal') && $action != 'show_day' && $action != 'show_week') {
$action='show_month'; $day='';
} // View by month
@@ -1250,8 +1254,8 @@ else // View by day
print "\n".'';
+// End of page
llxFooter();
-
$db->close();
@@ -1327,7 +1331,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa
$ymd=sprintf("%04d",$year).sprintf("%02d",$month).sprintf("%02d",$day);
$colorindexused[$user->id] = 0; // Color index for current user (user->id) is always 0
- $nextindextouse=count($colorindexused); // At first run this is 0, so first user has 0, next 1, ...
+ $nextindextouse=is_array($colorindexused)?count($colorindexused):0; // At first run this is 0, so fist user has 0, next 1, ...
//var_dump($colorindexused);
foreach ($eventarray as $daykey => $notused)
diff --git a/htdocs/comm/action/info.php b/htdocs/comm/action/info.php
index 9a043a13690..2582e9b6b32 100644
--- a/htdocs/comm/action/info.php
+++ b/htdocs/comm/action/info.php
@@ -114,5 +114,6 @@ print '
';
dol_fiche_end();
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php
index 2c11a1de977..5628e65c6d9 100644
--- a/htdocs/comm/action/list.php
+++ b/htdocs/comm/action/list.php
@@ -4,6 +4,7 @@
* Copyright (C) 2004-2016 Laurent Destailleur
* Copyright (C) 2005-2012 Regis Houssin
* Copyright (C) 2017 Open-DSI
+ * 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
@@ -189,9 +190,9 @@ $form=new Form($db);
$userstatic=new User($db);
$formactions=new FormActions($db);
-$nav='';
-$nav.=$form->select_date($dateselect, 'dateselect', 0, 0, 1, '', 1, 0, 1);
-$nav.=' ';
+$nav = '';
+$nav .= $form->selectDate($dateselect, 'dateselect', 0, 0, 1, '', 1, 0);
+$nav .=' ';
$now=dol_now();
@@ -438,15 +439,17 @@ if ($resql)
if (! empty($arrayfields['a.label']['checked'])) print ' ';
if (! empty($arrayfields['a.datep']['checked'])) {
print '';
- print $form->select_date($datestart, 'datestart', 0, 0, 1, '', 1, 0, 1);
+ print $form->selectDate($datestart, 'datestart', 0, 0, 1, '', 1, 0);
print ' ';
}
if (! empty($arrayfields['a.datep2']['checked'])) {
print '';
- print $form->select_date($dateend, 'dateend', 0, 0, 1, '', 1, 0, 1);
+ print $form->selectDate($dateend, 'dateend', 0, 0, 1, '', 1, 0);
print ' ';
}
- if (! empty($arrayfields['s.nom']['checked'])) print ' ';
+ if (! empty($arrayfields['s.nom']['checked'])) {
+ print ' ';
+ }
if (! empty($arrayfields['a.fk_contact']['checked'])) print ' ';
if (! empty($arrayfields['a.fk_element']['checked'])) print ' ';
@@ -672,7 +675,6 @@ else
dol_print_error($db);
}
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/comm/action/pertype.php b/htdocs/comm/action/pertype.php
index 2fdfa180319..31f22420cb8 100644
--- a/htdocs/comm/action/pertype.php
+++ b/htdocs/comm/action/pertype.php
@@ -5,6 +5,7 @@
* Copyright (C) 2005-2012 Regis Houssin
* Copyright (C) 2011 Juanjo Menent
* Copyright (C) 2014 Cedric GROSS
+ * 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
@@ -262,7 +263,7 @@ $nav.='';
$nav.='';
$nav.='';
-$nav.=$form->select_date($dateselect, 'dateselect', 0, 0, 1, '', 1, 0, 1);
+$nav.= $form->selectDate($dateselect, 'dateselect', 0, 0, 1, '', 1, 0);
$nav.=' ';
$nav.='';
@@ -730,10 +731,8 @@ jQuery(document).ready(function() {
});
';
-
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/comm/action/peruser.php b/htdocs/comm/action/peruser.php
index 0cf056ef3a9..7b02857becf 100644
--- a/htdocs/comm/action/peruser.php
+++ b/htdocs/comm/action/peruser.php
@@ -5,6 +5,7 @@
* Copyright (C) 2005-2012 Regis Houssin
* Copyright (C) 2011 Juanjo Menent
* Copyright (C) 2014 Cedric GROSS
+ * 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
@@ -276,7 +277,7 @@ $nav.='';
$nav.='';
$nav.='';
*/
-$nav.=$form->select_date($dateselect, 'dateselect', 0, 0, 1, '', 1, 0, 1);
+$nav.= $form->selectDate($dateselect, 'dateselect', 0, 0, 1, '', 1, 0);
$nav.=' ';
//$nav.='';
@@ -865,10 +866,8 @@ jQuery(document).ready(function() {
});
';
-
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/comm/action/rapport/index.php b/htdocs/comm/action/rapport/index.php
index 7e4108b470b..ff1c7746afa 100644
--- a/htdocs/comm/action/rapport/index.php
+++ b/htdocs/comm/action/rapport/index.php
@@ -209,5 +209,6 @@ else
dol_print_error($db);
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/comm/admin/propal_extrafields.php b/htdocs/comm/admin/propal_extrafields.php
index 6a6aa12862a..becfabc949c 100644
--- a/htdocs/comm/admin/propal_extrafields.php
+++ b/htdocs/comm/admin/propal_extrafields.php
@@ -111,6 +111,6 @@ if ($action == 'edit' && ! empty($attrname))
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php';
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/comm/admin/propaldet_extrafields.php b/htdocs/comm/admin/propaldet_extrafields.php
index 0816a4c035c..7172c0e5b7c 100644
--- a/htdocs/comm/admin/propaldet_extrafields.php
+++ b/htdocs/comm/admin/propaldet_extrafields.php
@@ -118,6 +118,6 @@ if ($action == 'edit' && ! empty($attrname))
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php';
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php
index 83db0e0f1d2..5874a7b855c 100644
--- a/htdocs/comm/card.php
+++ b/htdocs/comm/card.php
@@ -181,7 +181,7 @@ if (empty($reshook))
if ($action == 'setorder_min_amount')
{
$object->fetch($id);
- $object->order_min_amount=GETPOST('order_min_amount');
+ $object->order_min_amount=price2num(GETPOST('order_min_amount','alpha'));
$result=$object->update($object->id, $user);
if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
}
@@ -423,15 +423,21 @@ if ($object->id > 0)
print ' ';
print ' ';
+ }
- print '';
- print '';
- print $form->editfieldkey("OrderMinAmount",'order_min_amount',$object->order_min_amount,$object,$user->rights->societe->creer);
- print ' ';
- print $form->editfieldval("OrderMinAmount",'order_min_amount',$object->order_min_amount,$object,$user->rights->societe->creer,$limit_field_type,($object->order_min_amount != '' ? price($object->order_min_amount) : ''));
-
- print ' ';
- print ' ';
+ if ($object->client)
+ {
+ if (! empty($conf->commande->enabled) && ! empty($conf->global->ORDER_MANAGE_MIN_AMOUNT))
+ {
+ print ''."\n";
+ print '';
+ print '';
+ print $form->editfieldkey("OrderMinAmount",'order_min_amount',$object->order_min_amount,$object,$user->rights->societe->creer);
+ print ' ';
+ print $form->editfieldval("OrderMinAmount",'order_min_amount',$object->order_min_amount,$object,$user->rights->societe->creer,$limit_field_type,($object->order_min_amount != '' ? price($object->order_min_amount) : ''));
+ print ' ';
+ print ' ';
+ }
}
@@ -582,7 +588,7 @@ if ($object->id > 0)
$link=DOL_URL_ROOT.'/comm/propal/list.php?socid='.$object->id;
$icon='bill';
if ($link) $boxstat.='';
- $boxstat.='';
+ $boxstat.='';
$boxstat.=''.img_object("",$icon).' '.$text.'
';
$boxstat.=''.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).'';
$boxstat.='';
@@ -600,7 +606,7 @@ if ($object->id > 0)
$link=DOL_URL_ROOT.'/commande/list.php?socid='.$object->id;
$icon='bill';
if ($link) $boxstat.='';
- $boxstat.='';
+ $boxstat.='';
$boxstat.=''.img_object("",$icon).' '.$text.'
';
$boxstat.=''.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).'';
$boxstat.='';
@@ -618,7 +624,7 @@ if ($object->id > 0)
$link=DOL_URL_ROOT.'/compta/facture/list.php?socid='.$object->id;
$icon='bill';
if ($link) $boxstat.='';
- $boxstat.='';
+ $boxstat.='';
$boxstat.=''.img_object("",$icon).' '.$text.'
';
$boxstat.=''.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).'';
$boxstat.='';
@@ -634,7 +640,7 @@ if ($object->id > 0)
$link=DOL_URL_ROOT.'/compta/recap-compta.php?socid='.$object->id;
$icon='bill';
if ($link) $boxstat.='';
- $boxstat.='';
+ $boxstat.='';
$boxstat.=''.img_object("",$icon).' '.$text.'
';
$boxstat.=''.price($outstandingOpened, 1, $langs, 1, -1, -1, $conf->currency).$warn.'';
$boxstat.='';
@@ -1346,5 +1352,4 @@ else
// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/comm/contact.php b/htdocs/comm/contact.php
index aa8dae43140..b6d9f0922aa 100644
--- a/htdocs/comm/contact.php
+++ b/htdocs/comm/contact.php
@@ -176,6 +176,6 @@ else
dol_print_error($db);
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php
index e90a821b5e3..92757dcac36 100644
--- a/htdocs/comm/index.php
+++ b/htdocs/comm/index.php
@@ -884,6 +884,6 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire)
print '';
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/comm/mailing/advtargetemailing.php b/htdocs/comm/mailing/advtargetemailing.php
index 1c886e2ba2c..72058578db7 100644
--- a/htdocs/comm/mailing/advtargetemailing.php
+++ b/htdocs/comm/mailing/advtargetemailing.php
@@ -84,9 +84,12 @@ if (empty($template_id)) {
$result = $advTarget->fetch($template_id);
}
-if ($result < 0) {
- setEventMessage($advTarget->error, 'errors');
-} else {
+if ($result < 0)
+{
+ setEventMessages($advTarget->error, $advTarget->errors, 'errors');
+}
+else
+{
if (! empty($advTarget->id)) {
$array_query = json_decode($advTarget->filtervalue, true);
}
@@ -101,7 +104,7 @@ if ($action == 'loadfilter') {
if (! empty($template_id)) {
$result = $advTarget->fetch($template_id);
if ($result < 0) {
- setEventMessage($advTarget->error, 'errors');
+ setEventMessages($advTarget->error, $advTarget->errors, 'errors');
} else {
if (! empty($advTarget->id)) {
$array_query = json_decode($advTarget->filtervalue, true);
@@ -202,7 +205,7 @@ if ($action == 'add') {
// if ($array_query ['type_of_target'] == 1 || $array_query ['type_of_target'] == 3) {
$result = $advTarget->query_thirdparty($array_query);
if ($result < 0) {
- setEventMessage($advTarget->error, 'errors');
+ setEventMessages($advTarget->error, $advTarget->errors, 'errors');
}
/*} else {
$advTarget->thirdparty_lines = array ();
@@ -211,7 +214,7 @@ if ($action == 'add') {
if ($user_contact_query && ($array_query['type_of_target'] == 1 || $array_query['type_of_target'] == 2 || $array_query['type_of_target'] == 4)) {
$result = $advTarget->query_contact($array_query, 1);
if ($result < 0) {
- setEventMessage($advTarget->error, 'errors');
+ setEventMessages($advTarget->error, $advTarget->errors, 'errors');
}
// If use contact but no result use artefact to so not use socid into add_to_target
if (count($advTarget->contact_lines) == 0) {
@@ -222,7 +225,7 @@ if ($action == 'add') {
} else {
$advTarget->contact_lines = array ();
}
-
+
if ((count($advTarget->thirdparty_lines) > 0) || (count($advTarget->contact_lines) > 0)) {
// Add targets into database
$obj = new mailing_advthirdparties($db);
@@ -241,10 +244,10 @@ if ($action == 'add') {
exit();
}
if ($result == 0) {
- setEventMessage($langs->trans("WarningNoEMailsAdded"), 'warnings');
+ setEventMessages($langs->trans("WarningNoEMailsAdded"), null, 'warnings');
}
if ($result < 0) {
- setEventMessage($obj->error, 'errors');
+ setEventMessages($obj->error, $obj->errors, 'errors');
}
}
@@ -264,7 +267,7 @@ if ($action == 'savefilter' || $action == 'createfilter') {
$error = 0;
if ($action == 'createfilter' && empty($template_name)) {
- setEventMessage($langs->trans('ErrorFieldRequired', $langs->trans('AdvTgtOrCreateNewFilter')), 'errors');
+ setEventMessages($langs->trans('ErrorFieldRequired', $langs->trans('AdvTgtOrCreateNewFilter')), null, 'errors');
$error ++;
}
@@ -353,13 +356,13 @@ if ($action == 'savefilter' || $action == 'createfilter') {
$advTarget->name = $template_name;
$result = $advTarget->create($user);
if ($result < 0) {
- setEventMessage($advTarget->error, 'errors');
+ setEventMessages($advTarget->error, $advTarget->errors, 'errors');
}
} elseif ($action == 'savefilter') {
-
+
$result = $advTarget->update($user);
if ($result < 0) {
- setEventMessage($advTarget->error, 'errors');
+ setEventMessages($advTarget->error, $advTarget->errors, 'errors');
}
}
$template_id = $advTarget->id;
@@ -369,7 +372,7 @@ if ($action == 'savefilter' || $action == 'createfilter') {
if ($action == 'deletefilter') {
$result = $advTarget->delete($user);
if ($result < 0) {
- setEventMessage($advTarget->error, 'errors');
+ setEventMessages($advTarget->error, $advTarget->errors, 'errors');
}
header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $id);
exit();
@@ -462,11 +465,12 @@ if ($object->fetch($id) >= 0) {
// Show email selectors
if ($object->statut == 0 && $user->rights->mailing->creer) {
-
+
include DOL_DOCUMENT_ROOT . '/core/tpl/advtarget.tpl.php';
-
+
}
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php
index 97746ad9d82..469db6f2a54 100644
--- a/htdocs/comm/mailing/card.php
+++ b/htdocs/comm/mailing/card.php
@@ -1358,5 +1358,6 @@ else
}
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/comm/mailing/cibles.php b/htdocs/comm/mailing/cibles.php
index d3a627a1695..f07f308e74a 100644
--- a/htdocs/comm/mailing/cibles.php
+++ b/htdocs/comm/mailing/cibles.php
@@ -66,7 +66,6 @@ $modulesdir = dolGetModulesDirs('/mailings');
$object = new Mailing($db);
-
/*
* Actions
*/
@@ -303,9 +302,11 @@ if ($object->fetch($id) >= 0)
// Sort $modulenames
sort($modulenames);
+ $var = true;
+
// Loop on each submodule
- foreach($modulenames as $modulename)
- {
+ foreach($modulenames as $modulename)
+ {
// Loading Class
$file = $dir.$modulename.".modules.php";
$classname = "mailing_".$modulename;
@@ -328,7 +329,6 @@ if ($object->fetch($id) >= 0)
// Si le module mailing est qualifie
if ($qualified)
{
-
if ($allowaddtarget)
{
print '';
@@ -646,7 +646,6 @@ if ($object->fetch($id) >= 0)
}
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/comm/mailing/class/advtargetemailing.class.php b/htdocs/comm/mailing/class/advtargetemailing.class.php
index 50d9faf0637..c862b8392fd 100644
--- a/htdocs/comm/mailing/class/advtargetemailing.class.php
+++ b/htdocs/comm/mailing/class/advtargetemailing.class.php
@@ -28,14 +28,35 @@
*/
class AdvanceTargetingMailing extends CommonObject
{
+ /**
+ * @var DoliDB Database handler.
+ */
+ public $db;
- var $db; //!< To store db handler
- var $error; //!< To return error code (or message)
- var $errors = array(); //!< To return several error codes (or messages)
- var $element='advtargetemailing'; //!< Id that identify managed objects
- var $table_element='advtargetemailing'; //!< Name of table without prefix where object is stored
+ /**
+ * @var string Error code (or message)
+ */
+ public $error='';
- var $id;
+ /**
+ * @var string[] Error codes (or messages)
+ */
+ public $errors = array();
+
+ /**
+ * @var string ID to identify managed object
+ */
+ public $element='advtargetemailing';
+
+ /**
+ * @var string Name of table without prefix where object is stored
+ */
+ public $table_element='advtargetemailing';
+
+ /**
+ * @var int ID
+ */
+ public $id;
var $name;
var $entity;
@@ -54,9 +75,9 @@ class AdvanceTargetingMailing extends CommonObject
/**
- * Constructor
+ * Constructor
*
- * @param DoliDb $db Database handler
+ * @param DoliDb $db Database handler
*/
function __construct($db)
{
@@ -233,6 +254,7 @@ class AdvanceTargetingMailing extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Load object in memory from the database
*
@@ -241,6 +263,7 @@ class AdvanceTargetingMailing extends CommonObject
*/
function fetch_by_mailing($id=0)
{
+ // phpcs:enable
global $langs;
$sql = "SELECT";
$sql.= " t.rowid,";
@@ -298,6 +321,7 @@ class AdvanceTargetingMailing extends CommonObject
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Load object in memory from the database
*
@@ -307,6 +331,7 @@ class AdvanceTargetingMailing extends CommonObject
*/
function fetch_by_element($id=0, $type_element='mailing')
{
+ // phpcs:enable
global $langs;
$sql = "SELECT";
$sql.= " t.rowid,";
@@ -523,6 +548,7 @@ class AdvanceTargetingMailing extends CommonObject
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Load object in memory from database
*
@@ -531,6 +557,7 @@ class AdvanceTargetingMailing extends CommonObject
*/
function query_thirdparty($arrayquery)
{
+ // phpcs:enable
global $langs,$conf;
$sql = "SELECT";
@@ -621,16 +648,16 @@ class AdvanceTargetingMailing extends CommonObject
if (!empty($arrayquery['options_'.$key.'_max'])) {
$sqlwhere[]= " (te.".$key." >= ".$arrayquery['options_'.$key.'_max']." AND te.".$key." <= ".$arrayquery['options_'.$key.'_min'].")";
}
- } else if (($extrafields->attribute_type[$key] == 'date') ||
+ } elseif (($extrafields->attribute_type[$key] == 'date') ||
($extrafields->attribute_type[$key] == 'datetime')) {
if (!empty($arrayquery['options_'.$key.'_end_dt'])){
$sqlwhere[]= " (te.".$key." >= '".$this->db->idate($arrayquery['options_'.$key.'_st_dt'])."' AND te.".$key." <= '".$this->db->idate($arrayquery['options_'.$key.'_end_dt'])."')";
}
- }else if ($extrafields->attribute_type[$key] == 'boolean') {
+ } elseif ($extrafields->attribute_type[$key] == 'boolean') {
if ($arrayquery['options_'.$key]!=''){
$sqlwhere[]= " (te.".$key." = ".$arrayquery['options_'.$key].")";
}
- }else{
+ } else {
if (is_array($arrayquery['options_'.$key])) {
$sqlwhere[]= " (te.".$key." IN ('".implode("','",$arrayquery['options_'.$key])."'))";
} elseif (!empty($arrayquery['options_'.$key])) {
@@ -676,6 +703,7 @@ class AdvanceTargetingMailing extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Load object in memory from database
*
@@ -685,6 +713,7 @@ class AdvanceTargetingMailing extends CommonObject
*/
function query_contact($arrayquery, $withThirdpartyFilter = 0)
{
+ // phpcs:enable
global $langs,$conf;
$sql = "SELECT";
@@ -916,7 +945,8 @@ class AdvanceTargetingMailing extends CommonObject
* For exemple jean;joe;jim%%;!jimo;!jima%> will target all jean, joe, start with jim but not jimo and not everythnig taht start by jima
* @return string Sql to use for the where condition
*/
- public function transformToSQL($column_to_test,$criteria) {
+ public function transformToSQL($column_to_test,$criteria)
+ {
$return_sql_criteria = '(';
//This is a multiple value test
@@ -948,6 +978,4 @@ class AdvanceTargetingMailing extends CommonObject
return $return_sql_criteria;
}
-
-
-}
\ No newline at end of file
+}
diff --git a/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php b/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php
index 7408bb27d37..3fdcd6178b0 100644
--- a/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php
+++ b/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php
@@ -16,9 +16,9 @@
*/
/**
- * \file comm/mailing/class/html.formadvtragetemaling.class.php
+ * \file comm/mailing/class/html.formadvtargetemailing.class.php
* \ingroup mailing
- * \brief Fichier de la classe des fonctions predefinie de composants html advtargetemaling
+ * \brief Fichier de la classe des fonctions predefinies de composant html advtargetemailing
*/
/**
@@ -26,15 +26,23 @@
*/
class FormAdvTargetEmailing extends Form
{
- var $db;
- var $error;
+ /**
+ * @var DoliDB Database handler.
+ */
+ public $db;
+
+ /**
+ * @var string Error code (or message)
+ */
+ public $error='';
/**
* Constructor
*
* @param DoliDB $db handler
*/
- function __construct($db) {
+ function __construct($db)
+ {
global $langs;
$this->db = $db;
@@ -47,7 +55,8 @@ class FormAdvTargetEmailing extends Form
* @param string $htmlname select field
* @return string select field
*/
- function multiselectProspectionStatus($selected_array = array(), $htmlname = 'cust_prospect_status') {
+ function multiselectProspectionStatus($selected_array = array(), $htmlname = 'cust_prospect_status')
+ {
global $conf, $langs;
$options_array = array();
@@ -83,7 +92,8 @@ class FormAdvTargetEmailing extends Form
* @param array $selected_array or Code or Label of preselected country
* @return string HTML string with select
*/
- function multiselectCountry($htmlname = 'country_id', $selected_array=array()) {
+ function multiselectCountry($htmlname = 'country_id', $selected_array=array())
+ {
global $conf, $langs;
$langs->load("dict");
@@ -143,7 +153,8 @@ class FormAdvTargetEmailing extends Form
* @param User $user User action
* @return string combo list code
*/
- function multiselectselectSalesRepresentatives($htmlname, $selected_array, $user) {
+ function multiselectselectSalesRepresentatives($htmlname, $selected_array, $user)
+ {
global $conf;
@@ -184,7 +195,8 @@ class FormAdvTargetEmailing extends Form
* @param array $selected_array selected array
* @return string combo list code
*/
- function multiselectselectLanguage($htmlname='', $selected_array=array()) {
+ function multiselectselectLanguage($htmlname='', $selected_array=array())
+ {
global $conf,$langs;
@@ -330,7 +342,8 @@ class FormAdvTargetEmailing extends Form
* @param int $showempty show empty
* @return string HTML combo
*/
- function advMultiselectarray($htmlname, $options_array = array(), $selected_array = array(), $showempty = 0) {
+ function advMultiselectarray($htmlname, $options_array = array(), $selected_array = array(), $showempty = 0)
+ {
global $conf, $langs;
$form=new Form($this->db);
@@ -365,10 +378,10 @@ class FormAdvTargetEmailing extends Form
/**
* Return combo list of categories
*
- * @param string $htmlname Name of categorie
- * @param array $selected_array value selected
- * @param int $type type
- * @return string HTML combo
+ * @param string $htmlname Name of categorie
+ * @param array $selected_array Value selected
+ * @param int $type Type
+ * @return string HTML combo
*/
public function multiselectCategories($htmlname='',$selected_array = array(), $type=0)
{
@@ -417,7 +430,8 @@ class FormAdvTargetEmailing extends Form
* @param string $type_element Type element. Example: 'mailing'
* @return string HTML combo
*/
- public function selectAdvtargetemailingTemplate($htmlname='template_id', $selected=0, $showempty=0, $type_element='mailing') {
+ public function selectAdvtargetemailingTemplate($htmlname='template_id', $selected=0, $showempty=0, $type_element='mailing')
+ {
global $conf, $user, $langs;
$out = '';
@@ -460,4 +474,4 @@ class FormAdvTargetEmailing extends Form
$this->db->free ( $resql );
return $out;
}
-}
\ No newline at end of file
+}
diff --git a/htdocs/comm/mailing/class/mailing.class.php b/htdocs/comm/mailing/class/mailing.class.php
index 63fc0a2caab..7a0d758ae17 100644
--- a/htdocs/comm/mailing/class/mailing.class.php
+++ b/htdocs/comm/mailing/class/mailing.class.php
@@ -31,44 +31,55 @@ require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php';
*/
class Mailing extends CommonObject
{
+ /**
+ * @var string ID to identify managed object
+ */
public $element='mailing';
+
+ /**
+ * @var string Name of table without prefix where object is stored
+ */
public $table_element='mailing';
+
+ /**
+ * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
+ */
public $picto='email';
- var $titre;
- var $sujet;
- var $body;
- var $nbemail;
- var $bgcolor;
- var $bgimage;
+ public $titre;
+ public $sujet;
+ public $body;
+ public $nbemail;
+ public $bgcolor;
+ public $bgimage;
- var $statut; // Status 0=Draft, 1=Validated, 2=Sent partially, 3=Sent completely
+ public $statut; // Status 0=Draft, 1=Validated, 2=Sent partially, 3=Sent completely
- var $email_from;
- var $email_replyto;
- var $email_errorsto;
+ public $email_from;
+ public $email_replyto;
+ public $email_errorsto;
- var $joined_file1;
- var $joined_file2;
- var $joined_file3;
- var $joined_file4;
+ public $joined_file1;
+ public $joined_file2;
+ public $joined_file3;
+ public $joined_file4;
- var $user_creat;
- var $user_valid;
+ public $user_creat;
+ public $user_valid;
- var $date_creat;
- var $date_valid;
+ public $date_creat;
+ public $date_valid;
- var $extraparams=array();
+ public $extraparams=array();
public $statut_dest=array();
public $statuts=array();
- /**
+ /**
* Constructor
*
- * @param DoliDb $db Database handler
+ * @param DoliDb $db Database handler
*/
function __construct($db)
{
@@ -85,7 +96,6 @@ class Mailing extends CommonObject
$this->statut_dest[1] = 'MailingStatusSent';
$this->statut_dest[2] = 'MailingStatusRead';
$this->statut_dest[3] = 'MailingStatusReadAndUnsubscribe'; // Read but ask to not be contacted anymore
-
}
/**
@@ -432,6 +442,7 @@ class Mailing extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Delete targets emailing
*
@@ -439,6 +450,7 @@ class Mailing extends CommonObject
*/
function delete_targets()
{
+ // phpcs:enable
$sql = "DELETE FROM ".MAIN_DB_PREFIX."mailing_cibles";
$sql.= " WHERE fk_mailing = ".$this->id;
@@ -456,6 +468,7 @@ class Mailing extends CommonObject
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Change status of each recipient
*
@@ -464,6 +477,7 @@ class Mailing extends CommonObject
*/
function reset_targets_status($user)
{
+ // phpcs:enable
$sql = "UPDATE ".MAIN_DB_PREFIX."mailing_cibles";
$sql.= " SET statut = 0";
$sql.= " WHERE fk_mailing = ".$this->id;
@@ -527,6 +541,7 @@ class Mailing extends CommonObject
return $this->LibStatut($this->statut,$mode);
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Renvoi le libelle d'un statut donne
*
@@ -536,39 +551,36 @@ class Mailing extends CommonObject
*/
function LibStatut($statut,$mode=0)
{
+ // phpcs:enable
global $langs;
$langs->load('mails');
- if ($mode == 0)
+ if ($mode == 0 || $mode == 1)
{
return $langs->trans($this->statuts[$statut]);
}
- if ($mode == 1)
- {
- return $langs->trans($this->statuts[$statut]);
- }
- if ($mode == 2)
+ elseif ($mode == 2)
{
if ($statut == 0) return img_picto($langs->trans($this->statuts[$statut]),'statut0').' '.$langs->trans($this->statuts[$statut]);
if ($statut == 1) return img_picto($langs->trans($this->statuts[$statut]),'statut1').' '.$langs->trans($this->statuts[$statut]);
if ($statut == 2) return img_picto($langs->trans($this->statuts[$statut]),'statut3').' '.$langs->trans($this->statuts[$statut]);
if ($statut == 3) return img_picto($langs->trans($this->statuts[$statut]),'statut6').' '.$langs->trans($this->statuts[$statut]);
}
- if ($mode == 3)
+ elseif ($mode == 3)
{
if ($statut == 0) return img_picto($langs->trans($this->statuts[$statut]),'statut0');
if ($statut == 1) return img_picto($langs->trans($this->statuts[$statut]),'statut1');
if ($statut == 2) return img_picto($langs->trans($this->statuts[$statut]),'statut3');
if ($statut == 3) return img_picto($langs->trans($this->statuts[$statut]),'statut6');
}
- if ($mode == 4)
+ elseif ($mode == 4)
{
if ($statut == 0) return img_picto($langs->trans($this->statuts[$statut]),'statut0').' '.$langs->trans($this->statuts[$statut]);
if ($statut == 1) return img_picto($langs->trans($this->statuts[$statut]),'statut1').' '.$langs->trans($this->statuts[$statut]);
if ($statut == 2) return img_picto($langs->trans($this->statuts[$statut]),'statut3').' '.$langs->trans($this->statuts[$statut]);
if ($statut == 3) return img_picto($langs->trans($this->statuts[$statut]),'statut6').' '.$langs->trans($this->statuts[$statut]);
}
- if ($mode == 5)
+ elseif ($mode == 5)
{
if ($statut == 0) return $langs->trans($this->statuts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),'statut0');
if ($statut == 1) return $langs->trans($this->statuts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),'statut1');
@@ -596,39 +608,39 @@ class Mailing extends CommonObject
{
return $langs->trans('MailingStatusError');
}
- if ($mode == 1)
+ elseif ($mode == 1)
{
return $langs->trans('MailingStatusSent');
}
- if ($mode == 2)
+ elseif ($mode == 2)
{
if ($statut==-1) return $langs->trans("MailingStatusError").' '.img_error($desc);
if ($statut==1) return $langs->trans("MailingStatusSent").' '.img_picto($langs->trans("MailingStatusSent"),'statut6');
if ($statut==2) return $langs->trans("MailingStatusRead").' '.img_picto($langs->trans("MailingStatusRead"),'statut4');
if ($statut==3) return $langs->trans("MailingStatusNotContact").' '.img_picto($langs->trans("MailingStatusNotContact"),'statut3');
}
- if ($mode == 3)
+ elseif ($mode == 3)
{
if ($statut==-1) return $langs->trans("MailingStatusError").' '.img_error($desc);
if ($statut==1) return $langs->trans("MailingStatusSent").' '.img_picto($langs->trans("MailingStatusSent"),'statut6');
if ($statut==2) return $langs->trans("MailingStatusRead").' '.img_picto($langs->trans("MailingStatusRead"),'statut4');
if ($statut==3) return $langs->trans("MailingStatusNotContact").' '.img_picto($langs->trans("MailingStatusNotContact"),'statut3');
}
- if ($mode == 4)
+ elseif ($mode == 4)
{
if ($statut==-1) return $langs->trans("MailingStatusError").' '.img_error($desc);
if ($statut==1) return $langs->trans("MailingStatusSent").' '.img_picto($langs->trans("MailingStatusSent"),'statut6');
if ($statut==2) return $langs->trans("MailingStatusRead").' '.img_picto($langs->trans("MailingStatusRead"),'statut4');
if ($statut==3) return $langs->trans("MailingStatusNotContact").' '.img_picto($langs->trans("MailingStatusNotContact"),'statut3');
}
- if ($mode == 5)
+ elseif ($mode == 5)
{
if ($statut==-1) return $langs->trans("MailingStatusError").' '.img_error($desc);
if ($statut==1) return $langs->trans("MailingStatusSent").' '.img_picto($langs->trans("MailingStatusSent"),'statut6');
if ($statut==2) return $langs->trans("MailingStatusRead").' '.img_picto($langs->trans("MailingStatusRead"),'statut4');
if ($statut==3) return $langs->trans("MailingStatusNotContact").' '.img_picto($langs->trans("MailingStatusNotContact"),'statut3');
}
- if ($mode == 6)
+ elseif ($mode == 6)
{
if ($statut==-1) return $langs->trans("MailingStatusError").' '.img_error($desc);
if ($statut==1) return $langs->trans("MailingStatusSent").' '.img_picto($langs->trans("MailingStatusSent"),'statut6');
@@ -636,6 +648,4 @@ class Mailing extends CommonObject
if ($statut==3) return $langs->trans("MailingStatusNotContact").' '.img_picto($langs->trans("MailingStatusNotContact"),'statut3');
}
}
-
}
-
diff --git a/htdocs/comm/mailing/index.php b/htdocs/comm/mailing/index.php
index 17693a1a73c..9cd1e8546d0 100644
--- a/htdocs/comm/mailing/index.php
+++ b/htdocs/comm/mailing/index.php
@@ -210,7 +210,6 @@ if ($langs->file_exists("html/spam.html",0)) {
print '
';
}
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/comm/mailing/info.php b/htdocs/comm/mailing/info.php
index b4f2eaeb6f3..3c1e6e2cffa 100644
--- a/htdocs/comm/mailing/info.php
+++ b/htdocs/comm/mailing/info.php
@@ -75,5 +75,6 @@ if ($object->fetch($id) >= 0)
dol_fiche_end();
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/comm/mailing/list.php b/htdocs/comm/mailing/list.php
index 87a390d4006..5087698b9ab 100644
--- a/htdocs/comm/mailing/list.php
+++ b/htdocs/comm/mailing/list.php
@@ -224,6 +224,6 @@ else
dol_print_error($db);
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/comm/multiprix.php b/htdocs/comm/multiprix.php
index 1e8c5c82cf4..55f49c44cfd 100644
--- a/htdocs/comm/multiprix.php
+++ b/htdocs/comm/multiprix.php
@@ -45,7 +45,7 @@ if ($user->societe_id > 0)
if ($_POST["action"] == 'setpricelevel')
{
- $soc = New Societe($db);
+ $soc = new Societe($db);
$soc->fetch($id);
$soc->set_price_level($_POST["price_level"],$user);
@@ -177,5 +177,6 @@ if ($_socid > 0)
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php
index dfde7ce613f..30fa8d74a8d 100644
--- a/htdocs/comm/propal/card.php
+++ b/htdocs/comm/propal/card.php
@@ -1,17 +1,18 @@
+/* Copyright (C) 2001-2007 Rodolphe Quiedeville
* Copyright (C) 2004-2014 Laurent Destailleur
* Copyright (C) 2004 Eric Seigne
* Copyright (C) 2005 Marc Barilley / Ocebo
* Copyright (C) 2005-2012 Regis Houssin
* Copyright (C) 2006 Andre Cianfarani
* Copyright (C) 2010-2016 Juanjo Menent
- * Copyright (C) 2010-2015 Philippe Grand
+ * Copyright (C) 2010-2018 Philippe Grand
* Copyright (C) 2012-2013 Christophe Battarel
* Copyright (C) 2012 Cedric Salvador
* Copyright (C) 2013-2014 Florian Henry
* Copyright (C) 2014 Ferran Marcet
* Copyright (C) 2016 Marcos García
+ * 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
@@ -74,6 +75,7 @@ $originid = GETPOST('originid', 'int');
$confirm = GETPOST('confirm', 'alpha');
$lineid = GETPOST('lineid', 'int');
$contactid = GETPOST('contactid','int');
+$projectid = GETPOST('projectid','int');
// PDF
$hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0));
@@ -749,7 +751,7 @@ if (empty($reshook))
if ($res = $prodcomb->fetchByProductCombination2ValuePairs($idprod, $combinations)) {
$idprod = $res->fk_product_child;
} else {
- setEventMessage($langs->trans('ErrorProductCombinationNotFound'), 'errors');
+ setEventMessages($langs->trans('ErrorProductCombinationNotFound'), null, 'errors');
$error ++;
}
}
@@ -1389,7 +1391,7 @@ if ($action == 'create')
}
$objectsrc->fetch_thirdparty();
- $projectid = (! empty($objectsrc->fk_project) ? $objectsrc->fk_project : '');
+ $projectid = (! empty($objectsrc->fk_project) ? $objectsrc->fk_project : 0);
$ref_client = (! empty($objectsrc->ref_client) ? $objectsrc->ref_client : '');
$ref_int = (! empty($objectsrc->ref_int) ? $objectsrc->ref_int : '');
@@ -1494,7 +1496,7 @@ if ($action == 'create')
// Date
print '' . $langs->trans('Date') . ' ';
- $form->select_date('', '', '', '', '', "addprop", 1, 1);
+ print $form->selectDate('', '', '', '', '', "addprop", 1, 1);
print ' ';
// Validaty duration
@@ -1513,7 +1515,7 @@ if ($action == 'create')
// Bank Account
if (! empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL) && ! empty($conf->banque->enabled)) {
print '' . $langs->trans('BankAccount') . ' ';
- $form->select_comptes($fk_account, 'fk_account', 0, '', 1);
+ $form->select_comptes($soc->fk_account, 'fk_account', 0, '', 1);
print ' ';
}
@@ -1542,18 +1544,15 @@ if ($action == 'create')
$syear = date("Y", $tmpdte);
$smonth = date("m", $tmpdte);
$sday = date("d", $tmpdte);
- $form->select_date($syear."-".$smonth."-".$sday, 'date_livraison', '', '', '', "addprop");
+ print $form->selectDate($syear."-".$smonth."-".$sday, 'date_livraison', '', '', '', "addprop");
} else {
- $form->select_date(-1, 'date_livraison', '', '', '', "addprop", 1, 1);
+ print $form->selectDate(-1, 'date_livraison', '', '', '', "addprop", 1, 1);
}
print '';
// Project
if (! empty($conf->projet->enabled))
{
- $projectid = GETPOST('projectid')?GETPOST('projectid'):0;
- if ($origin == 'project') $projectid = ($originid ? $originid : 0);
-
$langs->load("projects");
print '';
print '' . $langs->trans("Project") . ' ';
@@ -1829,12 +1828,11 @@ if ($action == 'create')
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('ValidateProp'), $text, 'confirm_validate', '', 0, 1);
}
- if (! $formconfirm) {
- $parameters = array('lineid' => $lineid);
- $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
- if (empty($reshook)) $formconfirm.=$hookmanager->resPrint;
- elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint;
- }
+ // Call Hook formConfirm
+ $parameters = array('lineid' => $lineid);
+ $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
+ if (empty($reshook)) $formconfirm.=$hookmanager->resPrint;
+ elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint;
// Print form confirm
print $formconfirm;
@@ -1932,7 +1930,7 @@ if ($action == 'create')
print 'id . '" method="post">';
print '';
print '';
- $form->select_date($object->date, 're', '', '', 0, "editdate");
+ print $form->selectDate($object->date, 're', '', '', 0, "editdate");
print '';
print ' ';
} else {
@@ -1958,7 +1956,7 @@ if ($action == 'create')
print 'id . '" method="post">';
print '';
print '';
- $form->select_date($object->fin_validite, 'ech', '', '', '', "editecheance");
+ print $form->selectDate($object->fin_validite, 'ech', '', '', '', "editecheance");
print '';
print ' ';
} else {
diff --git a/htdocs/comm/propal/class/api_proposals.class.php b/htdocs/comm/propal/class/api_proposals.class.php
index 39857d88365..fc721912462 100644
--- a/htdocs/comm/propal/class/api_proposals.class.php
+++ b/htdocs/comm/propal/class/api_proposals.class.php
@@ -97,7 +97,8 @@ class Proposals extends DolibarrApi
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.datec:<:'20160101')"
* @return array Array of order objects
*/
- function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '') {
+ function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '')
+ {
global $db, $conf;
$obj_ret = array();
@@ -215,7 +216,8 @@ class Proposals extends DolibarrApi
*
* @return int
*/
- function getLines($id) {
+ function getLines($id)
+ {
if(! DolibarrApiAccess::$user->rights->propal->lire) {
throw new RestException(401);
}
@@ -381,7 +383,8 @@ class Proposals extends DolibarrApi
* @throws 401
* @throws 404
*/
- function deleteLine($id, $lineid) {
+ function deleteLine($id, $lineid)
+ {
if(! DolibarrApiAccess::$user->rights->propal->creer) {
throw new RestException(401);
}
@@ -415,7 +418,8 @@ class Proposals extends DolibarrApi
*
* @return int
*/
- function put($id, $request_data = null) {
+ function put($id, $request_data = null)
+ {
if(! DolibarrApiAccess::$user->rights->propal->creer) {
throw new RestException(401);
}
@@ -487,7 +491,6 @@ class Proposals extends DolibarrApi
'message' => 'Commercial Proposal deleted'
)
);
-
}
/**
@@ -703,23 +706,24 @@ class Proposals extends DolibarrApi
}
- /**
- * Clean sensible object datas
- *
- * @param object $object Object to clean
- * @return array Array of cleaned object properties
- */
- function _cleanObjectDatas($object) {
+ /**
+ * Clean sensible object datas
+ *
+ * @param object $object Object to clean
+ * @return array Array of cleaned object properties
+ */
+ function _cleanObjectDatas($object)
+ {
- $object = parent::_cleanObjectDatas($object);
+ $object = parent::_cleanObjectDatas($object);
- unset($object->note);
- unset($object->name);
- unset($object->lastname);
- unset($object->firstname);
- unset($object->civility_id);
- unset($object->address);
+ unset($object->note);
+ unset($object->name);
+ unset($object->lastname);
+ unset($object->firstname);
+ unset($object->civility_id);
+ unset($object->address);
- return $object;
- }
+ return $object;
+ }
}
diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php
index 562032de9fa..45e139c0b4f 100644
--- a/htdocs/comm/propal/class/propal.class.php
+++ b/htdocs/comm/propal/class/propal.class.php
@@ -45,16 +45,37 @@ require_once DOL_DOCUMENT_ROOT .'/multicurrency/class/multicurrency.class.php';
*/
class Propal extends CommonObject
{
+ /**
+ * @var string ID to identify managed object
+ */
public $element='propal';
+
+ /**
+ * @var string Name of table without prefix where object is stored
+ */
public $table_element='propal';
+
+ /**
+ * @var int Name of subtable line
+ */
public $table_element_line='propaldet';
- public $fk_element='fk_propal';
+
+ /**
+ * @var int Field with ID of parent key if this field has a parent
+ */
+ public $fk_element ='fk_propal';
+
+ /**
+ * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
+ */
public $picto='propal';
+
/**
* 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
* @var int
*/
public $ismultientitymanaged = 1;
+
/**
* 0=Default, 1=View may be restricted to sales representative only if no permission to see all or to company of external user if external user
* @var integer
@@ -222,9 +243,10 @@ class Propal extends CommonObject
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
- * Add line into array products
- * $this->thirdparty should be loaded
+ * Add line into array products
+ * $this->thirdparty should be loaded
*
* @param int $idproduct Product Id to add
* @param int $qty Quantity
@@ -236,6 +258,7 @@ class Propal extends CommonObject
*/
function add_product($idproduct, $qty, $remise_percent=0)
{
+ // phpcs:enable
global $conf, $mysoc;
if (! $qty) $qty = 1;
@@ -282,6 +305,7 @@ class Propal extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Adding line of fixed discount in the proposal in DB
*
@@ -290,6 +314,7 @@ class Propal extends CommonObject
*/
function insert_discount($idremise)
{
+ // phpcs:enable
global $langs;
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
@@ -1160,6 +1185,7 @@ class Propal extends CommonObject
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Insert into DB a proposal object completely defined by its data members (ex, results from copy).
*
@@ -1169,6 +1195,7 @@ class Propal extends CommonObject
*/
function create_from($user)
{
+ // phpcs:enable
// i love this function because $this->products is not used in create function...
$this->products=$this->lines;
@@ -1322,6 +1349,7 @@ class Propal extends CommonObject
$sql.= ", p.fk_shipping_method";
$sql.= ", p.fk_incoterms, p.location_incoterms";
$sql.= ", p.fk_multicurrency, p.multicurrency_code, p.multicurrency_tx, p.multicurrency_total_ht, p.multicurrency_total_tva, p.multicurrency_total_ttc";
+ $sql.= ", p.tms as date_modification";
$sql.= ", i.libelle as libelle_incoterms";
$sql.= ", c.label as statut_label";
$sql.= ", ca.code as availability_code, ca.label as availability";
@@ -1335,13 +1363,12 @@ class Propal extends CommonObject
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_availability as ca ON p.fk_availability = ca.rowid';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_input_reason as dr ON p.fk_input_reason = dr.rowid';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON p.fk_incoterms = i.rowid';
- $sql.= " WHERE p.fk_statut = c.id";
if ($ref) {
- $sql.= " AND p.entity IN (".getEntity('propal').")"; // Dont't use entity if you use rowid
- $sql.= " AND p.ref='".$ref."'";
+ $sql.= " WHERE p.entity IN (".getEntity('propal').")"; // Dont't use entity if you use rowid
+ $sql.= " AND p.ref='".$this->db->escape($ref)."'";
}
- else $sql.= " AND p.rowid=".$rowid;
+ else $sql.= " WHERE p.rowid=".$rowid;
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
$resql=$this->db->query($sql);
@@ -1379,6 +1406,7 @@ class Propal 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_modification = $this->db->jdate($obj->date_modification); // tms
$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);
@@ -1464,6 +1492,8 @@ class Propal extends CommonObject
*/
function update(User $user, $notrigger=0)
{
+ global $conf;
+
$error=0;
// Clean parameters
@@ -1512,17 +1542,23 @@ class Propal extends CommonObject
$error++; $this->errors[]="Error ".$this->db->lasterror();
}
- if (! $error)
+ if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options)>0)
{
- if (! $notrigger)
+ $result=$this->insertExtraFields();
+ if ($result < 0)
{
- // Call trigger
- $result=$this->call_trigger('PROPAL_MODIFY', $user);
- if ($result < 0) $error++;
- // End call triggers
+ $error++;
}
}
+ if (! $error && ! $notrigger)
+ {
+ // Call trigger
+ $result=$this->call_trigger('PROPAL_MODIFY', $user);
+ if ($result < 0) $error++;
+ // End call triggers
+ }
+
// Commit or rollback
if ($error)
{
@@ -1542,6 +1578,7 @@ class Propal extends CommonObject
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Load array lines
*
@@ -1550,15 +1587,16 @@ class Propal extends CommonObject
*/
function fetch_lines($only_product=0)
{
+ // phpcs:enable
$this->lines=array();
$sql = 'SELECT d.rowid, d.fk_propal, d.fk_parent_line, d.label as custom_label, d.description, d.price, d.vat_src_code, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.localtax1_type, d.localtax2_type, d.qty, d.fk_remise_except, d.remise_percent, d.subprice, d.fk_product,';
$sql.= ' d.info_bits, d.total_ht, d.total_tva, d.total_localtax1, d.total_localtax2, d.total_ttc, d.fk_product_fournisseur_price as fk_fournprice, d.buy_price_ht as pa_ht, d.special_code, d.rang, d.product_type,';
$sql.= ' d.fk_unit,';
- $sql.= ' p.ref as product_ref, p.description as product_desc, p.fk_product_type, p.label as product_label,';
+ $sql.= ' p.ref as product_ref, p.description as product_desc, p.fk_product_type, p.label as product_label, p.tobatch as product_batch,';
$sql.= ' p.weight, p.weight_units, p.volume, p.volume_units,';
- $sql.= ' d.date_start, d.date_end';
- $sql.= ' ,d.fk_multicurrency, d.multicurrency_code, d.multicurrency_subprice, d.multicurrency_total_ht, d.multicurrency_total_tva, d.multicurrency_total_ttc';
+ $sql.= ' d.date_start, d.date_end,';
+ $sql.= ' d.fk_multicurrency, d.multicurrency_code, d.multicurrency_subprice, d.multicurrency_total_ht, d.multicurrency_total_tva, d.multicurrency_total_ttc';
$sql.= ' FROM '.MAIN_DB_PREFIX.'propaldet as d';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON (d.fk_product = p.rowid)';
$sql.= ' WHERE d.fk_propal = '.$this->id;
@@ -1620,7 +1658,8 @@ class Propal extends CommonObject
$line->libelle = $objp->product_label; // TODO deprecated
$line->product_label = $objp->product_label;
$line->product_desc = $objp->product_desc; // Description produit
- $line->fk_product_type = $objp->fk_product_type;
+ $line->product_tobatch = $objp->product_tobatch;
+ $line->fk_product_type = $objp->fk_product_type; // TODO deprecated
$line->fk_unit = $objp->fk_unit;
$line->weight = $objp->weight;
$line->weight_units = $objp->weight_units;
@@ -1779,6 +1818,7 @@ class Propal extends CommonObject
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Define proposal date
*
@@ -1789,6 +1829,7 @@ class Propal extends CommonObject
*/
function set_date($user, $date, $notrigger=0)
{
+ // phpcs:enable
if (empty($date))
{
$this->error='ErrorBadParameter';
@@ -1846,6 +1887,7 @@ class Propal extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Define end validity date
*
@@ -1856,6 +1898,7 @@ class Propal extends CommonObject
*/
function set_echeance($user, $date_fin_validite, $notrigger=0)
{
+ // phpcs:enable
if (! empty($user->rights->propal->creer))
{
$error=0;
@@ -1906,6 +1949,7 @@ class Propal extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Set delivery date
*
@@ -1916,6 +1960,7 @@ class Propal extends CommonObject
*/
function set_date_livraison($user, $date_livraison, $notrigger=0)
{
+ // phpcs:enable
if (! empty($user->rights->propal->creer))
{
$error=0;
@@ -1966,6 +2011,7 @@ class Propal extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Set delivery
*
@@ -1976,6 +2022,7 @@ class Propal extends CommonObject
*/
function set_availability($user, $id, $notrigger=0)
{
+ // phpcs:enable
if (! empty($user->rights->propal->creer) && $this->statut >= self::STATUS_DRAFT)
{
$error=0;
@@ -2035,6 +2082,7 @@ class Propal extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Set source of demand
*
@@ -2045,6 +2093,7 @@ class Propal extends CommonObject
*/
function set_demand_reason($user, $id, $notrigger=0)
{
+ // phpcs:enable
if (! empty($user->rights->propal->creer) && $this->statut >= self::STATUS_DRAFT)
{
$error=0;
@@ -2106,6 +2155,7 @@ class Propal extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Set customer reference number
*
@@ -2116,6 +2166,7 @@ class Propal extends CommonObject
*/
function set_ref_client($user, $ref_client, $notrigger=0)
{
+ // phpcs:enable
if (! empty($user->rights->propal->creer))
{
$error=0;
@@ -2169,6 +2220,7 @@ class Propal extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Set an overall discount on the proposal
*
@@ -2179,6 +2231,7 @@ class Propal extends CommonObject
*/
function set_remise_percent($user, $remise, $notrigger=0)
{
+ // phpcs:enable
$remise=trim($remise)?trim($remise):0;
if (! empty($user->rights->propal->creer))
@@ -2234,6 +2287,7 @@ class Propal extends CommonObject
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Set an absolute overall discount on the proposal
*
@@ -2244,6 +2298,7 @@ class Propal extends CommonObject
*/
function set_remise_absolue($user, $remise, $notrigger=0)
{
+ // phpcs:enable
$remise=trim($remise)?trim($remise):0;
if (! empty($user->rights->propal->creer))
@@ -2518,6 +2573,7 @@ class Propal extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Set draft status
*
@@ -2527,6 +2583,7 @@ class Propal extends CommonObject
*/
function set_draft($user, $notrigger=0)
{
+ // phpcs:enable
$error=0;
$this->db->begin();
@@ -2575,6 +2632,7 @@ class Propal extends CommonObject
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Return list of proposal (eventually filtered on user) into an array
*
@@ -2590,6 +2648,7 @@ class Propal extends CommonObject
*/
function liste_array($shortlist=0, $draft=0, $notcurrentuser=0, $socid=0, $limit=0, $offset=0, $sortfield='p.datep', $sortorder='DESC')
{
+ // phpcs:enable
global $user;
$ga = array();
@@ -2661,6 +2720,7 @@ class Propal extends CommonObject
return $this->InvoiceArrayList($this->id);
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Returns an array with id and ref of related invoices
*
@@ -2669,6 +2729,7 @@ class Propal extends CommonObject
*/
function InvoiceArrayList($id)
{
+ // phpcs:enable
$ga = array();
$linkedInvoices = array();
@@ -2939,6 +3000,7 @@ class Propal extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Change source demand
*
@@ -2949,6 +3011,7 @@ class Propal extends CommonObject
*/
function demand_reason($demand_reason_id, $notrigger=0)
{
+ // phpcs:enable
global $user;
if ($this->statut >= self::STATUS_DRAFT)
@@ -3079,6 +3142,7 @@ class Propal extends CommonObject
return $this->LibStatut($this->statut, $mode);
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Return label of a status (draft, validated, ...)
*
@@ -3088,6 +3152,7 @@ class Propal extends CommonObject
*/
function LibStatut($statut,$mode=1)
{
+ // phpcs:enable
global $conf;
// Init/load array of translation of status
@@ -3121,9 +3186,10 @@ class Propal extends CommonObject
if ($mode == 4) return img_picto($this->labelstatut[$statut],$statuttrans).' '.$this->labelstatut[$statut];
if ($mode == 5) return ''.$this->labelstatut_short[$statut].' '.img_picto($this->labelstatut[$statut],$statuttrans);
if ($mode == 6) return ''.$this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut],$statuttrans);
- }
+ }
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Load indicators for dashboard (this->nbtodo and this->nbtodolate)
*
@@ -3133,11 +3199,12 @@ class Propal extends CommonObject
*/
function load_board($user,$mode)
{
+ // phpcs:enable
global $conf, $langs;
$clause = " WHERE";
- $sql = "SELECT p.rowid, p.ref, p.datec as datec, p.fin_validite as datefin";
+ $sql = "SELECT p.rowid, p.ref, p.datec as datec, p.fin_validite as datefin, p.total_ht";
$sql.= " FROM ".MAIN_DB_PREFIX."propal as p";
if (!$user->rights->societe->client->voir && !$user->societe_id)
{
@@ -3181,6 +3248,8 @@ class Propal extends CommonObject
while ($obj=$this->db->fetch_object($resql))
{
$response->nbtodo++;
+ $response->total+=$obj->total_ht;
+
if ($mode == 'opened')
{
$datelimit = $this->db->jdate($obj->datefin);
@@ -3296,6 +3365,7 @@ class Propal extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Charge indicateurs this->nb de tableau de bord
*
@@ -3303,6 +3373,7 @@ class Propal extends CommonObject
*/
function load_state_board()
{
+ // phpcs:enable
global $user;
$this->nb=array();
@@ -3490,8 +3561,8 @@ class Propal extends CommonObject
*/
function getLinesArray()
{
- // TODO Duplicate with fetch_lines ? Wich one to keep ?
-
+ return $this->fetch_lines();
+ /*
$this->lines = array();
$sql = 'SELECT pt.rowid, pt.label as custom_label, pt.description, pt.fk_product, pt.fk_remise_except,';
@@ -3580,7 +3651,7 @@ class Propal extends CommonObject
{
$this->error=$this->db->error();
return -1;
- }
+ }*/
}
/**
@@ -3640,7 +3711,14 @@ class Propal extends CommonObject
*/
class PropaleLigne extends CommonObjectLine
{
+ /**
+ * @var string ID to identify managed object
+ */
public $element='propaldet';
+
+ /**
+ * @var string Name of table without prefix where object is stored
+ */
public $table_element='propaldet';
var $oldline;
@@ -3930,7 +4008,7 @@ class PropaleLigne extends CommonObjectLine
$sql.= " ".price2num($this->localtax2_tx).",";
$sql.= " '".$this->db->escape($this->localtax1_type)."',";
$sql.= " '".$this->db->escape($this->localtax2_type)."',";
- $sql.= " ".($this->subprice?price2num($this->subprice):"null").",";
+ $sql.= " ".(price2num($this->subprice)!==''?price2num($this->subprice):"null").",";
$sql.= " ".price2num($this->remise_percent).",";
$sql.= " ".(isset($this->info_bits)?"'".$this->db->escape($this->info_bits)."'":"null").",";
$sql.= " ".price2num($this->total_ht).",";
@@ -4175,14 +4253,16 @@ class PropaleLigne extends CommonObjectLine
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Update DB line fields total_xxx
* Used by migration
*
- * @return int <0 if ko, >0 if ok
+ * @return int <0 if KO, >0 if OK
*/
function update_total()
{
+ // phpcs:enable
$this->db->begin();
// Mise a jour ligne en base
@@ -4207,6 +4287,4 @@ class PropaleLigne extends CommonObjectLine
return -2;
}
}
-
}
-
diff --git a/htdocs/comm/propal/class/propalestats.class.php b/htdocs/comm/propal/class/propalestats.class.php
index d6e9ee3b103..bb4e0ab56f4 100644
--- a/htdocs/comm/propal/class/propalestats.class.php
+++ b/htdocs/comm/propal/class/propalestats.class.php
@@ -35,7 +35,10 @@ include_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
*/
class PropaleStats extends Stats
{
- public $table_element;
+ /**
+ * @var string Name of table without prefix where object is stored
+ */
+ public $table_element;
var $socid;
var $userid;
diff --git a/htdocs/comm/propal/contact.php b/htdocs/comm/propal/contact.php
index 5e21f493c64..4e017ff13d9 100644
--- a/htdocs/comm/propal/contact.php
+++ b/htdocs/comm/propal/contact.php
@@ -212,6 +212,6 @@ if ($object->id > 0)
}
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/comm/propal/document.php b/htdocs/comm/propal/document.php
index 1c8d494214d..cbdfd44383c 100644
--- a/htdocs/comm/propal/document.php
+++ b/htdocs/comm/propal/document.php
@@ -94,7 +94,7 @@ if ($object->id > 0)
$head = propal_prepare_head($object);
dol_fiche_head($head, 'document', $langs->trans('Proposal'), -1, 'propal');
- // Construit liste des fichiers
+ // Build file list
$filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
$totalsize=0;
foreach($filearray as $key => $file)
@@ -179,5 +179,6 @@ else
print $langs->trans("ErrorUnknown");
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/comm/propal/index.php b/htdocs/comm/propal/index.php
index 0dbe2fb855e..b47a4506412 100644
--- a/htdocs/comm/propal/index.php
+++ b/htdocs/comm/propal/index.php
@@ -530,7 +530,6 @@ if (! empty($conf->propal->enabled))
//print ' ';
print ' ';
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/comm/propal/info.php b/htdocs/comm/propal/info.php
index 317c9902d52..7879612b099 100644
--- a/htdocs/comm/propal/info.php
+++ b/htdocs/comm/propal/info.php
@@ -127,5 +127,6 @@ print '';
dol_fiche_end();
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php
index 1a23c0b8728..dc6e4aff17b 100644
--- a/htdocs/comm/propal/list.php
+++ b/htdocs/comm/propal/list.php
@@ -78,13 +78,15 @@ $search_day=GETPOST("search_day","int");
$search_month=GETPOST("search_month","int");
$search_year=GETPOST("search_year","int");
$search_dayfin=GETPOST("search_dayfin","int");
-$search_monthfin=GETPOST("search_monthfin","int");
+$search_month_end=GETPOST("search_month_end","int");
$search_yearfin=GETPOST("search_yearfin","int");
$search_daydelivery=GETPOST("search_daydelivery","int");
$search_monthdelivery=GETPOST("search_monthdelivery","int");
$search_yeardelivery=GETPOST("search_yeardelivery","int");
$search_availability=GETPOST('search_availability','int');
$search_categ_cus=trim(GETPOST("search_categ_cus",'int'));
+$search_btn=GETPOST('button_search','alpha');
+$search_remove_btn=GETPOST('button_removefilter','alpha');
$viewstatut=GETPOST('viewstatut','alpha');
$optioncss = GETPOST('optioncss','alpha');
@@ -98,7 +100,7 @@ $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');
-if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
+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
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
@@ -159,6 +161,7 @@ $arrayfields=array(
'p.total_vat'=>array('label'=>$langs->trans("AmountVAT"), 'checked'=>0),
'p.total_ttc'=>array('label'=>$langs->trans("AmountTTC"), 'checked'=>0),
'u.login'=>array('label'=>$langs->trans("Author"), 'checked'=>1, 'position'=>10),
+ 'sale_representative'=>array('label'=>$langs->trans("SaleRepresentativesOfThirdParty"), 'checked'=>1),
'p.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500),
'p.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500),
'p.fk_statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000),
@@ -213,7 +216,7 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x',
$search_month='';
$search_day='';
$search_yearfin='';
- $search_monthfin='';
+ $search_month_end='';
$search_dayfin='';
$search_yeardelivery='';
$search_monthdelivery='';
@@ -310,7 +313,7 @@ if ($search_country) $sql .= " AND s.fk_pays IN (".$db->escape($search_country).
if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$db->escape($search_type_thirdparty).')';
if ($search_ref) $sql .= natural_search('p.ref', $search_ref);
if ($search_refcustomer) $sql .= natural_search('p.ref_client', $search_refcustomer);
-if ($search_refproject) $sql .= natural_search('pr.ref', $search_refprojet);
+if ($search_refproject) $sql .= natural_search('pr.ref', $search_refproject);
if ($search_availability) $sql .= " AND p.fk_availability IN (".$db->escape($search_availability).')';
if ($search_societe) $sql .= natural_search('s.nom', $search_societe);
@@ -343,14 +346,14 @@ else if ($search_year > 0)
{
$sql.= " AND p.datep BETWEEN '".$db->idate(dol_get_first_day($search_year,1,false))."' AND '".$db->idate(dol_get_last_day($search_year,12,false))."'";
}
-if ($search_monthfin > 0)
+if ($search_month_end > 0)
{
if ($search_yearfin > 0 && empty($search_dayfin))
- $sql.= " AND p.fin_validite BETWEEN '".$db->idate(dol_get_first_day($search_yearfin,$search_monthfin,false))."' AND '".$db->idate(dol_get_last_day($search_yearfin,$search_monthfin,false))."'";
+ $sql.= " AND p.fin_validite BETWEEN '".$db->idate(dol_get_first_day($search_yearfin,$search_month_end,false))."' AND '".$db->idate(dol_get_last_day($search_yearfin,$search_month_end,false))."'";
else if ($search_yearfin > 0 && ! empty($search_dayfin))
- $sql.= " AND p.fin_validite BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $search_monthfin, $search_dayfin, $search_yearfin))."' AND '".$db->idate(dol_mktime(23, 59, 59, $search_monthfin, $search_dayfin, $search_yearfin))."'";
+ $sql.= " AND p.fin_validite BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $search_month_end, $search_dayfin, $search_yearfin))."' AND '".$db->idate(dol_mktime(23, 59, 59, $search_month_end, $search_dayfin, $search_yearfin))."'";
else
- $sql.= " AND date_format(p.fin_validite, '%m') = '".$db->escape($search_monthfin)."'";
+ $sql.= " AND date_format(p.fin_validite, '%m') = '".$db->escape($search_month_end)."'";
}
else if ($search_yearfin > 0)
{
@@ -432,7 +435,7 @@ if ($resql)
if ($search_year) $param.='&search_year='.urlencode($search_year);
if ($search_ref) $param.='&search_ref='.urlencode($search_ref);
if ($search_refcustomer) $param.='&search_refcustomer='.urlencode($search_refcustomer);
- if ($search_refprojet) $param.='&search_refprojet='.urlencode($search_refprojet);
+ if ($search_refproject) $param.='&search_refproject='.urlencode($search_refproject);
if ($search_societe) $param.='&search_societe='.urlencode($search_societe);
if ($search_user > 0) $param.='&search_user='.urlencode($search_user);
if ($search_sale > 0) $param.='&search_sale='.urlencode($search_sale);
@@ -615,7 +618,7 @@ if ($resql)
print '';
//print $langs->trans('Month').': ';
if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '';
- print '';
+ print '';
//print ' '.$langs->trans('Year').': ';
$formother->select_year($search_yearfin,'search_yearfin',1, 20, 5);
print ' ';
@@ -667,6 +670,10 @@ if ($resql)
print '';
print '';
}
+ if (! empty($arrayfields['sale_representative']['checked']))
+ {
+ print ' ';
+ }
// Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
@@ -721,6 +728,7 @@ if ($resql)
if (! empty($arrayfields['p.total_vat']['checked'])) print_liste_field_titre($arrayfields['p.total_vat']['label'],$_SERVER["PHP_SELF"],'p.tva','',$param, 'align="right"',$sortfield,$sortorder);
if (! empty($arrayfields['p.total_ttc']['checked'])) print_liste_field_titre($arrayfields['p.total_ttc']['label'],$_SERVER["PHP_SELF"],'p.total','',$param, 'align="right"',$sortfield,$sortorder);
if (! empty($arrayfields['u.login']['checked'])) print_liste_field_titre($arrayfields['u.login']['label'],$_SERVER["PHP_SELF"],'u.login','',$param,'align="center"',$sortfield,$sortorder);
+ if (! empty($arrayfields['sale_representative']['checked'])) print_liste_field_titre($arrayfields['sale_representative']['label'], $_SERVER["PHP_SELF"], "","","$param",'',$sortfield,$sortorder);
// Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
// Hook fields
@@ -943,6 +951,51 @@ if ($resql)
if (! $i) $totalarray['nbfield']++;
}
+ if (! empty($arrayfields['sale_representative']['checked']))
+ {
+ // Sales representatives
+ print '';
+ if ($obj->socid > 0)
+ {
+ $listsalesrepresentatives=$companystatic->getSalesRepresentatives($user);
+ if ($listsalesrepresentatives < 0) dol_print_error($db);
+ $nbofsalesrepresentative=count($listsalesrepresentatives);
+ if ($nbofsalesrepresentative > 3) // We print only number
+ {
+ print '';
+ print $nbofsalesrepresentative;
+ print '';
+ }
+ else if ($nbofsalesrepresentative > 0)
+ {
+ $userstatic=new User($db);
+ $j=0;
+ foreach($listsalesrepresentatives as $val)
+ {
+ $userstatic->id=$val['id'];
+ $userstatic->lastname=$val['lastname'];
+ $userstatic->firstname=$val['firstname'];
+ $userstatic->email=$val['email'];
+ $userstatic->statut=$val['statut'];
+ $userstatic->entity=$val['entity'];
+ $userstatic->photo=$val['photo'];
+
+ //print '':
+ print $userstatic->getNomUrl(-2);
+ $j++;
+ if ($j < $nbofsalesrepresentative) print ' ';
+ //print '';
+ }
+ }
+ //else print $langs->trans("NoSalesRepresentativeAffected");
+ }
+ else
+ {
+ print ' ';
+ }
+ print ' ';
+ }
+
// Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
// Fields from hook
@@ -988,27 +1041,40 @@ if ($resql)
}
// Show total line
- if (isset($totalarray['totalhtfield'])
+ if (isset($totalarray['totalhtfield'])
|| isset($totalarray['totalvatfield'])
|| isset($totalarray['totalttcfield'])
|| isset($totalarray['totalamfield'])
|| isset($totalarray['totalrtpfield'])
+ || isset($totalarray['totalizable'])
)
{
print '';
$i=0;
while ($i < $totalarray['nbfield'])
{
- $i++;
- if ($i == 1)
- {
+ $i++;
+ if ($i == 1)
+ {
if ($num < $limit && empty($offset)) print ''.$langs->trans("Total").' ';
else print ''.$langs->trans("Totalforthispage").' ';
- }
- elseif ($totalarray['totalhtfield'] == $i) print ''.price($totalarray['totalht']).' ';
- elseif ($totalarray['totalvatfield'] == $i) print ''.price($totalarray['totalvat']).' ';
- elseif ($totalarray['totalttcfield'] == $i) print ''.price($totalarray['totalttc']).' ';
- else print ' ';
+ }
+ elseif ($totalarray['totalhtfield'] == $i) print ''.price($totalarray['totalht']).' ';
+ elseif ($totalarray['totalvatfield'] == $i) print ''.price($totalarray['totalvat']).' ';
+ elseif ($totalarray['totalttcfield'] == $i) print ''.price($totalarray['totalttc']).' ';
+ elseif ($totalarray['totalizable']) {
+ $printed = false;
+ foreach ($totalarray['totalizable'] as $totalizable) {
+ if ($totalizable['pos']==$i && ! $printed) {
+ print ''.price($totalizable['total']).' ';
+ $printed = true;
+ }
+ }
+ if (! $printed) {
+ print ' ';
+ }
+ }
+ else print ' ';
}
print ' ';
}
diff --git a/htdocs/comm/propal/note.php b/htdocs/comm/propal/note.php
index 607cff245d9..a346f8df18f 100644
--- a/htdocs/comm/propal/note.php
+++ b/htdocs/comm/propal/note.php
@@ -144,6 +144,6 @@ if ($id > 0 || ! empty($ref))
}
}
-
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/comm/propal/stats/index.php b/htdocs/comm/propal/stats/index.php
index ac6b42c45d8..00db6264377 100644
--- a/htdocs/comm/propal/stats/index.php
+++ b/htdocs/comm/propal/stats/index.php
@@ -344,7 +344,6 @@ print '';
dol_fiche_end();
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php b/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php
index cd49ca863e6..724e0bcce15 100644
--- a/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php
+++ b/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php
@@ -57,7 +57,7 @@ foreach($linkedObjectBlock as $key => $objectlink)
global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES)
{
$url = DOL_URL_ROOT.'/comm/propal/card.php?id='.$objectlink->id;
- print ' ';
+ print ' ';
}
?>
diff --git a/htdocs/comm/prospect/index.php b/htdocs/comm/prospect/index.php
index 2273012696f..6d7e93af4be 100644
--- a/htdocs/comm/prospect/index.php
+++ b/htdocs/comm/prospect/index.php
@@ -275,6 +275,6 @@ if ($resql)
//print '';
print '';
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/comm/prospect/recap-prospect.php b/htdocs/comm/prospect/recap-prospect.php
index 50127d719c8..93cfada8860 100644
--- a/htdocs/comm/prospect/recap-prospect.php
+++ b/htdocs/comm/prospect/recap-prospect.php
@@ -89,5 +89,6 @@ else
dol_print_error($db);
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/comm/recap-client.php b/htdocs/comm/recap-client.php
index 6cd41c6c658..86c1bad0521 100644
--- a/htdocs/comm/recap-client.php
+++ b/htdocs/comm/recap-client.php
@@ -89,5 +89,6 @@ else
dol_print_error($db);
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/comm/remise.php b/htdocs/comm/remise.php
index 6f3287b8831..f045e570c6e 100644
--- a/htdocs/comm/remise.php
+++ b/htdocs/comm/remise.php
@@ -129,8 +129,9 @@ if ($socid > 0)
print '';
- llxFooter();
- $db->close();
+ // End of page
+ llxFooter();
+ $db->close();
exit;
}
@@ -324,5 +325,6 @@ if ($socid > 0)
}
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/comm/remx.php b/htdocs/comm/remx.php
index 3eec109e6b3..78e4643d5e3 100644
--- a/htdocs/comm/remx.php
+++ b/htdocs/comm/remx.php
@@ -998,5 +998,6 @@ if ($socid > 0)
}
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php
index 0fe49cf9f12..0dd266ef186 100644
--- a/htdocs/commande/card.php
+++ b/htdocs/commande/card.php
@@ -5,13 +5,14 @@
* Copyright (C) 2005-2015 Regis Houssin
* Copyright (C) 2006 Andre Cianfarani
* Copyright (C) 2010-2013 Juanjo Menent
- * Copyright (C) 2011-2016 Philippe Grand
+ * Copyright (C) 2011-2018 Philippe Grand
* Copyright (C) 2012-2013 Christophe Battarel
* Copyright (C) 2012-2016 Marcos García
* Copyright (C) 2012 Cedric Salvador
* Copyright (C) 2013 Florian Henry
* Copyright (C) 2014 Ferran Marcet
* Copyright (C) 2015 Jean-François Ferry
+ * 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
@@ -679,7 +680,7 @@ if (empty($reshook))
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), null, 'errors');
$error++;
}
- if ($prod_entry_mode == 'free' && empty($idprod) && (! ($price_ht >= 0) || $price_ht == '') && (! ($price_ht_devise >= 0) || $price_ht_devise == '')) // Unit price can be 0 but not ''
+ if ($prod_entry_mode == 'free' && empty($idprod) && $price_ht == '' && $price_ht_devise == '') // Unit price can be 0 but not ''. Also price can be negative for order.
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), null, 'errors');
$error++;
@@ -700,8 +701,10 @@ if (empty($reshook))
if ($res = $prodcomb->fetchByProductCombination2ValuePairs($idprod, $combinations)) {
$idprod = $res->fk_product_child;
- } else {
- setEventMessage($langs->trans('ErrorProductCombinationNotFound'), 'errors');
+ }
+ else
+ {
+ setEventMessages($langs->trans('ErrorProductCombinationNotFound'), null, 'errors');
$error ++;
}
}
@@ -1577,7 +1580,7 @@ if ($action == 'create' && $user->rights->commande->creer)
}
// Date
print '' . $langs->trans('Date') . ' ';
- $form->select_date('', 're', '', '', '', "crea_commande", 1, 1); // Always autofill date with current date
+ print $form->selectDate('', 're', '', '', '', "crea_commande", 1, 1); // Always autofill date with current date
print ' ';
// Delivery date planed
@@ -1587,7 +1590,7 @@ if ($action == 'create' && $user->rights->commande->creer)
if (! empty($conf->global->DATE_LIVRAISON_WEEK_DELAY)) $datedelivery = time() + ((7*$conf->global->DATE_LIVRAISON_WEEK_DELAY) * 24 * 60 * 60);
else $datedelivery=empty($conf->global->MAIN_AUTOFILL_DATE_DELIVERY)?-1:'';
}
- $form->select_date($datedelivery, 'liv_', '', '', '', "crea_commande", 1, 1);
+ print $form->selectDate($datedelivery, 'liv_', '', '', '', "crea_commande", 1, 1);
print "";
// Conditions de reglement
@@ -1965,12 +1968,11 @@ if ($action == 'create' && $user->rights->commande->creer)
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('CloneOrder'), $langs->trans('ConfirmCloneOrder', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
}
- if (! $formconfirm) {
- $parameters = array('lineid' => $lineid);
- $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
- if (empty($reshook)) $formconfirm.=$hookmanager->resPrint;
- elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint;
- }
+ // Call Hook formConfirm
+ $parameters = array('lineid' => $lineid);
+ $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
+ if (empty($reshook)) $formconfirm.=$hookmanager->resPrint;
+ elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint;
// Print form confirm
print $formconfirm;
@@ -2085,7 +2087,7 @@ if ($action == 'create' && $user->rights->commande->creer)
print 'id . '" method="post">';
print '';
print '';
- $form->select_date($object->date, 'order_', '', '', '', "setdate");
+ print $form->selectDate($object->date, 'order_', '', '', '', "setdate");
print '';
print ' ';
} else {
@@ -2110,7 +2112,7 @@ if ($action == 'create' && $user->rights->commande->creer)
print 'id . '" method="post">';
print '';
print '';
- $form->select_date($object->date_livraison ? $object->date_livraison : - 1, 'liv_', '', '', '', "setdate_livraison");
+ print $form->selectDate($object->date_livraison ? $object->date_livraison : - 1, 'liv_', '', '', '', "setdate_livraison");
print '';
print ' ';
} else {
@@ -2387,7 +2389,7 @@ if ($action == 'create' && $user->rights->commande->creer)
// Total HT
$alert = '';
- if($object->total_ht < $object->thirdparty->order_min_amount) {
+ if (! empty($conf->global->ORDER_MANAGE_MIN_AMOUNT) && $object->total_ht < $object->thirdparty->order_min_amount) {
$alert = ' ' . img_warning($langs->trans('OrderMinAmount').': '.price($object->thirdparty->order_min_amount));
}
print '' . $langs->trans('AmountHT') . ' ';
@@ -2676,5 +2678,6 @@ if ($action == 'create' && $user->rights->commande->creer)
}
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php
index e52da47e11b..60011592afe 100644
--- a/htdocs/commande/class/api_orders.class.php
+++ b/htdocs/commande/class/api_orders.class.php
@@ -97,9 +97,10 @@ class Orders extends DolibarrApi
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')"
* @return array Array of order objects
*
- * @throws RestException
+ * @throws RestException
*/
- function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '') {
+ function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '')
+ {
global $db, $conf;
$obj_ret = array();
@@ -185,9 +186,9 @@ class Orders extends DolibarrApi
*/
function post($request_data = null)
{
- if(! DolibarrApiAccess::$user->rights->commande->creer) {
- throw new RestException(401, "Insuffisant rights");
- }
+ if(! DolibarrApiAccess::$user->rights->commande->creer) {
+ throw new RestException(401, "Insuffisant rights");
+ }
// Check mandatory fields
$result = $this->_validate($request_data);
@@ -218,25 +219,26 @@ class Orders extends DolibarrApi
*
* @return int
*/
- function getLines($id) {
- if(! DolibarrApiAccess::$user->rights->commande->lire) {
- throw new RestException(401);
- }
+ function getLines($id)
+ {
+ if(! DolibarrApiAccess::$user->rights->commande->lire) {
+ throw new RestException(401);
+ }
- $result = $this->commande->fetch($id);
- if( ! $result ) {
- throw new RestException(404, 'Order not found');
- }
+ $result = $this->commande->fetch($id);
+ if( ! $result ) {
+ throw new RestException(404, 'Order not found');
+ }
- if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) {
- throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
- }
- $this->commande->getLinesArray();
- $result = array();
- foreach ($this->commande->lines as $line) {
- array_push($result,$this->_cleanObjectDatas($line));
- }
- return $result;
+ if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) {
+ throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
+ }
+ $this->commande->getLinesArray();
+ $result = array();
+ foreach ($this->commande->lines as $line) {
+ array_push($result,$this->_cleanObjectDatas($line));
+ }
+ return $result;
}
/**
@@ -249,21 +251,22 @@ class Orders extends DolibarrApi
*
* @return int
*/
- function postLine($id, $request_data = null) {
- if(! DolibarrApiAccess::$user->rights->commande->creer) {
- throw new RestException(401);
- }
+ function postLine($id, $request_data = null)
+ {
+ if(! DolibarrApiAccess::$user->rights->commande->creer) {
+ throw new RestException(401);
+ }
- $result = $this->commande->fetch($id);
- if( ! $result ) {
- throw new RestException(404, 'Order not found');
- }
+ $result = $this->commande->fetch($id);
+ if( ! $result ) {
+ throw new RestException(404, 'Order not found');
+ }
- if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) {
- throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
- }
- $request_data = (object) $request_data;
- $updateRes = $this->commande->addline(
+ if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) {
+ throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
+ }
+ $request_data = (object) $request_data;
+ $updateRes = $this->commande->addline(
$request_data->desc,
$request_data->subprice,
$request_data->qty,
@@ -290,15 +293,14 @@ class Orders extends DolibarrApi
$request_data->origin,
$request_data->origin_id,
$request_data->multicurrency_subprice
- );
+ );
- if ($updateRes > 0) {
- return $updateRes;
+ if ($updateRes > 0) {
+ return $updateRes;
- }
- else {
+ } else {
throw new RestException(400, $this->commande->error);
- }
+ }
}
/**
@@ -312,51 +314,52 @@ class Orders extends DolibarrApi
*
* @return object
*/
- function putLine($id, $lineid, $request_data = null) {
- if(! DolibarrApiAccess::$user->rights->commande->creer) {
- throw new RestException(401);
- }
+ function putLine($id, $lineid, $request_data = null)
+ {
+ if(! DolibarrApiAccess::$user->rights->commande->creer) {
+ throw new RestException(401);
+ }
- $result = $this->commande->fetch($id);
- if( ! $result ) {
- throw new RestException(404, 'Order not found');
- }
+ $result = $this->commande->fetch($id);
+ if( ! $result ) {
+ throw new RestException(404, 'Order not found');
+ }
- if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) {
- throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
- }
- $request_data = (object) $request_data;
- $updateRes = $this->commande->updateline(
- $lineid,
- $request_data->desc,
- $request_data->subprice,
- $request_data->qty,
- $request_data->remise_percent,
- $request_data->tva_tx,
- $request_data->localtax1_tx,
- $request_data->localtax2_tx,
- 'HT',
- $request_data->info_bits,
- $request_data->date_start,
- $request_data->date_end,
- $request_data->product_type,
- $request_data->fk_parent_line,
- 0,
- $request_data->fk_fournprice,
- $request_data->pa_ht,
- $request_data->label,
- $request_data->special_code,
- $request_data->array_options,
- $request_data->fk_unit,
- $request_data->multicurrency_subprice
- );
+ if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) {
+ throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
+ }
+ $request_data = (object) $request_data;
+ $updateRes = $this->commande->updateline(
+ $lineid,
+ $request_data->desc,
+ $request_data->subprice,
+ $request_data->qty,
+ $request_data->remise_percent,
+ $request_data->tva_tx,
+ $request_data->localtax1_tx,
+ $request_data->localtax2_tx,
+ 'HT',
+ $request_data->info_bits,
+ $request_data->date_start,
+ $request_data->date_end,
+ $request_data->product_type,
+ $request_data->fk_parent_line,
+ 0,
+ $request_data->fk_fournprice,
+ $request_data->pa_ht,
+ $request_data->label,
+ $request_data->special_code,
+ $request_data->array_options,
+ $request_data->fk_unit,
+ $request_data->multicurrency_subprice
+ );
- if ($updateRes > 0) {
- $result = $this->get($id);
- unset($result->line);
- return $this->_cleanObjectDatas($result);
- }
- return false;
+ if ($updateRes > 0) {
+ $result = $this->get($id);
+ unset($result->line);
+ return $this->_cleanObjectDatas($result);
+ }
+ return false;
}
/**
@@ -372,30 +375,29 @@ class Orders extends DolibarrApi
* @throws 401
* @throws 404
*/
- function deleteLine($id, $lineid) {
- if(! DolibarrApiAccess::$user->rights->commande->creer) {
- throw new RestException(401);
- }
+ function deleteLine($id, $lineid)
+ {
+ if(! DolibarrApiAccess::$user->rights->commande->creer) {
+ throw new RestException(401);
+ }
- $result = $this->commande->fetch($id);
- if( ! $result ) {
- throw new RestException(404, 'Order not found');
- }
+ $result = $this->commande->fetch($id);
+ if( ! $result ) {
+ throw new RestException(404, 'Order not found');
+ }
- if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) {
- throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
- }
+ if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) {
+ throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
+ }
- // TODO Check the lineid $lineid is a line of ojbect
+ // TODO Check the lineid $lineid is a line of ojbect
- $updateRes = $this->commande->deleteline(DolibarrApiAccess::$user,$lineid);
- if ($updateRes > 0) {
- return $this->get($id);
- }
- else
- {
- throw new RestException(405, $this->commande->error);
- }
+ $updateRes = $this->commande->deleteline(DolibarrApiAccess::$user,$lineid);
+ if ($updateRes > 0) {
+ return $this->get($id);
+ } else {
+ throw new RestException(405, $this->commande->error);
+ }
}
/**
@@ -406,10 +408,11 @@ class Orders extends DolibarrApi
*
* @return int
*/
- function put($id, $request_data = null) {
- if (! DolibarrApiAccess::$user->rights->commande->creer) {
- throw new RestException(401);
- }
+ function put($id, $request_data = null)
+ {
+ if (! DolibarrApiAccess::$user->rights->commande->creer) {
+ throw new RestException(401);
+ }
$result = $this->commande->fetch($id);
if (! $result) {
@@ -470,7 +473,6 @@ class Orders extends DolibarrApi
'message' => 'Order deleted'
)
);
-
}
/**
@@ -547,24 +549,25 @@ class Orders extends DolibarrApi
* @throws 404
* @throws 405
*/
- function reopen($id) {
+ function reopen($id)
+ {
if(! DolibarrApiAccess::$user->rights->commande->creer) {
- throw new RestException(401);
+ throw new RestException(401);
}
if(empty($id)) {
- throw new RestException(400, 'Order ID is mandatory');
+ throw new RestException(400, 'Order ID is mandatory');
}
$result = $this->commande->fetch($id);
if( ! $result ) {
- throw new RestException(404, 'Order not found');
+ throw new RestException(404, 'Order not found');
}
$result = $this->commande->set_reopen(DolibarrApiAccess::$user);
if( $result < 0) {
- throw new RestException(405, $this->commande->error);
+ throw new RestException(405, $this->commande->error);
}else if( $result == 0) {
- throw new RestException(304);
+ throw new RestException(304);
}
return $result;
@@ -584,22 +587,23 @@ class Orders extends DolibarrApi
* @throws 404
* @throws 405
*/
- function setinvoiced($id) {
+ function setinvoiced($id)
+ {
if(! DolibarrApiAccess::$user->rights->commande->creer) {
- throw new RestException(401);
+ throw new RestException(401);
}
if(empty($id)) {
- throw new RestException(400, 'Order ID is mandatory');
+ throw new RestException(400, 'Order ID is mandatory');
}
$result = $this->commande->fetch($id);
if( ! $result ) {
- throw new RestException(404, 'Order not found');
+ throw new RestException(404, 'Order not found');
}
$result = $this->commande->classifyBilled(DolibarrApiAccess::$user);
if( $result < 0) {
- throw new RestException(400, $this->commande->error);
+ throw new RestException(400, $this->commande->error);
}
$result = $this->commande->fetch($id);
@@ -675,23 +679,23 @@ class Orders extends DolibarrApi
function settodraft($id, $idwarehouse=-1)
{
if(! DolibarrApiAccess::$user->rights->commande->creer) {
- throw new RestException(401);
+ throw new RestException(401);
}
$result = $this->commande->fetch($id);
if( ! $result ) {
- throw new RestException(404, 'Order not found');
+ throw new RestException(404, 'Order not found');
}
if( ! DolibarrApi::_checkAccessToResource('commande',$this->commande->id)) {
- throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
+ throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$result = $this->commande->set_draft(DolibarrApiAccess::$user, $idwarehouse);
if ($result == 0) {
- throw new RestException(304, 'Nothing done. May be object is already closed');
+ throw new RestException(304, 'Nothing done. May be object is already closed');
}
if ($result < 0) {
- throw new RestException(500, 'Error when closing Order: '.$this->commande->error);
+ throw new RestException(500, 'Error when closing Order: '.$this->commande->error);
}
$result = $this->commande->fetch($id);
@@ -709,43 +713,44 @@ class Orders extends DolibarrApi
}
- /**
- * Create an order using an existing proposal.
- *
- *
- * @param int $proposalid Id of the proposal
- *
- * @url POST /createfromproposal/{proposalid}
- *
- * @return int
- * @throws 400
- * @throws 401
- * @throws 404
- * @throws 405
- */
- function createOrderFromProposal($proposalid) {
+ /**
+ * Create an order using an existing proposal.
+ *
+ *
+ * @param int $proposalid Id of the proposal
+ *
+ * @url POST /createfromproposal/{proposalid}
+ *
+ * @return int
+ * @throws 400
+ * @throws 401
+ * @throws 404
+ * @throws 405
+ */
+ function createOrderFromProposal($proposalid)
+ {
require_once DOL_DOCUMENT_ROOT . '/comm/propal/class/propal.class.php';
if(! DolibarrApiAccess::$user->rights->propal->lire) {
- throw new RestException(401);
+ throw new RestException(401);
}
if(! DolibarrApiAccess::$user->rights->commande->creer) {
- throw new RestException(401);
+ throw new RestException(401);
}
if(empty($proposalid)) {
- throw new RestException(400, 'Proposal ID is mandatory');
+ throw new RestException(400, 'Proposal ID is mandatory');
}
$propal = new Propal($this->db);
$result = $propal->fetch($proposalid);
if( ! $result ) {
- throw new RestException(404, 'Proposal not found');
+ throw new RestException(404, 'Proposal not found');
}
$result = $this->commande->createFromProposal($propal, DolibarrApiAccess::$user);
if( $result < 0) {
- throw new RestException(405, $this->commande->error);
+ throw new RestException(405, $this->commande->error);
}
$this->commande->fetchObjectLinked();
@@ -759,7 +764,8 @@ class Orders extends DolibarrApi
* @param object $object Object to clean
* @return array Array of cleaned object properties
*/
- function _cleanObjectDatas($object) {
+ function _cleanObjectDatas($object)
+ {
$object = parent::_cleanObjectDatas($object);
@@ -785,7 +791,7 @@ class Orders extends DolibarrApi
$commande = array();
foreach (Orders::$FIELDS as $field) {
if (!isset($data[$field]))
- throw new RestException(400, "$field field missing");
+ throw new RestException(400, $field ." field missing");
$commande[$field] = $data[$field];
}
diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php
index 17e4387c4de..65459d37895 100644
--- a/htdocs/commande/class/commande.class.php
+++ b/htdocs/commande/class/commande.class.php
@@ -42,108 +42,137 @@ require_once DOL_DOCUMENT_ROOT .'/multicurrency/class/multicurrency.class.php';
*/
class Commande extends CommonOrder
{
- public $element='commande';
- public $table_element='commande';
- public $table_element_line = 'commandedet';
- public $class_element_line = 'OrderLine';
- public $fk_element = 'fk_commande';
- public $picto = 'order';
- /**
- * 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
- * @var int
- */
- public $ismultientitymanaged = 1;
- /**
- * 0=Default, 1=View may be restricted to sales representative only if no permission to see all or to company of external user if external user
- * @var integer
- */
- public $restrictiononfksoc = 1;
+ /**
+ * @var string ID to identify managed object
+ */
+ public $element='commande';
- /**
- * {@inheritdoc}
- */
- protected $table_ref_field = 'ref';
+ /**
+ * @var string Name of table without prefix where object is stored
+ */
+ public $table_element='commande';
+
+ /**
+ * @var int Name of subtable line
+ */
+ public $table_element_line = 'commandedet';
+
+ public $class_element_line = 'OrderLine';
+
+ /**
+ * @var int Field with ID of parent key if this field has a parent
+ */
+ public $fk_element = 'fk_commande';
+
+ /**
+ * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
+ */
+ public $picto = 'order';
+
+ /**
+ * 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
+ * @var int
+ */
+ public $ismultientitymanaged = 1;
+
+ /**
+ * 0=Default, 1=View may be restricted to sales representative only if no permission to see all or to company of external user if external user
+ * @var integer
+ */
+ public $restrictiononfksoc = 1;
+
+ /**
+ * {@inheritdoc}
+ */
+ protected $table_ref_field = 'ref';
/**
* Client ID
* @var int
*/
- public $socid;
+ public $socid;
- public $ref_client;
- public $ref_int;
- public $contactid;
+ public $ref_client;
+ public $ref_int;
+ public $contactid;
/**
* Status of the order
* @var int
*/
- public $statut;
+ public $statut;
+
/**
* Billed
* @var int
*/
- public $billed; // billed or not
+ public $billed; // billed or not
- public $brouillon;
- public $cond_reglement_code;
+ public $brouillon;
+ public $cond_reglement_code;
- public $fk_account;
+ public $fk_account;
- /**
- * It holds the label of the payment mode. Use it in case translation cannot be found.
- * @var string
- */
- public $mode_reglement;
+ /**
+ * It holds the label of the payment mode. Use it in case translation cannot be found.
+ * @var string
+ */
+ public $mode_reglement;
- /**
- * Payment mode id
- * @var int
- */
- public $mode_reglement_id;
- /**
- * Payment mode code
- * @var string
- */
- public $mode_reglement_code;
- /**
- * Availability delivery time id
- * @var int
- */
- public $availability_id;
- /**
- * Availability delivery time code
- * @var string
- */
- public $availability_code;
- /**
- * Label of availability delivery time. Use it in case translation cannot be found.
- * @var string
- */
- public $availability;
+ /**
+ * Payment mode id
+ * @var int
+ */
+ public $mode_reglement_id;
+
+ /**
+ * Payment mode code
+ * @var string
+ */
+ public $mode_reglement_code;
+
+ /**
+ * Availability delivery time id
+ * @var int
+ */
+ public $availability_id;
+
+ /**
+ * Availability delivery time code
+ * @var string
+ */
+ public $availability_code;
+
+ /**
+ * Label of availability delivery time. Use it in case translation cannot be found.
+ * @var string
+ */
+ public $availability;
+
+ public $demand_reason_id; // Source reason. Why we receive order (after a phone campaign, ...)
+ public $demand_reason_code;
+ public $date; // Date commande
- public $demand_reason_id; // Source reason. Why we receive order (after a phone campaign, ...)
- public $demand_reason_code;
- public $date; // Date commande
/**
* @deprecated
* @see date
*/
- public $date_commande;
- public $date_livraison; // Date expected of shipment (date starting shipment, not the reception that occurs some days after)
- public $fk_remise_except;
- public $remise_percent;
- public $remise_absolue;
- public $info_bits;
- public $rang;
- public $special_code;
- public $source; // Order mode. How we received order (by phone, by email, ...)
- public $extraparams=array();
+ public $date_commande;
- public $linked_objects=array();
+ public $date_livraison; // Date expected of shipment (date starting shipment, not the reception that occurs some days after)
+ public $fk_remise_except;
+ public $remise_percent;
+ public $remise_absolue;
+ public $info_bits;
+ public $rang;
+ public $special_code;
+ public $source; // Order mode. How we received order (by phone, by email, ...)
+ public $extraparams=array();
- public $user_author_id;
- public $user_valid;
+ public $linked_objects=array();
+
+ public $user_author_id;
+ public $user_valid;
/**
* @var OrderLine[]
@@ -160,10 +189,10 @@ class Commande extends CommonOrder
public $oldcopy;
- /**
- * ERR Not enough stock
- */
- const STOCK_NOT_ENOUGH_FOR_ORDER = -3;
+ /**
+ * ERR Not enough stock
+ */
+ const STOCK_NOT_ENOUGH_FOR_ORDER = -3;
/**
* Canceled status
@@ -189,445 +218,449 @@ class Commande extends CommonOrder
const STATUS_CLOSED = 3;
- /**
- * Constructor
- *
- * @param DoliDB $db Database handler
- */
- function __construct($db)
- {
- $this->db = $db;
+ /**
+ * Constructor
+ *
+ * @param DoliDB $db Database handler
+ */
+ function __construct($db)
+ {
+ $this->db = $db;
- $this->remise = 0;
- $this->remise_percent = 0;
+ $this->remise = 0;
+ $this->remise_percent = 0;
- $this->products = array();
- }
+ $this->products = array();
+ }
- /**
+ /**
* Returns the reference to the following non used Order depending on the active numbering module
* defined into COMMANDE_ADDON
*
* @param Societe $soc Object thirdparty
* @return string Order free reference
*/
- function getNextNumRef($soc)
- {
- global $langs, $conf;
- $langs->load("order");
+ function getNextNumRef($soc)
+ {
+ global $langs, $conf;
+ $langs->load("order");
- if (! empty($conf->global->COMMANDE_ADDON))
- {
- $mybool=false;
+ if (! empty($conf->global->COMMANDE_ADDON))
+ {
+ $mybool=false;
- $file = $conf->global->COMMANDE_ADDON.".php";
+ $file = $conf->global->COMMANDE_ADDON.".php";
$classname = $conf->global->COMMANDE_ADDON;
// Include file with class
$dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']);
foreach ($dirmodels as $reldir)
{
- $dir = dol_buildpath($reldir."core/modules/commande/");
+ $dir = dol_buildpath($reldir."core/modules/commande/");
- // Load file with numbering class (if found)
- $mybool|=@include_once $dir.$file;
- }
+ // Load file with numbering class (if found)
+ $mybool|=@include_once $dir.$file;
+ }
- if (! $mybool)
- {
- dol_print_error('',"Failed to include file ".$file);
- return '';
- }
+ if (! $mybool)
+ {
+ dol_print_error('',"Failed to include file ".$file);
+ return '';
+ }
- $obj = new $classname();
- $numref = $obj->getNextValue($soc,$this);
+ $obj = new $classname();
+ $numref = $obj->getNextValue($soc,$this);
- if ($numref != "")
- {
- return $numref;
- }
- else
+ if ($numref != "")
+ {
+ return $numref;
+ }
+ else
{
$this->error=$obj->error;
- //dol_print_error($this->db,get_class($this)."::getNextNumRef ".$obj->error);
- return "";
- }
- }
- else
- {
- print $langs->trans("Error")." ".$langs->trans("Error_COMMANDE_ADDON_NotDefined");
- return "";
- }
- }
-
-
- /**
- * Validate order
- *
- * @param User $user User making status change
- * @param int $idwarehouse Id of warehouse to use for stock decrease
- * @param int $notrigger 1=Does not execute triggers, 0= execute triggers
- * @return int <=0 if OK, 0=Nothing done, >0 if KO
- */
- function valid($user, $idwarehouse=0, $notrigger=0)
- {
- global $conf,$langs;
- require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
-
- $error=0;
-
- // Protection
- if ($this->statut == self::STATUS_VALIDATED)
- {
- dol_syslog(get_class($this)."::valid action abandonned: already validated", LOG_WARNING);
- return 0;
- }
-
- if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->creer))
- || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->order_advance->validate))))
- {
- $this->error='NotEnoughPermissions';
- dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR);
- return -1;
- }
-
- $now=dol_now();
-
- $this->db->begin();
-
- // Definition du nom de module de numerotation de commande
- $soc = new Societe($this->db);
- $soc->fetch($this->socid);
-
- // Class of company linked to order
- $result=$soc->set_as_client();
-
- // Define new ref
- if (! $error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) // empty should not happened, but when it occurs, the test save life
- {
- $num = $this->getNextNumRef($soc);
- }
- else
+ //dol_print_error($this->db,get_class($this)."::getNextNumRef ".$obj->error);
+ return "";
+ }
+ }
+ else
{
- $num = $this->ref;
- }
- $this->newref = $num;
+ print $langs->trans("Error")." ".$langs->trans("Error_COMMANDE_ADDON_NotDefined");
+ return "";
+ }
+ }
- // Validate
- $sql = "UPDATE ".MAIN_DB_PREFIX."commande";
- $sql.= " SET ref = '".$num."',";
- $sql.= " fk_statut = ".self::STATUS_VALIDATED.",";
- $sql.= " date_valid='".$this->db->idate($now)."',";
- $sql.= " fk_user_valid = ".$user->id;
- $sql.= " WHERE rowid = ".$this->id;
- dol_syslog(get_class($this)."::valid()", LOG_DEBUG);
- $resql=$this->db->query($sql);
- if (! $resql)
- {
- dol_print_error($this->db);
- $this->error=$this->db->lasterror();
- $error++;
- }
+ /**
+ * Validate order
+ *
+ * @param User $user User making status change
+ * @param int $idwarehouse Id of warehouse to use for stock decrease
+ * @param int $notrigger 1=Does not execute triggers, 0= execute triggers
+ * @return int <=0 if OK, 0=Nothing done, >0 if KO
+ */
+ function valid($user, $idwarehouse=0, $notrigger=0)
+ {
+ global $conf,$langs;
+ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
- if (! $error)
- {
- // If stock is incremented on validate order, we must increment it
- if ($result >= 0 && ! empty($conf->stock->enabled) && $conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER == 1)
- {
- require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php';
- $langs->load("agenda");
+ $error=0;
- // Loop on each line
- $cpt=count($this->lines);
- for ($i = 0; $i < $cpt; $i++)
- {
- if ($this->lines[$i]->fk_product > 0)
- {
- $mouvP = new MouvementStock($this->db);
+ // Protection
+ if ($this->statut == self::STATUS_VALIDATED)
+ {
+ dol_syslog(get_class($this)."::valid action abandonned: already validated", LOG_WARNING);
+ return 0;
+ }
+
+ if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->creer))
+ || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->order_advance->validate))))
+ {
+ $this->error='NotEnoughPermissions';
+ dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR);
+ return -1;
+ }
+
+ $now=dol_now();
+
+ $this->db->begin();
+
+ // Definition du nom de module de numerotation de commande
+ $soc = new Societe($this->db);
+ $soc->fetch($this->socid);
+
+ // Class of company linked to order
+ $result=$soc->set_as_client();
+
+ // Define new ref
+ if (! $error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) // empty should not happened, but when it occurs, the test save life
+ {
+ $num = $this->getNextNumRef($soc);
+ }
+ else
+ {
+ $num = $this->ref;
+ }
+ $this->newref = $num;
+
+ // Validate
+ $sql = "UPDATE ".MAIN_DB_PREFIX."commande";
+ $sql.= " SET ref = '".$num."',";
+ $sql.= " fk_statut = ".self::STATUS_VALIDATED.",";
+ $sql.= " date_valid='".$this->db->idate($now)."',";
+ $sql.= " fk_user_valid = ".$user->id;
+ $sql.= " WHERE rowid = ".$this->id;
+
+ dol_syslog(get_class($this)."::valid()", LOG_DEBUG);
+ $resql=$this->db->query($sql);
+ if (! $resql)
+ {
+ dol_print_error($this->db);
+ $this->error=$this->db->lasterror();
+ $error++;
+ }
+
+ if (! $error)
+ {
+ // If stock is incremented on validate order, we must increment it
+ if ($result >= 0 && ! empty($conf->stock->enabled) && $conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER == 1)
+ {
+ require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php';
+ $langs->load("agenda");
+
+ // Loop on each line
+ $cpt=count($this->lines);
+ for ($i = 0; $i < $cpt; $i++)
+ {
+ if ($this->lines[$i]->fk_product > 0)
+ {
+ $mouvP = new MouvementStock($this->db);
$mouvP->origin = &$this;
- // We decrement stock of product (and sub-products)
- $result=$mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("OrderValidatedInDolibarr",$num));
- if ($result < 0)
- {
- $error++;
- $this->error=$mouvP->error;
- }
- }
- if ($error) break;
- }
- }
- }
+ // We decrement stock of product (and sub-products)
+ $result=$mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("OrderValidatedInDolibarr",$num));
+ if ($result < 0)
+ {
+ $error++;
+ $this->error=$mouvP->error;
+ }
+ }
+ if ($error) break;
+ }
+ }
+ }
- if (! $error && ! $notrigger)
- {
- // Call trigger
- $result=$this->call_trigger('ORDER_VALIDATE',$user);
- if ($result < 0) $error++;
- // End call triggers
- }
-
- if (! $error)
- {
- $this->oldref = $this->ref;
-
- // Rename directory if dir was a temporary ref
- if (preg_match('/^[\(]?PROV/i', $this->ref))
- {
- // On renomme repertoire ($this->ref = ancienne ref, $num = nouvelle ref)
- // in order not to lose the attachments
- $oldref = dol_sanitizeFileName($this->ref);
- $newref = dol_sanitizeFileName($num);
- $dirsource = $conf->commande->dir_output.'/'.$oldref;
- $dirdest = $conf->commande->dir_output.'/'.$newref;
- if (file_exists($dirsource))
- {
- dol_syslog(get_class($this)."::valid() rename dir ".$dirsource." into ".$dirdest);
-
- if (@rename($dirsource, $dirdest))
- {
- dol_syslog("Rename ok");
- // Rename docs starting with $oldref with $newref
- $listoffiles=dol_dir_list($conf->commande->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref,'/'));
- foreach($listoffiles as $fileentry)
- {
- $dirsource=$fileentry['name'];
- $dirdest=preg_replace('/^'.preg_quote($oldref,'/').'/',$newref, $dirsource);
- $dirsource=$fileentry['path'].'/'.$dirsource;
- $dirdest=$fileentry['path'].'/'.$dirdest;
- @rename($dirsource, $dirdest);
- }
- }
- }
- }
- }
-
- // Set new ref and current status
- if (! $error)
- {
- $this->ref = $num;
- $this->statut = self::STATUS_VALIDATED;
- }
-
- if (! $error)
- {
- $this->db->commit();
- return 1;
- }
- else
+ if (! $error && ! $notrigger)
{
- $this->db->rollback();
- return -1;
- }
- }
+ // Call trigger
+ $result=$this->call_trigger('ORDER_VALIDATE',$user);
+ if ($result < 0) $error++;
+ // End call triggers
+ }
- /**
- * Set draft status
- *
- * @param User $user Object user that modify
- * @param int $idwarehouse Warehouse ID to use for stock change (Used only if option STOCK_CALCULATE_ON_VALIDATE_ORDER is on)
- * @return int <0 if KO, >0 if OK
- */
- function set_draft($user, $idwarehouse=-1)
- {
- global $conf,$langs;
+ if (! $error)
+ {
+ $this->oldref = $this->ref;
- $error=0;
+ // Rename directory if dir was a temporary ref
+ if (preg_match('/^[\(]?PROV/i', $this->ref))
+ {
+ // On renomme repertoire ($this->ref = ancienne ref, $num = nouvelle ref)
+ // in order not to lose the attachments
+ $oldref = dol_sanitizeFileName($this->ref);
+ $newref = dol_sanitizeFileName($num);
+ $dirsource = $conf->commande->dir_output.'/'.$oldref;
+ $dirdest = $conf->commande->dir_output.'/'.$newref;
+ if (file_exists($dirsource))
+ {
+ dol_syslog(get_class($this)."::valid() rename dir ".$dirsource." into ".$dirdest);
- // Protection
- if ($this->statut <= self::STATUS_DRAFT)
- {
- return 0;
- }
+ if (@rename($dirsource, $dirdest))
+ {
+ dol_syslog("Rename ok");
+ // Rename docs starting with $oldref with $newref
+ $listoffiles=dol_dir_list($conf->commande->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref,'/'));
+ foreach($listoffiles as $fileentry)
+ {
+ $dirsource=$fileentry['name'];
+ $dirdest=preg_replace('/^'.preg_quote($oldref,'/').'/',$newref, $dirsource);
+ $dirsource=$fileentry['path'].'/'.$dirsource;
+ $dirdest=$fileentry['path'].'/'.$dirdest;
+ @rename($dirsource, $dirdest);
+ }
+ }
+ }
+ }
+ }
- if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->creer))
- || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->order_advance->validate))))
- {
- $this->error='Permission denied';
- return -1;
- }
+ // Set new ref and current status
+ if (! $error)
+ {
+ $this->ref = $num;
+ $this->statut = self::STATUS_VALIDATED;
+ }
- $this->db->begin();
+ if (! $error)
+ {
+ $this->db->commit();
+ return 1;
+ }
+ else
+ {
+ $this->db->rollback();
+ return -1;
+ }
+ }
- $sql = "UPDATE ".MAIN_DB_PREFIX."commande";
- $sql.= " SET fk_statut = ".self::STATUS_DRAFT;
- $sql.= " WHERE rowid = ".$this->id;
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
+ /**
+ * Set draft status
+ *
+ * @param User $user Object user that modify
+ * @param int $idwarehouse Warehouse ID to use for stock change (Used only if option STOCK_CALCULATE_ON_VALIDATE_ORDER is on)
+ * @return int <0 if KO, >0 if OK
+ */
+ function set_draft($user, $idwarehouse=-1)
+ {
+ //phpcs:enable
+ global $conf,$langs;
- dol_syslog(get_class($this)."::set_draft", LOG_DEBUG);
- if ($this->db->query($sql))
- {
- // If stock is decremented on validate order, we must reincrement it
- if (! empty($conf->stock->enabled) && $conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER == 1)
- {
- $result = 0;
+ $error=0;
- require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php';
- $langs->load("agenda");
+ // Protection
+ if ($this->statut <= self::STATUS_DRAFT)
+ {
+ return 0;
+ }
- $num=count($this->lines);
- for ($i = 0; $i < $num; $i++)
- {
- if ($this->lines[$i]->fk_product > 0)
- {
- $mouvP = new MouvementStock($this->db);
- $mouvP->origin = &$this;
- // We increment stock of product (and sub-products)
- $result=$mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("OrderBackToDraftInDolibarr",$this->ref));
- if ($result < 0) { $error++; $this->error=$mouvP->error; break; }
- }
- }
- }
+ if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->creer))
+ || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->order_advance->validate))))
+ {
+ $this->error='Permission denied';
+ return -1;
+ }
- if (!$error) {
- // Call trigger
- $result=$this->call_trigger('ORDER_UNVALIDATE',$user);
- if ($result < 0) $error++;
- }
+ $this->db->begin();
- if (!$error) {
- $this->statut=self::STATUS_DRAFT;
- $this->db->commit();
- return 1;
- }else {
- $this->db->rollback();
- return -1;
- }
- }
- else
- {
- $this->error=$this->db->error();
- $this->db->rollback();
- return -1;
- }
- }
+ $sql = "UPDATE ".MAIN_DB_PREFIX."commande";
+ $sql.= " SET fk_statut = ".self::STATUS_DRAFT;
+ $sql.= " WHERE rowid = ".$this->id;
+
+ dol_syslog(get_class($this)."::set_draft", LOG_DEBUG);
+ if ($this->db->query($sql))
+ {
+ // If stock is decremented on validate order, we must reincrement it
+ if (! empty($conf->stock->enabled) && $conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER == 1)
+ {
+ $result = 0;
+
+ require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php';
+ $langs->load("agenda");
+
+ $num=count($this->lines);
+ for ($i = 0; $i < $num; $i++)
+ {
+ if ($this->lines[$i]->fk_product > 0)
+ {
+ $mouvP = new MouvementStock($this->db);
+ $mouvP->origin = &$this;
+ // We increment stock of product (and sub-products)
+ $result=$mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("OrderBackToDraftInDolibarr",$this->ref));
+ if ($result < 0) { $error++; $this->error=$mouvP->error; break; }
+ }
+ }
+ }
+
+ if (!$error) {
+ // Call trigger
+ $result=$this->call_trigger('ORDER_UNVALIDATE',$user);
+ if ($result < 0) $error++;
+ }
+
+ if (!$error) {
+ $this->statut=self::STATUS_DRAFT;
+ $this->db->commit();
+ return 1;
+ }else {
+ $this->db->rollback();
+ return -1;
+ }
+ }
+ else
+ {
+ $this->error=$this->db->error();
+ $this->db->rollback();
+ return -1;
+ }
+ }
- /**
- * Tag the order as validated (opened)
- * Function used when order is reopend after being closed.
- *
- * @param User $user Object user that change status
- * @return int <0 if KO, 0 if nothing is done, >0 if OK
- */
- function set_reopen($user)
- {
- $error=0;
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
+ /**
+ * Tag the order as validated (opened)
+ * Function used when order is reopend after being closed.
+ *
+ * @param User $user Object user that change status
+ * @return int <0 if KO, 0 if nothing is done, >0 if OK
+ */
+ function set_reopen($user)
+ {
+ // phpcs:enable
+ $error=0;
- if ($this->statut != self::STATUS_CANCELED && $this->statut != self::STATUS_CLOSED)
- {
- dol_syslog(get_class($this)."::set_reopen order has not status closed", LOG_WARNING);
- return 0;
- }
+ if ($this->statut != self::STATUS_CANCELED && $this->statut != self::STATUS_CLOSED)
+ {
+ dol_syslog(get_class($this)."::set_reopen order has not status closed", LOG_WARNING);
+ return 0;
+ }
- $this->db->begin();
+ $this->db->begin();
- $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande';
- $sql.= ' SET fk_statut='.self::STATUS_VALIDATED.', facture=0';
- $sql.= ' WHERE rowid = '.$this->id;
+ $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande';
+ $sql.= ' SET fk_statut='.self::STATUS_VALIDATED.', facture=0';
+ $sql.= ' WHERE rowid = '.$this->id;
- dol_syslog(get_class($this)."::set_reopen", LOG_DEBUG);
- $resql = $this->db->query($sql);
- if ($resql)
- {
- // Call trigger
- $result=$this->call_trigger('ORDER_REOPEN',$user);
- if ($result < 0) $error++;
- // End call triggers
- }
- else
- {
- $error++;
- $this->error=$this->db->lasterror();
- dol_print_error($this->db);
- }
+ dol_syslog(get_class($this)."::set_reopen", LOG_DEBUG);
+ $resql = $this->db->query($sql);
+ if ($resql)
+ {
+ // Call trigger
+ $result=$this->call_trigger('ORDER_REOPEN',$user);
+ if ($result < 0) $error++;
+ // End call triggers
+ }
+ else
+ {
+ $error++;
+ $this->error=$this->db->lasterror();
+ dol_print_error($this->db);
+ }
- if (! $error)
- {
- $this->statut = self::STATUS_VALIDATED;
- $this->billed = 0;
+ if (! $error)
+ {
+ $this->statut = self::STATUS_VALIDATED;
+ $this->billed = 0;
- $this->db->commit();
- return 1;
- }
- else
- {
- foreach($this->errors as $errmsg)
- {
- dol_syslog(get_class($this)."::set_reopen ".$errmsg, LOG_ERR);
- $this->error.=($this->error?', '.$errmsg:$errmsg);
- }
- $this->db->rollback();
- return -1*$error;
- }
- }
+ $this->db->commit();
+ return 1;
+ }
+ else
+ {
+ foreach($this->errors as $errmsg)
+ {
+ dol_syslog(get_class($this)."::set_reopen ".$errmsg, LOG_ERR);
+ $this->error.=($this->error?', '.$errmsg:$errmsg);
+ }
+ $this->db->rollback();
+ return -1*$error;
+ }
+ }
- /**
- * Close order
- *
- * @param User $user Objet user that close
- * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers
- * @return int <0 if KO, >0 if OK
- */
- function cloture($user, $notrigger=0)
- {
- global $conf;
+ /**
+ * Close order
+ *
+ * @param User $user Objet user that close
+ * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers
+ * @return int <0 if KO, >0 if OK
+ */
+ function cloture($user, $notrigger=0)
+ {
+ global $conf;
- $error=0;
+ $error=0;
- if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->creer))
- || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->order_advance->validate)))
- {
- $this->db->begin();
+ if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->creer))
+ || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->order_advance->validate)))
+ {
+ $this->db->begin();
- $now=dol_now();
+ $now=dol_now();
- $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande';
- $sql.= ' SET fk_statut = '.self::STATUS_CLOSED.',';
- $sql.= ' fk_user_cloture = '.$user->id.',';
- $sql.= " date_cloture = '".$this->db->idate($now)."'";
- $sql.= ' WHERE rowid = '.$this->id.' AND fk_statut > '.self::STATUS_DRAFT;
+ $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande';
+ $sql.= ' SET fk_statut = '.self::STATUS_CLOSED.',';
+ $sql.= ' fk_user_cloture = '.$user->id.',';
+ $sql.= " date_cloture = '".$this->db->idate($now)."'";
+ $sql.= ' WHERE rowid = '.$this->id.' AND fk_statut > '.self::STATUS_DRAFT;
- if ($this->db->query($sql))
- {
- if (! $notrigger)
- {
- // Call trigger
- $result=$this->call_trigger('ORDER_CLOSE',$user);
- if ($result < 0) $error++;
- // End call triggers
- }
+ if ($this->db->query($sql))
+ {
+ if (! $notrigger)
+ {
+ // Call trigger
+ $result=$this->call_trigger('ORDER_CLOSE',$user);
+ if ($result < 0) $error++;
+ // End call triggers
+ }
- if (! $error)
- {
- $this->statut=self::STATUS_CLOSED;
+ if (! $error)
+ {
+ $this->statut=self::STATUS_CLOSED;
- $this->db->commit();
- return 1;
- }
- else
- {
- $this->db->rollback();
- return -1;
- }
- }
- else
- {
- $this->error=$this->db->lasterror();
+ $this->db->commit();
+ return 1;
+ }
+ else
+ {
+ $this->db->rollback();
+ return -1;
+ }
+ }
+ else
+ {
+ $this->error=$this->db->lasterror();
- $this->db->rollback();
- return -1;
- }
- }
- return 0;
- }
+ $this->db->rollback();
+ return -1;
+ }
+ }
+ return 0;
+ }
- /**
- * Cancel an order
- * If stock is decremented on order validation, we must reincrement it
- *
- * @param int $idwarehouse Id warehouse to use for stock change.
- * @return int <0 if KO, >0 if OK
- */
+ /**
+ * Cancel an order
+ * If stock is decremented on order validation, we must reincrement it
+ *
+ * @param int $idwarehouse Id warehouse to use for stock change.
+ * @return int <0 if KO, >0 if OK
+ */
function cancel($idwarehouse=-1)
{
global $conf,$user,$langs;
@@ -670,10 +703,10 @@ class Commande extends CommonOrder
if (! $error)
{
- // Call trigger
- $result=$this->call_trigger('ORDER_CANCEL',$user);
- if ($result < 0) $error++;
- // End call triggers
+ // Call trigger
+ $result=$this->call_trigger('ORDER_CANCEL',$user);
+ if ($result < 0) $error++;
+ // End call triggers
}
if (! $error)
@@ -701,24 +734,24 @@ class Commande extends CommonOrder
}
}
- /**
- * Create order
- * Note that this->ref can be set or empty. If empty, we will use "(PROV)"
- *
- * @param User $user Objet user that make creation
- * @param int $notrigger Disable all triggers
- * @return int <0 if KO, >0 if OK
- */
- function create($user, $notrigger=0)
- {
- global $conf,$langs;
- $error=0;
+ /**
+ * Create order
+ * Note that this->ref can be set or empty. If empty, we will use "(PROV)"
+ *
+ * @param User $user Objet user that make creation
+ * @param int $notrigger Disable all triggers
+ * @return int <0 if KO, >0 if OK
+ */
+ function create($user, $notrigger=0)
+ {
+ global $conf,$langs;
+ $error=0;
- // Clean parameters
- $this->brouillon = 1; // set command as draft
+ // Clean parameters
+ $this->brouillon = 1; // set command as draft
// $date_commande is deprecated
- $date = ($this->date_commande ? $this->date_commande : $this->date);
+ $date = ($this->date_commande ? $this->date_commande : $this->date);
// Multicurrency (test on $this->multicurrency_tx because we should take the default rate only if not using origin rate)
if (!empty($this->multicurrency_code) && empty($this->multicurrency_tx)) list($this->fk_multicurrency,$this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code, $date);
@@ -730,412 +763,412 @@ class Commande extends CommonOrder
$this->multicurrency_tx = 1;
}
- dol_syslog(get_class($this)."::create user=".$user->id);
+ dol_syslog(get_class($this)."::create user=".$user->id);
- // Check parameters
- if (! empty($this->ref)) // We check that ref is not already used
- {
- $result=self::isExistingObject($this->element, 0, $this->ref); // Check ref is not yet used
- if ($result > 0)
- {
- $this->error='ErrorRefAlreadyExists';
- dol_syslog(get_class($this)."::create ".$this->error,LOG_WARNING);
- $this->db->rollback();
- return -1;
- }
- }
+ // Check parameters
+ if (! empty($this->ref)) // We check that ref is not already used
+ {
+ $result=self::isExistingObject($this->element, 0, $this->ref); // Check ref is not yet used
+ if ($result > 0)
+ {
+ $this->error='ErrorRefAlreadyExists';
+ dol_syslog(get_class($this)."::create ".$this->error,LOG_WARNING);
+ $this->db->rollback();
+ return -1;
+ }
+ }
- $soc = new Societe($this->db);
- $result=$soc->fetch($this->socid);
- if ($result < 0)
- {
- $this->error="Failed to fetch company";
- dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR);
- return -2;
- }
- if (! empty($conf->global->COMMANDE_REQUIRE_SOURCE) && $this->source < 0)
- {
- $this->error=$langs->trans("ErrorFieldRequired",$langs->trans("Source"));
- dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR);
- return -1;
- }
+ $soc = new Societe($this->db);
+ $result=$soc->fetch($this->socid);
+ if ($result < 0)
+ {
+ $this->error="Failed to fetch company";
+ dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR);
+ return -2;
+ }
+ if (! empty($conf->global->COMMANDE_REQUIRE_SOURCE) && $this->source < 0)
+ {
+ $this->error=$langs->trans("ErrorFieldRequired",$langs->trans("Source"));
+ dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR);
+ return -1;
+ }
- $now=dol_now();
+ $now=dol_now();
- $this->db->begin();
+ $this->db->begin();
- $sql = "INSERT INTO ".MAIN_DB_PREFIX."commande (";
- $sql.= " ref, fk_soc, date_creation, fk_user_author, fk_projet, date_commande, source, note_private, note_public, ref_ext, ref_client, ref_int";
- $sql.= ", model_pdf, fk_cond_reglement, fk_mode_reglement, fk_account, fk_availability, fk_input_reason, date_livraison, fk_delivery_address";
- $sql.= ", fk_shipping_method";
- $sql.= ", fk_warehouse";
- $sql.= ", remise_absolue, remise_percent";
- $sql.= ", fk_incoterms, location_incoterms";
- $sql.= ", entity";
- $sql.= ", fk_multicurrency";
- $sql.= ", multicurrency_code";
- $sql.= ", multicurrency_tx";
- $sql.= ")";
- $sql.= " VALUES ('(PROV)', ".$this->socid.", '".$this->db->idate($now)."', ".$user->id;
- $sql.= ", ".($this->fk_project>0?$this->fk_project:"null");
- $sql.= ", '".$this->db->idate($date)."'";
- $sql.= ", ".($this->source>=0 && $this->source != '' ?$this->db->escape($this->source):'null');
- $sql.= ", '".$this->db->escape($this->note_private)."'";
- $sql.= ", '".$this->db->escape($this->note_public)."'";
- $sql.= ", ".($this->ref_ext?"'".$this->db->escape($this->ref_ext)."'":"null");
- $sql.= ", ".($this->ref_client?"'".$this->db->escape($this->ref_client)."'":"null");
- $sql.= ", ".($this->ref_int?"'".$this->db->escape($this->ref_int)."'":"null");
- $sql.= ", '".$this->db->escape($this->modelpdf)."'";
- $sql.= ", ".($this->cond_reglement_id>0?$this->cond_reglement_id:"null");
- $sql.= ", ".($this->mode_reglement_id>0?$this->mode_reglement_id:"null");
- $sql.= ", ".($this->fk_account>0?$this->fk_account:'NULL');
- $sql.= ", ".($this->availability_id>0?$this->availability_id:"null");
- $sql.= ", ".($this->demand_reason_id>0?$this->demand_reason_id:"null");
- $sql.= ", ".($this->date_livraison?"'".$this->db->idate($this->date_livraison)."'":"null");
- $sql.= ", ".($this->fk_delivery_address>0?$this->fk_delivery_address:'NULL');
- $sql.= ", ".($this->shipping_method_id>0?$this->shipping_method_id:'NULL');
- $sql.= ", ".($this->warehouse_id>0?$this->warehouse_id:'NULL');
- $sql.= ", ".($this->remise_absolue>0?$this->db->escape($this->remise_absolue):'NULL');
- $sql.= ", ".($this->remise_percent>0?$this->db->escape($this->remise_percent):0);
- $sql.= ", ".(int) $this->fk_incoterms;
- $sql.= ", '".$this->db->escape($this->location_incoterms)."'";
- $sql.= ", ".$conf->entity;
+ $sql = "INSERT INTO ".MAIN_DB_PREFIX."commande (";
+ $sql.= " ref, fk_soc, date_creation, fk_user_author, fk_projet, date_commande, source, note_private, note_public, ref_ext, ref_client, ref_int";
+ $sql.= ", model_pdf, fk_cond_reglement, fk_mode_reglement, fk_account, fk_availability, fk_input_reason, date_livraison, fk_delivery_address";
+ $sql.= ", fk_shipping_method";
+ $sql.= ", fk_warehouse";
+ $sql.= ", remise_absolue, remise_percent";
+ $sql.= ", fk_incoterms, location_incoterms";
+ $sql.= ", entity";
+ $sql.= ", fk_multicurrency";
+ $sql.= ", multicurrency_code";
+ $sql.= ", multicurrency_tx";
+ $sql.= ")";
+ $sql.= " VALUES ('(PROV)', ".$this->socid.", '".$this->db->idate($now)."', ".$user->id;
+ $sql.= ", ".($this->fk_project>0?$this->fk_project:"null");
+ $sql.= ", '".$this->db->idate($date)."'";
+ $sql.= ", ".($this->source>=0 && $this->source != '' ?$this->db->escape($this->source):'null');
+ $sql.= ", '".$this->db->escape($this->note_private)."'";
+ $sql.= ", '".$this->db->escape($this->note_public)."'";
+ $sql.= ", ".($this->ref_ext?"'".$this->db->escape($this->ref_ext)."'":"null");
+ $sql.= ", ".($this->ref_client?"'".$this->db->escape($this->ref_client)."'":"null");
+ $sql.= ", ".($this->ref_int?"'".$this->db->escape($this->ref_int)."'":"null");
+ $sql.= ", '".$this->db->escape($this->modelpdf)."'";
+ $sql.= ", ".($this->cond_reglement_id>0?$this->cond_reglement_id:"null");
+ $sql.= ", ".($this->mode_reglement_id>0?$this->mode_reglement_id:"null");
+ $sql.= ", ".($this->fk_account>0?$this->fk_account:'NULL');
+ $sql.= ", ".($this->availability_id>0?$this->availability_id:"null");
+ $sql.= ", ".($this->demand_reason_id>0?$this->demand_reason_id:"null");
+ $sql.= ", ".($this->date_livraison?"'".$this->db->idate($this->date_livraison)."'":"null");
+ $sql.= ", ".($this->fk_delivery_address>0?$this->fk_delivery_address:'NULL');
+ $sql.= ", ".($this->shipping_method_id>0?$this->shipping_method_id:'NULL');
+ $sql.= ", ".($this->warehouse_id>0?$this->warehouse_id:'NULL');
+ $sql.= ", ".($this->remise_absolue>0?$this->db->escape($this->remise_absolue):'NULL');
+ $sql.= ", ".($this->remise_percent>0?$this->db->escape($this->remise_percent):0);
+ $sql.= ", ".(int) $this->fk_incoterms;
+ $sql.= ", '".$this->db->escape($this->location_incoterms)."'";
+ $sql.= ", ".$conf->entity;
$sql.= ", ".(int) $this->fk_multicurrency;
$sql.= ", '".$this->db->escape($this->multicurrency_code)."'";
$sql.= ", ".(double) $this->multicurrency_tx;
- $sql.= ")";
+ $sql.= ")";
- dol_syslog(get_class($this)."::create", LOG_DEBUG);
- $resql=$this->db->query($sql);
- if ($resql)
- {
- $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.'commande');
+ dol_syslog(get_class($this)."::create", LOG_DEBUG);
+ $resql=$this->db->query($sql);
+ if ($resql)
+ {
+ $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.'commande');
- if ($this->id)
- {
- $fk_parent_line=0;
- $num=count($this->lines);
+ if ($this->id)
+ {
+ $fk_parent_line=0;
+ $num=count($this->lines);
- /*
- * Insert products details into db
- */
- for ($i=0;$i<$num;$i++)
- {
- $line = $this->lines[$i];
+ /*
+ * Insert products details into db
+ */
+ for ($i=0;$i<$num;$i++)
+ {
+ $line = $this->lines[$i];
- // Test and convert into object this->lines[$i]. When coming from REST API, we may still have an array
- //if (! is_object($line)) $line=json_decode(json_encode($line), false); // convert recursively array into object.
- if (! is_object($line)) $line = (object) $line;
+ // Test and convert into object this->lines[$i]. When coming from REST API, we may still have an array
+ //if (! is_object($line)) $line=json_decode(json_encode($line), false); // convert recursively array into object.
+ if (! is_object($line)) $line = (object) $line;
- // Reset fk_parent_line for no child products and special product
- if (($line->product_type != 9 && empty($line->fk_parent_line)) || $line->product_type == 9) {
- $fk_parent_line = 0;
- }
+ // Reset fk_parent_line for no child products and special product
+ if (($line->product_type != 9 && empty($line->fk_parent_line)) || $line->product_type == 9) {
+ $fk_parent_line = 0;
+ }
// Complete vat rate with code
$vatrate = $line->tva_tx;
if ($line->vat_src_code && ! preg_match('/\(.*\)/', $vatrate)) $vatrate.=' ('.$line->vat_src_code.')';
- $result = $this->addline(
- $line->desc,
- $line->subprice,
- $line->qty,
- $vatrate,
- $line->localtax1_tx,
- $line->localtax2_tx,
- $line->fk_product,
- $line->remise_percent,
- $line->info_bits,
- $line->fk_remise_except,
- 'HT',
- 0,
- $line->date_start,
- $line->date_end,
- $line->product_type,
- $line->rang,
- $line->special_code,
- $fk_parent_line,
- $line->fk_fournprice,
- $line->pa_ht,
- $line->label,
- $line->array_options,
- $line->fk_unit,
- $this->element,
- $line->id
- );
- if ($result < 0)
- {
- if ($result != self::STOCK_NOT_ENOUGH_FOR_ORDER)
- {
- $this->error=$this->db->lasterror();
- dol_print_error($this->db);
- }
- $this->db->rollback();
- return -1;
- }
- // Defined the new fk_parent_line
- if ($result > 0 && $line->product_type == 9) {
- $fk_parent_line = $result;
- }
- }
-
- // update ref
- $initialref='(PROV'.$this->id.')';
- if (! empty($this->ref)) $initialref=$this->ref;
-
- $sql = 'UPDATE '.MAIN_DB_PREFIX."commande SET ref='".$this->db->escape($initialref)."' WHERE rowid=".$this->id;
- if ($this->db->query($sql))
- {
- if ($this->id)
- {
- $this->ref = $initialref;
-
- if (! empty($this->linkedObjectsIds) && empty($this->linked_objects)) // To use new linkedObjectsIds instead of old linked_objects
- {
- $this->linked_objects = $this->linkedObjectsIds; // TODO Replace linked_objects with linkedObjectsIds
- }
-
- // Add object linked
- if (! $error && $this->id && is_array($this->linked_objects) && ! empty($this->linked_objects))
- {
- foreach($this->linked_objects as $origin => $tmp_origin_id)
- {
- if (is_array($tmp_origin_id)) // New behaviour, if linked_object can have several links per type, so is something like array('contract'=>array(id1, id2, ...))
- {
- foreach($tmp_origin_id as $origin_id)
- {
- $ret = $this->add_object_linked($origin, $origin_id);
- if (! $ret)
- {
- $this->error=$this->db->lasterror();
- $error++;
- }
- }
- }
- else // Old behaviour, if linked_object has only one link per type, so is something like array('contract'=>id1))
- {
- $origin_id = $tmp_origin_id;
- $ret = $this->add_object_linked($origin, $origin_id);
- if (! $ret)
- {
- $this->error=$this->db->lasterror();
- $error++;
- }
- }
- }
- }
-
- if (! $error && $this->id && ! empty($conf->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN) && ! empty($this->origin) && ! empty($this->origin_id)) // Get contact from origin object
- {
- $originforcontact = $this->origin;
- $originidforcontact = $this->origin_id;
- if ($originforcontact == 'shipping') // shipment and order share the same contacts. If creating from shipment we take data of order
- {
- require_once DOL_DOCUMENT_ROOT . '/expedition/class/expedition.class.php';
- $exp = new Expedition($this->db);
- $exp->fetch($this->origin_id);
- $exp->fetchObjectLinked();
- if (count($exp->linkedObjectsIds['commande']) > 0)
- {
- foreach ($exp->linkedObjectsIds['commande'] as $key => $value)
- {
- $originforcontact = 'commande';
- if (is_object($value)) $originidforcontact = $value->id;
- else $originidforcontact = $value;
- break; // We take first one
- }
- }
- }
-
- $sqlcontact = "SELECT ctc.code, ctc.source, ec.fk_socpeople FROM ".MAIN_DB_PREFIX."element_contact as ec, ".MAIN_DB_PREFIX."c_type_contact as ctc";
- $sqlcontact.= " WHERE element_id = ".$originidforcontact." AND ec.fk_c_type_contact = ctc.rowid AND ctc.element = '".$originforcontact."'";
-
- $resqlcontact = $this->db->query($sqlcontact);
- if ($resqlcontact)
- {
- while($objcontact = $this->db->fetch_object($resqlcontact))
- {
- //print $objcontact->code.'-'.$objcontact->source.'-'.$objcontact->fk_socpeople."\n";
- $this->add_contact($objcontact->fk_socpeople, $objcontact->code, $objcontact->source); // May failed because of duplicate key or because code of contact type does not exists for new object
- }
- }
- else dol_print_error($resqlcontact);
- }
- }
-
- if (! $error)
- {
- $result=$this->insertExtraFields();
- if ($result < 0) $error++;
- }
-
- if (! $error && ! $notrigger)
- {
- // Call trigger
- $result=$this->call_trigger('ORDER_CREATE',$user);
- if ($result < 0) $error++;
- // End call triggers
- }
-
- if (! $error)
- {
- $this->db->commit();
- return $this->id;
- }
- else
+ $result = $this->addline(
+ $line->desc,
+ $line->subprice,
+ $line->qty,
+ $vatrate,
+ $line->localtax1_tx,
+ $line->localtax2_tx,
+ $line->fk_product,
+ $line->remise_percent,
+ $line->info_bits,
+ $line->fk_remise_except,
+ 'HT',
+ 0,
+ $line->date_start,
+ $line->date_end,
+ $line->product_type,
+ $line->rang,
+ $line->special_code,
+ $fk_parent_line,
+ $line->fk_fournprice,
+ $line->pa_ht,
+ $line->label,
+ $line->array_options,
+ $line->fk_unit,
+ $this->element,
+ $line->id
+ );
+ if ($result < 0)
{
- $this->db->rollback();
- return -1*$error;
+ if ($result != self::STOCK_NOT_ENOUGH_FOR_ORDER)
+ {
+ $this->error=$this->db->lasterror();
+ dol_print_error($this->db);
+ }
+ $this->db->rollback();
+ return -1;
}
- }
- else
+ // Defined the new fk_parent_line
+ if ($result > 0 && $line->product_type == 9) {
+ $fk_parent_line = $result;
+ }
+ }
+
+ // update ref
+ $initialref='(PROV'.$this->id.')';
+ if (! empty($this->ref)) $initialref=$this->ref;
+
+ $sql = 'UPDATE '.MAIN_DB_PREFIX."commande SET ref='".$this->db->escape($initialref)."' WHERE rowid=".$this->id;
+ if ($this->db->query($sql))
+ {
+ if ($this->id)
+ {
+ $this->ref = $initialref;
+
+ if (! empty($this->linkedObjectsIds) && empty($this->linked_objects)) // To use new linkedObjectsIds instead of old linked_objects
+ {
+ $this->linked_objects = $this->linkedObjectsIds; // TODO Replace linked_objects with linkedObjectsIds
+ }
+
+ // Add object linked
+ if (! $error && $this->id && is_array($this->linked_objects) && ! empty($this->linked_objects))
+ {
+ foreach($this->linked_objects as $origin => $tmp_origin_id)
+ {
+ if (is_array($tmp_origin_id)) // New behaviour, if linked_object can have several links per type, so is something like array('contract'=>array(id1, id2, ...))
+ {
+ foreach($tmp_origin_id as $origin_id)
+ {
+ $ret = $this->add_object_linked($origin, $origin_id);
+ if (! $ret)
+ {
+ $this->error=$this->db->lasterror();
+ $error++;
+ }
+ }
+ }
+ else // Old behaviour, if linked_object has only one link per type, so is something like array('contract'=>id1))
+ {
+ $origin_id = $tmp_origin_id;
+ $ret = $this->add_object_linked($origin, $origin_id);
+ if (! $ret)
+ {
+ $this->error=$this->db->lasterror();
+ $error++;
+ }
+ }
+ }
+ }
+
+ if (! $error && $this->id && ! empty($conf->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN) && ! empty($this->origin) && ! empty($this->origin_id)) // Get contact from origin object
+ {
+ $originforcontact = $this->origin;
+ $originidforcontact = $this->origin_id;
+ if ($originforcontact == 'shipping') // shipment and order share the same contacts. If creating from shipment we take data of order
+ {
+ require_once DOL_DOCUMENT_ROOT . '/expedition/class/expedition.class.php';
+ $exp = new Expedition($this->db);
+ $exp->fetch($this->origin_id);
+ $exp->fetchObjectLinked();
+ if (count($exp->linkedObjectsIds['commande']) > 0)
+ {
+ foreach ($exp->linkedObjectsIds['commande'] as $key => $value)
+ {
+ $originforcontact = 'commande';
+ if (is_object($value)) $originidforcontact = $value->id;
+ else $originidforcontact = $value;
+ break; // We take first one
+ }
+ }
+ }
+
+ $sqlcontact = "SELECT ctc.code, ctc.source, ec.fk_socpeople FROM ".MAIN_DB_PREFIX."element_contact as ec, ".MAIN_DB_PREFIX."c_type_contact as ctc";
+ $sqlcontact.= " WHERE element_id = ".$originidforcontact." AND ec.fk_c_type_contact = ctc.rowid AND ctc.element = '".$originforcontact."'";
+
+ $resqlcontact = $this->db->query($sqlcontact);
+ if ($resqlcontact)
+ {
+ while($objcontact = $this->db->fetch_object($resqlcontact))
+ {
+ //print $objcontact->code.'-'.$objcontact->source.'-'.$objcontact->fk_socpeople."\n";
+ $this->add_contact($objcontact->fk_socpeople, $objcontact->code, $objcontact->source); // May failed because of duplicate key or because code of contact type does not exists for new object
+ }
+ }
+ else dol_print_error($resqlcontact);
+ }
+ }
+
+ if (! $error)
+ {
+ $result=$this->insertExtraFields();
+ if ($result < 0) $error++;
+ }
+
+ if (! $error && ! $notrigger)
+ {
+ // Call trigger
+ $result=$this->call_trigger('ORDER_CREATE',$user);
+ if ($result < 0) $error++;
+ // End call triggers
+ }
+
+ if (! $error)
+ {
+ $this->db->commit();
+ return $this->id;
+ }
+ else
+ {
+ $this->db->rollback();
+ return -1*$error;
+ }
+ }
+ else
{
$this->error=$this->db->lasterror();
- $this->db->rollback();
- return -1;
- }
- }
- }
- else
+ $this->db->rollback();
+ return -1;
+ }
+ }
+ }
+ else
{
- dol_print_error($this->db);
- $this->db->rollback();
- return -1;
- }
- }
+ dol_print_error($this->db);
+ $this->db->rollback();
+ return -1;
+ }
+ }
- /**
- * Load an object from its id and create a new one in database
- *
- * @param int $socid Id of thirdparty
- * @return int New id of clone
- */
- function createFromClone($socid=0)
- {
- global $user,$hookmanager;
+ /**
+ * Load an object from its id and create a new one in database
+ *
+ * @param int $socid Id of thirdparty
+ * @return int New id of clone
+ */
+ function createFromClone($socid=0)
+ {
+ global $user,$hookmanager;
- $error=0;
+ $error=0;
- $this->context['createfromclone'] = 'createfromclone';
+ $this->context['createfromclone'] = 'createfromclone';
- $this->db->begin();
+ $this->db->begin();
// get lines so they will be clone
foreach($this->lines as $line)
$line->fetch_optionals();
- // Load source object
- $objFrom = clone $this;
+ // Load source object
+ $objFrom = clone $this;
- // Change socid if needed
- if (! empty($socid) && $socid != $this->socid)
- {
- $objsoc = new Societe($this->db);
+ // Change socid if needed
+ if (! empty($socid) && $socid != $this->socid)
+ {
+ $objsoc = new Societe($this->db);
- if ($objsoc->fetch($socid)>0)
- {
- $this->socid = $objsoc->id;
- $this->cond_reglement_id = (! empty($objsoc->cond_reglement_id) ? $objsoc->cond_reglement_id : 0);
- $this->mode_reglement_id = (! empty($objsoc->mode_reglement_id) ? $objsoc->mode_reglement_id : 0);
- $this->fk_project = 0;
- $this->fk_delivery_address = 0;
- }
+ if ($objsoc->fetch($socid)>0)
+ {
+ $this->socid = $objsoc->id;
+ $this->cond_reglement_id = (! empty($objsoc->cond_reglement_id) ? $objsoc->cond_reglement_id : 0);
+ $this->mode_reglement_id = (! empty($objsoc->mode_reglement_id) ? $objsoc->mode_reglement_id : 0);
+ $this->fk_project = 0;
+ $this->fk_delivery_address = 0;
+ }
- // TODO Change product price if multi-prices
- }
+ // TODO Change product price if multi-prices
+ }
- $this->id=0;
- $this->ref = '';
- $this->statut=self::STATUS_DRAFT;
+ $this->id=0;
+ $this->ref = '';
+ $this->statut=self::STATUS_DRAFT;
- // Clear fields
- $this->user_author_id = $user->id;
- $this->user_valid = '';
- $this->date = dol_now();
- $this->date_commande = dol_now();
- $this->date_creation = '';
- $this->date_validation = '';
- $this->ref_client = '';
+ // Clear fields
+ $this->user_author_id = $user->id;
+ $this->user_valid = '';
+ $this->date = dol_now();
+ $this->date_commande = dol_now();
+ $this->date_creation = '';
+ $this->date_validation = '';
+ $this->ref_client = '';
- // Create clone
- $result=$this->create($user);
- if ($result < 0) $error++;
+ // Create clone
+ $result=$this->create($user);
+ if ($result < 0) $error++;
- if (! $error)
- {
- // Hook of thirdparty module
- if (is_object($hookmanager))
- {
- $parameters=array('objFrom'=>$objFrom);
- $action='';
- $reshook=$hookmanager->executeHooks('createFrom',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
- if ($reshook < 0) $error++;
- }
- }
+ if (! $error)
+ {
+ // Hook of thirdparty module
+ if (is_object($hookmanager))
+ {
+ $parameters=array('objFrom'=>$objFrom);
+ $action='';
+ $reshook=$hookmanager->executeHooks('createFrom',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
+ if ($reshook < 0) $error++;
+ }
+ }
- unset($this->context['createfromclone']);
+ unset($this->context['createfromclone']);
- // End
- if (! $error)
- {
- $this->db->commit();
- return $this->id;
- }
- else
- {
- $this->db->rollback();
- return -1;
- }
- }
+ // End
+ if (! $error)
+ {
+ $this->db->commit();
+ return $this->id;
+ }
+ else
+ {
+ $this->db->rollback();
+ return -1;
+ }
+ }
- /**
- * Load an object from a proposal and create a new order into database
- *
- * @param Object $object Object source
- * @param User $user User making creation
- * @return int <0 if KO, 0 if nothing done, 1 if OK
- */
- function createFromProposal($object, User $user)
- {
- global $conf, $hookmanager;
+ /**
+ * Load an object from a proposal and create a new order into database
+ *
+ * @param Object $object Object source
+ * @param User $user User making creation
+ * @return int <0 if KO, 0 if nothing done, 1 if OK
+ */
+ function createFromProposal($object, User $user)
+ {
+ global $conf, $hookmanager;
dol_include_once('/core/class/extrafields.class.php');
- $error=0;
+ $error=0;
- $this->date_commande = dol_now();
- $this->source = 0;
+ $this->date_commande = dol_now();
+ $this->source = 0;
- $num=count($object->lines);
- for ($i = 0; $i < $num; $i++)
- {
- $line = new OrderLine($this->db);
+ $num=count($object->lines);
+ for ($i = 0; $i < $num; $i++)
+ {
+ $line = new OrderLine($this->db);
- $line->libelle = $object->lines[$i]->libelle;
- $line->label = $object->lines[$i]->label;
- $line->desc = $object->lines[$i]->desc;
- $line->price = $object->lines[$i]->price;
- $line->subprice = $object->lines[$i]->subprice;
- $line->vat_src_code = $object->lines[$i]->vat_src_code;
- $line->tva_tx = $object->lines[$i]->tva_tx;
- $line->localtax1_tx = $object->lines[$i]->localtax1_tx;
- $line->localtax2_tx = $object->lines[$i]->localtax2_tx;
- $line->qty = $object->lines[$i]->qty;
- $line->fk_remise_except = $object->lines[$i]->fk_remise_except;
- $line->remise_percent = $object->lines[$i]->remise_percent;
- $line->fk_product = $object->lines[$i]->fk_product;
- $line->info_bits = $object->lines[$i]->info_bits;
- $line->product_type = $object->lines[$i]->product_type;
- $line->rang = $object->lines[$i]->rang;
- $line->special_code = $object->lines[$i]->special_code;
- $line->fk_parent_line = $object->lines[$i]->fk_parent_line;
- $line->fk_unit = $object->lines[$i]->fk_unit;
+ $line->libelle = $object->lines[$i]->libelle;
+ $line->label = $object->lines[$i]->label;
+ $line->desc = $object->lines[$i]->desc;
+ $line->price = $object->lines[$i]->price;
+ $line->subprice = $object->lines[$i]->subprice;
+ $line->vat_src_code = $object->lines[$i]->vat_src_code;
+ $line->tva_tx = $object->lines[$i]->tva_tx;
+ $line->localtax1_tx = $object->lines[$i]->localtax1_tx;
+ $line->localtax2_tx = $object->lines[$i]->localtax2_tx;
+ $line->qty = $object->lines[$i]->qty;
+ $line->fk_remise_except = $object->lines[$i]->fk_remise_except;
+ $line->remise_percent = $object->lines[$i]->remise_percent;
+ $line->fk_product = $object->lines[$i]->fk_product;
+ $line->info_bits = $object->lines[$i]->info_bits;
+ $line->product_type = $object->lines[$i]->product_type;
+ $line->rang = $object->lines[$i]->rang;
+ $line->special_code = $object->lines[$i]->special_code;
+ $line->fk_parent_line = $object->lines[$i]->fk_parent_line;
+ $line->fk_unit = $object->lines[$i]->fk_unit;
- $line->date_start = $object->lines[$i]->date_start;
- $line->date_end = $object->lines[$i]->date_end;
+ $line->date_start = $object->lines[$i]->date_start;
+ $line->date_end = $object->lines[$i]->date_end;
$line->fk_fournprice = $object->lines[$i]->fk_fournprice;
$marginInfos = getMarginInfos($object->lines[$i]->subprice, $object->lines[$i]->remise_percent, $object->lines[$i]->tva_tx, $object->lines[$i]->localtax1_tx, $object->lines[$i]->localtax2_tx, $object->lines[$i]->fk_fournprice, $object->lines[$i]->pa_ht);
@@ -1143,34 +1176,34 @@ class Commande extends CommonOrder
$line->marge_tx = $marginInfos[1];
$line->marque_tx = $marginInfos[2];
- // get extrafields from original line
+ // get extrafields from original line
$object->lines[$i]->fetch_optionals();
foreach($object->lines[$i]->array_options as $options_key => $value)
$line->array_options[$options_key] = $value;
- $this->lines[$i] = $line;
- }
+ $this->lines[$i] = $line;
+ }
- $this->socid = $object->socid;
- $this->fk_project = $object->fk_project;
- $this->cond_reglement_id = $object->cond_reglement_id;
- $this->mode_reglement_id = $object->mode_reglement_id;
- $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;
- $this->shipping_method_id = $object->shipping_method_id;
- $this->warehouse_id = $object->warehouse_id;
- $this->fk_delivery_address = $object->fk_delivery_address;
- $this->contact_id = $object->contactid;
- $this->ref_client = $object->ref_client;
- $this->note_private = $object->note_private;
- $this->note_public = $object->note_public;
+ $this->socid = $object->socid;
+ $this->fk_project = $object->fk_project;
+ $this->cond_reglement_id = $object->cond_reglement_id;
+ $this->mode_reglement_id = $object->mode_reglement_id;
+ $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;
+ $this->shipping_method_id = $object->shipping_method_id;
+ $this->warehouse_id = $object->warehouse_id;
+ $this->fk_delivery_address = $object->fk_delivery_address;
+ $this->contact_id = $object->contactid;
+ $this->ref_client = $object->ref_client;
+ $this->note_private = $object->note_private;
+ $this->note_public = $object->note_public;
- $this->origin = $object->element;
- $this->origin_id = $object->id;
+ $this->origin = $object->element;
+ $this->origin_id = $object->id;
- // get extrafields from original line
+ // get extrafields from original line
$object->fetch_optionals($object->id);
$e = new ExtraFields($this->db);
@@ -1181,129 +1214,129 @@ class Commande extends CommonOrder
$this->array_options[$options_key] = $value;
}
}
- // Possibility to add external linked objects with hooks
- $this->linked_objects[$this->origin] = $this->origin_id;
- if (is_array($object->other_linked_objects) && ! empty($object->other_linked_objects))
- {
- $this->linked_objects = array_merge($this->linked_objects, $object->other_linked_objects);
- }
+ // Possibility to add external linked objects with hooks
+ $this->linked_objects[$this->origin] = $this->origin_id;
+ if (is_array($object->other_linked_objects) && ! empty($object->other_linked_objects))
+ {
+ $this->linked_objects = array_merge($this->linked_objects, $object->other_linked_objects);
+ }
- $ret = $this->create($user);
+ $ret = $this->create($user);
- if ($ret > 0)
- {
- // Actions hooked (by external module)
- $hookmanager->initHooks(array('orderdao'));
+ if ($ret > 0)
+ {
+ // Actions hooked (by external module)
+ $hookmanager->initHooks(array('orderdao'));
- $parameters=array('objFrom'=>$object);
- $action='';
- $reshook=$hookmanager->executeHooks('createFrom',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
- if ($reshook < 0) $error++;
+ $parameters=array('objFrom'=>$object);
+ $action='';
+ $reshook=$hookmanager->executeHooks('createFrom',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
+ if ($reshook < 0) $error++;
- if (! $error)
- {
- // Ne pas passer par la commande provisoire
- if ($conf->global->COMMANDE_VALID_AFTER_CLOSE_PROPAL == 1)
- {
- $this->fetch($ret);
- $this->valid($user);
- }
- return $ret;
- }
- else return -1;
- }
- else return -1;
- }
+ if (! $error)
+ {
+ // Ne pas passer par la commande provisoire
+ if ($conf->global->COMMANDE_VALID_AFTER_CLOSE_PROPAL == 1)
+ {
+ $this->fetch($ret);
+ $this->valid($user);
+ }
+ return $ret;
+ }
+ else return -1;
+ }
+ else return -1;
+ }
- /**
- * Add an order line into database (linked to product/service or not)
- *
- * @param string $desc Description of line
- * @param float $pu_ht Unit price (without tax)
- * @param float $qty Quantite
- * @param float $txtva Force Vat rate, -1 for auto (Can contain the vat_src_code too with syntax '9.9 (CODE)')
- * @param float $txlocaltax1 Local tax 1 rate (deprecated, use instead txtva with code inside)
- * @param float $txlocaltax2 Local tax 2 rate (deprecated, use instead txtva with code inside)
- * @param int $fk_product Id of product
- * @param float $remise_percent Pourcentage de remise de la ligne
- * @param int $info_bits Bits de type de lignes
- * @param int $fk_remise_except Id remise
- * @param string $price_base_type HT or TTC
- * @param float $pu_ttc Prix unitaire TTC
- * @param int $date_start Start date of the line - Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html)
- * @param int $date_end End date of the line - Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html)
- * @param int $type Type of line (0=product, 1=service). Not used if fk_product is defined, the type of product is used.
- * @param int $rang Position of line
- * @param int $special_code Special code (also used by externals modules!)
- * @param int $fk_parent_line Parent line
- * @param int $fk_fournprice Id supplier price
- * @param int $pa_ht Buying price (without tax)
- * @param string $label Label
+ /**
+ * Add an order line into database (linked to product/service or not)
+ *
+ * @param string $desc Description of line
+ * @param float $pu_ht Unit price (without tax)
+ * @param float $qty Quantite
+ * @param float $txtva Force Vat rate, -1 for auto (Can contain the vat_src_code too with syntax '9.9 (CODE)')
+ * @param float $txlocaltax1 Local tax 1 rate (deprecated, use instead txtva with code inside)
+ * @param float $txlocaltax2 Local tax 2 rate (deprecated, use instead txtva with code inside)
+ * @param int $fk_product Id of product
+ * @param float $remise_percent Pourcentage de remise de la ligne
+ * @param int $info_bits Bits de type de lignes
+ * @param int $fk_remise_except Id remise
+ * @param string $price_base_type HT or TTC
+ * @param float $pu_ttc Prix unitaire TTC
+ * @param int $date_start Start date of the line - Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html)
+ * @param int $date_end End date of the line - Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html)
+ * @param int $type Type of line (0=product, 1=service). Not used if fk_product is defined, the type of product is used.
+ * @param int $rang Position of line
+ * @param int $special_code Special code (also used by externals modules!)
+ * @param int $fk_parent_line Parent line
+ * @param int $fk_fournprice Id supplier price
+ * @param int $pa_ht Buying price (without tax)
+ * @param string $label Label
* @param array $array_options extrafields array. Example array('options_codeforfield1'=>'valueforfield1', 'options_codeforfield2'=>'valueforfield2', ...)
- * @param string $fk_unit Code of the unit to use. Null to use the default one
- * @param string $origin 'order', ...
- * @param int $origin_id Id of origin object
+ * @param string $fk_unit Code of the unit to use. Null to use the default one
+ * @param string $origin 'order', ...
+ * @param int $origin_id Id of origin object
* @param double $pu_ht_devise Unit price in currency
- * @return int >0 if OK, <0 if KO
- *
- * @see add_product
- *
- * Les parametres sont deja cense etre juste et avec valeurs finales a l'appel
- * de cette methode. Aussi, pour le taux tva, il doit deja avoir ete defini
- * par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,produit)
- * et le desc doit deja avoir la bonne valeur (a l'appelant de gerer le multilangue)
- */
+ * @return int >0 if OK, <0 if KO
+ *
+ * @see add_product
+ *
+ * Les parametres sont deja cense etre juste et avec valeurs finales a l'appel
+ * de cette methode. Aussi, pour le taux tva, il doit deja avoir ete defini
+ * par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,produit)
+ * et le desc doit deja avoir la bonne valeur (a l'appelant de gerer le multilangue)
+ */
function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $info_bits=0, $fk_remise_except=0, $price_base_type='HT', $pu_ttc=0, $date_start='', $date_end='', $type=0, $rang=-1, $special_code=0, $fk_parent_line=0, $fk_fournprice=null, $pa_ht=0, $label='',$array_options=0, $fk_unit=null, $origin='', $origin_id=0, $pu_ht_devise = 0)
- {
- global $mysoc, $conf, $langs, $user;
+ {
+ global $mysoc, $conf, $langs, $user;
$logtext = "::addline commandeid=$this->id, desc=$desc, pu_ht=$pu_ht, qty=$qty, txtva=$txtva, fk_product=$fk_product, remise_percent=$remise_percent";
$logtext.= ", info_bits=$info_bits, fk_remise_except=$fk_remise_except, price_base_type=$price_base_type, pu_ttc=$pu_ttc, date_start=$date_start";
$logtext.= ", date_end=$date_end, type=$type special_code=$special_code, fk_unit=$fk_unit, origin=$origin, origin_id=$origin_id, pu_ht_devise=$pu_ht_devise";
- dol_syslog(get_class($this).$logtext, LOG_DEBUG);
+ dol_syslog(get_class($this).$logtext, LOG_DEBUG);
- include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
+ include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
- // Clean parameters
- if (empty($remise_percent)) $remise_percent=0;
- if (empty($qty)) $qty=0;
- if (empty($info_bits)) $info_bits=0;
- if (empty($rang)) $rang=0;
- if (empty($txtva)) $txtva=0;
- if (empty($txlocaltax1)) $txlocaltax1=0;
- if (empty($txlocaltax2)) $txlocaltax2=0;
- if (empty($fk_parent_line) || $fk_parent_line < 0) $fk_parent_line=0;
- if (empty($this->fk_multicurrency)) $this->fk_multicurrency=0;
+ // Clean parameters
+ if (empty($remise_percent)) $remise_percent=0;
+ if (empty($qty)) $qty=0;
+ if (empty($info_bits)) $info_bits=0;
+ if (empty($rang)) $rang=0;
+ if (empty($txtva)) $txtva=0;
+ if (empty($txlocaltax1)) $txlocaltax1=0;
+ if (empty($txlocaltax2)) $txlocaltax2=0;
+ if (empty($fk_parent_line) || $fk_parent_line < 0) $fk_parent_line=0;
+ if (empty($this->fk_multicurrency)) $this->fk_multicurrency=0;
- $remise_percent=price2num($remise_percent);
- $qty=price2num($qty);
- $pu_ht=price2num($pu_ht);
- $pu_ht_devise=price2num($pu_ht_devise);
- $pu_ttc=price2num($pu_ttc);
- $pa_ht=price2num($pa_ht);
- $txtva = price2num($txtva);
- $txlocaltax1 = price2num($txlocaltax1);
- $txlocaltax2 = price2num($txlocaltax2);
- if ($price_base_type=='HT')
- {
- $pu=$pu_ht;
- }
- else
- {
- $pu=$pu_ttc;
- }
- $label=trim($label);
- $desc=trim($desc);
+ $remise_percent=price2num($remise_percent);
+ $qty=price2num($qty);
+ $pu_ht=price2num($pu_ht);
+ $pu_ht_devise=price2num($pu_ht_devise);
+ $pu_ttc=price2num($pu_ttc);
+ $pa_ht=price2num($pa_ht);
+ $txtva = price2num($txtva);
+ $txlocaltax1 = price2num($txlocaltax1);
+ $txlocaltax2 = price2num($txlocaltax2);
+ if ($price_base_type=='HT')
+ {
+ $pu=$pu_ht;
+ }
+ else
+ {
+ $pu=$pu_ttc;
+ }
+ $label=trim($label);
+ $desc=trim($desc);
- // Check parameters
- if ($type < 0) return -1;
+ // Check parameters
+ if ($type < 0) return -1;
- if ($this->statut == self::STATUS_DRAFT)
- {
- $this->db->begin();
+ if ($this->statut == self::STATUS_DRAFT)
+ {
+ $this->db->begin();
- $product_type=$type;
+ $product_type=$type;
if (!empty($fk_product))
{
$product=new Product($this->db);
@@ -1312,105 +1345,105 @@ class Commande extends CommonOrder
if (! empty($conf->global->STOCK_MUST_BE_ENOUGH_FOR_ORDER) && $product_type == 0 && $product->stock_reel < $qty)
{
- $langs->load("errors");
- $this->error=$langs->trans('ErrorStockIsNotEnoughToAddProductOnOrder', $product->ref);
+ $langs->load("errors");
+ $this->error=$langs->trans('ErrorStockIsNotEnoughToAddProductOnOrder', $product->ref);
dol_syslog(get_class($this)."::addline error=Product ".$product->ref.": ".$this->error, LOG_ERR);
$this->db->rollback();
return self::STOCK_NOT_ENOUGH_FOR_ORDER;
}
}
// Calcul du total TTC et de la TVA pour la ligne a partir de
- // qty, pu, remise_percent et txtva
- // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker
- // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva.
+ // qty, pu, remise_percent et txtva
+ // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker
+ // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva.
- $localtaxes_type=getLocalTaxesFromRate($txtva,0,$this->thirdparty,$mysoc);
+ $localtaxes_type=getLocalTaxesFromRate($txtva,0,$this->thirdparty,$mysoc);
- // Clean vat code
- $vat_src_code='';
- if (preg_match('/\((.*)\)/', $txtva, $reg))
- {
- $vat_src_code = $reg[1];
- $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate.
- }
+ // Clean vat code
+ $vat_src_code='';
+ if (preg_match('/\((.*)\)/', $txtva, $reg))
+ {
+ $vat_src_code = $reg[1];
+ $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate.
+ }
- $tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $product_type, $mysoc, $localtaxes_type, 100, $this->multicurrency_tx, $pu_ht_devise);
+ $tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $product_type, $mysoc, $localtaxes_type, 100, $this->multicurrency_tx, $pu_ht_devise);
- /*var_dump($txlocaltax1);
- var_dump($txlocaltax2);
- var_dump($localtaxes_type);
- var_dump($tabprice);
- var_dump($tabprice[9]);
- var_dump($tabprice[10]);
- exit;*/
+ /*var_dump($txlocaltax1);
+ var_dump($txlocaltax2);
+ var_dump($localtaxes_type);
+ var_dump($tabprice);
+ var_dump($tabprice[9]);
+ var_dump($tabprice[10]);
+ exit;*/
- $total_ht = $tabprice[0];
- $total_tva = $tabprice[1];
- $total_ttc = $tabprice[2];
- $total_localtax1 = $tabprice[9];
- $total_localtax2 = $tabprice[10];
+ $total_ht = $tabprice[0];
+ $total_tva = $tabprice[1];
+ $total_ttc = $tabprice[2];
+ $total_localtax1 = $tabprice[9];
+ $total_localtax2 = $tabprice[10];
$pu_ht = $tabprice[3];
// MultiCurrency
$multicurrency_total_ht = $tabprice[16];
- $multicurrency_total_tva = $tabprice[17];
- $multicurrency_total_ttc = $tabprice[18];
+ $multicurrency_total_tva = $tabprice[17];
+ $multicurrency_total_ttc = $tabprice[18];
$pu_ht_devise = $tabprice[19];
- // Rang to use
- $rangtouse = $rang;
- if ($rangtouse == -1)
- {
- $rangmax = $this->line_max($fk_parent_line);
- $rangtouse = $rangmax + 1;
- }
+ // Rang to use
+ $rangtouse = $rang;
+ if ($rangtouse == -1)
+ {
+ $rangmax = $this->line_max($fk_parent_line);
+ $rangtouse = $rangmax + 1;
+ }
- // TODO A virer
- // Anciens indicateurs: $price, $remise (a ne plus utiliser)
- $price = $pu;
- $remise = 0;
- if ($remise_percent > 0)
- {
- $remise = round(($pu * $remise_percent / 100), 2);
- $price = $pu - $remise;
- }
+ // TODO A virer
+ // Anciens indicateurs: $price, $remise (a ne plus utiliser)
+ $price = $pu;
+ $remise = 0;
+ if ($remise_percent > 0)
+ {
+ $remise = round(($pu * $remise_percent / 100), 2);
+ $price = $pu - $remise;
+ }
- // Insert line
- $this->line=new OrderLine($this->db);
+ // Insert line
+ $this->line=new OrderLine($this->db);
- $this->line->context = $this->context;
+ $this->line->context = $this->context;
- $this->line->fk_commande=$this->id;
- $this->line->label=$label;
- $this->line->desc=$desc;
- $this->line->qty=$qty;
+ $this->line->fk_commande=$this->id;
+ $this->line->label=$label;
+ $this->line->desc=$desc;
+ $this->line->qty=$qty;
- $this->line->vat_src_code=$vat_src_code;
- $this->line->tva_tx=$txtva;
- $this->line->localtax1_tx=($total_localtax1?$localtaxes_type[1]:0);
- $this->line->localtax2_tx=($total_localtax2?$localtaxes_type[3]:0);
- $this->line->localtax1_type=$localtaxes_type[0];
- $this->line->localtax2_type=$localtaxes_type[2];
- $this->line->fk_product=$fk_product;
+ $this->line->vat_src_code=$vat_src_code;
+ $this->line->tva_tx=$txtva;
+ $this->line->localtax1_tx=($total_localtax1?$localtaxes_type[1]:0);
+ $this->line->localtax2_tx=($total_localtax2?$localtaxes_type[3]:0);
+ $this->line->localtax1_type=$localtaxes_type[0];
+ $this->line->localtax2_type=$localtaxes_type[2];
+ $this->line->fk_product=$fk_product;
$this->line->product_type=$product_type;
- $this->line->fk_remise_except=$fk_remise_except;
- $this->line->remise_percent=$remise_percent;
- $this->line->subprice=$pu_ht;
- $this->line->rang=$rangtouse;
- $this->line->info_bits=$info_bits;
- $this->line->total_ht=$total_ht;
- $this->line->total_tva=$total_tva;
- $this->line->total_localtax1=$total_localtax1;
- $this->line->total_localtax2=$total_localtax2;
- $this->line->total_ttc=$total_ttc;
- $this->line->special_code=$special_code;
- $this->line->origin=$origin;
- $this->line->origin_id=$origin_id;
- $this->line->fk_parent_line=$fk_parent_line;
- $this->line->fk_unit=$fk_unit;
+ $this->line->fk_remise_except=$fk_remise_except;
+ $this->line->remise_percent=$remise_percent;
+ $this->line->subprice=$pu_ht;
+ $this->line->rang=$rangtouse;
+ $this->line->info_bits=$info_bits;
+ $this->line->total_ht=$total_ht;
+ $this->line->total_tva=$total_tva;
+ $this->line->total_localtax1=$total_localtax1;
+ $this->line->total_localtax2=$total_localtax2;
+ $this->line->total_ttc=$total_ttc;
+ $this->line->special_code=$special_code;
+ $this->line->origin=$origin;
+ $this->line->origin_id=$origin_id;
+ $this->line->fk_parent_line=$fk_parent_line;
+ $this->line->fk_unit=$fk_unit;
- $this->line->date_start=$date_start;
- $this->line->date_end=$date_end;
+ $this->line->date_start=$date_start;
+ $this->line->date_end=$date_end;
$this->line->fk_fournprice = $fk_fournprice;
$this->line->pa_ht = $pa_ht;
@@ -1420,187 +1453,190 @@ class Commande extends CommonOrder
$this->line->multicurrency_code = $this->multicurrency_code;
$this->line->multicurrency_subprice = $pu_ht_devise;
$this->line->multicurrency_total_ht = $multicurrency_total_ht;
- $this->line->multicurrency_total_tva = $multicurrency_total_tva;
- $this->line->multicurrency_total_ttc = $multicurrency_total_ttc;
+ $this->line->multicurrency_total_tva = $multicurrency_total_tva;
+ $this->line->multicurrency_total_ttc = $multicurrency_total_ttc;
- // TODO Ne plus utiliser
- $this->line->price=$price;
- $this->line->remise=$remise;
+ // TODO Ne plus utiliser
+ $this->line->price=$price;
+ $this->line->remise=$remise;
if (is_array($array_options) && count($array_options)>0) {
$this->line->array_options=$array_options;
}
- $result=$this->line->insert($user);
- if ($result > 0)
- {
- // Reorder if child line
- if (! empty($fk_parent_line)) $this->line_order(true,'DESC');
+ $result=$this->line->insert($user);
+ if ($result > 0)
+ {
+ // Reorder if child line
+ if (! empty($fk_parent_line)) $this->line_order(true,'DESC');
- // Mise a jour informations denormalisees au niveau de la commande meme
- $result=$this->update_price(1,'auto',0,$mysoc); // This method is designed to add line from user input so total calculation must be done using 'auto' mode.
- if ($result > 0)
- {
- $this->db->commit();
- return $this->line->rowid;
- }
- else
- {
- $this->db->rollback();
- return -1;
- }
- }
- else
- {
- $this->error=$this->line->error;
- dol_syslog(get_class($this)."::addline error=".$this->error, LOG_ERR);
- $this->db->rollback();
- return -2;
- }
- }
+ // Mise a jour informations denormalisees au niveau de la commande meme
+ $result=$this->update_price(1,'auto',0,$mysoc); // This method is designed to add line from user input so total calculation must be done using 'auto' mode.
+ if ($result > 0)
+ {
+ $this->db->commit();
+ return $this->line->rowid;
+ }
+ else
+ {
+ $this->db->rollback();
+ return -1;
+ }
+ }
+ else
+ {
+ $this->error=$this->line->error;
+ dol_syslog(get_class($this)."::addline error=".$this->error, LOG_ERR);
+ $this->db->rollback();
+ return -2;
+ }
+ }
else
{
- dol_syslog(get_class($this)."::addline status of order must be Draft to allow use of ->addline()", LOG_ERR);
+ dol_syslog(get_class($this)."::addline status of order must be Draft to allow use of ->addline()", LOG_ERR);
return -3;
- }
- }
+ }
+ }
- /**
- * Add line into array
- * $this->client must be loaded
- *
- * @param int $idproduct Product Id
- * @param float $qty Quantity
- * @param float $remise_percent Product discount relative
- * @param int $date_start Start date of the line - Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html)
- * @param int $date_end End date of the line - Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html)
- * @return void
- *
- * TODO Remplacer les appels a cette fonction par generation objet Ligne
- * insere dans tableau $this->products
- */
- function add_product($idproduct, $qty, $remise_percent=0.0, $date_start='', $date_end='')
- {
- global $conf, $mysoc;
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
+ /**
+ * Add line into array
+ * $this->client must be loaded
+ *
+ * @param int $idproduct Product Id
+ * @param float $qty Quantity
+ * @param float $remise_percent Product discount relative
+ * @param int $date_start Start date of the line - Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html)
+ * @param int $date_end End date of the line - Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html)
+ * @return void
+ *
+ * TODO Remplacer les appels a cette fonction par generation objet Ligne
+ * insere dans tableau $this->products
+ */
+ function add_product($idproduct, $qty, $remise_percent=0.0, $date_start='', $date_end='')
+ {
+ // phpcs:enable
+ global $conf, $mysoc;
- if (! $qty) $qty = 1;
+ if (! $qty) $qty = 1;
- if ($idproduct > 0)
- {
- $prod=new Product($this->db);
- $prod->fetch($idproduct);
+ if ($idproduct > 0)
+ {
+ $prod=new Product($this->db);
+ $prod->fetch($idproduct);
- $tva_tx = get_default_tva($mysoc,$this->thirdparty,$prod->id);
- $tva_npr = get_default_npr($mysoc,$this->thirdparty,$prod->id);
- if (empty($tva_tx)) $tva_npr=0;
- $vat_src_code = ''; // May be defined into tva_tx
+ $tva_tx = get_default_tva($mysoc,$this->thirdparty,$prod->id);
+ $tva_npr = get_default_npr($mysoc,$this->thirdparty,$prod->id);
+ if (empty($tva_tx)) $tva_npr=0;
+ $vat_src_code = ''; // May be defined into tva_tx
- $localtax1_tx=get_localtax($tva_tx,1,$this->thirdparty,$mysoc,$tva_npr);
- $localtax2_tx=get_localtax($tva_tx,2,$this->thirdparty,$mysoc,$tva_npr);
+ $localtax1_tx=get_localtax($tva_tx,1,$this->thirdparty,$mysoc,$tva_npr);
+ $localtax2_tx=get_localtax($tva_tx,2,$this->thirdparty,$mysoc,$tva_npr);
- // multiprix
- if($conf->global->PRODUIT_MULTIPRICES && $this->thirdparty->price_level)
- $price = $prod->multiprices[$this->thirdparty->price_level];
- else
- $price = $prod->price;
+ // multiprix
+ if($conf->global->PRODUIT_MULTIPRICES && $this->thirdparty->price_level) {
+ $price = $prod->multiprices[$this->thirdparty->price_level];
+ } else {
+ $price = $prod->price;
+ }
- $line=new OrderLine($this->db);
+ $line=new OrderLine($this->db);
- $line->context = $this->context;
+ $line->context = $this->context;
- $line->fk_product=$idproduct;
- $line->desc=$prod->description;
- $line->qty=$qty;
- $line->subprice=$price;
- $line->remise_percent=$remise_percent;
- $line->vat_src_code=$vat_src_code;
- $line->tva_tx=$tva_tx;
- $line->localtax1_tx=$localtax1_tx;
- $line->localtax2_tx=$localtax2_tx;
- $line->ref=$prod->ref;
- $line->libelle=$prod->label;
- $line->product_desc=$prod->description;
- $line->fk_unit=$prod->fk_unit;
+ $line->fk_product=$idproduct;
+ $line->desc=$prod->description;
+ $line->qty=$qty;
+ $line->subprice=$price;
+ $line->remise_percent=$remise_percent;
+ $line->vat_src_code=$vat_src_code;
+ $line->tva_tx=$tva_tx;
+ $line->localtax1_tx=$localtax1_tx;
+ $line->localtax2_tx=$localtax2_tx;
+ $line->ref=$prod->ref;
+ $line->libelle=$prod->label;
+ $line->product_desc=$prod->description;
+ $line->fk_unit=$prod->fk_unit;
- // Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html)
- // Save the start and end date of the line in the object
- if ($date_start) { $line->date_start = $date_start; }
- if ($date_end) { $line->date_end = $date_end; }
+ // Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html)
+ // Save the start and end date of the line in the object
+ if ($date_start) { $line->date_start = $date_start; }
+ if ($date_end) { $line->date_end = $date_end; }
- $this->lines[] = $line;
+ $this->lines[] = $line;
- /** POUR AJOUTER AUTOMATIQUEMENT LES SOUSPRODUITS a LA COMMANDE
- if (! empty($conf->global->PRODUIT_SOUSPRODUITS))
- {
- $prod = new Product($this->db);
- $prod->fetch($idproduct);
- $prod -> get_sousproduits_arbo();
- $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]);
+ /** POUR AJOUTER AUTOMATIQUEMENT LES SOUSPRODUITS a LA COMMANDE
+ if (! empty($conf->global->PRODUIT_SOUSPRODUITS))
+ {
+ $prod = new Product($this->db);
+ $prod->fetch($idproduct);
+ $prod -> get_sousproduits_arbo();
+ $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]);
- }
- }
+ }
+ }
- }
- **/
- }
- }
+ }
+ **/
+ }
+ }
- /**
- * Get object and lines from database
- *
- * @param int $id Id of object to load
- * @param string $ref Ref of object
- * @param string $ref_ext External reference of object
- * @param string $ref_int Internal reference of other object
- * @return int >0 if OK, <0 if KO, 0 if not found
- */
- function fetch($id, $ref='', $ref_ext='', $ref_int='')
- {
+ /**
+ * Get object and lines from database
+ *
+ * @param int $id Id of object to load
+ * @param string $ref Ref of object
+ * @param string $ref_ext External reference of object
+ * @param string $ref_int Internal reference of other object
+ * @return int >0 if OK, <0 if KO, 0 if not found
+ */
+ function fetch($id, $ref='', $ref_ext='', $ref_int='')
+ {
- // Check parameters
- if (empty($id) && empty($ref) && empty($ref_ext) && empty($ref_int)) return -1;
+ // Check parameters
+ if (empty($id) && empty($ref) && empty($ref_ext) && empty($ref_int)) return -1;
- $sql = 'SELECT c.rowid, c.entity, c.date_creation, c.ref, c.fk_soc, c.fk_user_author, c.fk_user_valid, c.fk_statut';
- $sql.= ', c.amount_ht, c.total_ht, c.total_ttc, c.tva as total_tva, c.localtax1 as total_localtax1, c.localtax2 as total_localtax2, c.fk_cond_reglement, c.fk_mode_reglement, c.fk_availability, c.fk_input_reason';
- $sql.= ', c.fk_account';
- $sql.= ', c.date_commande';
- $sql.= ', c.date_livraison';
- $sql.= ', c.fk_shipping_method';
- $sql.= ', c.fk_warehouse';
- $sql.= ', c.fk_projet, c.remise_percent, c.remise, c.remise_absolue, c.source, c.facture as billed';
- $sql.= ', c.note_private, c.note_public, c.ref_client, c.ref_ext, c.ref_int, c.model_pdf, c.last_main_doc, c.fk_delivery_address, c.extraparams';
- $sql.= ', c.fk_incoterms, c.location_incoterms';
+ $sql = 'SELECT c.rowid, c.entity, c.date_creation, c.ref, c.fk_soc, c.fk_user_author, c.fk_user_valid, c.fk_statut';
+ $sql.= ', c.amount_ht, c.total_ht, c.total_ttc, c.tva as total_tva, c.localtax1 as total_localtax1, c.localtax2 as total_localtax2, c.fk_cond_reglement, c.fk_mode_reglement, c.fk_availability, c.fk_input_reason';
+ $sql.= ', c.fk_account';
+ $sql.= ', c.date_commande';
+ $sql.= ', c.date_livraison';
+ $sql.= ', c.fk_shipping_method';
+ $sql.= ', c.fk_warehouse';
+ $sql.= ', c.fk_projet, c.remise_percent, c.remise, c.remise_absolue, c.source, c.facture as billed';
+ $sql.= ', c.note_private, c.note_public, c.ref_client, c.ref_ext, c.ref_int, c.model_pdf, c.last_main_doc, c.fk_delivery_address, c.extraparams';
+ $sql.= ', c.fk_incoterms, c.location_incoterms';
$sql.= ", c.fk_multicurrency, c.multicurrency_code, c.multicurrency_tx, c.multicurrency_total_ht, c.multicurrency_total_tva, c.multicurrency_total_ttc";
- $sql.= ", i.libelle as libelle_incoterms";
- $sql.= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle';
- $sql.= ', cr.code as cond_reglement_code, cr.libelle as cond_reglement_libelle, cr.libelle_facture as cond_reglement_libelle_doc';
- $sql.= ', ca.code as availability_code, ca.label as availability_label';
- $sql.= ', dr.code as demand_reason_code';
- $sql.= ' FROM '.MAIN_DB_PREFIX.'commande as c';
- $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as cr ON c.fk_cond_reglement = cr.rowid';
- $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON c.fk_mode_reglement = p.id';
- $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_availability as ca ON c.fk_availability = ca.rowid';
- $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_input_reason as dr ON c.fk_input_reason = ca.rowid';
+ $sql.= ", i.libelle as libelle_incoterms";
+ $sql.= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle';
+ $sql.= ', cr.code as cond_reglement_code, cr.libelle as cond_reglement_libelle, cr.libelle_facture as cond_reglement_libelle_doc';
+ $sql.= ', ca.code as availability_code, ca.label as availability_label';
+ $sql.= ', dr.code as demand_reason_code';
+ $sql.= ' FROM '.MAIN_DB_PREFIX.'commande as c';
+ $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as cr ON c.fk_cond_reglement = cr.rowid';
+ $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON c.fk_mode_reglement = p.id';
+ $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_availability as ca ON c.fk_availability = ca.rowid';
+ $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_input_reason as dr ON c.fk_input_reason = ca.rowid';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON c.fk_incoterms = i.rowid';
if ($id) $sql.= " WHERE c.rowid=".$id;
else $sql.= " WHERE c.entity IN (".getEntity('commande').")"; // Dont't use entity if you use rowid
- if ($ref) $sql.= " AND c.ref='".$this->db->escape($ref)."'";
- if ($ref_ext) $sql.= " AND c.ref_ext='".$this->db->escape($ref_ext)."'";
- if ($ref_int) $sql.= " AND c.ref_int='".$this->db->escape($ref_int)."'";
+ if ($ref) $sql.= " AND c.ref='".$this->db->escape($ref)."'";
+ if ($ref_ext) $sql.= " AND c.ref_ext='".$this->db->escape($ref_ext)."'";
+ if ($ref_int) $sql.= " AND c.ref_int='".$this->db->escape($ref_int)."'";
- dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
- $result = $this->db->query($sql);
+ dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
+ $result = $this->db->query($sql);
if ($result)
{
$obj = $this->db->fetch_object($result);
@@ -1609,50 +1645,50 @@ class Commande extends CommonOrder
$this->id = $obj->rowid;
$this->entity = $obj->entity;
- $this->ref = $obj->ref;
- $this->ref_client = $obj->ref_client;
- $this->ref_customer = $obj->ref_client;
- $this->ref_ext = $obj->ref_ext;
- $this->ref_int = $obj->ref_int;
- $this->socid = $obj->fk_soc;
- $this->statut = $obj->fk_statut;
- $this->user_author_id = $obj->fk_user_author;
- $this->user_valid = $obj->fk_user_valid;
- $this->total_ht = $obj->total_ht;
- $this->total_tva = $obj->total_tva;
- $this->total_localtax1 = $obj->total_localtax1;
- $this->total_localtax2 = $obj->total_localtax2;
- $this->total_ttc = $obj->total_ttc;
- $this->date = $this->db->jdate($obj->date_commande);
- $this->date_commande = $this->db->jdate($obj->date_commande);
- $this->remise = $obj->remise;
- $this->remise_percent = $obj->remise_percent;
- $this->remise_absolue = $obj->remise_absolue;
- $this->source = $obj->source;
- $this->billed = $obj->billed;
- $this->note = $obj->note_private; // deprecated
- $this->note_private = $obj->note_private;
- $this->note_public = $obj->note_public;
- $this->fk_project = $obj->fk_projet;
- $this->modelpdf = $obj->model_pdf;
- $this->last_main_doc = $obj->last_main_doc;
- $this->mode_reglement_id = $obj->fk_mode_reglement;
- $this->mode_reglement_code = $obj->mode_reglement_code;
- $this->mode_reglement = $obj->mode_reglement_libelle;
- $this->cond_reglement_id = $obj->fk_cond_reglement;
- $this->cond_reglement_code = $obj->cond_reglement_code;
- $this->cond_reglement = $obj->cond_reglement_libelle;
- $this->cond_reglement_doc = $obj->cond_reglement_libelle_doc;
- $this->fk_account = $obj->fk_account;
- $this->availability_id = $obj->fk_availability;
- $this->availability_code = $obj->availability_code;
- $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->date_livraison);
- $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;
- $this->fk_delivery_address = $obj->fk_delivery_address;
+ $this->ref = $obj->ref;
+ $this->ref_client = $obj->ref_client;
+ $this->ref_customer = $obj->ref_client;
+ $this->ref_ext = $obj->ref_ext;
+ $this->ref_int = $obj->ref_int;
+ $this->socid = $obj->fk_soc;
+ $this->statut = $obj->fk_statut;
+ $this->user_author_id = $obj->fk_user_author;
+ $this->user_valid = $obj->fk_user_valid;
+ $this->total_ht = $obj->total_ht;
+ $this->total_tva = $obj->total_tva;
+ $this->total_localtax1 = $obj->total_localtax1;
+ $this->total_localtax2 = $obj->total_localtax2;
+ $this->total_ttc = $obj->total_ttc;
+ $this->date = $this->db->jdate($obj->date_commande);
+ $this->date_commande = $this->db->jdate($obj->date_commande);
+ $this->remise = $obj->remise;
+ $this->remise_percent = $obj->remise_percent;
+ $this->remise_absolue = $obj->remise_absolue;
+ $this->source = $obj->source;
+ $this->billed = $obj->billed;
+ $this->note = $obj->note_private; // deprecated
+ $this->note_private = $obj->note_private;
+ $this->note_public = $obj->note_public;
+ $this->fk_project = $obj->fk_projet;
+ $this->modelpdf = $obj->model_pdf;
+ $this->last_main_doc = $obj->last_main_doc;
+ $this->mode_reglement_id = $obj->fk_mode_reglement;
+ $this->mode_reglement_code = $obj->mode_reglement_code;
+ $this->mode_reglement = $obj->mode_reglement_libelle;
+ $this->cond_reglement_id = $obj->fk_cond_reglement;
+ $this->cond_reglement_code = $obj->cond_reglement_code;
+ $this->cond_reglement = $obj->cond_reglement_libelle;
+ $this->cond_reglement_doc = $obj->cond_reglement_libelle_doc;
+ $this->fk_account = $obj->fk_account;
+ $this->availability_id = $obj->fk_availability;
+ $this->availability_code = $obj->availability_code;
+ $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->date_livraison);
+ $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;
+ $this->fk_delivery_address = $obj->fk_delivery_address;
//Incoterms
$this->fk_incoterms = $obj->fk_incoterms;
@@ -1667,207 +1703,211 @@ class Commande extends CommonOrder
$this->multicurrency_total_tva = $obj->multicurrency_total_tva;
$this->multicurrency_total_ttc = $obj->multicurrency_total_ttc;
- $this->extraparams = (array) json_decode($obj->extraparams, true);
+ $this->extraparams = (array) json_decode($obj->extraparams, true);
- $this->lines = array();
+ $this->lines = array();
- if ($this->statut == self::STATUS_DRAFT) $this->brouillon = 1;
+ if ($this->statut == self::STATUS_DRAFT) $this->brouillon = 1;
- // Retreive all extrafield
- // fetch optionals attributes and labels
- $this->fetch_optionals();
+ // Retreive all extrafield
+ // fetch optionals attributes and labels
+ $this->fetch_optionals();
- $this->db->free($result);
+ $this->db->free($result);
- /*
- * Lines
- */
- $result=$this->fetch_lines();
- if ($result < 0)
- {
- return -3;
- }
- return 1;
- }
- else
- {
- $this->error='Order with id '.$id.' not found sql='.$sql;
- return 0;
- }
- }
- else
- {
- $this->error=$this->db->error();
- return -1;
- }
- }
+ /*
+ * Lines
+ */
+ $result=$this->fetch_lines();
+ if ($result < 0)
+ {
+ return -3;
+ }
+ return 1;
+ }
+ else
+ {
+ $this->error='Order with id '.$id.' not found sql='.$sql;
+ return 0;
+ }
+ }
+ else
+ {
+ $this->error=$this->db->error();
+ return -1;
+ }
+ }
- /**
- * Adding line of fixed discount in the order in DB
- *
- * @param int $idremise Id de la remise fixe
- * @return int >0 si ok, <0 si ko
- */
- function insert_discount($idremise)
- {
- global $langs;
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
+ /**
+ * Adding line of fixed discount in the order in DB
+ *
+ * @param int $idremise Id de la remise fixe
+ * @return int >0 si ok, <0 si ko
+ */
+ function insert_discount($idremise)
+ {
+ // phpcs:enable
+ global $langs;
- include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
- include_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php';
+ include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
+ include_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php';
- $this->db->begin();
+ $this->db->begin();
- $remise=new DiscountAbsolute($this->db);
- $result=$remise->fetch($idremise);
+ $remise=new DiscountAbsolute($this->db);
+ $result=$remise->fetch($idremise);
- if ($result > 0)
- {
- if ($remise->fk_facture) // Protection against multiple submission
- {
- $this->error=$langs->trans("ErrorDiscountAlreadyUsed");
- $this->db->rollback();
- return -5;
- }
+ if ($result > 0)
+ {
+ if ($remise->fk_facture) // Protection against multiple submission
+ {
+ $this->error=$langs->trans("ErrorDiscountAlreadyUsed");
+ $this->db->rollback();
+ return -5;
+ }
- $line = new OrderLine($this->db);
+ $line = new OrderLine($this->db);
- $line->fk_commande=$this->id;
- $line->fk_remise_except=$remise->id;
- $line->desc=$remise->description; // Description ligne
- $line->vat_src_code=$remise->vat_src_code;
- $line->tva_tx=$remise->tva_tx;
- $line->subprice=-$remise->amount_ht;
- $line->price=-$remise->amount_ht;
- $line->fk_product=0; // Id produit predefini
- $line->qty=1;
- $line->remise=0;
- $line->remise_percent=0;
- $line->rang=-1;
- $line->info_bits=2;
+ $line->fk_commande=$this->id;
+ $line->fk_remise_except=$remise->id;
+ $line->desc=$remise->description; // Description ligne
+ $line->vat_src_code=$remise->vat_src_code;
+ $line->tva_tx=$remise->tva_tx;
+ $line->subprice=-$remise->amount_ht;
+ $line->price=-$remise->amount_ht;
+ $line->fk_product=0; // Id produit predefini
+ $line->qty=1;
+ $line->remise=0;
+ $line->remise_percent=0;
+ $line->rang=-1;
+ $line->info_bits=2;
- $line->total_ht = -$remise->amount_ht;
- $line->total_tva = -$remise->amount_tva;
- $line->total_ttc = -$remise->amount_ttc;
+ $line->total_ht = -$remise->amount_ht;
+ $line->total_tva = -$remise->amount_tva;
+ $line->total_ttc = -$remise->amount_ttc;
- $result=$line->insert();
- if ($result > 0)
- {
- $result=$this->update_price(1);
- if ($result > 0)
- {
- $this->db->commit();
- return 1;
- }
- else
- {
- $this->db->rollback();
- return -1;
- }
- }
- else
- {
- $this->error=$line->error;
- $this->db->rollback();
- return -2;
- }
- }
- else
- {
- $this->db->rollback();
- return -2;
- }
- }
+ $result=$line->insert();
+ if ($result > 0)
+ {
+ $result=$this->update_price(1);
+ if ($result > 0)
+ {
+ $this->db->commit();
+ return 1;
+ }
+ else
+ {
+ $this->db->rollback();
+ return -1;
+ }
+ }
+ else
+ {
+ $this->error=$line->error;
+ $this->db->rollback();
+ return -2;
+ }
+ }
+ else
+ {
+ $this->db->rollback();
+ return -2;
+ }
+ }
- /**
- * Load array lines
- *
- * @param int $only_product Return only physical products
- * @return int <0 if KO, >0 if OK
- */
- function fetch_lines($only_product=0)
- {
- $this->lines=array();
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
+ /**
+ * Load array lines
+ *
+ * @param int $only_product Return only physical products
+ * @return int <0 if KO, >0 if OK
+ */
+ function fetch_lines($only_product=0)
+ {
+ // phpcs:enable
+ $this->lines=array();
- $sql = 'SELECT l.rowid, l.fk_product, l.fk_parent_line, l.product_type, l.fk_commande, l.label as custom_label, l.description, l.price, l.qty, l.vat_src_code, l.tva_tx,';
- $sql.= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.fk_remise_except, l.remise_percent, l.subprice, l.fk_product_fournisseur_price as fk_fournprice, l.buy_price_ht as pa_ht, l.rang, l.info_bits, l.special_code,';
- $sql.= ' l.total_ht, l.total_ttc, l.total_tva, l.total_localtax1, l.total_localtax2, l.date_start, l.date_end,';
- $sql.= ' l.fk_unit,';
+ $sql = 'SELECT l.rowid, l.fk_product, l.fk_parent_line, l.product_type, l.fk_commande, l.label as custom_label, l.description, l.price, l.qty, l.vat_src_code, l.tva_tx,';
+ $sql.= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.fk_remise_except, l.remise_percent, l.subprice, l.fk_product_fournisseur_price as fk_fournprice, l.buy_price_ht as pa_ht, l.rang, l.info_bits, l.special_code,';
+ $sql.= ' l.total_ht, l.total_ttc, l.total_tva, l.total_localtax1, l.total_localtax2, l.date_start, l.date_end,';
+ $sql.= ' l.fk_unit,';
$sql.= ' l.fk_multicurrency, l.multicurrency_code, l.multicurrency_subprice, l.multicurrency_total_ht, l.multicurrency_total_tva, l.multicurrency_total_ttc,';
- $sql.= ' p.ref as product_ref, p.description as product_desc, p.fk_product_type, p.label as product_label, p.tobatch as product_tobatch,';
- $sql.= ' p.weight, p.weight_units, p.volume, p.volume_units';
- $sql.= ' FROM '.MAIN_DB_PREFIX.'commandedet as l';
- $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON (p.rowid = l.fk_product)';
- $sql.= ' WHERE l.fk_commande = '.$this->id;
- if ($only_product) $sql .= ' AND p.fk_product_type = 0';
- $sql .= ' ORDER BY l.rang, l.rowid';
+ $sql.= ' p.ref as product_ref, p.description as product_desc, p.fk_product_type, p.label as product_label, p.tobatch as product_tobatch,';
+ $sql.= ' p.weight, p.weight_units, p.volume, p.volume_units';
+ $sql.= ' FROM '.MAIN_DB_PREFIX.'commandedet as l';
+ $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON (p.rowid = l.fk_product)';
+ $sql.= ' WHERE l.fk_commande = '.$this->id;
+ if ($only_product) $sql .= ' AND p.fk_product_type = 0';
+ $sql .= ' ORDER BY l.rang, l.rowid';
- dol_syslog(get_class($this)."::fetch_lines", LOG_DEBUG);
- $result = $this->db->query($sql);
- if ($result)
- {
- $num = $this->db->num_rows($result);
+ dol_syslog(get_class($this)."::fetch_lines", LOG_DEBUG);
+ $result = $this->db->query($sql);
+ if ($result)
+ {
+ $num = $this->db->num_rows($result);
- $i = 0;
- while ($i < $num)
- {
- $objp = $this->db->fetch_object($result);
+ $i = 0;
+ while ($i < $num)
+ {
+ $objp = $this->db->fetch_object($result);
- $line = new OrderLine($this->db);
+ $line = new OrderLine($this->db);
- $line->rowid = $objp->rowid;
- $line->id = $objp->rowid;
- $line->fk_commande = $objp->fk_commande;
- $line->commande_id = $objp->fk_commande;
- $line->label = $objp->custom_label;
- $line->desc = $objp->description;
- $line->description = $objp->description; // Description line
- $line->product_type = $objp->product_type;
- $line->qty = $objp->qty;
+ $line->rowid = $objp->rowid;
+ $line->id = $objp->rowid;
+ $line->fk_commande = $objp->fk_commande;
+ $line->commande_id = $objp->fk_commande;
+ $line->label = $objp->custom_label;
+ $line->desc = $objp->description;
+ $line->description = $objp->description; // Description line
+ $line->product_type = $objp->product_type;
+ $line->qty = $objp->qty;
- $line->vat_src_code = $objp->vat_src_code;
- $line->tva_tx = $objp->tva_tx;
- $line->localtax1_tx = $objp->localtax1_tx;
- $line->localtax2_tx = $objp->localtax2_tx;
- $line->localtax1_type = $objp->localtax1_type;
- $line->localtax2_type = $objp->localtax2_type;
- $line->total_ht = $objp->total_ht;
- $line->total_ttc = $objp->total_ttc;
- $line->total_tva = $objp->total_tva;
- $line->total_localtax1 = $objp->total_localtax1;
- $line->total_localtax2 = $objp->total_localtax2;
- $line->subprice = $objp->subprice;
- $line->fk_remise_except = $objp->fk_remise_except;
- $line->remise_percent = $objp->remise_percent;
- $line->price = $objp->price;
- $line->fk_product = $objp->fk_product;
+ $line->vat_src_code = $objp->vat_src_code;
+ $line->tva_tx = $objp->tva_tx;
+ $line->localtax1_tx = $objp->localtax1_tx;
+ $line->localtax2_tx = $objp->localtax2_tx;
+ $line->localtax1_type = $objp->localtax1_type;
+ $line->localtax2_type = $objp->localtax2_type;
+ $line->total_ht = $objp->total_ht;
+ $line->total_ttc = $objp->total_ttc;
+ $line->total_tva = $objp->total_tva;
+ $line->total_localtax1 = $objp->total_localtax1;
+ $line->total_localtax2 = $objp->total_localtax2;
+ $line->subprice = $objp->subprice;
+ $line->fk_remise_except = $objp->fk_remise_except;
+ $line->remise_percent = $objp->remise_percent;
+ $line->price = $objp->price;
+ $line->fk_product = $objp->fk_product;
$line->fk_fournprice = $objp->fk_fournprice;
- $marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $line->fk_fournprice, $objp->pa_ht);
- $line->pa_ht = $marginInfos[0];
- $line->marge_tx = $marginInfos[1];
- $line->marque_tx = $marginInfos[2];
- $line->rang = $objp->rang;
- $line->info_bits = $objp->info_bits;
- $line->special_code = $objp->special_code;
- $line->fk_parent_line = $objp->fk_parent_line;
+ $marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $line->fk_fournprice, $objp->pa_ht);
+ $line->pa_ht = $marginInfos[0];
+ $line->marge_tx = $marginInfos[1];
+ $line->marque_tx = $marginInfos[2];
+ $line->rang = $objp->rang;
+ $line->info_bits = $objp->info_bits;
+ $line->special_code = $objp->special_code;
+ $line->fk_parent_line = $objp->fk_parent_line;
- $line->ref = $objp->product_ref;
- $line->product_ref = $objp->product_ref;
- $line->libelle = $objp->product_label;
- $line->product_label = $objp->product_label;
- $line->product_desc = $objp->product_desc;
- $line->product_tobatch = $objp->product_tobatch;
- $line->fk_product_type = $objp->fk_product_type; // Produit ou service
- $line->fk_unit = $objp->fk_unit;
+ $line->ref = $objp->product_ref;
+ $line->product_ref = $objp->product_ref;
+ $line->libelle = $objp->product_label;
+ $line->product_label = $objp->product_label;
+ $line->product_desc = $objp->product_desc;
+ $line->product_tobatch = $objp->product_tobatch;
+ $line->fk_product_type = $objp->fk_product_type; // Produit ou service
+ $line->fk_unit = $objp->fk_unit;
- $line->weight = $objp->weight;
- $line->weight_units = $objp->weight_units;
- $line->volume = $objp->volume;
- $line->volume_units = $objp->volume_units;
+ $line->weight = $objp->weight;
+ $line->weight_units = $objp->weight_units;
+ $line->volume = $objp->volume;
+ $line->volume_units = $objp->volume_units;
- $line->date_start = $this->db->jdate($objp->date_start);
- $line->date_end = $this->db->jdate($objp->date_end);
+ $line->date_start = $this->db->jdate($objp->date_start);
+ $line->date_end = $this->db->jdate($objp->date_end);
// Multicurrency
$line->fk_multicurrency = $objp->fk_multicurrency;
@@ -1877,810 +1917,828 @@ class Commande extends CommonOrder
$line->multicurrency_total_tva = $objp->multicurrency_total_tva;
$line->multicurrency_total_ttc = $objp->multicurrency_total_ttc;
- $this->lines[$i] = $line;
+ $this->lines[$i] = $line;
- $i++;
- }
+ $i++;
+ }
- $this->db->free($result);
+ $this->db->free($result);
- return 1;
- }
- else
- {
- $this->error=$this->db->error();
- return -3;
- }
- }
+ return 1;
+ }
+ else
+ {
+ $this->error=$this->db->error();
+ return -3;
+ }
+ }
- /**
- * Return number of line with type product.
- *
- * @return int <0 if KO, Nbr of product lines if OK
- */
- function getNbOfProductsLines()
- {
- $nb=0;
- foreach($this->lines as $line)
- {
- if ($line->product_type == 0) $nb++;
- }
- return $nb;
- }
+ /**
+ * Return number of line with type product.
+ *
+ * @return int <0 if KO, Nbr of product lines if OK
+ */
+ function getNbOfProductsLines()
+ {
+ $nb=0;
+ foreach($this->lines as $line)
+ {
+ if ($line->product_type == 0) $nb++;
+ }
+ return $nb;
+ }
- /**
- * Return number of line with type service.
- *
- * @return int <0 if KO, Nbr of service lines if OK
- */
- function getNbOfServicesLines()
- {
- $nb=0;
- foreach($this->lines as $line)
- {
- if ($line->product_type == 1) $nb++;
- }
- return $nb;
- }
+ /**
+ * Return number of line with type service.
+ *
+ * @return int <0 if KO, Nbr of service lines if OK
+ */
+ function getNbOfServicesLines()
+ {
+ $nb=0;
+ foreach($this->lines as $line)
+ {
+ if ($line->product_type == 1) $nb++;
+ }
+ return $nb;
+ }
- /**
- * Count numbe rof shipments for this order
- *
- * @return int <0 if KO, Nb of shipment found if OK
- */
- function getNbOfShipments()
- {
- $nb = 0;
+ /**
+ * Count numbe rof shipments for this order
+ *
+ * @return int <0 if KO, Nb of shipment found if OK
+ */
+ function getNbOfShipments()
+ {
+ $nb = 0;
- $sql = 'SELECT COUNT(DISTINCT ed.fk_expedition) as nb';
- $sql.= ' FROM '.MAIN_DB_PREFIX.'expeditiondet as ed,';
- $sql.= ' '.MAIN_DB_PREFIX.'commandedet as cd';
- $sql.= ' WHERE';
- $sql.= ' ed.fk_origin_line = cd.rowid';
- $sql.= ' AND cd.fk_commande =' .$this->id;
- //print $sql;
+ $sql = 'SELECT COUNT(DISTINCT ed.fk_expedition) as nb';
+ $sql.= ' FROM '.MAIN_DB_PREFIX.'expeditiondet as ed,';
+ $sql.= ' '.MAIN_DB_PREFIX.'commandedet as cd';
+ $sql.= ' WHERE';
+ $sql.= ' ed.fk_origin_line = cd.rowid';
+ $sql.= ' AND cd.fk_commande =' .$this->id;
+ //print $sql;
- dol_syslog(get_class($this)."::getNbOfShipments", LOG_DEBUG);
- $resql = $this->db->query($sql);
- if ($resql)
- {
- $obj = $this->db->fetch_object($resql);
- if ($obj) $nb = $obj->nb;
+ dol_syslog(get_class($this)."::getNbOfShipments", LOG_DEBUG);
+ $resql = $this->db->query($sql);
+ if ($resql)
+ {
+ $obj = $this->db->fetch_object($resql);
+ if ($obj) $nb = $obj->nb;
- $this->db->free($resql);
- return $nb;
- }
- else
- {
- $this->error=$this->db->lasterror();
- return -1;
- }
- }
+ $this->db->free($resql);
+ return $nb;
+ }
+ else
+ {
+ $this->error=$this->db->lasterror();
+ return -1;
+ }
+ }
- /**
- * Load array this->expeditions of lines of shipments with nb of products sent for each order line
- * Note: For a dedicated shipment, the fetch_lines can be used to load the qty_asked and qty_shipped. This function is use to return qty_shipped cumulated for the order
- *
- * @param int $filtre_statut Filter on shipment status
- * @return int <0 if KO, Nb of lines found if OK
- */
- function loadExpeditions($filtre_statut=-1)
- {
- $this->expeditions = array();
+ /**
+ * Load array this->expeditions of lines of shipments with nb of products sent for each order line
+ * Note: For a dedicated shipment, the fetch_lines can be used to load the qty_asked and qty_shipped. This function is use to return qty_shipped cumulated for the order
+ *
+ * @param int $filtre_statut Filter on shipment status
+ * @return int <0 if KO, Nb of lines found if OK
+ */
+ function loadExpeditions($filtre_statut=-1)
+ {
+ $this->expeditions = array();
- $sql = 'SELECT cd.rowid, cd.fk_product,';
- $sql.= ' sum(ed.qty) as qty';
- $sql.= ' FROM '.MAIN_DB_PREFIX.'expeditiondet as ed,';
- if ($filtre_statut >= 0) $sql.= ' '.MAIN_DB_PREFIX.'expedition as e,';
- $sql.= ' '.MAIN_DB_PREFIX.'commandedet as cd';
- $sql.= ' WHERE';
- if ($filtre_statut >= 0) $sql.= ' ed.fk_expedition = e.rowid AND';
- $sql.= ' ed.fk_origin_line = cd.rowid';
- $sql.= ' AND cd.fk_commande =' .$this->id;
- if ($this->fk_product > 0) $sql.= ' AND cd.fk_product = '.$this->fk_product;
- if ($filtre_statut >= 0) $sql.=' AND e.fk_statut >= '.$filtre_statut;
- $sql.= ' GROUP BY cd.rowid, cd.fk_product';
- //print $sql;
+ $sql = 'SELECT cd.rowid, cd.fk_product,';
+ $sql.= ' sum(ed.qty) as qty';
+ $sql.= ' FROM '.MAIN_DB_PREFIX.'expeditiondet as ed,';
+ if ($filtre_statut >= 0) $sql.= ' '.MAIN_DB_PREFIX.'expedition as e,';
+ $sql.= ' '.MAIN_DB_PREFIX.'commandedet as cd';
+ $sql.= ' WHERE';
+ if ($filtre_statut >= 0) $sql.= ' ed.fk_expedition = e.rowid AND';
+ $sql.= ' ed.fk_origin_line = cd.rowid';
+ $sql.= ' AND cd.fk_commande =' .$this->id;
+ if ($this->fk_product > 0) $sql.= ' AND cd.fk_product = '.$this->fk_product;
+ if ($filtre_statut >= 0) $sql.=' AND e.fk_statut >= '.$filtre_statut;
+ $sql.= ' GROUP BY cd.rowid, cd.fk_product';
+ //print $sql;
- dol_syslog(get_class($this)."::loadExpeditions", LOG_DEBUG);
- $resql = $this->db->query($sql);
- if ($resql)
- {
- $num = $this->db->num_rows($resql);
- $i = 0;
- while ($i < $num)
- {
- $obj = $this->db->fetch_object($resql);
- $this->expeditions[$obj->rowid] = $obj->qty;
- $i++;
- }
- $this->db->free($resql);
- return $num;
- }
- else
- {
- $this->error=$this->db->lasterror();
- return -1;
- }
- }
+ dol_syslog(get_class($this)."::loadExpeditions", LOG_DEBUG);
+ $resql = $this->db->query($sql);
+ if ($resql)
+ {
+ $num = $this->db->num_rows($resql);
+ $i = 0;
+ while ($i < $num)
+ {
+ $obj = $this->db->fetch_object($resql);
+ $this->expeditions[$obj->rowid] = $obj->qty;
+ $i++;
+ }
+ $this->db->free($resql);
+ return $num;
+ }
+ else
+ {
+ $this->error=$this->db->lasterror();
+ return -1;
+ }
+ }
- /**
- * Returns a array with expeditions lines number
- *
- * @return int Nb of shipments
- *
- * TODO deprecate, move to Shipping class
- */
- function nb_expedition()
- {
- $sql = 'SELECT count(*)';
- $sql.= ' FROM '.MAIN_DB_PREFIX.'expedition as e';
- $sql.= ', '.MAIN_DB_PREFIX.'element_element as el';
- $sql.= ' WHERE el.fk_source = '.$this->id;
- $sql.= " AND el.fk_target = e.rowid";
- $sql.= " AND el.targettype = 'shipping'";
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
+ /**
+ * Returns a array with expeditions lines number
+ *
+ * @return int Nb of shipments
+ *
+ * TODO deprecate, move to Shipping class
+ */
+ function nb_expedition()
+ {
+ // phpcs:enable
+ $sql = 'SELECT count(*)';
+ $sql.= ' FROM '.MAIN_DB_PREFIX.'expedition as e';
+ $sql.= ', '.MAIN_DB_PREFIX.'element_element as el';
+ $sql.= ' WHERE el.fk_source = '.$this->id;
+ $sql.= " AND el.fk_target = e.rowid";
+ $sql.= " AND el.targettype = 'shipping'";
- $resql = $this->db->query($sql);
- if ($resql)
- {
- $row = $this->db->fetch_row($resql);
- return $row[0];
- }
- else dol_print_error($this->db);
- }
+ $resql = $this->db->query($sql);
+ if ($resql)
+ {
+ $row = $this->db->fetch_row($resql);
+ return $row[0];
+ }
+ else dol_print_error($this->db);
+ }
- /**
- * Return a array with the pending stock by product
- *
- * @param int $filtre_statut Filtre sur statut
- * @return int 0 si OK, <0 si KO
- *
- * TODO FONCTION NON FINIE A FINIR
- */
- function stock_array($filtre_statut=self::STATUS_CANCELED)
- {
- $this->stocks = array();
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
+ /**
+ * Return a array with the pending stock by product
+ *
+ * @param int $filtre_statut Filtre sur statut
+ * @return int 0 si OK, <0 si KO
+ *
+ * TODO FONCTION NON FINIE A FINIR
+ */
+ function stock_array($filtre_statut=self::STATUS_CANCELED)
+ {
+ // phpcs:enable
+ $this->stocks = array();
- // Tableau des id de produit de la commande
+ // Tableau des id de produit de la commande
$array_of_product=array();
- // Recherche total en stock pour chaque produit
- // TODO $array_of_product est défini vide juste au dessus !!
- if (count($array_of_product))
- {
- $sql = "SELECT fk_product, sum(ps.reel) as total";
- $sql.= " FROM ".MAIN_DB_PREFIX."product_stock as ps";
- $sql.= " WHERE ps.fk_product IN (".join(',',$array_of_product).")";
- $sql.= ' GROUP BY fk_product ';
- $resql = $this->db->query($sql);
- if ($resql)
- {
- $num = $this->db->num_rows($resql);
- $i = 0;
- while ($i < $num)
- {
- $obj = $this->db->fetch_object($resql);
- $this->stocks[$obj->fk_product] = $obj->total;
- $i++;
- }
- $this->db->free($resql);
- }
- }
- return 0;
- }
+ // Recherche total en stock pour chaque produit
+ // TODO $array_of_product est défini vide juste au dessus !!
+ if (count($array_of_product))
+ {
+ $sql = "SELECT fk_product, sum(ps.reel) as total";
+ $sql.= " FROM ".MAIN_DB_PREFIX."product_stock as ps";
+ $sql.= " WHERE ps.fk_product IN (".join(',',$array_of_product).")";
+ $sql.= ' GROUP BY fk_product ';
+ $resql = $this->db->query($sql);
+ if ($resql)
+ {
+ $num = $this->db->num_rows($resql);
+ $i = 0;
+ while ($i < $num)
+ {
+ $obj = $this->db->fetch_object($resql);
+ $this->stocks[$obj->fk_product] = $obj->total;
+ $i++;
+ }
+ $this->db->free($resql);
+ }
+ }
+ return 0;
+ }
- /**
- * Delete an order line
- *
- * @param User $user User object
- * @param int $lineid Id of line to delete
- * @return int >0 if OK, 0 if nothing to do, <0 if KO
- */
- function deleteline($user=null, $lineid=0)
- {
- if ($this->statut == self::STATUS_DRAFT)
- {
- $this->db->begin();
+ /**
+ * Delete an order line
+ *
+ * @param User $user User object
+ * @param int $lineid Id of line to delete
+ * @return int >0 if OK, 0 if nothing to do, <0 if KO
+ */
+ function deleteline($user=null, $lineid=0)
+ {
+ if ($this->statut == self::STATUS_DRAFT)
+ {
+ $this->db->begin();
- $sql = "SELECT fk_product, qty";
- $sql.= " FROM ".MAIN_DB_PREFIX."commandedet";
- $sql.= " WHERE rowid = ".$lineid;
+ $sql = "SELECT fk_product, qty";
+ $sql.= " FROM ".MAIN_DB_PREFIX."commandedet";
+ $sql.= " WHERE rowid = ".$lineid;
- $result = $this->db->query($sql);
- if ($result)
- {
- $obj = $this->db->fetch_object($result);
+ $result = $this->db->query($sql);
+ if ($result)
+ {
+ $obj = $this->db->fetch_object($result);
- if ($obj)
- {
- $product = new Product($this->db);
- $product->id = $obj->fk_product;
+ if ($obj)
+ {
+ $product = new Product($this->db);
+ $product->id = $obj->fk_product;
- // Delete line
- $line = new OrderLine($this->db);
+ // Delete line
+ $line = new OrderLine($this->db);
- // For triggers
- $line->fetch($lineid);
+ // For triggers
+ $line->fetch($lineid);
- if ($line->delete($user) > 0)
- {
- $result=$this->update_price(1);
-
- if ($result > 0)
- {
- $this->db->commit();
- return 1;
- }
- else
- {
- $this->db->rollback();
- $this->error=$this->db->lasterror();
- return -1;
- }
- }
- else
- {
- $this->db->rollback();
- $this->error=$line->error;
- return -1;
- }
- }
- else
- {
- $this->db->rollback();
- return 0;
- }
- }
- else
- {
- $this->db->rollback();
- $this->error=$this->db->lasterror();
- return -1;
- }
- }
- else
- {
- $this->error='ErrorDeleteLineNotAllowedByObjectStatus';
- return -1;
- }
- }
-
- /**
- * Applique une remise relative
- *
- * @param User $user User qui positionne la remise
- * @param float $remise Discount (percent)
- * @param int $notrigger 1=Does not execute triggers, 0= execute triggers
- * @return int <0 if KO, >0 if OK
- */
- function set_remise($user, $remise, $notrigger=0)
- {
- $remise=trim($remise)?trim($remise):0;
-
- if ($user->rights->commande->creer)
- {
- $error=0;
-
- $this->db->begin();
-
- $remise=price2num($remise);
-
- $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande';
- $sql.= ' SET remise_percent = '.$remise;
- $sql.= ' WHERE rowid = '.$this->id.' AND fk_statut = '.self::STATUS_DRAFT.' ;';
-
- dol_syslog(__METHOD__, LOG_DEBUG);
- $resql=$this->db->query($sql);
- if (!$resql)
- {
- $this->errors[]=$this->db->error();
- $error++;
- }
-
- if (! $error)
- {
- $this->oldcopy= clone $this;
- $this->remise_percent = $remise;
- $this->update_price(1);
- }
-
- if (! $notrigger && empty($error))
- {
- // Call trigger
- $result=$this->call_trigger('ORDER_MODIFY',$user);
- if ($result < 0) $error++;
- // End call triggers
- }
-
- if (! $error)
- {
- $this->db->commit();
- return 1;
- }
- else
- {
- foreach($this->errors as $errmsg)
- {
- dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR);
- $this->error.=($this->error?', '.$errmsg:$errmsg);
- }
- $this->db->rollback();
- return -1*$error;
- }
- }
- }
-
-
- /**
- * Applique une remise absolue
- *
- * @param User $user User qui positionne la remise
- * @param float $remise Discount
- * @param int $notrigger 1=Does not execute triggers, 0= execute triggers
- * @return int <0 if KO, >0 if OK
- */
- function set_remise_absolue($user, $remise, $notrigger=0)
- {
- $remise=trim($remise)?trim($remise):0;
-
- if ($user->rights->commande->creer)
- {
- $error=0;
-
- $this->db->begin();
-
- $remise=price2num($remise);
-
- $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande';
- $sql.= ' SET remise_absolue = '.$remise;
- $sql.= ' WHERE rowid = '.$this->id.' AND fk_statut = '.self::STATUS_DRAFT.' ;';
-
- dol_syslog(__METHOD__, LOG_DEBUG);
- $resql=$this->db->query($sql);
- if (!$resql)
- {
- $this->errors[]=$this->db->error();
- $error++;
- }
-
- if (! $error)
- {
- $this->oldcopy= clone $this;
- $this->remise_absolue = $remise;
- $this->update_price(1);
- }
-
- if (! $notrigger && empty($error))
- {
- // Call trigger
- $result=$this->call_trigger('ORDER_MODIFY',$user);
- if ($result < 0) $error++;
- // End call triggers
- }
-
- if (! $error)
- {
- $this->db->commit();
- return 1;
- }
- else
- {
- foreach($this->errors as $errmsg)
- {
- dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR);
- $this->error.=($this->error?', '.$errmsg:$errmsg);
- }
- $this->db->rollback();
- return -1*$error;
- }
- }
- }
-
-
- /**
- * Set the order date
- *
- * @param User $user Object user making change
- * @param int $date Date
- * @param int $notrigger 1=Does not execute triggers, 0= execute triggers
- * @return int <0 if KO, >0 if OK
- */
- function set_date($user, $date, $notrigger=0)
- {
- if ($user->rights->commande->creer)
- {
- $error=0;
-
- $this->db->begin();
-
- $sql = "UPDATE ".MAIN_DB_PREFIX."commande";
- $sql.= " SET date_commande = ".($date ? "'".$this->db->idate($date)."'" : 'null');
- $sql.= " WHERE rowid = ".$this->id." AND fk_statut = ".self::STATUS_DRAFT;
-
- dol_syslog(__METHOD__, LOG_DEBUG);
- $resql=$this->db->query($sql);
- if (!$resql)
- {
- $this->errors[]=$this->db->error();
- $error++;
- }
-
- if (! $error)
- {
- $this->oldcopy= clone $this;
- $this->date = $date;
- }
-
- if (! $notrigger && empty($error))
- {
- // Call trigger
- $result=$this->call_trigger('ORDER_MODIFY',$user);
- if ($result < 0) $error++;
- // End call triggers
- }
-
- if (! $error)
- {
- $this->db->commit();
- return 1;
- }
- else
- {
- foreach($this->errors as $errmsg)
- {
- dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR);
- $this->error.=($this->error?', '.$errmsg:$errmsg);
- }
- $this->db->rollback();
- return -1*$error;
- }
- }
- else
- {
- return -2;
- }
- }
-
- /**
- * Set the planned delivery date
- *
- * @param User $user Objet utilisateur qui modifie
- * @param int $date_livraison Date de livraison
- * @param int $notrigger 1=Does not execute triggers, 0= execute triggers
- * @return int <0 si ko, >0 si ok
- */
- function set_date_livraison($user, $date_livraison, $notrigger=0)
- {
- if ($user->rights->commande->creer)
- {
- $error=0;
-
- $this->db->begin();
-
- $sql = "UPDATE ".MAIN_DB_PREFIX."commande";
- $sql.= " SET date_livraison = ".($date_livraison ? "'".$this->db->idate($date_livraison)."'" : 'null');
- $sql.= " WHERE rowid = ".$this->id;
-
- dol_syslog(__METHOD__, LOG_DEBUG);
- $resql=$this->db->query($sql);
- if (!$resql)
- {
- $this->errors[]=$this->db->error();
- $error++;
- }
-
- if (! $error)
- {
- $this->oldcopy= clone $this;
- $this->date_livraison = $date_livraison;
- }
-
- if (! $notrigger && empty($error))
- {
- // Call trigger
- $result=$this->call_trigger('ORDER_MODIFY',$user);
- if ($result < 0) $error++;
- // End call triggers
- }
-
- if (! $error)
- {
- $this->db->commit();
- return 1;
- }
- else
- {
- foreach($this->errors as $errmsg)
- {
- dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR);
- $this->error.=($this->error?', '.$errmsg:$errmsg);
- }
- $this->db->rollback();
- return -1*$error;
- }
- }
- else
- {
- return -2;
- }
- }
-
- /**
- * Return list of orders (eventuelly filtered on a user) into an array
- *
- * @param int $shortlist 0=Return array[id]=ref, 1=Return array[](id=>id,ref=>ref,name=>name)
- * @param int $draft 0=not draft, 1=draft
- * @param User $excluser Objet user to exclude
- * @param int $socid Id third pary
- * @param int $limit For pagination
- * @param int $offset For pagination
- * @param string $sortfield Sort criteria
- * @param string $sortorder Sort order
- * @return int -1 if KO, array with result if OK
- */
- function liste_array($shortlist=0, $draft=0, $excluser='', $socid=0, $limit=0, $offset=0, $sortfield='c.date_commande', $sortorder='DESC')
- {
- global $user;
-
- $ga = array();
-
- $sql = "SELECT s.rowid, s.nom as name, s.client,";
- $sql.= " c.rowid as cid, c.ref";
- if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", sc.fk_soc, sc.fk_user";
- $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as c";
- if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
- $sql.= " WHERE c.entity IN (".getEntity('commande').")";
- $sql.= " AND c.fk_soc = s.rowid";
- if (! $user->rights->societe->client->voir && ! $socid) //restriction
- {
- $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
- }
- if ($socid) $sql.= " AND s.rowid = ".$socid;
- if ($draft) $sql.= " AND c.fk_statut = ".self::STATUS_DRAFT;
- if (is_object($excluser)) $sql.= " AND c.fk_user_author <> ".$excluser->id;
- $sql.= $this->db->order($sortfield,$sortorder);
- $sql.= $this->db->plimit($limit,$offset);
-
- $result=$this->db->query($sql);
- if ($result)
- {
- $numc = $this->db->num_rows($result);
- if ($numc)
- {
- $i = 0;
- while ($i < $numc)
- {
- $obj = $this->db->fetch_object($result);
-
- if ($shortlist == 1)
- {
- $ga[$obj->cid] = $obj->ref;
- }
- else if ($shortlist == 2)
- {
- $ga[$obj->cid] = $obj->ref.' ('.$obj->name.')';
- }
- else
+ if ($line->delete($user) > 0)
{
- $ga[$i]['id'] = $obj->cid;
- $ga[$i]['ref'] = $obj->ref;
- $ga[$i]['name'] = $obj->name;
- }
- $i++;
- }
- }
- return $ga;
- }
- else
- {
- dol_print_error($this->db);
- return -1;
- }
- }
+ $result=$this->update_price(1);
- /**
- * Update delivery delay
- *
- * @param int $availability_id Id du nouveau mode
- * @param int $notrigger 1=Does not execute triggers, 0= execute triggers
- * @return int >0 if OK, <0 if KO
- */
- function availability($availability_id, $notrigger=0)
- {
- global $user;
+ if ($result > 0)
+ {
+ $this->db->commit();
+ return 1;
+ }
+ else
+ {
+ $this->db->rollback();
+ $this->error=$this->db->lasterror();
+ return -1;
+ }
+ }
+ else
+ {
+ $this->db->rollback();
+ $this->error=$line->error;
+ return -1;
+ }
+ }
+ else
+ {
+ $this->db->rollback();
+ return 0;
+ }
+ }
+ else
+ {
+ $this->db->rollback();
+ $this->error=$this->db->lasterror();
+ return -1;
+ }
+ }
+ else
+ {
+ $this->error='ErrorDeleteLineNotAllowedByObjectStatus';
+ return -1;
+ }
+ }
- dol_syslog('Commande::availability('.$availability_id.')');
- if ($this->statut >= self::STATUS_DRAFT)
- {
- $error=0;
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
+ /**
+ * Applique une remise relative
+ *
+ * @param User $user User qui positionne la remise
+ * @param float $remise Discount (percent)
+ * @param int $notrigger 1=Does not execute triggers, 0= execute triggers
+ * @return int <0 if KO, >0 if OK
+ */
+ function set_remise($user, $remise, $notrigger=0)
+ {
+ // phpcs:enable
+ $remise=trim($remise)?trim($remise):0;
- $this->db->begin();
+ if ($user->rights->commande->creer)
+ {
+ $error=0;
- $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande';
- $sql .= ' SET fk_availability = '.$availability_id;
- $sql .= ' WHERE rowid='.$this->id;
+ $this->db->begin();
- dol_syslog(__METHOD__, LOG_DEBUG);
- $resql=$this->db->query($sql);
- if (!$resql)
- {
- $this->errors[]=$this->db->error();
- $error++;
- }
+ $remise=price2num($remise);
- if (! $error)
- {
- $this->oldcopy= clone $this;
- $this->availability_id = $availability_id;
- }
+ $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande';
+ $sql.= ' SET remise_percent = '.$remise;
+ $sql.= ' WHERE rowid = '.$this->id.' AND fk_statut = '.self::STATUS_DRAFT.' ;';
- if (! $notrigger && empty($error))
- {
- // Call trigger
- $result=$this->call_trigger('ORDER_MODIFY',$user);
- if ($result < 0) $error++;
- // End call triggers
- }
+ dol_syslog(__METHOD__, LOG_DEBUG);
+ $resql=$this->db->query($sql);
+ if (!$resql)
+ {
+ $this->errors[]=$this->db->error();
+ $error++;
+ }
- if (! $error)
- {
- $this->db->commit();
- return 1;
- }
- else
- {
- foreach($this->errors as $errmsg)
- {
- dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR);
- $this->error.=($this->error?', '.$errmsg:$errmsg);
- }
- $this->db->rollback();
- return -1*$error;
- }
- }
- else
- {
- $error_str='Command status do not meet requirement '.$this->statut;
- dol_syslog(__METHOD__.$error_str, LOG_ERR);
- $this->error=$error_str;
- $this->errors[]= $this->error;
- return -2;
- }
- }
+ if (! $error)
+ {
+ $this->oldcopy= clone $this;
+ $this->remise_percent = $remise;
+ $this->update_price(1);
+ }
- /**
- * Update order demand_reason
- *
- * @param int $demand_reason_id Id of new demand
- * @param int $notrigger 1=Does not execute triggers, 0= execute triggers
- * @return int >0 if ok, <0 if ko
- */
- function demand_reason($demand_reason_id, $notrigger=0)
- {
- global $user;
+ if (! $notrigger && empty($error))
+ {
+ // Call trigger
+ $result=$this->call_trigger('ORDER_MODIFY',$user);
+ if ($result < 0) $error++;
+ // End call triggers
+ }
- dol_syslog('Commande::demand_reason('.$demand_reason_id.')');
- if ($this->statut >= self::STATUS_DRAFT)
- {
- $error=0;
+ if (! $error)
+ {
+ $this->db->commit();
+ return 1;
+ }
+ else
+ {
+ foreach($this->errors as $errmsg)
+ {
+ dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR);
+ $this->error.=($this->error?', '.$errmsg:$errmsg);
+ }
+ $this->db->rollback();
+ return -1*$error;
+ }
+ }
+ }
- $this->db->begin();
- $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande';
- $sql .= ' SET fk_input_reason = '.$demand_reason_id;
- $sql .= ' WHERE rowid='.$this->id;
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
+ /**
+ * Applique une remise absolue
+ *
+ * @param User $user User qui positionne la remise
+ * @param float $remise Discount
+ * @param int $notrigger 1=Does not execute triggers, 0= execute triggers
+ * @return int <0 if KO, >0 if OK
+ */
+ function set_remise_absolue($user, $remise, $notrigger=0)
+ {
+ // phpcs:enable
+ $remise=trim($remise)?trim($remise):0;
- dol_syslog(__METHOD__, LOG_DEBUG);
- $resql=$this->db->query($sql);
- if (!$resql)
- {
- $this->errors[]=$this->db->error();
- $error++;
- }
+ if ($user->rights->commande->creer)
+ {
+ $error=0;
- if (! $error)
- {
- $this->oldcopy= clone $this;
- $this->demand_reason_id = $demand_reason_id;
- }
+ $this->db->begin();
- if (! $notrigger && empty($error))
- {
- // Call trigger
- $result=$this->call_trigger('ORDER_MODIFY',$user);
- if ($result < 0) $error++;
- // End call triggers
- }
+ $remise=price2num($remise);
- if (! $error)
- {
- $this->db->commit();
- return 1;
- }
- else
- {
- foreach($this->errors as $errmsg)
- {
- dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR);
- $this->error.=($this->error?', '.$errmsg:$errmsg);
- }
- $this->db->rollback();
- return -1*$error;
- }
- }
- else
- {
- $error_str='order status do not meet requirement '.$this->statut;
- dol_syslog(__METHOD__.$error_str, LOG_ERR);
- $this->error=$error_str;
- $this->errors[]= $this->error;
- return -2;
- }
- }
+ $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande';
+ $sql.= ' SET remise_absolue = '.$remise;
+ $sql.= ' WHERE rowid = '.$this->id.' AND fk_statut = '.self::STATUS_DRAFT.' ;';
- /**
- * Set customer ref
- *
- * @param User $user User that make change
- * @param string $ref_client Customer ref
- * @param int $notrigger 1=Does not execute triggers, 0= execute triggers
- * @return int <0 if KO, >0 if OK
- */
- function set_ref_client($user, $ref_client, $notrigger=0)
- {
- if ($user->rights->commande->creer)
- {
- $error=0;
+ dol_syslog(__METHOD__, LOG_DEBUG);
+ $resql=$this->db->query($sql);
+ if (!$resql)
+ {
+ $this->errors[]=$this->db->error();
+ $error++;
+ }
- $this->db->begin();
+ if (! $error)
+ {
+ $this->oldcopy= clone $this;
+ $this->remise_absolue = $remise;
+ $this->update_price(1);
+ }
- $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande SET';
- $sql.= ' ref_client = '.(empty($ref_client) ? 'NULL' : '\''.$this->db->escape($ref_client).'\'');
- $sql.= ' WHERE rowid = '.$this->id;
+ if (! $notrigger && empty($error))
+ {
+ // Call trigger
+ $result=$this->call_trigger('ORDER_MODIFY',$user);
+ if ($result < 0) $error++;
+ // End call triggers
+ }
- dol_syslog(__METHOD__.' this->id='.$this->id.', ref_client='.$ref_client, LOG_DEBUG);
- $resql=$this->db->query($sql);
- if (!$resql)
- {
- $this->errors[]=$this->db->error();
- $error++;
- }
+ if (! $error)
+ {
+ $this->db->commit();
+ return 1;
+ }
+ else
+ {
+ foreach($this->errors as $errmsg)
+ {
+ dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR);
+ $this->error.=($this->error?', '.$errmsg:$errmsg);
+ }
+ $this->db->rollback();
+ return -1*$error;
+ }
+ }
+ }
- if (! $error)
- {
- $this->oldcopy= clone $this;
- $this->ref_client = $ref_client;
- }
- if (! $notrigger && empty($error))
- {
- // Call trigger
- $result=$this->call_trigger('ORDER_MODIFY',$user);
- if ($result < 0) $error++;
- // End call triggers
- }
- if (! $error)
- {
- $this->db->commit();
- return 1;
- }
- else
- {
- foreach($this->errors as $errmsg)
- {
- dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR);
- $this->error.=($this->error?', '.$errmsg:$errmsg);
- }
- $this->db->rollback();
- return -1*$error;
- }
- }
- else
- {
- return -1;
- }
- }
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
+ /**
+ * Set the order date
+ *
+ * @param User $user Object user making change
+ * @param int $date Date
+ * @param int $notrigger 1=Does not execute triggers, 0= execute triggers
+ * @return int <0 if KO, >0 if OK
+ */
+ function set_date($user, $date, $notrigger=0)
+ {
+ // phpcs:enable
+ if ($user->rights->commande->creer)
+ {
+ $error=0;
+
+ $this->db->begin();
+
+ $sql = "UPDATE ".MAIN_DB_PREFIX."commande";
+ $sql.= " SET date_commande = ".($date ? "'".$this->db->idate($date)."'" : 'null');
+ $sql.= " WHERE rowid = ".$this->id." AND fk_statut = ".self::STATUS_DRAFT;
+
+ dol_syslog(__METHOD__, LOG_DEBUG);
+ $resql=$this->db->query($sql);
+ if (!$resql)
+ {
+ $this->errors[]=$this->db->error();
+ $error++;
+ }
+
+ if (! $error)
+ {
+ $this->oldcopy= clone $this;
+ $this->date = $date;
+ }
+
+ if (! $notrigger && empty($error))
+ {
+ // Call trigger
+ $result=$this->call_trigger('ORDER_MODIFY',$user);
+ if ($result < 0) $error++;
+ // End call triggers
+ }
+
+ if (! $error)
+ {
+ $this->db->commit();
+ return 1;
+ }
+ else
+ {
+ foreach($this->errors as $errmsg)
+ {
+ dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR);
+ $this->error.=($this->error?', '.$errmsg:$errmsg);
+ }
+ $this->db->rollback();
+ return -1*$error;
+ }
+ }
+ else
+ {
+ return -2;
+ }
+ }
+
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
+ /**
+ * Set the planned delivery date
+ *
+ * @param User $user Objet utilisateur qui modifie
+ * @param int $date_livraison Date de livraison
+ * @param int $notrigger 1=Does not execute triggers, 0= execute triggers
+ * @return int <0 si ko, >0 si ok
+ */
+ function set_date_livraison($user, $date_livraison, $notrigger=0)
+ {
+ // phpcs:enable
+ if ($user->rights->commande->creer)
+ {
+ $error=0;
+
+ $this->db->begin();
+
+ $sql = "UPDATE ".MAIN_DB_PREFIX."commande";
+ $sql.= " SET date_livraison = ".($date_livraison ? "'".$this->db->idate($date_livraison)."'" : 'null');
+ $sql.= " WHERE rowid = ".$this->id;
+
+ dol_syslog(__METHOD__, LOG_DEBUG);
+ $resql=$this->db->query($sql);
+ if (!$resql)
+ {
+ $this->errors[]=$this->db->error();
+ $error++;
+ }
+
+ if (! $error)
+ {
+ $this->oldcopy= clone $this;
+ $this->date_livraison = $date_livraison;
+ }
+
+ if (! $notrigger && empty($error))
+ {
+ // Call trigger
+ $result=$this->call_trigger('ORDER_MODIFY',$user);
+ if ($result < 0) $error++;
+ // End call triggers
+ }
+
+ if (! $error)
+ {
+ $this->db->commit();
+ return 1;
+ }
+ else
+ {
+ foreach($this->errors as $errmsg)
+ {
+ dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR);
+ $this->error.=($this->error?', '.$errmsg:$errmsg);
+ }
+ $this->db->rollback();
+ return -1*$error;
+ }
+ }
+ else
+ {
+ return -2;
+ }
+ }
+
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
+ /**
+ * Return list of orders (eventuelly filtered on a user) into an array
+ *
+ * @param int $shortlist 0=Return array[id]=ref, 1=Return array[](id=>id,ref=>ref,name=>name)
+ * @param int $draft 0=not draft, 1=draft
+ * @param User $excluser Objet user to exclude
+ * @param int $socid Id third pary
+ * @param int $limit For pagination
+ * @param int $offset For pagination
+ * @param string $sortfield Sort criteria
+ * @param string $sortorder Sort order
+ * @return int -1 if KO, array with result if OK
+ */
+ function liste_array($shortlist=0, $draft=0, $excluser='', $socid=0, $limit=0, $offset=0, $sortfield='c.date_commande', $sortorder='DESC')
+ {
+ // phpcs:enable
+ global $user;
+
+ $ga = array();
+
+ $sql = "SELECT s.rowid, s.nom as name, s.client,";
+ $sql.= " c.rowid as cid, c.ref";
+ if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", sc.fk_soc, sc.fk_user";
+ $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as c";
+ if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+ $sql.= " WHERE c.entity IN (".getEntity('commande').")";
+ $sql.= " AND c.fk_soc = s.rowid";
+ if (! $user->rights->societe->client->voir && ! $socid) //restriction
+ {
+ $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
+ }
+ if ($socid) $sql.= " AND s.rowid = ".$socid;
+ if ($draft) $sql.= " AND c.fk_statut = ".self::STATUS_DRAFT;
+ if (is_object($excluser)) $sql.= " AND c.fk_user_author <> ".$excluser->id;
+ $sql.= $this->db->order($sortfield,$sortorder);
+ $sql.= $this->db->plimit($limit,$offset);
+
+ $result=$this->db->query($sql);
+ if ($result)
+ {
+ $numc = $this->db->num_rows($result);
+ if ($numc)
+ {
+ $i = 0;
+ while ($i < $numc)
+ {
+ $obj = $this->db->fetch_object($result);
+
+ if ($shortlist == 1)
+ {
+ $ga[$obj->cid] = $obj->ref;
+ }
+ else if ($shortlist == 2)
+ {
+ $ga[$obj->cid] = $obj->ref.' ('.$obj->name.')';
+ }
+ else
+ {
+ $ga[$i]['id'] = $obj->cid;
+ $ga[$i]['ref'] = $obj->ref;
+ $ga[$i]['name'] = $obj->name;
+ }
+ $i++;
+ }
+ }
+ return $ga;
+ }
+ else
+ {
+ dol_print_error($this->db);
+ return -1;
+ }
+ }
+
+ /**
+ * Update delivery delay
+ *
+ * @param int $availability_id Id du nouveau mode
+ * @param int $notrigger 1=Does not execute triggers, 0= execute triggers
+ * @return int >0 if OK, <0 if KO
+ */
+ function availability($availability_id, $notrigger=0)
+ {
+ global $user;
+
+ dol_syslog('Commande::availability('.$availability_id.')');
+ if ($this->statut >= self::STATUS_DRAFT)
+ {
+ $error=0;
+
+ $this->db->begin();
+
+ $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande';
+ $sql .= ' SET fk_availability = '.$availability_id;
+ $sql .= ' WHERE rowid='.$this->id;
+
+ dol_syslog(__METHOD__, LOG_DEBUG);
+ $resql=$this->db->query($sql);
+ if (!$resql)
+ {
+ $this->errors[]=$this->db->error();
+ $error++;
+ }
+
+ if (! $error)
+ {
+ $this->oldcopy= clone $this;
+ $this->availability_id = $availability_id;
+ }
+
+ if (! $notrigger && empty($error))
+ {
+ // Call trigger
+ $result=$this->call_trigger('ORDER_MODIFY',$user);
+ if ($result < 0) $error++;
+ // End call triggers
+ }
+
+ if (! $error)
+ {
+ $this->db->commit();
+ return 1;
+ }
+ else
+ {
+ foreach($this->errors as $errmsg)
+ {
+ dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR);
+ $this->error.=($this->error?', '.$errmsg:$errmsg);
+ }
+ $this->db->rollback();
+ return -1*$error;
+ }
+ }
+ else
+ {
+ $error_str='Command status do not meet requirement '.$this->statut;
+ dol_syslog(__METHOD__.$error_str, LOG_ERR);
+ $this->error=$error_str;
+ $this->errors[]= $this->error;
+ return -2;
+ }
+ }
+
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
+ /**
+ * Update order demand_reason
+ *
+ * @param int $demand_reason_id Id of new demand
+ * @param int $notrigger 1=Does not execute triggers, 0= execute triggers
+ * @return int >0 if ok, <0 if ko
+ */
+ function demand_reason($demand_reason_id, $notrigger=0)
+ {
+ // phpcs:enable
+ global $user;
+
+ dol_syslog('Commande::demand_reason('.$demand_reason_id.')');
+ if ($this->statut >= self::STATUS_DRAFT)
+ {
+ $error=0;
+
+ $this->db->begin();
+
+ $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande';
+ $sql .= ' SET fk_input_reason = '.$demand_reason_id;
+ $sql .= ' WHERE rowid='.$this->id;
+
+ dol_syslog(__METHOD__, LOG_DEBUG);
+ $resql=$this->db->query($sql);
+ if (!$resql)
+ {
+ $this->errors[]=$this->db->error();
+ $error++;
+ }
+
+ if (! $error)
+ {
+ $this->oldcopy= clone $this;
+ $this->demand_reason_id = $demand_reason_id;
+ }
+
+ if (! $notrigger && empty($error))
+ {
+ // Call trigger
+ $result=$this->call_trigger('ORDER_MODIFY',$user);
+ if ($result < 0) $error++;
+ // End call triggers
+ }
+
+ if (! $error)
+ {
+ $this->db->commit();
+ return 1;
+ }
+ else
+ {
+ foreach($this->errors as $errmsg)
+ {
+ dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR);
+ $this->error.=($this->error?', '.$errmsg:$errmsg);
+ }
+ $this->db->rollback();
+ return -1*$error;
+ }
+ }
+ else
+ {
+ $error_str='order status do not meet requirement '.$this->statut;
+ dol_syslog(__METHOD__.$error_str, LOG_ERR);
+ $this->error=$error_str;
+ $this->errors[]= $this->error;
+ return -2;
+ }
+ }
+
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
+ /**
+ * Set customer ref
+ *
+ * @param User $user User that make change
+ * @param string $ref_client Customer ref
+ * @param int $notrigger 1=Does not execute triggers, 0= execute triggers
+ * @return int <0 if KO, >0 if OK
+ */
+ function set_ref_client($user, $ref_client, $notrigger=0)
+ {
+ // phpcs:enable
+ if ($user->rights->commande->creer)
+ {
+ $error=0;
+
+ $this->db->begin();
+
+ $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande SET';
+ $sql.= ' ref_client = '.(empty($ref_client) ? 'NULL' : '\''.$this->db->escape($ref_client).'\'');
+ $sql.= ' WHERE rowid = '.$this->id;
+
+ dol_syslog(__METHOD__.' this->id='.$this->id.', ref_client='.$ref_client, LOG_DEBUG);
+ $resql=$this->db->query($sql);
+ if (!$resql)
+ {
+ $this->errors[]=$this->db->error();
+ $error++;
+ }
+
+ if (! $error)
+ {
+ $this->oldcopy= clone $this;
+ $this->ref_client = $ref_client;
+ }
+
+ if (! $notrigger && empty($error))
+ {
+ // Call trigger
+ $result=$this->call_trigger('ORDER_MODIFY',$user);
+ if ($result < 0) $error++;
+ // End call triggers
+ }
+ if (! $error)
+ {
+ $this->db->commit();
+ return 1;
+ }
+ else
+ {
+ foreach($this->errors as $errmsg)
+ {
+ dol_syslog(__METHOD__.' Error: '.$errmsg, LOG_ERR);
+ $this->error.=($this->error?', '.$errmsg:$errmsg);
+ }
+ $this->db->rollback();
+ return -1*$error;
+ }
+ }
+ else
+ {
+ return -1;
+ }
+ }
/**
* Classify the order as invoiced
@@ -2691,7 +2749,7 @@ class Commande extends CommonOrder
*/
function classifyBilled(User $user, $notrigger=0)
{
- $error = 0;
+ $error = 0;
$this->db->begin();
@@ -2710,10 +2768,10 @@ class Commande extends CommonOrder
if (! $notrigger && empty($error))
{
- // Call trigger
- $result=$this->call_trigger('ORDER_CLASSIFY_BILLED',$user);
- if ($result < 0) $error++;
- // End call triggers
+ // Call trigger
+ $result=$this->call_trigger('ORDER_CLASSIFY_BILLED',$user);
+ if ($result < 0) $error++;
+ // End call triggers
}
if (! $error)
@@ -2735,7 +2793,7 @@ class Commande extends CommonOrder
else
{
$this->error=$this->db->error();
- $this->db->rollback();
+ $this->db->rollback();
return -1;
}
}
@@ -2747,146 +2805,146 @@ class Commande extends CommonOrder
*/
function classifyUnBilled()
{
- global $conf, $user, $langs;
- $error = 0;
+ global $conf, $user, $langs;
+ $error = 0;
- $this->db->begin();
+ $this->db->begin();
- $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande SET facture = 0';
- $sql.= ' WHERE rowid = '.$this->id.' AND fk_statut > '.self::STATUS_DRAFT;
+ $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande SET facture = 0';
+ $sql.= ' WHERE rowid = '.$this->id.' AND fk_statut > '.self::STATUS_DRAFT;
- dol_syslog(get_class($this)."::classifyUnBilled", LOG_DEBUG);
- if ($this->db->query($sql))
- {
- if (! $error)
- {
- $this->oldcopy= clone $this;
- $this->billed=1;
- }
+ dol_syslog(get_class($this)."::classifyUnBilled", LOG_DEBUG);
+ if ($this->db->query($sql))
+ {
+ if (! $error)
+ {
+ $this->oldcopy= clone $this;
+ $this->billed=1;
+ }
- // Call trigger
- $result=$this->call_trigger('ORDER_CLASSIFY_UNBILLED',$user);
- if ($result < 0) $error++;
- // End call triggers
+ // Call trigger
+ $result=$this->call_trigger('ORDER_CLASSIFY_UNBILLED',$user);
+ if ($result < 0) $error++;
+ // End call triggers
- if (! $error)
- {
- $this->billed=0;
+ if (! $error)
+ {
+ $this->billed=0;
- $this->db->commit();
- return 1;
- }
- else
- {
- foreach($this->errors as $errmsg)
- {
- dol_syslog(get_class($this)."::classifyUnBilled ".$errmsg, LOG_ERR);
- $this->error.=($this->error?', '.$errmsg:$errmsg);
- }
- $this->db->rollback();
- return -1*$error;
- }
- }
- else
- {
- $this->error=$this->db->error();
- $this->db->rollback();
- return -1;
- }
+ $this->db->commit();
+ return 1;
+ }
+ else
+ {
+ foreach($this->errors as $errmsg)
+ {
+ dol_syslog(get_class($this)."::classifyUnBilled ".$errmsg, LOG_ERR);
+ $this->error.=($this->error?', '.$errmsg:$errmsg);
+ }
+ $this->db->rollback();
+ return -1*$error;
+ }
+ }
+ else
+ {
+ $this->error=$this->db->error();
+ $this->db->rollback();
+ return -1;
+ }
}
- /**
- * Update a line in database
- *
- * @param int $rowid Id of line to update
- * @param string $desc Description of line
- * @param float $pu Unit price
- * @param float $qty Quantity
- * @param float $remise_percent Percent of discount
- * @param float $txtva Taux TVA
- * @param float $txlocaltax1 Local tax 1 rate
- * @param float $txlocaltax2 Local tax 2 rate
- * @param string $price_base_type HT or TTC
- * @param int $info_bits Miscellaneous informations on line
- * @param int $date_start Start date of the line
- * @param int $date_end End date of the line
- * @param int $type Type of line (0=product, 1=service)
- * @param int $fk_parent_line Id of parent line (0 in most cases, used by modules adding sublevels into lines).
- * @param int $skip_update_total Keep fields total_xxx to 0 (used for special lines by some modules)
- * @param int $fk_fournprice Id of origin supplier price
- * @param int $pa_ht Price (without tax) of product when it was bought
- * @param string $label Label
- * @param int $special_code Special code (also used by externals modules!)
+ /**
+ * Update a line in database
+ *
+ * @param int $rowid Id of line to update
+ * @param string $desc Description of line
+ * @param float $pu Unit price
+ * @param float $qty Quantity
+ * @param float $remise_percent Percent of discount
+ * @param float $txtva Taux TVA
+ * @param float $txlocaltax1 Local tax 1 rate
+ * @param float $txlocaltax2 Local tax 2 rate
+ * @param string $price_base_type HT or TTC
+ * @param int $info_bits Miscellaneous informations on line
+ * @param int $date_start Start date of the line
+ * @param int $date_end End date of the line
+ * @param int $type Type of line (0=product, 1=service)
+ * @param int $fk_parent_line Id of parent line (0 in most cases, used by modules adding sublevels into lines).
+ * @param int $skip_update_total Keep fields total_xxx to 0 (used for special lines by some modules)
+ * @param int $fk_fournprice Id of origin supplier price
+ * @param int $pa_ht Price (without tax) of product when it was bought
+ * @param string $label Label
+ * @param int $special_code Special code (also used by externals modules!)
* @param array $array_options extrafields array
- * @param string $fk_unit Code of the unit to use. Null to use the default one
+ * @param string $fk_unit Code of the unit to use. Null to use the default one
* @param double $pu_ht_devise Amount in currency
- * @param int $notrigger disable line update trigger
- * @return int < 0 if KO, > 0 if OK
- */
+ * @param int $notrigger disable line update trigger
+ * @return int < 0 if KO, > 0 if OK
+ */
function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0.0,$txlocaltax2=0.0, $price_base_type='HT', $info_bits=0, $date_start='', $date_end='', $type=0, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='', $special_code=0, $array_options=0, $fk_unit=null, $pu_ht_devise = 0, $notrigger=0)
- {
- global $conf, $mysoc, $langs, $user;
+ {
+ global $conf, $mysoc, $langs, $user;
- dol_syslog(get_class($this)."::updateline id=$rowid, desc=$desc, pu=$pu, qty=$qty, remise_percent=$remise_percent, txtva=$txtva, txlocaltax1=$txlocaltax1, txlocaltax2=$txlocaltax2, price_base_type=$price_base_type, info_bits=$info_bits, date_start=$date_start, date_end=$date_end, type=$type, fk_parent_line=$fk_parent_line, pa_ht=$pa_ht, special_code=$special_code");
- include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
+ dol_syslog(get_class($this)."::updateline id=$rowid, desc=$desc, pu=$pu, qty=$qty, remise_percent=$remise_percent, txtva=$txtva, txlocaltax1=$txlocaltax1, txlocaltax2=$txlocaltax2, price_base_type=$price_base_type, info_bits=$info_bits, date_start=$date_start, date_end=$date_end, type=$type, fk_parent_line=$fk_parent_line, pa_ht=$pa_ht, special_code=$special_code");
+ include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
- if (! empty($this->brouillon))
- {
- $this->db->begin();
+ if (! empty($this->brouillon))
+ {
+ $this->db->begin();
- // Clean parameters
- if (empty($qty)) $qty=0;
- if (empty($info_bits)) $info_bits=0;
- if (empty($txtva)) $txtva=0;
- if (empty($txlocaltax1)) $txlocaltax1=0;
- if (empty($txlocaltax2)) $txlocaltax2=0;
- if (empty($remise_percent)) $remise_percent=0;
- if (empty($special_code) || $special_code == 3) $special_code=0;
+ // Clean parameters
+ if (empty($qty)) $qty=0;
+ if (empty($info_bits)) $info_bits=0;
+ if (empty($txtva)) $txtva=0;
+ if (empty($txlocaltax1)) $txlocaltax1=0;
+ if (empty($txlocaltax2)) $txlocaltax2=0;
+ if (empty($remise_percent)) $remise_percent=0;
+ if (empty($special_code) || $special_code == 3) $special_code=0;
- $remise_percent=price2num($remise_percent);
- $qty=price2num($qty);
- $pu = price2num($pu);
- $pa_ht=price2num($pa_ht);
- $pu_ht_devise=price2num($pu_ht_devise);
- $txtva=price2num($txtva);
- $txlocaltax1=price2num($txlocaltax1);
- $txlocaltax2=price2num($txlocaltax2);
+ $remise_percent=price2num($remise_percent);
+ $qty=price2num($qty);
+ $pu = price2num($pu);
+ $pa_ht=price2num($pa_ht);
+ $pu_ht_devise=price2num($pu_ht_devise);
+ $txtva=price2num($txtva);
+ $txlocaltax1=price2num($txlocaltax1);
+ $txlocaltax2=price2num($txlocaltax2);
- // Calcul du total TTC et de la TVA pour la ligne a partir de
- // qty, pu, remise_percent et txtva
- // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker
- // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva.
+ // Calcul du total TTC et de la TVA pour la ligne a partir de
+ // qty, pu, remise_percent et txtva
+ // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker
+ // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva.
- $localtaxes_type=getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc);
+ $localtaxes_type=getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc);
- // Clean vat code
- $vat_src_code='';
- if (preg_match('/\((.*)\)/', $txtva, $reg))
- {
- $vat_src_code = $reg[1];
- $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate.
- }
+ // Clean vat code
+ $vat_src_code='';
+ if (preg_match('/\((.*)\)/', $txtva, $reg))
+ {
+ $vat_src_code = $reg[1];
+ $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate.
+ }
- $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type, 100, $this->multicurrency_tx, $pu_ht_devise);
+ $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type, 100, $this->multicurrency_tx, $pu_ht_devise);
- $total_ht = $tabprice[0];
- $total_tva = $tabprice[1];
- $total_ttc = $tabprice[2];
- $total_localtax1 = $tabprice[9];
- $total_localtax2 = $tabprice[10];
+ $total_ht = $tabprice[0];
+ $total_tva = $tabprice[1];
+ $total_ttc = $tabprice[2];
+ $total_localtax1 = $tabprice[9];
+ $total_localtax2 = $tabprice[10];
$pu_ht = $tabprice[3];
$pu_tva = $tabprice[4];
$pu_ttc = $tabprice[5];
// MultiCurrency
$multicurrency_total_ht = $tabprice[16];
- $multicurrency_total_tva = $tabprice[17];
- $multicurrency_total_ttc = $tabprice[18];
+ $multicurrency_total_tva = $tabprice[17];
+ $multicurrency_total_ttc = $tabprice[18];
$pu_ht_devise = $tabprice[19];
- // Anciens indicateurs: $price, $subprice (a ne plus utiliser)
- $price = $pu_ht;
+ // Anciens indicateurs: $price, $subprice (a ne plus utiliser)
+ $price = $pu_ht;
if ($price_base_type == 'TTC')
{
$subprice = $pu_ttc;
@@ -2895,72 +2953,72 @@ class Commande extends CommonOrder
{
$subprice = $pu_ht;
}
- $remise = 0;
- if ($remise_percent > 0)
- {
- $remise = round(($pu * $remise_percent / 100),2);
- $price = ($pu - $remise);
- }
+ $remise = 0;
+ if ($remise_percent > 0)
+ {
+ $remise = round(($pu * $remise_percent / 100),2);
+ $price = ($pu - $remise);
+ }
- //Fetch current line from the database and then clone the object and set it in $oldline property
- $line = new OrderLine($this->db);
- $line->fetch($rowid);
+ //Fetch current line from the database and then clone the object and set it in $oldline property
+ $line = new OrderLine($this->db);
+ $line->fetch($rowid);
- if (!empty($line->fk_product))
- {
- $product=new Product($this->db);
- $result=$product->fetch($line->fk_product);
- $product_type=$product->type;
+ if (!empty($line->fk_product))
+ {
+ $product=new Product($this->db);
+ $result=$product->fetch($line->fk_product);
+ $product_type=$product->type;
- if (! empty($conf->global->STOCK_MUST_BE_ENOUGH_FOR_ORDER) && $product_type == 0 && $product->stock_reel < $qty)
- {
- $langs->load("errors");
- $this->error=$langs->trans('ErrorStockIsNotEnoughToAddProductOnOrder', $product->ref);
- dol_syslog(get_class($this)."::addline error=Product ".$product->ref.": ".$this->error, LOG_ERR);
- $this->db->rollback();
- return self::STOCK_NOT_ENOUGH_FOR_ORDER;
- }
- }
+ if (! empty($conf->global->STOCK_MUST_BE_ENOUGH_FOR_ORDER) && $product_type == 0 && $product->stock_reel < $qty)
+ {
+ $langs->load("errors");
+ $this->error=$langs->trans('ErrorStockIsNotEnoughToAddProductOnOrder', $product->ref);
+ dol_syslog(get_class($this)."::addline error=Product ".$product->ref.": ".$this->error, LOG_ERR);
+ $this->db->rollback();
+ return self::STOCK_NOT_ENOUGH_FOR_ORDER;
+ }
+ }
- $staticline = clone $line;
+ $staticline = clone $line;
- $line->oldline = $staticline;
- $this->line = $line;
- $this->line->context = $this->context;
+ $line->oldline = $staticline;
+ $this->line = $line;
+ $this->line->context = $this->context;
- // Reorder if fk_parent_line change
- if (! empty($fk_parent_line) && ! empty($staticline->fk_parent_line) && $fk_parent_line != $staticline->fk_parent_line)
- {
- $rangmax = $this->line_max($fk_parent_line);
- $this->line->rang = $rangmax + 1;
- }
+ // Reorder if fk_parent_line change
+ if (! empty($fk_parent_line) && ! empty($staticline->fk_parent_line) && $fk_parent_line != $staticline->fk_parent_line)
+ {
+ $rangmax = $this->line_max($fk_parent_line);
+ $this->line->rang = $rangmax + 1;
+ }
- $this->line->rowid=$rowid;
- $this->line->label=$label;
- $this->line->desc=$desc;
- $this->line->qty=$qty;
+ $this->line->rowid=$rowid;
+ $this->line->label=$label;
+ $this->line->desc=$desc;
+ $this->line->qty=$qty;
- $this->line->vat_src_code = $vat_src_code;
- $this->line->tva_tx = $txtva;
- $this->line->localtax1_tx = $txlocaltax1;
- $this->line->localtax2_tx = $txlocaltax2;
+ $this->line->vat_src_code = $vat_src_code;
+ $this->line->tva_tx = $txtva;
+ $this->line->localtax1_tx = $txlocaltax1;
+ $this->line->localtax2_tx = $txlocaltax2;
$this->line->localtax1_type = $localtaxes_type[0];
$this->line->localtax2_type = $localtaxes_type[2];
- $this->line->remise_percent = $remise_percent;
- $this->line->subprice = $subprice;
- $this->line->info_bits = $info_bits;
- $this->line->special_code = $special_code;
- $this->line->total_ht = $total_ht;
- $this->line->total_tva = $total_tva;
- $this->line->total_localtax1= $total_localtax1;
- $this->line->total_localtax2= $total_localtax2;
- $this->line->total_ttc = $total_ttc;
- $this->line->date_start = $date_start;
- $this->line->date_end = $date_end;
- $this->line->product_type = $type;
- $this->line->fk_parent_line = $fk_parent_line;
- $this->line->skip_update_total=$skip_update_total;
- $this->line->fk_unit = $fk_unit;
+ $this->line->remise_percent = $remise_percent;
+ $this->line->subprice = $subprice;
+ $this->line->info_bits = $info_bits;
+ $this->line->special_code = $special_code;
+ $this->line->total_ht = $total_ht;
+ $this->line->total_tva = $total_tva;
+ $this->line->total_localtax1= $total_localtax1;
+ $this->line->total_localtax2= $total_localtax2;
+ $this->line->total_ttc = $total_ttc;
+ $this->line->date_start = $date_start;
+ $this->line->date_end = $date_end;
+ $this->line->product_type = $type;
+ $this->line->fk_parent_line = $fk_parent_line;
+ $this->line->skip_update_total=$skip_update_total;
+ $this->line->fk_unit = $fk_unit;
$this->line->fk_fournprice = $fk_fournprice;
$this->line->pa_ht = $pa_ht;
@@ -2968,44 +3026,44 @@ class Commande extends CommonOrder
// Multicurrency
$this->line->multicurrency_subprice = $pu_ht_devise;
$this->line->multicurrency_total_ht = $multicurrency_total_ht;
- $this->line->multicurrency_total_tva = $multicurrency_total_tva;
- $this->line->multicurrency_total_ttc = $multicurrency_total_ttc;
+ $this->line->multicurrency_total_tva = $multicurrency_total_tva;
+ $this->line->multicurrency_total_ttc = $multicurrency_total_ttc;
- // TODO deprecated
- $this->line->price=$price;
- $this->line->remise=$remise;
+ // TODO deprecated
+ $this->line->price=$price;
+ $this->line->remise=$remise;
if (is_array($array_options) && count($array_options)>0) {
$this->line->array_options=$array_options;
}
- $result=$this->line->update($user, $notrigger);
- if ($result > 0)
- {
- // Reorder if child line
- if (! empty($fk_parent_line)) $this->line_order(true,'DESC');
+ $result=$this->line->update($user, $notrigger);
+ if ($result > 0)
+ {
+ // Reorder if child line
+ if (! empty($fk_parent_line)) $this->line_order(true,'DESC');
- // Mise a jour info denormalisees
- $this->update_price(1);
+ // Mise a jour info denormalisees
+ $this->update_price(1);
- $this->db->commit();
- return $result;
- }
- else
- {
- $this->error=$this->line->error;
+ $this->db->commit();
+ return $result;
+ }
+ else
+ {
+ $this->error=$this->line->error;
- $this->db->rollback();
- return -1;
- }
- }
- else
- {
- $this->error=get_class($this)."::updateline Order status makes operation forbidden";
- $this->errors=array('OrderStatusMakeOperationForbidden');
- return -2;
- }
- }
+ $this->db->rollback();
+ return -1;
+ }
+ }
+ else
+ {
+ $this->error=get_class($this)."::updateline Order status makes operation forbidden";
+ $this->errors=array('OrderStatusMakeOperationForbidden');
+ return -2;
+ }
+ }
/**
* Update database
@@ -3067,17 +3125,23 @@ class Commande extends CommonOrder
$error++; $this->errors[]="Error ".$this->db->lasterror();
}
- if (! $error)
+ if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options)>0)
{
- if (! $notrigger)
+ $result=$this->insertExtraFields();
+ if ($result < 0)
{
- // Call trigger
- $result=$this->call_trigger('ORDER_MODIFY', $user);
- if ($result < 0) $error++;
- // End call triggers
+ $error++;
}
}
+ if (! $error && ! $notrigger)
+ {
+ // Call trigger
+ $result=$this->call_trigger('ORDER_MODIFY', $user);
+ if ($result < 0) $error++;
+ // End call triggers
+ }
+
// Commit or rollback
if ($error)
{
@@ -3096,31 +3160,31 @@ class Commande extends CommonOrder
}
}
- /**
- * Delete the customer order
- *
- * @param User $user User object
- * @param int $notrigger 1=Does not execute triggers, 0= execute triggers
- * @return int <=0 if KO, >0 if OK
- */
- function delete($user, $notrigger=0)
- {
- global $conf, $langs;
- require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
+ /**
+ * Delete the customer order
+ *
+ * @param User $user User object
+ * @param int $notrigger 1=Does not execute triggers, 0= execute triggers
+ * @return int <=0 if KO, >0 if OK
+ */
+ function delete($user, $notrigger=0)
+ {
+ global $conf, $langs;
+ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
- $error = 0;
+ $error = 0;
- dol_syslog(get_class($this) . "::delete ".$this->id, LOG_DEBUG);
+ dol_syslog(get_class($this) . "::delete ".$this->id, LOG_DEBUG);
- $this->db->begin();
+ $this->db->begin();
- if (! $error && ! $notrigger)
- {
- // Call trigger
- $result=$this->call_trigger('ORDER_DELETE',$user);
- if ($result < 0) $error++;
- // End call triggers
- }
+ if (! $error && ! $notrigger)
+ {
+ // Call trigger
+ $result=$this->call_trigger('ORDER_DELETE',$user);
+ if ($result < 0) $error++;
+ // End call triggers
+ }
if ($this->nb_expedition() != 0)
{
@@ -3128,311 +3192,318 @@ class Commande extends CommonOrder
$error++;
}
- if (! $error)
- {
- // Delete order details
- $sql = 'DELETE FROM '.MAIN_DB_PREFIX."commandedet WHERE fk_commande = ".$this->id;
- if (! $this->db->query($sql) )
- {
- $error++;
- $this->errors[]=$this->db->lasterror();
- }
- }
+ if (! $error)
+ {
+ // Delete order details
+ $sql = 'DELETE FROM '.MAIN_DB_PREFIX."commandedet WHERE fk_commande = ".$this->id;
+ if (! $this->db->query($sql) )
+ {
+ $error++;
+ $this->errors[]=$this->db->lasterror();
+ }
+ }
- if (! $error)
- {
- // Delete linked object
- $res = $this->deleteObjectLinked();
- if ($res < 0) $error++;
- }
+ if (! $error)
+ {
+ // Delete linked object
+ $res = $this->deleteObjectLinked();
+ if ($res < 0) $error++;
+ }
- if (! $error)
- {
- // Delete linked contacts
- $res = $this->delete_linked_contact();
- if ($res < 0) $error++;
- }
+ if (! $error)
+ {
+ // Delete linked contacts
+ $res = $this->delete_linked_contact();
+ if ($res < 0) $error++;
+ }
- if (! $error)
- {
- // Remove extrafields
- if ((! $error) && (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) // For avoid conflicts if trigger used
- {
- $result=$this->deleteExtraFields();
- if ($result < 0)
- {
- $error++;
- dol_syslog(get_class($this)."::delete error -4 ".$this->error, LOG_ERR);
- }
- }
- }
+ if (! $error)
+ {
+ // Remove extrafields
+ if ((! $error) && (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) // For avoid conflicts if trigger used
+ {
+ $result=$this->deleteExtraFields();
+ if ($result < 0)
+ {
+ $error++;
+ dol_syslog(get_class($this)."::delete error -4 ".$this->error, LOG_ERR);
+ }
+ }
+ }
- if (! $error)
- {
- // Delete object
- $sql = 'DELETE FROM '.MAIN_DB_PREFIX."commande WHERE rowid = ".$this->id;
- if (! $this->db->query($sql) )
- {
- $error++;
- $this->errors[]=$this->db->lasterror();
- }
- }
+ if (! $error)
+ {
+ // Delete object
+ $sql = 'DELETE FROM '.MAIN_DB_PREFIX."commande WHERE rowid = ".$this->id;
+ if (! $this->db->query($sql) )
+ {
+ $error++;
+ $this->errors[]=$this->db->lasterror();
+ }
+ }
- if (! $error)
- {
- // Remove directory with files
- $comref = dol_sanitizeFileName($this->ref);
- if ($conf->commande->dir_output && !empty($this->ref))
- {
- $dir = $conf->commande->dir_output . "/" . $comref ;
- $file = $conf->commande->dir_output . "/" . $comref . "/" . $comref . ".pdf";
- if (file_exists($file)) // We must delete all files before deleting directory
- {
- dol_delete_preview($this);
+ if (! $error)
+ {
+ // Remove directory with files
+ $comref = dol_sanitizeFileName($this->ref);
+ if ($conf->commande->dir_output && !empty($this->ref))
+ {
+ $dir = $conf->commande->dir_output . "/" . $comref ;
+ $file = $conf->commande->dir_output . "/" . $comref . "/" . $comref . ".pdf";
+ if (file_exists($file)) // We must delete all files before deleting directory
+ {
+ dol_delete_preview($this);
- if (! dol_delete_file($file,0,0,0,$this)) // For triggers
- {
- $this->db->rollback();
- return 0;
- }
- }
- if (file_exists($dir))
- {
- if (! dol_delete_dir_recursive($dir))
- {
- $this->error=$langs->trans("ErrorCanNotDeleteDir",$dir);
- $this->db->rollback();
- return 0;
- }
- }
- }
- }
+ if (! dol_delete_file($file,0,0,0,$this)) // For triggers
+ {
+ $this->db->rollback();
+ return 0;
+ }
+ }
+ if (file_exists($dir))
+ {
+ if (! dol_delete_dir_recursive($dir))
+ {
+ $this->error=$langs->trans("ErrorCanNotDeleteDir",$dir);
+ $this->db->rollback();
+ return 0;
+ }
+ }
+ }
+ }
- if (! $error)
- {
- $this->db->commit();
- return 1;
- }
- else
- {
- foreach($this->errors as $errmsg)
- {
- $this->error.=($this->error?', '.$errmsg:$errmsg);
- }
- $this->db->rollback();
- return -1*$error;
- }
- }
+ if (! $error)
+ {
+ $this->db->commit();
+ return 1;
+ }
+ else
+ {
+ foreach($this->errors as $errmsg)
+ {
+ $this->error.=($this->error?', '.$errmsg:$errmsg);
+ }
+ $this->db->rollback();
+ return -1*$error;
+ }
+ }
- /**
- * Load indicators for dashboard (this->nbtodo and this->nbtodolate)
- *
- * @param User $user Object user
- * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK
- */
- function load_board($user)
- {
- global $conf, $langs;
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
+ /**
+ * Load indicators for dashboard (this->nbtodo and this->nbtodolate)
+ *
+ * @param User $user Object user
+ * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK
+ */
+ function load_board($user)
+ {
+ // phpcs:enable
+ global $conf, $langs;
- $clause = " WHERE";
+ $clause = " WHERE";
- $sql = "SELECT c.rowid, c.date_creation as datec, c.date_commande, c.date_livraison as delivery_date, c.fk_statut";
- $sql.= " FROM ".MAIN_DB_PREFIX."commande as c";
- if (!$user->rights->societe->client->voir && !$user->societe_id)
- {
- $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON c.fk_soc = sc.fk_soc";
- $sql.= " WHERE sc.fk_user = " .$user->id;
- $clause = " AND";
- }
- $sql.= $clause." c.entity IN (".getEntity('commande').")";
- //$sql.= " AND c.fk_statut IN (1,2,3) AND c.facture = 0";
- $sql.= " AND ((c.fk_statut IN (".self::STATUS_VALIDATED.",".self::STATUS_SHIPMENTONPROCESS.")) OR (c.fk_statut = ".self::STATUS_CLOSED." AND c.facture = 0))"; // If status is 2 and facture=1, it must be selected
- if ($user->societe_id) $sql.=" AND c.fk_soc = ".$user->societe_id;
+ $sql = "SELECT c.rowid, c.date_creation as datec, c.date_commande, c.date_livraison as delivery_date, c.fk_statut, c.total_ht";
+ $sql.= " FROM ".MAIN_DB_PREFIX."commande as c";
+ if (!$user->rights->societe->client->voir && !$user->societe_id)
+ {
+ $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON c.fk_soc = sc.fk_soc";
+ $sql.= " WHERE sc.fk_user = " .$user->id;
+ $clause = " AND";
+ }
+ $sql.= $clause." c.entity IN (".getEntity('commande').")";
+ //$sql.= " AND c.fk_statut IN (1,2,3) AND c.facture = 0";
+ $sql.= " AND ((c.fk_statut IN (".self::STATUS_VALIDATED.",".self::STATUS_SHIPMENTONPROCESS.")) OR (c.fk_statut = ".self::STATUS_CLOSED." AND c.facture = 0))"; // If status is 2 and facture=1, it must be selected
+ if ($user->societe_id) $sql.=" AND c.fk_soc = ".$user->societe_id;
- $resql=$this->db->query($sql);
- if ($resql)
- {
- $response = new WorkboardResponse();
- $response->warning_delay=$conf->commande->client->warning_delay/60/60/24;
- $response->label=$langs->trans("OrdersToProcess");
- $response->url=DOL_URL_ROOT.'/commande/list.php?viewstatut=-3&mainmenu=commercial&leftmenu=orders';
- $response->img=img_object('',"order");
+ $resql=$this->db->query($sql);
+ if ($resql)
+ {
+ $response = new WorkboardResponse();
+ $response->warning_delay=$conf->commande->client->warning_delay/60/60/24;
+ $response->label=$langs->trans("OrdersToProcess");
+ $response->url=DOL_URL_ROOT.'/commande/list.php?viewstatut=-3&mainmenu=commercial&leftmenu=orders';
+ $response->img=img_object('',"order");
- $generic_commande = new Commande($this->db);
+ $generic_commande = new Commande($this->db);
- while ($obj=$this->db->fetch_object($resql))
- {
- $response->nbtodo++;
+ while ($obj=$this->db->fetch_object($resql))
+ {
+ $response->nbtodo++;
+ $response->total+= $obj->total_ht;
- $generic_commande->statut = $obj->fk_statut;
- $generic_commande->date_commande = $this->db->jdate($obj->date_commande);
- $generic_commande->date_livraison = $this->db->jdate($obj->delivery_date);
+ $generic_commande->statut = $obj->fk_statut;
+ $generic_commande->date_commande = $this->db->jdate($obj->date_commande);
+ $generic_commande->date_livraison = $this->db->jdate($obj->delivery_date);
- if ($generic_commande->hasDelay()) {
- $response->nbtodolate++;
- }
- }
+ if ($generic_commande->hasDelay()) {
+ $response->nbtodolate++;
+ }
+ }
- return $response;
- }
- else
- {
- $this->error=$this->db->error();
- return -1;
- }
- }
+ return $response;
+ }
+ else
+ {
+ $this->error=$this->db->error();
+ return -1;
+ }
+ }
- /**
- * Return source label of order
- *
- * @return string Label
- */
- function getLabelSource()
- {
- global $langs;
+ /**
+ * Return source label of order
+ *
+ * @return string Label
+ */
+ function getLabelSource()
+ {
+ global $langs;
- $label=$langs->trans('OrderSource'.$this->source);
+ $label=$langs->trans('OrderSource'.$this->source);
- if ($label == 'OrderSource') return '';
- return $label;
- }
+ if ($label == 'OrderSource') return '';
+ return $label;
+ }
- /**
- * Return status label of Order
- *
- * @param int $mode 0=Long label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Long label, 5=Short label + Picto, 6=Long label + Picto
- * @return string Label of status
- */
- function getLibStatut($mode)
- {
- return $this->LibStatut($this->statut, $this->billed, $mode);
- }
+ /**
+ * Return status label of Order
+ *
+ * @param int $mode 0=Long label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Long label, 5=Short label + Picto, 6=Long label + Picto
+ * @return string Label of status
+ */
+ function getLibStatut($mode)
+ {
+ return $this->LibStatut($this->statut, $this->billed, $mode);
+ }
- /**
- * Return label of status
- *
- * @param int $statut Id statut
- * @param int $billed If invoiced
- * @param int $mode 0=Long label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Long label, 5=Short label + Picto, 6=Long label + Picto
- * @param int $donotshowbilled Do not show billed status after order status
- * @return string Label of status
- */
- function LibStatut($statut,$billed,$mode,$donotshowbilled=0)
- {
- global $langs, $conf;
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
+ /**
+ * Return label of status
+ *
+ * @param int $statut Id statut
+ * @param int $billed If invoiced
+ * @param int $mode 0=Long label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Long label, 5=Short label + Picto, 6=Long label + Picto
+ * @param int $donotshowbilled Do not show billed status after order status
+ * @return string Label of status
+ */
+ function LibStatut($statut,$billed,$mode,$donotshowbilled=0)
+ {
+ // phpcs:enable
+ global $langs, $conf;
- $billedtext = '';
- if (empty($donotshowbilled)) $billedtext .= ($billed?' - '.$langs->trans("Billed"):'');
+ $billedtext = '';
+ if (empty($donotshowbilled)) $billedtext .= ($billed?' - '.$langs->trans("Billed"):'');
- //print 'x'.$statut.'-'.$billed;
- if ($mode == 0)
- {
- if ($statut==self::STATUS_CANCELED) return $langs->trans('StatusOrderCanceled');
- if ($statut==self::STATUS_DRAFT) return $langs->trans('StatusOrderDraft');
- if ($statut==self::STATUS_VALIDATED) return $langs->trans('StatusOrderValidated').$billedtext;
- if ($statut==self::STATUS_SHIPMENTONPROCESS) return $langs->trans('StatusOrderSentShort').$billedtext;
- if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderToBill');
- if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderProcessed').$billedtext;
- if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderDelivered');
- }
- elseif ($mode == 1)
- {
- if ($statut==self::STATUS_CANCELED) return $langs->trans('StatusOrderCanceledShort');
- if ($statut==self::STATUS_DRAFT) return $langs->trans('StatusOrderDraftShort');
- if ($statut==self::STATUS_VALIDATED) return $langs->trans('StatusOrderValidatedShort').$billedtext;
- if ($statut==self::STATUS_SHIPMENTONPROCESS) return $langs->trans('StatusOrderSentShort').$billedtext;
- if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderToBillShort');
- if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderProcessed').$billedtext;
- if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderDelivered');
- }
- elseif ($mode == 2)
- {
- if ($statut==self::STATUS_CANCELED) return img_picto($langs->trans('StatusOrderCanceled'),'statut5').' '.$langs->trans('StatusOrderCanceledShort');
- if ($statut==self::STATUS_DRAFT) return img_picto($langs->trans('StatusOrderDraft'),'statut0').' '.$langs->trans('StatusOrderDraftShort');
- if ($statut==self::STATUS_VALIDATED) return img_picto($langs->trans('StatusOrderValidated'),'statut1').' '.$langs->trans('StatusOrderValidatedShort').$billedtext;
- if ($statut==self::STATUS_SHIPMENTONPROCESS) return img_picto($langs->trans('StatusOrderSent'),'statut3').' '.$langs->trans('StatusOrderSentShort').$billedtext;
- if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderToBill'),'statut4').' '.$langs->trans('StatusOrderToBillShort');
- if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderProcessed').$billedtext,'statut6').' '.$langs->trans('StatusOrderProcessed').$billedtext;
- if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderDelivered'),'statut6').' '.$langs->trans('StatusOrderDeliveredShort');
- }
- elseif ($mode == 3)
- {
- if ($statut==self::STATUS_CANCELED) return img_picto($langs->trans('StatusOrderCanceled'),'statut5');
- if ($statut==self::STATUS_DRAFT) return img_picto($langs->trans('StatusOrderDraft'),'statut0');
- if ($statut==self::STATUS_VALIDATED) return img_picto($langs->trans('StatusOrderValidated').$billedtext,'statut1');
- if ($statut==self::STATUS_SHIPMENTONPROCESS) return img_picto($langs->trans('StatusOrderSentShort').$billedtext,'statut3');
- if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderToBill'),'statut4');
- if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderProcessed').$billedtext,'statut6');
- if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderDelivered'),'statut6');
- }
- elseif ($mode == 4)
- {
- if ($statut==self::STATUS_CANCELED) return img_picto($langs->trans('StatusOrderCanceled'),'statut5').' '.$langs->trans('StatusOrderCanceled');
- if ($statut==self::STATUS_DRAFT) return img_picto($langs->trans('StatusOrderDraft'),'statut0').' '.$langs->trans('StatusOrderDraft');
- if ($statut==self::STATUS_VALIDATED) return img_picto($langs->trans('StatusOrderValidated').$billedtext,'statut1').' '.$langs->trans('StatusOrderValidated').$billedtext;
- if ($statut==self::STATUS_SHIPMENTONPROCESS) return img_picto($langs->trans('StatusOrderSentShort').$billedtext,'statut3').' '.$langs->trans('StatusOrderSent').$billedtext;
- if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderToBill'),'statut4').' '.$langs->trans('StatusOrderToBill');
- if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderProcessedShort').$billedtext,'statut6').' '.$langs->trans('StatusOrderProcessed').$billedtext;
- if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderDelivered'),'statut6').' '.$langs->trans('StatusOrderDelivered');
- }
- elseif ($mode == 5)
- {
- if ($statut==self::STATUS_CANCELED) return ''.$langs->trans('StatusOrderCanceledShort').' '.img_picto($langs->trans('StatusOrderCanceled'),'statut5');
- if ($statut==self::STATUS_DRAFT) return ''.$langs->trans('StatusOrderDraftShort').' '.img_picto($langs->trans('StatusOrderDraft'),'statut0');
- if ($statut==self::STATUS_VALIDATED) return ''.$langs->trans('StatusOrderValidatedShort').$billedtext.' '.img_picto($langs->trans('StatusOrderValidated').$billedtext,'statut1');
- if ($statut==self::STATUS_SHIPMENTONPROCESS) return ''.$langs->trans('StatusOrderSentShort').$billedtext.' '.img_picto($langs->trans('StatusOrderSent').$billedtext,'statut3');
- if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return ''.$langs->trans('StatusOrderToBillShort').' '.img_picto($langs->trans('StatusOrderToBill'),'statut4');
- if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return ''.$langs->trans('StatusOrderProcessedShort').$billedtext.' '.img_picto($langs->trans('StatusOrderProcessed').$billedtext,'statut6');
- if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return ''.$langs->trans('StatusOrderDeliveredShort').' '.img_picto($langs->trans('StatusOrderDelivered'),'statut6');
- }
- elseif ($mode == 6)
- {
- if ($statut==self::STATUS_CANCELED) return ''.$langs->trans('StatusOrderCanceled').' '.img_picto($langs->trans('StatusOrderCanceled'),'statut5');
- if ($statut==self::STATUS_DRAFT) return ''.$langs->trans('StatusOrderDraft').' '.img_picto($langs->trans('StatusOrderDraft'),'statut0');
- if ($statut==self::STATUS_VALIDATED) return ''.$langs->trans('StatusOrderValidated').$billedtext.' '.img_picto($langs->trans('StatusOrderValidated').$billedtext,'statut1');
- if ($statut==self::STATUS_SHIPMENTONPROCESS) return ''.$langs->trans('StatusOrderSent').$billedtext.' '.img_picto($langs->trans('StatusOrderSent').$billedtext,'statut3');
- if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return ''.$langs->trans('StatusOrderToBill').' '.img_picto($langs->trans('StatusOrderToBill'),'statut4');
- if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return ''.$langs->trans('StatusOrderProcessed').$billedtext.' '.img_picto($langs->trans('StatusOrderProcessed').$billedtext,'statut6');
- if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return ''.$langs->trans('StatusOrderDelivered').' '.img_picto($langs->trans('StatusOrderDelivered'),'statut6');
- }
-
- }
+ //print 'x'.$statut.'-'.$billed;
+ if ($mode == 0)
+ {
+ if ($statut==self::STATUS_CANCELED) return $langs->trans('StatusOrderCanceled');
+ if ($statut==self::STATUS_DRAFT) return $langs->trans('StatusOrderDraft');
+ if ($statut==self::STATUS_VALIDATED) return $langs->trans('StatusOrderValidated').$billedtext;
+ if ($statut==self::STATUS_SHIPMENTONPROCESS) return $langs->trans('StatusOrderSentShort').$billedtext;
+ if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderToBill');
+ if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderProcessed').$billedtext;
+ if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderDelivered');
+ }
+ elseif ($mode == 1)
+ {
+ if ($statut==self::STATUS_CANCELED) return $langs->trans('StatusOrderCanceledShort');
+ if ($statut==self::STATUS_DRAFT) return $langs->trans('StatusOrderDraftShort');
+ if ($statut==self::STATUS_VALIDATED) return $langs->trans('StatusOrderValidatedShort').$billedtext;
+ if ($statut==self::STATUS_SHIPMENTONPROCESS) return $langs->trans('StatusOrderSentShort').$billedtext;
+ if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderToBillShort');
+ if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderProcessed').$billedtext;
+ if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderDelivered');
+ }
+ elseif ($mode == 2)
+ {
+ if ($statut==self::STATUS_CANCELED) return img_picto($langs->trans('StatusOrderCanceled'),'statut5').' '.$langs->trans('StatusOrderCanceledShort');
+ if ($statut==self::STATUS_DRAFT) return img_picto($langs->trans('StatusOrderDraft'),'statut0').' '.$langs->trans('StatusOrderDraftShort');
+ if ($statut==self::STATUS_VALIDATED) return img_picto($langs->trans('StatusOrderValidated'),'statut1').' '.$langs->trans('StatusOrderValidatedShort').$billedtext;
+ if ($statut==self::STATUS_SHIPMENTONPROCESS) return img_picto($langs->trans('StatusOrderSent'),'statut3').' '.$langs->trans('StatusOrderSentShort').$billedtext;
+ if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderToBill'),'statut4').' '.$langs->trans('StatusOrderToBillShort');
+ if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderProcessed').$billedtext,'statut6').' '.$langs->trans('StatusOrderProcessed').$billedtext;
+ if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderDelivered'),'statut6').' '.$langs->trans('StatusOrderDeliveredShort');
+ }
+ elseif ($mode == 3)
+ {
+ if ($statut==self::STATUS_CANCELED) return img_picto($langs->trans('StatusOrderCanceled'),'statut5');
+ if ($statut==self::STATUS_DRAFT) return img_picto($langs->trans('StatusOrderDraft'),'statut0');
+ if ($statut==self::STATUS_VALIDATED) return img_picto($langs->trans('StatusOrderValidated').$billedtext,'statut1');
+ if ($statut==self::STATUS_SHIPMENTONPROCESS) return img_picto($langs->trans('StatusOrderSentShort').$billedtext,'statut3');
+ if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderToBill'),'statut4');
+ if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderProcessed').$billedtext,'statut6');
+ if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderDelivered'),'statut6');
+ }
+ elseif ($mode == 4)
+ {
+ if ($statut==self::STATUS_CANCELED) return img_picto($langs->trans('StatusOrderCanceled'),'statut5').' '.$langs->trans('StatusOrderCanceled');
+ if ($statut==self::STATUS_DRAFT) return img_picto($langs->trans('StatusOrderDraft'),'statut0').' '.$langs->trans('StatusOrderDraft');
+ if ($statut==self::STATUS_VALIDATED) return img_picto($langs->trans('StatusOrderValidated').$billedtext,'statut1').' '.$langs->trans('StatusOrderValidated').$billedtext;
+ if ($statut==self::STATUS_SHIPMENTONPROCESS) return img_picto($langs->trans('StatusOrderSentShort').$billedtext,'statut3').' '.$langs->trans('StatusOrderSent').$billedtext;
+ if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderToBill'),'statut4').' '.$langs->trans('StatusOrderToBill');
+ if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderProcessedShort').$billedtext,'statut6').' '.$langs->trans('StatusOrderProcessed').$billedtext;
+ if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderDelivered'),'statut6').' '.$langs->trans('StatusOrderDelivered');
+ }
+ elseif ($mode == 5)
+ {
+ if ($statut==self::STATUS_CANCELED) return ''.$langs->trans('StatusOrderCanceledShort').' '.img_picto($langs->trans('StatusOrderCanceled'),'statut5');
+ if ($statut==self::STATUS_DRAFT) return ''.$langs->trans('StatusOrderDraftShort').' '.img_picto($langs->trans('StatusOrderDraft'),'statut0');
+ if ($statut==self::STATUS_VALIDATED) return ''.$langs->trans('StatusOrderValidatedShort').$billedtext.' '.img_picto($langs->trans('StatusOrderValidated').$billedtext,'statut1');
+ if ($statut==self::STATUS_SHIPMENTONPROCESS) return ''.$langs->trans('StatusOrderSentShort').$billedtext.' '.img_picto($langs->trans('StatusOrderSent').$billedtext,'statut3');
+ if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return ''.$langs->trans('StatusOrderToBillShort').' '.img_picto($langs->trans('StatusOrderToBill'),'statut4');
+ if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return ''.$langs->trans('StatusOrderProcessedShort').$billedtext.' '.img_picto($langs->trans('StatusOrderProcessed').$billedtext,'statut6');
+ if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return ''.$langs->trans('StatusOrderDeliveredShort').' '.img_picto($langs->trans('StatusOrderDelivered'),'statut6');
+ }
+ elseif ($mode == 6)
+ {
+ if ($statut==self::STATUS_CANCELED) return ''.$langs->trans('StatusOrderCanceled').' '.img_picto($langs->trans('StatusOrderCanceled'),'statut5');
+ if ($statut==self::STATUS_DRAFT) return ''.$langs->trans('StatusOrderDraft').' '.img_picto($langs->trans('StatusOrderDraft'),'statut0');
+ if ($statut==self::STATUS_VALIDATED) return ''.$langs->trans('StatusOrderValidated').$billedtext.' '.img_picto($langs->trans('StatusOrderValidated').$billedtext,'statut1');
+ if ($statut==self::STATUS_SHIPMENTONPROCESS) return ''.$langs->trans('StatusOrderSent').$billedtext.' '.img_picto($langs->trans('StatusOrderSent').$billedtext,'statut3');
+ if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return ''.$langs->trans('StatusOrderToBill').' '.img_picto($langs->trans('StatusOrderToBill'),'statut4');
+ if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return ''.$langs->trans('StatusOrderProcessed').$billedtext.' '.img_picto($langs->trans('StatusOrderProcessed').$billedtext,'statut6');
+ if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return ''.$langs->trans('StatusOrderDelivered').' '.img_picto($langs->trans('StatusOrderDelivered'),'statut6');
+ }
+ }
- /**
- * Return clicable link of object (with eventually picto)
- *
- * @param int $withpicto Add picto into link
- * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link)
- * @param int $max Max length to show
- * @param int $short ???
- * @param int $notooltip 1=Disable tooltip
- * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
- * @return string String with URL
- */
- function getNomUrl($withpicto=0, $option='', $max=0, $short=0, $notooltip=0, $save_lastsearch_value=-1)
- {
- global $conf, $langs, $user;
+ /**
+ * Return clicable link of object (with eventually picto)
+ *
+ * @param int $withpicto Add picto into link
+ * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link)
+ * @param int $max Max length to show
+ * @param int $short ???
+ * @param int $notooltip 1=Disable tooltip
+ * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
+ * @return string String with URL
+ */
+ function getNomUrl($withpicto=0, $option='', $max=0, $short=0, $notooltip=0, $save_lastsearch_value=-1)
+ {
+ global $conf, $langs, $user;
- 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='';
+ $result='';
- if (! empty($conf->expedition->enabled) && ($option == '1' || $option == '2')) $url = DOL_URL_ROOT.'/expedition/shipment.php?id='.$this->id;
- else $url = DOL_URL_ROOT.'/commande/card.php?id='.$this->id;
+ if (! empty($conf->expedition->enabled) && ($option == '1' || $option == '2')) $url = DOL_URL_ROOT.'/expedition/shipment.php?id='.$this->id;
+ else $url = DOL_URL_ROOT.'/commande/card.php?id='.$this->id;
- if ($option !== 'nolink')
- {
- // Add param to save lastsearch_values or not
- $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0);
- if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1;
- if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1';
- }
+ if (!$user->rights->commande->lire)
+ $option = 'nolink';
- if ($short) return $url;
+ if ($option !== 'nolink')
+ {
+ // Add param to save lastsearch_values or not
+ $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0);
+ if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1;
+ if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1';
+ }
- $label = '';
+ if ($short) return $url;
+
+ $label = '';
if ($user->rights->commande->lire) {
$label = ''.$langs->trans("ShowOrder").'';
@@ -3452,225 +3523,232 @@ class Commande extends CommonOrder
$linkclose='';
if (empty($notooltip) && $user->rights->commande->lire)
{
- if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
- {
- $label=$langs->trans("ShowOrder");
- $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"';
- }
- $linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"';
- $linkclose.=' class="classfortooltip"';
+ if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
+ {
+ $label=$langs->trans("ShowOrder");
+ $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"';
+ }
+ $linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"';
+ $linkclose.=' class="classfortooltip"';
}
- $linkstart = '';
- $linkend='';
+ $linkstart = '';
+ $linkend='';
- $result .= $linkstart;
- 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.= $this->ref;
- $result .= $linkend;
+ if ($option === 'nolink') {
+ $linkstart = '';
+ $linkend = '';
+ }
- return $result;
- }
+ $result .= $linkstart;
+ 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.= $this->ref;
+ $result .= $linkend;
+
+ return $result;
+ }
- /**
- * Charge les informations d'ordre info dans l'objet commande
- *
- * @param int $id Id of order
- * @return void
- */
- function info($id)
- {
- $sql = 'SELECT c.rowid, date_creation as datec, tms as datem,';
- $sql.= ' date_valid as datev,';
- $sql.= ' date_cloture as datecloture,';
- $sql.= ' fk_user_author, fk_user_valid, fk_user_cloture';
- $sql.= ' FROM '.MAIN_DB_PREFIX.'commande as c';
- $sql.= ' WHERE c.rowid = '.$id;
- $result=$this->db->query($sql);
- if ($result)
- {
- if ($this->db->num_rows($result))
- {
- $obj = $this->db->fetch_object($result);
- $this->id = $obj->rowid;
- if ($obj->fk_user_author)
- {
- $cuser = new User($this->db);
- $cuser->fetch($obj->fk_user_author);
- $this->user_creation = $cuser;
- }
+ /**
+ * Charge les informations d'ordre info dans l'objet commande
+ *
+ * @param int $id Id of order
+ * @return void
+ */
+ function info($id)
+ {
+ $sql = 'SELECT c.rowid, date_creation as datec, tms as datem,';
+ $sql.= ' date_valid as datev,';
+ $sql.= ' date_cloture as datecloture,';
+ $sql.= ' fk_user_author, fk_user_valid, fk_user_cloture';
+ $sql.= ' FROM '.MAIN_DB_PREFIX.'commande as c';
+ $sql.= ' WHERE c.rowid = '.$id;
+ $result=$this->db->query($sql);
+ if ($result)
+ {
+ if ($this->db->num_rows($result))
+ {
+ $obj = $this->db->fetch_object($result);
+ $this->id = $obj->rowid;
+ if ($obj->fk_user_author)
+ {
+ $cuser = new User($this->db);
+ $cuser->fetch($obj->fk_user_author);
+ $this->user_creation = $cuser;
+ }
- if ($obj->fk_user_valid)
- {
- $vuser = new User($this->db);
- $vuser->fetch($obj->fk_user_valid);
- $this->user_validation = $vuser;
- }
+ if ($obj->fk_user_valid)
+ {
+ $vuser = new User($this->db);
+ $vuser->fetch($obj->fk_user_valid);
+ $this->user_validation = $vuser;
+ }
- if ($obj->fk_user_cloture)
- {
- $cluser = new User($this->db);
- $cluser->fetch($obj->fk_user_cloture);
- $this->user_cloture = $cluser;
- }
+ if ($obj->fk_user_cloture)
+ {
+ $cluser = new User($this->db);
+ $cluser->fetch($obj->fk_user_cloture);
+ $this->user_cloture = $cluser;
+ }
- $this->date_creation = $this->db->jdate($obj->datec);
- $this->date_modification = $this->db->jdate($obj->datem);
- $this->date_validation = $this->db->jdate($obj->datev);
- $this->date_cloture = $this->db->jdate($obj->datecloture);
- }
+ $this->date_creation = $this->db->jdate($obj->datec);
+ $this->date_modification = $this->db->jdate($obj->datem);
+ $this->date_validation = $this->db->jdate($obj->datev);
+ $this->date_cloture = $this->db->jdate($obj->datecloture);
+ }
- $this->db->free($result);
+ $this->db->free($result);
- }
- else
- {
- dol_print_error($this->db);
- }
- }
+ }
+ else
+ {
+ dol_print_error($this->db);
+ }
+ }
- /**
- * Initialise an instance with random values.
- * Used to build previews or test instances.
- * id must be 0 if object instance is a specimen.
- *
- * @return void
- */
- function initAsSpecimen()
- {
- global $langs;
+ /**
+ * Initialise an instance with random values.
+ * Used to build previews or test instances.
+ * id must be 0 if object instance is a specimen.
+ *
+ * @return void
+ */
+ function initAsSpecimen()
+ {
+ global $langs;
- dol_syslog(get_class($this)."::initAsSpecimen");
+ dol_syslog(get_class($this)."::initAsSpecimen");
- // Load array of products prodids
- $num_prods = 0;
- $prodids = array();
- $sql = "SELECT rowid";
- $sql.= " FROM ".MAIN_DB_PREFIX."product";
- $sql.= " WHERE entity IN (".getEntity('product').")";
- $resql = $this->db->query($sql);
- if ($resql)
- {
- $num_prods = $this->db->num_rows($resql);
- $i = 0;
- while ($i < $num_prods)
- {
- $i++;
- $row = $this->db->fetch_row($resql);
- $prodids[$i] = $row[0];
- }
- }
+ // Load array of products prodids
+ $num_prods = 0;
+ $prodids = array();
+ $sql = "SELECT rowid";
+ $sql.= " FROM ".MAIN_DB_PREFIX."product";
+ $sql.= " WHERE entity IN (".getEntity('product').")";
+ $resql = $this->db->query($sql);
+ if ($resql)
+ {
+ $num_prods = $this->db->num_rows($resql);
+ $i = 0;
+ while ($i < $num_prods)
+ {
+ $i++;
+ $row = $this->db->fetch_row($resql);
+ $prodids[$i] = $row[0];
+ }
+ }
- // Initialise parametres
- $this->id=0;
- $this->ref = 'SPECIMEN';
- $this->specimen=1;
- $this->socid = 1;
- $this->date = time();
- $this->date_lim_reglement=$this->date+3600*24*30;
- $this->cond_reglement_code = 'RECEP';
- $this->mode_reglement_code = 'CHQ';
- $this->availability_code = 'DSP';
- $this->demand_reason_code = 'SRC_00';
- $this->note_public='This is a comment (public)';
- $this->note_private='This is a comment (private)';
- // Lines
- $nbp = 5;
- $xnbp = 0;
- while ($xnbp < $nbp)
- {
- $line=new OrderLine($this->db);
+ // Initialise parametres
+ $this->id=0;
+ $this->ref = 'SPECIMEN';
+ $this->specimen=1;
+ $this->socid = 1;
+ $this->date = time();
+ $this->date_lim_reglement=$this->date+3600*24*30;
+ $this->cond_reglement_code = 'RECEP';
+ $this->mode_reglement_code = 'CHQ';
+ $this->availability_code = 'DSP';
+ $this->demand_reason_code = 'SRC_00';
+ $this->note_public='This is a comment (public)';
+ $this->note_private='This is a comment (private)';
+ // Lines
+ $nbp = 5;
+ $xnbp = 0;
+ while ($xnbp < $nbp)
+ {
+ $line=new OrderLine($this->db);
- $line->desc=$langs->trans("Description")." ".$xnbp;
- $line->qty=1;
- $line->subprice=100;
- $line->price=100;
- $line->tva_tx=20;
- if ($xnbp == 2)
- {
- $line->total_ht=50;
- $line->total_ttc=60;
- $line->total_tva=10;
- $line->remise_percent=50;
- }
- else
- {
- $line->total_ht=100;
- $line->total_ttc=120;
- $line->total_tva=20;
- $line->remise_percent=0;
- }
- if ($num_prods > 0)
- {
- $prodid = mt_rand(1, $num_prods);
- $line->fk_product=$prodids[$prodid];
+ $line->desc=$langs->trans("Description")." ".$xnbp;
+ $line->qty=1;
+ $line->subprice=100;
+ $line->price=100;
+ $line->tva_tx=20;
+ if ($xnbp == 2)
+ {
+ $line->total_ht=50;
+ $line->total_ttc=60;
+ $line->total_tva=10;
+ $line->remise_percent=50;
+ }
+ else
+ {
+ $line->total_ht=100;
+ $line->total_ttc=120;
+ $line->total_tva=20;
+ $line->remise_percent=0;
+ }
+ if ($num_prods > 0)
+ {
+ $prodid = mt_rand(1, $num_prods);
+ $line->fk_product=$prodids[$prodid];
$line->product_ref='SPECIMEN';
- }
+ }
- $this->lines[$xnbp]=$line;
+ $this->lines[$xnbp]=$line;
- $this->total_ht += $line->total_ht;
- $this->total_tva += $line->total_tva;
- $this->total_ttc += $line->total_ttc;
+ $this->total_ht += $line->total_ht;
+ $this->total_tva += $line->total_tva;
+ $this->total_ttc += $line->total_ttc;
- $xnbp++;
- }
- }
+ $xnbp++;
+ }
+ }
- /**
- * Charge indicateurs this->nb de tableau de bord
- *
- * @return int <0 si ko, >0 si ok
- */
- function load_state_board()
- {
- global $user;
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
+ /**
+ * Charge indicateurs this->nb de tableau de bord
+ *
+ * @return int <0 si ko, >0 si ok
+ */
+ function load_state_board()
+ {
+ // phpcs:enable
+ global $user;
- $this->nb=array();
- $clause = "WHERE";
+ $this->nb=array();
+ $clause = "WHERE";
- $sql = "SELECT count(co.rowid) as nb";
- $sql.= " FROM ".MAIN_DB_PREFIX."commande as co";
- $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON co.fk_soc = s.rowid";
- if (!$user->rights->societe->client->voir && !$user->societe_id)
- {
- $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc";
- $sql.= " WHERE sc.fk_user = " .$user->id;
- $clause = "AND";
- }
- $sql.= " ".$clause." co.entity IN (".getEntity('commande').")";
+ $sql = "SELECT count(co.rowid) as nb";
+ $sql.= " FROM ".MAIN_DB_PREFIX."commande as co";
+ $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON co.fk_soc = s.rowid";
+ if (!$user->rights->societe->client->voir && !$user->societe_id)
+ {
+ $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc";
+ $sql.= " WHERE sc.fk_user = " .$user->id;
+ $clause = "AND";
+ }
+ $sql.= " ".$clause." co.entity IN (".getEntity('commande').")";
- $resql=$this->db->query($sql);
- if ($resql)
- {
- while ($obj=$this->db->fetch_object($resql))
- {
- $this->nb["orders"]=$obj->nb;
- }
- $this->db->free($resql);
- return 1;
- }
- else
- {
- dol_print_error($this->db);
- $this->error=$this->db->error();
- return -1;
- }
- }
+ $resql=$this->db->query($sql);
+ if ($resql)
+ {
+ while ($obj=$this->db->fetch_object($resql))
+ {
+ $this->nb["orders"]=$obj->nb;
+ }
+ $this->db->free($resql);
+ return 1;
+ }
+ else
+ {
+ dol_print_error($this->db);
+ $this->error=$this->db->error();
+ return -1;
+ }
+ }
- /**
+ /**
* Create an array of order lines
*
* @return int >0 if OK, <0 if KO
- */
- function getLinesArray()
- {
- return $this->fetch_lines();
- }
+ */
+ function getLinesArray()
+ {
+ return $this->fetch_lines();
+ }
/**
* Create a document onto disk according to template module.
@@ -3680,7 +3758,7 @@ class Commande extends CommonOrder
* @param int $hidedetails Hide details of lines
* @param int $hidedesc Hide description
* @param int $hideref Hide ref
- * @param null|array $moreparams Array to provide more information
+ * @param null|array $moreparams Array to provide more information
* @return int 0 if KO, 1 if OK
*/
public function generateDocument($modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0, $moreparams=null)
@@ -3717,45 +3795,45 @@ class Commande extends CommonOrder
public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id)
{
$tables = array(
- 'commande'
+ 'commande'
);
return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables);
}
- /**
- * Is the customer order delayed?
- *
- * @return bool true if late, false if not
- */
- public function hasDelay()
- {
- global $conf;
+ /**
+ * Is the customer order delayed?
+ *
+ * @return bool true if late, false if not
+ */
+ public function hasDelay()
+ {
+ global $conf;
- if (! ($this->statut > Commande::STATUS_DRAFT && $this->statut < Commande::STATUS_CLOSED)) {
- return false; // Never late if not inside this status range
- }
+ if (! ($this->statut > Commande::STATUS_DRAFT && $this->statut < Commande::STATUS_CLOSED)) {
+ return false; // Never late if not inside this status range
+ }
- $now = dol_now();
+ $now = dol_now();
- return max($this->date_commande, $this->date_livraison) < ($now - $conf->commande->client->warning_delay);
- }
+ return max($this->date_commande, $this->date_livraison) < ($now - $conf->commande->client->warning_delay);
+ }
- /**
- * Show the customer delayed info
- *
- * @return string Show delayed information
- */
- public function showDelay()
- {
- global $conf, $langs;
+ /**
+ * Show the customer delayed info
+ *
+ * @return string Show delayed information
+ */
+ public function showDelay()
+ {
+ global $conf, $langs;
- if (empty($this->date_livraison)) $text=$langs->trans("OrderDate").' '.dol_print_date($this->date_commande, 'day');
- else $text=$text=$langs->trans("DeliveryDate").' '.dol_print_date($this->date_livraison, 'day');
- $text.=' '.($conf->commande->client->warning_delay>0?'+':'-').' '.round(abs($conf->commande->client->warning_delay)/3600/24,1).' '.$langs->trans("days").' < '.$langs->trans("Today");
+ if (empty($this->date_livraison)) $text=$langs->trans("OrderDate").' '.dol_print_date($this->date_commande, 'day');
+ else $text=$text=$langs->trans("DeliveryDate").' '.dol_print_date($this->date_livraison, 'day');
+ $text.=' '.($conf->commande->client->warning_delay>0?'+':'-').' '.round(abs($conf->commande->client->warning_delay)/3600/24,1).' '.$langs->trans("days").' < '.$langs->trans("Today");
- return $text;
- }
+ return $text;
+ }
}
@@ -3764,10 +3842,14 @@ class Commande extends CommonOrder
*/
class OrderLine extends CommonOrderLine
{
+ /**
+ * @var string ID to identify managed object
+ */
public $element='commandedet';
+
public $table_element='commandedet';
- var $oldline;
+ var $oldline;
/**
* Id of parent order
@@ -3783,12 +3865,17 @@ class OrderLine extends CommonOrderLine
*/
public $commande_id;
- // From llx_commandedet
- var $fk_parent_line;
- var $fk_facture;
- var $label;
- var $fk_remise_except;
- var $rang = 0;
+ // From llx_commandedet
+ var $fk_parent_line;
+ var $fk_facture;
+
+ /**
+ * @var string Order lines label
+ */
+ public $label;
+
+ var $fk_remise_except;
+ var $rang = 0;
var $fk_fournprice;
/**
@@ -3796,8 +3883,8 @@ class OrderLine extends CommonOrderLine
* @var float
*/
var $pa_ht;
- var $marge_tx;
- var $marque_tx;
+ var $marge_tx;
+ var $marque_tx;
/**
* @deprecated
@@ -3805,88 +3892,89 @@ class OrderLine extends CommonOrderLine
*/
var $remise;
- // Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html)
- // Start and end date of the line
- var $date_start;
- var $date_end;
+ // Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html)
+ // Start and end date of the line
+ var $date_start;
+ var $date_end;
- var $skip_update_total; // Skip update price total for special lines
+ var $skip_update_total; // Skip update price total for special lines
- /**
- * Constructor
- *
- * @param DoliDB $db handler d'acces base de donnee
- */
- function __construct($db)
- {
- $this->db= $db;
- }
+ /**
+ * Constructor
+ *
+ * @param DoliDB $db handler d'acces base de donnee
+ */
+ function __construct($db)
+ {
+ $this->db= $db;
+ }
- /**
- * Load line order
- *
- * @param int $rowid Id line order
- * @return int <0 if KO, >0 if OK
- */
- function fetch($rowid)
- {
- $sql = 'SELECT cd.rowid, cd.fk_commande, cd.fk_parent_line, cd.fk_product, cd.product_type, cd.label as custom_label, cd.description, cd.price, cd.qty, cd.tva_tx, cd.localtax1_tx, cd.localtax2_tx,';
- $sql.= ' cd.remise, cd.remise_percent, cd.fk_remise_except, cd.subprice,';
- $sql.= ' cd.info_bits, cd.total_ht, cd.total_tva, cd.total_localtax1, cd.total_localtax2, cd.total_ttc, cd.fk_product_fournisseur_price as fk_fournprice, cd.buy_price_ht as pa_ht, cd.rang, cd.special_code,';
- $sql.= ' cd.fk_unit,';
+ /**
+ * Load line order
+ *
+ * @param int $rowid Id line order
+ * @return int <0 if KO, >0 if OK
+ */
+ function fetch($rowid)
+ {
+ $sql = 'SELECT cd.rowid, cd.fk_commande, cd.fk_parent_line, cd.fk_product, cd.product_type, cd.label as custom_label, cd.description, cd.price, cd.qty, cd.tva_tx, cd.localtax1_tx, cd.localtax2_tx,';
+ $sql.= ' cd.remise, cd.remise_percent, cd.fk_remise_except, cd.subprice,';
+ $sql.= ' cd.info_bits, cd.total_ht, cd.total_tva, cd.total_localtax1, cd.total_localtax2, cd.total_ttc, cd.fk_product_fournisseur_price as fk_fournprice, cd.buy_price_ht as pa_ht, cd.rang, cd.special_code,';
+ $sql.= ' cd.fk_unit,';
$sql.= ' cd.fk_multicurrency, cd.multicurrency_code, cd.multicurrency_subprice, cd.multicurrency_total_ht, cd.multicurrency_total_tva, cd.multicurrency_total_ttc,';
- $sql.= ' p.ref as product_ref, p.label as product_libelle, p.description as product_desc, p.tobatch as product_tobatch,';
- $sql.= ' cd.date_start, cd.date_end';
- $sql.= ' FROM '.MAIN_DB_PREFIX.'commandedet as cd';
- $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON cd.fk_product = p.rowid';
- $sql.= ' WHERE cd.rowid = '.$rowid;
- $result = $this->db->query($sql);
- if ($result)
- {
- $objp = $this->db->fetch_object($result);
- $this->rowid = $objp->rowid;
- $this->fk_commande = $objp->fk_commande;
- $this->fk_parent_line = $objp->fk_parent_line;
- $this->label = $objp->custom_label;
- $this->desc = $objp->description;
- $this->qty = $objp->qty;
- $this->price = $objp->price;
- $this->subprice = $objp->subprice;
- $this->vat_src_code = $objp->vat_src_code;
- $this->tva_tx = $objp->tva_tx;
- $this->localtax1_tx = $objp->localtax1_tx;
- $this->localtax2_tx = $objp->localtax2_tx;
- $this->remise = $objp->remise;
- $this->remise_percent = $objp->remise_percent;
- $this->fk_remise_except = $objp->fk_remise_except;
- $this->fk_product = $objp->fk_product;
- $this->product_type = $objp->product_type;
- $this->info_bits = $objp->info_bits;
+ $sql.= ' p.ref as product_ref, p.label as product_libelle, p.description as product_desc, p.tobatch as product_tobatch,';
+ $sql.= ' cd.date_start, cd.date_end';
+ $sql.= ' FROM '.MAIN_DB_PREFIX.'commandedet as cd';
+ $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON cd.fk_product = p.rowid';
+ $sql.= ' WHERE cd.rowid = '.$rowid;
+ $result = $this->db->query($sql);
+ if ($result)
+ {
+ $objp = $this->db->fetch_object($result);
+ $this->rowid = $objp->rowid;
+ $this->id = $objp->rowid;
+ $this->fk_commande = $objp->fk_commande;
+ $this->fk_parent_line = $objp->fk_parent_line;
+ $this->label = $objp->custom_label;
+ $this->desc = $objp->description;
+ $this->qty = $objp->qty;
+ $this->price = $objp->price;
+ $this->subprice = $objp->subprice;
+ $this->vat_src_code = $objp->vat_src_code;
+ $this->tva_tx = $objp->tva_tx;
+ $this->localtax1_tx = $objp->localtax1_tx;
+ $this->localtax2_tx = $objp->localtax2_tx;
+ $this->remise = $objp->remise;
+ $this->remise_percent = $objp->remise_percent;
+ $this->fk_remise_except = $objp->fk_remise_except;
+ $this->fk_product = $objp->fk_product;
+ $this->product_type = $objp->product_type;
+ $this->info_bits = $objp->info_bits;
$this->special_code = $objp->special_code;
- $this->total_ht = $objp->total_ht;
- $this->total_tva = $objp->total_tva;
- $this->total_localtax1 = $objp->total_localtax1;
- $this->total_localtax2 = $objp->total_localtax2;
- $this->total_ttc = $objp->total_ttc;
+ $this->total_ht = $objp->total_ht;
+ $this->total_tva = $objp->total_tva;
+ $this->total_localtax1 = $objp->total_localtax1;
+ $this->total_localtax2 = $objp->total_localtax2;
+ $this->total_ttc = $objp->total_ttc;
$this->fk_fournprice = $objp->fk_fournprice;
$marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $this->fk_fournprice, $objp->pa_ht);
$this->pa_ht = $marginInfos[0];
$this->marge_tx = $marginInfos[1];
$this->marque_tx = $marginInfos[2];
- $this->special_code = $objp->special_code;
- $this->rang = $objp->rang;
+ $this->special_code = $objp->special_code;
+ $this->rang = $objp->rang;
- $this->ref = $objp->product_ref; // deprecated
- $this->product_ref = $objp->product_ref;
- $this->libelle = $objp->product_libelle; // deprecated
- $this->product_label = $objp->product_libelle;
- $this->product_desc = $objp->product_desc;
- $this->product_tobatch = $objp->product_tobatch;
- $this->fk_unit = $objp->fk_unit;
+ $this->ref = $objp->product_ref; // deprecated
+ $this->product_ref = $objp->product_ref;
+ $this->libelle = $objp->product_libelle; // deprecated
+ $this->product_label = $objp->product_libelle;
+ $this->product_desc = $objp->product_desc;
+ $this->product_tobatch = $objp->product_tobatch;
+ $this->fk_unit = $objp->fk_unit;
- $this->date_start = $this->db->jdate($objp->date_start);
- $this->date_end = $this->db->jdate($objp->date_end);
+ $this->date_start = $this->db->jdate($objp->date_start);
+ $this->date_end = $this->db->jdate($objp->date_end);
$this->fk_multicurrency = $objp->fk_multicurrency;
$this->multicurrency_code = $objp->multicurrency_code;
@@ -3895,38 +3983,38 @@ class OrderLine extends CommonOrderLine
$this->multicurrency_total_tva = $objp->multicurrency_total_tva;
$this->multicurrency_total_ttc = $objp->multicurrency_total_ttc;
- $this->db->free($result);
+ $this->db->free($result);
- return 1;
- }
- else
- {
- $this->error = $this->db->lasterror();
- return -1;
- }
- }
+ return 1;
+ }
+ else
+ {
+ $this->error = $this->db->lasterror();
+ return -1;
+ }
+ }
- /**
- * Delete line in database
- *
- * @param User $user User that modify
+ /**
+ * Delete line in database
+ *
+ * @param User $user User that modify
* @param int $notrigger 0=launch triggers after, 1=disable triggers
- * @return int <0 si ko, >0 si ok
- */
- function delete($user=null, $notrigger=0)
- {
- global $conf, $user, $langs;
+ * @return int <0 si ko, >0 si ok
+ */
+ function delete($user=null, $notrigger=0)
+ {
+ global $conf, $user, $langs;
$error=0;
- $this->db->begin();
+ $this->db->begin();
- $sql = 'DELETE FROM '.MAIN_DB_PREFIX."commandedet WHERE rowid=".$this->rowid;
+ $sql = 'DELETE FROM '.MAIN_DB_PREFIX."commandedet WHERE rowid=".$this->rowid;
- dol_syslog("OrderLine::delete", LOG_DEBUG);
- $resql=$this->db->query($sql);
- if ($resql)
- {
+ dol_syslog("OrderLine::delete", LOG_DEBUG);
+ $resql=$this->db->query($sql);
+ if ($resql)
+ {
// Remove extrafields
if ((! $error) && (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) // For avoid conflicts if trigger used
{
@@ -3941,63 +4029,63 @@ class OrderLine extends CommonOrderLine
if (! $error && ! $notrigger)
{
- // Call trigger
- $result=$this->call_trigger('LINEORDER_DELETE',$user);
- if ($result < 0) $error++;
- // End call triggers
+ // Call trigger
+ $result=$this->call_trigger('LINEORDER_DELETE',$user);
+ if ($result < 0) $error++;
+ // End call triggers
}
- if (!$error) {
- $this->db->commit();
- return 1;
- }
+ if (!$error) {
+ $this->db->commit();
+ return 1;
+ }
- foreach($this->errors as $errmsg)
- {
- dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
- $this->error.=($this->error?', '.$errmsg:$errmsg);
- }
- $this->db->rollback();
- return -1*$error;
- }
- else
- {
- $this->error=$this->db->lasterror();
- return -1;
- }
- }
+ foreach($this->errors as $errmsg)
+ {
+ dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
+ $this->error.=($this->error?', '.$errmsg:$errmsg);
+ }
+ $this->db->rollback();
+ return -1*$error;
+ }
+ else
+ {
+ $this->error=$this->db->lasterror();
+ return -1;
+ }
+ }
- /**
- * Insert line into database
- *
- * @param User $user User that modify
- * @param int $notrigger 1 = disable triggers
- * @return int <0 if KO, >0 if OK
- */
- function insert($user=null, $notrigger=0)
- {
- global $langs, $conf;
+ /**
+ * Insert line into database
+ *
+ * @param User $user User that modify
+ * @param int $notrigger 1 = disable triggers
+ * @return int <0 if KO, >0 if OK
+ */
+ function insert($user=null, $notrigger=0)
+ {
+ global $langs, $conf;
$error=0;
- $pa_ht_isemptystring = (empty($this->pa_ht) && $this->pa_ht == ''); // If true, we can use a default value. If this->pa_ht = '0', we must use '0'.
+ $pa_ht_isemptystring = (empty($this->pa_ht) && $this->pa_ht == ''); // If true, we can use a default value. If this->pa_ht = '0', we must use '0'.
- dol_syslog(get_class($this)."::insert rang=".$this->rang);
+ dol_syslog(get_class($this)."::insert rang=".$this->rang);
- // Clean parameters
- if (empty($this->tva_tx)) $this->tva_tx=0;
- if (empty($this->localtax1_tx)) $this->localtax1_tx=0;
- if (empty($this->localtax2_tx)) $this->localtax2_tx=0;
+ // Clean parameters
+ if (empty($this->tva_tx)) $this->tva_tx=0;
+ if (empty($this->localtax1_tx)) $this->localtax1_tx=0;
+ if (empty($this->localtax2_tx)) $this->localtax2_tx=0;
if (empty($this->localtax1_type)) $this->localtax1_type=0;
if (empty($this->localtax2_type)) $this->localtax2_type=0;
- if (empty($this->total_localtax1)) $this->total_localtax1=0;
- if (empty($this->total_localtax2)) $this->total_localtax2=0;
- if (empty($this->rang)) $this->rang=0;
- if (empty($this->remise)) $this->remise=0;
- if (empty($this->remise_percent)) $this->remise_percent=0;
- if (empty($this->info_bits)) $this->info_bits=0;
- if (empty($this->special_code)) $this->special_code=0;
- if (empty($this->fk_parent_line)) $this->fk_parent_line=0;
+ if (empty($this->total_localtax1)) $this->total_localtax1=0;
+ if (empty($this->total_localtax2)) $this->total_localtax2=0;
+ if (empty($this->rang)) $this->rang=0;
+ if (empty($this->remise)) $this->remise=0;
+ if (empty($this->remise_percent)) $this->remise_percent=0;
+ if (empty($this->info_bits)) $this->info_bits=0;
+ if (empty($this->special_code)) $this->special_code=0;
+ if (empty($this->fk_parent_line)) $this->fk_parent_line=0;
if (empty($this->pa_ht)) $this->pa_ht=0;
// if buy price not defined, define buyprice as configured in margin admin
@@ -4013,65 +4101,65 @@ class OrderLine extends CommonOrderLine
}
}
- // Check parameters
- if ($this->product_type < 0) return -1;
+ // Check parameters
+ if ($this->product_type < 0) return -1;
- $this->db->begin();
+ $this->db->begin();
- // Insertion dans base de la ligne
- $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'commandedet';
- $sql.= ' (fk_commande, fk_parent_line, label, description, qty, ';
- $sql.= ' vat_src_code, tva_tx, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type,';
- $sql.= ' fk_product, product_type, remise_percent, subprice, price, remise, fk_remise_except,';
- $sql.= ' special_code, rang, fk_product_fournisseur_price, buy_price_ht,';
- $sql.= ' info_bits, total_ht, total_tva, total_localtax1, total_localtax2, total_ttc, date_start, date_end,';
- $sql.= ' fk_unit';
+ // Insertion dans base de la ligne
+ $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'commandedet';
+ $sql.= ' (fk_commande, fk_parent_line, label, description, qty, ';
+ $sql.= ' vat_src_code, tva_tx, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type,';
+ $sql.= ' fk_product, product_type, remise_percent, subprice, price, remise, fk_remise_except,';
+ $sql.= ' special_code, rang, fk_product_fournisseur_price, buy_price_ht,';
+ $sql.= ' info_bits, total_ht, total_tva, total_localtax1, total_localtax2, total_ttc, date_start, date_end,';
+ $sql.= ' fk_unit';
$sql.= ', fk_multicurrency, multicurrency_code, multicurrency_subprice, multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc';
$sql.= ')';
- $sql.= " VALUES (".$this->fk_commande.",";
- $sql.= " ".($this->fk_parent_line>0?"'".$this->db->escape($this->fk_parent_line)."'":"null").",";
- $sql.= " ".(! empty($this->label)?"'".$this->db->escape($this->label)."'":"null").",";
- $sql.= " '".$this->db->escape($this->desc)."',";
- $sql.= " '".price2num($this->qty)."',";
- $sql.= " ".(empty($this->vat_src_code)?"''":"'".$this->db->escape($this->vat_src_code)."'").",";
- $sql.= " '".price2num($this->tva_tx)."',";
- $sql.= " '".price2num($this->localtax1_tx)."',";
- $sql.= " '".price2num($this->localtax2_tx)."',";
+ $sql.= " VALUES (".$this->fk_commande.",";
+ $sql.= " ".($this->fk_parent_line>0?"'".$this->db->escape($this->fk_parent_line)."'":"null").",";
+ $sql.= " ".(! empty($this->label)?"'".$this->db->escape($this->label)."'":"null").",";
+ $sql.= " '".$this->db->escape($this->desc)."',";
+ $sql.= " '".price2num($this->qty)."',";
+ $sql.= " ".(empty($this->vat_src_code)?"''":"'".$this->db->escape($this->vat_src_code)."'").",";
+ $sql.= " '".price2num($this->tva_tx)."',";
+ $sql.= " '".price2num($this->localtax1_tx)."',";
+ $sql.= " '".price2num($this->localtax2_tx)."',";
$sql.= " '".$this->db->escape($this->localtax1_type)."',";
$sql.= " '".$this->db->escape($this->localtax2_type)."',";
- $sql.= ' '.(! empty($this->fk_product)?$this->fk_product:"null").',';
- $sql.= " '".$this->db->escape($this->product_type)."',";
- $sql.= " '".price2num($this->remise_percent)."',";
- $sql.= " ".($this->subprice!=''?"'".price2num($this->subprice)."'":"null").",";
- $sql.= " ".($this->price!=''?"'".price2num($this->price)."'":"null").",";
- $sql.= " '".price2num($this->remise)."',";
- $sql.= ' '.(! empty($this->fk_remise_except)?$this->fk_remise_except:"null").',';
- $sql.= ' '.$this->special_code.',';
- $sql.= ' '.$this->rang.',';
+ $sql.= ' '.(! empty($this->fk_product)?$this->fk_product:"null").',';
+ $sql.= " '".$this->db->escape($this->product_type)."',";
+ $sql.= " '".price2num($this->remise_percent)."',";
+ $sql.= " ".(price2num($this->subprice)!==''?price2num($this->subprice):"null").",";
+ $sql.= " ".($this->price!=''?"'".price2num($this->price)."'":"null").",";
+ $sql.= " '".price2num($this->remise)."',";
+ $sql.= ' '.(! empty($this->fk_remise_except)?$this->fk_remise_except:"null").',';
+ $sql.= ' '.$this->special_code.',';
+ $sql.= ' '.$this->rang.',';
$sql.= ' '.(! empty($this->fk_fournprice)?$this->fk_fournprice:"null").',';
$sql.= ' '.price2num($this->pa_ht).',';
- $sql.= " '".$this->db->escape($this->info_bits)."',";
- $sql.= " '".price2num($this->total_ht)."',";
- $sql.= " '".price2num($this->total_tva)."',";
- $sql.= " '".price2num($this->total_localtax1)."',";
- $sql.= " '".price2num($this->total_localtax2)."',";
- $sql.= " '".price2num($this->total_ttc)."',";
- $sql.= " ".(! empty($this->date_start)?"'".$this->db->idate($this->date_start)."'":"null").',';
- $sql.= " ".(! empty($this->date_end)?"'".$this->db->idate($this->date_end)."'":"null").',';
- $sql.= ' '.(!$this->fk_unit ? 'NULL' : $this->fk_unit);
+ $sql.= " '".$this->db->escape($this->info_bits)."',";
+ $sql.= " ".price2num($this->total_ht).",";
+ $sql.= " ".price2num($this->total_tva).",";
+ $sql.= " ".price2num($this->total_localtax1).",";
+ $sql.= " ".price2num($this->total_localtax2).",";
+ $sql.= " ".price2num($this->total_ttc).",";
+ $sql.= " ".(! empty($this->date_start)?"'".$this->db->idate($this->date_start)."'":"null").',';
+ $sql.= " ".(! empty($this->date_end)?"'".$this->db->idate($this->date_end)."'":"null").',';
+ $sql.= ' '.(!$this->fk_unit ? 'NULL' : $this->fk_unit);
$sql.= ", ".(! empty($this->fk_multicurrency) ? $this->fk_multicurrency : 'NULL');
$sql.= ", '".$this->db->escape($this->multicurrency_code)."'";
$sql.= ", ".$this->multicurrency_subprice;
$sql.= ", ".$this->multicurrency_total_ht;
$sql.= ", ".$this->multicurrency_total_tva;
$sql.= ", ".$this->multicurrency_total_ttc;
- $sql.= ')';
+ $sql.= ')';
- dol_syslog(get_class($this)."::insert", LOG_DEBUG);
- $resql=$this->db->query($sql);
- if ($resql)
- {
- $this->rowid=$this->db->last_insert_id(MAIN_DB_PREFIX.'commandedet');
+ dol_syslog(get_class($this)."::insert", LOG_DEBUG);
+ $resql=$this->db->query($sql);
+ if ($resql)
+ {
+ $this->rowid=$this->db->last_insert_id(MAIN_DB_PREFIX.'commandedet');
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
{
@@ -4083,42 +4171,42 @@ class OrderLine extends CommonOrderLine
}
}
- if (! $error && ! $notrigger)
- {
- // Call trigger
- $result=$this->call_trigger('LINEORDER_INSERT',$user);
- if ($result < 0) $error++;
- // End call triggers
- }
+ if (! $error && ! $notrigger)
+ {
+ // Call trigger
+ $result=$this->call_trigger('LINEORDER_INSERT',$user);
+ if ($result < 0) $error++;
+ // End call triggers
+ }
- if (!$error) {
- $this->db->commit();
- return 1;
- }
+ if (!$error) {
+ $this->db->commit();
+ return 1;
+ }
- foreach($this->errors as $errmsg)
- {
- dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
- $this->error.=($this->error?', '.$errmsg:$errmsg);
- }
- $this->db->rollback();
- return -1*$error;
- }
- else
- {
- $this->error=$this->db->error();
- $this->db->rollback();
- return -2;
- }
- }
+ foreach($this->errors as $errmsg)
+ {
+ dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
+ $this->error.=($this->error?', '.$errmsg:$errmsg);
+ }
+ $this->db->rollback();
+ return -1*$error;
+ }
+ else
+ {
+ $this->error=$this->db->error();
+ $this->db->rollback();
+ return -2;
+ }
+ }
- /**
- * Update the line object into db
- *
- * @param User $user User that modify
+ /**
+ * Update the line object into db
+ *
+ * @param User $user User that modify
* @param int $notrigger 1 = disable triggers
- * @return int <0 si ko, >0 si ok
- */
+ * @return int <0 si ko, >0 si ok
+ */
function update(User $user, $notrigger=0)
{
global $conf,$langs;
@@ -4141,7 +4229,7 @@ class OrderLine extends CommonOrderLine
if (empty($this->remise)) $this->remise=0;
if (empty($this->remise_percent)) $this->remise_percent=0;
if (empty($this->info_bits)) $this->info_bits=0;
- if (empty($this->special_code)) $this->special_code=0;
+ if (empty($this->special_code)) $this->special_code=0;
if (empty($this->product_type)) $this->product_type=0;
if (empty($this->fk_parent_line)) $this->fk_parent_line=0;
if (empty($this->pa_ht)) $this->pa_ht=0;
@@ -4187,7 +4275,7 @@ class OrderLine extends CommonOrderLine
$sql.= " , fk_product_fournisseur_price=".(! empty($this->fk_fournprice)?$this->fk_fournprice:"null");
$sql.= " , buy_price_ht='".price2num($this->pa_ht)."'";
$sql.= " , info_bits=".$this->info_bits;
- $sql.= " , special_code=".$this->special_code;
+ $sql.= " , special_code=".$this->special_code;
$sql.= " , date_start=".(! empty($this->date_start)?"'".$this->db->idate($this->date_start)."'":"null");
$sql.= " , date_end=".(! empty($this->date_end)?"'".$this->db->idate($this->date_end)."'":"null");
$sql.= " , product_type=".$this->product_type;
@@ -4197,9 +4285,9 @@ class OrderLine extends CommonOrderLine
// Multicurrency
$sql.= " , multicurrency_subprice=".price2num($this->multicurrency_subprice)."";
- $sql.= " , multicurrency_total_ht=".price2num($this->multicurrency_total_ht)."";
- $sql.= " , multicurrency_total_tva=".price2num($this->multicurrency_total_tva)."";
- $sql.= " , multicurrency_total_ttc=".price2num($this->multicurrency_total_ttc)."";
+ $sql.= " , multicurrency_total_ht=".price2num($this->multicurrency_total_ht)."";
+ $sql.= " , multicurrency_total_tva=".price2num($this->multicurrency_total_tva)."";
+ $sql.= " , multicurrency_total_ttc=".price2num($this->multicurrency_total_ttc)."";
$sql.= " WHERE rowid = ".$this->rowid;
@@ -4219,10 +4307,10 @@ class OrderLine extends CommonOrderLine
if (! $error && ! $notrigger)
{
- // Call trigger
- $result=$this->call_trigger('LINEORDER_UPDATE',$user);
- if ($result < 0) $error++;
- // End call triggers
+ // Call trigger
+ $result=$this->call_trigger('LINEORDER_UPDATE',$user);
+ if ($result < 0) $error++;
+ // End call triggers
}
if (!$error) {
@@ -4246,42 +4334,44 @@ class OrderLine extends CommonOrderLine
}
}
- /**
- * Update totals of order into database
- *
- * @return int <0 if ko, >0 if ok
- */
- function update_total()
- {
- $this->db->begin();
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
+ /**
+ * Update DB line fields total_xxx
+ * Used by migration
+ *
+ * @return int <0 if KO, >0 if OK
+ */
+ function update_total()
+ {
+ // phpcs:enable
+ $this->db->begin();
- // Clean parameters
- if (empty($this->total_localtax1)) $this->total_localtax1=0;
- if (empty($this->total_localtax2)) $this->total_localtax2=0;
+ // Clean parameters
+ if (empty($this->total_localtax1)) $this->total_localtax1=0;
+ if (empty($this->total_localtax2)) $this->total_localtax2=0;
- // Mise a jour ligne en base
- $sql = "UPDATE ".MAIN_DB_PREFIX."commandedet SET";
- $sql.= " total_ht='".price2num($this->total_ht)."'";
- $sql.= ",total_tva='".price2num($this->total_tva)."'";
- $sql.= ",total_localtax1='".price2num($this->total_localtax1)."'";
- $sql.= ",total_localtax2='".price2num($this->total_localtax2)."'";
- $sql.= ",total_ttc='".price2num($this->total_ttc)."'";
- $sql.= " WHERE rowid = ".$this->rowid;
+ // Mise a jour ligne en base
+ $sql = "UPDATE ".MAIN_DB_PREFIX."commandedet SET";
+ $sql.= " total_ht='".price2num($this->total_ht)."'";
+ $sql.= ",total_tva='".price2num($this->total_tva)."'";
+ $sql.= ",total_localtax1='".price2num($this->total_localtax1)."'";
+ $sql.= ",total_localtax2='".price2num($this->total_localtax2)."'";
+ $sql.= ",total_ttc='".price2num($this->total_ttc)."'";
+ $sql.= " WHERE rowid = ".$this->rowid;
- dol_syslog("OrderLine::update_total", LOG_DEBUG);
+ dol_syslog("OrderLine::update_total", LOG_DEBUG);
- $resql=$this->db->query($sql);
- if ($resql)
- {
- $this->db->commit();
- return 1;
- }
- else
- {
- $this->error=$this->db->error();
- $this->db->rollback();
- return -2;
- }
- }
+ $resql=$this->db->query($sql);
+ if ($resql)
+ {
+ $this->db->commit();
+ return 1;
+ }
+ else
+ {
+ $this->error=$this->db->error();
+ $this->db->rollback();
+ return -2;
+ }
+ }
}
-
diff --git a/htdocs/commande/class/commandestats.class.php b/htdocs/commande/class/commandestats.class.php
index 6d9dde94bc4..13d7e245f05 100644
--- a/htdocs/commande/class/commandestats.class.php
+++ b/htdocs/commande/class/commandestats.class.php
@@ -34,6 +34,9 @@ include_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
*/
class CommandeStats extends Stats
{
+ /**
+ * @var string Name of table without prefix where object is stored
+ */
public $table_element;
var $socid;
@@ -219,6 +222,5 @@ class CommandeStats extends Stats
return $this->_getAllByProduct($sql);
}
-
}
diff --git a/htdocs/commande/contact.php b/htdocs/commande/contact.php
index 7669239134a..bd00116e026 100644
--- a/htdocs/commande/contact.php
+++ b/htdocs/commande/contact.php
@@ -214,5 +214,6 @@ if ($id > 0 || ! empty($ref))
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/commande/customer.php b/htdocs/commande/customer.php
index 9263ceb3f45..42def36ee28 100644
--- a/htdocs/commande/customer.php
+++ b/htdocs/commande/customer.php
@@ -190,7 +190,7 @@ else
dol_print_error($db);
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/commande/document.php b/htdocs/commande/document.php
index ffebbaa260a..fc8192f7edb 100644
--- a/htdocs/commande/document.php
+++ b/htdocs/commande/document.php
@@ -97,7 +97,7 @@ if ($id > 0 || ! empty($ref))
$head = commande_prepare_head($object);
dol_fiche_head($head, 'documents', $langs->trans('CustomerOrder'), -1, 'order');
- // Construit liste des fichiers
+ // Build file list
$filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
$totalsize=0;
foreach($filearray as $key => $file)
@@ -189,6 +189,6 @@ else
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/commande/index.php b/htdocs/commande/index.php
index 5cfb87c7a25..4c596620c6c 100644
--- a/htdocs/commande/index.php
+++ b/htdocs/commande/index.php
@@ -479,6 +479,6 @@ if (! empty($conf->commande->enabled))
print '';
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/commande/info.php b/htdocs/commande/info.php
index 4bac4a3a447..6c0b5f42ec6 100644
--- a/htdocs/commande/info.php
+++ b/htdocs/commande/info.php
@@ -128,5 +128,6 @@ print '';
dol_fiche_end();
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php
index 2b86ad2f18a..558d8186a86 100644
--- a/htdocs/commande/list.php
+++ b/htdocs/commande/list.php
@@ -1,15 +1,15 @@
- * Copyright (C) 2004-2016 Laurent Destailleur
- * Copyright (C) 2005 Marc Barilley / Ocebo
- * Copyright (C) 2005-2012 Regis Houssin
- * Copyright (C) 2012 Juanjo Menent
- * Copyright (C) 2013 Christophe Battarel
- * Copyright (C) 2013 Cédric Salvador
- * Copyright (C) 2015 Frederic France
- * Copyright (C) 2015 Marcos García
- * Copyright (C) 2015 Jean-François Ferry
- * Copyright (C) 2016 Ferran Marcet
+/* Copyright (C) 2001-2005 Rodolphe Quiedeville
+ * Copyright (C) 2004-2016 Laurent Destailleur
+ * Copyright (C) 2005 Marc Barilley / Ocebo
+ * Copyright (C) 2005-2012 Regis Houssin
+ * Copyright (C) 2012 Juanjo Menent
+ * Copyright (C) 2013 Christophe Battarel
+ * Copyright (C) 2013 Cédric Salvador
+ * Copyright (C) 2015-2018 Frédéric France
+ * Copyright (C) 2015 Marcos García
+ * Copyright (C) 2015 Jean-François Ferry
+ * Copyright (C) 2016 Ferran Marcet
*
* 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
@@ -78,6 +78,9 @@ $search_categ_cus=trim(GETPOST("search_categ_cus",'int'));
$optioncss = GETPOST('optioncss','alpha');
$billed = GETPOST('billed','int');
$viewstatut=GETPOST('viewstatut');
+$search_btn=GETPOST('button_search','alpha');
+$search_remove_btn=GETPOST('button_removefilter','alpha');
+$search_project_ref=GETPOST('search_project_ref','alpha');
// Security check
$id = (GETPOST('orderid')?GETPOST('orderid','int'):GETPOST('id','int'));
@@ -91,7 +94,7 @@ $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');
-if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
+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
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
@@ -484,7 +487,7 @@ if ($resql)
print $langs->trans('DateInvoice');
print '';
print '';
- print $form->select_date('', '', '', '', '', '', 1, 1);
+ print $form->selectDate('', '', '', '', '', '', 1, 1);
print ' ';
print ' ';
print '';
@@ -1160,5 +1163,6 @@ else
dol_print_error($db);
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/commande/note.php b/htdocs/commande/note.php
index 6cff3bfb3bc..bf02c9b993c 100644
--- a/htdocs/commande/note.php
+++ b/htdocs/commande/note.php
@@ -142,5 +142,6 @@ if ($id > 0 || ! empty($ref))
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/commande/orderstoinvoice.php b/htdocs/commande/orderstoinvoice.php
index 03d379270b1..3335cf93276 100644
--- a/htdocs/commande/orderstoinvoice.php
+++ b/htdocs/commande/orderstoinvoice.php
@@ -1,12 +1,13 @@
- * Copyright (C) 2004-2013 Laurent Destailleur
- * Copyright (C) 2005 Marc Barilley / Ocebo
- * Copyright (C) 2005-2012 Regis Houssin
- * Copyright (C) 2012 Andreu Bisquerra Gaya
- * Copyright (C) 2012 David Rodriguez Martinez
- * Copyright (C) 2012-2018 Juanjo Menent
- * Copyright (C) 2015 Ferran Marcet
+/* Copyright (C) 2001-2005 Rodolphe Quiedeville
+ * Copyright (C) 2004-2013 Laurent Destailleur
+ * Copyright (C) 2005 Marc Barilley / Ocebo
+ * Copyright (C) 2005-2012 Regis Houssin
+ * Copyright (C) 2012 Andreu Bisquerra Gaya
+ * Copyright (C) 2012 David Rodriguez Martinez
+ * Copyright (C) 2012-2018 Juanjo Menent
+ * Copyright (C) 2015 Ferran Marcet
+ * 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
@@ -442,7 +443,7 @@ if ($action == 'create' && !$error)
// Date invoice
print ''.$langs->trans('Date').' ';
- $html->select_date('','','','','',"add",1,1);
+ print $html->selectDate('', '', '', '', '', "add", 1, 1);
print ' ';
// Payment term
print ''.$langs->trans('PaymentConditionsShort').' ';
@@ -596,8 +597,8 @@ if (($action != 'create' && $action != 'add') || ($action == 'create' && $error)
$num = $db->num_rows($resql);
print load_fiche_titre($title);
$i = 0;
- $period=$html->select_date($date_start,'date_start',0,0,1,'',1,0,1).' - '.$html->select_date($date_end,'date_end',0,0,1,'',1,0,1);
- $periodely=$html->select_date($date_starty,'date_start_dely',0,0,1,'',1,0,1).' - '.$html->select_date($date_endy,'date_end_dely',0,0,1,'',1,0,1);
+ $period=$html->selectDate($date_start,'date_start',0,0,1,'',1,0).' - '.$html->selectDate($date_end,'date_end',0,0,1,'',1,0);
+ $periodely=$html->selectDate($date_starty,'date_start_dely',0,0,1,'',1,0).' - '.$html->selectDate($date_endy,'date_end_dely',0,0,1,'',1,0);
if (! empty($socid))
{
@@ -654,7 +655,7 @@ if (($action != 'create' && $action != 'add') || ($action == 'create' && $error)
print '';
print '';
-
+
$generic_commande = new Commande($db);
while ($i < $num)
@@ -739,5 +740,6 @@ if (($action != 'create' && $action != 'add') || ($action == 'create' && $error)
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/commande/stats/index.php b/htdocs/commande/stats/index.php
index 8f259808357..49e7d5cfb60 100644
--- a/htdocs/commande/stats/index.php
+++ b/htdocs/commande/stats/index.php
@@ -369,7 +369,6 @@ print '';
dol_fiche_end();
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/bank/annuel.php b/htdocs/compta/bank/annuel.php
index a786cf5ca28..5e1a10390e2 100644
--- a/htdocs/compta/bank/annuel.php
+++ b/htdocs/compta/bank/annuel.php
@@ -24,7 +24,7 @@
* \brief Page to report input-output of a bank account
*/
-require('../../main.inc.php');
+require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
@@ -494,5 +494,6 @@ else
print "\n
\n";
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php
index 72f4bbbd988..311335fd96b 100644
--- a/htdocs/compta/bank/bankentries_list.php
+++ b/htdocs/compta/bank/bankentries_list.php
@@ -8,6 +8,7 @@
* Copyright (C) 2016 Juanjo Menent
* Copyright (C) 2017 Alexandre Spangaro
* Copyright (C) 2018 Ferran Marcet
+ * 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
@@ -29,7 +30,7 @@
* \brief List of bank transactions
*/
-require('../../main.inc.php');
+require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
@@ -103,7 +104,7 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined,
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
-if (! $sortorder) $sortorder='ASC';
+if (! $sortorder) $sortorder='desc,desc,desc';
if (! $sortfield) $sortfield='b.datev,b.dateo,b.rowid';
$mode_balance_ok=false;
@@ -113,7 +114,6 @@ if (($sortfield == 'b.datev' || $sortfield == 'b.datev,b.dateo,b.rowid'))
$sortfield = 'b.datev,b.dateo,b.rowid';
if ($id > 0 || ! empty($ref) || $search_account > 0) $mode_balance_ok = true;
}
-if (strtolower($sortorder) == 'desc') $mode_balance_ok = false;
$object = new Account($db);
if ($id > 0 || ! empty($ref))
@@ -445,7 +445,7 @@ $sql = "SELECT b.rowid, b.dateo as do, b.datev as dv, b.amount, b.label, b.rappr
$sql.= " b.fk_account, b.fk_type,";
$sql.= " ba.rowid as bankid, ba.ref as bankref,";
$sql.= " bu.url_id,";
-$sql.= " s.nom, s.name_alias, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur";
+$sql.= " s.nom, s.name_alias, s.client, s.fournisseur, s.email, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur";
// Add fields from extrafields
foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : '');
// Add fields from hooks
@@ -526,8 +526,8 @@ if (! empty($debit)) $mode_balance_ok=false;
if (! empty($credit)) $mode_balance_ok=false;
if (! empty($thirdparty)) $mode_balance_ok=false;
-$sql.= $db->plimit($limit+1,$offset);
-
+$sql.= $db->plimit($limit+1, $offset);
+//print $sql;
dol_syslog('compta/bank/bankentries_list.php', LOG_DEBUG);
$resql = $db->query($sql);
if ($resql)
@@ -667,7 +667,7 @@ if ($resql)
}
print ' ';
print '';
- $form->select_date(empty($dateop)?-1:$dateop,'op',0,0,0,'transaction');
+ print $form->selectDate(empty($dateop)?-1:$dateop, 'op', 0, 0, 0, 'transaction');
print ' ';
print ' ';
print '';
@@ -788,17 +788,17 @@ if ($resql)
$moreforfilter.='';
$moreforfilter .= $langs->trans('DateOperationShort').' : ';
$moreforfilter .= ''.$langs->trans('From') . ' ';
- $moreforfilter .= $form->select_date($search_dt_start, 'search_start_dt', 0, 0, 1, "search_form", 1, 0, 1).'';
+ $moreforfilter .= $form->selectDate($search_dt_start, 'search_start_dt', 0, 0, 1, "search_form", 1, 0).'';
//$moreforfilter .= ' - ';
- $moreforfilter .= ''.$langs->trans('to') . ' ' . $form->select_date($search_dt_end, 'search_end_dt', 0, 0, 1, "search_form", 1, 0, 1).'';
+ $moreforfilter .= ''.$langs->trans('to') . ' ' . $form->selectDate($search_dt_end, 'search_end_dt', 0, 0, 1, "search_form", 1, 0).'';
$moreforfilter .= '';
$moreforfilter.='';
$moreforfilter .= $langs->trans('DateValueShort').' : ';
$moreforfilter .= ''.$langs->trans('From') . ' ';
- $moreforfilter .= $form->select_date($search_dv_start, 'search_start_dv', 0, 0, 1, "search_form", 1, 0, 1).'';
+ $moreforfilter .= $form->selectDate($search_dv_start, 'search_start_dv', 0, 0, 1, "search_form", 1, 0).'';
//$moreforfilter .= ' - ';
- $moreforfilter .= ''.$langs->trans('to') . ' ' . $form->select_date($search_dv_end, 'search_end_dv', 0, 0, 1, "search_form", 1, 0, 1).'';
+ $moreforfilter .= ''.$langs->trans('to') . ' ' . $form->selectDate($search_dv_end, 'search_end_dv', 0, 0, 1, "search_form", 1, 0).'';
$moreforfilter .= '';
if (! empty($conf->categorie->enabled))
@@ -950,7 +950,8 @@ if ($resql)
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ');
print " \n";
- $balance = 0; // For balance
+ $balance = 0; // For balance
+ $balancebefore = 0; // For balance
$balancecalculated = false;
$posconciliatecol = 0;
@@ -974,7 +975,7 @@ if ($resql)
// Loop on each record before
$sign = 1;
$i = 0;
- $sqlforbalance='SELECT SUM(b.amount) as balance';
+ $sqlforbalance='SELECT SUM(b.amount) as previoustotal';
$sqlforbalance.= " FROM ";
$sqlforbalance.= " ".MAIN_DB_PREFIX."bank_account as ba,";
$sqlforbalance.= " ".MAIN_DB_PREFIX."bank as b";
@@ -989,7 +990,16 @@ if ($resql)
$objforbalance = $db->fetch_object($resqlforbalance);
if ($objforbalance)
{
- $balance = $objforbalance->balance;
+ // If sort is desc,desc,desc then total of previous date + amount is the balancebefore of the previous line before the line to show
+ if ($sortfield == 'b.datev,b.dateo,b.rowid' && $sortorder == 'desc,desc,desc')
+ {
+ $balancebefore = $objforbalance->previoustotal + ($sign * $objp->amount);
+ }
+ // If sort is asc,asc,asc then total of previous date is balance of line before the next line to show
+ else
+ {
+ $balance = $objforbalance->previoustotal;
+ }
}
}
else dol_print_error($db);
@@ -1065,7 +1075,17 @@ if ($resql)
}
}
- $balance = price2num($balance + ($sign * $objp->amount),'MT');
+
+ if ($sortfield == 'b.datev,b.dateo,b.rowid' && $sortorder == 'desc,desc,desc')
+ {
+ $balance = price2num($balancebefore, 'MT'); // balance = balancebefore of previous line (sort is desc)
+ $balancebefore = price2num($balancebefore - ($sign * $objp->amount),'MT');
+ }
+ else
+ {
+ $balancebefore = price2num($balance, 'MT'); // balancebefore = balance of previous line (sort is asc)
+ $balance = price2num($balance + ($sign * $objp->amount),'MT');
+ }
if (empty($cachebankaccount[$objp->bankid]))
{
@@ -1285,6 +1305,7 @@ if ($resql)
$companystatic->name=$objp->nom;
$companystatic->name_alias=$objp->name_alias;
$companystatic->client=$objp->client;
+ $companystatic->email=$objp->email;
$companystatic->fournisseur=$objp->fournisseur;
$companystatic->code_client=$objp->code_client;
$companystatic->code_fournisseur=$objp->code_fournisseur;
@@ -1342,7 +1363,6 @@ if ($resql)
{
if ($mode_balance_ok)
{
- $balancebefore = price2num($balance - ($sign * $objp->amount),'MT');
if ($balancebefore >= 0)
{
print ' '.price($balancebefore).' ';
@@ -1404,14 +1424,14 @@ if ($resql)
if (! empty($arrayfields['b.conciliated']['checked']))
{
- print '';
+ print ' ';
print $objp->conciliated?$langs->trans("Yes"):$langs->trans("No");
print ' ';
if (! $i) $totalarray['nbfield']++;
}
// Action edit/delete
- print '';
+ print ' ';
// Transaction reconciliated or edit link
if ($objp->conciliated && $bankaccount->canBeConciliated() > 0) // If line not conciliated and account can be conciliated
{
@@ -1510,6 +1530,6 @@ if ($_POST["action"] == "search" && ! $num)
print ''.$langs->trans("NoRecordFound").'';
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/bank/bilan.php b/htdocs/compta/bank/bilan.php
index 5e5194d55c8..99856a2dea2 100644
--- a/htdocs/compta/bank/bilan.php
+++ b/htdocs/compta/bank/bilan.php
@@ -22,7 +22,7 @@
* \brief Page de bilan
*/
-require('../../main.inc.php');
+require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
// Load translation files required by the page
@@ -92,5 +92,6 @@ print " ".$langs->trans("BankBalance")." ";
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/compta/bank/budget.php b/htdocs/compta/bank/budget.php
index 280cd9bdbc0..ccec902bf7c 100644
--- a/htdocs/compta/bank/budget.php
+++ b/htdocs/compta/bank/budget.php
@@ -24,7 +24,7 @@
* \brief Page de budget
*/
-require('../../main.inc.php');
+require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
// Load translation files required by the page
@@ -96,5 +96,6 @@ else
}
print "";
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php
index db497733863..b58619b66a2 100644
--- a/htdocs/compta/bank/card.php
+++ b/htdocs/compta/bank/card.php
@@ -6,6 +6,7 @@
* Copyright (C) 2014-2017 Alexandre Spangaro
* Copyright (C) 2015 Jean-François Ferry
* Copyright (C) 2016 Marcos García
+ * 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
@@ -27,7 +28,7 @@
* \brief Page to create/view a bank account
*/
-require('../../main.inc.php');
+require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/bank.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php';
@@ -284,7 +285,7 @@ if ($action == 'confirm_delete' && $_POST["confirm"] == "yes" && $user->rights->
$form = new Form($db);
$formbank = new FormBank($db);
$formcompany = new FormCompany($db);
-if (! empty($conf->accounting->enabled)) $formaccounting = New FormAccounting($db);
+if (! empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db);
$countrynotdefined=$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')';
@@ -431,7 +432,7 @@ if ($action == 'create')
print ''.$langs->trans("Date").' ';
print '';
- $form->select_date('', 're', 0, 0, 0, 'formsoc');
+ print $form->selectDate('', 're', 0, 0, 0, 'formsoc');
print ' ';
print ''.$langs->trans("BalanceMinimalAllowed").' ';
@@ -1034,5 +1035,6 @@ else
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/compta/bank/categ.php b/htdocs/compta/bank/categ.php
index be029fcb2f5..7ef798103d5 100644
--- a/htdocs/compta/bank/categ.php
+++ b/htdocs/compta/bank/categ.php
@@ -26,7 +26,7 @@
* \brief Page ajout de categories bancaires
*/
-require('../../main.inc.php');
+require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/bankcateg.class.php';
@@ -144,4 +144,6 @@ if ($action != 'edit')
print '';
+// End of page
llxFooter();
+$db->close();
diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php
index 7228214e51c..3bd5997506e 100644
--- a/htdocs/compta/bank/class/account.class.php
+++ b/htdocs/compta/bank/class/account.class.php
@@ -36,8 +36,19 @@ require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php';
*/
class Account extends CommonObject
{
+ /**
+ * @var string ID to identify managed object
+ */
public $element = 'bank_account';
+
+ /**
+ * @var string Name of table without prefix where object is stored
+ */
public $table_element = 'bank_account';
+
+ /**
+ * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
+ */
public $picto = 'account';
/**
@@ -286,6 +297,7 @@ class Account extends CommonObject
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Add a link between bank line record and its source
*
@@ -298,6 +310,7 @@ class Account extends CommonObject
*/
function add_url_line($line_id, $url_id, $url, $label, $type)
{
+ // phpcs:enable
$sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_url (";
$sql.= "fk_bank";
$sql.= ", url_id";
@@ -325,6 +338,7 @@ class Account extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* TODO Move this into AccountLine
* Return array with links from llx_bank_url
@@ -332,10 +346,11 @@ class Account extends CommonObject
* @param int $fk_bank To search using bank transaction id
* @param int $url_id To search using link to
* @param string $type To search using type
- * @return array|-1 Array of links array('url'=>, 'url_id'=>, 'label'=>, 'type'=> 'fk_bank'=> ) or -1 on error
+ * @return array|int Array of links array('url'=>, 'url_id'=>, 'label'=>, 'type'=> 'fk_bank'=> ) or -1 on error
*/
function get_url($fk_bank='', $url_id='', $type='')
{
+ // phpcs:enable
$lines = array();
// Check parameters
@@ -774,14 +789,16 @@ class Account extends CommonObject
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
- * Update BBAN (RIB) account fields
+ * Update BBAN (RIB) account fields
*
- * @param User $user Object user making update
- * @return int <0 if KO, >0 if OK
+ * @param User $user Object user making update
+ * @return int <0 if KO, >0 if OK
*/
function update_bban(User $user = null)
{
+ // phpcs:enable
global $conf,$langs;
// Clean parameters
@@ -943,8 +960,10 @@ class Account extends CommonObject
* Existing categories are left untouch.
*
* @param int[]|int $categories Category or categories IDs
+ * @return void
*/
- public function setCategories($categories) {
+ public function setCategories($categories)
+ {
// Handle single category
if (! is_array($categories)) {
$categories = array($categories);
@@ -1058,6 +1077,7 @@ class Account extends CommonObject
return $this->LibStatut($this->clos,$mode);
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Return label of given object status
*
@@ -1067,6 +1087,7 @@ class Account extends CommonObject
*/
function LibStatut($statut, $mode = 0)
{
+ // phpcs:enable
global $langs;
$langs->load('banks');
@@ -1095,6 +1116,7 @@ class Account extends CommonObject
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Renvoi si un compte peut etre supprimer ou non (sans mouvements)
*
@@ -1102,6 +1124,7 @@ class Account extends CommonObject
*/
function can_be_deleted()
{
+ // phpcs:enable
$can_be_deleted=false;
$sql = "SELECT COUNT(rowid) as nb";
@@ -1160,9 +1183,9 @@ class Account extends CommonObject
}
return $solde;
-
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Load indicators for dashboard (this->nbtodo and this->nbtodolate)
*
@@ -1172,6 +1195,7 @@ class Account extends CommonObject
*/
function load_board(User $user, $filteraccountid = 0)
{
+ // phpcs:enable
global $conf, $langs;
if ($user->societe_id) return -1; // protection pour eviter appel par utilisateur externe
@@ -1218,6 +1242,7 @@ class Account extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Charge indicateurs this->nb de tableau de bord
* @param int $filteraccountid To get info for a particular account id
@@ -1225,6 +1250,7 @@ class Account extends CommonObject
*/
function load_state_board($filteraccountid = 0)
{
+ // phpcs:enable
global $user;
if ($user->societe_id) return -1; // protection pour eviter appel par utilisateur externe
@@ -1301,13 +1327,19 @@ class Account extends CommonObject
*/
function getNomUrl($withpicto=0, $mode='', $option='', $save_lastsearch_value=-1, $notooltip=0)
{
- global $conf, $langs;
+ global $conf, $langs, $user;
$result='';
$label = '' . $langs->trans("ShowAccount") . '';
$label .= '
' . $langs->trans('BankAccount') . ': ' . $this->label;
$label .= '
' . $langs->trans('AccountNumber') . ': ' . $this->number;
$label .= '
' . $langs->trans("AccountCurrency") . ': ' . $this->currency_code;
+
+ if (empty($user->rights->banque->lire) || !empty($user->socid))
+ {
+ $option = 'nolink';
+ }
+
if (! empty($conf->accounting->enabled))
{
include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
@@ -1338,6 +1370,11 @@ class Account extends CommonObject
$linkstart = 'ref.($option == 'reflabel' && $this->label ? ' - '.$this->label : '');
@@ -1492,7 +1529,6 @@ class Account extends CommonObject
*/
function info($id)
{
-
}
/**
@@ -1537,7 +1573,6 @@ class Account extends CommonObject
//Get the order the properties are shown
return $fieldarray;
-
}
/**
@@ -1611,7 +1646,6 @@ class Account extends CommonObject
$this->owner_address = 'Owner address';
$this->country_id = 1;
}
-
}
@@ -1620,37 +1654,69 @@ class Account extends CommonObject
*/
class AccountLine extends CommonObject
{
- var $error;
- var $db;
- var $element='bank';
- var $table_element='bank';
- var $picto = 'generic';
+ /**
+ * @var string Error code (or message)
+ */
+ public $error='';
- var $id;
- var $ref;
- var $datec;
- var $dateo;
+ /**
+ * @var DoliDB Database handler.
+ */
+ public $db;
+
+ /**
+ * @var string ID to identify managed object
+ */
+ public $element='bank';
+
+ /**
+ * @var string Name of table without prefix where object is stored
+ */
+ public $table_element='bank';
+
+ /**
+ * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
+ */
+ public $picto = 'generic';
+
+ /**
+ * @var int ID
+ */
+ public $id;
+
+ /**
+ * @var string Ref
+ */
+ public $ref;
+
+ public $datec;
+ public $dateo;
/**
* Value date
*/
- var $datev;
- var $amount;
- var $label;
- var $note;
- var $fk_user_author;
- var $fk_user_rappro;
- var $fk_type;
- var $rappro; // Is it conciliated
- var $num_releve; // If conciliated, what is bank statement
- var $num_chq; // Num of cheque
- var $bank_chq; // Bank of cheque
- var $fk_bordereau; // Id of cheque receipt
+ public $datev;
+ public $amount;
- var $fk_account; // Id of bank account
- var $bank_account_label; // Label of bank account
+ /**
+ * @var string bank transaction lines label
+ */
+ public $label;
- public $emetteur;
+ public $note;
+ public $fk_user_author;
+ public $fk_user_rappro;
+ public $fk_type;
+ public $rappro; // Is it conciliated
+ public $num_releve; // If conciliated, what is bank statement
+ public $num_chq; // Num of cheque
+ public $bank_chq; // Bank of cheque
+ public $fk_bordereau; // Id of cheque receipt
+
+ public $fk_account; // Id of bank account
+ public $bank_account_label; // Label of bank account
+
+ public $emetteur;
/**
* Constructor
@@ -1835,6 +1901,7 @@ class AccountLine extends CommonObject
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Delete bank line records
*
@@ -1843,6 +1910,7 @@ class AccountLine extends CommonObject
*/
function delete_urls(User $user = null)
{
+ // phpcs:enable
$nbko=0;
if ($this->rappro)
@@ -1905,15 +1973,17 @@ class AccountLine extends CommonObject
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
- * Update conciliation field
+ * Update conciliation field
*
- * @param User $user Objet user making update
- * @param int $cat Category id
- * @return int <0 if KO, >0 if OK
+ * @param User $user Objet user making update
+ * @param int $cat Category id
+ * @return int <0 if KO, >0 if OK
*/
function update_conciliation(User $user, $cat)
{
+ // phpcs:enable
global $conf,$langs;
$this->db->begin();
@@ -1967,6 +2037,7 @@ class AccountLine extends CommonObject
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Increase/decrease value date of a rowid
*
@@ -1976,6 +2047,7 @@ class AccountLine extends CommonObject
*/
function datev_change($rowid,$sign=1)
{
+ // phpcs:enable
$sql = "SELECT datev FROM ".MAIN_DB_PREFIX."bank WHERE rowid = ".$rowid;
$resql = $this->db->query($sql);
if ($resql)
@@ -2005,6 +2077,7 @@ class AccountLine extends CommonObject
return 0;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Increase value date of a rowid
*
@@ -2013,9 +2086,11 @@ class AccountLine extends CommonObject
*/
function datev_next($id)
{
+ // phpcs:enable
return $this->datev_change($id,1);
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Decrease value date of a rowid
*
@@ -2024,10 +2099,12 @@ class AccountLine extends CommonObject
*/
function datev_previous($id)
{
+ // phpcs:enable
return $this->datev_change($id,-1);
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Increase/decrease operation date of a rowid
*
@@ -2037,6 +2114,7 @@ class AccountLine extends CommonObject
*/
function dateo_change($rowid,$sign=1)
{
+ // phpcs:enable
$sql = "SELECT dateo FROM ".MAIN_DB_PREFIX."bank WHERE rowid = ".$rowid;
$resql = $this->db->query($sql);
if ($resql)
@@ -2066,6 +2144,7 @@ class AccountLine extends CommonObject
return 0;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Increase operation date of a rowid
*
@@ -2074,9 +2153,11 @@ class AccountLine extends CommonObject
*/
function dateo_next($id)
{
+ // phpcs:enable
return $this->dateo_change($id,1);
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Decrease operation date of a rowid
*
@@ -2085,6 +2166,7 @@ class AccountLine extends CommonObject
*/
function dateo_previous($id)
{
+ // phpcs:enable
return $this->dateo_change($id,-1);
}
@@ -2191,6 +2273,7 @@ class AccountLine extends CommonObject
return $this->LibStatut($this->status,$mode);
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Renvoi le libelle d'un statut donne
*
@@ -2200,6 +2283,7 @@ class AccountLine extends CommonObject
*/
function LibStatut($statut,$mode=0)
{
+ // phpcs:enable
global $langs;
//$langs->load('companies');
/*
@@ -2269,6 +2353,4 @@ class AccountLine extends CommonObject
}
return 0;
}
-
}
-
diff --git a/htdocs/compta/bank/class/bankcateg.class.php b/htdocs/compta/bank/class/bankcateg.class.php
index 176fdb626a5..cc291c6be64 100644
--- a/htdocs/compta/bank/class/bankcateg.class.php
+++ b/htdocs/compta/bank/class/bankcateg.class.php
@@ -30,11 +30,21 @@ class BankCateg // extends CommonObject
{
//public $element='bank_categ'; //!< Id that identify managed objects
//public $table_element='bank_categ'; //!< Name of table without prefix where object is stored
- public $picto='generic';
-
- public $id;
- public $label;
-
+ /**
+ * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
+ */
+ public $picto='generic';
+
+ /**
+ * @var int ID
+ */
+ public $id;
+
+ /**
+ * @var string bank categories label
+ */
+ public $label;
+
/**
* Constructor
@@ -205,7 +215,7 @@ class BankCateg // extends CommonObject
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_account";
$sql.= " WHERE fk_categorie = ".$this->id;
-
+
$resql = $this->db->query($sql);
if (!$resql)
{
@@ -213,13 +223,13 @@ class BankCateg // extends CommonObject
$this->errors[] = "Error ".$this->db->lasterror();
}
}
-
+
// Delete link between tag and bank lines
if (! $error)
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_class";
$sql.= " WHERE fk_categ = ".$this->id;
-
+
$resql = $this->db->query($sql);
if (!$resql)
{
@@ -227,21 +237,21 @@ class BankCateg // extends CommonObject
$this->errors[] = "Error ".$this->db->lasterror();
}
}
-
+
// Delete bank categ
if (! $error)
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_categ";
$sql .= " WHERE rowid=".$this->id;
-
+
$resql = $this->db->query($sql);
- if (!$resql)
+ if (!$resql)
{
$error++;
$this->errors[] = "Error ".$this->db->lasterror();
}
}
-
+
// Commit or rollback
if ($error) {
foreach ($this->errors as $errmsg) {
@@ -339,5 +349,4 @@ class BankCateg // extends CommonObject
$this->id = 0;
$this->label = '';
}
-
}
diff --git a/htdocs/compta/bank/class/paymentvarious.class.php b/htdocs/compta/bank/class/paymentvarious.class.php
index fe56ea99504..25a5b06df98 100644
--- a/htdocs/compta/bank/class/paymentvarious.class.php
+++ b/htdocs/compta/bank/class/paymentvarious.class.php
@@ -30,25 +30,49 @@ require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php';
*/
class PaymentVarious extends CommonObject
{
- public $element='variouspayment'; //!< Id that identify managed objects
- public $table_element='payment_various'; //!< Name of table without prefix where object is stored
+ /**
+ * @var string ID to identify managed object
+ */
+ public $element='variouspayment';
+
+ /**
+ * @var string Name of table without prefix where object is stored
+ */
+ public $table_element='payment_various';
+
+ /**
+ * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
+ */
public $picto = 'bill';
- var $id;
- var $ref;
- var $tms;
- var $datep;
- var $datev;
- var $sens;
- var $amount;
- var $type_payment;
- var $num_payment;
- var $label;
- var $accountancy_code;
- var $fk_project;
- var $fk_bank;
- var $fk_user_author;
- var $fk_user_modif;
+ /**
+ * @var int ID
+ */
+ public $id;
+
+ /**
+ * @var string Ref
+ */
+ public $ref;
+
+ public $tms;
+ public $datep;
+ public $datev;
+ public $sens;
+ public $amount;
+ public $type_payment;
+ public $num_payment;
+
+ /**
+ * @var string various payments label
+ */
+ public $label;
+
+ public $accountancy_code;
+ public $fk_project;
+ public $fk_bank;
+ public $fk_user_author;
+ public $fk_user_modif;
/**
@@ -61,14 +85,13 @@ class PaymentVarious extends CommonObject
$this->db = $db;
$this->element = 'payment_various';
$this->table_element = 'payment_various';
- return 1;
}
/**
* Update database
*
* @param User $user User that modify
- * @param int $notrigger 0=no, 1=yes (no update trigger)
+ * @param int $notrigger 0=no, 1=yes (no update trigger)
* @return int <0 if KO, >0 if OK
*/
function update($user=null, $notrigger=0)
@@ -363,13 +386,14 @@ class PaymentVarious extends CommonObject
// Insert payment into llx_bank
// Add link 'payment_various' in bank_url between payment and bank transaction
- if ($this->sens == '0') $sign='-';
+ $sign=1;
+ if ($this->sens == '0') $sign=-1;
$bank_line_id = $acc->addline(
$this->datep,
$this->type_payment,
$this->label,
- $sign.abs($this->amount),
+ $sign * abs($this->amount),
$this->num_payment,
'',
$user
@@ -434,6 +458,7 @@ class PaymentVarious extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Update link between payment various and line generate into llx_bank
*
@@ -442,6 +467,7 @@ class PaymentVarious extends CommonObject
*/
function update_fk_bank($id_bank)
{
+ // phpcs:enable
$sql = 'UPDATE '.MAIN_DB_PREFIX.'payment_various SET fk_bank = '.$id_bank;
$sql.= ' WHERE rowid = '.$this->id;
$result = $this->db->query($sql);
@@ -468,6 +494,7 @@ class PaymentVarious extends CommonObject
return $this->LibStatut($this->statut,$mode);
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Renvoi le libelle d'un statut donne
*
@@ -477,35 +504,36 @@ class PaymentVarious extends CommonObject
*/
function LibStatut($statut,$mode=0)
{
+ // phpcs:enable
global $langs;
if ($mode == 0)
{
return $langs->trans($this->statuts[$statut]);
}
- if ($mode == 1)
+ elseif ($mode == 1)
{
return $langs->trans($this->statuts_short[$statut]);
}
- if ($mode == 2)
+ elseif ($mode == 2)
{
if ($statut==0) return img_picto($langs->trans($this->statuts_short[$statut]),'statut0').' '.$langs->trans($this->statuts_short[$statut]);
if ($statut==1) return img_picto($langs->trans($this->statuts_short[$statut]),'statut4').' '.$langs->trans($this->statuts_short[$statut]);
if ($statut==2) return img_picto($langs->trans($this->statuts_short[$statut]),'statut6').' '.$langs->trans($this->statuts_short[$statut]);
}
- if ($mode == 3)
+ elseif ($mode == 3)
{
if ($statut==0 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]),'statut0');
if ($statut==1 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]),'statut4');
if ($statut==2 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]),'statut6');
}
- if ($mode == 4)
+ elseif ($mode == 4)
{
if ($statut==0 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]),'statut0').' '.$langs->trans($this->statuts[$statut]);
if ($statut==1 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]),'statut4').' '.$langs->trans($this->statuts[$statut]);
if ($statut==2 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]),'statut6').' '.$langs->trans($this->statuts[$statut]);
}
- if ($mode == 5)
+ elseif ($mode == 5)
{
if ($statut==0 && ! empty($this->statuts_short[$statut])) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]),'statut0');
if ($statut==1 && ! empty($this->statuts_short[$statut])) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]),'statut4');
@@ -517,11 +545,13 @@ class PaymentVarious extends CommonObject
/**
* Send name clicable (with possibly the picto)
*
- * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto
- * @param string $option link option
- * @return string Chaine with URL
+ * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto
+ * @param string $option link option
+ * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
+ * @param int $notooltip 1=Disable tooltip
+ * @return string String with URL
*/
- function getNomUrl($withpicto=0,$option='')
+ function getNomUrl($withpicto=0, $option='', $save_lastsearch_value=-1, $notooltip=0)
{
global $langs;
@@ -532,8 +562,8 @@ class PaymentVarious extends CommonObject
$linkend='';
$result .= $linkstart;
- if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1);
- if ($withpicto != 2) $result.= ($maxlen?dol_trunc($this->ref,$maxlen):$this->ref);
+ 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.= $this->ref.($option == 'reflabel' && $this->label ? ' - '.$this->label : '');
$result .= $linkend;
return $result;
@@ -582,5 +612,4 @@ class PaymentVarious extends CommonObject
dol_print_error($this->db);
}
}
-
}
diff --git a/htdocs/compta/bank/document.php b/htdocs/compta/bank/document.php
index 33e74dc3691..f908b68b35c 100644
--- a/htdocs/compta/bank/document.php
+++ b/htdocs/compta/bank/document.php
@@ -24,7 +24,7 @@
* \ingroup banque
* \brief Page de gestion des documents attaches a un compte bancaire
*/
-require('../../main.inc.php');
+require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . "/core/lib/bank.lib.php";
require_once DOL_DOCUMENT_ROOT . "/core/lib/files.lib.php";
require_once DOL_DOCUMENT_ROOT . "/core/lib/images.lib.php";
@@ -105,7 +105,7 @@ if ($id > 0 || !empty($ref)) {
dol_fiche_head($head, 'document', $langs->trans("FinancialAccount"), -1, 'account');
- // Construit liste des fichiers
+ // Build file list
$filearray = dol_dir_list($upload_dir, "files", 0, '', '\.meta$',
$sortfield,
(strtolower($sortorder) == 'desc' ? SORT_DESC : SORT_ASC), 1);
@@ -147,7 +147,6 @@ else {
exit;
}
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/bank/graph.php b/htdocs/compta/bank/graph.php
index b829002a990..7dad720139a 100644
--- a/htdocs/compta/bank/graph.php
+++ b/htdocs/compta/bank/graph.php
@@ -23,7 +23,7 @@
* \brief Page graph des transactions bancaires
*/
-require('../../main.inc.php');
+require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
@@ -864,7 +864,6 @@ if ($mode == 'showalltime')
print '';
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/bank/info.php b/htdocs/compta/bank/info.php
index ab43b9374aa..7eaeb515aa9 100644
--- a/htdocs/compta/bank/info.php
+++ b/htdocs/compta/bank/info.php
@@ -21,7 +21,7 @@
* \brief Onglet info d'une ecriture bancaire
*/
-require('../../main.inc.php');
+require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
@@ -71,5 +71,6 @@ print ' ';
print '';
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/compta/bank/ligne.php b/htdocs/compta/bank/ligne.php
index e006f78c6e7..85cd839fd44 100644
--- a/htdocs/compta/bank/ligne.php
+++ b/htdocs/compta/bank/ligne.php
@@ -7,6 +7,7 @@
* Copyright (C) 2015-2017 Alexandre Spangaro
* Copyright (C) 2015 Jean-François Ferry
* Copyright (C) 2016 Marcos García
+ * 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
@@ -28,12 +29,12 @@
* \brief Page to edit a bank transaction record
*/
-require('../../main.inc.php');
+require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
// Load translation files required by the page
-$langs->loadLangs(array('banks', 'categories', 'compta', 'bills'));
+$langs->loadLangs(array('banks', 'categories', 'compta', 'bills', 'other'));
if (! empty($conf->adherent->enabled)) $langs->load("members");
if (! empty($conf->don->enabled)) $langs->load("donations");
if (! empty($conf->loan->enabled)) $langs->load("loan");
@@ -98,8 +99,10 @@ if ($action == 'confirm_delete_categ' && $confirm == "yes" && $user->rights->ban
{
dol_print_error($db);
}
- } else {
- setEventMessage('Missing ids','errors');
+ }
+ else
+ {
+ setEventMessages($langs->trans("MissingIds"), null, 'errors');
}
}
@@ -495,7 +498,7 @@ if ($result)
if ($user->rights->banque->modifier || $user->rights->banque->consolidate)
{
print '';
- print $form->select_date($db->jdate($objp->do),'dateo','','','','update',1,0,1,$objp->rappro);
+ print $form->selectDate($db->jdate($objp->do), 'dateo', '', '', '', 'update', 1, 0, $objp->rappro);
if (! $objp->rappro)
{
print ' ';
@@ -519,7 +522,7 @@ if ($result)
if ($user->rights->banque->modifier || $user->rights->banque->consolidate)
{
print ' ';
- print $form->select_date($db->jdate($objp->dv),'datev','','','','update',1,0,1,$objp->rappro);
+ print $form->selectDate($db->jdate($objp->dv), 'datev', '', '', '', 'update', 1, 0, $objp->rappro);
if (! $objp->rappro)
{
print ' ';
@@ -686,6 +689,6 @@ if ($result)
}
else dol_print_error($db);
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/bank/list.php b/htdocs/compta/bank/list.php
index e52e285742c..1f01355050c 100644
--- a/htdocs/compta/bank/list.php
+++ b/htdocs/compta/bank/list.php
@@ -27,7 +27,7 @@ use Stripe\BankAccount;
* \brief Home page of bank module
*/
-require('../../main.inc.php');
+require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php';
@@ -604,7 +604,6 @@ print "";
print "";
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/bank/releve.php b/htdocs/compta/bank/releve.php
index 1d9d5526700..3f1bede8e20 100644
--- a/htdocs/compta/bank/releve.php
+++ b/htdocs/compta/bank/releve.php
@@ -25,7 +25,7 @@
* \brief Page to show a bank statement report
*/
-require('../../main.inc.php');
+require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
@@ -813,7 +813,6 @@ else
}
}
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/bank/transfer.php b/htdocs/compta/bank/transfer.php
index 765001e75a5..38109b964b4 100644
--- a/htdocs/compta/bank/transfer.php
+++ b/htdocs/compta/bank/transfer.php
@@ -5,6 +5,7 @@
* Copyright (C) 2012 Juanjo Menent
* Copyright (C) 2015 Jean-François Ferry
* Copyright (C) 2015 Marcos García
+ * 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
@@ -26,7 +27,7 @@
* \brief Page de saisie d'un virement
*/
-require('../../main.inc.php');
+require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
@@ -253,7 +254,7 @@ $form->select_comptes($account_to, 'account_to', 0, '', 1, '', empty($conf->mult
print " \n";
print "";
-$form->select_date((! empty($dateo)?$dateo:''),'','','','','add');
+print $form->selectDate((! empty($dateo)?$dateo:''), '', '', '', '', 'add');
print " \n";
print ' ';
print ' ';
@@ -265,5 +266,6 @@ print '
";
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/compta/bank/treso.php b/htdocs/compta/bank/treso.php
index 0fb8880ce87..2389d1fec77 100644
--- a/htdocs/compta/bank/treso.php
+++ b/htdocs/compta/bank/treso.php
@@ -330,5 +330,6 @@ else
print $langs->trans("ErrorBankAccountNotFound");
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/compta/bank/various_payment/card.php b/htdocs/compta/bank/various_payment/card.php
index 1b4d7579892..33757c67c6a 100644
--- a/htdocs/compta/bank/various_payment/card.php
+++ b/htdocs/compta/bank/various_payment/card.php
@@ -1,5 +1,6 @@
+/* Copyright (C) 2017 Alexandre Spangaro
+ * 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
@@ -220,7 +221,7 @@ if (empty($reshook))
llxHeader("",$langs->trans("VariousPayment"));
$form = new Form($db);
-if (! empty($conf->accounting->enabled)) $formaccounting = New FormAccounting($db);
+if (! empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db);
if (! empty($conf->projet->enabled)) $formproject = new FormProjets($db);
if ($id)
@@ -255,13 +256,13 @@ if ($action == 'create')
// Date payment
print '';
print fieldLabel('DatePayment','datep',1).' ';
- print $form->select_date((empty($datep)?-1:$datep),"datep",'','','','add',1,1);
+ print $form->selectDate((empty($datep)?-1:$datep),"datep",'','','','add',1,1);
print ' ';
// Date value for bank
print '';
print fieldLabel('DateValue','datev',0).' ';
- print $form->select_date((empty($datev)?-1:$datev),"datev",'','','','add',1,1);
+ print $form->selectDate((empty($datev)?-1:$datev),"datev",'','','','add',1,1);
print ' ';
// Label
@@ -499,8 +500,6 @@ if ($id)
print " ";
}
-
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/bank/various_payment/document.php b/htdocs/compta/bank/various_payment/document.php
index cf596860a4b..faa9a8ed199 100644
--- a/htdocs/compta/bank/various_payment/document.php
+++ b/htdocs/compta/bank/various_payment/document.php
@@ -124,7 +124,7 @@ if ($object->id)
print '';
print '';
- // Construit liste des fichiers
+ // Build file list
$filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
$totalsize=0;
foreach($filearray as $key => $file)
@@ -154,6 +154,6 @@ else
print $langs->trans("ErrorUnknown");
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/bank/various_payment/index.php b/htdocs/compta/bank/various_payment/index.php
index 6535e0c0082..7e3f921b67f 100644
--- a/htdocs/compta/bank/various_payment/index.php
+++ b/htdocs/compta/bank/various_payment/index.php
@@ -1,6 +1,7 @@
- * Copyright (C) 2017 Laurent Destailleur
+/* Copyright (C) 2017 Alexandre Spangaro
+ * Copyright (C) 2017 Laurent Destailleur
+ * 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
@@ -189,7 +190,7 @@ if ($result)
// Date
print '';
print '';
- print $form->select_date($search_date, 'date_doc', 0, 0, 1);
+ print $form->selectDate($search_date, 'date_doc', 0, 0, 1);
print '';
print ' ';
@@ -344,5 +345,6 @@ else
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/compta/bank/various_payment/info.php b/htdocs/compta/bank/various_payment/info.php
index bb66871d6c0..c39a6379000 100644
--- a/htdocs/compta/bank/various_payment/info.php
+++ b/htdocs/compta/bank/various_payment/info.php
@@ -58,6 +58,6 @@ print ' ';
print '';
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/charges/index.php b/htdocs/compta/charges/index.php
index 6d369b696b9..e367054fc40 100644
--- a/htdocs/compta/charges/index.php
+++ b/htdocs/compta/charges/index.php
@@ -455,7 +455,7 @@ while($j<$numlt)
// Payment Salary
-if (! empty($conf->salaries->enabled) && $user->rights->salaries->read)
+if (! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read))
{
if (! $mode || $mode != 'sconly')
{
@@ -568,7 +568,6 @@ if (! empty($conf->salaries->enabled) && $user->rights->salaries->read)
print '';
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/deplacement/card.php b/htdocs/compta/deplacement/card.php
index 05d509e268d..861ee6e897f 100644
--- a/htdocs/compta/deplacement/card.php
+++ b/htdocs/compta/deplacement/card.php
@@ -3,7 +3,8 @@
* Copyright (C) 2004-2012 Laurent Destailleur
* Copyright (C) 2005-2012 Regis Houssin
* Copyright (C) 2012 Juanjo Menent
- * Copyright (C) 2013 Florian Henry
+ * Copyright (C) 2013 Florian Henry
+ * 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
@@ -20,8 +21,8 @@
*/
/**
- * \file htdocs/compta/deplacement/card.php
- * \brief Page to show a trip card
+ * \file htdocs/compta/deplacement/card.php
+ * \brief Page to show a trip card
*/
require '../../main.inc.php';
@@ -263,7 +264,7 @@ if ($action == 'create')
print "";
print ''.$langs->trans("Date").' ';
- print $form->select_date($datec?$datec:-1,'','','','','add',1,1,1);
+ print $form->selectDate($datec?$datec:-1, '', '', '', '', 'add', 1, 1);
print ' ';
// Km
@@ -360,7 +361,7 @@ else if ($id)
// Date
print ''.$langs->trans("Date").' ';
- print $form->select_date($object->date,'',0,0,0,'update',1,0,1);
+ print $form->selectDate($object->date, '', 0, 0, 0, 'update', 1, 0);
print ' ';
// Km
@@ -577,7 +578,6 @@ else if ($id)
}
}
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/deplacement/class/deplacement.class.php b/htdocs/compta/deplacement/class/deplacement.class.php
index 05664080ed3..403988052bd 100644
--- a/htdocs/compta/deplacement/class/deplacement.class.php
+++ b/htdocs/compta/deplacement/class/deplacement.class.php
@@ -31,23 +31,44 @@ require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php';
*/
class Deplacement extends CommonObject
{
+ /**
+ * @var string ID to identify managed object
+ */
public $element='deplacement';
+
+ /**
+ * @var string Name of table without prefix where object is stored
+ */
public $table_element='deplacement';
+
+ /**
+ * @var int Name of subtable line
+ */
public $table_element_line = '';
+
+ /**
+ * @var int Field with ID of parent key if this field has a parent
+ */
public $fk_element = '';
+
public $ismultientitymanaged = 0; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
- var $datec; // Creation date
- var $dated;
- var $fk_user_author;
- var $fk_user;
- var $km;
- var $socid;
- var $statut; // 0=draft, 1=validated
- var $extraparams=array();
+ public $datec; // Creation date
+ public $dated;
+ public $fk_user_author;
- var $statuts=array();
- var $statuts_short=array();
+ /**
+ * @var int User ID
+ */
+ public $fk_user;
+
+ public $km;
+ public $socid;
+ public $statut; // 0=draft, 1=validated
+ public $extraparams=array();
+
+ public $statuts=array();
+ public $statuts_short=array();
/**
* Constructor
@@ -146,7 +167,6 @@ class Deplacement extends CommonObject
$this->db->rollback();
return -1;
}
-
}
/**
@@ -293,6 +313,7 @@ class Deplacement extends CommonObject
return $this->LibStatut($this->statut,$mode);
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Renvoi le libelle d'un statut donne
*
@@ -302,35 +323,36 @@ class Deplacement extends CommonObject
*/
function LibStatut($statut,$mode=0)
{
+ // phpcs:enable
global $langs;
if ($mode == 0)
{
return $langs->trans($this->statuts[$statut]);
}
- if ($mode == 1)
+ elseif ($mode == 1)
{
return $langs->trans($this->statuts_short[$statut]);
}
- if ($mode == 2)
+ elseif ($mode == 2)
{
if ($statut==0) return img_picto($langs->trans($this->statuts_short[$statut]),'statut0').' '.$langs->trans($this->statuts_short[$statut]);
if ($statut==1) return img_picto($langs->trans($this->statuts_short[$statut]),'statut4').' '.$langs->trans($this->statuts_short[$statut]);
if ($statut==2) return img_picto($langs->trans($this->statuts_short[$statut]),'statut6').' '.$langs->trans($this->statuts_short[$statut]);
}
- if ($mode == 3)
+ elseif ($mode == 3)
{
if ($statut==0 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]),'statut0');
if ($statut==1 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]),'statut4');
if ($statut==2 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]),'statut6');
}
- if ($mode == 4)
+ elseif ($mode == 4)
{
if ($statut==0 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]),'statut0').' '.$langs->trans($this->statuts[$statut]);
if ($statut==1 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]),'statut4').' '.$langs->trans($this->statuts[$statut]);
if ($statut==2 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]),'statut6').' '.$langs->trans($this->statuts[$statut]);
}
- if ($mode == 5)
+ elseif ($mode == 5)
{
if ($statut==0 && ! empty($this->statuts_short[$statut])) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]),'statut0');
if ($statut==1 && ! empty($this->statuts_short[$statut])) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]),'statut4');
@@ -445,6 +467,4 @@ class Deplacement extends CommonObject
dol_print_error($this->db);
}
}
-
}
-
diff --git a/htdocs/compta/deplacement/class/deplacementstats.class.php b/htdocs/compta/deplacement/class/deplacementstats.class.php
index 75ac39a7cca..e490c90f1ed 100644
--- a/htdocs/compta/deplacement/class/deplacementstats.class.php
+++ b/htdocs/compta/deplacement/class/deplacementstats.class.php
@@ -30,6 +30,9 @@ include_once DOL_DOCUMENT_ROOT . '/compta/deplacement/class/deplacement.class.ph
*/
class DeplacementStats extends Stats
{
+ /**
+ * @var string Name of table without prefix where object is stored
+ */
public $table_element;
var $socid;
diff --git a/htdocs/compta/deplacement/document.php b/htdocs/compta/deplacement/document.php
index 59d92140c86..e34a2aedb21 100644
--- a/htdocs/compta/deplacement/document.php
+++ b/htdocs/compta/deplacement/document.php
@@ -91,7 +91,7 @@ if ($object->id)
dol_fiche_head($head, 'documents', $langs->trans("TripCard"), 0, 'trip');
- // Construit liste des fichiers
+ // Build file list
$filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
$totalsize=0;
foreach($filearray as $key => $file)
@@ -129,6 +129,6 @@ else
print $langs->trans("ErrorUnknown");
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/deplacement/index.php b/htdocs/compta/deplacement/index.php
index a390023e280..98c939965a3 100644
--- a/htdocs/compta/deplacement/index.php
+++ b/htdocs/compta/deplacement/index.php
@@ -204,7 +204,6 @@ else dol_print_error($db);
print '';
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/deplacement/info.php b/htdocs/compta/deplacement/info.php
index 6a62484323f..f63b1765efb 100644
--- a/htdocs/compta/deplacement/info.php
+++ b/htdocs/compta/deplacement/info.php
@@ -59,5 +59,6 @@ if ($id)
print '';
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/compta/deplacement/list.php b/htdocs/compta/deplacement/list.php
index bdbdad0a712..20d300d9da4 100644
--- a/htdocs/compta/deplacement/list.php
+++ b/htdocs/compta/deplacement/list.php
@@ -212,6 +212,6 @@ else
dol_print_error($db);
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/deplacement/stats/index.php b/htdocs/compta/deplacement/stats/index.php
index cf652948a6e..193e2c7e9a9 100644
--- a/htdocs/compta/deplacement/stats/index.php
+++ b/htdocs/compta/deplacement/stats/index.php
@@ -312,7 +312,6 @@ print '';
dol_fiche_end();
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/facture/admin/facture_cust_extrafields.php b/htdocs/compta/facture/admin/facture_cust_extrafields.php
index 4e44774e0c4..1fe26e82a54 100644
--- a/htdocs/compta/facture/admin/facture_cust_extrafields.php
+++ b/htdocs/compta/facture/admin/facture_cust_extrafields.php
@@ -114,6 +114,6 @@ if ($action == 'edit' && ! empty($attrname))
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php';
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/facture/admin/facture_rec_cust_extrafields.php b/htdocs/compta/facture/admin/facture_rec_cust_extrafields.php
index 54d3da8e18a..23c0d79a33c 100644
--- a/htdocs/compta/facture/admin/facture_rec_cust_extrafields.php
+++ b/htdocs/compta/facture/admin/facture_rec_cust_extrafields.php
@@ -115,6 +115,6 @@ if ($action == 'edit' && ! empty($attrname))
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php';
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/facture/admin/facturedet_cust_extrafields.php b/htdocs/compta/facture/admin/facturedet_cust_extrafields.php
index c2490da4f42..0947f788719 100644
--- a/htdocs/compta/facture/admin/facturedet_cust_extrafields.php
+++ b/htdocs/compta/facture/admin/facturedet_cust_extrafields.php
@@ -113,6 +113,6 @@ if ($action == 'edit' && ! empty($attrname))
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php';
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/facture/admin/facturedet_rec_cust_extrafields.php b/htdocs/compta/facture/admin/facturedet_rec_cust_extrafields.php
index 28c70ea9024..46d9ed28335 100644
--- a/htdocs/compta/facture/admin/facturedet_rec_cust_extrafields.php
+++ b/htdocs/compta/facture/admin/facturedet_rec_cust_extrafields.php
@@ -113,6 +113,6 @@ if ($action == 'edit' && ! empty($attrname))
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php';
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php
index 457f03c6afc..a40ad636976 100644
--- a/htdocs/compta/facture/card.php
+++ b/htdocs/compta/facture/card.php
@@ -1,19 +1,20 @@
- * Copyright (C) 2004 Eric Seigne
- * Copyright (C) 2004-2016 Laurent Destailleur
- * Copyright (C) 2005 Marc Barilley / Ocebo
- * Copyright (C) 2005-2015 Regis Houssin
- * Copyright (C) 2006 Andre Cianfarani
- * Copyright (C) 2010-2015 Juanjo Menent
- * Copyright (C) 2012-2013 Christophe Battarel
- * Copyright (C) 2012-2013 Cédric Salvador
- * Copyright (C) 2012-2014 Raphaël Doursenaud
- * Copyright (C) 2013 Jean-Francois FERRY
- * Copyright (C) 2013-2014 Florian Henry
- * Copyright (C) 2013 Cédric Salvador
- * Copyright (C) 2014-2018 Ferran Marcet
- * Copyright (C) 2015-2016 Marcos García
+/* Copyright (C) 2002-2006 Rodolphe Quiedeville
+ * Copyright (C) 2004 Eric Seigne
+ * Copyright (C) 2004-2016 Laurent Destailleur
+ * Copyright (C) 2005 Marc Barilley / Ocebo
+ * Copyright (C) 2005-2015 Regis Houssin
+ * Copyright (C) 2006 Andre Cianfarani
+ * Copyright (C) 2010-2015 Juanjo Menent
+ * Copyright (C) 2012-2013 Christophe Battarel
+ * Copyright (C) 2012-2013 Cédric Salvador
+ * Copyright (C) 2012-2014 Raphaël Doursenaud
+ * Copyright (C) 2013 Jean-Francois FERRY
+ * Copyright (C) 2013-2014 Florian Henry
+ * Copyright (C) 2013 Cédric Salvador
+ * Copyright (C) 2014-2018 Ferran Marcet
+ * Copyright (C) 2015-2016 Marcos García
+ * 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
@@ -513,7 +514,7 @@ if (empty($reshook))
if ($object->type != Facture::TYPE_DEPOSIT && ! empty($conf->global->STOCK_CALCULATE_ON_BILL) && $qualified_for_stock_change)
{
if (! $idwarehouse || $idwarehouse == - 1) {
- $error ++;
+ $error++;
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Warehouse")), null, 'errors');
$action = '';
}
@@ -573,7 +574,7 @@ if (empty($reshook))
if ($object->type != Facture::TYPE_DEPOSIT && ! empty($conf->global->STOCK_CALCULATE_ON_BILL) && $qualified_for_stock_change)
{
if (! $idwarehouse || $idwarehouse == - 1) {
- $error ++;
+ $error++;
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Warehouse")), null, 'errors');
$action = '';
}
@@ -832,7 +833,7 @@ if (empty($reshook))
}
if (! ($_POST['fac_replacement'] > 0)) {
- $error ++;
+ $error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ReplaceInvoice")), null, 'errors');
}
@@ -878,14 +879,14 @@ if (empty($reshook))
$sourceinvoice = GETPOST('fac_avoir');
if (! ($sourceinvoice > 0) && empty($conf->global->INVOICE_CREDIT_NOTE_STANDALONE))
{
- $error ++;
+ $error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CorrectInvoice")), null, 'errors');
}
$dateinvoice = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']);
if (empty($dateinvoice))
{
- $error ++;
+ $error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->trans("Date")), null, 'errors');
}
@@ -1109,7 +1110,7 @@ if (empty($reshook))
{
if (GETPOST('socid', 'int') < 1)
{
- $error ++;
+ $error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Customer")), null, 'errors');
}
@@ -1279,7 +1280,7 @@ if (empty($reshook))
}
} else {
setEventMessages($srcobject->error, $srcobject->errors, 'errors');
- $error ++;
+ $error++;
}
}
@@ -1290,7 +1291,7 @@ if (empty($reshook))
{
$arraylist = array('amount' => 'FixAmount','variable' => 'VarAmount');
$descline = $langs->trans('Deposit');
- $descline.= ' - '.$langs->trans($arraylist[$typeamount]);
+ //$descline.= ' - '.$langs->trans($arraylist[$typeamount]);
if ($typeamount=='amount') {
$descline.= ' ('. price($valuedeposit, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).')';
} elseif ($typeamount=='variable') {
@@ -1373,7 +1374,7 @@ if (empty($reshook))
$result = $object->insert_discount($discountid); // This include link_to_invoice
} else {
setEventMessages($discount->error, $discount->errors, 'errors');
- $error ++;
+ $error++;
break;
}
} else {
@@ -1429,7 +1430,7 @@ if (empty($reshook))
$lineid = $result;
} else {
$lineid = 0;
- $error ++;
+ $error++;
break;
}
@@ -1441,7 +1442,7 @@ if (empty($reshook))
}
} else {
setEventMessages($srcobject->error, $srcobject->errors, 'errors');
- $error ++;
+ $error++;
}
}
@@ -1665,37 +1666,46 @@ if (empty($reshook))
if (empty($idprod) && ($price_ht < 0) && ($qty < 0)) {
setEventMessages($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPriceHT'), $langs->transnoentitiesnoconv('Qty')), null, 'errors');
- $error ++;
+ $error++;
}
if (!$prod_entry_mode)
{
if (GETPOST('type') < 0 && ! GETPOST('search_idprod'))
{
setEventMessages($langs->trans('ErrorChooseBetweenFreeEntryOrPredefinedProduct'), null, 'errors');
- $error ++;
+ $error++;
}
}
if ($prod_entry_mode == 'free' && empty($idprod) && GETPOST('type') < 0) {
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), null, 'errors');
- $error ++;
+ $error++;
}
if ($prod_entry_mode == 'free' && empty($idprod) && (($price_ht < 0 && empty($conf->global->FACTURE_ENABLE_NEGATIVE_LINES)) || $price_ht == '') && $price_ht_devise == '') // Unit price can be 0 but not ''
{
- setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), null, 'errors');
- $error ++;
+ if ($price_ht < 0 && empty($conf->global->FACTURE_ENABLE_NEGATIVE_LINES))
+ {
+ $langs->load("errors");
+ setEventMessages($langs->trans("ErrorFieldCantBeNegativeOnInvoice", $langs->transnoentitiesnoconv("UnitPriceHT")), null, 'errors');
+ $error++;
+ }
+ else
+ {
+ setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), null, 'errors');
+ $error++;
+ }
}
if ($qty == '') {
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), null, 'errors');
- $error ++;
+ $error++;
}
if ($prod_entry_mode == 'free' && empty($idprod) && empty($product_desc)) {
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Description')), null, 'errors');
- $error ++;
+ $error++;
}
if ($qty < 0) {
$langs->load("errors");
setEventMessages($langs->trans('ErrorQtyForCustomerInvoiceCantBeNegative'), null, 'errors');
- $error ++;
+ $error++;
}
if (!$error && !empty($conf->variants->enabled) && $prod_entry_mode != 'free') {
@@ -1705,9 +1715,11 @@ if (empty($reshook))
if ($res = $prodcomb->fetchByProductCombination2ValuePairs($idprod, $combinations)) {
$idprod = $res->fk_product_child;
- } else {
- setEventMessage($langs->trans('ErrorProductCombinationNotFound'), 'errors');
- $error ++;
+ }
+ else
+ {
+ setEventMessages($langs->trans('ErrorProductCombinationNotFound'), null, 'errors');
+ $error++;
}
}
}
@@ -2113,7 +2125,7 @@ if (empty($reshook))
// Check price is not lower than minimum (check is done only for standard or replacement invoices)
if (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT) && $price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent')) / 100) < price2num($price_min))) {
setEventMessages($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)), null, 'errors');
- $error ++;
+ $error++;
}
} else {
$type = GETPOST('type');
@@ -2122,14 +2134,29 @@ if (empty($reshook))
// Check parameters
if (GETPOST('type') < 0) {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors');
- $error ++;
+ $error++;
}
}
if ($qty < 0) {
$langs->load("errors");
setEventMessages($langs->trans('ErrorQtyForCustomerInvoiceCantBeNegative'), null, 'errors');
- $error ++;
+ $error++;
}
+ if (empty($productid) && (($pu_ht < 0 && empty($conf->global->FACTURE_ENABLE_NEGATIVE_LINES)) || $pu_ht == '') && $pu_ht_devise == '') // Unit price can be 0 but not ''
+ {
+ if ($pu_ht < 0 && empty($conf->global->FACTURE_ENABLE_NEGATIVE_LINES))
+ {
+ $langs->load("errors");
+ setEventMessages($langs->trans("ErrorFieldCantBeNegativeOnInvoice", $langs->transnoentitiesnoconv("UnitPriceHT")), null, 'errors');
+ $error++;
+ }
+ else
+ {
+ setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), null, 'errors');
+ $error++;
+ }
+ }
+
// Update line
if (! $error) {
@@ -2430,7 +2457,7 @@ if (empty($reshook))
if($error)
{
- setEventMessage($langs->trans('ErrorsOnXLines',$error), 'errors');
+ setEventMessages($langs->trans('ErrorsOnXLines',$error), null, 'errors');
}
}
}
@@ -2873,7 +2900,7 @@ if ($action == 'create')
if (($origin == 'propal') || ($origin == 'commande'))
{
print '';
- $arraylist = array('amount' => 'FixAmount','variable' => 'VarAmount');
+ $arraylist = array('amount' => $langs->transnoentitiesnoconv('FixAmount'), 'variable' => $langs->transnoentitiesnoconv('VarAmountOneLine', $langs->transnoentitiesnoconv('Deposit')));
print $form->selectarray('typedeposit', $arraylist, GETPOST('typedeposit'), 0, 0, 0, '', 1);
print ' ';
print '' . $langs->trans('Value') . ':';
@@ -3046,7 +3073,7 @@ if ($action == 'create')
// Date invoice
print ' ' . $langs->trans('DateInvoice') . ' ';
- print $form->select_date($datefacture?$datefacture:$dateinvoice, '', '', '', '', "add", 1, 1, 1);
+ print $form->selectDate($datefacture?$datefacture:$dateinvoice, '', '', '', '', "add", 1, 1);
print ' ';
// Date point of tax
@@ -3054,7 +3081,7 @@ if ($action == 'create')
{
print '' . $langs->trans('DatePointOfTax') . ' ';
$date_pointoftax = dol_mktime(12, 0, 0, $_POST['date_pointoftaxmonth'], $_POST['date_pointoftaxday'], $_POST['date_pointoftaxyear']);
- print $form->select_date($date_pointoftax?$date_pointoftax:-1, 'date_pointoftax', '', '', '', "add", 1, 1, 1);
+ print $form->selectDate($date_pointoftax?$date_pointoftax:-1, 'date_pointoftax', '', '', '', "add", 1, 1);
print ' ';
}
@@ -3598,13 +3625,11 @@ else if ($id > 0 || ! empty($ref))
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?facid=' . $object->id, $langs->trans('CloneInvoice'), $langs->trans('ConfirmCloneInvoice', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
}
- if (! $formconfirm)
- {
- $parameters = array('lineid' => $lineid);
- $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
- if (empty($reshook)) $formconfirm.=$hookmanager->resPrint;
- elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint;
- }
+ // Call Hook formConfirm
+ $parameters = array('lineid' => $lineid);
+ $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
+ if (empty($reshook)) $formconfirm.=$hookmanager->resPrint;
+ elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint;
// Print form confirm
print $formconfirm;
@@ -3703,7 +3728,7 @@ else if ($id > 0 || ! empty($ref))
$discount = new DiscountAbsolute($db);
$result = $discount->fetch(0, $object->id);
if ($result > 0){
- print '. '.$langs->trans("CreditNoteConvertedIntoDiscount", $object->getLibType(), $discount->getNomUrl(1, 'discount')).'
';
+ print '. '.$langs->trans("CreditNoteConvertedIntoDiscount", $object->getLibType(1), $discount->getNomUrl(1, 'discount')).'
';
}
}
print ' ';
@@ -4028,8 +4053,6 @@ else if ($id > 0 || ! empty($ref))
print '';
- // List of previous situation invoices
-
$sign = 1;
if ($object->type == Facture::TYPE_CREDIT_NOTE) $sign = - 1;
$nbrows = 8;
@@ -4370,7 +4393,7 @@ else if ($id > 0 || ! empty($ref))
}
else // Credit note
{
- $cssforamountpaymentcomplete='';
+ $cssforamountpaymentcomplete='amountpaymentneutral';
// Total already paid back
print '';
@@ -4385,7 +4408,7 @@ else if ($id > 0 || ! empty($ref))
if ($resteapayeraffiche <= 0)
print $langs->trans('RemainderToPayBack');
else
- print $langs->trans('ExcessPaydBack');
+ print $langs->trans('ExcessPaid');
print ' : ';
print '' . price($sign * $resteapayeraffiche) . ' ';
print ' ';
@@ -4730,7 +4753,7 @@ else if ($id > 0 || ! empty($ref))
}
// For situation invoice with excess received
- if ($object->statut == Facture::STATUS_VALIDATED
+ if ($object->statut > Facture::STATUS_DRAFT
&& ($object->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits) > 0
&& $user->rights->facture->creer
&& !$objectidnext
@@ -4748,7 +4771,7 @@ else if ($id > 0 || ! empty($ref))
}
// remove situation from cycle
- if ($object->statut == Facture::STATUS_VALIDATED
+ if ($object->statut > Facture::STATUS_DRAFT
&& $object->type == Facture::TYPE_SITUATION
&& $user->rights->facture->creer
&& !$objectidnext
@@ -4884,5 +4907,6 @@ else if ($id > 0 || ! empty($ref))
include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php
index 7012b0ef800..5075d9d8cb7 100644
--- a/htdocs/compta/facture/class/api_invoices.class.php
+++ b/htdocs/compta/facture/class/api_invoices.class.php
@@ -32,7 +32,7 @@ class Invoices extends DolibarrApi
* @var array $FIELDS Mandatory fields, checked when create and update object
*/
static $FIELDS = array(
- 'socid'
+ 'socid',
);
/**
@@ -104,7 +104,8 @@ class Invoices extends DolibarrApi
*
* @throws RestException
*/
- function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids='', $status='', $sqlfilters = '') {
+ function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids='', $status='', $sqlfilters = '')
+ {
global $db, $conf;
$obj_ret = array();
@@ -245,29 +246,30 @@ class Invoices extends DolibarrApi
* @throws 404
* @throws 405
*/
- function createInvoiceFromOrder($orderid) {
+ function createInvoiceFromOrder($orderid)
+ {
require_once DOL_DOCUMENT_ROOT . '/commande/class/commande.class.php';
if(! DolibarrApiAccess::$user->rights->commande->lire) {
- throw new RestException(401);
+ throw new RestException(401);
}
if(! DolibarrApiAccess::$user->rights->facture->creer) {
- throw new RestException(401);
+ throw new RestException(401);
}
if(empty($orderid)) {
- throw new RestException(400, 'Order ID is mandatory');
+ throw new RestException(400, 'Order ID is mandatory');
}
$order = new Commande($this->db);
$result = $order->fetch($orderid);
if( ! $result ) {
- throw new RestException(404, 'Order not found');
+ throw new RestException(404, 'Order not found');
}
$result = $this->invoice->createFromOrder($order, DolibarrApiAccess::$user);
if( $result < 0) {
- throw new RestException(405, $this->invoice->error);
+ throw new RestException(405, $this->invoice->error);
}
$this->invoice->fetchObjectLinked();
return $this->_cleanObjectDatas($this->invoice);
@@ -282,7 +284,8 @@ class Invoices extends DolibarrApi
*
* @return int
*/
- function getLines($id) {
+ function getLines($id)
+ {
if(! DolibarrApiAccess::$user->rights->facture->lire) {
throw new RestException(401);
}
@@ -319,7 +322,8 @@ class Invoices extends DolibarrApi
* @throws 401
* @throws 404
*/
- function putLine($id, $lineid, $request_data = null) {
+ function putLine($id, $lineid, $request_data = null)
+ {
if(! DolibarrApiAccess::$user->rights->facture->creer) {
throw new RestException(401);
}
@@ -383,7 +387,8 @@ class Invoices extends DolibarrApi
* @throws 404
* @throws 405
*/
- function deleteLine($id, $lineid) {
+ function deleteLine($id, $lineid)
+ {
if(! DolibarrApiAccess::$user->rights->facture->creer) {
throw new RestException(401);
@@ -511,67 +516,68 @@ class Invoices extends DolibarrApi
* @throws 404
* @throws 400
*/
- function postLine($id, $request_data = null) {
- if(! DolibarrApiAccess::$user->rights->facture->creer) {
- throw new RestException(401);
- }
+ function postLine($id, $request_data = null)
+ {
+ if(! DolibarrApiAccess::$user->rights->facture->creer) {
+ throw new RestException(401);
+ }
- $result = $this->invoice->fetch($id);
- if( ! $result ) {
- throw new RestException(404, 'Invoice not found');
- }
+ $result = $this->invoice->fetch($id);
+ if( ! $result ) {
+ throw new RestException(404, 'Invoice not found');
+ }
- if( ! DolibarrApi::_checkAccessToResource('facture',$this->invoice->id)) {
- throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
- }
+ if( ! DolibarrApi::_checkAccessToResource('facture',$this->invoice->id)) {
+ throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
+ }
- $request_data = (object) $request_data;
+ $request_data = (object) $request_data;
- // Reset fk_parent_line for no child products and special product
- if (($request_data->product_type != 9 && empty($request_data->fk_parent_line)) || $request_data->product_type == 9) {
- $request_data->fk_parent_line = 0;
- }
+ // Reset fk_parent_line for no child products and special product
+ if (($request_data->product_type != 9 && empty($request_data->fk_parent_line)) || $request_data->product_type == 9) {
+ $request_data->fk_parent_line = 0;
+ }
- // calculate pa_ht
- $marginInfos = getMarginInfos($request_data->subprice, $request_data->remise_percent, $request_data->tva_tx, $request_data->localtax1_tx, $request_data->localtax2_tx, $request_data->fk_fournprice, $request_data->pa_ht);
- $pa_ht = $marginInfos[0];
+ // calculate pa_ht
+ $marginInfos = getMarginInfos($request_data->subprice, $request_data->remise_percent, $request_data->tva_tx, $request_data->localtax1_tx, $request_data->localtax2_tx, $request_data->fk_fournprice, $request_data->pa_ht);
+ $pa_ht = $marginInfos[0];
- $updateRes = $this->invoice->addline(
- $request_data->desc,
- $request_data->subprice,
- $request_data->qty,
- $request_data->tva_tx,
- $request_data->localtax1_tx,
- $request_data->localtax2_tx,
- $request_data->fk_product,
- $request_data->remise_percent,
- $request_data->date_start,
- $request_data->date_end,
- $request_data->fk_code_ventilation,
- $request_data->info_bits,
- $request_data->fk_remise_except,
- 'HT',
- 0,
- $request_data->product_type,
- $request_data->rang,
- $request_data->special_code,
- $request_data->origin,
- $request_data->origin_id,
- $request_data->fk_parent_line,
- empty($request_data->fk_fournprice)?null:$request_data->fk_fournprice,
- $pa_ht,
- $request_data->label,
- $request_data->array_options,
- $request_data->situation_percent,
- $request_data->fk_prev_id,
- $request_data->fk_unit
- );
+ $updateRes = $this->invoice->addline(
+ $request_data->desc,
+ $request_data->subprice,
+ $request_data->qty,
+ $request_data->tva_tx,
+ $request_data->localtax1_tx,
+ $request_data->localtax2_tx,
+ $request_data->fk_product,
+ $request_data->remise_percent,
+ $request_data->date_start,
+ $request_data->date_end,
+ $request_data->fk_code_ventilation,
+ $request_data->info_bits,
+ $request_data->fk_remise_except,
+ 'HT',
+ 0,
+ $request_data->product_type,
+ $request_data->rang,
+ $request_data->special_code,
+ $request_data->origin,
+ $request_data->origin_id,
+ $request_data->fk_parent_line,
+ empty($request_data->fk_fournprice)?null:$request_data->fk_fournprice,
+ $pa_ht,
+ $request_data->label,
+ $request_data->array_options,
+ $request_data->situation_percent,
+ $request_data->fk_prev_id,
+ $request_data->fk_unit
+ );
- if ($updateRes < 0) {
+ if ($updateRes < 0) {
throw new RestException(400, 'Unable to insert the new line. Check your inputs. '.$this->invoice->error);
- }
+ }
- return $updateRes;
+ return $updateRes;
}
/**
@@ -647,23 +653,23 @@ class Invoices extends DolibarrApi
function settodraft($id, $idwarehouse=-1)
{
if(! DolibarrApiAccess::$user->rights->facture->creer) {
- throw new RestException(401);
+ throw new RestException(401);
}
$result = $this->invoice->fetch($id);
if( ! $result ) {
- throw new RestException(404, 'Invoice not found');
+ throw new RestException(404, 'Invoice not found');
}
if( ! DolibarrApi::_checkAccessToResource('facture',$this->invoice->id)) {
- throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
+ throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$result = $this->invoice->set_draft(DolibarrApiAccess::$user, $idwarehouse);
if ($result == 0) {
- throw new RestException(304, 'Nothing done.');
+ throw new RestException(304, 'Nothing done.');
}
if ($result < 0) {
- throw new RestException(500, 'Error : '.$this->invoice->error);
+ throw new RestException(500, 'Error : '.$this->invoice->error);
}
$result = $this->invoice->fetch($id);
@@ -750,23 +756,23 @@ class Invoices extends DolibarrApi
function settopaid($id, $close_code='', $close_note='')
{
if(! DolibarrApiAccess::$user->rights->facture->creer) {
- throw new RestException(401);
+ throw new RestException(401);
}
$result = $this->invoice->fetch($id);
if( ! $result ) {
- throw new RestException(404, 'Invoice not found');
+ throw new RestException(404, 'Invoice not found');
}
if( ! DolibarrApi::_checkAccessToResource('facture',$this->invoice->id)) {
- throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
+ throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$result = $this->invoice->set_paid(DolibarrApiAccess::$user, $close_code, $close_note);
if ($result == 0) {
- throw new RestException(304, 'Error nothing done. May be object is already validated');
+ throw new RestException(304, 'Error nothing done. May be object is already validated');
}
if ($result < 0) {
- throw new RestException(500, 'Error : '.$this->invoice->error);
+ throw new RestException(500, 'Error : '.$this->invoice->error);
}
@@ -801,23 +807,23 @@ class Invoices extends DolibarrApi
function settounpaid($id)
{
if(! DolibarrApiAccess::$user->rights->facture->creer) {
- throw new RestException(401);
+ throw new RestException(401);
}
$result = $this->invoice->fetch($id);
if( ! $result ) {
- throw new RestException(404, 'Invoice not found');
+ throw new RestException(404, 'Invoice not found');
}
if( ! DolibarrApi::_checkAccessToResource('facture',$this->invoice->id)) {
- throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
+ throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$result = $this->invoice->set_unpaid(DolibarrApiAccess::$user);
if ($result == 0) {
- throw new RestException(304, 'Nothing done');
+ throw new RestException(304, 'Nothing done');
}
if ($result < 0) {
- throw new RestException(500, 'Error : '.$this->invoice->error);
+ throw new RestException(500, 'Error : '.$this->invoice->error);
}
@@ -849,30 +855,31 @@ class Invoices extends DolibarrApi
* @throws 404
* @throws 405
*/
- function useDiscount($id, $discountid) {
+ function useDiscount($id, $discountid)
+ {
if(! DolibarrApiAccess::$user->rights->facture->creer) {
- throw new RestException(401);
+ throw new RestException(401);
}
if(empty($id)) {
- throw new RestException(400, 'Invoice ID is mandatory');
+ throw new RestException(400, 'Invoice ID is mandatory');
}
if(empty($discountid)) {
- throw new RestException(400, 'Discount ID is mandatory');
+ throw new RestException(400, 'Discount ID is mandatory');
}
if( ! DolibarrApi::_checkAccessToResource('facture',$id)) {
- throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
+ throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$result = $this->invoice->fetch($id);
if( ! $result ) {
- throw new RestException(404, 'Invoice not found');
+ throw new RestException(404, 'Invoice not found');
}
$result = $this->invoice->insert_discount($discountid);
if( $result < 0) {
- throw new RestException(405, $this->invoice->error);
+ throw new RestException(405, $this->invoice->error);
}
return $result;
@@ -894,32 +901,33 @@ class Invoices extends DolibarrApi
* @throws 404
* @throws 405
*/
- function useCreditNote($id, $discountid) {
+ function useCreditNote($id, $discountid)
+ {
require_once DOL_DOCUMENT_ROOT . '/core/class/discount.class.php';
if(! DolibarrApiAccess::$user->rights->facture->creer) {
- throw new RestException(401);
+ throw new RestException(401);
}
if(empty($id)) {
- throw new RestException(400, 'Invoice ID is mandatory');
+ throw new RestException(400, 'Invoice ID is mandatory');
}
if(empty($discountid)) {
- throw new RestException(400, 'Credit ID is mandatory');
+ throw new RestException(400, 'Credit ID is mandatory');
}
if( ! DolibarrApi::_checkAccessToResource('facture',$id)) {
- throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
+ throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$discount = new DiscountAbsolute($this->db);
$result = $discount->fetch($discountid);
if( ! $result ) {
- throw new RestException(404, 'Credit not found');
+ throw new RestException(404, 'Credit not found');
}
$result = $discount->link_to_invoice(0, $id);
if( $result < 0) {
- throw new RestException(405, $discount->error);
+ throw new RestException(405, $discount->error);
}
return $result;
@@ -938,27 +946,28 @@ class Invoices extends DolibarrApi
* @throws 404
* @throws 405
*/
- function getPayments($id) {
+ function getPayments($id)
+ {
if(! DolibarrApiAccess::$user->rights->facture->lire) {
- throw new RestException(401);
+ throw new RestException(401);
}
if(empty($id)) {
- throw new RestException(400, 'Invoice ID is mandatory');
+ throw new RestException(400, 'Invoice ID is mandatory');
}
if( ! DolibarrApi::_checkAccessToResource('facture',$id)) {
- throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
+ throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$result = $this->invoice->fetch($id);
if( ! $result ) {
- throw new RestException(404, 'Invoice not found');
+ throw new RestException(404, 'Invoice not found');
}
$result = $this->invoice->getListOfPayments();
if( $result < 0) {
- throw new RestException(405, $this->invoice->error);
+ throw new RestException(405, $this->invoice->error);
}
return $result;
@@ -985,8 +994,9 @@ class Invoices extends DolibarrApi
* @throws 401
* @throws 404
*/
- function addPayment($id, $datepaye, $paiementid, $closepaidinvoices, $accountid, $num_paiement='', $comment='', $chqemetteur='', $chqbank='') {
- global $conf;
+ function addPayment($id, $datepaye, $paiementid, $closepaidinvoices, $accountid, $num_paiement='', $comment='', $chqemetteur='', $chqbank='')
+ {
+ global $conf;
require_once DOL_DOCUMENT_ROOT . '/compta/paiement/class/paiement.class.php';
@@ -1111,7 +1121,7 @@ class Invoices extends DolibarrApi
require_once DOL_DOCUMENT_ROOT . '/compta/paiement/class/paiement.class.php';
if(! DolibarrApiAccess::$user->rights->facture->creer) {
- throw new RestException(403);
+ throw new RestException(403);
}
foreach($arrayofamounts as $id => $amount) {
if(empty($id)) {
@@ -1215,18 +1225,19 @@ class Invoices extends DolibarrApi
* @param object $object Object to clean
* @return array Array of cleaned object properties
*/
- function _cleanObjectDatas($object) {
+ function _cleanObjectDatas($object)
+ {
- $object = parent::_cleanObjectDatas($object);
+ $object = parent::_cleanObjectDatas($object);
unset($object->note);
- unset($object->address);
- unset($object->barcode_type);
- unset($object->barcode_type_code);
- unset($object->barcode_type_label);
- unset($object->barcode_type_coder);
+ unset($object->address);
+ unset($object->barcode_type);
+ unset($object->barcode_type_code);
+ unset($object->barcode_type_label);
+ unset($object->barcode_type_coder);
- return $object;
+ return $object;
}
/**
@@ -1241,11 +1252,11 @@ class Invoices extends DolibarrApi
{
$invoice = array();
foreach (Invoices::$FIELDS as $field) {
- if (!isset($data[$field]))
+ if (!isset($data[$field])) {
throw new RestException(400, "$field field missing");
+ }
$invoice[$field] = $data[$field];
}
return $invoice;
}
-
}
diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php
index 71123d1c6e2..1c97b82d926 100644
--- a/htdocs/compta/facture/class/facture-rec.class.php
+++ b/htdocs/compta/facture/class/facture-rec.class.php
@@ -39,36 +39,55 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
*/
class FactureRec extends CommonInvoice
{
+ /**
+ * @var string ID to identify managed object
+ */
public $element='facturerec';
+
+ /**
+ * @var string Name of table without prefix where object is stored
+ */
public $table_element='facture_rec';
+
+ /**
+ * @var int Name of subtable line
+ */
public $table_element_line='facturedet_rec';
+
+ /**
+ * @var int Field with ID of parent key if this field has a parent
+ */
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
+ */
public $picto='bill';
- var $entity;
- var $number;
- var $date;
- var $amount;
- var $remise;
- var $tva;
- var $total;
- var $db_table;
- var $propalid;
+ public $entity;
+ public $number;
+ public $date;
+ public $amount;
+ public $remise;
+ public $tva;
+ public $total;
+ public $db_table;
+ public $propalid;
- var $date_last_gen;
- var $date_when;
- var $nb_gen_done;
- var $nb_gen_max;
+ public $date_last_gen;
+ public $date_when;
+ public $nb_gen_done;
+ public $nb_gen_max;
- var $frequency;
- var $unit_frequency;
+ public $frequency;
+ public $unit_frequency;
- var $rang;
- var $special_code;
+ public $rang;
+ public $special_code;
- var $usenewprice=0;
+ public $usenewprice=0;
- var $suspended; // status
+ public $suspended; // status
const STATUS_NOTSUSPENDED = 0;
const STATUS_SUSPENDED = 1;
@@ -432,18 +451,20 @@ class FactureRec extends CommonInvoice
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Recupere les lignes de factures predefinies dans this->lines
*
- * @return int 1 if OK, < 0 if KO
- */
+ * @return int 1 if OK, < 0 if KO
+ */
function fetch_lines()
{
+ // phpcs:enable
$this->lines=array();
// Retreive all extrafield for line
// fetch optionals attributes and labels
- require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
+ require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
$extrafieldsline=new ExtraFields($this->db);
$extrafieldsline=$extrafieldsline->fetch_name_optionals_label('facturedet_rec',true);
@@ -983,7 +1004,8 @@ class FactureRec extends CommonInvoice
$error=0;
- $langs->load("bills");
+ // Load translation files required by the page
+ $langs->loadLangs(array("main","bills"));
$nb_create=0;
@@ -1060,6 +1082,8 @@ class FactureRec extends CommonInvoice
}
if (! $error && $facturerec->generate_pdf)
{
+ // We refresh the object in order to have all necessary data (like date_lim_reglement)
+ $facture->fetch($facture->id);
$result = $facture->generateDocument($facturerec->modelpdf, $langs);
if ($result <= 0)
{
@@ -1170,6 +1194,7 @@ class FactureRec extends CommonInvoice
return $this->LibStatut($this->frequency?1:0, $this->suspended, $mode, $alreadypaid, empty($this->type)?0:$this->type);
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Return label of a status
*
@@ -1182,6 +1207,7 @@ class FactureRec extends CommonInvoice
*/
function LibStatut($recur, $status, $mode=0, $alreadypaid=-1, $type=0)
{
+ // phpcs:enable
global $langs;
$langs->load('bills');
@@ -1200,7 +1226,7 @@ class FactureRec extends CommonInvoice
else return $langs->trans("Draft");
}
}
- if ($mode == 1)
+ elseif ($mode == 1)
{
$prefix='Short';
if ($recur)
@@ -1214,7 +1240,7 @@ class FactureRec extends CommonInvoice
else return $langs->trans("Draft");
}
}
- if ($mode == 2)
+ elseif ($mode == 2)
{
if ($recur)
{
@@ -1227,7 +1253,7 @@ class FactureRec extends CommonInvoice
else return img_picto($langs->trans('Draft'),'statut0').' '.$langs->trans('Draft');
}
}
- if ($mode == 3)
+ elseif ($mode == 3)
{
if ($recur)
{
@@ -1241,7 +1267,7 @@ class FactureRec extends CommonInvoice
else return img_picto($langs->trans('Draft'),'statut0');
}
}
- if ($mode == 4)
+ elseif ($mode == 4)
{
$prefix='';
if ($recur)
@@ -1255,7 +1281,7 @@ class FactureRec extends CommonInvoice
else return img_picto($langs->trans('Draft'),'statut0').' '.$langs->trans('Draft');
}
}
- if ($mode == 5 || $mode == 6)
+ elseif ($mode == 5 || $mode == 6)
{
$prefix='';
if ($mode == 5) $prefix='Short';
@@ -1636,7 +1662,14 @@ class FactureRec extends CommonInvoice
*/
class FactureLigneRec extends CommonInvoiceLine
{
+ /**
+ * @var string ID to identify managed object
+ */
public $element='facturedetrec';
+
+ /**
+ * @var string Name of table without prefix where object is stored
+ */
public $table_element='facturedet_rec';
var $date_start_fill;
@@ -1840,7 +1873,5 @@ class FactureLigneRec extends CommonInvoiceLine
$this->db->rollback();
return -2;
}
-
}
-
}
diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php
index c6e43206c78..0773e6eedc1 100644
--- a/htdocs/compta/facture/class/facture.class.php
+++ b/htdocs/compta/facture/class/facture.class.php
@@ -53,16 +53,37 @@ if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accoun
*/
class Facture extends CommonInvoice
{
+ /**
+ * @var string ID to identify managed object
+ */
public $element='facture';
+
+ /**
+ * @var string Name of table without prefix where object is stored
+ */
public $table_element='facture';
+
+ /**
+ * @var int Name of subtable line
+ */
public $table_element_line = 'facturedet';
+
+ /**
+ * @var int Field with ID of parent key if this field has a parent
+ */
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
+ */
public $picto='bill';
+
/**
* 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
* @var int
*/
public $ismultientitymanaged = 1;
+
/**
* 0=Default, 1=View may be restricted to sales representative only if no permission to see all or to company of external user if external user
* @var integer
@@ -112,14 +133,17 @@ class Facture extends CommonInvoice
public $cond_reglement_code; // Code in llx_c_paiement
public $mode_reglement_code; // Code in llx_c_paiement
public $fk_bank; // Field to store bank id to use when payment mode is withdraw
+
/**
* @deprecated
*/
public $products=array();
+
/**
* @var FactureLigne[]
*/
public $lines=array();
+
public $line;
public $extraparams=array();
public $specimen;
@@ -1159,7 +1183,8 @@ class Facture extends CommonInvoice
if ($option == 'withdraw') $url = DOL_URL_ROOT.'/compta/facture/prelevement.php?facid='.$this->id;
else $url = DOL_URL_ROOT.'/compta/facture/card.php?facid='.$this->id;
- if ($short) return $url;
+ if (!$user->rights->facture->lire)
+ $option = 'nolink';
if ($option !== 'nolink')
{
@@ -1169,6 +1194,8 @@ class Facture extends CommonInvoice
if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1';
}
+ if ($short) return $url;
+
$picto='bill';
if ($this->type == self::TYPE_REPLACEMENT) $picto.='r'; // Replacement invoice
if ($this->type == self::TYPE_CREDIT_NOTE) $picto.='a'; // Credit note
@@ -1185,9 +1212,9 @@ class Facture extends CommonInvoice
$label.= '
' . $langs->trans('AmountHT') . ': ' . price($this->total_ht, 0, $langs, 0, -1, -1, $conf->currency);
if (! empty($this->total_tva))
$label.= '
' . $langs->trans('VAT') . ': ' . price($this->total_tva, 0, $langs, 0, -1, -1, $conf->currency);
- if (! empty($this->total_localtax1))
- $label.= '
' . $langs->trans('LT1') . ': ' . price($this->total_localtax1, 0, $langs, 0, -1, -1, $conf->currency);
- if (! empty($this->total_localtax2))
+ if (! empty($this->total_localtax1) && $this->total_localtax1 != 0) // We keep test != 0 because $this->total_localtax1 can be '0.00000000'
+ $label.= '
eee' . $langs->trans('LT1') . ': ' . price($this->total_localtax1, 0, $langs, 0, -1, -1, $conf->currency);
+ if (! empty($this->total_localtax2) && $this->total_localtax2 != 0)
$label.= '
' . $langs->trans('LT2') . ': ' . price($this->total_localtax2, 0, $langs, 0, -1, -1, $conf->currency);
if (! empty($this->total_ttc))
$label.= '
' . $langs->trans('AmountTTC') . ': ' . price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency);
@@ -1214,6 +1241,11 @@ class Facture extends CommonInvoice
$linkstart.=$linkclose.'>';
$linkend='';
+ if ($option == 'nolink') {
+ $linkstart = '';
+ $linkend = '';
+ }
+
$result .= $linkstart;
if ($withpicto) $result.=img_object(($notooltip?'':$label), $picto, ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1);
if ($withpicto != 2) $result.= ($max?dol_trunc($this->ref,$max):$this->ref);
@@ -1392,6 +1424,7 @@ class Facture extends CommonInvoice
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Load all detailed lines into this->lines
*
@@ -1399,6 +1432,7 @@ class Facture extends CommonInvoice
*/
function fetch_lines()
{
+ // phpcs:enable
$this->lines=array();
$sql = 'SELECT l.rowid, l.fk_facture, l.fk_product, l.fk_parent_line, l.label as custom_label, l.description, l.product_type, l.price, l.qty, l.vat_src_code, l.tva_tx,';
@@ -1537,7 +1571,6 @@ class Facture extends CommonInvoice
}
}
}
-
}
/**
@@ -1549,6 +1582,8 @@ class Facture extends CommonInvoice
*/
function update(User $user, $notrigger=0)
{
+ global $conf;
+
$error=0;
// Clean parameters
@@ -1614,17 +1649,23 @@ class Facture extends CommonInvoice
$error++; $this->errors[]="Error ".$this->db->lasterror();
}
- if (! $error)
+ if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options)>0)
{
- if (! $notrigger)
+ $result=$this->insertExtraFields();
+ if ($result < 0)
{
- // Call trigger
- $result=$this->call_trigger('BILL_MODIFY',$user);
- if ($result < 0) $error++;
- // End call triggers
+ $error++;
}
}
+ if (! $error && ! $notrigger)
+ {
+ // Call trigger
+ $result=$this->call_trigger('BILL_MODIFY',$user);
+ if ($result < 0) $error++;
+ // End call triggers
+ }
+
// Commit or rollback
if ($error)
{
@@ -1644,6 +1685,7 @@ class Facture extends CommonInvoice
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Add a discount line into an invoice (as an invoice line) using an existing absolute discount (Consume the discount)
*
@@ -1652,6 +1694,7 @@ class Facture extends CommonInvoice
*/
function insert_discount($idremise)
{
+ // phpcs:enable
global $langs;
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
@@ -1744,6 +1787,7 @@ class Facture extends CommonInvoice
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Set customer ref
*
@@ -1753,6 +1797,7 @@ class Facture extends CommonInvoice
*/
function set_ref_client($ref_client, $notrigger=0)
{
+ // phpcs:enable
global $user;
$error=0;
@@ -1977,6 +2022,7 @@ class Facture extends CommonInvoice
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Tag la facture comme paye completement (si close_code non renseigne) => this->fk_statut=2, this->paye=1
* ou partiellement (si close_code renseigne) + appel trigger BILL_PAYED => this->fk_statut=2, this->paye stay 0
@@ -1988,6 +2034,7 @@ class Facture extends CommonInvoice
*/
function set_paid($user, $close_code='', $close_note='')
{
+ // phpcs:enable
$error=0;
if ($this->paye != 1)
@@ -2035,6 +2082,7 @@ class Facture extends CommonInvoice
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Tag la facture comme non payee completement + appel trigger BILL_UNPAYED
* Fonction utilisee quand un paiement prelevement est refuse,
@@ -2045,6 +2093,7 @@ class Facture extends CommonInvoice
*/
function set_unpaid($user)
{
+ // phpcs:enable
$error=0;
$this->db->begin();
@@ -2082,6 +2131,7 @@ class Facture extends CommonInvoice
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Tag invoice as canceled, with no payment on it (example for replacement invoice or payment never received) + call trigger BILL_CANCEL
* Warning, if option to decrease stock on invoice was set, this function does not change stock (it might be a cancel because
@@ -2094,6 +2144,7 @@ class Facture extends CommonInvoice
*/
function set_canceled($user, $close_code='', $close_note='')
{
+ // phpcs:enable
dol_syslog(get_class($this)."::set_canceled rowid=".$this->id, LOG_DEBUG);
@@ -2445,6 +2496,7 @@ class Facture extends CommonInvoice
return true;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Set draft status
*
@@ -2454,6 +2506,7 @@ class Facture extends CommonInvoice
*/
function set_draft($user,$idwarehouse=-1)
{
+ // phpcs:enable
global $conf,$langs;
$error=0;
@@ -3010,6 +3063,7 @@ class Facture extends CommonInvoice
else return $situation_percent < $obj->situation_percent;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Update invoice line with percentage
*
@@ -3019,9 +3073,10 @@ class Facture extends CommonInvoice
*/
function update_percent($line, $percent)
{
+ // phpcs:enable
global $mysoc,$user;
- include_once(DOL_DOCUMENT_ROOT . '/core/lib/price.lib.php');
+ include_once DOL_DOCUMENT_ROOT . '/core/lib/price.lib.php';
// Cap percentages to 100
if ($percent > 100) $percent = 100;
@@ -3106,6 +3161,7 @@ class Facture extends CommonInvoice
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Set percent discount
*
@@ -3116,6 +3172,7 @@ class Facture extends CommonInvoice
*/
function set_remise($user, $remise, $notrigger=0)
{
+ // phpcs:enable
// Clean parameters
if (empty($remise)) $remise=0;
@@ -3170,6 +3227,7 @@ class Facture extends CommonInvoice
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Set absolute discount
*
@@ -3180,6 +3238,7 @@ class Facture extends CommonInvoice
*/
function set_remise_absolue($user, $remise, $notrigger=0)
{
+ // phpcs:enable
if (empty($remise)) $remise=0;
if ($user->rights->facture->creer)
@@ -3370,6 +3429,7 @@ class Facture extends CommonInvoice
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Return list of invoices (eventually filtered on a user) into an array
*
@@ -3385,6 +3445,7 @@ class Facture extends CommonInvoice
*/
function liste_array($shortlist=0, $draft=0, $excluser='', $socid=0, $limit=0, $offset=0, $sortfield='f.datef,f.rowid', $sortorder='DESC')
{
+ // phpcs:enable
global $conf,$user;
$ga = array();
@@ -3444,6 +3505,7 @@ class Facture extends CommonInvoice
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Return list of invoices qualified to be replaced by another invoice.
* Invoices matching the following rules are returned:
@@ -3454,6 +3516,7 @@ class Facture extends CommonInvoice
*/
function list_replacable_invoices($socid=0)
{
+ // phpcs:enable
global $conf;
$return = array();
@@ -3492,6 +3555,7 @@ class Facture extends CommonInvoice
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Return list of invoices qualified to be corrected by a credit note.
* Invoices matching the following rules are returned:
@@ -3502,6 +3566,7 @@ class Facture extends CommonInvoice
*/
function list_qualified_avoir_invoices($socid=0)
{
+ // phpcs:enable
global $conf;
$return = array();
@@ -3565,6 +3630,7 @@ class Facture extends CommonInvoice
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Create a withdrawal request for a standing order.
* Use the remain to pay excluding all existing open direct debit requests.
@@ -3575,6 +3641,7 @@ class Facture extends CommonInvoice
*/
function demande_prelevement($fuser, $amount=0)
{
+ // phpcs:enable
$error=0;
@@ -3675,6 +3742,7 @@ class Facture extends CommonInvoice
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Supprime une demande de prelevement
*
@@ -3684,6 +3752,7 @@ class Facture extends CommonInvoice
*/
function demande_prelevement_delete($fuser, $did)
{
+ // phpcs:enable
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.'prelevement_facture_demande';
$sql .= ' WHERE rowid = '.$did;
$sql .= ' AND traite = 0';
@@ -3700,6 +3769,7 @@ class Facture extends CommonInvoice
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Load indicators for dashboard (this->nbtodo and this->nbtodolate)
*
@@ -3708,11 +3778,12 @@ class Facture extends CommonInvoice
*/
function load_board($user)
{
+ // phpcs:enable
global $conf, $langs;
$clause = " WHERE";
- $sql = "SELECT f.rowid, f.date_lim_reglement as datefin,f.fk_statut";
+ $sql = "SELECT f.rowid, f.date_lim_reglement as datefin,f.fk_statut, f.total";
$sql.= " FROM ".MAIN_DB_PREFIX."facture as f";
if (!$user->rights->societe->client->voir && !$user->societe_id)
{
@@ -3734,7 +3805,7 @@ class Facture extends CommonInvoice
$response = new WorkboardResponse();
$response->warning_delay=$conf->facture->client->warning_delay/60/60/24;
$response->label=$langs->trans("CustomerBillsUnpaid");
- $response->url=DOL_URL_ROOT.'/compta/facture/list.php?search_status=1&mainmenu=accountancy&leftmenu=customers_bills';
+ $response->url=DOL_URL_ROOT.'/compta/facture/list.php?search_status=1&mainmenu=billing&leftmenu=customers_bills';
$response->img=img_object('',"bill");
$generic_facture = new Facture($this->db);
@@ -3745,6 +3816,7 @@ class Facture extends CommonInvoice
$generic_facture->statut = $obj->fk_statut;
$response->nbtodo++;
+ $response->total += $obj->total;
if ($generic_facture->hasDelay()) {
$response->nbtodolate++;
@@ -3944,6 +4016,7 @@ class Facture extends CommonInvoice
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Load indicators for dashboard (this->nbtodo and this->nbtodolate)
*
@@ -3951,6 +4024,7 @@ class Facture extends CommonInvoice
*/
function load_state_board()
{
+ // phpcs:enable
global $conf, $user;
$this->nb=array();
@@ -4057,6 +4131,7 @@ class Facture extends CommonInvoice
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Checks if the invoice is the first of a cycle
*
@@ -4064,9 +4139,11 @@ class Facture extends CommonInvoice
*/
function is_first()
{
+ // phpcs:enable
return ($this->situation_counter == 1);
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Returns an array containing the previous situations as Facture objects
*
@@ -4074,6 +4151,7 @@ class Facture extends CommonInvoice
*/
function get_prev_sits()
{
+ // phpcs:enable
global $conf;
$sql = 'SELECT rowid FROM ' . MAIN_DB_PREFIX . 'facture';
@@ -4146,6 +4224,7 @@ class Facture extends CommonInvoice
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Checks if the invoice is the last in its cycle
*
@@ -4154,6 +4233,7 @@ class Facture extends CommonInvoice
*/
function is_last_in_cycle()
{
+ // phpcs:enable
global $conf;
if (!empty($this->situation_cycle_ref)) {
@@ -4216,8 +4296,15 @@ class Facture extends CommonInvoice
*/
class FactureLigne extends CommonInvoiceLine
{
- public $element='facturedet';
- public $table_element='facturedet';
+ /**
+ * @var string ID to identify managed object
+ */
+ public $element='facturedet';
+
+ /**
+ * @var string Name of table without prefix where object is stored
+ */
+ public $table_element='facturedet';
var $oldline;
@@ -4325,6 +4412,7 @@ class FactureLigne extends CommonInvoiceLine
$objp = $this->db->fetch_object($result);
$this->rowid = $objp->rowid;
+ $this->id = $objp->rowid;
$this->fk_facture = $objp->fk_facture;
$this->fk_parent_line = $objp->fk_parent_line;
$this->label = $objp->custom_label;
@@ -4775,14 +4863,16 @@ class FactureLigne extends CommonInvoiceLine
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
- * Mise a jour en base des champs total_xxx de ligne de facture
- * TODO What is goal of this method ?
+ * Update DB line fields total_xxx
+ * Used by migration
*
* @return int <0 if KO, >0 if OK
*/
function update_total()
{
+ // phpcs:enable
$this->db->begin();
dol_syslog(get_class($this)."::update_total", LOG_DEBUG);
@@ -4815,6 +4905,7 @@ class FactureLigne extends CommonInvoiceLine
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Returns situation_percent of the previous line.
* Warning: If invoice is a replacement invoice, this->fk_prev_id is id of the replaced line.
@@ -4824,6 +4915,7 @@ class FactureLigne extends CommonInvoiceLine
*/
function get_prev_progress($invoiceid)
{
+ // phpcs:enable
if (is_null($this->fk_prev_id) || empty($this->fk_prev_id) || $this->fk_prev_id == "") {
return 0;
} else {
@@ -4836,7 +4928,7 @@ class FactureLigne extends CommonInvoiceLine
$resql = $this->db->query($sql);
if ($resql && $resql->num_rows > 0) {
$res = $this->db->fetch_array($resql);
- return $res['situation_percent'];
+ return floatval($res['situation_percent']);
} else {
$this->error = $this->db->error();
dol_syslog(get_class($this) . "::select Error " . $this->error, LOG_ERR);
diff --git a/htdocs/compta/facture/class/facturestats.class.php b/htdocs/compta/facture/class/facturestats.class.php
index a23d5bdc2c2..ef54a6ffa5f 100644
--- a/htdocs/compta/facture/class/facturestats.class.php
+++ b/htdocs/compta/facture/class/facturestats.class.php
@@ -35,7 +35,11 @@ class FactureStats extends Stats
var $socid;
var $userid;
- public $table_element;
+ /**
+ * @var string Name of table without prefix where object is stored
+ */
+ public $table_element;
+
var $from;
var $field;
var $where;
@@ -220,7 +224,5 @@ class FactureStats extends Stats
return $this->_getAllByProduct($sql);
}
-
-
}
diff --git a/htdocs/compta/facture/class/paymentterm.class.php b/htdocs/compta/facture/class/paymentterm.class.php
index 3697a61672b..619487e9574 100644
--- a/htdocs/compta/facture/class/paymentterm.class.php
+++ b/htdocs/compta/facture/class/paymentterm.class.php
@@ -28,23 +28,38 @@
*/
class PaymentTerm // extends CommonObject
{
- var $db; //!< To store db handler
- var $error; //!< To return error code (or message)
- var $errors=array(); //!< To return several error codes (or messages)
+ /**
+ * @var DoliDB Database handler.
+ */
+ public $db;
+
+ /**
+ * @var string Error code (or message)
+ */
+ public $error='';
+
+ /**
+ * @var string[] Error codes (or messages)
+ */
+ public $errors = array();
+
//public $element='c_payment_term'; //!< Id that identify managed objects
//public $table_element='c_payment_term'; //!< Name of table without prefix where object is stored
- var $context =array();
+ public $context =array();
- var $id;
+ /**
+ * @var int ID
+ */
+ public $id;
- var $code;
- var $sortorder;
- var $active;
- var $libelle;
- var $libelle_facture;
- var $type_cdr;
- var $nbjour;
- var $decalage;
+ public $code;
+ public $sortorder;
+ public $active;
+ public $libelle;
+ public $libelle_facture;
+ public $type_cdr;
+ public $nbjour;
+ public $decalage;
@@ -467,5 +482,4 @@ class PaymentTerm // extends CommonObject
$this->nbjour='';
$this->decalage='';
}
-
}
diff --git a/htdocs/compta/facture/contact.php b/htdocs/compta/facture/contact.php
index af872a174ca..ab96700fc53 100644
--- a/htdocs/compta/facture/contact.php
+++ b/htdocs/compta/facture/contact.php
@@ -215,6 +215,6 @@ if ($id > 0 || ! empty($ref))
}
}
-
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/compta/facture/document.php b/htdocs/compta/facture/document.php
index 828c77f1178..0ce8ad7eb92 100644
--- a/htdocs/compta/facture/document.php
+++ b/htdocs/compta/facture/document.php
@@ -35,7 +35,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
if (! empty($conf->projet->enabled)) {
- require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
+ include_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
}
// Load translation files required by the page
@@ -78,7 +78,7 @@ if ($object->fetch($id))
* Actions
*/
-include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php';
+require_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php';
/*
@@ -104,7 +104,7 @@ if ($id > 0 || ! empty($ref))
$totalpaye = $object->getSommePaiement();
- // Construit liste des fichiers
+ // Build file list
$filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
$totalsize=0;
foreach($filearray as $key => $file)
@@ -191,6 +191,6 @@ else
print $langs->trans("ErrorUnknown");
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php
index 6719e7091c8..3fa091e0665 100644
--- a/htdocs/compta/facture/fiche-rec.php
+++ b/htdocs/compta/facture/fiche-rec.php
@@ -1,14 +1,14 @@
- * Copyright (C) 2004-2016 Laurent Destailleur
- * Copyright (C) 2005-2012 Regis Houssin
- * Copyright (C) 2013 Florian Henry
- * Copyright (C) 2013 Juanjo Menent
- * Copyright (C) 2015 Jean-François Ferry
- * Copyright (C) 2012 Cedric Salvador
- * Copyright (C) 2015 Alexandre Spangaro
- * Copyright (C) 2016 Meziane Sof
- * Copyright (C) 2017 Frédéric France
+/* Copyright (C) 2002-2003 Rodolphe Quiedeville
+ * Copyright (C) 2004-2016 Laurent Destailleur
+ * Copyright (C) 2005-2012 Regis Houssin
+ * Copyright (C) 2013 Florian Henry
+ * Copyright (C) 2013 Juanjo Menent
+ * Copyright (C) 2015 Jean-François Ferry
+ * Copyright (C) 2012 Cedric Salvador
+ * Copyright (C) 2015 Alexandre Spangaro
+ * Copyright (C) 2016 Meziane Sof
+ * Copyright (C) 2017-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
@@ -35,8 +35,8 @@ require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php';
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
if (! empty($conf->projet->enabled)) {
- require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
- //require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php';
+ include_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
+ //include_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php';
}
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
@@ -546,7 +546,7 @@ if (empty($reshook))
}
elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES))
{
- require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php';
+ include_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php';
$prodcustprice = new Productcustomerprice($db);
@@ -1113,7 +1113,7 @@ if ($action == 'create')
// Date next run
print "".$langs->trans('NextDateToExecution')." ";
$date_next_execution = isset($date_next_execution) ? $date_next_execution : (GETPOST('remonth') ? dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')) : -1);
- print $form->select_date($date_next_execution, '', 1, 1, '', "add", 1, 1, 1);
+ print $form->selectDate($date_next_execution, '', 1, 1, '', "add", 1, 1);
print " ";
// Number max of generation
@@ -1513,7 +1513,7 @@ else
//var_dump(dol_print_date($object->date_when+60, 'dayhour').' - '.dol_print_date($now, 'dayhour'));
if (! $object->isMaxNbGenReached())
{
- if ($action != 'editdate_when' && $object->frequency > 0 && $object->date_when && $object->date_when < $now) print img_warning($langs->trans("Late"));
+ if (! $object->suspended && $action != 'editdate_when' && $object->frequency > 0 && $object->date_when && $object->date_when < $now) print img_warning($langs->trans("Late"));
}
else
{
@@ -1734,6 +1734,6 @@ else
}
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/facture/info.php b/htdocs/compta/facture/info.php
index 8964b85203b..aff7cb362a8 100644
--- a/htdocs/compta/facture/info.php
+++ b/htdocs/compta/facture/info.php
@@ -29,7 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php';
if (! empty($conf->projet->enabled)) {
- require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
+ include_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
}
// Load translation files required by the page
@@ -122,5 +122,6 @@ print '';
dol_fiche_end();
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/compta/facture/invoicetemplate_list.php b/htdocs/compta/facture/invoicetemplate_list.php
index 13db00a02c2..cf41f864f05 100644
--- a/htdocs/compta/facture/invoicetemplate_list.php
+++ b/htdocs/compta/facture/invoicetemplate_list.php
@@ -607,7 +607,7 @@ if ($resql)
print ($objp->frequency ? ($invoicerectmp->isMaxNbGenReached()?'':'').dol_print_date($db->jdate($objp->date_when),'day').($invoicerectmp->isMaxNbGenReached()?'':'') : ''.$langs->trans('NA').'');
if (! $invoicerectmp->isMaxNbGenReached())
{
- if ($objp->frequency > 0 && $db->jdate($objp->date_when) && $db->jdate($objp->date_when) < $now) print img_warning($langs->trans("Late"));
+ if (! $objp->suspended && $objp->frequency > 0 && $db->jdate($objp->date_when) && $db->jdate($objp->date_when) < $now) print img_warning($langs->trans("Late"));
}
else
{
@@ -709,6 +709,6 @@ else
dol_print_error($db);
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php
index d5d320e6d32..3fdfbc0c514 100644
--- a/htdocs/compta/facture/list.php
+++ b/htdocs/compta/facture/list.php
@@ -88,13 +88,15 @@ $search_country=GETPOST("search_country",'int');
$search_type_thirdparty=GETPOST("search_type_thirdparty",'int');
$search_user = GETPOST('search_user','int');
$search_sale = GETPOST('search_sale','int');
-$search_day = GETPOST('search_day','int');
+$search_day = GETPOST('search_day','int');
$search_month = GETPOST('search_month','int');
$search_year = GETPOST('search_year','int');
-$search_day_lim = GETPOST('search_day_lim','int');
+$search_day_lim = GETPOST('search_day_lim','int');
$search_month_lim = GETPOST('search_month_lim','int');
$search_year_lim = GETPOST('search_year_lim','int');
$search_categ_cus=trim(GETPOST("search_categ_cus",'int'));
+$search_btn=GETPOST('button_search','alpha');
+$search_remove_btn=GETPOST('button_removefilter','alpha');
$option = GETPOST('search_option');
if ($option == 'late') {
@@ -106,7 +108,7 @@ $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');
-if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
+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
$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';
@@ -146,29 +148,29 @@ if (empty($user->socid)) $fieldstosearchall["f.note_private"]="NotePrivate";
$checkedtypetiers=0;
$arrayfields=array(
- 'f.facnumber'=>array('label'=>$langs->trans("Ref"), 'checked'=>1),
- 'f.ref_client'=>array('label'=>$langs->trans("RefCustomer"), 'checked'=>1),
- 'f.type'=>array('label'=>$langs->trans("Type"), 'checked'=>0),
- 'f.date'=>array('label'=>$langs->trans("DateInvoice"), 'checked'=>1),
- 'f.date_lim_reglement'=>array('label'=>$langs->trans("DateDue"), 'checked'=>1),
- 'p.ref'=>array('label'=>$langs->trans("ProjectRef"), 'checked'=>0, 'enabled'=>(empty($conf->projet->enabled)?0:1)),
- 's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1),
- 's.town'=>array('label'=>$langs->trans("Town"), 'checked'=>1),
- 's.zip'=>array('label'=>$langs->trans("Zip"), 'checked'=>1),
- 'state.nom'=>array('label'=>$langs->trans("StateShort"), 'checked'=>0),
- 'country.code_iso'=>array('label'=>$langs->trans("Country"), 'checked'=>0),
- 'typent.code'=>array('label'=>$langs->trans("ThirdPartyType"), 'checked'=>$checkedtypetiers),
- 'f.fk_mode_reglement'=>array('label'=>$langs->trans("PaymentMode"), 'checked'=>1),
- 'f.total_ht'=>array('label'=>$langs->trans("AmountHT"), 'checked'=>1),
- 'f.total_vat'=>array('label'=>$langs->trans("AmountVAT"), 'checked'=>0),
+ 'f.facnumber'=>array('label'=>"Ref", 'checked'=>1),
+ 'f.ref_client'=>array('label'=>"RefCustomer", 'checked'=>1),
+ 'f.type'=>array('label'=>"Type", 'checked'=>0),
+ 'f.date'=>array('label'=>"DateInvoice", 'checked'=>1),
+ 'f.date_lim_reglement'=>array('label'=>"DateDue", 'checked'=>1),
+ 'p.ref'=>array('label'=>"ProjectRef", '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),
+ 'f.fk_mode_reglement'=>array('label'=>"PaymentMode", 'checked'=>1),
+ 'f.total_ht'=>array('label'=>"AmountHT", 'checked'=>1),
+ 'f.total_vat'=>array('label'=>"AmountVAT", 'checked'=>0),
'f.total_localtax1'=>array('label'=>$langs->transcountry("AmountLT1", $mysoc->country_code), 'checked'=>0, 'enabled'=>($mysoc->localtax1_assuj=="1")),
'f.total_localtax2'=>array('label'=>$langs->transcountry("AmountLT2", $mysoc->country_code), 'checked'=>0, 'enabled'=>($mysoc->localtax2_assuj=="1")),
- 'f.total_ttc'=>array('label'=>$langs->trans("AmountTTC"), 'checked'=>0),
- 'dynamount_payed'=>array('label'=>$langs->trans("Received"), 'checked'=>0),
- 'rtp'=>array('label'=>$langs->trans("Rest"), 'checked'=>0),
- 'f.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500),
- 'f.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500),
- 'f.fk_statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000),
+ 'f.total_ttc'=>array('label'=>"AmountTTC", 'checked'=>0),
+ 'dynamount_payed'=>array('label'=>"Received", 'checked'=>0),
+ 'rtp'=>array('label'=>"Rest", 'checked'=>0),
+ 'f.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500),
+ 'f.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500),
+ 'f.fk_statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000),
);
// Extra fields
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
@@ -268,7 +270,6 @@ if ($massaction == 'withdrawrequest')
$totalcreditnotes = $objecttmp->getSumCreditNotesUsed();
$totaldeposits = $objecttmp->getSumDepositsUsed();
$objecttmp->resteapayer = price2num($objecttmp->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits,'MT');
- $listofbills[] = $objecttmp;
if($objecttmp->paye || $objecttmp->resteapayer==0){
$error++;
setEventMessages($objecttmp->ref.' '.$langs->trans("AlreadyPaid"), $objecttmp->errors, 'errors');
@@ -300,18 +301,21 @@ if ($massaction == 'withdrawrequest')
if ($numprlv>0){
$error++;
- setEventMessages($objecttmp->ref.' '.$langs->trans("RequestAlreadyDone"), $objecttmp->errors, 'errors');
+ setEventMessages($objecttmp->ref.' '.$langs->trans("RequestAlreadyDone"), $objecttmp->errors, 'warnings');
}
- if (!empty($objecttmp->mode_reglement_code ) && $objecttmp->mode_reglement_code != 'PRE'){
+ else if (!empty($objecttmp->mode_reglement_code ) && $objecttmp->mode_reglement_code != 'PRE'){
$error++;
setEventMessages($objecttmp->ref.' '.$langs->trans("BadPaymentMethod"), $objecttmp->errors, 'errors');
}
+ else {
+ $listofbills[] = $objecttmp; // $listofbills will only contains invoices with good payment method and no request already done
+ }
}
}
- //Massive withdraw request
- if(!empty($listofbills) && empty($error))
+ //Massive withdraw request for request with no errors
+ if(!empty($listofbills))
{
$nbwithdrawrequestok=0;
foreach($listofbills as $aBill)
@@ -418,22 +422,14 @@ if ($filtre)
}
if ($search_ref) $sql .= natural_search('f.facnumber', $search_ref);
if ($search_refcustomer) $sql .= natural_search('f.ref_client', $search_refcustomer);
-if ($search_type != '' && $search_type >= 0)
-{
- if ($search_type == '0') $sql.=" AND f.type = 0"; // standard
- if ($search_type == '1') $sql.=" AND f.type = 1"; // replacement
- if ($search_type == '2') $sql.=" AND f.type = 2"; // credit note
- if ($search_type == '3') $sql.=" AND f.type = 3"; // deposit
- if ($search_type == '4') $sql.=" AND f.type = 4"; // proforma
- if ($search_type == '5') $sql.=" AND f.type = 5"; // situation
-}
+if ($search_type != '') $sql.=" AND f.type IN (".$db->escape($search_type).")";
if ($search_project) $sql .= natural_search('p.ref', $search_project);
if ($search_societe) $sql .= natural_search('s.nom', $search_societe);
if ($search_town) $sql.= natural_search('s.town', $search_town);
if ($search_zip) $sql.= natural_search("s.zip",$search_zip);
if ($search_state) $sql.= natural_search("state.nom",$search_state);
-if ($search_country) $sql .= " AND s.fk_pays IN (".$search_country.')';
-if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$search_type_thirdparty.')';
+if ($search_country) $sql .= " AND s.fk_pays IN (".$db->escape($search_country).')';
+if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$db->escape($search_type_thirdparty).')';
if ($search_company) $sql .= natural_search('s.nom', $search_company);
if ($search_montant_ht != '') $sql.= natural_search('f.total', $search_montant_ht, 1);
if ($search_montant_vat != '') $sql.= natural_search('f.tva', $search_montant_vat, 1);
@@ -442,7 +438,7 @@ if ($search_montant_localtax2 != '') $sql.= natural_search('f.localtax2', $searc
if ($search_montant_ttc != '') $sql.= natural_search('f.total_ttc', $search_montant_ttc, 1);
if ($search_categ_cus > 0) $sql.= " AND cc.fk_categorie = ".$db->escape($search_categ_cus);
if ($search_categ_cus == -2) $sql.= " AND cc.fk_categorie IS NULL";
-if ($search_status != '')
+if ($search_status != '-1' && $search_status != '')
{
if (is_numeric($search_status) && $search_status >= 0)
{
@@ -507,8 +503,9 @@ if (! $sall)
$sql.= ' typent.code,';
$sql.= ' state.code_departement, state.nom,';
$sql.= ' country.code,';
- $sql.= " p.rowid, p.ref";
-
+ $sql.= " p.rowid, p.ref, p.title";
+ if ($search_categ_cus) $sql .= ", cc.fk_categorie, cc.fk_soc";
+ // Add fields from extrafields
foreach ($extrafields->attribute_label as $key => $val) //prevent error with sql_mode=only_full_group_by
{
$sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key : '');
@@ -572,14 +569,14 @@ if ($resql)
if ($search_zip) $param.='&search_zip='.urlencode($search_zip);
if ($search_sale > 0) $param.='&search_sale=' .urlencode($search_sale);
if ($search_user > 0) $param.='&search_user=' .urlencode($search_user);
- if ($search_product_category > 0) $param.='$search_product_category=' .urlencode($search_product_category);
+ if ($search_product_category > 0) $param.='&search_product_category=' .urlencode($search_product_category);
if ($search_montant_ht != '') $param.='&search_montant_ht='.urlencode($search_montant_ht);
if ($search_montant_vat != '') $param.='&search_montant_vat='.urlencode($search_montant_vat);
if ($search_montant_localtax1 != '') $param.='&search_montant_localtax1='.urlencode($search_montant_localtax1);
if ($search_montant_localtax2 != '') $param.='&search_montant_localtax2='.urlencode($search_montant_localtax2);
if ($search_montant_ttc != '') $param.='&search_montant_ttc='.urlencode($search_montant_ttc);
if ($search_status != '') $param.='&search_status='.urlencode($search_status);
- if ($search_paymentmode > 0) $param.='search_paymentmode='.urlencode($search_paymentmode);
+ if ($search_paymentmode > 0) $param.='&search_paymentmode='.urlencode($search_paymentmode);
if ($show_files) $param.='&show_files='.urlencode($show_files);
if ($option) $param.="&search_option=".urlencode($option);
if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss);
@@ -919,6 +916,9 @@ if ($resql)
$facturestatic->id=$obj->id;
$facturestatic->ref=$obj->ref;
$facturestatic->type=$obj->type;
+ $facturestatic->total_ht=$obj->total_ht;
+ $facturestatic->total_tva=$obj->total_vat;
+ $facturestatic->total_ttc=$obj->total_ttc;
$facturestatic->statut=$obj->fk_statut;
$facturestatic->date_lim_reglement=$db->jdate($obj->datelimite);
$facturestatic->note_public=$obj->note_public;
@@ -1063,11 +1063,20 @@ if ($resql)
if (! empty($arrayfields['typent.code']['checked']))
{
print '';
- if (count($typenArray)==0) $typenArray = $formcompany->typent_array(1);
+ if (! is_array($typenArray) || count($typenArray)==0) $typenArray = $formcompany->typent_array(1);
print $typenArray[$obj->typent_code];
print ' ';
if (! $i) $totalarray['nbfield']++;
}
+ // Staff
+ if (! empty($arrayfields['staff.code']['checked']))
+ {
+ print '';
+ if (! is_array($staffArray) || count($staffArray)==0) $staffArray = $formcompany->effectif_array(1);
+ print $staffArray[$obj->staff_code];
+ print ' ';
+ if (! $i) $totalarray['nbfield']++;
+ }
// Payment mode
if (! empty($arrayfields['f.fk_mode_reglement']['checked']))
@@ -1245,5 +1254,6 @@ else
dol_print_error($db);
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/compta/facture/note.php b/htdocs/compta/facture/note.php
index 58fc26030b7..c46d3ed690e 100644
--- a/htdocs/compta/facture/note.php
+++ b/htdocs/compta/facture/note.php
@@ -142,7 +142,6 @@ if ($id > 0 || ! empty($ref))
dol_fiche_end();
}
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/facture/prelevement.php b/htdocs/compta/facture/prelevement.php
index ecde973bd3b..d7766268989 100644
--- a/htdocs/compta/facture/prelevement.php
+++ b/htdocs/compta/facture/prelevement.php
@@ -696,6 +696,6 @@ if ($object->id > 0)
print '';
}
-
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/compta/facture/stats/index.php b/htdocs/compta/facture/stats/index.php
index 0416e04f7b0..04603076b07 100644
--- a/htdocs/compta/facture/stats/index.php
+++ b/htdocs/compta/facture/stats/index.php
@@ -347,7 +347,6 @@ print '';
dol_fiche_end();
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php
index 09a528b1ce7..ea43c270b5f 100644
--- a/htdocs/compta/index.php
+++ b/htdocs/compta/index.php
@@ -234,7 +234,8 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture-
$sql.= ", s.nom as name";
$sql.= ", s.rowid as socid, s.email";
$sql.= ", s.code_fournisseur, s.code_compta_fournisseur";
- $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn as f, ".MAIN_DB_PREFIX."societe as s";
+ $sql.= ", cc.rowid as country_id, cc.code as country_code";
+ $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn as f, ".MAIN_DB_PREFIX."societe as s LEFT JOIN ".MAIN_DB_PREFIX."c_country as cc ON cc.rowid = s.fk_pays";
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE s.rowid = f.fk_soc AND f.fk_statut = 0";
$sql.= " AND f.entity = ".$conf->entity;
@@ -274,6 +275,8 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture-
$companystatic->id=$obj->socid;
$companystatic->name=$obj->name;
$companystatic->email=$obj->email;
+ $companystatic->country_id=$obj->country_id;
+ $companystatic->country_code=$obj->country_code;
$companystatic->fournisseur = 1;
$companystatic->code_client = $obj->code_client;
$companystatic->code_fournisseur = $obj->code_fournisseur;
@@ -324,8 +327,9 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire)
$sql.= ", s.nom as name";
$sql.= ", s.rowid as socid";
$sql.= ", s.code_client, s.code_compta, s.email";
- $sql.= ", sum(pf.amount) as am";
- $sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f";
+ $sql.= ", cc.rowid as country_id, cc.code as country_code";
+ $sql.= ", sum(pf.amount) as am";
+ $sql.= " FROM ".MAIN_DB_PREFIX."societe as s LEFT JOIN ".MAIN_DB_PREFIX."c_country as cc ON cc.rowid = s.fk_pays, ".MAIN_DB_PREFIX."facture as f";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf on f.rowid=pf.fk_facture";
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE s.rowid = f.fk_soc";
@@ -338,7 +342,8 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire)
$sql.=$hookmanager->resPrint;
$sql.= " GROUP BY f.rowid, f.facnumber, f.fk_statut, f.type, f.total, f.tva, f.total_ttc, f.paye, f.tms, f.date_lim_reglement,";
- $sql.= " s.nom, s.rowid, s.code_client, s.code_compta, s.email";
+ $sql.= " s.nom, s.rowid, s.code_client, s.code_compta, s.email,";
+ $sql.= " cc.rowid, cc.code";
$sql.= " ORDER BY f.tms DESC ";
$sql.= $db->plimit($max, 0);
@@ -375,6 +380,9 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire)
$thirdpartystatic->id=$obj->socid;
$thirdpartystatic->name=$obj->name;
$thirdpartystatic->email=$obj->email;
+ $thirdpartystatic->country_id=$obj->country_id;
+ $thirdpartystatic->country_code=$obj->country_code;
+ $thirdpartystatic->email=$obj->email;
$thirdpartystatic->client=1;
$thirdpartystatic->code_client = $obj->code_client;
//$thirdpartystatic->code_fournisseur = $obj->code_fournisseur;
@@ -696,8 +704,9 @@ if (! empty($conf->facture->enabled) && ! empty($conf->commande->enabled) && $us
$sql.= ", s.nom as name, s.email";
$sql.= ", s.rowid as socid";
$sql.= ", s.code_client, s.code_compta";
- $sql.= ", c.rowid, c.ref, c.facture, c.fk_statut, c.total_ht, c.tva as total_tva, c.total_ttc";
- $sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
+ $sql.= ", c.rowid, c.ref, c.facture, c.fk_statut, c.total_ht, c.tva as total_tva, c.total_ttc,";
+ $sql.= " cc.rowid as country_id, cc.code as country_code";
+ $sql.= " FROM ".MAIN_DB_PREFIX."societe as s LEFT JOIN ".MAIN_DB_PREFIX."c_country as cc ON cc.rowid = s.fk_pays";
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= ", ".MAIN_DB_PREFIX."commande as c";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON el.fk_source = c.rowid AND el.sourcetype = 'commande'";
@@ -713,7 +722,7 @@ if (! empty($conf->facture->enabled) && ! empty($conf->commande->enabled) && $us
$reshook=$hookmanager->executeHooks('printFieldListWhereCustomerOrderToBill',$parameters);
$sql.=$hookmanager->resPrint;
- $sql.= " GROUP BY s.nom, s.rowid, s.email, s.code_client, s.code_compta, c.rowid, c.ref, c.facture, c.fk_statut, c.tva, c.total_ht, c.total_ttc";
+ $sql.= " GROUP BY s.nom, s.email, s.rowid, s.code_client, s.code_compta, c.rowid, c.ref, c.facture, c.fk_statut, c.total_ht, c.tva, c.total_ttc, cc.rowid, cc.code";
$resql = $db->query($sql);
if ( $resql )
@@ -741,6 +750,8 @@ if (! empty($conf->facture->enabled) && ! empty($conf->commande->enabled) && $us
$societestatic->id=$obj->socid;
$societestatic->name=$obj->name;
$societestatic->email=$obj->email;
+ $societestatic->country_id=$obj->country_id;
+ $societestatic->country_code=$obj->country_code;
$societestatic->client=1;
$societestatic->code_client = $obj->code_client;
//$societestatic->code_fournisseur = $obj->code_fournisseur;
@@ -813,8 +824,9 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire)
$sql.= ", s.nom as name";
$sql.= ", s.rowid as socid, s.email";
$sql.= ", s.code_client, s.code_compta";
- $sql.= ", sum(pf.amount) as am";
- $sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f";
+ $sql.= ", cc.rowid as country_id, cc.code as country_code";
+ $sql.= ", sum(pf.amount) as am";
+ $sql.= " FROM ".MAIN_DB_PREFIX."societe as s LEFT JOIN ".MAIN_DB_PREFIX."c_country as cc ON cc.rowid = s.fk_pays,".MAIN_DB_PREFIX."facture as f";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf on f.rowid=pf.fk_facture";
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE s.rowid = f.fk_soc AND f.paye = 0 AND f.fk_statut = 1";
@@ -827,7 +839,7 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire)
$sql.=$hookmanager->resPrint;
$sql.= " GROUP BY f.rowid, f.facnumber, f.fk_statut, f.datef, f.type, f.total, f.tva, f.total_ttc, f.paye, f.tms, f.date_lim_reglement,";
- $sql.= " s.nom, s.rowid, s.email, s.code_client, s.code_compta";
+ $sql.= " s.nom, s.rowid, s.email, s.code_client, s.code_compta, cc.rowid, cc.code";
$sql.= " ORDER BY f.datef ASC, f.facnumber ASC";
$resql = $db->query($sql);
@@ -865,6 +877,8 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire)
$societestatic->id=$obj->socid;
$societestatic->name=$obj->name;
$societestatic->email=$obj->email;
+ $societestatic->country_id=$obj->country_id;
+ $societestatic->country_code=$obj->country_code;
$societestatic->client=1;
$societestatic->code_client = $obj->code_client;
$societestatic->code_fournisseur = $obj->code_fournisseur;
diff --git a/htdocs/compta/journal/purchasesjournal.php b/htdocs/compta/journal/purchasesjournal.php
index 2bc754ccf11..2d43d48d778 100644
--- a/htdocs/compta/journal/purchasesjournal.php
+++ b/htdocs/compta/journal/purchasesjournal.php
@@ -1,10 +1,11 @@
- * Copyright (C) 2007-2010 Jean Heimburger
- * Copyright (C) 2011-2014 Juanjo Menent
- * Copyright (C) 2012 Regis Houssin
- * Copyright (C) 2011-2012 Alexandre spangaro
- * Copyright (C) 2013 Marcos García
+/* Copyright (C) 2007-2010 Laurent Destailleur
+ * Copyright (C) 2007-2010 Jean Heimburger
+ * Copyright (C) 2011-2014 Juanjo Menent
+ * Copyright (C) 2012 Regis Houssin
+ * Copyright (C) 2011-2012 Alexandre spangaro
+ * Copyright (C) 2013 Marcos García
+ * 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
@@ -80,7 +81,8 @@ $date_end=dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
if (empty($date_start) || empty($date_end)) // We define date_start and date_end
{
- $date_start=dol_get_first_day($pastmonthyear,$pastmonth,false); $date_end=dol_get_last_day($pastmonthyear,$pastmonth,false);
+ $date_start=dol_get_first_day($pastmonthyear,$pastmonth,false);
+ $date_end=dol_get_last_day($pastmonthyear,$pastmonth,false);
}
$name=$langs->trans("PurchasesJournal");
@@ -90,7 +92,7 @@ $builddate=dol_now();
$description=$langs->trans("DescPurchasesJournal").'
';
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description.= $langs->trans("DepositsAreNotIncluded");
else $description.= $langs->trans("DepositsAreIncluded");
-$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
+$period=$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
report_header($name,'',$period,$periodlink,$description,$builddate,$exportlink);
@@ -251,8 +253,6 @@ foreach ($tabfac as $key => $val)
print "";
-
// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/journal/sellsjournal.php b/htdocs/compta/journal/sellsjournal.php
index 24b36cf76c0..3b4be22a81d 100644
--- a/htdocs/compta/journal/sellsjournal.php
+++ b/htdocs/compta/journal/sellsjournal.php
@@ -1,12 +1,13 @@
- * Copyright (C) 2007-2010 Jean Heimburger
- * Copyright (C) 2011-2014 Juanjo Menent
- * Copyright (C) 2012 Regis Houssin
- * Copyright (C) 2011-2012 Alexandre Spangaro
- * Copyright (C) 2012 Cédric Salvador
- * Copyright (C) 2013 Marcos García
- * Copyright (C) 2014 Raphaël Doursenaud
+/* Copyright (C) 2007-2010 Laurent Destailleur
+ * Copyright (C) 2007-2010 Jean Heimburger
+ * Copyright (C) 2011-2014 Juanjo Menent
+ * Copyright (C) 2012 Regis Houssin
+ * Copyright (C) 2011-2012 Alexandre Spangaro
+ * Copyright (C) 2012 Cédric Salvador
+ * Copyright (C) 2013 Marcos García
+ * Copyright (C) 2014 Raphaël Doursenaud
+ * 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
@@ -93,7 +94,7 @@ $builddate=dol_now();
$description=$langs->trans("DescSellsJournal").'
';
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description.= $langs->trans("DepositsAreNotIncluded");
else $description.= $langs->trans("DepositsAreIncluded");
-$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
+$period=$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
report_header($name,'',$period,$periodlink,$description,$builddate,$exportlink);
$p = explode(":", $conf->global->MAIN_INFO_SOCIETE_COUNTRY);
@@ -282,7 +283,6 @@ foreach ($tabfac as $key => $val)
print "";
-
// End of page
llxFooter();
$db->close();
diff --git a/htdocs/compta/localtax/card.php b/htdocs/compta/localtax/card.php
index e8a84fcc9e1..222423b7c67 100644
--- a/htdocs/compta/localtax/card.php
+++ b/htdocs/compta/localtax/card.php
@@ -1,6 +1,7 @@
- * Copyright (C) 2015 Marcos García
+/* Copyright (C) 2011-2014 Juanjo Menent
+ * Copyright (C) 2015 Marcos García
+ * 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
@@ -172,11 +173,11 @@ if ($action == 'create')
print "";
print ''.$langs->trans("DatePayment").' ';
- print $form->select_date($datep,"datep",'','','','add',1,1);
+ print $form->selectDate($datep, "datep", '', '', '', 'add', 1, 1);
print ' ';
print ''.$form->textwithpicto($langs->trans("PeriodEndDate"), $langs->trans("LastDayTaxIsRelatedTo")).' ';
- print $form->select_date($datev,"datev",'','','','add',1,1);
+ print $form->selectDate($datev, "datev", '', '', '', 'add', 1, 1);
print ' ';
// Label
@@ -299,6 +300,6 @@ if ($id)
print "";
}
+// End of page
llxFooter();
$db->close();
-
diff --git a/htdocs/compta/localtax/class/localtax.class.php b/htdocs/compta/localtax/class/localtax.class.php
index a75de537724..6838f9a65b2 100644
--- a/htdocs/compta/localtax/class/localtax.class.php
+++ b/htdocs/compta/localtax/class/localtax.class.php
@@ -29,19 +29,35 @@ require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php';
*/
class Localtax extends CommonObject
{
- public $element='localtax'; //!< Id that identify managed objects
- public $table_element='localtax'; //!< Name of table without prefix where object is stored
+ /**
+ * @var string ID to identify managed object
+ */
+ public $element='localtax';
+
+ /**
+ * @var string Name of table without prefix where object is stored
+ */
+ public $table_element='localtax';
+
+ /**
+ * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
+ */
public $picto='payment';
- var $ltt;
- var $tms;
- var $datep;
- var $datev;
- var $amount;
- var $label;
- var $fk_bank;
- var $fk_user_creat;
- var $fk_user_modif;
+ public $ltt;
+ public $tms;
+ public $datep;
+ public $datev;
+ public $amount;
+
+ /**
+ * @var string local tax
+ */
+ public $label;
+
+ public $fk_bank;
+ public $fk_user_creat;
+ public $fk_user_modif;
/**
* Constructor
@@ -331,6 +347,7 @@ class Localtax extends CommonObject
return $solde;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Total de la localtax des factures emises par la societe.
*
@@ -339,6 +356,7 @@ class Localtax extends CommonObject
*/
function localtax_sum_collectee($year = 0)
{
+ // phpcs:enable
$sql = "SELECT sum(f.localtax) as amount";
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f WHERE f.paye = 1";
if ($year)
@@ -369,6 +387,7 @@ class Localtax extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* localtax payed
*
@@ -377,6 +396,7 @@ class Localtax extends CommonObject
*/
function localtax_sum_payee($year = 0)
{
+ // phpcs:enable
$sql = "SELECT sum(f.total_localtax) as total_localtax";
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f";
@@ -409,6 +429,7 @@ class Localtax extends CommonObject
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* localtax payed
* Total de la localtax payed
@@ -418,6 +439,7 @@ class Localtax extends CommonObject
*/
function localtax_sum_reglee($year = 0)
{
+ // phpcs:enable
$sql = "SELECT sum(f.amount) as amount";
$sql .= " FROM ".MAIN_DB_PREFIX."localtax as f";
@@ -563,6 +585,7 @@ class Localtax extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Update the link betwen localtax payment and the line into llx_bank
*
@@ -571,6 +594,7 @@ class Localtax extends CommonObject
*/
function update_fk_bank($id)
{
+ // phpcs:enable
$sql = 'UPDATE '.MAIN_DB_PREFIX.'localtax SET fk_bank = '.$id;
$sql.= ' WHERE rowid = '.$this->id;
$result = $this->db->query($sql);
@@ -622,18 +646,19 @@ class Localtax extends CommonObject
return $this->LibStatut($this->statut,$mode);
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Renvoi le libelle d'un statut donne
*
* @param int $status Statut
* @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
- * @return string Libelle du statut
+ * @return string Libelle du statut
*/
- function LibStatut($status,$mode=0)
- {
- global $langs; // TODO Renvoyer le libelle anglais et faire traduction a affichage
-
- return '';
- }
+ function LibStatut($status, $mode=0)
+ {
+ // phpcs:enable
+ global $langs; // TODO Renvoyer le libelle anglais et faire traduction a affichage
+ return '';
+ }
}
diff --git a/htdocs/compta/localtax/clients.php b/htdocs/compta/localtax/clients.php
index 9502ff46d2d..8f986697a01 100644
--- a/htdocs/compta/localtax/clients.php
+++ b/htdocs/compta/localtax/clients.php
@@ -1,6 +1,7 @@
- * Copyright (C) 2014 Ferran Marcet
+/* Copyright (C) 2011-2014 Juanjo Menent
+ * Copyright (C) 2014 Ferran Marcet
+ * 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
@@ -117,7 +118,7 @@ if ($calc==0 || $calc==1) // Calculate on invoice for goods and services
{
$calcmode=$calc==0?$langs->trans("CalcModeLT".$local):$langs->trans("CalcModeLT".$local."Rec");
$calcmode.='
('.$langs->trans("TaxModuleSetupToModifyRulesLT",DOL_URL_ROOT.'/admin/company.php').')';
- $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
+ $period=$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
if (! empty($conf->global->MAIN_MODULE_COMPTABILITE)) $description.='
'.$langs->trans("WarningDepositsNotIncluded");
$description.=$fsearch;
$description.='
('.$langs->trans("TaxModuleSetupToModifyRulesLT",DOL_URL_ROOT.'/admin/company.php').')';
@@ -134,7 +135,7 @@ if ($calc==2) // Invoice for goods, payment for services
{
$calcmode=$langs->trans("CalcModeLT2Debt");
$calcmode.='
('.$langs->trans("TaxModuleSetupToModifyRulesLT",DOL_URL_ROOT.'/admin/company.php').')';
- $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
+ $period=$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
if (! empty($conf->global->MAIN_MODULE_COMPTABILITE)) $description.='
'.$langs->trans("WarningDepositsNotIncluded");
$description.=$fsearch;
$description.='
('.$langs->trans("TaxModuleSetupToModifyRulesLT",DOL_URL_ROOT.'/admin/company.php').')';
@@ -325,5 +326,6 @@ if($calc ==0){
}
print '';
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/compta/localtax/index.php b/htdocs/compta/localtax/index.php
index c62034ee65c..1e2c26c0c62 100644
--- a/htdocs/compta/localtax/index.php
+++ b/htdocs/compta/localtax/index.php
@@ -1,7 +1,8 @@
- * Copyright (C) 2014 Ferran Marcet
- * Copyright (C) 2018 Laurent Destailleur
+/* Copyright (C) 2011-2014 Juanjo Menent
+ * Copyright (C) 2014 Ferran Marcet
+ * Copyright (C) 2018 Laurent Destailleur
+ * 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
@@ -223,7 +224,7 @@ $calcmode.= '('.$langs->trans("TaxModuleSetupToModifyRulesLT",DOL_URL_ROOT.'/adm
//if (! empty($conf->global->MAIN_MODULE_ACCOUNTING)) $description.='
'.$langs->trans("ThisIsAnEstimatedValue");
-$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
+$period=$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
$builddate=dol_now();
@@ -587,5 +588,6 @@ pt($db, $sql, $langs->trans("Month"));
print '';
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/compta/localtax/list.php b/htdocs/compta/localtax/list.php
index 0e32a249f17..37ead35433c 100644
--- a/htdocs/compta/localtax/list.php
+++ b/htdocs/compta/localtax/list.php
@@ -103,5 +103,6 @@ else
dol_print_error($db);
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/compta/localtax/quadri_detail.php b/htdocs/compta/localtax/quadri_detail.php
index 31729693f37..e49f42bb14f 100644
--- a/htdocs/compta/localtax/quadri_detail.php
+++ b/htdocs/compta/localtax/quadri_detail.php
@@ -4,6 +4,7 @@
* Copyright (C) 2004-2013 Laurent Destailleur
* Copyright (C) 2006-2007 Yannick Warnier
* Copyright (C) 2014-2016 Juanjo Menent
+ * 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
@@ -132,18 +133,22 @@ if ($modetax == 1) $calcmode=$langs->trans('OptionVATDebitOption');
if ($modetax == 2) $calcmode=$langs->trans('OptionPaymentForProductAndServices');
$calcmode.='
('.$langs->trans("TaxModuleSetupToModifyRules",DOL_URL_ROOT.'/admin/taxes.php').')';
// Set period
-$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
-$prevyear=$year_start; $prevquarter=$q;
+$period=$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
+$prevyear=$year_start;
+$prevquarter=$q;
if ($prevquarter > 1) {
$prevquarter--;
} else {
- $prevquarter=4; $prevyear--;
+ $prevquarter=4;
+ $prevyear--;
}
-$nextyear=$year_start; $nextquarter=$q;
+$nextyear=$year_start;
+$nextquarter=$q;
if ($nextquarter < 4) {
$nextquarter++;
} else {
- $nextquarter=1; $nextyear++;
+ $nextquarter=1;
+ $nextyear++;
}
$description.=$fsearch;
$builddate=dol_now();
@@ -209,7 +214,7 @@ if (! is_array($x_coll) || ! is_array($x_paye))
$langs->load("errors");
if ($x_coll == -1)
print ''.$langs->trans("ErrorNoAccountancyModuleLoaded").' ';
- else if ($x_coll == -2)
+ elseif ($x_coll == -2)
print ''.$langs->trans("FeatureNotYetAvailable").' ';
else
print ''.$langs->trans("Error").' ';
@@ -640,5 +645,6 @@ else
}
print '';
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php
index c2ce95dd827..764ca818f7f 100644
--- a/htdocs/compta/paiement.php
+++ b/htdocs/compta/paiement.php
@@ -1,13 +1,14 @@
- * Copyright (C) 2004-2017 Laurent Destailleur
- * Copyright (C) 2005 Marc Barilley / Ocebo
- * Copyright (C) 2005-2012 Regis Houssin
- * Copyright (C) 2007 Franky Van Liedekerke
- * Copyright (C) 2012 Cédric Salvador
- * Copyright (C) 2014 Raphaël Doursenaud
- * Copyright (C) 2014 Teddy Andreotti <125155@supinfo.com>
- * Copyright (C) 2015 Juanjo Menent
+/* Copyright (C) 2001-2006 Rodolphe Quiedeville
+ * Copyright (C) 2004-2017 Laurent Destailleur
+ * Copyright (C) 2005 Marc Barilley / Ocebo
+ * Copyright (C) 2005-2012 Regis Houssin
+ * Copyright (C) 2007 Franky Van Liedekerke
+ * Copyright (C) 2012 Cédric Salvador
+ * Copyright (C) 2014 Raphaël Doursenaud
+ * Copyright (C) 2014 Teddy Andreotti <125155@supinfo.com>
+ * Copyright (C) 2015 Juanjo Menent
+ * 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
@@ -467,7 +468,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
print ''.$langs->trans('Date').' ';
$datepayment = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']);
$datepayment= ($datepayment == '' ? (empty($conf->global->MAIN_AUTOFILL_DATE)?-1:'') : $datepayment);
- $form->select_date($datepayment,'','','',0,"add_paiement",1,1,0,0,'','',$facture->date);
+ print $form->selectDate($datepayment, '', '', '', 0, "add_paiement", 1, 1, 0, '', '', $facture->date);
print ' ';
// Payment mode
diff --git a/htdocs/compta/paiement/card.php b/htdocs/compta/paiement/card.php
index 656d6c673f2..31c557373d0 100644
--- a/htdocs/compta/paiement/card.php
+++ b/htdocs/compta/paiement/card.php
@@ -450,6 +450,6 @@ if ($user->societe_id == 0 && $action == '')
print '';
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/paiement/cheque/card.php b/htdocs/compta/paiement/cheque/card.php
index 69f3bd102df..1f7b344f62d 100644
--- a/htdocs/compta/paiement/cheque/card.php
+++ b/htdocs/compta/paiement/cheque/card.php
@@ -5,6 +5,7 @@
* Copyright (C) 2011-2016 Juanjo Menent
* Copyright (C) 2013 Philippe Grand
* Copyright (C) 2015-2016 Alexandre Spangaro
+ * 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
@@ -273,7 +274,7 @@ else if ($action == 'remove_file' && $user->rights->banque->cheque)
{
if ($object->fetch($id) > 0)
{
- require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
+ include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
$langs->load("other");
@@ -386,7 +387,7 @@ if ($action == 'new')
//print ''.$langs->trans('Date').' '.dol_print_date($now,'day').' ';
// Filter
print ''.$langs->trans("DateChequeReceived").' ';
- print $form->select_date($filterdate,'fd',0,0,1,'',1,1,1);
+ print $form->selectDate($filterdate, 'fd', 0, 0, 1, '', 1, 1);
print ' ';
print ''.$langs->trans("BankAccount").' ';
$form->select_comptes($filteraccountid,'accountid',0,'courant <> 2',1);
@@ -586,7 +587,7 @@ else
print 'id.'" method="post">';
print '';
print '';
- $form->select_date($object->date_bordereau,'datecreate_','','','',"setdate");
+ print $form->selectDate($object->date_bordereau, 'datecreate_', '', '', '', "setdate");
print '';
print ' ';
}
@@ -806,8 +807,6 @@ if ($action != 'new')
}
}
-
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/paiement/cheque/class/remisecheque.class.php b/htdocs/compta/paiement/cheque/class/remisecheque.class.php
index 528b01477a6..ade6895ac41 100644
--- a/htdocs/compta/paiement/cheque/class/remisecheque.class.php
+++ b/htdocs/compta/paiement/cheque/class/remisecheque.class.php
@@ -33,14 +33,25 @@ require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
*/
class RemiseCheque extends CommonObject
{
+ /**
+ * @var string ID to identify managed object
+ */
public $element='chequereceipt';
+
+ /**
+ * @var string Name of table without prefix where object is stored
+ */
public $table_element='bordereau_cheque';
+
+ /**
+ * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
+ */
public $picto = 'payment';
- var $num;
- var $intitule;
+ public $num;
+ public $intitule;
//! Numero d'erreur Plage 1024-1279
- var $errno;
+ public $errno;
public $amount;
public $date_bordereau;
@@ -48,6 +59,10 @@ class RemiseCheque extends CommonObject
public $account_label;
public $author_id;
public $nbcheque;
+
+ /**
+ * @var string Ref
+ */
public $ref;
/**
@@ -480,6 +495,7 @@ class RemiseCheque extends CommonObject
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Load indicators for dashboard (this->nbtodo and this->nbtodolate)
*
@@ -488,6 +504,7 @@ class RemiseCheque extends CommonObject
*/
function load_board($user)
{
+ // phpcs:enable
global $conf, $langs;
if ($user->societe_id) return -1; // protection pour eviter appel par utilisateur externe
@@ -533,6 +550,7 @@ class RemiseCheque extends CommonObject
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Charge indicateurs this->nb de tableau de bord
*
@@ -540,6 +558,7 @@ class RemiseCheque extends CommonObject
*/
function load_state_board()
{
+ // phpcs:enable
global $user;
if ($user->societe_id) return -1; // protection pour eviter appel par utilisateur externe
@@ -593,8 +612,8 @@ class RemiseCheque extends CommonObject
$file = "pdf_".$model.".class.php";
if (file_exists($dir.$file))
{
- require_once DOL_DOCUMENT_ROOT .'/compta/bank/class/account.class.php';
- require_once $dir.$file;
+ include_once DOL_DOCUMENT_ROOT .'/compta/bank/class/account.class.php';
+ include_once $dir.$file;
$classname='BordereauCheque'.ucfirst($model);
$docmodel = new $classname($this->db);
@@ -847,13 +866,15 @@ class RemiseCheque extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Charge les proprietes ref_previous et ref_next
*
- * @return int <0 if KO, 0 if OK
+ * @return int <0 if KO, 0 if OK
*/
function load_previous_next_id()
{
+ // phpcs:enable
global $conf;
$this->errno = 0;
@@ -888,6 +909,7 @@ class RemiseCheque extends CommonObject
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Set the creation date
*
@@ -897,6 +919,7 @@ class RemiseCheque extends CommonObject
*/
function set_date($user, $date)
{
+ // phpcs:enable
if ($user->rights->banque->cheque)
{
$sql = "UPDATE ".MAIN_DB_PREFIX."bordereau_cheque";
@@ -922,6 +945,7 @@ class RemiseCheque extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Set the ref of bordereau
*
@@ -931,6 +955,7 @@ class RemiseCheque extends CommonObject
*/
function set_number($user, $ref)
{
+ // phpcs:enable
if ($user->rights->banque->cheque)
{
$sql = "UPDATE ".MAIN_DB_PREFIX."bordereau_cheque";
@@ -1044,6 +1069,7 @@ class RemiseCheque extends CommonObject
return $this->LibStatut($this->statut,$mode);
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Return label of a status
*
@@ -1053,6 +1079,7 @@ class RemiseCheque extends CommonObject
*/
function LibStatut($status,$mode=0)
{
+ // phpcs:enable
global $langs; // TODO Renvoyer le libelle anglais et faire traduction a affichage
$langs->load('compta');
if ($mode == 0)
@@ -1060,37 +1087,36 @@ class RemiseCheque extends CommonObject
if ($status == 0) return $langs->trans('ToValidate');
if ($status == 1) return $langs->trans('Validated');
}
- if ($mode == 1)
+ elseif ($mode == 1)
{
if ($status == 0) return $langs->trans('ToValidate');
if ($status == 1) return $langs->trans('Validated');
}
- if ($mode == 2)
+ elseif ($mode == 2)
{
if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut0').' '.$langs->trans('ToValidate');
if ($status == 1) return img_picto($langs->trans('Validated'),'statut4').' '.$langs->trans('Validated');
}
- if ($mode == 3)
+ elseif ($mode == 3)
{
if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut0');
if ($status == 1) return img_picto($langs->trans('Validated'),'statut4');
}
- if ($mode == 4)
+ elseif ($mode == 4)
{
if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut0').' '.$langs->trans('ToValidate');
if ($status == 1) return img_picto($langs->trans('Validated'),'statut4').' '.$langs->trans('Validated');
}
- if ($mode == 5)
+ elseif ($mode == 5)
{
if ($status == 0) return $langs->trans('ToValidate').' '.img_picto($langs->trans('ToValidate'),'statut0');
if ($status == 1) return $langs->trans('Validated').' '.img_picto($langs->trans('Validated'),'statut4');
}
- if ($mode == 6)
+ elseif ($mode == 6)
{
if ($status == 0) return $langs->trans('ToValidate').' '.img_picto($langs->trans('ToValidate'),'statut0');
if ($status == 1) return $langs->trans('Validated').' '.img_picto($langs->trans('Validated'),'statut4');
}
return $langs->trans('Unknown');
}
-
}
diff --git a/htdocs/compta/paiement/cheque/index.php b/htdocs/compta/paiement/cheque/index.php
index 527bd05e3a1..ecb035caeb8 100644
--- a/htdocs/compta/paiement/cheque/index.php
+++ b/htdocs/compta/paiement/cheque/index.php
@@ -24,7 +24,7 @@
* \brief Home page for cheque receipts
*/
-require('../../../main.inc.php');
+require '../../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/compta/paiement/cheque/class/remisecheque.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
@@ -151,6 +151,6 @@ else
print '';
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/paiement/cheque/list.php b/htdocs/compta/paiement/cheque/list.php
index 800f40b9694..2f0c6592694 100644
--- a/htdocs/compta/paiement/cheque/list.php
+++ b/htdocs/compta/paiement/cheque/list.php
@@ -25,7 +25,7 @@
* \brief Page list of cheque deposits
*/
-require('../../../main.inc.php');
+require '../../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/compta/paiement/cheque/class/remisecheque.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
@@ -250,6 +250,6 @@ else
dol_print_error($db);
}
-
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/compta/paiement/class/cpaiement.class.php b/htdocs/compta/paiement/class/cpaiement.class.php
index 59f13023b24..c9794d9662e 100644
--- a/htdocs/compta/paiement/class/cpaiement.class.php
+++ b/htdocs/compta/paiement/class/cpaiement.class.php
@@ -34,15 +34,12 @@ class Cpaiement
* @var string Id to identify managed objects
*/
public $element = 'cpaiement';
+
/**
* @var string Name of table without prefix where object is stored
*/
public $table_element = 'c_paiement';
-
- /**
- */
-
public $code;
public $libelle;
public $type;
@@ -50,9 +47,6 @@ class Cpaiement
public $accountancy_code;
public $module;
- /**
- */
-
/**
* Constructor
@@ -375,8 +369,5 @@ class Cpaiement
$this->active = '';
$this->accountancy_code = '';
$this->module = '';
-
-
}
-
}
diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php
index 539c70f591b..952f478087b 100644
--- a/htdocs/compta/paiement/class/paiement.class.php
+++ b/htdocs/compta/paiement/class/paiement.class.php
@@ -36,36 +36,50 @@ require_once DOL_DOCUMENT_ROOT .'/multicurrency/class/multicurrency.class.php';
*/
class Paiement extends CommonObject
{
- public $element='payment';
- public $table_element='paiement';
- public $picto = 'payment';
+ /**
+ * @var string ID to identify managed object
+ */
+ public $element='payment';
+
+ /**
+ * @var string Name of table without prefix where object is stored
+ */
+ public $table_element='paiement';
+
+ /**
+ * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
+ */
+ public $picto = 'payment';
+
+ public $facid;
+ public $datepaye;
- var $facid;
- var $datepaye;
/**
* @deprecated
* @see amount, amounts
*/
- var $total;
+ public $total;
+
/**
* @deprecated
* @see amount, amounts
*/
- var $montant;
- var $amount; // Total amount of payment
- var $amounts=array(); // Array of amounts
- var $multicurrency_amounts=array(); // Array of amounts
- var $author;
- var $paiementid; // Type de paiement. Stocke dans fk_paiement
+ public $montant;
+
+ public $amount; // Total amount of payment
+ public $amounts=array(); // Array of amounts
+ public $multicurrency_amounts=array(); // Array of amounts
+ public $author;
+ public $paiementid; // Type de paiement. Stocke dans fk_paiement
// de llx_paiement qui est lie aux types de
//paiement de llx_c_paiement
- var $num_paiement; // Numero du CHQ, VIR, etc...
- var $num_payment; // Numero du CHQ, VIR, etc...
- var $bank_account; // Id compte bancaire du paiement
- var $bank_line; // Id de la ligne d'ecriture bancaire
+ public $num_paiement; // Numero du CHQ, VIR, etc...
+ public $num_payment; // Numero du CHQ, VIR, etc...
+ public $bank_account; // Id compte bancaire du paiement
+ public $bank_line; // Id de la ligne d'ecriture bancaire
// fk_paiement dans llx_paiement est l'id du type de paiement (7 pour CHQ, ...)
// fk_paiement dans llx_paiement_facture est le rowid du paiement
- var $fk_paiement; // Type of paiment
+ public $fk_paiement; // Type of paiment
/**
@@ -545,7 +559,7 @@ class Paiement extends CommonObject
$this->fk_account=$accountid;
- require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
+ include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
dol_syslog("$user->id,$mode,$label,$this->fk_account,$emetteur_nom,$emetteur_banque");
@@ -694,6 +708,7 @@ class Paiement extends CommonObject
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Mise a jour du lien entre le paiement et la ligne generee dans llx_bank
*
@@ -702,6 +717,7 @@ class Paiement extends CommonObject
*/
function update_fk_bank($id_bank)
{
+ // phpcs:enable
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element.' set fk_bank = '.$id_bank;
$sql.= ' WHERE rowid = '.$this->id;
@@ -719,6 +735,7 @@ class Paiement extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Updates the payment date
*
@@ -727,6 +744,7 @@ class Paiement extends CommonObject
*/
function update_date($date)
{
+ // phpcs:enable
if (!empty($date) && $this->statut!=1)
{
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
@@ -750,6 +768,7 @@ class Paiement extends CommonObject
return -1; //no date given or already validated
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Updates the payment number
*
@@ -758,6 +777,7 @@ class Paiement extends CommonObject
*/
function update_num($num)
{
+ // phpcs:enable
if(!empty($num) && $this->statut!=1)
{
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
@@ -1064,7 +1084,7 @@ class Paiement extends CommonObject
$arraybill = $this->getBillsArray();
if (is_array($arraybill) && count($arraybill) > 0)
{
- require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
+ include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
$facturestatic=new Facture($this->db);
foreach ($arraybill as $billid)
{
@@ -1112,6 +1132,7 @@ class Paiement extends CommonObject
return $this->LibStatut($this->statut,$mode);
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Renvoi le libelle d'un statut donne
*
@@ -1121,6 +1142,7 @@ class Paiement extends CommonObject
*/
function LibStatut($status,$mode=0)
{
+ // phpcs:enable
global $langs; // TODO Renvoyer le libelle anglais et faire traduction a affichage
$langs->load('compta');
@@ -1162,15 +1184,17 @@ class Paiement extends CommonObject
return '';
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
- * Load the third party of object, from id into this->thirdparty
+ * Load the third party of object, from id into this->thirdparty
*
- * @param int $force_thirdparty_id Force thirdparty id
- * @return int <0 if KO, >0 if OK
+ * @param int $force_thirdparty_id Force thirdparty id
+ * @return int <0 if KO, >0 if OK
*/
function fetch_thirdparty($force_thirdparty_id=0)
{
- require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';
+ // phpcs:enable
+ include_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';
if (empty($force_thirdparty_id))
{
diff --git a/htdocs/compta/paiement/index.php b/htdocs/compta/paiement/index.php
index 7f1597b5afc..5bcda011615 100644
--- a/htdocs/compta/paiement/index.php
+++ b/htdocs/compta/paiement/index.php
@@ -31,5 +31,6 @@ llxHeader();
print load_fiche_titre("Payments");
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/compta/paiement/info.php b/htdocs/compta/paiement/info.php
index 9f55761dba0..86e45508b2c 100644
--- a/htdocs/compta/paiement/info.php
+++ b/htdocs/compta/paiement/info.php
@@ -76,5 +76,6 @@ print '';
dol_fiche_end();
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/compta/paiement/list.php b/htdocs/compta/paiement/list.php
index 064ca877c3f..5b5124b2b80 100644
--- a/htdocs/compta/paiement/list.php
+++ b/htdocs/compta/paiement/list.php
@@ -371,5 +371,6 @@ else
dol_print_error($db);
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/compta/paiement/rapport.php b/htdocs/compta/paiement/rapport.php
index 3e6427f6ac2..c2c63aea84d 100644
--- a/htdocs/compta/paiement/rapport.php
+++ b/htdocs/compta/paiement/rapport.php
@@ -166,6 +166,6 @@ if ($year)
}
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/paiement/tovalidate.php b/htdocs/compta/paiement/tovalidate.php
index e60f65f924e..9fea9afa5df 100644
--- a/htdocs/compta/paiement/tovalidate.php
+++ b/htdocs/compta/paiement/tovalidate.php
@@ -139,5 +139,6 @@ if ($resql)
print "";
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/compta/paiement_charge.php b/htdocs/compta/paiement_charge.php
index fba8723d818..9b605e68929 100644
--- a/htdocs/compta/paiement_charge.php
+++ b/htdocs/compta/paiement_charge.php
@@ -1,6 +1,6 @@
- * Copyright (C) 2016 Frédéric France
+/* Copyright (C) 2004-2014 Laurent Destailleur
+ * Copyright (C) 2016-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
@@ -17,9 +17,9 @@
*/
/**
- * \file htdocs/compta/paiement_charge.php
- * \ingroup tax
- * \brief Page to add payment of a tax
+ * \file htdocs/compta/paiement_charge.php
+ * \ingroup tax
+ * \brief Page to add payment of a tax
*/
require '../main.inc.php';
@@ -226,7 +226,7 @@ if ($action == 'create')
print ''.$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;
- $form->select_date($datepayment,'','','','',"add_payment",1,1);
+ print $form->selectDate($datepayment, '', '', '', '', "add_payment", 1, 1);
print " ";
print ' ';
diff --git a/htdocs/compta/payment_sc/card.php b/htdocs/compta/payment_sc/card.php
index b395016aeed..b22d4d21e43 100644
--- a/htdocs/compta/payment_sc/card.php
+++ b/htdocs/compta/payment_sc/card.php
@@ -323,8 +323,6 @@ if ($action == '')
print '';
-
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/prelevement/bons.php b/htdocs/compta/prelevement/bons.php
index 0cbaa9ce55e..a6d1f480a06 100644
--- a/htdocs/compta/prelevement/bons.php
+++ b/htdocs/compta/prelevement/bons.php
@@ -24,7 +24,7 @@
* \brief Page liste des bons de prelevements
*/
-require('../../main.inc.php');
+require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
@@ -183,7 +183,6 @@ else
dol_print_error($db);
}
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/prelevement/card.php b/htdocs/compta/prelevement/card.php
index 343a45472b6..60e471d712d 100644
--- a/htdocs/compta/prelevement/card.php
+++ b/htdocs/compta/prelevement/card.php
@@ -1,7 +1,8 @@
- * Copyright (C) 2005-2010 Laurent Destailleur
- * Copyright (C) 2010-2016 Juanjo Menent
+/* Copyright (C) 2005 Rodolphe Quiedeville
+ * Copyright (C) 2005-2010 Laurent Destailleur
+ * Copyright (C) 2010-2016 Juanjo Menent
+ * 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
@@ -23,22 +24,18 @@
* \brief Card of a direct debit
*/
-require('../../main.inc.php');
+require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/prelevement.lib.php';
require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/ligneprelevement.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
// Load translation files required by the page
-$langs->loadLangs(array('banks', 'categories'));
+$langs->loadLangs(array('banks', 'categories','bills','withdrawals'));
if (!$user->rights->prelevement->bons->lire)
accessforbidden();
-$langs->load("bills");
-$langs->load("withdrawals");
-
-
// Security check
if ($user->societe_id > 0) accessforbidden();
@@ -244,7 +241,7 @@ if ($id > 0 || $ref)
print '';
print ''.$langs->trans("NotifyTransmision").' ';
print ''.$langs->trans("TransData").' ';
- print $form->select_date('','','','','',"userfile",1,1);
+ print $form->selectDate('', '', '', '', '', "userfile", 1, 1);
print ' ';
print ''.$langs->trans("TransMetod").' ';
print $form->selectarray("methode",$object->methodes_trans);
@@ -268,7 +265,7 @@ if ($id > 0 || $ref)
print ' ';
print ''.$langs->trans("NotifyCredit").' ';
print ''.$langs->trans('CreditDate').' ';
- print $form->select_date('','','','','',"infocredit",1,1);
+ print $form->selectDate('', '', '', '', '', "infocredit", 1, 1);
print ' ';
print '';
print '
'.$langs->trans("ThisWillAlsoAddPaymentOnInvoice");
@@ -419,6 +416,6 @@ if ($id > 0 || $ref)
}
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php
index a6b0ec84317..7b93966aa8b 100644
--- a/htdocs/compta/prelevement/class/bonprelevement.class.php
+++ b/htdocs/compta/prelevement/class/bonprelevement.class.php
@@ -39,29 +39,40 @@ require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
*/
class BonPrelevement extends CommonObject
{
+ /**
+ * @var string ID to identify managed object
+ */
public $element='widthdraw';
+
+ /**
+ * @var string Name of table without prefix where object is stored
+ */
public $table_element='prelevement_bons';
- public $picto = 'payment';
- var $date_echeance;
- var $raison_sociale;
- var $reference_remise;
- var $emetteur_code_guichet;
- var $emetteur_numero_compte;
- var $emetteur_code_banque;
- var $emetteur_number_key;
+ /**
+ * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
+ */
+ public $picto = 'payment';
- var $emetteur_iban;
- var $emetteur_bic;
- var $emetteur_ics;
+ public $date_echeance;
+ public $raison_sociale;
+ public $reference_remise;
+ public $emetteur_code_guichet;
+ public $emetteur_numero_compte;
+ public $emetteur_code_banque;
+ public $emetteur_number_key;
- var $total;
- var $_fetched;
- var $statut; // 0-Wait, 1-Trans, 2-Done
- var $labelstatut=array();
+ public $emetteur_iban;
+ public $emetteur_bic;
+ public $emetteur_ics;
- var $invoice_in_error=array();
- var $thirdparty_in_error=array();
+ public $total;
+ public $fetched;
+ public $statut; // 0-Wait, 1-Trans, 2-Done
+ public $labelstatut=array();
+
+ public $invoice_in_error=array();
+ public $thirdparty_in_error=array();
/**
@@ -98,9 +109,10 @@ class BonPrelevement extends CommonObject
$this->methodes_trans[0] = "Internet";
- $this->_fetched = 0;
+ $this->fetched = 0;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Add invoice to withdrawal
*
@@ -116,6 +128,7 @@ class BonPrelevement extends CommonObject
*/
function AddFacture($facture_id, $client_id, $client_nom, $amount, $code_banque, $code_guichet, $number, $number_key)
{
+ // phpcs:enable
$result = 0;
$line_id = 0;
@@ -156,7 +169,6 @@ class BonPrelevement extends CommonObject
}
return $result;
-
}
/**
@@ -304,7 +316,7 @@ class BonPrelevement extends CommonObject
$this->statut = $obj->statut;
- $this->_fetched = 1;
+ $this->fetched = 1;
return 1;
}
@@ -320,6 +332,7 @@ class BonPrelevement extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Set credite and set status of linked invoices. Still used ??
*
@@ -327,6 +340,7 @@ class BonPrelevement extends CommonObject
*/
function set_credite()
{
+ // phpcs:enable
global $user,$conf;
$error = 0;
@@ -397,6 +411,7 @@ class BonPrelevement extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Set direct debit order to "credited" status.
*
@@ -406,11 +421,12 @@ class BonPrelevement extends CommonObject
*/
function set_infocredit($user, $date)
{
+ // phpcs:enable
global $conf,$langs;
$error = 0;
- if ($this->_fetched == 1)
+ if ($this->fetched == 1)
{
if ($date >= $this->date_trans)
{
@@ -543,6 +559,7 @@ class BonPrelevement extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Set withdrawal to transmited status
*
@@ -553,6 +570,7 @@ class BonPrelevement extends CommonObject
*/
function set_infotrans($user, $date, $method)
{
+ // phpcs:enable
global $conf,$langs;
$error = 0;
@@ -667,6 +685,7 @@ class BonPrelevement extends CommonObject
return $arr;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Returns amount of withdrawal
*
@@ -674,6 +693,7 @@ class BonPrelevement extends CommonObject
*/
function SommeAPrelever()
{
+ // phpcs:enable
global $conf;
$sql = "SELECT sum(pfd.amount) as nb";
@@ -704,6 +724,7 @@ class BonPrelevement extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Get number of invoices to withdrawal
* TODO delete params banque and agence when not necesary
@@ -714,6 +735,7 @@ class BonPrelevement extends CommonObject
*/
function NbFactureAPrelever($banque=0,$agence=0)
{
+ // phpcs:enable
global $conf;
$sql = "SELECT count(f.rowid) as nb";
@@ -745,6 +767,7 @@ class BonPrelevement extends CommonObject
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Create a withdraw
* TODO delete params banque and agence when not necesary
@@ -758,20 +781,21 @@ class BonPrelevement extends CommonObject
*/
function Create($banque=0, $agence=0, $mode='real', $format='ALL',$executiondate='')
{
+ // phpcs:enable
global $conf,$langs;
dol_syslog(__METHOD__."::Bank=".$banque." Office=".$agence." mode=".$mode." format=".$format, LOG_DEBUG);
- require_once (DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php");
- require_once (DOL_DOCUMENT_ROOT."/societe/class/societe.class.php");
+ require_once DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php";
+ require_once DOL_DOCUMENT_ROOT."/societe/class/societe.class.php";
if (empty($format)) return 'ErrorBadParametersForDirectDebitFileCreate';
$error = 0;
$datetimeprev = time();
- //Choice the date of the execution direct debit
- if(!empty($executiondate)) $datetimeprev = $executiondate;
+ //Choice the date of the execution direct debit
+ if(!empty($executiondate)) $datetimeprev = $executiondate;
$month = strftime("%m", $datetimeprev);
$year = strftime("%Y", $datetimeprev);
@@ -1180,6 +1204,7 @@ class BonPrelevement extends CommonObject
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Delete a notification def by id
*
@@ -1188,6 +1213,7 @@ class BonPrelevement extends CommonObject
*/
function DeleteNotificationById($rowid)
{
+ // phpcs:enable
$result = 0;
$sql = "DELETE FROM ".MAIN_DB_PREFIX."notify_def";
@@ -1203,6 +1229,7 @@ class BonPrelevement extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Delete a notification
*
@@ -1212,6 +1239,7 @@ class BonPrelevement extends CommonObject
*/
function DeleteNotification($user, $action)
{
+ // phpcs:enable
$result = 0;
$sql = "DELETE FROM ".MAIN_DB_PREFIX."notify_def";
@@ -1227,6 +1255,7 @@ class BonPrelevement extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Add a notification
*
@@ -1237,6 +1266,7 @@ class BonPrelevement extends CommonObject
*/
function AddNotification($db, $user, $action)
{
+ // phpcs:enable
$result = 0;
if ($this->DeleteNotification($user, $action) == 0)
@@ -1449,10 +1479,10 @@ class BonPrelevement extends CommonObject
if (! empty($conf->global->MAIN_UMASK))
@chmod($this->file, octdec($conf->global->MAIN_UMASK));
return $result;
-
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Write recipient of request (customer)
*
@@ -1469,6 +1499,7 @@ class BonPrelevement extends CommonObject
*/
function EnregDestinataire($rowid, $client_nom, $rib_banque, $rib_guichet, $rib_number, $amount, $facnumber, $facid, $rib_dom='')
{
+ // phpcs:enable
fputs($this->file, "06");
fputs($this->file, "08"); // Prelevement ordinaire
@@ -1539,6 +1570,7 @@ class BonPrelevement extends CommonObject
return $pre.$row_code_client.'-'.$row_drum.'-'.date('U', $row_datec);
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Write recipient of request (customer)
*
@@ -1562,6 +1594,7 @@ class BonPrelevement extends CommonObject
*/
function EnregDestinataireSEPA($row_code_client, $row_nom, $row_address, $row_zip, $row_town, $row_country_code, $row_cb, $row_cg, $row_cc, $row_somme, $row_facnumber, $row_idfac, $row_iban, $row_bic, $row_datec, $row_drum)
{
+ // phpcs:enable
$CrLf = "\n";
$Rowing = sprintf("%06d", $row_idfac);
@@ -1616,6 +1649,7 @@ class BonPrelevement extends CommonObject
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Write sender of request (me)
*
@@ -1623,6 +1657,7 @@ class BonPrelevement extends CommonObject
*/
function EnregEmetteur()
{
+ // phpcs:enable
fputs($this->file, "03");
fputs($this->file, "08"); // Prelevement ordinaire
@@ -1679,9 +1714,9 @@ class BonPrelevement extends CommonObject
fputs($this->file, substr(" ",0,5));
fputs($this->file, "\n");
-
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Write sender of request (me).
* Note: The tag PmtInf is opened here but closed into caller
@@ -1696,6 +1731,7 @@ class BonPrelevement extends CommonObject
*/
function EnregEmetteurSEPA($configuration, $ladate, $nombre, $total, $CrLf='\n', $format='FRST')
{
+ // phpcs:enable
// SEPA INITIALISATION
global $conf;
@@ -1803,6 +1839,7 @@ class BonPrelevement extends CommonObject
return $XML_SEPA_INFO;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Write end
*
@@ -1811,6 +1848,7 @@ class BonPrelevement extends CommonObject
*/
function EnregTotal($total)
{
+ // phpcs:enable
fputs($this->file, "08");
fputs($this->file, "08"); // Prelevement ordinaire
@@ -1875,6 +1913,7 @@ class BonPrelevement extends CommonObject
return $this->LibStatut($this->statut,$mode);
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Return status label for a status
*
@@ -1884,6 +1923,7 @@ class BonPrelevement extends CommonObject
*/
function LibStatut($statut,$mode=0)
{
+ // phpcs:enable
if (empty($this->labelstatut))
{
global $langs;
@@ -1893,45 +1933,39 @@ class BonPrelevement extends CommonObject
$this->labelstatut[2]=$langs->trans("StatusCredited");
}
- if ($mode == 0)
+ if ($mode == 0 || $mode == 1)
{
return $this->labelstatut[$statut];
}
- if ($mode == 1)
- {
- return $this->labelstatut[$statut];
- }
- if ($mode == 2)
+ elseif ($mode == 2)
{
if ($statut==0) return img_picto($this->labelstatut[$statut],'statut1').' '.$this->labelstatut[$statut];
if ($statut==1) return img_picto($this->labelstatut[$statut],'statut3').' '.$this->labelstatut[$statut];
if ($statut==2) return img_picto($this->labelstatut[$statut],'statut6').' '.$this->labelstatut[$statut];
}
- if ($mode == 3)
+ elseif ($mode == 3)
{
if ($statut==0) return img_picto($this->labelstatut[$statut],'statut1');
if ($statut==1) return img_picto($this->labelstatut[$statut],'statut3');
if ($statut==2) return img_picto($this->labelstatut[$statut],'statut6');
}
- if ($mode == 4)
+ elseif ($mode == 4)
{
if ($statut==0) return img_picto($this->labelstatut[$statut],'statut1').' '.$this->labelstatut[$statut];
if ($statut==1) return img_picto($this->labelstatut[$statut],'statut3').' '.$this->labelstatut[$statut];
if ($statut==2) return img_picto($this->labelstatut[$statut],'statut6').' '.$this->labelstatut[$statut];
}
- if ($mode == 5)
+ elseif ($mode == 5)
{
if ($statut==0) return $this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut],'statut1');
if ($statut==1) return $this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut],'statut3');
if ($statut==2) return $this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut],'statut6');
}
- if ($mode == 6)
+ elseif ($mode == 6)
{
if ($statut==0) return $this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut],'statut1');
if ($statut==1) return $this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut],'statut3');
if ($statut==2) return $this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut],'statut6');
}
}
-
}
-
diff --git a/htdocs/compta/prelevement/class/ligneprelevement.class.php b/htdocs/compta/prelevement/class/ligneprelevement.class.php
index fa8545c4ea2..d8434caefd8 100644
--- a/htdocs/compta/prelevement/class/ligneprelevement.class.php
+++ b/htdocs/compta/prelevement/class/ligneprelevement.class.php
@@ -31,8 +31,15 @@
*/
class LignePrelevement
{
- var $id;
- var $db;
+ /**
+ * @var int ID
+ */
+ public $id;
+
+ /**
+ * @var DoliDB Database handler.
+ */
+ public $db;
var $statuts = array();
@@ -121,6 +128,7 @@ class LignePrelevement
return $this->LibStatut($this->statut,$mode);
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Return status label for a status
*
@@ -130,25 +138,26 @@ class LignePrelevement
*/
function LibStatut($statut,$mode=0)
{
+ // phpcs:enable
global $langs;
if ($mode == 0)
{
return $langs->trans($this->statuts[$statut]);
}
- if ($mode == 1)
+ elseif ($mode == 1)
{
if ($statut==0) return img_picto($langs->trans($this->statuts[$statut]),'statut1').' '.$langs->trans($this->statuts[$statut]); // Waiting
if ($statut==2) return img_picto($langs->trans($this->statuts[$statut]),'statut6').' '.$langs->trans($this->statuts[$statut]); // Credited
if ($statut==3) return img_picto($langs->trans($this->statuts[$statut]),'statut8').' '.$langs->trans($this->statuts[$statut]); // Refused
}
- if ($mode == 2)
+ elseif ($mode == 2)
{
if ($statut==0) return img_picto($langs->trans($this->statuts[$statut]),'statut1');
if ($statut==2) return img_picto($langs->trans($this->statuts[$statut]),'statut6');
if ($statut==3) return img_picto($langs->trans($this->statuts[$statut]),'statut8');
}
- if ($mode == 3)
+ elseif ($mode == 3)
{
if ($statut==0) return $langs->trans($this->statuts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),'statut1');
if ($statut==2) return $langs->trans($this->statuts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),'statut6');
@@ -173,4 +182,3 @@ class LignePrelevement
return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables);
}
}
-
diff --git a/htdocs/compta/prelevement/class/rejetprelevement.class.php b/htdocs/compta/prelevement/class/rejetprelevement.class.php
index 87de138e63a..6e3cfe499a8 100644
--- a/htdocs/compta/prelevement/class/rejetprelevement.class.php
+++ b/htdocs/compta/prelevement/class/rejetprelevement.class.php
@@ -30,8 +30,15 @@
*/
class RejetPrelevement
{
- var $id;
- var $db;
+ /**
+ * @var int ID
+ */
+ public $id;
+
+ /**
+ * @var DoliDB Database handler.
+ */
+ public $db;
/**
@@ -62,7 +69,6 @@ class RejetPrelevement
$this->facturer[0]=$langs->trans("NoInvoiceRefused");
$this->facturer[1]=$langs->trans("InvoiceRefused");
-
}
/**
@@ -191,9 +197,9 @@ class RejetPrelevement
dol_syslog("RejetPrelevement::Create Rollback");
$this->db->rollback();
}
-
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Send email to all users that has asked the withdraw request
*
@@ -202,6 +208,7 @@ class RejetPrelevement
*/
function _send_email($fac)
{
+ // phpcs:enable
global $langs;
$userid = 0;
@@ -320,7 +327,6 @@ class RejetPrelevement
}
return $arr;
-
}
/**
@@ -364,6 +370,4 @@ class RejetPrelevement
return -2;
}
}
-
}
-
diff --git a/htdocs/compta/prelevement/create.php b/htdocs/compta/prelevement/create.php
index 74bd282d606..0d07c341458 100644
--- a/htdocs/compta/prelevement/create.php
+++ b/htdocs/compta/prelevement/create.php
@@ -1,9 +1,10 @@
- * Copyright (C) 2010-2015 Laurent Destailleur
- * Copyright (C) 2005-2009 Regis Houssin
- * Copyright (C) 2010-2012 Juanjo Menent
- * Copyright (C) 2018 Nicolas ZABOURI
+/* Copyright (C) 2005 Rodolphe Quiedeville
+ * Copyright (C) 2010-2015 Laurent Destailleur
+ * Copyright (C) 2005-2009 Regis Houssin
+ * Copyright (C) 2010-2012 Juanjo Menent
+ * Copyright (C) 2018 Nicolas ZABOURI
+ * 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
@@ -25,7 +26,7 @@
* \brief Prelevement creation page
*/
-require('../../main.inc.php');
+require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
@@ -45,7 +46,10 @@ $result = restrictedArea($user, 'prelevement', '', '', 'bons');
$action = GETPOST('action','alpha');
$mode = GETPOST('mode','alpha')?GETPOST('mode','alpha'):'real';
$format = GETPOST('format','aZ09');
-
+$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit;
+$page = GETPOST("page",'int');
+if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
+$offset = $limit * $page;
/*
* Actions
@@ -150,7 +154,7 @@ print ''
if ($nb) {
if ($pricetowithdraw) {
print $langs->trans('ExecutionDate').' ';
- print $form->select_date();
+ print $form->selectDate();
if ($mysoc->isInEEC()) {
print '';
print '';
@@ -196,13 +200,33 @@ $sql.= " AND pfd.traite = 0";
$sql.= " AND pfd.fk_facture = f.rowid";
if ($socid) $sql.= " AND f.fk_soc = ".$socid;
+$nbtotalofrecords = '';
+if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
+{
+ $result = $db->query($sql);
+ $nbtotalofrecords = $db->num_rows($result);
+}
+
+$sql.= $db->plimit($limit+1,$offset);
+
$resql=$db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
- print load_fiche_titre($langs->trans("InvoiceWaitingWithdraw").($num > 0?' ('.$num.')':''),'','');
+ $param='';
+ if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit);
+ if($socid) $param .= '&socid='.urlencode($socid);
+ if($option) $param .= "&option=".urlencode($option);
+
+ if(! empty($page) && $num <= $nbtotalofrecords) $page = 0;
+
+ print '';
+ print '';
+ print '';
+
+ print_barre_liste($langs->trans("InvoiceWaitingWithdraw"),$page,$_SERVER['PHP_SELF'],$param,'','','',$num,$nbtotalofrecords,'title_accountancy.png',0,'','', $limit);
print '';
print '';
@@ -219,7 +243,7 @@ if ($resql)
require_once DOL_DOCUMENT_ROOT . '/societe/class/companybankaccount.class.php';
$bac = new CompanyBankAccount($db);
- while ($i < $num && $i < 20)
+ while ($i < $num && $i < $limit)
{
$obj = $db->fetch_object($resql);
@@ -260,6 +284,7 @@ if ($resql)
}
else print ' '.$langs->trans("None").' ';
print "
";
+ print " ";
print "
\n";
}
else
@@ -324,5 +349,6 @@ else
}
*/
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/compta/prelevement/demandes.php b/htdocs/compta/prelevement/demandes.php
index d20f92cb188..10c390ed5bd 100644
--- a/htdocs/compta/prelevement/demandes.php
+++ b/htdocs/compta/prelevement/demandes.php
@@ -24,7 +24,7 @@
* \brief Page to list withdraw requests
*/
-require('../../main.inc.php');
+require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/modules/modPrelevement.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
@@ -167,5 +167,6 @@ else
dol_print_error($db);
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/compta/prelevement/factures.php b/htdocs/compta/prelevement/factures.php
index 2eabd64873d..df71dcb3f31 100644
--- a/htdocs/compta/prelevement/factures.php
+++ b/htdocs/compta/prelevement/factures.php
@@ -24,7 +24,7 @@
* \brief Page liste des factures prelevees
*/
-require('../../main.inc.php');
+require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/prelevement.lib.php';
require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/rejetprelevement.class.php';
@@ -296,7 +296,6 @@ else
dol_print_error($db);
}
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/prelevement/fiche-rejet.php b/htdocs/compta/prelevement/fiche-rejet.php
index 113153bc896..3819c145851 100644
--- a/htdocs/compta/prelevement/fiche-rejet.php
+++ b/htdocs/compta/prelevement/fiche-rejet.php
@@ -24,7 +24,7 @@
* \brief Withdraw reject
*/
-require('../../main.inc.php');
+require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/prelevement.lib.php';
require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/rejetprelevement.class.php';
@@ -245,5 +245,6 @@ else
dol_print_error($db);
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/compta/prelevement/fiche-stat.php b/htdocs/compta/prelevement/fiche-stat.php
index c126212f17c..a3a1d06e322 100644
--- a/htdocs/compta/prelevement/fiche-stat.php
+++ b/htdocs/compta/prelevement/fiche-stat.php
@@ -23,7 +23,7 @@
* \brief Prelevement statistics
*/
-require('../../main.inc.php');
+require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/prelevement.lib.php';
require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/ligneprelevement.class.php';
@@ -193,5 +193,6 @@ if ($prev_id > 0 || $ref)
}
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/compta/prelevement/index.php b/htdocs/compta/prelevement/index.php
index de99b56eb19..673b83d15aa 100644
--- a/htdocs/compta/prelevement/index.php
+++ b/htdocs/compta/prelevement/index.php
@@ -26,7 +26,7 @@
*/
-require('../../main.inc.php');
+require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
@@ -221,6 +221,6 @@ else
print '';
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/prelevement/ligne.php b/htdocs/compta/prelevement/ligne.php
index 721cf62bcd7..8dd1c87069a 100644
--- a/htdocs/compta/prelevement/ligne.php
+++ b/htdocs/compta/prelevement/ligne.php
@@ -1,8 +1,9 @@
- * Copyright (C) 2005-2012 Laurent Destailleur
- * Copyright (C) 2005-2009 Regis Houssin
- * Copyright (C) 2010-2013 Juanjo Menent
+/* Copyright (C) 2005 Rodolphe Quiedeville
+ * Copyright (C) 2005-2012 Laurent Destailleur
+ * Copyright (C) 2005-2009 Regis Houssin
+ * Copyright (C) 2010-2013 Juanjo Menent
+ * 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
@@ -24,7 +25,7 @@
* \brief card of withdraw line
*/
-require('../../main.inc.php');
+require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/ligneprelevement.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/rejetprelevement.class.php';
@@ -196,7 +197,7 @@ if ($id)
//Date
print ''.$langs->trans("RefusedData").' ';
print '';
- print $form->select_date('','','','','',"confirm_rejet");
+ print $form->selectDate('', '', '', '', '', "confirm_rejet");
print ' ';
//Reason
@@ -334,6 +335,6 @@ if ($id)
}
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/prelevement/list.php b/htdocs/compta/prelevement/list.php
index 8d657f00221..ead1bfff08f 100644
--- a/htdocs/compta/prelevement/list.php
+++ b/htdocs/compta/prelevement/list.php
@@ -24,7 +24,7 @@
* \brief Page liste des prelevements
*/
-require('../../main.inc.php');
+require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/ligneprelevement.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
@@ -213,5 +213,6 @@ else
dol_print_error($db);
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/compta/prelevement/rejets.php b/htdocs/compta/prelevement/rejets.php
index c8812bba1a9..5c38b29954e 100644
--- a/htdocs/compta/prelevement/rejets.php
+++ b/htdocs/compta/prelevement/rejets.php
@@ -24,7 +24,7 @@
* \brief Reject page
*/
-require('../../main.inc.php');
+require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/rejetprelevement.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/ligneprelevement.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
@@ -120,5 +120,6 @@ else
dol_print_error($db);
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/compta/prelevement/stats.php b/htdocs/compta/prelevement/stats.php
index 20d213e820b..ab233a61be3 100644
--- a/htdocs/compta/prelevement/stats.php
+++ b/htdocs/compta/prelevement/stats.php
@@ -24,7 +24,7 @@
* \brief Page with statistics on withdrawals
*/
-require('../../main.inc.php');
+require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/ligneprelevement.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
@@ -225,7 +225,7 @@ else
dol_print_error($db);
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php
index c9e32b9a97f..4d643536388 100644
--- a/htdocs/compta/resultat/clientfourn.php
+++ b/htdocs/compta/resultat/clientfourn.php
@@ -1,12 +1,13 @@
- * Copyright (C) 2004-2017 Laurent Destailleur
- * Copyright (C) 2005-2012 Regis Houssin
- * Copyright (C) 2012 Cédric Salvador
- * Copyright (C) 2012-2014 Raphaël Dourseanud
- * Copyright (C) 2014-2106 Ferran Marcet
- * Copyright (C) 2014 Juanjo Menent
- * Copyright (C) 2014 Florian Henry
+/* Copyright (C) 2002-2006 Rodolphe Quiedeville
+ * Copyright (C) 2004-2017 Laurent Destailleur
+ * Copyright (C) 2005-2012 Regis Houssin
+ * Copyright (C) 2012 Cédric Salvador
+ * Copyright (C) 2012-2014 Raphaël Dourseanud
+ * Copyright (C) 2014-2106 Ferran Marcet
+ * Copyright (C) 2014 Juanjo Menent
+ * Copyright (C) 2014 Florian Henry
+ * 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
@@ -161,7 +162,7 @@ if ($modecompta=="CREANCES-DETTES")
$calcmode=$langs->trans("CalcModeDebt");
$calcmode.='
('.$langs->trans("SeeReportInInputOutputMode",'','').')';
if (! empty($conf->accounting->enabled)) $calcmode.='
('.$langs->trans("SeeReportInBookkeepingMode",'','').')';
- $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
+ $period=$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
$periodlink=($year_start?"".img_previous()." ".img_next()."":"");
$description=$langs->trans("RulesResultDue");
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description.= $langs->trans("DepositsAreNotIncluded");
@@ -175,9 +176,8 @@ elseif ($modecompta=="RECETTES-DEPENSES")
$calcmode=$langs->trans("CalcModeEngagement");
$calcmode.='
('.$langs->trans("SeeReportInDueDebtMode",'','').')';
if (! empty($conf->accounting->enabled)) $calcmode.='
('.$langs->trans("SeeReportInBookkeepingMode",'','').')';
- //$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',1,1,0,'',1,0,1);
- $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
- $periodlink=($year_start?"".img_previous()." ".img_next()."":"");
+ $period=$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
+ $periodlink=($year_start?"".img_previous()." ".img_next()."":"");
$description=$langs->trans("RulesResultInOut");
$builddate=dol_now();
//$exportlink=$langs->trans("NotYetAvailable");
@@ -188,8 +188,7 @@ elseif ($modecompta=="BOOKKEEPING")
$calcmode=$langs->trans("CalcModeBookkeeping");
$calcmode.='
('.$langs->trans("SeeReportInInputOutputMode",'','').')';
$calcmode.='
('.$langs->trans("SeeReportInDueDebtMode",'','').')';
- //$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',1,1,0,'',1,0,1);
- $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
+ $period=$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
$arraylist=array('no'=>$langs->trans("No"), 'yes'=>$langs->trans("AccountWithNonZeroValues"), 'all'=>$langs->trans("All"));
$period.=' '.$langs->trans("DetailByAccount").' '. $form->selectarray('showaccountdetail', $arraylist, $showaccountdetail, 0);
$periodlink=($year_start?"".img_previous()." ".img_next()."":"");
@@ -1210,6 +1209,6 @@ if ($mysoc->tva_assuj != 'franchise') // Assujetti
print "";
print '
';
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/resultat/index.php b/htdocs/compta/resultat/index.php
index fbbc7a36eef..5fc58955b60 100644
--- a/htdocs/compta/resultat/index.php
+++ b/htdocs/compta/resultat/index.php
@@ -1,10 +1,11 @@
- * Copyright (C) 2004-2012 Laurent Destailleur
- * Copyright (C) 2005-2012 Regis Houssin
- * Copyright (C) 2014-2016 Ferran Marcet
- * Copyright (C) 2014 Juanjo Menent
- * Copyright (C) 2014 Florian Henry
+/* Copyright (C) 2003 Rodolphe Quiedeville
+ * Copyright (C) 2004-2012 Laurent Destailleur
+ * Copyright (C) 2005-2012 Regis Houssin
+ * Copyright (C) 2014-2016 Ferran Marcet
+ * Copyright (C) 2014 Juanjo Menent
+ * Copyright (C) 2014 Florian Henry
+ * 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
@@ -124,7 +125,7 @@ if ($modecompta == 'CREANCES-DETTES')
$calcmode=$langs->trans("CalcModeDebt");
$calcmode.='
('.$langs->trans("SeeReportInInputOutputMode",'','').')';
if (! empty($conf->accounting->enabled)) $calcmode.='
('.$langs->trans("SeeReportInBookkeepingMode",'','').')';
- $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
+ $period=$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
$periodlink=($year_start?"".img_previous()." ".img_next()."":"");
$description=$langs->trans("RulesAmountWithTaxIncluded");
$description.='
'.$langs->trans("RulesResultDue");
@@ -138,7 +139,7 @@ else if ($modecompta=="RECETTES-DEPENSES") {
$calcmode=$langs->trans("CalcModeEngagement");
$calcmode.='
('.$langs->trans("SeeReportInDueDebtMode",'','').')';
if (! empty($conf->accounting->enabled)) $calcmode.='
('.$langs->trans("SeeReportInBookkeepingMode",'','').')';
- $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
+ $period=$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
$periodlink=($year_start?"".img_previous()." ".img_next()."":"");
$description=$langs->trans("RulesAmountWithTaxIncluded");
$description.='
'.$langs->trans("RulesResultInOut");
@@ -151,7 +152,7 @@ else if ($modecompta=="BOOKKEEPING")
$calcmode=$langs->trans("CalcModeBookkeeping");
$calcmode.='
('.$langs->trans("SeeReportInInputOutputMode",'','').')';
$calcmode.='
('.$langs->trans("SeeReportInDueDebtMode",'','').')';
- $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
+ $period=$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
$periodlink=($year_start?"".img_previous()." ".img_next()."":"");
$description=$langs->trans("RulesAmountOnInOutBookkeepingRecord");
$description.=' ('.$langs->trans("SeePageForSetup", DOL_URL_ROOT.'/accountancy/admin/account.php?mainmenu=accountancy&leftmenu=accountancy_admin', $langs->transnoentitiesnoconv("Accountancy").' / '.$langs->transnoentitiesnoconv("Setup").' / '.$langs->trans("Chartofaccounts")).')';
@@ -1009,5 +1010,6 @@ print " \n";
print "";
print '';
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/compta/resultat/result.php b/htdocs/compta/resultat/result.php
index 23c7e91b989..c4a6e2ec755 100644
--- a/htdocs/compta/resultat/result.php
+++ b/htdocs/compta/resultat/result.php
@@ -1,7 +1,8 @@
- * Copyright (C) 2016 Alexandre Spangaro
- * Copyright (C) 2018 Laurent Destailleur
+/* Copyright (C) 2016-2017 Jamal Elbaz
+ * Copyright (C) 2016 Alexandre Spangaro
+ * Copyright (C) 2018 Laurent Destailleur
+ * 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
@@ -171,7 +172,7 @@ if ($modecompta=="CREANCES-DETTES")
$calcmode=$langs->trans("CalcModeDebt");
$calcmode.='
('.$langs->trans("SeeReportInInputOutputMode",'0?'&month='.GETPOST("month"):'').'&modecompta=RECETTES-DEPENSES">','').')';
if (! empty($conf->accounting->enabled)) $calcmode.='
('.$langs->trans("SeeReportInBookkeepingMode",'','').')';
- $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
+ $period=$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
//$periodlink=''.img_previous().' '.img_next().'';
$description=$langs->trans("RulesResultDue");
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description.= $langs->trans("DepositsAreNotIncluded");
@@ -179,25 +180,24 @@ if ($modecompta=="CREANCES-DETTES")
$builddate=dol_now();
//$exportlink=$langs->trans("NotYetAvailable");
}
-else if ($modecompta=="RECETTES-DEPENSES") {
+elseif ($modecompta=="RECETTES-DEPENSES") {
$name=$langs->trans("AnnualByAccountInputOutputMode");
$calcmode=$langs->trans("CalcModeEngagement");
$calcmode.='
('.$langs->trans("SeeReportInDueDebtMode",'0?'&month='.GETPOST("month"):'').'&modecompta=CREANCES-DETTES">','').')';
if (! empty($conf->accounting->enabled)) $calcmode.='
('.$langs->trans("SeeReportInBookkeepingMode",'','').')';
- //$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',1,1,0,'',1,0,1);
- $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
+ $period=$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
//$periodlink=''.img_previous().' '.img_next().'';
$description=$langs->trans("RulesResultInOut");
$builddate=dol_now();
//$exportlink=$langs->trans("NotYetAvailable");
}
-else if ($modecompta=="BOOKKEEPING")
+elseif ($modecompta=="BOOKKEEPING")
{
$name = $langs->trans("ReportInOut").', '.$langs->trans("ByPersonalizedAccountGroups");
$calcmode=$langs->trans("CalcModeBookkeeping");
//$calcmode.='
('.$langs->trans("SeeReportInDueDebtMode",'','').')';
//$calcmode.='
('.$langs->trans("SeeReportInInputOutputMode",'','').')';
- $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
+ $period=$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
$arraylist=array('no'=>$langs->trans("No"), 'yes'=>$langs->trans("AccountWithNonZeroValues"), 'all'=>$langs->trans("All"));
$period.=' '.$langs->trans("DetailByAccount").' '. $form->selectarray('showaccountdetail', $arraylist, $showaccountdetail, 0);
$periodlink = $textprevyear . $textnextyear ;
@@ -247,12 +247,12 @@ if ($modecompta == 'CREANCES-DETTES')
//if (! empty($date_start) && ! empty($date_end))
// $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
}
-else if ($modecompta=="RECETTES-DEPENSES")
+elseif ($modecompta=="RECETTES-DEPENSES")
{
//if (! empty($date_start) && ! empty($date_end))
// $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
}
-else if ($modecompta=="BOOKKEEPING")
+elseif ($modecompta=="BOOKKEEPING")
{
// Get array of all report groups that are active
@@ -537,5 +537,6 @@ else if ($modecompta=="BOOKKEEPING")
print "";
print '';
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/compta/salaries/card.php b/htdocs/compta/salaries/card.php
index 45fee127642..f50d940a51a 100644
--- a/htdocs/compta/salaries/card.php
+++ b/htdocs/compta/salaries/card.php
@@ -1,8 +1,9 @@
+/* Copyright (C) 2011-2018 Alexandre Spangaro
* Copyright (C) 2014 Laurent Destailleur
* Copyright (C) 2015 Jean-François Ferry
* Copyright (C) 2015 Charlie BENKE
+ * 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
@@ -29,17 +30,25 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/compta/salaries/class/paymentsalary.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/salaries.lib.php';
+if (! empty($conf->projet->enabled))
+{
+ require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
+ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
+}
// Load translation files required by the page
$langs->loadLangs(array("compta","banks","bills","users","salaries","hrm"));
+if (! empty($conf->projet->enabled)) $langs->load("projects");
$id=GETPOST("id",'int');
$action=GETPOST('action','aZ09');
+$cancel= GETPOST('cancel', 'aZ09');
+$projectid = (GETPOST('projectid','int') ? GETPOST('projectid', 'int') : GETPOST('fk_project','int'));
// Security check
$socid = GETPOST("socid","int");
if ($user->societe_id) $socid=$user->societe_id;
-$result = restrictedArea($user, 'salaries', '', '', 'payment');
+$result = restrictedArea($user, 'salaries', '', '', '');
$object = new PaymentSalary($db);
@@ -52,20 +61,27 @@ $hookmanager->initHooks(array('salarycard','globalcard'));
* Actions
*/
-if ($_POST["cancel"] == $langs->trans("Cancel"))
+if ($cancel)
{
header("Location: index.php");
exit;
}
-if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel"))
+// Link to a project
+if ($action == 'classin' && $user->rights->banque->modifier)
+{
+ $object->fetch($id);
+ $object->setProject(GETPOST('projectid'));
+}
+
+if ($action == 'add' && empty($cancel))
{
$error=0;
- $datep=dol_mktime(12,0,0, $_POST["datepmonth"], $_POST["datepday"], $_POST["datepyear"]);
- $datev=dol_mktime(12,0,0, $_POST["datevmonth"], $_POST["datevday"], $_POST["datevyear"]);
- $datesp=dol_mktime(12,0,0, $_POST["datespmonth"], $_POST["datespday"], $_POST["datespyear"]);
- $dateep=dol_mktime(12,0,0, $_POST["dateepmonth"], $_POST["dateepday"], $_POST["dateepyear"]);
+ $datep=dol_mktime(12,0,0, GETPOST("datepmonth",'int'), GETPOST("datepday",'int'), GETPOST("datepyear",'int'));
+ $datev=dol_mktime(12,0,0, GETPOST("datevmonth",'int'), GETPOST("datevday",'int'), GETPOST("datevyear",'int'));
+ $datesp=dol_mktime(12,0,0, GETPOST("datespmonth",'int'), GETPOST("datespday",'int'), GETPOST("datespyear",'int'));
+ $dateep=dol_mktime(12,0,0, GETPOST("dateepmonth",'int'), GETPOST("dateepday",'int'), GETPOST("dateepyear",'int'));
if (empty($datev)) $datev=$datep;
$type_payment = dol_getIdFromCode($db, GETPOST("paymenttype", 'alpha'), 'c_paiement', 'code', 'id', 1);
@@ -82,6 +98,7 @@ if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel"))
$object->type_payment=($type_payment > 0 ? $type_payment : 0);
$object->num_payment=GETPOST("num_payment");
$object->fk_user_author=$user->id;
+ $object->fk_project= GETPOST('fk_project','int');
// Set user current salary as ref salaray for the payment
$fuser=new User($db);
@@ -187,6 +204,7 @@ if ($action == 'delete')
llxHeader("",$langs->trans("SalaryPayment"));
$form = new Form($db);
+if (! empty($conf->projet->enabled)) $formproject = new FormProjets($db);
if ($id)
{
@@ -238,13 +256,13 @@ if ($action == 'create')
// Date payment
print '';
print fieldLabel('DatePayment','datep',1).' ';
- print $form->select_date((empty($datep)?-1:$datep),"datep",'','','','add',1,1);
+ print $form->selectDate((empty($datep)?-1:$datep), "datep", '', '', '', 'add', 1, 1);
print ' ';
// Date value for bank
print '';
print fieldLabel('DateValue','datev',0).' ';
- print $form->select_date((empty($datev)?-1:$datev),"datev",'','','','add',1,1);
+ print $form->selectDate((empty($datev)?-1:$datev), "datev", '', '', '', 'add', 1, 1);
print ' ';
// Employee
@@ -263,13 +281,13 @@ if ($action == 'create')
// Date start period
print '';
print fieldLabel('DateStartPeriod','datesp',1).' ';
- print $form->select_date($datesp,"datesp",'','','','add');
+ print $form->selectDate($datesp, "datesp", '', '', '', 'add');
print ' ';
// Date end period
print '';
print fieldLabel('DateEndPeriod','dateep',1).' ';
- print $form->select_date($dateep,"dateep",'','','','add');
+ print $form->selectDate($dateep, "dateep", '', '', '', 'add');
print ' ';
// Amount
@@ -278,6 +296,18 @@ if ($action == 'create')
print '';
print '';
+ // Project
+ if (! empty($conf->projet->enabled))
+ {
+ $formproject=new FormProjets($db);
+
+ print ''.$langs->trans("Project").' ';
+
+ $numproject=$formproject->select_projects(-1, $projectid,'fk_project',0,0,1,1);
+
+ print ' ';
+ }
+
// Bank
if (! empty($conf->banque->enabled))
{
@@ -335,14 +365,46 @@ if ($id)
dol_fiche_head($head, 'card', $langs->trans("SalaryPayment"), -1, 'payment');
- $linkback = ''.$langs->trans("BackToList").'';
+ $linkback = ''.$langs->trans("BackToList").'';
$morehtmlref='';
+ // Employee
$userstatic=new User($db);
$userstatic->fetch($object->fk_user);
-
$morehtmlref.=$langs->trans('Employee') . ' : ' . $userstatic->getNomUrl(1);
+
+ // Project
+ if (! empty($conf->projet->enabled))
+ {
+ $morehtmlref.='
'.$langs->trans('Project') . ' ';
+ if ($user->rights->salaries->write)
+ {
+ if ($action != 'classify')
+ $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : ';
+ if ($action == 'classify') {
+ //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
+ $morehtmlref.='';
+ $morehtmlref.='';
+ $morehtmlref.='';
+ $morehtmlref.=$formproject->select_projects(0, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
+ $morehtmlref.='';
+ $morehtmlref.=' ';
+ } else {
+ $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
+ }
+ } else {
+ if (! empty($object->fk_project)) {
+ $proj = new Project($db);
+ $proj->fetch($object->fk_project);
+ $morehtmlref.='';
+ $morehtmlref.=$proj->ref;
+ $morehtmlref.='';
+ } else {
+ $morehtmlref.='';
+ }
+ }
+ }
$morehtmlref.='';
dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', '');
@@ -425,8 +487,6 @@ if ($id)
print "";
}
-
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/salaries/class/paymentsalary.class.php b/htdocs/compta/salaries/class/paymentsalary.class.php
index 3a3f34b85b4..dc45c9a4fb0 100644
--- a/htdocs/compta/salaries/class/paymentsalary.class.php
+++ b/htdocs/compta/salaries/class/paymentsalary.class.php
@@ -1,6 +1,6 @@
- * Copyright (C) 2014 Juanjo Menent
+/* Copyright (C) 2011-2018 Alexandre Spangaro
+ * Copyright (C) 2014 Juanjo Menent
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -17,9 +17,9 @@
*/
/**
- * \file htdocs/compta/salaries/class/paymentsalary.class.php
- * \ingroup salaries
- * \brief Class for salaries module payment
+ * \file htdocs/compta/salaries/class/paymentsalary.class.php
+ * \ingroup salaries
+ * \brief Class for salaries module payment
*/
// Put here all includes required by your class file
@@ -31,18 +31,40 @@ require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php';
*/
class PaymentSalary extends CommonObject
{
- public $element='payment_salary'; //!< Id that identify managed objects
- public $table_element='payment_salary'; //!< Name of table without prefix where object is stored
+ /**
+ * @var string ID to identify managed object
+ */
+ public $element='payment_salary';
+
+ /**
+ * @var string Name of table without prefix where object is stored
+ */
+ public $table_element='payment_salary';
+
+ /**
+ * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
+ */
public $picto='payment';
public $tms;
+
+ /**
+ * @var int User ID
+ */
public $fk_user;
+
public $datep;
public $datev;
public $amount;
+ public $fk_project;
public $type_payment;
public $num_payment;
- public $label;
+
+ /**
+ * @var string salary payments label
+ */
+ public $label;
+
public $datesp;
public $dateep;
public $fk_bank;
@@ -102,6 +124,7 @@ class PaymentSalary extends CommonObject
$sql.= " datep='".$this->db->idate($this->datep)."',";
$sql.= " datev='".$this->db->idate($this->datev)."',";
$sql.= " amount=".price2num($this->amount).",";
+ $sql.= " fk_projet='".$this->db->escape($this->fk_project)."',";
$sql.= " fk_typepayment=".$this->fk_typepayment."',";
$sql.= " num_payment='".$this->db->escape($this->num_payment)."',";
$sql.= " label='".$this->db->escape($this->label)."',";
@@ -161,6 +184,7 @@ class PaymentSalary extends CommonObject
$sql.= " s.datep,";
$sql.= " s.datev,";
$sql.= " s.amount,";
+ $sql.= " s.fk_projet as fk_project,";
$sql.= " s.fk_typepayment,";
$sql.= " s.num_payment,";
$sql.= " s.label,";
@@ -186,25 +210,26 @@ class PaymentSalary extends CommonObject
{
$obj = $this->db->fetch_object($resql);
- $this->id = $obj->rowid;
- $this->ref = $obj->rowid;
- $this->tms = $this->db->jdate($obj->tms);
- $this->fk_user = $obj->fk_user;
- $this->datep = $this->db->jdate($obj->datep);
- $this->datev = $this->db->jdate($obj->datev);
- $this->amount = $obj->amount;
- $this->type_payement = $obj->fk_typepayment;
- $this->num_payment = $obj->num_payment;
- $this->label = $obj->label;
- $this->datesp = $this->db->jdate($obj->datesp);
- $this->dateep = $this->db->jdate($obj->dateep);
- $this->note = $obj->note;
- $this->fk_bank = $obj->fk_bank;
- $this->fk_user_author = $obj->fk_user_author;
- $this->fk_user_modif = $obj->fk_user_modif;
- $this->fk_account = $obj->fk_account;
- $this->fk_type = $obj->fk_type;
- $this->rappro = $obj->rappro;
+ $this->id = $obj->rowid;
+ $this->ref = $obj->rowid;
+ $this->tms = $this->db->jdate($obj->tms);
+ $this->fk_user = $obj->fk_user;
+ $this->datep = $this->db->jdate($obj->datep);
+ $this->datev = $this->db->jdate($obj->datev);
+ $this->amount = $obj->amount;
+ $this->fk_project = $obj->fk_project;
+ $this->type_payement = $obj->fk_typepayment;
+ $this->num_payment = $obj->num_payment;
+ $this->label = $obj->label;
+ $this->datesp = $this->db->jdate($obj->datesp);
+ $this->dateep = $this->db->jdate($obj->dateep);
+ $this->note = $obj->note;
+ $this->fk_bank = $obj->fk_bank;
+ $this->fk_user_author = $obj->fk_user_author;
+ $this->fk_user_modif = $obj->fk_user_modif;
+ $this->fk_account = $obj->fk_account;
+ $this->fk_type = $obj->fk_type;
+ $this->rappro = $obj->rappro;
}
$this->db->free($resql);
@@ -276,12 +301,12 @@ class PaymentSalary extends CommonObject
$this->fk_user_modif='';
}
- /**
- * Create in database
- *
- * @param User $user User that create
- * @return int <0 if KO, >0 if OK
- */
+ /**
+ * Create in database
+ *
+ * @param User $user User that create
+ * @return int <0 if KO, >0 if OK
+ */
function create($user)
{
global $conf,$langs;
@@ -331,6 +356,7 @@ class PaymentSalary extends CommonObject
$sql.= ", datep";
$sql.= ", datev";
$sql.= ", amount";
+ $sql.= ", fk_projet";
$sql.= ", salary";
$sql.= ", fk_typepayment";
$sql.= ", num_payment";
@@ -348,6 +374,7 @@ class PaymentSalary extends CommonObject
$sql.= ", '".$this->db->idate($this->datep)."'";
$sql.= ", '".$this->db->idate($this->datev)."'";
$sql.= ", ".$this->amount;
+ $sql.= ", ".($this->fk_project > 0? $this->fk_project : 0);
$sql.= ", ".($this->salary > 0 ? $this->salary : "null");
$sql.= ", ".$this->db->escape($this->type_payment);
$sql.= ", '".$this->db->escape($this->num_payment)."'";
@@ -467,6 +494,7 @@ class PaymentSalary extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Update link between payment salary and line generate into llx_bank
*
@@ -475,6 +503,7 @@ class PaymentSalary extends CommonObject
*/
function update_fk_bank($id_bank)
{
+ // phpcs:enable
$sql = 'UPDATE '.MAIN_DB_PREFIX.'payment_salary SET fk_bank = '.$id_bank;
$sql.= ' WHERE rowid = '.$this->id;
$result = $this->db->query($sql);
@@ -502,13 +531,11 @@ class PaymentSalary extends CommonObject
global $langs;
$result='';
- $label=$langs->trans("ShowSalaryPayment").': '.$this->ref;
+ $label=$langs->trans("ShowSalaryPayment").': '.$this->ref;
- $linkstart = '';
+ $linkstart = '';
$linkend='';
- $picto='payment';
-
$result .= $linkstart;
if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1);
if ($withpicto != 2) $result.= $this->ref;
@@ -566,6 +593,7 @@ class PaymentSalary extends CommonObject
return $this->LibStatut($this->statut,$mode);
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Renvoi le libelle d'un statut donne
*
@@ -575,6 +603,7 @@ class PaymentSalary extends CommonObject
*/
function LibStatut($status,$mode=0)
{
+ // phpcs:enable
global $langs; // TODO Renvoyer le libelle anglais et faire traduction a affichage
$langs->load('compta');
@@ -615,5 +644,4 @@ class PaymentSalary extends CommonObject
}*/
return '';
}
-
}
diff --git a/htdocs/compta/salaries/class/salariesstats.class.php b/htdocs/compta/salaries/class/salariesstats.class.php
index 647dc27f4a5..82a8d094148 100644
--- a/htdocs/compta/salaries/class/salariesstats.class.php
+++ b/htdocs/compta/salaries/class/salariesstats.class.php
@@ -29,6 +29,9 @@ include_once DOL_DOCUMENT_ROOT . '/compta/salaries/class/paymentsalary.class.php
*/
class SalariesStats extends Stats
{
+ /**
+ * @var string Name of table without prefix where object is stored
+ */
public $table_element;
var $socid;
diff --git a/htdocs/compta/salaries/document.php b/htdocs/compta/salaries/document.php
index 99c34f60815..59ca8389193 100644
--- a/htdocs/compta/salaries/document.php
+++ b/htdocs/compta/salaries/document.php
@@ -44,8 +44,9 @@ $action = GETPOST('action','alpha');
$confirm = GETPOST('confirm','alpha');
// Security check
+$socid = GETPOST("socid","int");
if ($user->societe_id) $socid=$user->societe_id;
-$result = restrictedArea($user, 'salaries', $id, '');
+$result = restrictedArea($user, 'salaries', '', '', '');
// Get parameters
@@ -90,7 +91,7 @@ if ($object->id)
dol_fiche_head($head, 'documents', $langs->trans("SalaryPayment"), -1, 'payment');
- // Construit liste des fichiers
+ // Build file list
$filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
$totalsize=0;
foreach($filearray as $key => $file)
@@ -133,6 +134,6 @@ else
print $langs->trans("ErrorUnknown");
}
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/salaries/index.php b/htdocs/compta/salaries/index.php
index 0b70275654f..a8a0b82e7d9 100644
--- a/htdocs/compta/salaries/index.php
+++ b/htdocs/compta/salaries/index.php
@@ -148,7 +148,7 @@ if ($result)
if ($optioncss != '') $param.='&optioncss='.$optioncss;
$newcardbutton='';
- if ($user->rights->salaries->payment->write)
+ if (! empty($user->rights->salaries->write))
{
$newcardbutton=''.$langs->trans('NewSalaryPayment').'';
$newcardbutton.= '';
@@ -294,6 +294,6 @@ else
dol_print_error($db);
}
-
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/compta/salaries/info.php b/htdocs/compta/salaries/info.php
index 467abe3618c..d2f02f3dc8f 100644
--- a/htdocs/compta/salaries/info.php
+++ b/htdocs/compta/salaries/info.php
@@ -79,6 +79,6 @@ print '';
dol_fiche_end();
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/salaries/stats/index.php b/htdocs/compta/salaries/stats/index.php
index 3e6fd56a266..d5e3e226615 100644
--- a/htdocs/compta/salaries/stats/index.php
+++ b/htdocs/compta/salaries/stats/index.php
@@ -41,18 +41,6 @@ $socid = GETPOST("socid","int");
if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'salaries', '', '', '');
-// Other security check
-$childids = $user->getAllChildIds();
-$childids[]=$user->id;
-if ($userid > 0)
-{
- if (empty($user->rights->salaries->payment->readall) && ! in_array($userid, $childids))
- {
- accessforbidden();
- exit;
- }
-}
-
$nowyear=strftime("%Y", dol_now());
$year = GETPOST('year')>0?GETPOST('year'):$nowyear;
//$startyear=$year-2;
@@ -77,11 +65,6 @@ print load_fiche_titre($title, $mesg);
dol_mkdir($dir);
$useridtofilter=$userid; // Filter from parameters
-if (empty($useridtofilter))
-{
- $useridtofilter=$childids;
- if (! empty($user->rights->salaries->payment->readall)) $useridtofilter=0;
-}
$stats = new SalariesStats($db, $socid, $useridtofilter);
@@ -288,7 +271,6 @@ print '';
dol_fiche_end();
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/sociales/card.php b/htdocs/compta/sociales/card.php
index 85e555de468..4ffa1a2829f 100644
--- a/htdocs/compta/sociales/card.php
+++ b/htdocs/compta/sociales/card.php
@@ -1,8 +1,8 @@
- * Copyright (C) 2005-2013 Regis Houssin
- * Copyright (C) 2016 Frédéric France
- * Copyright (C) 2017 Alexandre Spangaro
+/* Copyright (C) 2004-2016 Laurent Destailleur
+ * Copyright (C) 2005-2013 Regis Houssin
+ * Copyright (C) 2016-2018 Frédéric France
+ * Copyright (C) 2017 Alexandre Spangaro
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -29,17 +29,18 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsocialcontrib.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
if (! empty($conf->projet->enabled))
{
- require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
- require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
+ include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
+ include_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
}
if (! empty($conf->accounting->enabled)) {
- require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php';
+ include_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php';
}
// Load translation files required by the page
-$langs->loadLangs(array('compta', 'bills'));
+$langs->loadLangs(array('compta', 'bills', 'banks'));
$id=GETPOST('id','int');
$action=GETPOST('action','aZ09');
@@ -241,11 +242,12 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && ($user->rights->tax->char
{
$object->paye = 0;
$object->id = $object->ref = null;
+ $object->lib = $langs->trans("CopyOf").' '.$object->lib;
- if(GETPOST('clone_for_next_month') != '') {
-
- $object->date_ech = strtotime('+1month', $object->date_ech);
- $object->periode = strtotime('+1month', $object->periode);
+ if (GETPOST('clone_for_next_month') != '')
+ {
+ $object->date_ech = dol_time_plus_duree($object->date_ech, 1, 'm');
+ $object->periode = dol_time_plus_duree($object->periode, 1, 'm');
}
if ($object->check())
@@ -330,7 +332,7 @@ if ($action == 'create')
print $form->textwithpicto($langs->trans("PeriodEndDate"), $langs->trans("LastDayTaxIsRelatedTo"));
print '';
print '';
- print $form->select_date(! empty($dateperiod)?$dateperiod:'-1', 'period', 0, 0, 0, 'charge', 1);
+ print $form->selectDate(! empty($dateperiod)?$dateperiod:'-1', 'period', 0, 0, 0, 'charge', 1);
print ' ';
print '';
@@ -340,7 +342,7 @@ if ($action == 'create')
print $langs->trans("DateDue");
print '';
print '';
- print $form->select_date(! empty($dateech)?$dateech:'-1', 'ech', 0, 0, 0, 'charge', 1);
+ print $form->selectDate(! empty($dateech)?$dateech:'-1', 'ech', 0, 0, 0, 'charge', 1);
print ' ';
print "\n";
@@ -500,7 +502,7 @@ if ($id > 0)
print "";
if ($action == 'edit')
{
- print $form->select_date($object->periode, 'period', 0, 0, 0, 'charge', 1);
+ print $form->selectDate($object->periode, 'period', 0, 0, 0, 'charge', 1);
}
else
{
@@ -512,10 +514,9 @@ if ($id > 0)
if ($action == 'edit')
{
print ' '.$langs->trans("DateDue")." ";
- print $form->select_date($object->date_ech, 'ech', 0, 0, 0, 'charge', 1);
+ print $form->selectDate($object->date_ech, 'ech', 0, 0, 0, 'charge', 1);
print " ";
- }
- else {
+ } else {
print "".$langs->trans("DateDue")." ".dol_print_date($object->date_ech,'day')." ";
}
@@ -748,7 +749,6 @@ if ($id > 0)
}
}
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/sociales/class/cchargesociales.class.php b/htdocs/compta/sociales/class/cchargesociales.class.php
index a44b820c8ea..409ee99aaae 100644
--- a/htdocs/compta/sociales/class/cchargesociales.class.php
+++ b/htdocs/compta/sociales/class/cchargesociales.class.php
@@ -38,14 +38,12 @@ class Cchargesociales
* @var string Id to identify managed objects
*/
public $element = 'cchargesociales';
+
/**
* @var string Name of table without prefix where object is stored
*/
public $table_element = 'c_chargesociales';
- /**
- */
-
public $libelle;
public $deductible;
public $active;
@@ -54,9 +52,6 @@ class Cchargesociales
public $module;
public $accountancy_code;
- /**
- */
-
/**
* Constructor
@@ -83,7 +78,7 @@ class Cchargesociales
$error = 0;
// Clean parameters
-
+
if (isset($this->libelle)) {
$this->libelle = trim($this->libelle);
}
@@ -106,14 +101,14 @@ class Cchargesociales
$this->accountancy_code = trim($this->accountancy_code);
}
-
+
// Check parameters
// Put here code to add control on parameters values
// Insert request
$sql = 'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element . '(';
-
+
$sql.= 'libelle,';
$sql.= 'deductible,';
$sql.= 'active,';
@@ -122,9 +117,9 @@ class Cchargesociales
$sql.= 'module';
$sql.= 'accountancy_code';
-
+
$sql .= ') VALUES (';
-
+
$sql .= ' '.(! isset($this->libelle)?'NULL':"'".$this->db->escape($this->libelle)."'").',';
$sql .= ' '.(! isset($this->deductible)?'NULL':$this->deductible).',';
$sql .= ' '.(! isset($this->active)?'NULL':$this->active).',';
@@ -133,7 +128,7 @@ class Cchargesociales
$sql .= ' '.(! isset($this->module)?'NULL':"'".$this->db->escape($this->module)."'").',';
$sql .= ' '.(! isset($this->accountancy_code)?'NULL':"'".$this->db->escape($this->accountancy_code)."'");
-
+
$sql .= ')';
$this->db->begin();
@@ -206,7 +201,7 @@ class Cchargesociales
$obj = $this->db->fetch_object($resql);
$this->id = $obj->id;
-
+
$this->libelle = $obj->libelle;
$this->deductible = $obj->deductible;
$this->active = $obj->active;
@@ -215,7 +210,7 @@ class Cchargesociales
$this->module = $obj->module;
$this->accountancy_code = $obj->accountancy_code;
-
+
}
$this->db->free($resql);
@@ -247,7 +242,7 @@ class Cchargesociales
dol_syslog(__METHOD__, LOG_DEBUG);
// Clean parameters
-
+
if (isset($this->libelle)) {
$this->libelle = trim($this->libelle);
}
@@ -270,7 +265,7 @@ class Cchargesociales
$this->accountancy_code = trim($this->accountancy_code);
}
-
+
// Check parameters
// Put here code to add a control on parameters values
@@ -454,7 +449,7 @@ class Cchargesociales
$result.= $link . $this->ref . $linkend;
return $result;
}
-
+
/**
* Retourne le libelle du status d'un user (actif, inactif)
*
@@ -466,6 +461,7 @@ class Cchargesociales
return $this->LibStatut($this->status,$mode);
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Renvoi le libelle d'un status donne
*
@@ -475,6 +471,7 @@ class Cchargesociales
*/
function LibStatut($status,$mode=0)
{
+ // phpcs:enable
global $langs;
if ($mode == 0)
@@ -509,8 +506,8 @@ class Cchargesociales
if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5');
}
}
-
-
+
+
/**
* Initialise object with example values
* Id must be 0 if object instance is a specimen
@@ -520,7 +517,7 @@ class Cchargesociales
public function initAsSpecimen()
{
$this->id = 0;
-
+
$this->libelle = '';
$this->deductible = '';
$this->active = '';
@@ -528,8 +525,5 @@ class Cchargesociales
$this->fk_pays = '';
$this->module = '';
$this->accountancy_code = '';
-
-
}
-
}
diff --git a/htdocs/compta/sociales/class/chargesociales.class.php b/htdocs/compta/sociales/class/chargesociales.class.php
index 65e6085a650..2ea82fb32c4 100644
--- a/htdocs/compta/sociales/class/chargesociales.class.php
+++ b/htdocs/compta/sociales/class/chargesociales.class.php
@@ -32,9 +32,21 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
*/
class ChargeSociales extends CommonObject
{
- public $element='chargesociales';
+ /**
+ * @var string ID to identify managed object
+ */
+ public $element='chargesociales';
+
public $table='chargesociales';
- public $table_element='chargesociales';
+
+ /**
+ * @var string Name of table without prefix where object is stored
+ */
+ public $table_element='chargesociales';
+
+ /**
+ * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
+ */
public $picto = 'bill';
/**
@@ -42,18 +54,18 @@ class ChargeSociales extends CommonObject
*/
protected $table_ref_field = 'ref';
- var $date_ech;
- var $lib;
- var $type;
- var $type_libelle;
- var $amount;
- var $paye;
- var $periode;
- var $date_creation;
- var $date_modification;
- var $date_validation;
- var $fk_account;
- var $fk_project;
+ public $date_ech;
+ public $lib;
+ public $type;
+ public $type_libelle;
+ public $amount;
+ public $paye;
+ public $periode;
+ public $date_creation;
+ public $date_modification;
+ public $date_validation;
+ public $fk_account;
+ public $fk_project;
/**
@@ -280,7 +292,6 @@ class ChargeSociales extends CommonObject
$this->db->rollback();
return -1;
}
-
}
@@ -359,6 +370,7 @@ class ChargeSociales extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Tag social contribution as payed completely
*
@@ -367,6 +379,7 @@ class ChargeSociales extends CommonObject
*/
function set_paid($user)
{
+ // phpcs:enable
$sql = "UPDATE ".MAIN_DB_PREFIX."chargesociales SET";
$sql.= " paye = 1";
$sql.= " WHERE rowid = ".$this->id;
@@ -374,6 +387,8 @@ class ChargeSociales extends CommonObject
if ($return) return 1;
else return -1;
}
+
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Remove tag payed on social contribution
*
@@ -382,6 +397,7 @@ class ChargeSociales extends CommonObject
*/
function set_unpaid($user)
{
+ // phpcs:enable
$sql = "UPDATE ".MAIN_DB_PREFIX."chargesociales SET";
$sql.= " paye = 0";
$sql.= " WHERE rowid = ".$this->id;
@@ -402,6 +418,7 @@ class ChargeSociales extends CommonObject
return $this->LibStatut($this->paye,$mode,$alreadypaid);
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Renvoi le libelle d'un statut donne
*
@@ -412,52 +429,48 @@ class ChargeSociales extends CommonObject
*/
function LibStatut($statut,$mode=0,$alreadypaid=-1)
{
+ // phpcs:enable
global $langs;
$langs->load('customers');
$langs->load('bills');
- if ($mode == 0)
+ if ($mode == 0 || $mode == 1)
{
if ($statut == 0) return $langs->trans("Unpaid");
if ($statut == 1) return $langs->trans("Paid");
}
- if ($mode == 1)
- {
- if ($statut == 0) return $langs->trans("Unpaid");
- if ($statut == 1) return $langs->trans("Paid");
- }
- if ($mode == 2)
+ elseif ($mode == 2)
{
if ($statut == 0 && $alreadypaid <= 0) return img_picto($langs->trans("Unpaid"), 'statut1').' '.$langs->trans("Unpaid");
if ($statut == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3').' '.$langs->trans("BillStatusStarted");
if ($statut == 1) return img_picto($langs->trans("Paid"), 'statut6').' '.$langs->trans("Paid");
}
- if ($mode == 3)
+ elseif ($mode == 3)
{
if ($statut == 0 && $alreadypaid <= 0) return img_picto($langs->trans("Unpaid"), 'statut1');
if ($statut == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3');
if ($statut == 1) return img_picto($langs->trans("Paid"), 'statut6');
}
- if ($mode == 4)
+ elseif ($mode == 4)
{
if ($statut == 0 && $alreadypaid <= 0) return img_picto($langs->trans("Unpaid"), 'statut1').' '.$langs->trans("Unpaid");
if ($statut == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3').' '.$langs->trans("BillStatusStarted");
if ($statut == 1) return img_picto($langs->trans("Paid"), 'statut6').' '.$langs->trans("Paid");
}
- if ($mode == 5)
+ elseif ($mode == 5)
{
if ($statut == 0 && $alreadypaid <= 0) return $langs->trans("Unpaid").' '.img_picto($langs->trans("Unpaid"), 'statut1');
if ($statut == 0 && $alreadypaid > 0) return $langs->trans("BillStatusStarted").' '.img_picto($langs->trans("BillStatusStarted"), 'statut3');
if ($statut == 1) return $langs->trans("Paid").' '.img_picto($langs->trans("Paid"), 'statut6');
}
- if ($mode == 6)
+ elseif ($mode == 6)
{
if ($statut == 0 && $alreadypaid <= 0) return $langs->trans("Unpaid").' '.img_picto($langs->trans("Unpaid"), 'statut1');
if ($statut == 0 && $alreadypaid > 0) return $langs->trans("BillStatusStarted").' '.img_picto($langs->trans("BillStatusStarted"), 'statut3');
if ($statut == 1) return $langs->trans("Paid").' '.img_picto($langs->trans("Paid"), 'statut6');
}
- return "Error, mode/status not found";
+ else return "Error, mode/status not found";
}
@@ -637,4 +650,3 @@ class ChargeSociales extends CommonObject
$this->type_libelle = 'Social contribution label';
}
}
-
diff --git a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php
index ba9c671f755..442e63efe11 100644
--- a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php
+++ b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php
@@ -31,26 +31,39 @@ require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'
*/
class PaymentSocialContribution extends CommonObject
{
- public $element='paiementcharge'; //!< Id that identify managed objects
- public $table_element='paiementcharge'; //!< Name of table without prefix where object is stored
+ /**
+ * @var string ID to identify managed object
+ */
+ public $element='paiementcharge';
+
+ /**
+ * @var string Name of table without prefix where object is stored
+ */
+ public $table_element='paiementcharge';
+
+ /**
+ * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
+ */
public $picto = 'payment';
- var $fk_charge;
- var $datec='';
- var $tms='';
- var $datep='';
+ public $fk_charge;
+ public $datec='';
+ public $tms='';
+ public $datep='';
+
/**
* @deprecated
* @see amount
*/
- var $total;
- var $amount; // Total amount of payment
- var $amounts=array(); // Array of amounts
- var $fk_typepaiement;
- var $num_paiement;
- var $fk_bank;
- var $fk_user_creat;
- var $fk_user_modif;
+ public $total;
+
+ public $amount; // Total amount of payment
+ public $amounts=array(); // Array of amounts
+ public $fk_typepaiement;
+ public $num_paiement;
+ public $fk_bank;
+ public $fk_user_creat;
+ public $fk_user_modif;
/**
* Constructor
@@ -493,8 +506,6 @@ class PaymentSocialContribution extends CommonObject
$this->fk_bank='';
$this->fk_user_creat='';
$this->fk_user_modif='';
-
-
}
@@ -518,7 +529,7 @@ class PaymentSocialContribution extends CommonObject
if (! empty($conf->banque->enabled))
{
- require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
+ include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
$acc = new Account($this->db);
$acc->fetch($accountid);
@@ -594,6 +605,7 @@ class PaymentSocialContribution extends CommonObject
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Mise a jour du lien entre le paiement de charge et la ligne dans llx_bank generee
*
@@ -602,6 +614,7 @@ class PaymentSocialContribution extends CommonObject
*/
function update_fk_bank($id_bank)
{
+ // phpcs:enable
$sql = "UPDATE ".MAIN_DB_PREFIX."paiementcharge SET fk_bank = ".$id_bank." WHERE rowid = ".$this->id;
dol_syslog(get_class($this)."::update_fk_bank", LOG_DEBUG);
@@ -629,6 +642,7 @@ class PaymentSocialContribution extends CommonObject
return $this->LibStatut($this->statut,$mode);
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Renvoi le libelle d'un statut donne
*
@@ -638,6 +652,7 @@ class PaymentSocialContribution extends CommonObject
*/
function LibStatut($status,$mode=0)
{
+ // phpcs:enable
global $langs; // TODO Renvoyer le libelle anglais et faire traduction a affichage
$langs->load('compta');
@@ -708,5 +723,3 @@ class PaymentSocialContribution extends CommonObject
return $result;
}
}
-
-
diff --git a/htdocs/compta/sociales/document.php b/htdocs/compta/sociales/document.php
index 490dbf3a1fe..b2f73768e96 100644
--- a/htdocs/compta/sociales/document.php
+++ b/htdocs/compta/sociales/document.php
@@ -35,8 +35,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
if (! empty($conf->projet->enabled))
{
- require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
- require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
+ include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
+ include_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
}
// Load translation files required by the page
@@ -76,7 +76,7 @@ $modulepart='tax';
* Actions
*/
-include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php';
+require_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php';
if ($action == 'setlib' && $user->rights->tax->charges->creer)
{
@@ -136,7 +136,7 @@ if ($object->id)
print '';
print '';
- // Construit liste des fichiers
+ // Build file list
$filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
$totalsize=0;
foreach($filearray as $key => $file)
@@ -168,7 +168,6 @@ else
print $langs->trans("ErrorUnknown");
}
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/sociales/index.php b/htdocs/compta/sociales/index.php
index bd323c972fe..6a0250804f1 100644
--- a/htdocs/compta/sociales/index.php
+++ b/htdocs/compta/sociales/index.php
@@ -304,5 +304,6 @@ else
dol_print_error($db);
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/compta/sociales/info.php b/htdocs/compta/sociales/info.php
index 1827c1597f8..bd21db108c1 100644
--- a/htdocs/compta/sociales/info.php
+++ b/htdocs/compta/sociales/info.php
@@ -27,8 +27,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
if (! empty($conf->projet->enabled))
{
- require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
- require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
+ include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
+ include_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
}
// Load translation files required by the page
@@ -115,6 +115,6 @@ print '';
print '';
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/sociales/payments.php b/htdocs/compta/sociales/payments.php
index 3b7f68f8c83..48b2698c762 100644
--- a/htdocs/compta/sociales/payments.php
+++ b/htdocs/compta/sociales/payments.php
@@ -397,7 +397,7 @@ while($j<$numlt)
// Payment Salary
-if (! empty($conf->salaries->enabled) && $user->rights->salaries->read)
+if (! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read))
{
if (! $mode || $mode != 'sconly')
{
@@ -480,7 +480,6 @@ if (! empty($conf->salaries->enabled) && $user->rights->salaries->read)
print '';
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/stats/byratecountry.php b/htdocs/compta/stats/byratecountry.php
index 2c43db42d13..5c9366037ed 100644
--- a/htdocs/compta/stats/byratecountry.php
+++ b/htdocs/compta/stats/byratecountry.php
@@ -1,5 +1,6 @@
+/* Copyright (C) 2018 Laurent Destailleur
+ * 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
@@ -152,7 +153,7 @@ if ($modetax == 1) $calcmode=$langs->trans('OptionVATDebitOption');
if ($modetax == 2) $calcmode=$langs->trans('OptionPaymentForProductAndServices');
$calcmode.='
('.$langs->trans("TaxModuleSetupToModifyRules",DOL_URL_ROOT.'/admin/taxes.php').')';
// Set period
-$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
+$period=$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
$prevyear=$year_start; $prevquarter=$q;
if ($prevquarter > 1) {
$prevquarter--;
@@ -230,7 +231,7 @@ else if ($modecompta=="BOOKKEEPINGCOLLECTED")
}
-$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
+$period=$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
if ($date_end == dol_time_plus_duree($date_start, 1, 'y') - 1) $periodlink=''.img_previous().' '.img_next().'';
else $periodlink = '';
@@ -414,7 +415,6 @@ print "\n";
print '
'.$langs->trans("TurnoverPerSaleTaxRateInCommitmentAccountingNotRelevant") . '
';
}
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/stats/cabyprodserv.php b/htdocs/compta/stats/cabyprodserv.php
index 5d28ab3e077..e7a3d4da480 100644
--- a/htdocs/compta/stats/cabyprodserv.php
+++ b/htdocs/compta/stats/cabyprodserv.php
@@ -1,7 +1,8 @@
- * Copyright (C) 2013-2016 Laurent Destailleur
- * Copyright (C) 2015 Raphaël Doursenaud
+/* Copyright (C) 2013 Antoine Iauch
+ * Copyright (C) 2013-2016 Laurent Destailleur
+ * Copyright (C) 2015 Raphaël Doursenaud
+ * 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
@@ -199,7 +200,7 @@ else if ($modecompta=="BOOKKEEPINGCOLLECTED")
}
-$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
+$period=$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
if ($date_end == dol_time_plus_duree($date_start, 1, 'y') - 1) $periodlink=''.img_previous().' '.img_next().'';
else $periodlink = '';
@@ -461,5 +462,6 @@ if ($modecompta == 'CREANCES-DETTES')
print '
'.$langs->trans("TurnoverPerProductInCommitmentAccountingNotRelevant") . '
';
}
+// End of page
llxFooter();
$db->close();
diff --git a/htdocs/compta/stats/cabyuser.php b/htdocs/compta/stats/cabyuser.php
index ccb286c1420..4f49b9492ff 100644
--- a/htdocs/compta/stats/cabyuser.php
+++ b/htdocs/compta/stats/cabyuser.php
@@ -1,8 +1,9 @@
- * Copyright (C) 2004-2016 Laurent Destailleur
- * Copyright (C) 2005-2009 Regis Houssin
- * Copyright (C) 2013 Antoine Iauch
+/* Copyright (C) 2001-2003 Rodolphe Quiedeville
+ * Copyright (C) 2004-2016 Laurent Destailleur
+ * Copyright (C) 2005-2009 Regis Houssin
+ * Copyright (C) 2013 Antoine Iauch
+ * 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
@@ -177,7 +178,7 @@ else if ($modecompta=="BOOKKEEPINGCOLLECTED")
}
-$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
+$period=$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
if ($date_end == dol_time_plus_duree($date_start, 1, 'y') - 1) $periodlink=''.img_previous().' '.img_next().'';
else $periodlink = '';
@@ -465,7 +466,6 @@ print "";
print '';
print '';
-
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/stats/casoc.php b/htdocs/compta/stats/casoc.php
index 8e00dfe5fbe..309737111f5 100644
--- a/htdocs/compta/stats/casoc.php
+++ b/htdocs/compta/stats/casoc.php
@@ -5,6 +5,7 @@
* Copyright (C) 2007 Franky Van Liedekerke
* Copyright (C) 2013 Antoine Iauch
* Copyright (C) 2015 Raphaël Doursenaud
+ * 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
@@ -203,7 +204,7 @@ else if ($modecompta=="BOOKKEEPINGCOLLECTED")
}
-$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
+$period=$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
if ($date_end == dol_time_plus_duree($date_start, 1, 'y') - 1) $periodlink=''.img_previous().' '.img_next().'';
else $periodlink = '';
@@ -646,6 +647,6 @@ print "";
print '';
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/stats/index.php b/htdocs/compta/stats/index.php
index c255d236664..c5ceccdad61 100644
--- a/htdocs/compta/stats/index.php
+++ b/htdocs/compta/stats/index.php
@@ -1,8 +1,9 @@
- * Copyright (C) 2004-2012 Laurent Destailleur
- * Copyright (C) 2005-2009 Regis Houssin
- * Copyright (C) 2017 Olivier Geffroy
+/* Copyright (C) 2001-2004 Rodolphe Quiedeville
+ * Copyright (C) 2004-2012 Laurent Destailleur
+ * Copyright (C) 2005-2009 Regis Houssin
+ * Copyright (C) 2017 Olivier Geffroy
+ * 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
@@ -119,7 +120,7 @@ if ($modecompta=="CREANCES-DETTES")
$calcmode=$langs->trans("CalcModeDebt");
//$calcmode.='
('.$langs->trans("SeeReportInInputOutputMode",'','').')';
$calcmode.='
('.$langs->trans("SeeReportInBookkeepingMode",'','').')';
- $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
+ $period=$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
$periodlink=($year_start?"".img_previous()." ".img_next()."":"");
$description=$langs->trans("RulesCADue");
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description.= $langs->trans("DepositsAreNotIncluded");
@@ -133,7 +134,7 @@ else if ($modecompta=="RECETTES-DEPENSES")
$calcmode=$langs->trans("CalcModeEngagement");
//$calcmode.='
('.$langs->trans("SeeReportInDueDebtMode",'','').')';
//$calcmode.='
('.$langs->trans("SeeReportInBookkeepingMode",'','').')';
- $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
+ $period=$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
$periodlink=($year_start?"".img_previous()." ".img_next()."":"");
$description=$langs->trans("RulesCAIn");
$description.= $langs->trans("DepositsAreIncluded");
@@ -146,7 +147,7 @@ else if ($modecompta=="BOOKKEEPING")
$calcmode=$langs->trans("CalcModeBookkeeping");
$calcmode.='
('.$langs->trans("SeeReportInDueDebtMode",'','').')';
//$calcmode.='
('.$langs->trans("SeeReportInInputOutputMode",'','').')';
- $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
+ $period=$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
$periodlink=($year_start?"".img_previous()." ".img_next()."":"");
$description=$langs->trans("RulesCATotalSaleJournal");
$builddate=dol_now();
@@ -629,6 +630,6 @@ print '';
*/
+// End of page
llxFooter();
-
$db->close();
diff --git a/htdocs/compta/tva/card.php b/htdocs/compta/tva/card.php
index 4480682b091..69483d84be0 100644
--- a/htdocs/compta/tva/card.php
+++ b/htdocs/compta/tva/card.php
@@ -3,6 +3,7 @@
* Copyright (C) 2004-2016 Laurent Destailleur
* Copyright (C) 2005-2013 Regis Houssin
* Copyright (C) 2015-2017 Alexandre Spangaro
+ * 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
@@ -255,11 +256,11 @@ if ($action == 'create')
print "";
print ''.$langs->trans("DatePayment").' ';
- print $form->select_date($datep,"datep",'','','','add',1,1);
+ print $form->selectDate($datep, "datep", '', '', '', 'add', 1, 1);
print ' ';
print ''.$form->textwithpicto($langs->trans("PeriodEndDate"), $langs->trans("LastDayTaxIsRelatedTo")).' ';
- print $form->select_date($datev,"datev",'','','','add',1,1);
+ print $form->selectDate($datev, "datev", '', '', '', 'add', 1, 1);
print ' ';
// Label
diff --git a/htdocs/compta/tva/class/tva.class.php b/htdocs/compta/tva/class/tva.class.php
index af330910cdf..8b407c9be61 100644
--- a/htdocs/compta/tva/class/tva.class.php
+++ b/htdocs/compta/tva/class/tva.class.php
@@ -33,20 +33,36 @@ require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php';
*/
class Tva extends CommonObject
{
- public $element='tva'; //!< Id that identify managed objects
- public $table_element='tva'; //!< Name of table without prefix where object is stored
+ /**
+ * @var string ID to identify managed object
+ */
+ public $element='tva';
+
+ /**
+ * @var string Name of table without prefix where object is stored
+ */
+ public $table_element='tva';
+
+ /**
+ * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
+ */
public $picto='payment';
- var $tms;
- var $datep;
- var $datev;
- var $amount;
- var $type_payment;
- var $num_payment;
- var $label;
- var $fk_bank;
- var $fk_user_creat;
- var $fk_user_modif;
+ public $tms;
+ public $datep;
+ public $datev;
+ public $amount;
+ public $type_payment;
+ public $num_payment;
+
+ /**
+ * @var string label
+ */
+ public $label;
+
+ public $fk_bank;
+ public $fk_user_creat;
+ public $fk_user_modif;
/**
* Constructor
@@ -350,14 +366,16 @@ class Tva extends CommonObject
return $solde;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Total of the VAT from invoices emitted by the thirdparty.
*
* @param int $year Year
- * @return double Amount
+ * @return double Amount
*/
function tva_sum_collectee($year = 0)
{
+ // phpcs:enable
$sql = "SELECT sum(f.tva) as amount";
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f WHERE f.paye = 1";
@@ -389,6 +407,7 @@ class Tva extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* VAT payed
*
@@ -397,6 +416,7 @@ class Tva extends CommonObject
*/
function tva_sum_payee($year = 0)
{
+ // phpcs:enable
$sql = "SELECT sum(f.total_tva) as total_tva";
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f";
@@ -429,6 +449,7 @@ class Tva extends CommonObject
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Total of the VAT payed
*
@@ -437,6 +458,7 @@ class Tva extends CommonObject
*/
function tva_sum_reglee($year = 0)
{
+ // phpcs:enable
$sql = "SELECT sum(f.amount) as amount";
$sql .= " FROM ".MAIN_DB_PREFIX."tva as f";
@@ -620,6 +642,7 @@ class Tva extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Update link between payment tva and line generate into llx_bank
*
@@ -628,6 +651,7 @@ class Tva extends CommonObject
*/
function update_fk_bank($id_bank)
{
+ // phpcs:enable
$sql = 'UPDATE '.MAIN_DB_PREFIX.'tva SET fk_bank = '.$id_bank;
$sql.= ' WHERE rowid = '.$this->id;
$result = $this->db->query($sql);
@@ -783,6 +807,7 @@ class Tva extends CommonObject
return $this->LibStatut($this->statut,$mode);
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Renvoi le libelle d'un statut donne
*
@@ -790,10 +815,11 @@ class Tva extends CommonObject
* @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
* @return string Libelle du statut
*/
- function LibStatut($status,$mode=0)
- {
- global $langs; // TODO Renvoyer le libelle anglais et faire traduction a affichage
+ function LibStatut($status,$mode=0)
+ {
+ // phpcs:enable
+ global $langs; // TODO Renvoyer le libelle anglais et faire traduction a affichage
- return '';
- }
+ return '';
+ }
}
diff --git a/htdocs/compta/tva/clients.php b/htdocs/compta/tva/clients.php
index ae95d71ca9c..74a08d0d142 100644
--- a/htdocs/compta/tva/clients.php
+++ b/htdocs/compta/tva/clients.php
@@ -3,7 +3,8 @@
* Copyright (C) 2004 Eric Seigne
* Copyright (C) 2004-2018 Laurent Destailleur
* Copyright (C) 2006 Yannick Warnier
- * Copyright (C) 2014 Ferran Marcet
+ * Copyright (C) 2014 Ferran Marcet
+ * 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
@@ -136,18 +137,22 @@ if ($modetax == 1) $calcmode=$langs->trans('OptionVATDebitOption');
if ($modetax == 2) $calcmode=$langs->trans('OptionPaymentForProductAndServices');
$calcmode.='
('.$langs->trans("TaxModuleSetupToModifyRules",DOL_URL_ROOT.'/admin/taxes.php').')';
// Set period
-$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
-$prevyear=$year_start; $prevquarter=$q;
+$period=$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
+$prevyear=$year_start;
+$prevquarter=$q;
if ($prevquarter > 1) {
$prevquarter--;
} else {
- $prevquarter=4; $prevyear--;
+ $prevquarter=4;
+ $prevyear--;
}
-$nextyear=$year_start; $nextquarter=$q;
+$nextyear=$year_start;
+$nextquarter=$q;
if ($nextquarter < 4) {
$nextquarter++;
} else {
- $nextquarter=1; $nextyear++;
+ $nextquarter=1;
+ $nextyear++;
}
$builddate=dol_now();
diff --git a/htdocs/compta/tva/document.php b/htdocs/compta/tva/document.php
index b83cad80bdd..790058c20a9 100644
--- a/htdocs/compta/tva/document.php
+++ b/htdocs/compta/tva/document.php
@@ -122,7 +122,7 @@ if ($object->id)
print '';
print '';
- // Construit liste des fichiers
+ // Build file list
$filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
$totalsize=0;
foreach($filearray as $key => $file)
diff --git a/htdocs/compta/tva/index.php b/htdocs/compta/tva/index.php
index 7c4912411f6..8e4fccf4168 100644
--- a/htdocs/compta/tva/index.php
+++ b/htdocs/compta/tva/index.php
@@ -4,6 +4,7 @@
* Copyright (C) 2004-2018 Laurent Destailleur
* Copyright (C) 2005-2009 Regis Houssin
* Copyright (C) 2014 Ferran Marcet
+ * 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
@@ -217,7 +218,7 @@ if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
}
if (! empty($conf->global->MAIN_MODULE_ACCOUNTING)) $description.='
'.$langs->trans("ThisIsAnEstimatedValue");
-$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
+$period=$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
$builddate=dol_now();
diff --git a/htdocs/compta/tva/quadri_detail.php b/htdocs/compta/tva/quadri_detail.php
index e2c7cc5d793..ff3e3ce127d 100644
--- a/htdocs/compta/tva/quadri_detail.php
+++ b/htdocs/compta/tva/quadri_detail.php
@@ -1,9 +1,10 @@
- * Copyright (C) 2004 Eric Seigne
- * Copyright (C) 2004-2013 Laurent Destailleur
- * Copyright (C) 2006-2007, 2015 Yannick Warnier
- * Copyright (C) 2014 Ferran Marcet
+/* Copyright (C) 2001-2003 Rodolphe Quiedeville
+ * Copyright (C) 2004 Eric Seigne
+ * Copyright (C) 2004-2013 Laurent Destailleur
+ * Copyright (C) 2006-2015 Yannick Warnier
+ * Copyright (C) 2014 Ferran Marcet
+ * 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
@@ -135,18 +136,21 @@ if ($modetax == 1) $calcmode=$langs->trans('OptionVATDebitOption');
if ($modetax == 2) $calcmode=$langs->trans('OptionPaymentForProductAndServices');
$calcmode.='
('.$langs->trans("TaxModuleSetupToModifyRules",DOL_URL_ROOT.'/admin/taxes.php').')';
// Set period
-$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1);
+$period=$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
$prevyear=$year_start; $prevquarter=$q;
if ($prevquarter > 1) {
$prevquarter--;
} else {
- $prevquarter=4; $prevyear--;
+ $prevquarter=4;
+ $prevyear--;
}
-$nextyear=$year_start; $nextquarter=$q;
+$nextyear=$year_start;
+$nextquarter=$q;
if ($nextquarter < 4) {
$nextquarter++;
} else {
- $nextquarter=1; $nextyear++;
+ $nextquarter=1;
+ $nextyear++;
}
$description.=$fsearch;
$builddate=dol_now();
diff --git a/htdocs/conf/conf.php.example b/htdocs/conf/conf.php.example
index 7475cf54ddb..886a6171818 100644
--- a/htdocs/conf/conf.php.example
+++ b/htdocs/conf/conf.php.example
@@ -14,7 +14,7 @@
// dolibarr_main_url_root
// This parameter defines the root URL of your Dolibarr index.php page without ending "/".
// It must link to the directory htdocs.
-// In most cases, this is autodetected but it's still required
+// In most cases, this is autodetected but it's still required
// * to show full url bookmarks for some services (ie: agenda rss export url, ...)
// * or when using Apache dir aliases (autodetect fails)
// * or when using nginx (autodetect fails)
@@ -40,7 +40,7 @@ $dolibarr_main_document_root='';
// dolibarr_main_url_root_alt
// This parameter defines the relative sub URLs to add to $dolibarr_main_url_root to
// forge alternative root directories (used by modules developers).
-// You can put several values, separated by a coma, but number of entries must match
+// You can put several values, separated by a coma, but number of entries must match
// number of entries into $dolibarr_main_document_root_alt.
// Examples:
// $dolibarr_main_url_root_alt='/custom';
@@ -52,7 +52,7 @@ $dolibarr_main_document_root='';
// dolibarr_main_document_root_alt
// This parameter contains absolute alternative root file system directories (used by
// modules developers).
-// You can put several values, separated by a coma, but number of entries must match
+// You can put several values, separated by a coma, but number of entries must match
// number of entries into $dolibarr_main_url_root_alt.
// Examples:
// $dolibarr_main_document_root_alt='/var/www/dolibarr/htdocs/custom';
@@ -162,7 +162,7 @@ $dolibarr_main_db_collation='utf8_unicode_ci';
// Default value: dolibarr
// Possible values: Any values found in files in htdocs/core/login directory after
// the "function_" string and before the ".php" string. You can also separate several
-// values using a ",". In this case, Dolibarr will check login/pass for each value in
+// values using a ",". In this case, Dolibarr will check login/pass for each value in
// order defined into value. However, note that this can't work with all values.
// Examples:
// $dolibarr_main_authentication='http';
@@ -207,10 +207,10 @@ $dolibarr_main_authentication='dolibarr';
// 0 = No forced redirect
// 1 = Force redirect to https, until SCRIPT_URI start with https into response
// 2 = Force redirect to https, until SERVER["HTTPS"] is 'on' into response
-// 'https://my.domain.com' = Force reditect to https using this domain name.
+// 'https://my.domain.com' = Force reditect to https using this domain name.
// Warning: If you enable this parameter, your web server must be configured to
-// respond URL with https protocol.
-// According to your web server setup, some values may works and other not. Try
+// respond URL with https protocol.
+// According to your web server setup, some values may works and other not. Try
// different values (1,2 or 'https://my.domain.com') if you experience problems.
// Default value: 0
// Possible values: 0, 1, 2 or 'https://my.domain.com'
diff --git a/htdocs/contact/canvas/actions_contactcard_common.class.php b/htdocs/contact/canvas/actions_contactcard_common.class.php
index ba96c865d1a..7e413854846 100644
--- a/htdocs/contact/canvas/actions_contactcard_common.class.php
+++ b/htdocs/contact/canvas/actions_contactcard_common.class.php
@@ -27,7 +27,11 @@
*/
abstract class ActionsContactCardCommon
{
- var $db;
+ /**
+ * @var DoliDB Database handler.
+ */
+ public $db;
+
var $dirmodule;
var $targetmodule;
var $canvas;
@@ -37,10 +41,17 @@ abstract class ActionsContactCardCommon
var $tpl = array();
//! Object container
var $object;
- //! Error string
- var $error;
- //! Error array
- var $errors=array();
+
+ /**
+ * @var string Error code (or message)
+ */
+ public $error='';
+
+
+ /**
+ * @var string[] Error codes (or messages)
+ */
+ public $errors = array();
/**
@@ -65,7 +76,8 @@ abstract class ActionsContactCardCommon
//}
}
- /**
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
+ /**
* Set content of ->tpl array, to use into template
*
* @param string $action Type of action
@@ -74,6 +86,7 @@ abstract class ActionsContactCardCommon
*/
function assign_values(&$action, $id)
{
+ // phpcs:enable
global $conf, $langs, $user, $canvas;
global $form, $formcompany, $objsoc;
@@ -254,6 +267,7 @@ abstract class ActionsContactCardCommon
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Assign POST values into object
*
@@ -261,31 +275,32 @@ abstract class ActionsContactCardCommon
*/
private function assign_post()
{
+ // phpcs:enable
global $langs, $mysoc;
- $this->object->old_name = $_POST["old_name"];
- $this->object->old_firstname = $_POST["old_firstname"];
+ $this->object->old_name = $_POST["old_name"];
+ $this->object->old_firstname = $_POST["old_firstname"];
- $this->object->socid = $_POST["socid"];
- $this->object->lastname = $_POST["name"];
- $this->object->firstname = $_POST["firstname"];
- $this->object->civility_id = $_POST["civility_id"];
- $this->object->poste = $_POST["poste"];
- $this->object->address = $_POST["address"];
- $this->object->zip = $_POST["zipcode"];
- $this->object->town = $_POST["town"];
- $this->object->fk_departement = $_POST["state_id"];
- $this->object->country_id = $_POST["country_id"]?$_POST["country_id"]:$mysoc->country_id;
- $this->object->state_id = $_POST["state_id"];
- $this->object->phone_pro = $_POST["phone_pro"];
- $this->object->phone_perso = $_POST["phone_perso"];
- $this->object->phone_mobile = $_POST["phone_mobile"];
- $this->object->fax = $_POST["fax"];
- $this->object->email = $_POST["email"];
- $this->object->jabberid = $_POST["jabberid"];
- $this->object->priv = $_POST["priv"];
- $this->object->note = $_POST["note"];
- $this->object->canvas = $_POST["canvas"];
+ $this->object->socid = $_POST["socid"];
+ $this->object->lastname = $_POST["name"];
+ $this->object->firstname = $_POST["firstname"];
+ $this->object->civility_id = $_POST["civility_id"];
+ $this->object->poste = $_POST["poste"];
+ $this->object->address = $_POST["address"];
+ $this->object->zip = $_POST["zipcode"];
+ $this->object->town = $_POST["town"];
+ $this->object->fk_departement = $_POST["state_id"];
+ $this->object->country_id = $_POST["country_id"]?$_POST["country_id"]:$mysoc->country_id;
+ $this->object->state_id = $_POST["state_id"];
+ $this->object->phone_pro = $_POST["phone_pro"];
+ $this->object->phone_perso = $_POST["phone_perso"];
+ $this->object->phone_mobile = $_POST["phone_mobile"];
+ $this->object->fax = $_POST["fax"];
+ $this->object->email = $_POST["email"];
+ $this->object->jabberid = $_POST["jabberid"];
+ $this->object->priv = $_POST["priv"];
+ $this->object->note = $_POST["note"];
+ $this->object->canvas = $_POST["canvas"];
// We set country_id, and country_code label of the chosen country
if ($this->object->country_id)
@@ -305,6 +320,4 @@ abstract class ActionsContactCardCommon
$this->object->country = $langs->trans("Country".$obj->code)?$langs->trans("Country".$obj->code):$obj->label;
}
}
-
}
-
diff --git a/htdocs/contact/canvas/default/actions_contactcard_default.class.php b/htdocs/contact/canvas/default/actions_contactcard_default.class.php
index bfcb5a21142..5831b943d76 100644
--- a/htdocs/contact/canvas/default/actions_contactcard_default.class.php
+++ b/htdocs/contact/canvas/default/actions_contactcard_default.class.php
@@ -29,8 +29,8 @@ include_once DOL_DOCUMENT_ROOT.'/contact/canvas/actions_contactcard_common.class
*/
class ActionsContactCardDefault extends ActionsContactCardCommon
{
- /**
- * Constructor
+ /**
+ * Constructor
*
* @param DoliDB $db Handler acces base de donnees
* @param string $dirmodule Name of directory of module
@@ -66,6 +66,7 @@ class ActionsContactCardDefault extends ActionsContactCardCommon
return $out;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Assign custom values for canvas
*
@@ -75,6 +76,7 @@ class ActionsContactCardDefault extends ActionsContactCardCommon
*/
function assign_values(&$action, $id)
{
+ // phpcs:enable
global $limit, $offset, $sortfield, $sortorder;
global $conf, $db, $langs, $user;
global $form;
@@ -116,10 +118,10 @@ class ActionsContactCardDefault extends ActionsContactCardCommon
{
$this->LoadListDatas($limit, $offset, $sortfield, $sortorder);
}
-
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Fetch datas list and save into ->list_datas
*
@@ -131,6 +133,7 @@ class ActionsContactCardDefault extends ActionsContactCardCommon
*/
function LoadListDatas($limit, $offset, $sortfield, $sortorder)
{
+ // phpcs:enable
global $conf, $langs;
//$this->getFieldList();
@@ -138,4 +141,3 @@ class ActionsContactCardDefault extends ActionsContactCardCommon
$this->list_datas = array();
}
}
-
diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php
index 52957d25343..9e1757fdc5a 100644
--- a/htdocs/contact/card.php
+++ b/htdocs/contact/card.php
@@ -1,13 +1,14 @@
- * Copyright (C) 2004-2015 Laurent Destailleur
- * Copyright (C) 2004 Benoit Mortier
- * Copyright (C) 2005-2017 Regis Houssin
- * Copyright (C) 2007 Franky Van Liedekerke
- * Copyright (C) 2013 Florian Henry
- * Copyright (C) 2013-2016 Alexandre Spangaro
- * Copyright (C) 2014 Juanjo Menent
- * Copyright (C) 2015 Jean-François Ferry
+/* Copyright (C) 2004-2005 Rodolphe Quiedeville
+ * Copyright (C) 2004-2015 Laurent Destailleur
+ * Copyright (C) 2004 Benoit Mortier
+ * Copyright (C) 2005-2017 Regis Houssin
+ * Copyright (C) 2007 Franky Van Liedekerke
+ * Copyright (C) 2013 Florian Henry
+ * Copyright (C) 2013-2016 Alexandre Spangaro
+ * Copyright (C) 2014 Juanjo Menent
+ * Copyright (C) 2015 Jean-François Ferry
+ * 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
@@ -704,11 +705,11 @@ else
$form=new Form($db);
if ($object->birthday)
{
- print $form->select_date($object->birthday,'birthday',0,0,0,"perso", 1, 0, 1);
+ print $form->selectDate($object->birthday, 'birthday', 0, 0, 0, "perso", 1, 0);
}
else
{
- print $form->select_date('','birthday',0,0,1,"perso", 1, 0, 1);
+ print $form->selectDate('', 'birthday', 0, 0, 1, "perso", 1, 0);
}
print '';
diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php
index 4724f0d97cd..f81c4eed4c3 100644
--- a/htdocs/contact/class/contact.class.php
+++ b/htdocs/contact/class/contact.class.php
@@ -37,9 +37,21 @@ require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php';
*/
class Contact extends CommonObject
{
+ /**
+ * @var string ID to identify managed object
+ */
public $element='contact';
+
+ /**
+ * @var string Name of table without prefix where object is stored
+ */
public $table_element='socpeople';
+
public $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
+
+ /**
+ * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
+ */
public $picto = 'contact';
@@ -123,9 +135,6 @@ class Contact extends CommonObject
public $oldcopy; // To contains a clone of this when we need to save old properties of object
-
-
-
/**
* Constructor
*
@@ -137,6 +146,7 @@ class Contact extends CommonObject
$this->statut = 1; // By default, status is enabled
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Load indicators into this->nb for board
*
@@ -144,6 +154,7 @@ class Contact extends CommonObject
*/
function load_state_board()
{
+ // phpcs:enable
global $user;
$this->nb=array();
@@ -204,7 +215,7 @@ class Contact extends CommonObject
if (empty($this->priv)) $this->priv = 0;
if (empty($this->statut)) $this->statut = 0; // This is to convert '' into '0' to avoid bad sql request
- $entity = ((isset($this->entity) && is_numeric($this->entity))?$this->entity:$conf->entity);
+ $this->entity = ((isset($this->entity) && is_numeric($this->entity))?$this->entity:$conf->entity);
$sql = "INSERT INTO ".MAIN_DB_PREFIX."socpeople (";
$sql.= " datec";
@@ -228,7 +239,7 @@ class Contact extends CommonObject
$sql.= " ".$this->db->escape($this->priv).",";
$sql.= " ".$this->db->escape($this->statut).",";
$sql.= " ".(! empty($this->canvas)?"'".$this->db->escape($this->canvas)."'":"null").",";
- $sql.= " ".$this->db->escape($entity).",";
+ $sql.= " ".$this->db->escape($this->entity).",";
$sql.= "'".$this->db->escape($this->ref_ext)."',";
$sql.= " ".(! empty($this->import_key)?"'".$this->db->escape($this->import_key)."'":"null");
$sql.= ")";
@@ -307,6 +318,8 @@ class Contact extends CommonObject
$this->id = $id;
+ $this->entity = ((isset($this->entity) && is_numeric($this->entity))?$this->entity:$conf->entity);
+
// Clean parameters
$this->lastname=trim($this->lastname)?trim($this->lastname):trim($this->lastname);
$this->firstname=trim($this->firstname);
@@ -354,6 +367,7 @@ class Contact extends CommonObject
$sql .= ", fk_user_modif=".($user->id > 0 ? "'".$this->db->escape($user->id)."'":"NULL");
$sql .= ", default_lang=".($this->default_lang?"'".$this->db->escape($this->default_lang)."'":"NULL");
$sql .= ", no_email=".($this->no_email?"'".$this->db->escape($this->no_email)."'":"0");
+ $sql .= ", entity = " . $this->db->escape($this->entity);
$sql .= " WHERE rowid=".$this->db->escape($id);
dol_syslog(get_class($this)."::update", LOG_DEBUG);
@@ -368,15 +382,12 @@ class Contact extends CommonObject
$action='update';
// Actions on extra fields
- if (! $error)
+ if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))
{
- if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
+ $result=$this->insertExtraFields();
+ if ($result < 0)
{
- $result=$this->insertExtraFields();
- if ($result < 0)
- {
- $error++;
- }
+ $error++;
}
}
@@ -466,6 +477,7 @@ class Contact extends CommonObject
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Retourne chaine DN complete dans l'annuaire LDAP pour l'objet
*
@@ -477,6 +489,7 @@ class Contact extends CommonObject
*/
function _load_ldap_dn($info,$mode=0)
{
+ // phpcs:enable
global $conf;
$dn='';
if ($mode==0) $dn=$conf->global->LDAP_KEY_CONTACTS."=".$info[$conf->global->LDAP_KEY_CONTACTS].",".$conf->global->LDAP_CONTACT_DN;
@@ -486,6 +499,7 @@ class Contact extends CommonObject
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Initialise tableau info (tableau des attributs LDAP)
*
@@ -493,6 +507,7 @@ class Contact extends CommonObject
*/
function _load_ldap_info()
{
+ // phpcs:enable
global $conf,$langs;
$info = array();
@@ -559,6 +574,7 @@ class Contact extends CommonObject
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Update field alert birthday
*
@@ -569,6 +585,7 @@ class Contact extends CommonObject
*/
function update_perso($id, $user=null, $notrigger=0)
{
+ // phpcs:enable
$error=0;
$result=false;
@@ -677,6 +694,7 @@ class Contact extends CommonObject
$sql.= " c.photo,";
$sql.= " c.priv, c.note_private, c.note_public, c.default_lang, c.no_email, c.canvas,";
$sql.= " c.import_key,";
+ $sql.= " c.datec as date_creation, c.tms as date_modification,";
$sql.= " co.label as country, co.code as country_code,";
$sql.= " d.nom as state, d.code_departement as state_code,";
$sql.= " u.rowid as user_id, u.login as user_login,";
@@ -711,6 +729,9 @@ class Contact extends CommonObject
$this->zip = $obj->zip;
$this->town = $obj->town;
+ $this->date_creation = $this->db->jdate($obj->date_creation);
+ $this->date_modification = $this->db->jdate($obj->date_modification);
+
$this->fk_departement = $obj->fk_departement; // deprecated
$this->state_id = $obj->fk_departement;
$this->departement_code = $obj->state_code; // deprecated
@@ -836,6 +857,7 @@ class Contact extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Load number of elements the contact is used as a link for
* ref_facturation
@@ -847,6 +869,7 @@ class Contact extends CommonObject
*/
function load_ref_elements()
{
+ // phpcs:enable
// Compte les elements pour lesquels il est contact
$sql ="SELECT tc.element, count(ec.rowid) as nb";
$sql.=" FROM ".MAIN_DB_PREFIX."element_contact as ec, ".MAIN_DB_PREFIX."c_type_contact as tc";
@@ -1177,6 +1200,7 @@ class Contact extends CommonObject
return $this->LibStatut($this->statut,$mode);
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Renvoi le libelle d'un statut donne
*
@@ -1186,6 +1210,7 @@ class Contact extends CommonObject
*/
function LibStatut($statut,$mode)
{
+ // phpcs:enable
global $langs;
if ($mode == 0)
@@ -1222,6 +1247,7 @@ class Contact extends CommonObject
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Return translated label of Public or Private
*
@@ -1230,6 +1256,7 @@ class Contact extends CommonObject
*/
function LibPubPriv($statut)
{
+ // phpcs:enable
global $langs;
if ($statut=='1') return $langs->trans('ContactPrivate');
else return $langs->trans('ContactPublic');
@@ -1334,6 +1361,7 @@ class Contact extends CommonObject
* Existing categories are left untouch.
*
* @param int[]|int $categories Category or categories IDs
+ * @return void
*/
public function setCategories($categories)
{
diff --git a/htdocs/contact/document.php b/htdocs/contact/document.php
index 1a60ddaaccb..07795da30d0 100644
--- a/htdocs/contact/document.php
+++ b/htdocs/contact/document.php
@@ -97,7 +97,7 @@ if ($object->id)
dol_fiche_head($head, 'documents', $title, -1, 'contact');
- // Construit liste des fichiers
+ // Build file list
$filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
$totalsize=0;
foreach($filearray as $key => $file)
diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php
index 30b7c5158ba..b60fdd8886b 100644
--- a/htdocs/contact/list.php
+++ b/htdocs/contact/list.php
@@ -154,7 +154,7 @@ $arrayfields=array(
'p.phone'=>array('label'=>"Phone", 'checked'=>1),
'p.phone_perso'=>array('label'=>"PhonePerso", 'checked'=>0),
'p.phone_mobile'=>array('label'=>"PhoneMobile", 'checked'=>1),
- 'p.fax'=>array('label'=>"Fax", 'checked'=>1),
+ 'p.fax'=>array('label'=>"Fax", 'checked'=>0),
'p.email'=>array('label'=>"EMail", 'checked'=>1),
'p.skype'=>array('label'=>"Skype", 'checked'=>1, 'enabled'=>(! empty($conf->skype->enabled))),
'p.thirdparty'=>array('label'=>"ThirdParty", 'checked'=>1, 'enabled'=>empty($conf->global->SOCIETE_DISABLE_CONTACTS)),
@@ -307,7 +307,7 @@ if ($search_societe) $sql.= natural_search('s.nom', $search_socie
if ($search_country) $sql .= " AND p.fk_pays IN (".$search_country.')';
if (strlen($search_poste)) $sql.= natural_search('p.poste', $search_poste);
if (strlen($search_phone_perso)) $sql.= natural_search('p.phone_perso', $search_phone_perso);
-if (strlen($search_phone_pro)) $sql.= natural_search('p.phone', $search_phone);
+if (strlen($search_phone_pro)) $sql.= natural_search('p.phone', $search_phone_pro);
if (strlen($search_phone_mobile)) $sql.= natural_search('p.phone_mobile', $search_phone_mobile);
if (strlen($search_fax)) $sql.= natural_search('p.fax', $search_fax);
if (strlen($search_skype)) $sql.= natural_search('p.skype', $search_skype);
diff --git a/htdocs/contact/perso.php b/htdocs/contact/perso.php
index 3e5ec085132..4932d549df4 100644
--- a/htdocs/contact/perso.php
+++ b/htdocs/contact/perso.php
@@ -1,7 +1,8 @@
- * Copyright (C) 2004-2011 Laurent Destailleur
- * Copyright (C) 2005-2012 Regis Houssin
+/* Copyright (C) 2004 Rodolphe Quiedeville
+ * Copyright (C) 2004-2011 Laurent Destailleur
+ * Copyright (C) 2005-2012 Regis Houssin
+ * 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
@@ -199,7 +200,7 @@ if ($action == 'edit')
// Date To Birth
print ''.$langs->trans("DateToBirth").' ';
$form=new Form($db);
- print $form->select_date($object->birthday,'birthday',0,0,1,"perso", 1,0,1);
+ print $form->selectDate($object->birthday, 'birthday', 0, 0, 1, "perso", 1,0);
print ' ';
print ''.$langs->trans("Alert").': ';
diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php
index d0120d130df..0e0b0ee44f1 100644
--- a/htdocs/contrat/card.php
+++ b/htdocs/contrat/card.php
@@ -1,14 +1,15 @@
- * Copyright (C) 2004-2014 Laurent Destailleur
- * Copyright (C) 2005-2014 Regis Houssin
- * Copyright (C) 2006 Andre Cianfarani
- * Copyright (C) 2010-2017 Juanjo Menent
+/* Copyright (C) 2003-2004 Rodolphe Quiedeville
+ * Copyright (C) 2004-2014 Laurent Destailleur
+ * Copyright (C) 2005-2014 Regis Houssin
+ * Copyright (C) 2006 Andre Cianfarani
+ * Copyright (C) 2010-2017 Juanjo Menent
* Copyright (C) 2013 Christophe Battarel
* Copyright (C) 2013-2014 Florian Henry
* Copyright (C) 2014-2018 Ferran Marcet
* Copyright (C) 2014-2016 Marcos García
- * Copyright (C) 2015 Jean-François Ferry
+ * Copyright (C) 2015 Jean-François Ferry
+ * 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
@@ -30,7 +31,7 @@
* \brief Page of a contract
*/
-require ("../main.inc.php");
+require "../main.inc.php";
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/contract.lib.php';
@@ -1242,7 +1243,7 @@ if ($action == 'create')
print ' ';
print ''.$langs->trans("Date").' ';
- $form->select_date($datecontrat,'',0,0,'',"contrat");
+ print $form->selectDate($datecontrat, '', 0, 0, '', "contrat");
print " ";
// Project
@@ -1781,9 +1782,9 @@ else
print '';
print '';
print $langs->trans("DateStartPlanned").' ';
- $form->select_date($db->jdate($objp->date_debut),"date_start_update",$usehm,$usehm,($db->jdate($objp->date_debut)>0?0:1),"update");
+ print $form->selectDate($db->jdate($objp->date_debut), "date_start_update", $usehm, $usehm, ($db->jdate($objp->date_debut)>0?0:1), "update");
print ' '.$langs->trans("DateEndPlanned").' ';
- $form->select_date($db->jdate($objp->date_fin),"date_end_update",$usehm,$usehm,($db->jdate($objp->date_fin)>0?0:1),"update");
+ print $form->selectDate($db->jdate($objp->date_fin), "date_end_update", $usehm, $usehm, ($db->jdate($objp->date_fin)>0?0:1), "update");
print ' ';
print ' ';
@@ -1966,10 +1967,10 @@ else
print '';
print ''.$langs->trans("DateServiceActivate").' ';
- print $form->select_date($dateactstart,'',$usehm,$usehm,'',"active",1,0,1);
+ print $form->selectDate($dateactstart, '', $usehm, $usehm, '', "active", 1, 0);
print ' ';
print ''.$langs->trans("DateEndPlanned").' ';
- print $form->select_date($dateactend,"end",$usehm,$usehm,'',"active",1,0,1);
+ print $form->selectDate($dateactend, "end", $usehm, $usehm, '', "active", 1, 0);
print ' ';
print '';
print ' ';
@@ -2027,7 +2028,7 @@ else
if ($objp->statut == 4)
{
print $langs->trans("DateEndReal").' ';
- print $form->select_date($dateactend,"end",$usehm,$usehm,($objp->date_fin_reelle>0?0:1),"closeline",1,1,1);
+ print $form->selectDate($dateactend, "end", $usehm, $usehm, ($objp->date_fin_reelle>0?0:1), "closeline", 1, 1);
}
}
print '';
diff --git a/htdocs/contrat/class/api_contracts.class.php b/htdocs/contrat/class/api_contracts.class.php
index 1bb17eb4352..04252433824 100644
--- a/htdocs/contrat/class/api_contracts.class.php
+++ b/htdocs/contrat/class/api_contracts.class.php
@@ -55,13 +55,13 @@ class Contracts extends DolibarrApi
}
/**
- * Get properties of a contrat object
+ * Get properties of a contract object
*
- * Return an array with contrat informations
+ * Return an array with contract informations
*
* @param int $id ID of contract
* @return array|mixed data without useless information
- *
+ *
* @throws RestException
*/
function get($id)
@@ -100,7 +100,8 @@ class Contracts extends DolibarrApi
*
* @throws RestException
*/
- function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '') {
+ function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '')
+ {
global $db, $conf;
$obj_ret = array();
@@ -216,7 +217,8 @@ class Contracts extends DolibarrApi
*
* @return int
*/
- function getLines($id) {
+ function getLines($id)
+ {
if(! DolibarrApiAccess::$user->rights->contrat->lire) {
throw new RestException(401);
}
@@ -247,46 +249,47 @@ class Contracts extends DolibarrApi
*
* @return int
*/
- function postLine($id, $request_data = null) {
- if(! DolibarrApiAccess::$user->rights->contrat->creer) {
- throw new RestException(401);
- }
+ function postLine($id, $request_data = null)
+ {
+ if(! DolibarrApiAccess::$user->rights->contrat->creer) {
+ throw new RestException(401);
+ }
- $result = $this->contract->fetch($id);
- if( ! $result ) {
- throw new RestException(404, 'Contract not found');
- }
+ $result = $this->contract->fetch($id);
+ if( ! $result ) {
+ throw new RestException(404, 'Contract not found');
+ }
- if( ! DolibarrApi::_checkAccessToResource('contrat',$this->contract->id)) {
- throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
- }
- $request_data = (object) $request_data;
- $updateRes = $this->contract->addline(
- $request_data->desc,
- $request_data->subprice,
- $request_data->qty,
- $request_data->tva_tx,
- $request_data->localtax1_tx,
- $request_data->localtax2_tx,
- $request_data->fk_product,
- $request_data->remise_percent,
- $request_data->date_start, // date_start = date planned start, date ouverture = date_start_real
- $request_data->date_end, // date_end = date planned end, date_cloture = date_end_real
- $request_data->HT,
- $request_data->subprice_excl_tax,
- $request_data->info_bits,
- $request_data->fk_fournprice,
- $request_data->pa_ht,
- $request_data->array_options,
- $request_data->fk_unit,
- $request_data->rang
- );
+ if( ! DolibarrApi::_checkAccessToResource('contrat',$this->contract->id)) {
+ throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
+ }
+ $request_data = (object) $request_data;
+ $updateRes = $this->contract->addline(
+ $request_data->desc,
+ $request_data->subprice,
+ $request_data->qty,
+ $request_data->tva_tx,
+ $request_data->localtax1_tx,
+ $request_data->localtax2_tx,
+ $request_data->fk_product,
+ $request_data->remise_percent,
+ $request_data->date_start, // date_start = date planned start, date ouverture = date_start_real
+ $request_data->date_end, // date_end = date planned end, date_cloture = date_end_real
+ $request_data->HT,
+ $request_data->subprice_excl_tax,
+ $request_data->info_bits,
+ $request_data->fk_fournprice,
+ $request_data->pa_ht,
+ $request_data->array_options,
+ $request_data->fk_unit,
+ $request_data->rang
+ );
- if ($updateRes > 0) {
- return $updateRes;
+ if ($updateRes > 0) {
+ return $updateRes;
- }
- return false;
+ }
+ return false;
}
/**
@@ -300,50 +303,51 @@ class Contracts extends DolibarrApi
*
* @return object
*/
- function putLine($id, $lineid, $request_data = null) {
- if(! DolibarrApiAccess::$user->rights->contrat->creer) {
- throw new RestException(401);
- }
-
- $result = $this->contract->fetch($id);
- if( ! $result ) {
- throw new RestException(404, 'Contrat not found');
- }
-
- if( ! DolibarrApi::_checkAccessToResource('contrat',$this->contract->id)) {
- throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
+ function putLine($id, $lineid, $request_data = null)
+ {
+ if(! DolibarrApiAccess::$user->rights->contrat->creer) {
+ throw new RestException(401);
}
- $request_data = (object) $request_data;
+ $result = $this->contract->fetch($id);
+ if( ! $result ) {
+ throw new RestException(404, 'Contrat not found');
+ }
- $updateRes = $this->contract->updateline(
- $lineid,
- $request_data->desc,
- $request_data->subprice,
- $request_data->qty,
- $request_data->remise_percent,
- $request_data->date_ouveture_prevue,
- $request_data->date_fin_validite,
- $request_data->tva_tx,
- $request_data->localtax1_tx,
- $request_data->localtax2_tx,
- $request_data->date_ouverture,
- $request_data->date_cloture,
- 'HT',
- $request_data->info_bits,
- $request_data->fk_fourn_price,
- $request_data->pa_ht,
- $request_data->array_options,
- $request_data->fk_unit
- );
+ if( ! DolibarrApi::_checkAccessToResource('contrat',$this->contract->id)) {
+ throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
+ }
- if ($updateRes > 0) {
- $result = $this->get($id);
- unset($result->line);
- return $this->_cleanObjectDatas($result);
- }
+ $request_data = (object) $request_data;
- return false;
+ $updateRes = $this->contract->updateline(
+ $lineid,
+ $request_data->desc,
+ $request_data->subprice,
+ $request_data->qty,
+ $request_data->remise_percent,
+ $request_data->date_ouveture_prevue,
+ $request_data->date_fin_validite,
+ $request_data->tva_tx,
+ $request_data->localtax1_tx,
+ $request_data->localtax2_tx,
+ $request_data->date_ouverture,
+ $request_data->date_cloture,
+ 'HT',
+ $request_data->info_bits,
+ $request_data->fk_fourn_price,
+ $request_data->pa_ht,
+ $request_data->array_options,
+ $request_data->fk_unit
+ );
+
+ if ($updateRes > 0) {
+ $result = $this->get($id);
+ unset($result->line);
+ return $this->_cleanObjectDatas($result);
+ }
+
+ return false;
}
/**
@@ -359,7 +363,8 @@ class Contracts extends DolibarrApi
*
* @return object
*/
- function activateLine($id, $lineid, $datestart, $dateend = null, $comment = null) {
+ function activateLine($id, $lineid, $datestart, $dateend = null, $comment = null)
+ {
if(! DolibarrApiAccess::$user->rights->contrat->creer) {
throw new RestException(401);
}
@@ -396,7 +401,8 @@ class Contracts extends DolibarrApi
*
* @return object
*/
- function unactivateLine($id, $lineid, $datestart, $comment = null) {
+ function unactivateLine($id, $lineid, $datestart, $comment = null)
+ {
if(! DolibarrApiAccess::$user->rights->contrat->creer) {
throw new RestException(401);
}
@@ -436,44 +442,46 @@ class Contracts extends DolibarrApi
* @throws 401
* @throws 404
*/
- function deleteLine($id, $lineid) {
- if(! DolibarrApiAccess::$user->rights->contrat->creer) {
- throw new RestException(401);
- }
+ function deleteLine($id, $lineid)
+ {
+ if(! DolibarrApiAccess::$user->rights->contrat->creer) {
+ throw new RestException(401);
+ }
- $result = $this->contract->fetch($id);
- if( ! $result ) {
- throw new RestException(404, 'Contrat not found');
- }
+ $result = $this->contract->fetch($id);
+ if( ! $result ) {
+ throw new RestException(404, 'Contrat not found');
+ }
- if( ! DolibarrApi::_checkAccessToResource('contrat',$this->contract->id)) {
- throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
- }
+ if( ! DolibarrApi::_checkAccessToResource('contrat',$this->contract->id)) {
+ throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
+ }
- // TODO Check the lineid $lineid is a line of ojbect
+ // TODO Check the lineid $lineid is a line of object
- $updateRes = $this->contract->deleteline($lineid, DolibarrApiAccess::$user);
- if ($updateRes > 0) {
- return $this->get($id);
- }
- else
- {
- throw new RestException(405, $this->contract->error);
- }
+ $updateRes = $this->contract->deleteline($lineid, DolibarrApiAccess::$user);
+ if ($updateRes > 0) {
+ return $this->get($id);
+ }
+ else
+ {
+ throw new RestException(405, $this->contract->error);
+ }
}
/**
* Update contract general fields (won't touch lines of contract)
*
- * @param int $id Id of contrat to update
+ * @param int $id Id of contract to update
* @param array $request_data Datas
*
* @return int
*/
- function put($id, $request_data = null) {
- if(! DolibarrApiAccess::$user->rights->contrat->creer) {
- throw new RestException(401);
- }
+ function put($id, $request_data = null)
+ {
+ if(! DolibarrApiAccess::$user->rights->contrat->creer) {
+ throw new RestException(401);
+ }
$result = $this->contract->fetch($id);
if( ! $result ) {
@@ -529,11 +537,10 @@ class Contracts extends DolibarrApi
'message' => 'Contract deleted'
)
);
-
}
/**
- * Validate an contract
+ * Validate a contract
*
* @param int $id Contract ID
* @param int $notrigger 1=Does not execute triggers, 0= execute triggers
@@ -632,7 +639,8 @@ class Contracts extends DolibarrApi
* @param object $object Object to clean
* @return array Array of cleaned object properties
*/
- function _cleanObjectDatas($object) {
+ function _cleanObjectDatas($object)
+ {
$object = parent::_cleanObjectDatas($object);
diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php
index 640793b7f37..a811f10f881 100644
--- a/htdocs/contrat/class/contrat.class.php
+++ b/htdocs/contrat/class/contrat.class.php
@@ -41,16 +41,37 @@ require_once DOL_DOCUMENT_ROOT . '/margin/lib/margins.lib.php';
*/
class Contrat extends CommonObject
{
+ /**
+ * @var string ID to identify managed object
+ */
public $element='contrat';
+
+ /**
+ * @var string Name of table without prefix where object is stored
+ */
public $table_element='contrat';
+
+ /**
+ * @var int Name of subtable line
+ */
public $table_element_line='contratdet';
+
+ /**
+ * @var int Field with ID of parent key if this field has a parent
+ */
public $fk_element='fk_contrat';
- public $picto='contract';
+
+ /**
+ * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
+ */
+ public $picto='contract';
+
/**
* 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
* @var int
*/
public $ismultientitymanaged = 1;
+
/**
* 0=Default, 1=View may be restricted to sales representative only if no permission to see all or to company of external user if external user
* @var integer
@@ -66,27 +87,29 @@ class Contrat extends CommonObject
* Customer reference of the contract
* @var string
*/
- var $ref_customer;
+ public $ref_customer;
/**
* Supplier reference of the contract
* @var string
*/
- var $ref_supplier;
+ public $ref_supplier;
/**
* Client id linked to the contract
* @var int
*/
- var $socid;
- var $societe; // Objet societe
+ public $socid;
+
+ public $societe; // Objet societe
/**
* Status of the contract
* @var int
*/
- var $statut=0; // 0=Draft,
- var $product;
+ public $statut=0; // 0=Draft,
+
+ public $product;
/**
* @var int Id of user author of the contract
@@ -113,7 +136,7 @@ class Contrat extends CommonObject
/**
* @var int Date of creation
*/
- var $date_creation;
+ public $date_creation;
/**
* @var int Date of last modification. Not filled until you call ->info()
@@ -123,34 +146,34 @@ class Contrat extends CommonObject
/**
* @var int Date of validation
*/
- var $date_validation;
+ public $date_validation;
/**
* @var int Date when contract was signed
*/
- var $date_contrat;
+ public $date_contrat;
/**
* @var int Date of contract closure
* @deprecated we close contract lines, not a contract
*/
- var $date_cloture;
+ public $date_cloture;
- var $commercial_signature_id;
- var $commercial_suivi_id;
+ public $commercial_signature_id;
+ public $commercial_suivi_id;
/**
* @deprecated Use fk_project instead
* @see fk_project
*/
- var $fk_projet;
+ public $fk_projet;
- var $extraparams=array();
+ public $extraparams=array();
/**
* @var ContratLigne[] Contract lines
*/
- var $lines=array();
+ public $lines=array();
/**
* Maps ContratLigne IDs to $this->lines indexes
@@ -226,18 +249,20 @@ class Contrat extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Activate a contract line
*
* @param User $user Objet User who activate contract
* @param int $line_id Id of line to activate
- * @param int $date Date d'ouverture
- * @param int|string $date_end Date fin prevue
+ * @param int $date Opening date
+ * @param int|string $date_end Expected end date
* @param string $comment A comment typed by user
* @return int <0 if KO, >0 if OK
*/
function active_line($user, $line_id, $date, $date_end='', $comment='')
{
+ // phpcs:enable
$result = $this->lines[$this->lines_id_index_mapper[$line_id]]->active_line($user, $date, $date_end, $comment);
if ($result < 0)
{
@@ -248,17 +273,19 @@ class Contrat extends CommonObject
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Close a contract line
*
* @param User $user Objet User who close contract
* @param int $line_id Id of line to close
- * @param int $date_end Date end
+ * @param int $date_end End date
* @param string $comment A comment typed by user
* @return int <0 if KO, >0 if OK
*/
function close_line($user, $line_id, $date_end, $comment='')
{
+ // phpcs:enable
$result=$this->lines[$this->lines_id_index_mapper[$line_id]]->close_line($user, $date_end, $comment);
if ($result < 0)
{
@@ -510,13 +537,12 @@ class Contrat extends CommonObject
$this->db->rollback();
return -1;
}
-
}
/**
* Unvalidate a contract
*
- * @param User $user Objet User
+ * @param User $user Object User
* @param int $notrigger 1=Does not execute triggers, 0=execute triggers
* @return int <0 if KO, >0 if OK
*/
@@ -558,7 +584,7 @@ class Contrat extends CommonObject
// End call triggers
}
- // Set new ref and define current statut
+ // Set new ref and define current status
if (! $error)
{
$this->statut=0;
@@ -656,7 +682,7 @@ class Contrat extends CommonObject
$this->db->free($resql);
- // Retreive all extrafield
+ // Retreive all extrafields
// fetch optionals attributes and labels
$this->fetch_optionals();
@@ -689,9 +715,9 @@ class Contrat extends CommonObject
$this->error=$this->db->error();
return -1;
}
-
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Load lines array into this->lines.
* This set also nbofserviceswait, nbofservicesopened, nbofservicesexpired and nbofservicesclosed
@@ -700,6 +726,7 @@ class Contrat extends CommonObject
*/
function fetch_lines()
{
+ // phpcs:enable
$this->nbofserviceswait=0;
$this->nbofservicesopened=0;
$this->nbofservicesexpired=0;
@@ -719,7 +746,7 @@ class Contrat extends CommonObject
$this->lines=array();
$pos = 0;
- // Selectionne les lignes contrats liees a un produit
+ // Selects contract lines related to a product
$sql = "SELECT p.label as product_label, p.description as product_desc, p.ref as product_ref,";
$sql.= " d.rowid, d.fk_contrat, d.statut, d.description, d.price_ht, d.vat_src_code, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.localtax1_type, d.localtax2_type, d.qty, d.remise_percent, d.subprice, d.fk_product_fournisseur_price as fk_fournprice, d.buy_price_ht as pa_ht,";
$sql.= " d.total_ht,";
@@ -753,7 +780,7 @@ class Contrat extends CommonObject
$line->id = $objp->rowid;
$line->ref = $objp->rowid;
$line->fk_contrat = $objp->fk_contrat;
- $line->desc = $objp->description; // Description ligne
+ $line->desc = $objp->description; // Description line
$line->qty = $objp->qty;
$line->vat_src_code = $objp->vat_src_code ;
$line->tva_tx = $objp->tva_tx;
@@ -784,9 +811,9 @@ class Contrat extends CommonObject
$line->fk_unit = $objp->fk_unit;
$line->ref = $objp->product_ref; // deprecated
- $line->product_ref = $objp->product_ref; // Ref product
- $line->product_desc = $objp->product_desc; // Description product
- $line->product_label = $objp->product_label; // Label product
+ $line->product_ref = $objp->product_ref; // Product Ref
+ $line->product_desc = $objp->product_desc; // Product Description
+ $line->product_label = $objp->product_label; // Product Label
$line->description = $objp->description;
@@ -804,7 +831,7 @@ class Contrat extends CommonObject
$line->date_fin_prevue = $this->db->jdate($objp->date_fin_validite);
$line->date_fin_reel = $this->db->jdate($objp->date_cloture);
- // Retreive all extrafield for contract
+ // Retreive all extrafields for contract
// fetch optionals attributes and labels
$line->fetch_optionals();
@@ -910,7 +937,7 @@ class Contrat extends CommonObject
$modCodeContract = new $module();
if (!empty($modCodeContract->code_auto)) {
- // Mise a jour ref
+ // Update ref
$sql = 'UPDATE '.MAIN_DB_PREFIX."contrat SET ref='(PROV".$this->id.")' WHERE rowid=".$this->id;
if ($this->db->query($sql))
{
@@ -925,26 +952,23 @@ class Contrat extends CommonObject
}
}
- if (! $error)
+ if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))
{
- if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
- {
- $result=$this->insertExtraFields();
- if ($result < 0)
- {
- $error++;
- }
- }
+ $result=$this->insertExtraFields();
+ if ($result < 0)
+ {
+ $error++;
+ }
}
- // Insert contacts commerciaux ('SALESREPSIGN','contrat')
+ // Insert business contacts ('SALESREPSIGN','contrat')
if (! $error)
{
$result=$this->add_contact($this->commercial_signature_id,'SALESREPSIGN','internal');
if ($result < 0) $error++;
}
- // Insert contacts commerciaux ('SALESREPFOLL','contrat')
+ // Insert business contacts ('SALESREPFOLL','contrat')
if (! $error)
{
$result=$this->add_contact($this->commercial_suivi_id,'SALESREPFOLL','internal');
@@ -1048,7 +1072,7 @@ class Contrat extends CommonObject
}
else
{
- $this->error="Failed to add contact";
+ $this->error="Failed to add contract";
dol_syslog(get_class($this)."::create - 20 - ".$this->error, LOG_ERR);
$this->db->rollback();
return -2;
@@ -1283,18 +1307,7 @@ class Contrat extends CommonObject
$resql = $this->db->query($sql);
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
- if (! $error)
- {
- if (! $notrigger)
- {
- // Call triggers
- $result=$this->call_trigger('CONTRACT_MODIFY',$user);
- if ($result < 0) { $error++; }
- // End call triggers
- }
- }
-
- if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options)>0) // For avoid conflicts if trigger used
+ if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options)>0)
{
$result=$this->insertExtraFields();
if ($result < 0)
@@ -1303,6 +1316,14 @@ class Contrat extends CommonObject
}
}
+ if (! $error && ! $notrigger)
+ {
+ // Call triggers
+ $result=$this->call_trigger('CONTRACT_MODIFY',$user);
+ if ($result < 0) { $error++; }
+ // End call triggers
+ }
+
// Commit or rollback
if ($error)
{
@@ -1775,6 +1796,7 @@ class Contrat extends CommonObject
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Update statut of contract according to services
*
@@ -1784,6 +1806,7 @@ class Contrat extends CommonObject
*/
function update_statut($user)
{
+ // phpcs:enable
dol_syslog(__METHOD__ . " is deprecated", LOG_WARNING);
// If draft, we keep it (should not happen)
@@ -1813,6 +1836,7 @@ class Contrat extends CommonObject
return $this->LibStatut($this->statut,$mode);
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Renvoi label of a given contrat status
*
@@ -1822,6 +1846,7 @@ class Contrat extends CommonObject
*/
function LibStatut($statut,$mode)
{
+ // phpcs:enable
global $langs;
$langs->load("contracts");
if ($mode == 0)
@@ -1995,6 +2020,7 @@ class Contrat extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Return list of line rowid
*
@@ -2003,6 +2029,7 @@ class Contrat extends CommonObject
*/
function array_detail($statut=-1)
{
+ // phpcs:enable
$tab=array();
$sql = "SELECT cd.rowid";
@@ -2070,6 +2097,7 @@ class Contrat extends CommonObject
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Load indicators for dashboard (this->nbtodo and this->nbtodolate)
*
@@ -2079,6 +2107,7 @@ class Contrat extends CommonObject
*/
function load_board($user,$mode)
{
+ // phpcs:enable
global $conf, $langs;
$this->from = " FROM ".MAIN_DB_PREFIX."contrat as c";
@@ -2148,6 +2177,7 @@ class Contrat extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Charge indicateurs this->nb de tableau de bord
*
@@ -2155,6 +2185,7 @@ class Contrat extends CommonObject
*/
function load_state_board()
{
+ // phpcs:enable
global $conf, $user;
$this->nb=array();
@@ -2356,7 +2387,8 @@ class Contrat extends CommonObject
* @param int $notrigger 1=Does not execute triggers, 0= execute triggers
* @return int New id of clone
*/
- function createFromClone($socid = 0, $notrigger=0) {
+ function createFromClone($socid = 0, $notrigger=0)
+ {
global $db, $user, $langs, $conf, $hookmanager;
dol_include_once('/projet/class/project.class.php');
@@ -2456,55 +2488,75 @@ class Contrat extends CommonObject
*/
class ContratLigne extends CommonObjectLine
{
- public $element='contratdet';
- public $table_element='contratdet';
+ /**
+ * @var string ID to identify managed object
+ */
+ public $element='contratdet';
- var $id;
- var $ref;
- var $tms;
+ /**
+ * @var string Name of table without prefix where object is stored
+ */
+ public $table_element='contratdet';
+
+ /**
+ * @var int ID
+ */
+ public $id;
+
+ /**
+ * @var string Ref
+ */
+ public $ref;
+
+ public $tms;
+
+ public $fk_contrat;
+ public $fk_product;
+ public $statut; // 0 inactive, 4 active, 5 closed
+ public $type; // 0 for product, 1 for service
- var $fk_contrat;
- var $fk_product;
- var $statut; // 0 inactive, 4 active, 5 closed
- var $type; // 0 for product, 1 for service
/**
* @var string
* @deprecated
*/
- var $label;
+ public $label;
+
/**
* @var string
* @deprecated
*/
public $libelle;
- var $description;
+ /**
+ * @var string description
+ */
+ public $description;
- var $product_ref;
- var $product_label;
+ public $product_ref;
+ public $product_label;
- var $date_commande;
+ public $date_commande;
- var $date_start; // date start planned
- var $date_start_real; // date start real
- var $date_end; // date end planned
- var $date_end_real; // date end real
+ public $date_start; // date start planned
+ public $date_start_real; // date start real
+ public $date_end; // date end planned
+ public $date_end_real; // date end real
// For backward compatibility
- var $date_ouverture_prevue; // date start planned
- var $date_ouverture; // date start real
- var $date_fin_validite; // date end planned
- var $date_cloture; // date end real
- var $tva_tx;
- var $localtax1_tx;
- var $localtax2_tx;
- var $localtax1_type; // Local tax 1 type
- var $localtax2_type; // Local tax 2 type
- var $qty;
- var $remise_percent;
- var $remise;
- var $fk_remise_except;
+ public $date_ouverture_prevue; // date start planned
+ public $date_ouverture; // date start real
+ public $date_fin_validite; // date end planned
+ public $date_cloture; // date end real
+ public $tva_tx;
+ public $localtax1_tx;
+ public $localtax2_tx;
+ public $localtax1_type; // Local tax 1 type
+ public $localtax2_type; // Local tax 2 type
+ public $qty;
+ public $remise_percent;
+ public $remise;
+ public $fk_remise_except;
- var $subprice; // Unit price HT
+ public $subprice; // Unit price HT
/**
* @var float
@@ -2513,22 +2565,22 @@ class ContratLigne extends CommonObjectLine
*/
public $price;
- var $price_ht;
+ public $price_ht;
- var $total_ht;
- var $total_tva;
- var $total_localtax1;
- var $total_localtax2;
- var $total_ttc;
+ public $total_ht;
+ public $total_tva;
+ public $total_localtax1;
+ public $total_localtax2;
+ public $total_ttc;
- var $fk_fournprice;
- var $pa_ht;
+ public $fk_fournprice;
+ public $pa_ht;
- var $info_bits;
- var $fk_user_author;
- var $fk_user_ouverture;
- var $fk_user_cloture;
- var $commentaire;
+ public $info_bits;
+ public $fk_user_author;
+ public $fk_user_ouverture;
+ public $fk_user_cloture;
+ public $commentaire;
const STATUS_INITIAL = 0;
const STATUS_OPEN = 4;
@@ -2558,6 +2610,7 @@ class ContratLigne extends CommonObjectLine
return $this->LibStatut($this->statut,$mode,((! empty($this->date_fin_validite))?($this->date_fin_validite < dol_now()?1:0):-1));
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Return label of a contract line status
*
@@ -2569,6 +2622,7 @@ class ContratLigne extends CommonObjectLine
*/
static function LibStatut($statut,$mode,$expired=-1,$moreatt='')
{
+ // phpcs:enable
global $langs;
$langs->load("contracts");
if ($mode == 0)
@@ -2980,6 +3034,7 @@ class ContratLigne extends CommonObjectLine
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Mise a jour en base des champs total_xxx de ligne
* Used by migration process
@@ -2988,6 +3043,7 @@ class ContratLigne extends CommonObjectLine
*/
function update_total()
{
+ // phpcs:enable
$this->db->begin();
// Mise a jour ligne en base
@@ -3096,6 +3152,7 @@ class ContratLigne extends CommonObjectLine
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Activate a contract line
*
@@ -3107,6 +3164,7 @@ class ContratLigne extends CommonObjectLine
*/
function active_line($user, $date, $date_end = '', $comment = '')
{
+ // phpcs:enable
global $langs, $conf;
$error = 0;
@@ -3153,6 +3211,7 @@ class ContratLigne extends CommonObjectLine
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Close a contract line
*
@@ -3164,6 +3223,7 @@ class ContratLigne extends CommonObjectLine
*/
function close_line($user, $date_end, $comment = '', $notrigger=0)
{
+ // phpcs:enable
global $langs, $conf;
// Update object
diff --git a/htdocs/contrat/contact.php b/htdocs/contrat/contact.php
index 4d403198eb8..063e3ecb228 100644
--- a/htdocs/contrat/contact.php
+++ b/htdocs/contrat/contact.php
@@ -24,7 +24,7 @@
* \brief Onglet de gestion des contacts des contrats
*/
-require ("../main.inc.php");
+require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/contract.lib.php';
require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
diff --git a/htdocs/contrat/document.php b/htdocs/contrat/document.php
index 0208d68f80d..4b7a9b4faf5 100644
--- a/htdocs/contrat/document.php
+++ b/htdocs/contrat/document.php
@@ -27,7 +27,7 @@
* \brief Page des documents joints sur les contrats
*/
-require ("../main.inc.php");
+require "../main.inc.php";
require_once DOL_DOCUMENT_ROOT.'/core/lib/contract.lib.php';
require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
@@ -103,7 +103,7 @@ if ($object->id)
dol_fiche_head($head, 'documents', $langs->trans("Contract"), -1, 'contract');
- // Construit liste des fichiers
+ // Build file list
$filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
$totalsize=0;
foreach($filearray as $key => $file)
diff --git a/htdocs/contrat/index.php b/htdocs/contrat/index.php
index b78bf52b6be..f348cab8234 100644
--- a/htdocs/contrat/index.php
+++ b/htdocs/contrat/index.php
@@ -24,9 +24,9 @@
* \brief Home page of contract area
*/
-require ("../main.inc.php");
-require_once (DOL_DOCUMENT_ROOT."/contrat/class/contrat.class.php");
-require_once (DOL_DOCUMENT_ROOT."/product/class/product.class.php");
+require "../main.inc.php";
+require_once DOL_DOCUMENT_ROOT."/contrat/class/contrat.class.php";
+require_once DOL_DOCUMENT_ROOT."/product/class/product.class.php";
// Load translation files required by the page
$langs->loadLangs(array('products', 'companies', 'contracts'));
diff --git a/htdocs/contrat/info.php b/htdocs/contrat/info.php
index 8899351c284..c783ca4948c 100644
--- a/htdocs/contrat/info.php
+++ b/htdocs/contrat/info.php
@@ -22,7 +22,7 @@
* \brief Page des informations d'un contrat
*/
-require ("../main.inc.php");
+require "../main.inc.php";
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/contract.lib.php';
require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php
index 18e78c7ff0a..e616afefd99 100644
--- a/htdocs/contrat/list.php
+++ b/htdocs/contrat/list.php
@@ -28,7 +28,7 @@
* \brief Page liste des contrats
*/
-require ("../main.inc.php");
+require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
diff --git a/htdocs/contrat/note.php b/htdocs/contrat/note.php
index c160201191a..a5ea40e146c 100644
--- a/htdocs/contrat/note.php
+++ b/htdocs/contrat/note.php
@@ -24,7 +24,7 @@
* \brief Fiche de notes sur un contrat
*/
-require ("../main.inc.php");
+require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/contract.lib.php';
require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
if (! empty($conf->projet->enabled)) {
diff --git a/htdocs/contrat/services_list.php b/htdocs/contrat/services_list.php
index de44410e505..72b45f49db5 100644
--- a/htdocs/contrat/services_list.php
+++ b/htdocs/contrat/services_list.php
@@ -1,9 +1,10 @@
- * Copyright (C) 2004-2016 Laurent Destailleur
- * Copyright (C) 2005-2012 Regis Houssin
- * Copyright (C) 2015 Jean-François Ferry
- * Copyright (C) 2018 Ferran Marcet
+/* Copyright (C) 2001-2004 Rodolphe Quiedeville
+ * Copyright (C) 2004-2016 Laurent Destailleur
+ * Copyright (C) 2005-2012 Regis Houssin
+ * Copyright (C) 2015 Jean-François Ferry
+ * Copyright (C) 2018 Ferran Marcet
+ * 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
@@ -25,10 +26,10 @@
* \brief Page to list services in contracts
*/
-require ("../main.inc.php");
-require_once (DOL_DOCUMENT_ROOT."/contrat/class/contrat.class.php");
-require_once (DOL_DOCUMENT_ROOT."/product/class/product.class.php");
-require_once (DOL_DOCUMENT_ROOT."/societe/class/societe.class.php");
+require "../main.inc.php";
+require_once DOL_DOCUMENT_ROOT."/contrat/class/contrat.class.php";
+require_once DOL_DOCUMENT_ROOT."/product/class/product.class.php";
+require_once DOL_DOCUMENT_ROOT."/societe/class/societe.class.php";
// Load translation files required by the page
$langs->loadLangs(array('products', 'contracts', 'companies'));
@@ -197,7 +198,7 @@ $now=dol_now();
$form=new Form($db);
$sql = "SELECT c.rowid as cid, c.ref, c.statut as cstatut,";
-$sql.= " s.rowid as socid, s.nom as name,";
+$sql.= " s.rowid as socid, s.nom as name, s.email, s.client, s.fournisseur,";
$sql.= " cd.rowid, cd.description, cd.statut,";
$sql.= " p.rowid as pid, p.ref as pref, p.label as label, p.fk_product_type as ptype, p.entity as pentity,";
if (!$user->rights->societe->client->voir && !$socid) $sql .= " sc.fk_soc, sc.fk_user,";
@@ -455,7 +456,7 @@ if (! empty($arrayfields['cd.date_ouverture_prevue']['checked']))
print $form->selectarray('filter_opouvertureprevue',$arrayofoperators,$filter_opouvertureprevue,1);
print ' ';
$filter_dateouvertureprevue=dol_mktime(0,0,0,$opouvertureprevuemonth,$opouvertureprevueday,$opouvertureprevueyear);
- print $form->select_date($filter_dateouvertureprevue,'opouvertureprevue',0,0,1,'',1,0,1);
+ print $form->selectDate($filter_dateouvertureprevue, 'opouvertureprevue', 0, 0, 1, '', 1, 0);
print '';
}
if (! empty($arrayfields['cd.date_ouverture']['checked']))
@@ -465,7 +466,7 @@ if (! empty($arrayfields['cd.date_ouverture']['checked']))
print $form->selectarray('filter_op1',$arrayofoperators,$filter_op1,1);
print ' ';
$filter_date1=dol_mktime(0,0,0,$op1month,$op1day,$op1year);
- print $form->select_date($filter_date1,'op1',0,0,1,'',1,0,1);
+ print $form->selectDate($filter_date1, 'op1', 0, 0, 1, '', 1, 0);
print '';
}
if (! empty($arrayfields['cd.date_fin_validite']['checked']))
@@ -475,7 +476,7 @@ if (! empty($arrayfields['cd.date_fin_validite']['checked']))
print $form->selectarray('filter_op2',$arrayofoperators,$filter_op2,1);
print ' ';
$filter_date2=dol_mktime(0,0,0,$op2month,$op2day,$op2year);
- print $form->select_date($filter_date2,'op2',0,0,1,'',1,0,1);
+ print $form->selectDate($filter_date2, 'op2', 0, 0, 1, '', 1, 0);
print '';
}
if (! empty($arrayfields['cd.date_cloture']['checked']))
@@ -485,7 +486,7 @@ if (! empty($arrayfields['cd.date_cloture']['checked']))
print $form->selectarray('filter_opcloture',$arrayofoperators,$filter_opcloture,1);
print ' ';
$filter_date_cloture=dol_mktime(0,0,0,$opcloturemonth,$opclotureday,$opclotureyear);
- print $form->select_date($filter_date_cloture,'opcloture',0,0,1,'',1,0,1);
+ print $form->selectDate($filter_date_cloture, 'opcloture', 0, 0, 1, '', 1, 0);
print '';
}
// Extra fields
@@ -540,6 +541,11 @@ while ($i < min($num,$limit))
$contractstatic->id=$obj->cid;
$contractstatic->ref=$obj->ref?$obj->ref:$obj->cid;
+ $companystatic->id=$obj->socid;
+ $companystatic->name=$obj->name;
+ $companystatic->email=$obj->email;
+ $companystatic->client=$obj->client;
+ $companystatic->fournisseur=$obj->fournisseur;
print '';
@@ -555,7 +561,7 @@ while ($i < min($num,$limit))
if (! empty($arrayfields['p.description']['checked']))
{
print '';
- if ($obj->pid)
+ if ($obj->pid > 0)
{
$productstatic->id=$obj->pid;
$productstatic->type=$obj->ptype;
@@ -625,9 +631,6 @@ while ($i < min($num,$limit))
if (! empty($arrayfields['s.nom']['checked']))
{
print ' ';
- $companystatic->id=$obj->socid;
- $companystatic->name=$obj->name;
- $companystatic->client=1;
print $companystatic->getNomUrl(1,'customer',28);
print ' ';
if (! $i) $totalarray['nbfield']++;
diff --git a/htdocs/core/actions_extrafields.inc.php b/htdocs/core/actions_extrafields.inc.php
index 6b6d40acd9c..6b6d4b7a176 100644
--- a/htdocs/core/actions_extrafields.inc.php
+++ b/htdocs/core/actions_extrafields.inc.php
@@ -178,10 +178,12 @@ if ($action == 'add')
(GETPOST('alwayseditable', 'alpha')?1:0),
(GETPOST('perms', 'alpha')?GETPOST('perms', 'alpha'):''),
$visibility,
- 0,
+ GETPOST('help','alpha'),
GETPOST('computed_value','alpha'),
(GETPOST('entitycurrentorall', 'alpha')?0:''),
- GETPOST('langfile', 'alpha')
+ GETPOST('langfile', 'alpha'),
+ 1,
+ (GETPOST('totalizable', 'alpha')?1:0)
);
if ($result > 0)
{
@@ -331,7 +333,7 @@ if ($action == 'update')
$visibility = GETPOST('list', 'alpha');
if ($type == 'separate') $visibility=3;
- $result=$extrafields->update(
+ $result=$extrafields->update(
GETPOST('attrname', 'alpha'),
GETPOST('label', 'alpha'),
$type,
@@ -344,11 +346,13 @@ if ($action == 'update')
(GETPOST('alwayseditable', 'alpha')?1:0),
(GETPOST('perms', 'alpha')?GETPOST('perms', 'alpha'):''),
$visibility,
- 0,
+ GETPOST('help','alpha'),
GETPOST('default_value','alpha'),
GETPOST('computed_value','alpha'),
(GETPOST('entitycurrentorall', 'alpha')?0:''),
- GETPOST('langfile')
+ GETPOST('langfile'),
+ 1,
+ (GETPOST('totalizable', 'alpha')?1:0)
);
if ($result > 0)
{
diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php
index 646be9a3f92..2bb55264cf9 100644
--- a/htdocs/core/actions_massactions.inc.php
+++ b/htdocs/core/actions_massactions.inc.php
@@ -378,7 +378,7 @@ if (! $error && $massaction == 'confirm_presend')
//var_dump($filepath);
// Send mail (substitutionarray must be done just before this)
- require_once(DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php');
+ require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
$mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,$sendtobcc,$deliveryreceipt,-1);
if ($mailfile->error)
{
@@ -424,25 +424,25 @@ if (! $error && $massaction == 'confirm_presend')
if ($triggername == 'SOCIETE_SENTBYMAIL') $triggername = 'COMPANY_SENTBYEMAIL';
if ($triggername == 'CONTRAT_SENTBYMAIL') $triggername = 'CONTRACT_SENTBYEMAIL';
if ($triggername == 'COMMANDE_SENTBYMAIL') $triggername = 'ORDER_SENTBYEMAIL';
- if ($triggername == 'FACTURE_SENTBYMAIL') $triggername = 'BILL_SENTBYEMAIL';
+ if ($triggername == 'FACTURE_SENTBYMAIL') $triggername = 'BILL_SENTBYMAIL';
if ($triggername == 'EXPEDITION_SENTBYMAIL') $triggername = 'SHIPPING_SENTBYEMAIL';
if ($triggername == 'COMMANDEFOURNISSEUR_SENTBYMAIL') $triggername = 'ORDER_SUPPLIER_SENTBYMAIL';
if ($triggername == 'FACTUREFOURNISSEUR_SENTBYMAIL') $triggername = 'BILL_SUPPLIER_SENTBYEMAIL';
if ($triggername == 'SUPPLIERPROPOSAL_SENTBYMAIL') $triggername = 'PROPOSAL_SUPPLIER_SENTBYEMAIL';
- if (! empty($trigger_name))
+ if (! empty($triggername))
{
// Appel des triggers
- include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
+ include_once DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php";
$interface=new Interfaces($db);
- $result=$interface->run_triggers($trigger_name, $objectobj, $user, $langs, $conf);
+ $result=$interface->run_triggers($triggername, $objectobj, $user, $langs, $conf);
if ($result < 0) { $error++; $errors=$interface->errors; }
// Fin appel triggers
if ($error)
{
setEventMessages($db->lasterror(), $errors, 'errors');
- dol_syslog("Error in trigger ".$trigger_name.' '.$db->lasterror(), LOG_ERR);
+ dol_syslog("Error in trigger ".$triggername.' '.$db->lasterror(), LOG_ERR);
}
}
@@ -703,7 +703,7 @@ if ($massaction == 'confirm_createbills')
if (! $error)
{
$db->commit();
- setEventMessage($langs->trans('BillCreated', $nb_bills_created));
+ setEventMessages($langs->trans('BillCreated', $nb_bills_created), null, 'mesgs');
// Make a redirect to avoid to bill twice if we make a refresh or back
$param='';
@@ -825,7 +825,8 @@ if (! $error && $massaction == "builddoc" && $permtoread && ! GETPOST('button_se
}
$arrayofinclusion=array();
- foreach($listofobjectref as $tmppdf) $arrayofinclusion[]='^'.preg_quote(dol_sanitizeFileName($tmppdf).'.pdf','/').'$';
+ foreach($listofobjectref as $tmppdf) $arrayofinclusion[]='^'.preg_quote(dol_sanitizeFileName($tmppdf),'/').'\.pdf$';
+ foreach($listofobjectref as $tmppdf) $arrayofinclusion[]='^'.preg_quote(dol_sanitizeFileName($tmppdf),'/').'_[a-zA-Z0-9-_]+\.pdf$'; // To include PDF generated from ODX files
$listoffiles = dol_dir_list($uploaddir,'all',1,implode('|',$arrayofinclusion),'\.meta$|\.png','date',SORT_DESC,0,true);
// build list of files with full path
diff --git a/htdocs/core/actions_printing.inc.php b/htdocs/core/actions_printing.inc.php
index 62b61e531bf..302ad161241 100644
--- a/htdocs/core/actions_printing.inc.php
+++ b/htdocs/core/actions_printing.inc.php
@@ -1,6 +1,6 @@
- * Copyright (C) 2014 Frederic France
+ * Copyright (C) 2014-2018 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
@@ -28,7 +28,7 @@
// Filename to print must be provided into 'file' parameter
// Print file
-if ($action == 'print_file' and $user->rights->printing->read)
+if ($action == 'print_file' && $user->rights->printing->read)
{
$langs->load("printing");
require_once DOL_DOCUMENT_ROOT . '/core/modules/printing/modules_printing.php';
diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php
index 8c81c0efc6a..6afd6b1e354 100644
--- a/htdocs/core/actions_sendmails.inc.php
+++ b/htdocs/core/actions_sendmails.inc.php
@@ -42,7 +42,7 @@ if (GETPOST('addfile','alpha'))
$vardir=$conf->user->dir_output."/".$user->id;
$upload_dir_tmp = $vardir.'/temp'; // TODO Add $keytoavoidconflict in upload_dir path
- dol_add_file_process($upload_dir_tmp, 0, 0, 'addedfile', '', null, $trackid);
+ dol_add_file_process($upload_dir_tmp, 0, 0, 'addedfile', '', null, $trackid, 0);
$action='presend';
}
diff --git a/htdocs/core/actions_setnotes.inc.php b/htdocs/core/actions_setnotes.inc.php
index 50b35392644..ec253d5ef4a 100644
--- a/htdocs/core/actions_setnotes.inc.php
+++ b/htdocs/core/actions_setnotes.inc.php
@@ -32,8 +32,33 @@ if ($action == 'setnote_public' && ! empty($permissionnote) && ! GETPOST('cancel
{
if (empty($action) || ! is_object($object) || empty($id)) dol_print_error('','Include of actions_setnotes.inc.php was done but required variable was not set before');
if (empty($object->id)) $object->fetch($id); // Fetch may not be already done
- $result=$object->update_note(dol_html_entity_decode(GETPOST('note_public', 'none'), ENT_QUOTES),'_public');
- if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
+
+ $result_update=$object->update_note(dol_html_entity_decode(GETPOST('note_public', 'none'), ENT_QUOTES),'_public');
+
+ if ($result_update < 0) setEventMessages($object->error, $object->errors, 'errors');
+ elseif (in_array($object->table_element, array('supplier_proposal', 'propal', 'commande_fournisseur', 'commande', 'facture_fourn', 'facture')))
+ {
+ // Define output language
+ if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
+ {
+ $outputlangs = $langs;
+ $newlang = '';
+ if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang = GETPOST('lang_id','aZ09');
+ if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
+ if (! empty($newlang)) {
+ $outputlangs = new Translate("", $conf);
+ $outputlangs->setDefaultLang($newlang);
+ }
+ $model=$object->modelpdf;
+ $hidedetails = (GETPOST('hidedetails','int') ? GETPOST('hidedetails','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0));
+ $hidedesc = (GETPOST('hidedesc','int') ? GETPOST('hidedesc','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0));
+ $hideref = (GETPOST('hideref','int') ? GETPOST('hideref','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0));
+
+ $result=$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
+
+ if ($result < 0) dol_print_error($db,$result);
+ }
+ }
}
// Set public note
else if ($action == 'setnote_private' && ! empty($permissionnote) && ! GETPOST('cancel','alpha'))
diff --git a/htdocs/core/ajax/ajaxdirpreview.php b/htdocs/core/ajax/ajaxdirpreview.php
index f69cc85e026..8d1c5cd712c 100644
--- a/htdocs/core/ajax/ajaxdirpreview.php
+++ b/htdocs/core/ajax/ajaxdirpreview.php
@@ -158,8 +158,8 @@ print ''."\n";
//print ''."\n";
$param=($sortfield?'&sortfield='.$sortfield:'').($sortorder?'&sortorder='.$sortorder:'');
-if (! empty($website)) $param.='&website='.$website;
-if (! empty($pageid)) $param.='&pageid='.$pageid;
+if (! empty($websitekey)) $param.='&website='.$websitekey;
+if (! empty($pageid)) $param.='&pageid='.$pageid;
// Dir scan
@@ -234,7 +234,7 @@ if ($type == 'directory')
$param.='&file_manager=1';
if (!preg_match('/website=/',$param)) $param.='&website='.urlencode(GETPOST('website','alpha'));
if (!preg_match('/pageid=/',$param)) $param.='&pageid='.urlencode(GETPOST('pageid','int'));
- //if (!preg_match('/backtopage=/',$param)) $param.='&backtopage='.urlencode($_SERVER["PHP_SELF"].'?file_manager=1&website='.$website.'&pageid='.$pageid);
+ //if (!preg_match('/backtopage=/',$param)) $param.='&backtopage='.urlencode($_SERVER["PHP_SELF"].'?file_manager=1&website='.$websitekey.'&pageid='.$pageid);
}
}
else
@@ -315,7 +315,7 @@ if ($useajax || $action == 'delete')
$formquestion['section_id']=array('type'=>'hidden','value'=>$section_id,'name'=>'section_id'); // We must always put field, even if empty because it is fille by javascript later
$formquestion['section_dir']=array('type'=>'hidden','value'=>$section_dir,'name'=>'section_dir'); // We must always put field, even if empty because it is fille by javascript later
if (! empty($action) && $action == 'file_manager') $formquestion['file_manager']=array('type'=>'hidden','value'=>1,'name'=>'file_manager');
- if (! empty($website)) $formquestion['website']=array('type'=>'hidden','value'=>$website,'name'=>'website');
+ if (! empty($websitekey)) $formquestion['website']=array('type'=>'hidden','value'=>$websitekey,'name'=>'website');
if (! empty($pageid) && $pageid > 0) $formquestion['pageid']=array('type'=>'hidden','value'=>$pageid,'name'=>'pageid');
print $form->formconfirm($url,$langs->trans("DeleteFile"),$langs->trans("ConfirmDeleteFile"),'confirm_deletefile',$formquestion,"no",($useajax?'deletefile':0));
diff --git a/htdocs/core/ajax/ajaxdirtree.php b/htdocs/core/ajax/ajaxdirtree.php
index cfff81749de..4b588751829 100644
--- a/htdocs/core/ajax/ajaxdirtree.php
+++ b/htdocs/core/ajax/ajaxdirtree.php
@@ -201,7 +201,7 @@ if (! empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE
// Edit link
print ''.img_edit($langs->trans("Edit").' - '.$langs->trans("View"), 0, 'class="valignmiddle opacitymedium"').' ';
// Add link
diff --git a/htdocs/core/ajax/check_notifications.php b/htdocs/core/ajax/check_notifications.php
index 6984bbff5b4..642dc1038d9 100644
--- a/htdocs/core/ajax/check_notifications.php
+++ b/htdocs/core/ajax/check_notifications.php
@@ -44,37 +44,37 @@ $eventfound = array();
//dol_syslog('time='.$time.' $_SESSION[auto_ck_events_not_before]='.$_SESSION['auto_check_events_not_before']);
// TODO Try to make a solution with only a javascript timer that is easier. Difficulty is to avoid notification twice when several tabs are opened.
-if ($time >= $_SESSION['auto_check_events_not_before'])
+if ($time >= $_SESSION['auto_check_events_not_before'])
{
$time_update = (int) $conf->global->MAIN_BROWSER_NOTIFICATION_FREQUENCY; // Always defined
- if (! empty($_SESSION['auto_check_events_not_before']))
+ if (! empty($_SESSION['auto_check_events_not_before']))
{
// We start scan from the not before so if two tabs were opend at differents seconds and we close one (so the js timer),
- // then we are not losing periods
+ // then we are not losing periods
$starttime = $_SESSION['auto_check_events_not_before'];
// Protection to avoid too long sessions
- if ($starttime < ($time - (int) $conf->global->MAIN_SESSION_TIMEOUT))
+ if ($starttime < ($time - (int) $conf->global->MAIN_SESSION_TIMEOUT))
{
dol_syslog("We ask to check browser notification on a too large period. We fix this with current date.");
$starttime = $time;
}
}
- else
+ else
{
$starttime = $time;
}
-
+
$_SESSION['auto_check_events_not_before'] = $time + $time_update;
-
- // Force save of session change we did.
+
+ // Force save of session change we did.
// WARNING: Any change in sessions after that will not be saved !
session_write_close();
-
+
require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
-
-
+
+
dol_syslog('NEW $_SESSION[auto_check_events_not_before]='.$_SESSION['auto_check_events_not_before']);
-
+
$sql = 'SELECT id';
$sql .= ' FROM ' . MAIN_DB_PREFIX . 'actioncomm a, ' . MAIN_DB_PREFIX . 'actioncomm_resources ar';
$sql .= ' WHERE a.id = ar.fk_actioncomm';
@@ -91,11 +91,11 @@ if ($time >= $_SESSION['auto_check_events_not_before'])
$actionmod = new ActionComm($db);
- while ($obj = $db->fetch_object($resql))
+ while ($obj = $db->fetch_object($resql))
{
- $langs->load("agenda");
- $langs->load("commercial");
-
+ // Load translation files required by the page
+ $langs->loadLangs(array('agenda', 'commercial'));
+
$actionmod->fetch($obj->id);
// Message must be formated and translated to be used with javascript directly
@@ -105,7 +105,7 @@ if ($time >= $_SESSION['auto_check_events_not_before'])
$event['tipo'] = $langs->transnoentities('Action' . $actionmod->code);
$event['titulo'] = $actionmod->label;
$event['location'] = $langs->transnoentities('Location').': '.$actionmod->location;
-
+
$eventfound[] = $event;
}
}
diff --git a/htdocs/core/ajax/price.php b/htdocs/core/ajax/price.php
index 577f659b2cc..453fdc7bc82 100644
--- a/htdocs/core/ajax/price.php
+++ b/htdocs/core/ajax/price.php
@@ -25,7 +25,7 @@ if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1');
if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
-require('../../main.inc.php');
+require '../../main.inc.php';
$output = GETPOST('output','alpha');
$amount = price2num(GETPOST('amount','alpha'));
diff --git a/htdocs/core/ajax/ziptown.php b/htdocs/core/ajax/ziptown.php
index 9fa475039d9..2100d3d3600 100644
--- a/htdocs/core/ajax/ziptown.php
+++ b/htdocs/core/ajax/ziptown.php
@@ -120,6 +120,7 @@ if (! empty($_GET['zipcode']) || ! empty($_GET['town']))
$row_array['selectcountry_id'] = $row['fk_country'];
$row_array['state_id'] = $row['fk_county'];
+ // TODO Use a cache here to avoid to make select_state in each pass (this make a SQL and lot of logs)
$row_array['states'] = $formcompany->select_state('',$row['fk_country'],'');
array_push($return_arr,$row_array);
diff --git a/htdocs/core/boxes/box_actions.php b/htdocs/core/boxes/box_actions.php
index f6d9d03dccf..9bcfb002bb6 100644
--- a/htdocs/core/boxes/box_actions.php
+++ b/htdocs/core/boxes/box_actions.php
@@ -37,7 +37,11 @@ class box_actions extends ModeleBoxes
var $boxlabel="BoxLastActions";
var $depends = array("agenda");
- var $db;
+ /**
+ * @var DoliDB Database handler.
+ */
+ public $db;
+
var $param;
var $info_box_head = array();
@@ -256,6 +260,5 @@ class box_actions extends ModeleBoxes
return '';
}
-
}
diff --git a/htdocs/core/boxes/box_activity.php b/htdocs/core/boxes/box_activity.php
index 4fb8cc19c82..bd3163268ac 100644
--- a/htdocs/core/boxes/box_activity.php
+++ b/htdocs/core/boxes/box_activity.php
@@ -35,7 +35,11 @@ class box_activity extends ModeleBoxes
var $boxlabel='BoxGlobalActivity';
var $depends = array("facture");
- var $db;
+ /**
+ * @var DoliDB Database handler.
+ */
+ public $db;
+
var $param;
var $enabled = 1;
diff --git a/htdocs/core/boxes/box_bookmarks.php b/htdocs/core/boxes/box_bookmarks.php
index e2a45ffab22..c3a29877104 100644
--- a/htdocs/core/boxes/box_bookmarks.php
+++ b/htdocs/core/boxes/box_bookmarks.php
@@ -33,7 +33,11 @@ class box_bookmarks extends ModeleBoxes
var $boxlabel="BoxMyLastBookmarks";
var $depends = array("bookmark");
- var $db;
+ /**
+ * @var DoliDB Database handler.
+ */
+ public $db;
+
var $param;
var $info_box_head = array();
@@ -157,6 +161,5 @@ class box_bookmarks extends ModeleBoxes
{
return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
}
-
}
diff --git a/htdocs/core/boxes/box_clients.php b/htdocs/core/boxes/box_clients.php
index 7ab2de66a7b..96ccd7b675d 100644
--- a/htdocs/core/boxes/box_clients.php
+++ b/htdocs/core/boxes/box_clients.php
@@ -37,7 +37,11 @@ class box_clients extends ModeleBoxes
var $boxlabel="BoxLastCustomers";
var $depends = array("societe");
- var $db;
+ /**
+ * @var DoliDB Database handler.
+ */
+ public $db;
+
var $enabled = 1;
var $info_box_head = array();
@@ -159,7 +163,6 @@ class box_clients extends ModeleBoxes
'text' => $langs->trans("ReadPermissionNotAllowed")
);
}
-
}
/**
@@ -174,6 +177,5 @@ class box_clients extends ModeleBoxes
{
return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
}
-
}
diff --git a/htdocs/core/boxes/box_commandes.php b/htdocs/core/boxes/box_commandes.php
index 9bbde140dbe..5aeb6179207 100644
--- a/htdocs/core/boxes/box_commandes.php
+++ b/htdocs/core/boxes/box_commandes.php
@@ -37,7 +37,11 @@ class box_commandes extends ModeleBoxes
var $boxlabel="BoxLastCustomerOrders";
var $depends = array("commande");
- var $db;
+ /**
+ * @var DoliDB Database handler.
+ */
+ public $db;
+
var $param;
var $info_box_head = array();
@@ -198,6 +202,5 @@ class box_commandes extends ModeleBoxes
{
return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
}
-
}
diff --git a/htdocs/core/boxes/box_comptes.php b/htdocs/core/boxes/box_comptes.php
index 52f8e6c7d9e..8606d9b91f7 100644
--- a/htdocs/core/boxes/box_comptes.php
+++ b/htdocs/core/boxes/box_comptes.php
@@ -38,7 +38,11 @@ class box_comptes extends ModeleBoxes
var $boxlabel="BoxCurrentAccounts";
var $depends = array("banque"); // Box active if module banque active
- var $db;
+ /**
+ * @var DoliDB Database handler.
+ */
+ public $db;
+
var $param;
var $enabled = 1;
@@ -170,7 +174,6 @@ class box_comptes extends ModeleBoxes
'text' => $langs->trans("ReadPermissionNotAllowed")
);
}
-
}
/**
@@ -185,6 +188,5 @@ class box_comptes extends ModeleBoxes
{
return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
}
-
}
diff --git a/htdocs/core/boxes/box_contacts.php b/htdocs/core/boxes/box_contacts.php
index a8dc7f1231d..4feb101c090 100644
--- a/htdocs/core/boxes/box_contacts.php
+++ b/htdocs/core/boxes/box_contacts.php
@@ -39,7 +39,11 @@ class box_contacts extends ModeleBoxes
var $boxlabel="BoxLastContacts";
var $depends = array("societe");
- var $db;
+ /**
+ * @var DoliDB Database handler.
+ */
+ public $db;
+
var $param;
var $info_box_head = array();
@@ -185,6 +189,5 @@ class box_contacts extends ModeleBoxes
{
return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
}
-
}
diff --git a/htdocs/core/boxes/box_contracts.php b/htdocs/core/boxes/box_contracts.php
index 49d6df67d7f..6f9a62e1063 100644
--- a/htdocs/core/boxes/box_contracts.php
+++ b/htdocs/core/boxes/box_contracts.php
@@ -36,7 +36,11 @@ class box_contracts extends ModeleBoxes
var $boxlabel="BoxLastContracts";
var $depends = array("contrat"); // conf->contrat->enabled
- var $db;
+ /**
+ * @var DoliDB Database handler.
+ */
+ public $db;
+
var $param;
var $info_box_head = array();
@@ -181,6 +185,5 @@ class box_contracts extends ModeleBoxes
{
return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
}
-
}
diff --git a/htdocs/core/boxes/box_external_rss.php b/htdocs/core/boxes/box_external_rss.php
index 01eb4ac8893..f08c809627d 100644
--- a/htdocs/core/boxes/box_external_rss.php
+++ b/htdocs/core/boxes/box_external_rss.php
@@ -39,7 +39,11 @@ class box_external_rss extends ModeleBoxes
var $boxlabel="BoxLastRssInfos";
var $depends = array("externalrss");
- var $db;
+ /**
+ * @var DoliDB Database handler.
+ */
+ public $db;
+
var $paramdef; // Params of box definition (not user params)
var $info_box_head = array();
@@ -194,6 +198,5 @@ class box_external_rss extends ModeleBoxes
{
return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
}
-
}
diff --git a/htdocs/core/boxes/box_factures.php b/htdocs/core/boxes/box_factures.php
index a5da051d9d7..348bd7b9fe5 100644
--- a/htdocs/core/boxes/box_factures.php
+++ b/htdocs/core/boxes/box_factures.php
@@ -35,7 +35,11 @@ class box_factures extends ModeleBoxes
var $boxlabel="BoxLastCustomerBills";
var $depends = array("facture");
- var $db;
+ /**
+ * @var DoliDB Database handler.
+ */
+ public $db;
+
var $param;
var $info_box_head = array();
@@ -202,5 +206,4 @@ class box_factures extends ModeleBoxes
{
return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
}
-
}
diff --git a/htdocs/core/boxes/box_factures_fourn.php b/htdocs/core/boxes/box_factures_fourn.php
index 00df80f334b..c865cf185c4 100644
--- a/htdocs/core/boxes/box_factures_fourn.php
+++ b/htdocs/core/boxes/box_factures_fourn.php
@@ -36,7 +36,11 @@ class box_factures_fourn extends ModeleBoxes
var $boxlabel="BoxLastSupplierBills";
var $depends = array("facture","fournisseur");
- var $db;
+ /**
+ * @var DoliDB Database handler.
+ */
+ public $db;
+
var $param;
var $info_box_head = array();
@@ -214,6 +218,5 @@ class box_factures_fourn extends ModeleBoxes
{
return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
}
-
}
diff --git a/htdocs/core/boxes/box_factures_fourn_imp.php b/htdocs/core/boxes/box_factures_fourn_imp.php
index 1f894be3309..e8dedf59c41 100644
--- a/htdocs/core/boxes/box_factures_fourn_imp.php
+++ b/htdocs/core/boxes/box_factures_fourn_imp.php
@@ -35,7 +35,11 @@ class box_factures_fourn_imp extends ModeleBoxes
var $boxlabel = "BoxOldestUnpaidSupplierBills";
var $depends = array("facture","fournisseur");
- var $db;
+ /**
+ * @var DoliDB Database handler.
+ */
+ public $db;
+
var $param;
var $info_box_head = array();
@@ -187,7 +191,6 @@ class box_factures_fourn_imp extends ModeleBoxes
'text' => $langs->trans("ReadPermissionNotAllowed")
);
}
-
}
/**
@@ -202,6 +205,5 @@ class box_factures_fourn_imp extends ModeleBoxes
{
return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
}
-
}
diff --git a/htdocs/core/boxes/box_factures_imp.php b/htdocs/core/boxes/box_factures_imp.php
index ea483e223c1..54d265bf6af 100644
--- a/htdocs/core/boxes/box_factures_imp.php
+++ b/htdocs/core/boxes/box_factures_imp.php
@@ -38,7 +38,11 @@ class box_factures_imp extends ModeleBoxes
var $boxlabel="BoxOldestUnpaidCustomerBills";
var $depends = array("facture");
- var $db;
+ /**
+ * @var DoliDB Database handler.
+ */
+ public $db;
+
var $param;
var $info_box_head = array();
@@ -205,5 +209,4 @@ class box_factures_imp extends ModeleBoxes
{
return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
}
-
}
diff --git a/htdocs/core/boxes/box_ficheinter.php b/htdocs/core/boxes/box_ficheinter.php
index ef7ba62c15c..76d1414f53f 100644
--- a/htdocs/core/boxes/box_ficheinter.php
+++ b/htdocs/core/boxes/box_ficheinter.php
@@ -36,7 +36,11 @@ class box_ficheinter extends ModeleBoxes
var $boxlabel="BoxFicheInter";
var $depends = array("ficheinter"); // conf->contrat->enabled
- var $db;
+ /**
+ * @var DoliDB Database handler.
+ */
+ public $db;
+
var $param;
var $info_box_head = array();
@@ -166,6 +170,5 @@ class box_ficheinter extends ModeleBoxes
{
return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
}
-
}
diff --git a/htdocs/core/boxes/box_fournisseurs.php b/htdocs/core/boxes/box_fournisseurs.php
index 32ffd1f5618..0ca14fae7f5 100644
--- a/htdocs/core/boxes/box_fournisseurs.php
+++ b/htdocs/core/boxes/box_fournisseurs.php
@@ -36,7 +36,11 @@ class box_fournisseurs extends ModeleBoxes
var $boxlabel="BoxLastSuppliers";
var $depends = array("fournisseur");
- var $db;
+ /**
+ * @var DoliDB Database handler.
+ */
+ public $db;
+
var $param;
var $info_box_head = array();
@@ -146,7 +150,6 @@ class box_fournisseurs extends ModeleBoxes
'text' => $langs->trans("ReadPermissionNotAllowed")
);
}
-
}
/**
@@ -161,6 +164,5 @@ class box_fournisseurs extends ModeleBoxes
{
return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
}
-
}
diff --git a/htdocs/core/boxes/box_goodcustomers.php b/htdocs/core/boxes/box_goodcustomers.php
index 8e4ec988144..16668987a40 100644
--- a/htdocs/core/boxes/box_goodcustomers.php
+++ b/htdocs/core/boxes/box_goodcustomers.php
@@ -38,7 +38,11 @@ class box_goodcustomers extends ModeleBoxes
var $boxlabel="BoxGoodCustomers";
var $depends = array("societe");
- var $db;
+ /**
+ * @var DoliDB Database handler.
+ */
+ public $db;
+
var $enabled = 1;
var $info_box_head = array();
@@ -155,7 +159,6 @@ class box_goodcustomers extends ModeleBoxes
'text' => $langs->trans("ReadPermissionNotAllowed")
);
}
-
}
/**
diff --git a/htdocs/core/boxes/box_graph_invoices_permonth.php b/htdocs/core/boxes/box_graph_invoices_permonth.php
index abbdc7b7c71..c22163779a8 100644
--- a/htdocs/core/boxes/box_graph_invoices_permonth.php
+++ b/htdocs/core/boxes/box_graph_invoices_permonth.php
@@ -33,7 +33,10 @@ class box_graph_invoices_permonth extends ModeleBoxes
var $boxlabel="BoxCustomersInvoicesPerMonth";
var $depends = array("facture");
- var $db;
+ /**
+ * @var DoliDB Database handler.
+ */
+ public $db;
var $info_box_head = array();
var $info_box_contents = array();
@@ -277,6 +280,5 @@ class box_graph_invoices_permonth extends ModeleBoxes
{
return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
}
-
}
diff --git a/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php b/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php
index 53d9ce08059..a7f504b2d01 100644
--- a/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php
+++ b/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php
@@ -33,7 +33,10 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes
var $boxlabel="BoxSuppliersInvoicesPerMonth";
var $depends = array("fournisseur");
- var $db;
+ /**
+ * @var DoliDB Database handler.
+ */
+ public $db;
var $info_box_head = array();
var $info_box_contents = array();
@@ -276,6 +279,5 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes
{
return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
}
-
}
diff --git a/htdocs/core/boxes/box_graph_orders_permonth.php b/htdocs/core/boxes/box_graph_orders_permonth.php
index 05a0ff498ec..329fef77fba 100644
--- a/htdocs/core/boxes/box_graph_orders_permonth.php
+++ b/htdocs/core/boxes/box_graph_orders_permonth.php
@@ -33,7 +33,10 @@ class box_graph_orders_permonth extends ModeleBoxes
var $boxlabel="BoxCustomersOrdersPerMonth";
var $depends = array("commande");
- var $db;
+ /**
+ * @var DoliDB Database handler.
+ */
+ public $db;
var $info_box_head = array();
var $info_box_contents = array();
@@ -275,6 +278,5 @@ class box_graph_orders_permonth extends ModeleBoxes
{
return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
}
-
}
diff --git a/htdocs/core/boxes/box_graph_orders_supplier_permonth.php b/htdocs/core/boxes/box_graph_orders_supplier_permonth.php
index e88ed46be72..de962149cdf 100644
--- a/htdocs/core/boxes/box_graph_orders_supplier_permonth.php
+++ b/htdocs/core/boxes/box_graph_orders_supplier_permonth.php
@@ -33,7 +33,10 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes
var $boxlabel="BoxSuppliersOrdersPerMonth";
var $depends = array("fournisseur");
- var $db;
+ /**
+ * @var DoliDB Database handler.
+ */
+ public $db;
var $info_box_head = array();
var $info_box_contents = array();
@@ -274,6 +277,5 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes
{
return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
}
-
}
diff --git a/htdocs/core/boxes/box_graph_product_distribution.php b/htdocs/core/boxes/box_graph_product_distribution.php
index 39a7a3984d2..42afa4fbfe0 100644
--- a/htdocs/core/boxes/box_graph_product_distribution.php
+++ b/htdocs/core/boxes/box_graph_product_distribution.php
@@ -33,7 +33,11 @@ class box_graph_product_distribution extends ModeleBoxes
var $boxlabel="BoxProductDistribution";
var $depends = array("product|service","facture|propal|commande");
- var $db;
+ /**
+ * @var DoliDB Database handler.
+ */
+ public $db;
+
var $param;
var $info_box_head = array();
@@ -397,7 +401,6 @@ class box_graph_product_distribution extends ModeleBoxes
'text' => $mesg
);
}
-
}
/**
@@ -412,6 +415,5 @@ class box_graph_product_distribution extends ModeleBoxes
{
return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
}
-
}
diff --git a/htdocs/core/boxes/box_graph_propales_permonth.php b/htdocs/core/boxes/box_graph_propales_permonth.php
index bddf4a27e64..c19235c2fb2 100644
--- a/htdocs/core/boxes/box_graph_propales_permonth.php
+++ b/htdocs/core/boxes/box_graph_propales_permonth.php
@@ -33,7 +33,10 @@ class box_graph_propales_permonth extends ModeleBoxes
var $boxlabel="BoxProposalsPerMonth";
var $depends = array("propal");
- var $db;
+ /**
+ * @var DoliDB Database handler.
+ */
+ public $db;
var $info_box_head = array();
var $info_box_contents = array();
@@ -71,6 +74,8 @@ class box_graph_propales_permonth extends ModeleBoxes
//include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
//$propalstatic=new Propal($db);
+ $langs->load("propal");
+
$text = $langs->trans("BoxProposalsPerMonth",$max);
$this->info_box_head = array(
'text' => $text,
@@ -276,6 +281,5 @@ class box_graph_propales_permonth extends ModeleBoxes
{
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 a0613d58f3e..9ce7dd91605 100644
--- a/htdocs/core/boxes/box_last_modified_ticket.php
+++ b/htdocs/core/boxes/box_last_modified_ticket.php
@@ -34,7 +34,12 @@ class box_last_modified_ticket extends ModeleBoxes
public $boximg = "ticket";
public $boxlabel;
public $depends = array("ticket");
+
+ /**
+ * @var DoliDB Database handler.
+ */
public $db;
+
public $param;
public $info_box_head = array();
public $info_box_contents = array();
diff --git a/htdocs/core/boxes/box_last_ticket.php b/htdocs/core/boxes/box_last_ticket.php
index 2dfa71af904..a824a707168 100644
--- a/htdocs/core/boxes/box_last_ticket.php
+++ b/htdocs/core/boxes/box_last_ticket.php
@@ -34,7 +34,12 @@ class box_last_ticket extends ModeleBoxes
public $boximg = "ticket";
public $boxlabel;
public $depends = array("ticket");
+
+ /**
+ * @var DoliDB Database handler.
+ */
public $db;
+
public $param;
public $info_box_head = array();
public $info_box_contents = array();
diff --git a/htdocs/core/boxes/box_lastlogin.php b/htdocs/core/boxes/box_lastlogin.php
index 05bd3043b0a..c8149c6384b 100644
--- a/htdocs/core/boxes/box_lastlogin.php
+++ b/htdocs/core/boxes/box_lastlogin.php
@@ -35,7 +35,11 @@ class box_lastlogin extends ModeleBoxes
var $boxlabel='BoxLoginInformation';
var $depends = array("user");
- var $db;
+ /**
+ * @var DoliDB Database handler.
+ */
+ public $db;
+
var $param;
var $enabled = 1;
@@ -94,7 +98,6 @@ class box_lastlogin extends ModeleBoxes
'td' => '',
'text' => $tmp,
);
-
}
diff --git a/htdocs/core/boxes/box_members.php b/htdocs/core/boxes/box_members.php
index e5819f0f14c..6f7e62aa457 100644
--- a/htdocs/core/boxes/box_members.php
+++ b/htdocs/core/boxes/box_members.php
@@ -37,7 +37,11 @@ class box_members extends ModeleBoxes
var $boxlabel="BoxLastMembers";
var $depends = array("adherent");
- var $db;
+ /**
+ * @var DoliDB Database handler.
+ */
+ public $db;
+
var $param;
var $enabled = 1;
@@ -164,7 +168,6 @@ class box_members extends ModeleBoxes
'text' => $langs->trans("ReadPermissionNotAllowed")
);
}
-
}
/**
@@ -179,6 +182,5 @@ class box_members extends ModeleBoxes
{
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 53449afceeb..cadda2b8058 100644
--- a/htdocs/core/boxes/box_produits.php
+++ b/htdocs/core/boxes/box_produits.php
@@ -38,7 +38,11 @@ class box_produits extends ModeleBoxes
var $boxlabel="BoxLastProducts";
var $depends = array("produit");
- var $db;
+ /**
+ * @var DoliDB Database handler.
+ */
+ public $db;
+
var $param;
var $info_box_head = array();
@@ -226,6 +230,5 @@ class box_produits extends ModeleBoxes
{
return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
}
-
}
diff --git a/htdocs/core/boxes/box_produits_alerte_stock.php b/htdocs/core/boxes/box_produits_alerte_stock.php
index ee49e9e4534..648da118e09 100644
--- a/htdocs/core/boxes/box_produits_alerte_stock.php
+++ b/htdocs/core/boxes/box_produits_alerte_stock.php
@@ -40,7 +40,11 @@ class box_produits_alerte_stock extends ModeleBoxes
var $boxlabel="BoxProductsAlertStock";
var $depends = array("produit");
- var $db;
+ /**
+ * @var DoliDB Database handler.
+ */
+ public $db;
+
var $param;
var $info_box_head = array();
@@ -238,6 +242,5 @@ class box_produits_alerte_stock extends ModeleBoxes
{
return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
}
-
}
diff --git a/htdocs/core/boxes/box_project.php b/htdocs/core/boxes/box_project.php
index 976cbf1766c..a48543a00f6 100644
--- a/htdocs/core/boxes/box_project.php
+++ b/htdocs/core/boxes/box_project.php
@@ -23,7 +23,7 @@
* \ingroup projet
* \brief Module to show Projet activity of the current Year
*/
-include_once(DOL_DOCUMENT_ROOT."/core/boxes/modules_boxes.php");
+include_once DOL_DOCUMENT_ROOT."/core/boxes/modules_boxes.php";
/**
* Class to manage the box to show last projet
@@ -34,7 +34,12 @@ class box_project extends ModeleBoxes
var $boximg="object_projectpub";
var $boxlabel;
//var $depends = array("projet");
- var $db;
+
+ /**
+ * @var DoliDB Database handler.
+ */
+ public $db;
+
var $param;
var $info_box_head = array();
@@ -49,8 +54,9 @@ class box_project extends ModeleBoxes
function __construct($db,$param='')
{
global $user, $langs;
- $langs->load("boxes");
- $langs->load("projects");
+
+ // Load translation files required by the page
+ $langs->loadLangs(array('boxes', 'projects'));
$this->db = $db;
$this->boxlabel="Projects";
@@ -80,7 +86,7 @@ class box_project extends ModeleBoxes
// list the summary of the orders
if ($user->rights->projet->lire) {
- include_once(DOL_DOCUMENT_ROOT.'/projet/class/project.class.php');
+ include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
$projectstatic = new Project($this->db);
$socid=$user->societe_id;
@@ -179,7 +185,6 @@ class box_project extends ModeleBoxes
'td' => '',
'text' => " ",
);
-
}
/**
diff --git a/htdocs/core/boxes/box_propales.php b/htdocs/core/boxes/box_propales.php
index 8dad41f64a1..6db4ac11250 100644
--- a/htdocs/core/boxes/box_propales.php
+++ b/htdocs/core/boxes/box_propales.php
@@ -37,7 +37,11 @@ class box_propales extends ModeleBoxes
var $boxlabel="BoxLastProposals";
var $depends = array("propal"); // conf->propal->enabled
- var $db;
+ /**
+ * @var DoliDB Database handler.
+ */
+ public $db;
+
var $param;
var $info_box_head = array();
@@ -188,6 +192,5 @@ class box_propales extends ModeleBoxes
{
return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
}
-
}
diff --git a/htdocs/core/boxes/box_prospect.php b/htdocs/core/boxes/box_prospect.php
index 3186d0d30ce..629da790f3c 100644
--- a/htdocs/core/boxes/box_prospect.php
+++ b/htdocs/core/boxes/box_prospect.php
@@ -39,7 +39,11 @@ class box_prospect extends ModeleBoxes
var $boxlabel="BoxLastProspects";
var $depends = array("societe");
- var $db;
+ /**
+ * @var DoliDB Database handler.
+ */
+ public $db;
+
var $enabled = 1;
var $info_box_head = array();
@@ -176,6 +180,5 @@ class box_prospect extends ModeleBoxes
{
return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
}
-
}
diff --git a/htdocs/core/boxes/box_services_contracts.php b/htdocs/core/boxes/box_services_contracts.php
index 44a1ca020b5..41d287d0c37 100644
--- a/htdocs/core/boxes/box_services_contracts.php
+++ b/htdocs/core/boxes/box_services_contracts.php
@@ -37,7 +37,11 @@ class box_services_contracts extends ModeleBoxes
var $boxlabel="BoxLastProductsInContract";
var $depends = array("service","contrat");
- var $db;
+ /**
+ * @var DoliDB Database handler.
+ */
+ public $db;
+
var $param;
var $info_box_head = array();
@@ -218,7 +222,6 @@ class box_services_contracts extends ModeleBoxes
'text' => $langs->trans("ReadPermissionNotAllowed")
);
}
-
}
/**
@@ -233,6 +236,5 @@ class box_services_contracts extends ModeleBoxes
{
return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
}
-
}
diff --git a/htdocs/core/boxes/box_services_expired.php b/htdocs/core/boxes/box_services_expired.php
index 72d4390a2e2..afc087ad715 100644
--- a/htdocs/core/boxes/box_services_expired.php
+++ b/htdocs/core/boxes/box_services_expired.php
@@ -35,7 +35,11 @@ class box_services_expired extends ModeleBoxes
var $boxlabel="BoxOldestExpiredServices";
var $depends = array("contrat"); // conf->propal->enabled
- var $db;
+ /**
+ * @var DoliDB Database handler.
+ */
+ public $db;
+
var $param;
var $info_box_head = array();
@@ -180,6 +184,5 @@ class box_services_expired extends ModeleBoxes
{
return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
}
-
- }
+}
diff --git a/htdocs/core/boxes/box_supplier_orders.php b/htdocs/core/boxes/box_supplier_orders.php
index 895f411e3d6..97b4bf8feec 100644
--- a/htdocs/core/boxes/box_supplier_orders.php
+++ b/htdocs/core/boxes/box_supplier_orders.php
@@ -36,7 +36,11 @@ class box_supplier_orders extends ModeleBoxes
var $boxlabel="BoxLatestSupplierOrders";
var $depends = array("fournisseur");
- var $db;
+ /**
+ * @var DoliDB Database handler.
+ */
+ public $db;
+
var $param;
var $info_box_head = array();
var $info_box_contents = array();
@@ -184,6 +188,5 @@ class box_supplier_orders extends ModeleBoxes
{
return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
}
-
}
diff --git a/htdocs/core/boxes/box_task.php b/htdocs/core/boxes/box_task.php
index 3a665243073..b85ed0f4d8b 100644
--- a/htdocs/core/boxes/box_task.php
+++ b/htdocs/core/boxes/box_task.php
@@ -22,8 +22,8 @@
* \brief Module to Task activity of the current year
*/
-include_once(DOL_DOCUMENT_ROOT."/core/boxes/modules_boxes.php");
-require_once(DOL_DOCUMENT_ROOT."/core/lib/date.lib.php");
+include_once DOL_DOCUMENT_ROOT."/core/boxes/modules_boxes.php";
+require_once DOL_DOCUMENT_ROOT."/core/lib/date.lib.php";
/**
@@ -31,16 +31,21 @@ require_once(DOL_DOCUMENT_ROOT."/core/lib/date.lib.php");
*/
class box_task extends ModeleBoxes
{
- var $boxcode="projet";
- var $boximg="object_projecttask";
- var $boxlabel;
- //var $depends = array("projet");
- var $db;
- var $param;
- var $enabled = 0; // Disabled because bugged.
+ public $boxcode="projet";
+ public $boximg="object_projecttask";
+ public $boxlabel;
+ //public $depends = array("projet");
- var $info_box_head = array();
- var $info_box_contents = array();
+ /**
+ * @var DoliDB Database handler.
+ */
+ public $db;
+
+ public $param;
+ public $enabled = 0; // Disabled because bugged.
+
+ public $info_box_head = array();
+ public $info_box_contents = array();
/**
@@ -52,8 +57,10 @@ class box_task extends ModeleBoxes
function __construct($db,$param='')
{
global $user, $langs;
- $langs->load("boxes");
- $langs->load("projects");
+
+ // Load translation files required by the page
+ $langs->loadLangs(array('boxes', 'projects'));
+
$this->boxlabel="Tasks";
$this->db = $db;
@@ -75,7 +82,7 @@ class box_task extends ModeleBoxes
$totalMnt = 0;
$totalnb = 0;
$totalDuree=0;
- include_once(DOL_DOCUMENT_ROOT."/projet/class/task.class.php");
+ include_once DOL_DOCUMENT_ROOT."/projet/class/task.class.php";
$taskstatic=new Task($db);
@@ -126,13 +133,12 @@ class box_task extends ModeleBoxes
}
- // Add the sum à the bottom of the boxes
+ // Add the sum at the bottom of the boxes
$this->info_box_contents[$i][] = array('tr' => 'class="liste_total"', 'td' => '', 'text' => $langs->trans("Total")." ".$textHead);
$this->info_box_contents[$i][] = array('td' => 'align="right" ', 'text' => number_format($totalnb, 0, ',', ' ')." ".$langs->trans("Tasks"));
$this->info_box_contents[$i][] = array('td' => 'align="right" ', 'text' => ConvertSecondToTime($totalplannedtot,'all',25200,5));
$this->info_box_contents[$i][] = array('td' => 'align="right" ', 'text' => ConvertSecondToTime($totaldurationtot,'all',25200,5));
$this->info_box_contents[$i][] = array('td' => '', 'text' => "");
-
}
/**
diff --git a/htdocs/core/boxes/modules_boxes.php b/htdocs/core/boxes/modules_boxes.php
index 61af58a4b8b..4377b90d17a 100644
--- a/htdocs/core/boxes/modules_boxes.php
+++ b/htdocs/core/boxes/modules_boxes.php
@@ -31,7 +31,7 @@
*
* Boxes parent class
*/
-class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" boxes
+class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" boxes
{
/**
* @var DoliDB Database handler
@@ -503,8 +503,6 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty"
}
return $widget;
}
-
-
}
diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php
index f5382a91550..45998a78869 100644
--- a/htdocs/core/class/CMailFile.class.php
+++ b/htdocs/core/class/CMailFile.class.php
@@ -471,7 +471,6 @@ class CMailFile
// --------------------------------------
$this->error = 'Bad value for sendmode';
}
-
}
@@ -828,6 +827,7 @@ class CMailFile
return '=?'.$conf->file->character_set_client.'?B?'.base64_encode($stringtoencode).'?=';
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Read a file on disk and return encoded content for emails (mode = 'mail')
*
@@ -836,6 +836,7 @@ class CMailFile
*/
function _encode_file($sourcefile)
{
+ // phpcs:enable
$newsourcefile=dol_osencode($sourcefile);
if (is_readable($newsourcefile))
@@ -853,6 +854,7 @@ class CMailFile
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Write content of a SMTP request into a dump file (mode = all)
* Used for debugging.
@@ -862,6 +864,7 @@ class CMailFile
*/
function dump_mail()
{
+ // phpcs:enable
global $conf,$dolibarr_main_data_root;
if (@is_writeable($dolibarr_main_data_root)) // Avoid fatal error on fopen with open_basedir
@@ -946,6 +949,7 @@ class CMailFile
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Create SMTP headers (mode = 'mail')
*
@@ -953,6 +957,7 @@ class CMailFile
*/
function write_smtpheaders()
{
+ // phpcs:enable
global $conf;
$out = "";
@@ -1008,6 +1013,7 @@ class CMailFile
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Create header MIME (mode = 'mail')
*
@@ -1017,6 +1023,7 @@ class CMailFile
*/
function write_mimeheaders($filename_list, $mimefilename_list)
{
+ // phpcs:enable
$mimedone=0;
$out = "";
@@ -1037,6 +1044,7 @@ class CMailFile
return $out;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Return email content (mode = 'mail')
*
@@ -1045,6 +1053,7 @@ class CMailFile
*/
function write_body($msgtext)
{
+ // phpcs:enable
global $conf;
$out='';
@@ -1137,6 +1146,7 @@ class CMailFile
return $out;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Attach file to email (mode = 'mail')
*
@@ -1147,6 +1157,7 @@ class CMailFile
*/
function write_files($filename_list,$mimetype_list,$mimefilename_list)
{
+ // phpcs:enable
$out = '';
$filename_list_size=count($filename_list);
@@ -1184,6 +1195,7 @@ class CMailFile
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Attach an image to email (mode = 'mail')
*
@@ -1192,6 +1204,7 @@ class CMailFile
*/
function write_images($images_list)
{
+ // phpcs:enable
$out = '';
if ($images_list)
@@ -1215,6 +1228,7 @@ class CMailFile
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Try to create a socket connection
*
@@ -1224,6 +1238,7 @@ class CMailFile
*/
function check_server_port($host,$port)
{
+ // phpcs:enable
global $conf;
$_retVal=0;
@@ -1278,6 +1293,7 @@ class CMailFile
return $_retVal;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* This function has been modified as provided by SirSir to allow multiline responses when
* using SMTP Extensions.
@@ -1288,6 +1304,7 @@ class CMailFile
*/
function server_parse($socket, $response)
{
+ // phpcs:enable
$_retVal = true; // Indicates if Object was created or not
$server_response = '';
@@ -1512,4 +1529,3 @@ class CMailFile
return $ret;
}
}
-
diff --git a/htdocs/core/class/CSMSFile.class.php b/htdocs/core/class/CSMSFile.class.php
index 0a149feabf4..c2512af70ef 100644
--- a/htdocs/core/class/CSMSFile.class.php
+++ b/htdocs/core/class/CSMSFile.class.php
@@ -192,6 +192,7 @@ class CSMSFile
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Write content of a SendSms request into a dump file (mode = all)
* Used for debugging.
@@ -200,6 +201,7 @@ class CSMSFile
*/
function dump_sms()
{
+ // phpcs:enable
global $conf,$dolibarr_main_data_root;
if (@is_writeable($dolibarr_main_data_root)) // Avoid fatal error on fopen with open_basedir
@@ -221,6 +223,7 @@ class CSMSFile
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Write content of a SendSms result into a dump file (mode = all)
* Used for debugging.
@@ -230,6 +233,7 @@ class CSMSFile
*/
function dump_sms_result($result)
{
+ // phpcs:enable
global $conf,$dolibarr_main_data_root;
if (@is_writeable($dolibarr_main_data_root)) // Avoid fatal error on fopen with open_basedir
@@ -244,6 +248,4 @@ class CSMSFile
@chmod($outputfile, octdec($conf->global->MAIN_UMASK));
}
}
-
}
-
diff --git a/htdocs/core/class/antivir.class.php b/htdocs/core/class/antivir.class.php
index b5f4f0e5539..d18501d54d9 100644
--- a/htdocs/core/class/antivir.class.php
+++ b/htdocs/core/class/antivir.class.php
@@ -26,15 +26,26 @@
*/
/**
- * \class AntiVir
- * \brief Class to scan for virus
+ * Class to scan for virus
*/
class AntiVir
{
- var $error;
- var $errors;
+ /**
+ * @var string Error code (or message)
+ */
+ public $error='';
+
+ /**
+ * @var string[] Error codes (or messages)
+ */
+ public $errors = array();
+
var $output;
- var $db;
+
+ /**
+ * @var DoliDB Database handler.
+ */
+ public $db;
/**
* Constructor
@@ -46,6 +57,7 @@ class AntiVir
$this->db=$db;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Scan a file with antivirus.
* This function runs the command defined in setup. This antivirus command must return 0 if OK.
@@ -56,13 +68,14 @@ class AntiVir
*/
function dol_avscan_file($file)
{
+ // phpcs:enable
global $conf;
$return = 0;
if (preg_match('/\.virus$/i', $file))
{
- $this->errors='File has an extension saying file is a virus';
+ $this->errors[] = 'File has an extension saying file is a virus';
return -97;
}
@@ -168,6 +181,4 @@ class AntiVir
return $ret;
}
-
}
-
diff --git a/htdocs/core/class/canvas.class.php b/htdocs/core/class/canvas.class.php
index d9c496add4f..a4665701661 100644
--- a/htdocs/core/class/canvas.class.php
+++ b/htdocs/core/class/canvas.class.php
@@ -28,9 +28,20 @@
*/
class Canvas
{
- var $db;
- var $error;
- var $errors=array();
+ /**
+ * @var DoliDB Database handler.
+ */
+ public $db;
+
+ /**
+ * @var string Error code (or message)
+ */
+ public $error='';
+
+ /**
+ * @var string[] Error codes (or messages)
+ */
+ public $errors = array();
var $actiontype;
@@ -122,6 +133,7 @@ class Canvas
//print ' => template_dir='.$this->template_dir.'
';
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Shared method for canvas to assign values for templates
*
@@ -132,6 +144,7 @@ class Canvas
*/
function assign_values(&$action='view', $id=0, $ref='')
{
+ // phpcs:enable
if (method_exists($this->control,'assign_values')) $this->control->assign_values($action, $id, $ref);
}
@@ -149,6 +162,7 @@ class Canvas
else return 0;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Display a canvas page. This will include the template for output.
* Variables used by templates may have been defined or loaded before into the assign_values function.
@@ -158,6 +172,7 @@ class Canvas
*/
function display_canvas($action)
{
+ // phpcs:enable
global $db, $conf, $langs, $user, $canvas;
global $form, $formfile;
@@ -197,5 +212,4 @@ class Canvas
return $ret;
}
}
-
}
diff --git a/htdocs/core/class/ccountry.class.php b/htdocs/core/class/ccountry.class.php
index 7964510c91c..2f9a8636c8b 100644
--- a/htdocs/core/class/ccountry.class.php
+++ b/htdocs/core/class/ccountry.class.php
@@ -32,17 +32,38 @@
*/
class Ccountry // extends CommonObject
{
- var $db; //!< To store db handler
- var $error; //!< To return error code (or message)
- var $errors=array(); //!< To return several error codes (or messages)
+ /**
+ * @var DoliDB Database handler.
+ */
+ public $db;
+
+ /**
+ * @var string Error code (or message)
+ */
+ public $error='';
+
+ /**
+ * @var string[] Error codes (or messages)
+ */
+ public $errors = array();
+
//var $element='ccountry'; //!< Id that identify managed objects
//var $table_element='ccountry'; //!< Name of table without prefix where object is stored
- var $id;
- var $code;
- var $code_iso;
- var $label;
- var $active;
+ /**
+ * @var int ID
+ */
+ public $id;
+
+ public $code;
+ public $code_iso;
+
+ /**
+ * @var string Countries label
+ */
+ public $label;
+
+ public $active;
@@ -312,5 +333,4 @@ class Ccountry // extends CommonObject
return 1;
}
}
-
}
diff --git a/htdocs/core/class/comment.class.php b/htdocs/core/class/comment.class.php
index 9aeebd575bf..287d260f4d2 100644
--- a/htdocs/core/class/comment.class.php
+++ b/htdocs/core/class/comment.class.php
@@ -1,15 +1,46 @@
.
+ * or see http://www.gnu.org/
+ */
+
/**
* Class to manage comment
*/
class Comment extends CommonObject
{
- public $element='comment'; //!< Id that identify managed objects
- public $table_element='comment'; //!< Name of table without prefix where object is stored
+ /**
+ * @var string ID to identify managed object
+ */
+ public $element='comment';
+
+ /**
+ * @var string Name of table without prefix where object is stored
+ */
+ public $table_element='comment';
+
+ /**
+ * @var int Field with ID of parent key if this field has a parent
+ */
+ public $fk_element ='';
- public $fk_element;
public $element_type;
+ /**
+ * @var string description
+ */
public $description;
public $tms;
@@ -18,6 +49,9 @@ class Comment extends CommonObject
public $fk_user_author;
+ /**
+ * @var int Entity
+ */
public $entity;
public $import_key;
@@ -328,4 +362,4 @@ class Comment extends CommonObject
return count($this->comments);
}
-}
\ No newline at end of file
+}
diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php
index d3d77640540..a818bfe7a2f 100644
--- a/htdocs/core/class/commondocgenerator.class.php
+++ b/htdocs/core/class/commondocgenerator.class.php
@@ -42,11 +42,13 @@ abstract class CommonDocGenerator
*
* @param DoliDB $db Database handler
*/
- public function __construct($db) {
- $this->db = $db;
- }
+ public function __construct($db)
+ {
+ $this->db = $db;
+ }
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Define array with couple subtitution key => subtitution value
*
@@ -56,6 +58,7 @@ abstract class CommonDocGenerator
*/
function get_substitutionarray_user($user,$outputlangs)
{
+ // phpcs:enable
global $conf;
$logotouse=$conf->user->dir_output.'/'.get_exdir($user->id, 2, 0, 1, $user, 'user').'/'.$user->photo;
@@ -83,6 +86,7 @@ abstract class CommonDocGenerator
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Define array with couple subtitution key => subtitution value
*
@@ -92,6 +96,7 @@ abstract class CommonDocGenerator
*/
function get_substitutionarray_mysoc($mysoc,$outputlangs)
{
+ // phpcs:enable
global $conf;
if (empty($mysoc->forme_juridique) && ! empty($mysoc->forme_juridique_code))
@@ -141,6 +146,7 @@ abstract class CommonDocGenerator
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Define array with couple subtitution key => subtitution value
*
@@ -150,6 +156,7 @@ abstract class CommonDocGenerator
*/
function get_substitutionarray_thirdparty($object,$outputlangs)
{
+ // phpcs:enable
global $conf;
if (empty($object->country) && ! empty($object->country_code))
@@ -220,6 +227,7 @@ abstract class CommonDocGenerator
return $array_thirdparty;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Define array with couple subtitution key => subtitution value
*
@@ -228,7 +236,9 @@ abstract class CommonDocGenerator
* @param array_key $array_key Name of the key for return array
* @return array of substitution key->code
*/
- function get_substitutionarray_contact($object, $outputlangs, $array_key = 'object') {
+ function get_substitutionarray_contact($object, $outputlangs, $array_key = 'object')
+ {
+ // phpcs:enable
global $conf;
if(empty($object->country) && ! empty($object->country_code))
@@ -291,6 +301,7 @@ abstract class CommonDocGenerator
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Define array with couple subtitution key => subtitution value
*
@@ -299,6 +310,7 @@ abstract class CommonDocGenerator
*/
function get_substitutionarray_other($outputlangs)
{
+ // phpcs:enable
global $conf;
$now=dol_now('gmt'); // gmt
@@ -327,6 +339,7 @@ abstract class CommonDocGenerator
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Define array with couple substitution key => substitution value
*
@@ -337,6 +350,7 @@ abstract class CommonDocGenerator
*/
function get_substitutionarray_object($object,$outputlangs,$array_key='object')
{
+ // phpcs:enable
global $conf;
$sumpayed=$sumdeposit=$sumcreditnote='';
@@ -473,6 +487,7 @@ abstract class CommonDocGenerator
return $resarray;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Define array with couple substitution key => substitution value
*
@@ -482,11 +497,13 @@ abstract class CommonDocGenerator
*/
function get_substitutionarray_lines($line,$outputlangs)
{
+ // phpcs:enable
global $conf;
$resarray= array(
'line_fulldesc'=>doc_getlinedesc($line,$outputlangs),
'line_product_ref'=>$line->product_ref,
+ 'line_product_ref_fourn'=>$line->ref_fourn, // for supplier doc lines
'line_product_label'=>$line->product_label,
'line_product_type'=>$line->product_type,
'line_desc'=>$line->desc,
@@ -543,12 +560,13 @@ abstract class CommonDocGenerator
$tmpproduct = new Product($this->db);
$result = $tmpproduct->fetch($line->fk_product);
foreach($tmpproduct->array_options as $key=>$label)
- $resarray["line_".$key] = $label;
+ $resarray["line_product_".$key] = $label;
}
return $resarray;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Define array with couple substitution key => substitution value
*
@@ -559,6 +577,7 @@ abstract class CommonDocGenerator
*/
function get_substitutionarray_shipment($object,$outputlangs,$array_key='object')
{
+ // phpcs:enable
global $conf;
dol_include_once('/core/lib/product.lib.php');
$object->list_delivery_methods($object->shipping_method_id);
@@ -596,32 +615,35 @@ abstract class CommonDocGenerator
}
// Retrieve extrafields
- /*if(is_array($object->array_options) && count($object->array_options))
+ if (is_array($object->array_options) && count($object->array_options))
{
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
$extrafields = new ExtraFields($this->db);
- $extralabels = $extrafields->fetch_name_optionals_label('shipment',true);
+ $extralabels = $extrafields->fetch_name_optionals_label('expedition',true);
$object->fetch_optionals();
$array_shipment = $this->fill_substitutionarray_with_extrafields($object,$array_shipment,$extrafields,$array_key,$outputlangs);
- }*/
+ }
+
return $array_shipment;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
- * Define array with couple substitution key => substitution value
+ * Define array with couple substitution key => substitution value
*
- * @param array $line Array of lines
+ * @param ExpeditionLigne $line Object line
* @param Translate $outputlangs Lang object to use for output
* @return array Substitution array
*/
- function get_substitutionarray_shipment_lines($line,$outputlangs)
+ function get_substitutionarray_shipment_lines($line, $outputlangs)
{
- global $conf;
- dol_include_once('/core/lib/product.lib.php');
+ // phpcs:enable
+ global $conf;
+ dol_include_once('/core/lib/product.lib.php');
- return array(
+ $resarray = array(
'line_fulldesc'=>doc_getlinedesc($line,$outputlangs),
'line_product_ref'=>$line->product_ref,
'line_product_label'=>$line->product_label,
@@ -640,9 +662,22 @@ abstract class CommonDocGenerator
'line_surface'=>empty($line->surface) ? '' : $line->surface*$line->qty_shipped.' '.measuring_units_string($line->surface_units, 'surface'),
'line_volume'=>empty($line->volume) ? '' : $line->volume*$line->qty_shipped.' '.measuring_units_string($line->volume_units, 'volume'),
);
+
+ // Retrieve extrafields
+ $extrafieldkey = $line->element;
+ $array_key = "line";
+ require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
+ $extrafields = new ExtraFields($this->db);
+ $extralabels = $extrafields->fetch_name_optionals_label($extrafieldkey, true);
+ $line->fetch_optionals();
+
+ $resarray = $this->fill_substitutionarray_with_extrafields($line, $resarray, $extrafields, $array_key, $outputlangs);
+
+ return $resarray;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Define array with couple subtitution key => subtitution value
*
@@ -651,15 +686,17 @@ abstract class CommonDocGenerator
* @param boolean $recursive Want to fetch child array or child object
* @return array Array of substitution key->code
*/
- function get_substitutionarray_each_var_object(&$object,$outputlangs,$recursive=true) {
+ function get_substitutionarray_each_var_object(&$object,$outputlangs,$recursive=true)
+ {
+ // phpcs:enable
$array_other = array();
- if(!empty($object)) {
+ if (!empty($object)) {
foreach($object as $key => $value) {
- if(!empty($value)) {
- if(!is_array($value) && !is_object($value)) {
+ if (!empty($value)) {
+ if (!is_array($value) && !is_object($value)) {
$array_other['object_'.$key] = $value;
}
- if(is_array($value) && $recursive){
+ if (is_array($value) && $recursive) {
$array_other['object_'.$key] = $this->get_substitutionarray_each_var_object($value,$outputlangs,false);
}
}
@@ -669,6 +706,7 @@ abstract class CommonDocGenerator
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Fill array with couple extrafield key => extrafield value
*
@@ -679,8 +717,9 @@ abstract class CommonDocGenerator
* @param Translate $outputlangs Lang object to use for output
* @return array Substitution array
*/
- function fill_substitutionarray_with_extrafields($object,$array_to_fill,$extrafields,$array_key,$outputlangs)
+ function fill_substitutionarray_with_extrafields($object,$array_to_fill,$extrafields,$array_key,$outputlangs)
{
+ // phpcs:enable
global $conf;
foreach($extrafields->attribute_label as $key=>$label)
{
@@ -722,11 +761,34 @@ abstract class CommonDocGenerator
$array_to_fill=array_merge($array_to_fill,array($array_key.'_options_'.$key.'_locale' => $object->array_options['options_'.$key.'_locale']));
$array_to_fill=array_merge($array_to_fill,array($array_key.'_options_'.$key.'_rfc' => $object->array_options['options_'.$key.'_rfc']));
}
+ else if($extrafields->attribute_type[$key] == 'link')
+ {
+ $id = $object->array_options['options_'.$key];
+ if ($id != "")
+ {
+ $param = $extrafields->attribute_param[$key];
+ $param_list=array_keys($param['options']); // $param_list='ObjectName:classPath'
+ $InfoFieldList = explode(":", $param_list[0]);
+ $classname=$InfoFieldList[0];
+ $classpath=$InfoFieldList[1];
+ if (! empty($classpath))
+ {
+ dol_include_once($InfoFieldList[1]);
+ if ($classname && class_exists($classname))
+ {
+ $tmpobject = new $classname($this->db);
+ $tmpobject->fetch($id);
+ // completely replace the id with the linked object name
+ $object->array_options['options_'.$key] = $tmpobject->name;
+ }
+ }
+ }
+ }
+
$array_to_fill=array_merge($array_to_fill,array($array_key.'_options_'.$key => $object->array_options['options_'.$key]));
}
return $array_to_fill;
-
}
@@ -744,10 +806,9 @@ abstract class CommonDocGenerator
*/
function printRect($pdf, $x, $y, $l, $h, $hidetop=0, $hidebottom=0)
{
- if (empty($hidetop) || $hidetop==-1) $pdf->line($x, $y, $x+$l, $y);
- $pdf->line($x+$l, $y, $x+$l, $y+$h);
- if (empty($hidebottom)) $pdf->line($x+$l, $y+$h, $x, $y+$h);
- $pdf->line($x, $y+$h, $x, $y);
+ if (empty($hidetop) || $hidetop==-1) $pdf->line($x, $y, $x+$l, $y);
+ $pdf->line($x+$l, $y, $x+$l, $y+$h);
+ if (empty($hidebottom)) $pdf->line($x+$l, $y+$h, $x, $y+$h);
+ $pdf->line($x, $y+$h, $x, $y);
}
}
-
diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php
index 9bab103d2e4..e9be4b1f9da 100644
--- a/htdocs/core/class/commoninvoice.class.php
+++ b/htdocs/core/class/commoninvoice.class.php
@@ -325,6 +325,7 @@ abstract class CommonInvoice extends CommonObject
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Return if an invoice can be deleted
* Rule is:
@@ -339,6 +340,7 @@ abstract class CommonInvoice extends CommonObject
*/
function is_erasable()
{
+ // phpcs:enable
global $conf;
// We check if invoice is a temporary number (PROVxxxx)
@@ -449,6 +451,7 @@ abstract class CommonInvoice extends CommonObject
return $this->LibStatut($this->paye, $this->statut, $mode, $alreadypaid, $this->type);
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Return label of a status
*
@@ -461,6 +464,7 @@ abstract class CommonInvoice extends CommonObject
*/
function LibStatut($paye, $status, $mode=0, $alreadypaid=-1, $type=0)
{
+ // phpcs:enable
global $langs;
$langs->load('bills');
@@ -483,7 +487,7 @@ abstract class CommonInvoice extends CommonObject
else return $langs->trans('Bill'.$prefix.'StatusPaid');
}
}
- if ($mode == 1)
+ elseif ($mode == 1)
{
$prefix='Short';
if (! $paye)
@@ -501,7 +505,7 @@ abstract class CommonInvoice extends CommonObject
else return $langs->trans('Bill'.$prefix.'StatusPaid');
}
}
- if ($mode == 2)
+ elseif ($mode == 2)
{
$prefix='Short';
if (! $paye)
@@ -519,7 +523,7 @@ abstract class CommonInvoice extends CommonObject
else return img_picto($langs->trans('BillStatusPaid'),'statut6').' '.$langs->trans('Bill'.$prefix.'StatusPaid');
}
}
- if ($mode == 3)
+ elseif ($mode == 3)
{
$prefix='Short';
if (! $paye)
@@ -537,7 +541,7 @@ abstract class CommonInvoice extends CommonObject
else return img_picto($langs->trans('BillStatusPaid'),'statut6');
}
}
- if ($mode == 4)
+ elseif ($mode == 4)
{
$prefix='';
if (! $paye)
@@ -555,7 +559,7 @@ abstract class CommonInvoice extends CommonObject
else return img_picto($langs->trans('BillStatusPaid'),'statut6').' '.$langs->trans('BillStatusPaid');
}
}
- if ($mode == 5 || $mode == 6)
+ elseif ($mode == 5 || $mode == 6)
{
$prefix='';
if ($mode == 5) $prefix='Short';
@@ -580,15 +584,17 @@ abstract class CommonInvoice extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Renvoi une date limite de reglement de facture en fonction des
* conditions de reglements de la facture et date de facturation
*
* @param integer $cond_reglement Condition of payment (code or id) to use. If 0, we use current condition.
- * @return date Date limite de reglement si ok, <0 si ko
+ * @return date Date limite de reglement si ok, <0 si ko
*/
function calculate_date_lim_reglement($cond_reglement=0)
{
+ // phpcs:enable
if (! $cond_reglement) $cond_reglement=$this->cond_reglement_code;
if (! $cond_reglement) $cond_reglement=$this->cond_reglement_id;
@@ -776,4 +782,3 @@ abstract class CommonInvoiceLine extends CommonObjectLine
$this->db = $db;
}
}
-
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index 771f9fc4456..7991bbb9ae9 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -1,11 +1,9 @@
* Copyright (C) 2005-2013 Regis Houssin
- * Copyright (C) 2010-2013 Juanjo Menent
- * Copyright (C) 2012 Christophe Battarel
* Copyright (C) 2010-2015 Juanjo Menent
* Copyright (C) 2012-2013 Christophe Battarel
- * Copyright (C) 2011-2018 Philippe Grand
+ * Copyright (C) 2011-2018 Philippe Grand
* Copyright (C) 2012-2015 Marcos García
* Copyright (C) 2012-2015 Raphaël Doursenaud
* Copyright (C) 2012 Cedric Salvador
@@ -13,8 +11,9 @@
* Copyright (C) 2016 Bahfir abbes
* Copyright (C) 2017 ATM Consulting
* Copyright (C) 2017 Nicolas ZABOURI
- * Copyright (C) 2017 Rui Strecht
- * Copyright (C) 2018 Frederic France
+ * Copyright (C) 2017 Rui Strecht
+ * Copyright (C) 2018 Frédéric France
+ * Copyright (C) 2018 Josep Lluís Amador
*
* 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
@@ -46,47 +45,58 @@ abstract class CommonObject
* @var DoliDb Database handler (result of a new DoliDB)
*/
public $db;
+
/**
* @var int The object identifier
*/
public $id;
+
/**
* @var string Error string
* @see errors
*/
public $error;
+
/**
* @var string[] Array of error strings
*/
public $errors=array();
+
/**
- * @var string
+ * @var string ID to identify managed object
*/
public $element;
+
/**
- * @var string
+ * @var string Name of table without prefix where object is stored
*/
public $table_element;
+
/**
- * @var
+ * @var int Name of subtable line
*/
- public $table_element_line;
+ public $table_element_line='';
+
/**
* @var string Key value used to track if data is coming from import wizard
*/
public $import_key;
+
/**
* @var mixed Contains data to manage extrafields
*/
public $array_options=array();
+
/**
* @var int[][] Array of linked objects ids. Loaded by ->fetchObjectLinked
*/
public $linkedObjectsIds;
+
/**
* @var mixed Array of linked objects. Loaded by ->fetchObjectLinked
*/
public $linkedObjects;
+
/**
* @var Object To store a cloned copy of object before to edit it and keep track of old properties
*/
@@ -116,11 +126,13 @@ abstract class CommonObject
* @see fetch_projet()
*/
public $project;
+
/**
* @var int The related project ID
* @see setProject(), project
*/
public $fk_project;
+
/**
* @deprecated
* @see project
@@ -132,6 +144,7 @@ abstract class CommonObject
* @see fetch_contact()
*/
public $contact;
+
/**
* @var int The related contact ID
* @see fetch_contact()
@@ -155,6 +168,7 @@ abstract class CommonObject
* @see fetch_origin()
*/
public $origin;
+
/**
* @var int The id of originating object
* @see fetch_origin()
@@ -165,14 +179,17 @@ abstract class CommonObject
* @var string The object's reference
*/
public $ref;
+
/**
* @var string The object's previous reference
*/
public $ref_previous;
+
/**
* @var string The object's next reference
*/
public $ref_next;
+
/**
* @var string An external reference for the object
*/
@@ -189,36 +206,43 @@ abstract class CommonObject
* @see getFullAddress()
*/
public $country;
+
/**
* @var int
* @see getFullAddress(), country
*/
public $country_id;
+
/**
* @var string
* @see getFullAddress(), isInEEC(), country
*/
public $country_code;
+
/**
* @var string
* @see getFullAddress()
*/
public $state;
+
/**
* @var int
* @see getFullAddress(), state
*/
public $state_id;
+
/**
* @var string
* @see getFullAddress(), state
*/
public $state_code;
+
/**
* @var string
* @see getFullAddress(), region
*/
public $region;
+
/**
* @var string
* @see getFullAddress(), region
@@ -230,16 +254,19 @@ abstract class CommonObject
* @see fetch_barcode()
*/
public $barcode_type;
+
/**
* @var string
* @see fetch_barcode(), barcode_type
*/
public $barcode_type_code;
+
/**
* @var string
* @see fetch_barcode(), barcode_type
*/
public $barcode_type_label;
+
/**
* @var string
* @see fetch_barcode(), barcode_type
@@ -257,6 +284,7 @@ abstract class CommonObject
* @see setPaymentTerms()
*/
public $cond_reglement_id;
+
/**
* @var int Payment terms ID
* @deprecated Kept for compatibility
@@ -294,11 +322,13 @@ abstract class CommonObject
* @see update_note()
*/
public $note_public;
+
/**
* @var string Private note
* @see update_note()
*/
public $note_private;
+
/**
* @deprecated
* @see note_public
@@ -310,21 +340,25 @@ abstract class CommonObject
* @see update_price()
*/
public $total_ht;
+
/**
* @var float Total VAT amount
* @see update_price()
*/
public $total_tva;
+
/**
* @var float Total local tax 1 amount
* @see update_price()
*/
public $total_localtax1;
+
/**
* @var float Total local tax 2 amount
* @see update_price()
*/
public $total_localtax2;
+
/**
* @var float Total amount with taxes
* @see update_price()
@@ -347,11 +381,13 @@ abstract class CommonObject
* @see setIncoterms()
*/
public $fk_incoterms;
+
/**
* @var string
* @see SetIncoterms()
*/
public $libelle_incoterms;
+
/**
* @var string
* @see display_incoterms()
@@ -678,6 +714,7 @@ abstract class CommonObject
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Add a link between element $this->element and a contact
*
@@ -689,6 +726,7 @@ abstract class CommonObject
*/
function add_contact($fk_socpeople, $type_contact, $source='external',$notrigger=0)
{
+ // phpcs:enable
global $user,$langs;
@@ -800,6 +838,7 @@ abstract class CommonObject
} else return 0;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Copy contact from one element to current
*
@@ -809,6 +848,7 @@ abstract class CommonObject
*/
function copy_linked_contact($objFrom, $source='internal')
{
+ // phpcs:enable
$contacts = $objFrom->liste_contact(-1, $source);
foreach($contacts as $contact)
{
@@ -821,6 +861,7 @@ abstract class CommonObject
return 1;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Update a link to contact line
*
@@ -832,6 +873,7 @@ abstract class CommonObject
*/
function update_contact($rowid, $statut, $type_contact_id=0, $fk_socpeople=0)
{
+ // phpcs:enable
// Insert into database
$sql = "UPDATE ".MAIN_DB_PREFIX."element_contact set";
$sql.= " statut = ".$statut;
@@ -850,6 +892,7 @@ abstract class CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Delete a link to contact line
*
@@ -859,6 +902,7 @@ abstract class CommonObject
*/
function delete_contact($rowid, $notrigger=0)
{
+ // phpcs:enable
global $user;
@@ -887,6 +931,7 @@ abstract class CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Delete all links between an object $this and all its contacts
*
@@ -896,6 +941,7 @@ abstract class CommonObject
*/
function delete_linked_contact($source='',$code='')
{
+ // phpcs:enable
$temp = array();
$typeContact = $this->liste_type_contact($source,'',0,0,$code);
@@ -922,6 +968,7 @@ abstract class CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Get array of all contacts for an object
*
@@ -933,6 +980,7 @@ abstract class CommonObject
*/
function liste_contact($statut=-1,$source='external',$list=0,$code='')
{
+ // phpcs:enable
global $langs;
$tab=array();
@@ -1027,9 +1075,9 @@ abstract class CommonObject
dol_print_error($this->db);
return -1;
}
-
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Return array with list of possible values for type of contacts
*
@@ -1042,6 +1090,7 @@ abstract class CommonObject
*/
function liste_type_contact($source='internal', $order='position', $option=0, $activeonly=0, $code='')
{
+ // phpcs:enable
global $langs;
if (empty($order)) $order='position';
@@ -1143,6 +1192,7 @@ abstract class CommonObject
return $result;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Load object contact with id=$this->contactid into $this->contact
*
@@ -1151,6 +1201,7 @@ abstract class CommonObject
*/
function fetch_contact($contactid=null)
{
+ // phpcs:enable
if (empty($contactid)) $contactid=$this->contactid;
if (empty($contactid)) return 0;
@@ -1162,6 +1213,7 @@ abstract class CommonObject
return $result;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Load the third party of object, from id $this->socid or $this->fk_soc, into this->thirdparty
*
@@ -1170,6 +1222,7 @@ abstract class CommonObject
*/
function fetch_thirdparty($force_thirdparty_id=0)
{
+ // phpcs:enable
global $conf;
if (empty($this->socid) && empty($this->fk_soc) && empty($this->fk_thirdparty) && empty($force_thirdparty_id))
@@ -1223,6 +1276,7 @@ abstract class CommonObject
return $this->fetch($result->rowid);
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Load data for barcode into properties ->barcode_type*
* Properties ->barcode_type that is id of barcode. Type is used to find other properties, but
@@ -1232,6 +1286,7 @@ abstract class CommonObject
*/
function fetch_barcode()
{
+ // phpcs:enable
global $conf;
dol_syslog(get_class($this).'::fetch_barcode this->element='.$this->element.' this->barcode_type='.$this->barcode_type);
@@ -1272,6 +1327,7 @@ abstract class CommonObject
return 0;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Load the project with id $this->fk_project into this->project
*
@@ -1279,6 +1335,7 @@ abstract class CommonObject
*/
function fetch_projet()
{
+ // phpcs:enable
include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
if (empty($this->fk_project) && ! empty($this->fk_projet)) $this->fk_project = $this->fk_projet; // For backward compatibility
@@ -1292,6 +1349,7 @@ abstract class CommonObject
return $result;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Load the product with id $this->fk_product into this->product
*
@@ -1299,6 +1357,7 @@ abstract class CommonObject
*/
function fetch_product()
{
+ // phpcs:enable
include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
if (empty($this->fk_product)) return 0;
@@ -1310,6 +1369,7 @@ abstract class CommonObject
return $result;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Load the user with id $userid into this->user
*
@@ -1318,12 +1378,14 @@ abstract class CommonObject
*/
function fetch_user($userid)
{
+ // phpcs:enable
$user = new User($this->db);
$result=$user->fetch($userid);
$this->user = $user;
return $result;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Read linked origin object
*
@@ -1331,6 +1393,7 @@ abstract class CommonObject
*/
function fetch_origin()
{
+ // phpcs:enable
if ($this->origin == 'shipping') $this->origin = 'expedition';
if ($this->origin == 'delivery') $this->origin = 'livraison';
@@ -1490,6 +1553,7 @@ abstract class CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Load properties id_previous and id_next by comparing $fieldid with $this->ref
*
@@ -1500,6 +1564,7 @@ abstract class CommonObject
*/
function load_previous_next_ref($filter, $fieldid, $nodbprefix=0)
{
+ // phpcs:enable
global $conf, $user;
if (! $this->table_element)
@@ -1828,7 +1893,7 @@ abstract class CommonObject
case 'order_supplier':
$this->updateline(
$line->id, ($line->description?$line->description:$line->desc), $line->subprice, $line->qty, $line->remise_percent,
- $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, false,
+ $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, false,
$line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $line->multicurrency_subprice
);
break;
@@ -1990,7 +2055,6 @@ abstract class CommonObject
$this->db->commit();
return 1;
}
-
}
@@ -2125,6 +2189,7 @@ abstract class CommonObject
// TODO: Move line related operations to CommonObjectLine?
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Save a new position (field rang) for details lines.
* You can choose to set position for lines with already a position or lines without any position defined.
@@ -2136,6 +2201,7 @@ abstract class CommonObject
*/
function line_order($renum=false, $rowidorder='ASC', $fk_parent_line=true)
{
+ // phpcs:enable
if (! $this->table_element_line)
{
dol_syslog(get_class($this)."::line_order was called on objet with property table_element_line not defined",LOG_ERR);
@@ -2244,6 +2310,7 @@ abstract class CommonObject
return $rows;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Update a line to have a lower rank
*
@@ -2253,6 +2320,7 @@ abstract class CommonObject
*/
function line_up($rowid, $fk_parent_line=true)
{
+ // phpcs:enable
$this->line_order(false, 'ASC', $fk_parent_line);
// Get rang of line
@@ -2262,6 +2330,7 @@ abstract class CommonObject
$this->updateLineUp($rowid, $rang);
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Update a line to have a higher rank
*
@@ -2271,6 +2340,7 @@ abstract class CommonObject
*/
function line_down($rowid, $fk_parent_line=true)
{
+ // phpcs:enable
$this->line_order(false, 'ASC', $fk_parent_line);
// Get rang of line
@@ -2305,6 +2375,7 @@ abstract class CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Update position of line with ajax (rang)
*
@@ -2313,6 +2384,7 @@ abstract class CommonObject
*/
function line_ajaxorder($rows)
{
+ // phpcs:enable
$num = count($rows);
for ($i = 0 ; $i < $num ; $i++)
{
@@ -2420,6 +2492,7 @@ abstract class CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Get max value used for position of line (rang)
*
@@ -2428,6 +2501,7 @@ abstract class CommonObject
*/
function line_max($fk_parent_line=0)
{
+ // phpcs:enable
// Search the last rang with fk_parent_line
if ($fk_parent_line)
{
@@ -2466,6 +2540,7 @@ abstract class CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Update external ref of element
*
@@ -2474,6 +2549,7 @@ abstract class CommonObject
*/
function update_ref_ext($ref_ext)
{
+ // phpcs:enable
if (! $this->table_element)
{
dol_syslog(get_class($this)."::update_ref_ext was called on objet with property table_element not defined", LOG_ERR);
@@ -2497,6 +2573,7 @@ abstract class CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Update note of element
*
@@ -2504,8 +2581,9 @@ abstract class CommonObject
* @param string $suffix '', '_public' or '_private'
* @return int <0 if KO, >0 if OK
*/
- function update_note($note,$suffix='')
+ function update_note($note, $suffix='')
{
+ // phpcs:enable
global $user;
if (! $this->table_element)
@@ -2548,6 +2626,7 @@ abstract class CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Update public note (kept for backward compatibility)
*
@@ -2558,9 +2637,11 @@ abstract class CommonObject
*/
function update_note_public($note)
{
+ // phpcs:enable
return $this->update_note($note,'_public');
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Update total_ht, total_ttc, total_vat, total_localtax1, total_localtax2 for an object (sum of lines).
* Must be called at end of methods addline or updateline.
@@ -2573,7 +2654,8 @@ abstract class CommonObject
*/
function update_price($exclspec=0,$roundingadjust='none',$nodatabaseupdate=0,$seller=null)
{
- global $conf;
+ // phpcs:enable
+ global $conf, $hookmanager, $action;
// Some external module want no update price after a trigger because they have another method to calculate the total (ex: with an extrafield)
$MODULE = "";
@@ -2664,7 +2746,10 @@ abstract class CommonObject
$obj = $this->db->fetch_object($resql);
// Note: There is no check on detail line and no check on total, if $forcedroundingmode = 'none'
- if ($forcedroundingmode == '0') // Check if data on line are consistent. This may solve lines that were not consistent because set with $forcedroundingmode='auto'
+ $parameters=array('fk_element' => $obj->rowid);
+ $reshook = $hookmanager->executeHooks('changeRoundingMode', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
+
+ if (empty($reshook) && $forcedroundingmode == '0') // Check if data on line are consistent. This may solve lines that were not consistent because set with $forcedroundingmode='auto'
{
$localtax_array=array($obj->localtax1_type,$obj->localtax1_tx,$obj->localtax2_type,$obj->localtax2_tx);
$tmpcal=calcul_price_total($obj->qty, $obj->up, $obj->remise_percent, $obj->vatrate, $obj->localtax1_tx, $obj->localtax2_tx, 0, 'HT', $obj->info_bits, $obj->product_type, $seller, $localtax_array, (isset($obj->situation_percent) ? $obj->situation_percent : 100), $multicurrency_tx);
@@ -2796,6 +2881,7 @@ abstract class CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Add objects linked in llx_element_element.
*
@@ -2806,6 +2892,7 @@ abstract class CommonObject
*/
function add_object_linked($origin=null, $origin_id=null)
{
+ // phpcs:enable
$origin = (! empty($origin) ? $origin : $this->origin);
$origin_id = (! empty($origin_id) ? $origin_id : $this->origin_id);
@@ -3556,6 +3643,7 @@ abstract class CommonObject
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Return incoterms informations
* TODO Use a cache for label get
@@ -3564,6 +3652,7 @@ abstract class CommonObject
*/
function display_incoterms()
{
+ // phpcs:enable
$out = '';
$this->libelle_incoterms = '';
if (!empty($this->fk_incoterms))
@@ -3721,7 +3810,7 @@ abstract class CommonObject
$num = count($this->lines);
- //Line extrafield
+ // Line extrafield
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
$extrafieldsline = new ExtraFields($this->db);
$extralabelslines=$extrafieldsline->fetch_name_optionals_label($this->table_element_line);
@@ -3730,6 +3819,7 @@ abstract class CommonObject
$reshook = $hookmanager->executeHooks('printObjectLineTitle', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if (empty($reshook))
{
+ // Title line
print "\n";
print '';
@@ -3821,7 +3911,6 @@ abstract class CommonObject
//Line extrafield
$line->fetch_optionals();
-
//if (is_object($hookmanager) && (($line->product_type == 9 && ! empty($line->special_code)) || ! empty($line->fk_parent_line)))
if (is_object($hookmanager)) // Old code is commented on preceding line.
{
@@ -4163,6 +4252,7 @@ abstract class CommonObject
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Add resources to the current object : add entry into llx_element_resources
* Need $this->element & $this->id
@@ -4175,6 +4265,7 @@ abstract class CommonObject
*/
function add_element_resource($resource_id, $resource_type, $busy=0, $mandatory=0)
{
+ // phpcs:enable
$this->db->begin();
$sql = "INSERT INTO ".MAIN_DB_PREFIX."element_resources (";
@@ -4207,6 +4298,7 @@ abstract class CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Delete a link to resource line
*
@@ -4217,6 +4309,7 @@ abstract class CommonObject
*/
function delete_resource($rowid, $element, $notrigger=0)
{
+ // phpcs:enable
global $user;
$this->db->begin();
@@ -4583,13 +4676,13 @@ abstract class CommonObject
if (isset($conf->global->$keyforfieldname)) return $conf->global->$keyforfieldname;
// TODO Ad here a scan into table llx_overwrite_default with a filter on $this->element and $fieldname
-
}
/* For triggers */
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Call trigger based on this instance.
* Some context information may also be provided into array property this->context.
@@ -4602,6 +4695,7 @@ abstract class CommonObject
*/
function call_trigger($trigger_name, $user)
{
+ // phpcs:enable
global $langs,$conf;
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
@@ -4626,6 +4720,7 @@ abstract class CommonObject
/* Functions for extrafields */
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Function to get extra fields of an object into $this->array_options
* This method is in most cases called by method fetch of objects but you can call it separately.
@@ -4636,6 +4731,7 @@ abstract class CommonObject
*/
function fetch_optionals($rowid=null, $optionsArray=null)
{
+ // phpcs:enable
if (empty($rowid)) $rowid=$this->id;
// To avoid SQL errors. Probably not the better solution though
@@ -5122,7 +5218,7 @@ abstract class CommonObject
require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
$form=new Form($this->db);
}
-
+
$val=$this->fields[$key];
$out='';
@@ -5137,20 +5233,20 @@ abstract class CommonObject
$param['options']=array($reg[1].':'.$reg[2]=>'N');
$type ='link';
}else if(preg_match('/^sellist:(.*):(.*):(.*):(.*)/i', $val['type'], $reg)){
-
+
$param['options']=array($reg[1].':'.$reg[2].':'.$reg[3].':'.$reg[4]=>'N');
$type ='sellist';
}else if(preg_match('/varchar\((\d+)\)/', $val['type'],$reg)){
-
+
$param['options']=array();
$type ='varchar';
$size=$reg[1];
}else if(preg_match('/varchar/', $val['type'])){
-
+
$param['options']=array();
$type ='varchar';
}else if(is_array($this->fields[$key]['arrayofkeyval'])){
-
+
$param['options']=$this->fields[$key]['arrayofkeyval'];
$type ='select';
}else {
@@ -5164,7 +5260,7 @@ abstract class CommonObject
$computed=$this->fields[$key]['computed'];
$unique=$this->fields[$key]['unique'];
$required=$this->fields[$key]['required'];
-
+
$langfile=$this->fields[$key]['langfile'];
$list=$this->fields[$key]['list'];
$hidden=abs($this->fields[$key]['visible'])!=1?1:0;
@@ -5229,11 +5325,11 @@ abstract class CommonObject
$showtime = in_array($type,array('datetime')) ? 1 : 0;
- // Do not show current date when field not required (see select_date() method)
+ // Do not show current date when field not required (see selectDate() method)
if (!$required && $value == '') $value = '-1';
// TODO Must also support $moreparam
- $out = $form->select_date($value, $keyprefix.$key.$keysuffix, $showtime, $showtime, $required, '', 1, (($keyprefix != 'search_' && $keyprefix != 'search_options_') ? 1 : 0), 1, 0, 1);
+ $out = $form->selectDate($value, $keyprefix.$key.$keysuffix, $showtime, $showtime, $required, '', 1, (($keyprefix != 'search_' && $keyprefix != 'search_options_') ? 1 : 0), 1, 0);
}
elseif (in_array($type,array('int','integer')))
{
@@ -5707,7 +5803,7 @@ abstract class CommonObject
*/
return $out;
}
-
+
/**
* Return HTML string to show a field into a page
* Code very similar with showOutputField of extra fields
@@ -6085,7 +6181,7 @@ abstract class CommonObject
*
* @param Extrafields $extrafields Extrafield Object
* @param string $mode Show output (view) or input (edit) for extrafield
- * @param array $params Optional parameters
+ * @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
@@ -6108,6 +6204,9 @@ abstract class CommonObject
$e = 0;
foreach($extrafields->attributes[$this->table_element]['label'] as $key=>$label)
{
+ //Show only the key field in params
+ if (is_array($params) && array_key_exists('onlykey',$params) && $key != $params['onlykey']) continue;
+
$enabled = 1;
if ($enabled && isset($extrafields->attributes[$this->table_element]['list'][$key]))
{
@@ -6394,6 +6493,7 @@ abstract class CommonObject
return $buyPrice;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Show photos of an object (nbmax maximum), into several columns
*
@@ -6413,6 +6513,7 @@ abstract class CommonObject
*/
function show_photos($modulepart, $sdir, $size=0, $nbmax=0, $nbbyrow=5, $showfilename=0, $showaction=0, $maxHeight=120, $maxWidth=160, $nolink=0, $notitle=0, $usesharelink=0)
{
+ // phpcs:enable
global $conf,$user,$langs;
include_once DOL_DOCUMENT_ROOT .'/core/lib/files.lib.php';
@@ -6807,6 +6908,7 @@ abstract class CommonObject
* Function to load data from a SQL pointer into properties of current object $this
*
* @param stdClass $obj Contain data of object from database
+ * @return void
*/
protected function setVarsFromFetchObj(&$obj)
{
@@ -6870,7 +6972,8 @@ abstract class CommonObject
* @param array $fieldsentry Properties of field
* @return string
*/
- protected function quote($value, $fieldsentry) {
+ protected function quote($value, $fieldsentry)
+ {
if (is_null($value)) return 'NULL';
else if (preg_match('/^(int|double|real)/i', $fieldsentry['type'])) return $this->db->escape("$value");
else return "'".$this->db->escape($value)."'";
@@ -6913,7 +7016,7 @@ abstract class CommonObject
if (! empty($this->fields[$key]['foreignkey']) && $values[$key] == '-1') $values[$key]='';
//var_dump($key.'-'.$values[$key].'-'.($this->fields[$key]['notnull'] == 1));
- if ($this->fields[$key]['notnull'] == 1 && ! isset($values[$key]) && is_null($val['default']))
+ if (isset($this->fields[$key]['notnull']) && $this->fields[$key]['notnull'] == 1 && ! isset($values[$key]) && is_null($val['default']))
{
$error++;
$this->errors[]=$langs->trans("ErrorFieldRequired", $this->fields[$key]['label']);
@@ -7074,15 +7177,12 @@ abstract class CommonObject
}
// Update extrafield
- if (! $error)
+ if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options)>0)
{
- if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
+ $result=$this->insertExtraFields();
+ if ($result < 0)
{
- $result=$this->insertExtraFields();
- if ($result < 0)
- {
- $error++;
- }
+ $error++;
}
}
@@ -7205,5 +7305,4 @@ abstract class CommonObject
{
return count($this->comments);
}
-
}
diff --git a/htdocs/core/class/commonobjectline.class.php b/htdocs/core/class/commonobjectline.class.php
index bed227eb408..91d4245ff88 100644
--- a/htdocs/core/class/commonobjectline.class.php
+++ b/htdocs/core/class/commonobjectline.class.php
@@ -53,7 +53,7 @@ abstract class CommonObjectLine extends CommonObject
/**
* Returns the translation key from units dictionary.
* A langs->trans() must be called on result to get translated value.
- *
+ *
* @param string $type Label type (long or short)
* @return string|int <0 if ko, label if ok
*/
@@ -94,4 +94,3 @@ abstract class CommonObjectLine extends CommonObject
// For the moment we use the extends on CommonObject until PHP min is 5.4 so use Traits.
}
-
diff --git a/htdocs/core/class/commonorder.class.php b/htdocs/core/class/commonorder.class.php
index b3e5033330d..2ea53a345d8 100644
--- a/htdocs/core/class/commonorder.class.php
+++ b/htdocs/core/class/commonorder.class.php
@@ -144,6 +144,5 @@ abstract class CommonOrderLine extends CommonObjectLine
public $info_bits = 0;
public $special_code = 0;
-
}
diff --git a/htdocs/core/class/commonstickergenerator.class.php b/htdocs/core/class/commonstickergenerator.class.php
index 1091962f6ea..6d4c32d82bb 100644
--- a/htdocs/core/class/commonstickergenerator.class.php
+++ b/htdocs/core/class/commonstickergenerator.class.php
@@ -62,7 +62,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/format_cards.lib.php';
abstract class CommonStickerGenerator
{
- public $code; // Code of format
+ public $code; // Code of format
public $format; // Array with informations
// protected
@@ -93,7 +93,8 @@ abstract class CommonStickerGenerator
{
$this->db = $db;
}
-
+
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Function to build PDF on disk, then output on HTTP strem.
*
@@ -104,6 +105,7 @@ abstract class CommonStickerGenerator
* @return int 1=OK, 0=KO
*/
abstract function write_file($arrayofrecords,$outputlangs,$srctemplatepath,$outputdir='');
+ // phpcs:enable
/**
* Output a sticker on page at position _COUNTX, _COUNTY (_COUNTX and _COUNTY start from 0)
@@ -114,7 +116,8 @@ abstract class CommonStickerGenerator
* @return void
*/
abstract function addSticker(&$pdf,$outputlangs,$param);
-
+
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Methode qui permet de modifier la taille des caracteres
* Cela modiera aussi l'espace entre chaque ligne
@@ -125,13 +128,15 @@ abstract class CommonStickerGenerator
*/
function Set_Char_Size(&$pdf,$pt)
{
+ // phpcs:enable
if ($pt > 3) {
$this->_Char_Size = $pt;
$this->_Line_Height = $this->_Get_Height_Chars($pt);
$pdf->SetFont('','',$pt);
}
- }
+ }
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* protected Print dot line
*
@@ -146,6 +151,7 @@ abstract class CommonStickerGenerator
*/
function _Pointille(&$pdf,$x1=0,$y1=0,$x2=210,$y2=297,$epaisseur=1,$nbPointilles=15)
{
+ // phpcs:enable
$pdf->SetLineWidth($epaisseur);
$length=abs($x1-$x2);
$hauteur=abs($y1-$y2);
@@ -173,6 +179,7 @@ abstract class CommonStickerGenerator
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* protected Function realisant une croix aux 4 coins des cartes
*
@@ -187,6 +194,7 @@ abstract class CommonStickerGenerator
*/
function _Croix(&$pdf,$x1=0,$y1=0,$x2=210,$y2=297,$epaisseur=1,$taille=4)
{
+ // phpcs:enable
$pdf->SetDrawColor(192,192,192);
$pdf->SetLineWidth($epaisseur);
@@ -207,6 +215,7 @@ abstract class CommonStickerGenerator
$pdf->SetDrawColor(0,0,0);
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* protected Convert units (in to mm, mm to in)
* $src and $dest must be 'in' or 'mm'
@@ -216,8 +225,9 @@ abstract class CommonStickerGenerator
* @param string $dest to
* @return float value value after conversion
*/
- function _Convert_Metric ($value, $src, $dest)
+ function _Convert_Metric($value, $src, $dest)
{
+ // phpcs:enable
if ($src != $dest) {
$tab['in'] = 39.37008;
$tab['mm'] = 1000;
@@ -227,6 +237,7 @@ abstract class CommonStickerGenerator
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* protected Give the height for a char size given.
*
@@ -235,6 +246,7 @@ abstract class CommonStickerGenerator
*/
function _Get_Height_Chars($pt)
{
+ // phpcs:enable
// Tableau de concordance entre la hauteur des caracteres et de l'espacement entre les lignes
$_Table_Hauteur_Chars = array(6=>2, 7=>2.5, 8=>3, 9=>3.5, 10=>4, 11=>6, 12=>7, 13=>8, 14=>9, 15=>10);
if (in_array($pt, array_keys($_Table_Hauteur_Chars))) {
@@ -244,6 +256,7 @@ abstract class CommonStickerGenerator
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* protected Set format
*
@@ -251,20 +264,20 @@ abstract class CommonStickerGenerator
* @param string $format Format
* @return void
*/
- function _Set_Format(&$pdf, $format)
+ function _Set_Format(&$pdf, $format)
{
- $this->_Metric = $format['metric'];
- $this->_Avery_Name = $format['name'];
- $this->_Avery_Code = $format['code'];
+ // phpcs:enable
+ $this->_Metric = $format['metric'];
+ $this->_Avery_Name = $format['name'];
+ $this->_Avery_Code = $format['code'];
$this->_Margin_Left = $this->_Convert_Metric($format['marginLeft'], $this->_Metric, $this->_Metric_Doc);
- $this->_Margin_Top = $this->_Convert_Metric($format['marginTop'], $this->_Metric, $this->_Metric_Doc);
- $this->_X_Space = $this->_Convert_Metric($format['SpaceX'], $this->_Metric, $this->_Metric_Doc);
- $this->_Y_Space = $this->_Convert_Metric($format['SpaceY'], $this->_Metric, $this->_Metric_Doc);
- $this->_X_Number = $format['NX'];
- $this->_Y_Number = $format['NY'];
- $this->_Width = $this->_Convert_Metric($format['width'], $this->_Metric, $this->_Metric_Doc);
- $this->_Height = $this->_Convert_Metric($format['height'], $this->_Metric, $this->_Metric_Doc);
+ $this->_Margin_Top = $this->_Convert_Metric($format['marginTop'], $this->_Metric, $this->_Metric_Doc);
+ $this->_X_Space = $this->_Convert_Metric($format['SpaceX'], $this->_Metric, $this->_Metric_Doc);
+ $this->_Y_Space = $this->_Convert_Metric($format['SpaceY'], $this->_Metric, $this->_Metric_Doc);
+ $this->_X_Number = $format['NX'];
+ $this->_Y_Number = $format['NY'];
+ $this->_Width = $this->_Convert_Metric($format['width'], $this->_Metric, $this->_Metric_Doc);
+ $this->_Height = $this->_Convert_Metric($format['height'], $this->_Metric, $this->_Metric_Doc);
$this->Set_Char_Size($pdf, $format['font-size']);
}
-
}
diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php
index 3b33b1f16f1..db22d443c54 100644
--- a/htdocs/core/class/conf.class.php
+++ b/htdocs/core/class/conf.class.php
@@ -35,8 +35,12 @@ class Conf
/** \public */
//! To store properties found in conf file
var $file;
- //! Object with database handler
- var $db;
+
+ /**
+ * @var DoliDB Database handler.
+ */
+ public $db;
+
//! To store properties found into database
var $global;
//! To store browser info
@@ -519,6 +523,9 @@ class Conf
// By default, we open card if one found
if (! isset($this->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE)) $this->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE=1;
+ // By default, we show state code in combo list
+ if (! isset($this->global->MAIN_SHOW_STATE_CODE)) $this->global->MAIN_SHOW_STATE_CODE=1;
+
// Define list of limited modules (value must be key found for "name" property of module, so for example 'supplierproposal' for Module "Supplier Proposal"
if (! isset($this->global->MAIN_MODULES_FOR_EXTERNAL)) $this->global->MAIN_MODULES_FOR_EXTERNAL='user,societe,propal,commande,facture,categorie,supplierproposal,fournisseur,contact,projet,contrat,ficheinter,expedition,agenda,resource,adherent,blockedlog'; // '' means 'all'. Note that contact is added here as it should be a module later.
if (! empty($this->modules_parts['moduleforexternal'])) // Module part to include an external module into the MAIN_MODULES_FOR_EXTERNAL list
@@ -662,7 +669,6 @@ class Conf
$this->loghandlers[$handler] = $loghandlerinstance;
}
}
-
}
}
diff --git a/htdocs/core/class/coreobject.class.php b/htdocs/core/class/coreobject.class.php
index 1456fb991c2..5129ac54ece 100644
--- a/htdocs/core/class/coreobject.class.php
+++ b/htdocs/core/class/coreobject.class.php
@@ -1,6 +1,6 @@
*
* This program is free software; you can redistribute it and/or modify
@@ -22,7 +22,7 @@
* \ingroup core
* \brief File of class to manage all object. Might be replace or merge into commonobject
*/
-
+
require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
class CoreObject extends CommonObject
@@ -54,7 +54,7 @@ class CoreObject extends CommonObject
$this->id = 0;
$this->datec = 0;
$this->tms = 0;
-
+
if (!empty($this->fields))
{
foreach ($this->fields as $field=>$info)
@@ -68,14 +68,13 @@ class CoreObject extends CommonObject
$this->to_delete=false;
$this->is_clone=false;
-
+
return true;
}
else
{
return false;
}
-
}
/**
@@ -110,7 +109,7 @@ class CoreObject extends CommonObject
if($res>0) {
if ($loadChild) $this->fetchChild();
}
-
+
return $res;
}
@@ -133,14 +132,14 @@ class CoreObject extends CommonObject
if($object->{$key} === $id) return $k;
}
}
-
+
$k = count($this->{$tabName});
-
+
$className = ucfirst($tabName);
$this->{$tabName}[$k] = new $className($this->db);
if($id>0 && $key==='id' && $try_to_load)
{
- $this->{$tabName}[$k]->fetch($id);
+ $this->{$tabName}[$k]->fetch($id);
}
return $k;
@@ -171,6 +170,8 @@ class CoreObject extends CommonObject
/**
* Function to fetch children objects
+ *
+ * @return void
*/
public function fetchChild()
{
@@ -207,6 +208,7 @@ class CoreObject extends CommonObject
* Function to update children data
*
* @param User $user user object
+ * @return void
*/
public function saveChild(User &$user)
{
@@ -220,7 +222,7 @@ class CoreObject extends CommonObject
foreach($this->{$className} as $i => &$object)
{
$object->{$this->fk_element} = $this->id;
-
+
$object->update($user);
if($this->unsetChildDeleted && isset($object->to_delete) && $object->to_delete==true) unset($this->{$className}[$i]);
}
@@ -268,7 +270,6 @@ class CoreObject extends CommonObject
$this->db->rollback();
return -1;
}
-
}
/**
@@ -434,5 +435,4 @@ class CoreObject extends CommonObject
return 1;
}
-
}
diff --git a/htdocs/core/class/cstate.class.php b/htdocs/core/class/cstate.class.php
index ae2adde87d4..085da06c754 100644
--- a/htdocs/core/class/cstate.class.php
+++ b/htdocs/core/class/cstate.class.php
@@ -32,16 +32,32 @@
*/
class Cstate // extends CommonObject
{
- var $db; //!< To store db handler
- var $error; //!< To return error code (or message)
- var $errors=array(); //!< To return several error codes (or messages)
+ /**
+ * @var DoliDB Database handler.
+ */
+ public $db;
+
+ /**
+ * @var string Error code (or message)
+ */
+ public $error='';
+
+ /**
+ * @var string[] Error codes (or messages)
+ */
+ public $errors = array();
+
//var $element='cstate'; //!< Id that identify managed objects
//var $table_element='cstate'; //!< Name of table without prefix where object is stored
- var $id;
- var $code_departement;
- var $nom;
- var $active;
+ /**
+ * @var int ID
+ */
+ public $id;
+
+ public $code_departement;
+ public $nom;
+ public $active;
@@ -301,5 +317,4 @@ class Cstate // extends CommonObject
return 1;
}
}
-
}
diff --git a/htdocs/core/class/ctypent.class.php b/htdocs/core/class/ctypent.class.php
index b3bb750bd80..9366cf6317b 100644
--- a/htdocs/core/class/ctypent.class.php
+++ b/htdocs/core/class/ctypent.class.php
@@ -27,17 +27,33 @@
*/
class Ctypent // extends CommonObject
{
- var $db; //!< To store db handler
- var $error; //!< To return error code (or message)
- var $errors=array(); //!< To return several error codes (or messages)
+ /**
+ * @var DoliDB Database handler.
+ */
+ public $db;
+
+ /**
+ * @var string Error code (or message)
+ */
+ public $error='';
+
+ /**
+ * @var string[] Error codes (or messages)
+ */
+ public $errors = array();
+
//var $element='ctypent'; //!< Id that identify managed objects
//var $table_element='ctypent'; //!< Name of table without prefix where object is stored
- var $id;
- var $code;
- var $libelle;
- var $active;
- var $module;
+ /**
+ * @var int ID
+ */
+ public $id;
+
+ public $code;
+ public $libelle;
+ public $active;
+ public $module;
@@ -317,5 +333,4 @@ class Ctypent // extends CommonObject
return 1;
}
}
-
}
diff --git a/htdocs/core/class/ctyperesource.class.php b/htdocs/core/class/ctyperesource.class.php
index a5a6ea879ce..297e48a940b 100644
--- a/htdocs/core/class/ctyperesource.class.php
+++ b/htdocs/core/class/ctyperesource.class.php
@@ -19,7 +19,7 @@
*/
/**
- * \file resource/ctyperesource.class.php
+ * \file htdocs/core/class/ctyperesource.class.php
* \ingroup resource
*/
@@ -36,6 +36,7 @@ class Ctyperesource
* @var string Id to identify managed objects
*/
public $element = 'ctyperesource';
+
/**
* @var string Name of table without prefix where object is stored
*/
@@ -46,15 +47,14 @@ class Ctyperesource
*/
public $lines = array();
- /**
- */
-
public $code;
- public $label;
- public $active;
/**
- */
+ * @var string Type resource label
+ */
+ public $label;
+
+ public $active;
/**
@@ -127,15 +127,15 @@ class Ctyperesource
if (!$error) {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element);
- if (!$notrigger) {
- // Uncomment this and change MYOBJECT to your own tag if you
- // want this action to call a trigger.
+ // Uncomment this and change MYOBJECT to your own tag if you
+ // want this action to call a trigger.
+ //if (!$notrigger) {
- //// Call triggers
- //$result=$this->call_trigger('MYOBJECT_CREATE',$user);
- //if ($result < 0) $error++;
- //// End call triggers
- }
+ // // Call triggers
+ // $result=$this->call_trigger('MYOBJECT_CREATE',$user);
+ // if ($result < 0) $error++;
+ // // End call triggers
+ //}
}
// Commit or rollback
@@ -331,15 +331,15 @@ class Ctyperesource
dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR);
}
- if (!$error && !$notrigger) {
- // Uncomment this and change MYOBJECT to your own tag if you
- // want this action calls a trigger.
+ // Uncomment this and change MYOBJECT to your own tag if you
+ // want this action calls a trigger.
+ //if (!$error && !$notrigger) {
- //// Call triggers
- //$result=$this->call_trigger('MYOBJECT_MODIFY',$user);
- //if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail}
- //// End call triggers
- }
+ // // Call triggers
+ // $result=$this->call_trigger('MYOBJECT_MODIFY',$user);
+ // if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail}
+ // // End call triggers
+ //}
// Commit or rollback
if ($error) {
@@ -369,17 +369,15 @@ class Ctyperesource
$this->db->begin();
- if (!$error) {
- if (!$notrigger) {
- // Uncomment this and change MYOBJECT to your own tag if you
- // want this action calls a trigger.
+ // Uncomment this and change MYOBJECT to your own tag if you
+ // want this action calls a trigger.
+ //if (!$error && !$notrigger) {
- //// Call triggers
- //$result=$this->call_trigger('MYOBJECT_DELETE',$user);
- //if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail}
- //// End call triggers
- }
- }
+ // // Call triggers
+ // $result=$this->call_trigger('MYOBJECT_DELETE',$user);
+ // if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail}
+ // // End call triggers
+ //}
// If you need to delete child tables to, you can insert them here
@@ -468,7 +466,6 @@ class Ctyperesource
$this->label = '';
$this->active = '';
}
-
}
/**
@@ -480,16 +477,20 @@ class CtyperesourceLine
* @var int ID
*/
public $id;
+
/**
* @var mixed Sample line property 1
*/
-
public $code;
- public $label;
+
+ /**
+ * @var string Type resource line label
+ */
+ public $label;
+
public $active;
/**
* @var mixed Sample line property 2
*/
-
}
diff --git a/htdocs/core/class/discount.class.php b/htdocs/core/class/discount.class.php
index 9fc1921aa60..6f6e3a09041 100644
--- a/htdocs/core/class/discount.class.php
+++ b/htdocs/core/class/discount.class.php
@@ -28,18 +28,47 @@
*/
class DiscountAbsolute
{
+ /**
+ * @var DoliDB Database handler.
+ */
public $db;
- public $error;
- public $id; // Id discount
+ /**
+ * @var string Error code (or message)
+ */
+ public $error;
+
+ /**
+ * @var string[] Array of error strings
+ */
+ public $errors=array();
+
+ /**
+ * @var int ID discount
+ */
+ public $id;
+
+ /**
+ * @var int Thirdparty ID
+ */
public $fk_soc;
+
public $discount_type; // 0 => customer discount, 1 => supplier discount
public $amount_ht; //
public $amount_tva; //
public $amount_ttc; //
public $tva_tx; // Vat rate
- public $fk_user; // Id utilisateur qui accorde la remise
- public $description; // Description libre
+
+ /**
+ * @var int User ID Id utilisateur qui accorde la remise
+ */
+ public $fk_user;
+
+ /**
+ * @var string description
+ */
+ public $description;
+
public $datec; // Date creation
public $fk_facture_line; // Id invoice line when a discount is used into an invoice line (for absolute discounts)
public $fk_facture; // Id invoice when a discount line is used into an invoice (for credit note)
@@ -332,6 +361,7 @@ class DiscountAbsolute
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Link the discount to a particular invoice line or a particular invoice.
* When discount is a global discount used as an invoice line, we link using rowidline.
@@ -343,6 +373,7 @@ class DiscountAbsolute
*/
function link_to_invoice($rowidline,$rowidinvoice)
{
+ // phpcs:enable
// Check parameters
if (! $rowidline && ! $rowidinvoice)
{
@@ -386,6 +417,7 @@ class DiscountAbsolute
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Link the discount to a particular invoice line or a particular invoice.
* Do not call this if discount is linked to a reconcialiated invoice
@@ -394,6 +426,7 @@ class DiscountAbsolute
*/
function unlink_invoice()
{
+ // phpcs:enable
$sql ="UPDATE ".MAIN_DB_PREFIX."societe_remise_except";
if(! empty($this->discount_type)) {
$sql.=" SET fk_invoice_supplier_line = NULL, fk_invoice_supplier = NULL";
diff --git a/htdocs/core/class/doleditor.class.php b/htdocs/core/class/doleditor.class.php
index 860d89afea8..548721be05f 100644
--- a/htdocs/core/class/doleditor.class.php
+++ b/htdocs/core/class/doleditor.class.php
@@ -135,9 +135,9 @@ class DolEditor
$this->height = $height;
$this->width = $width;
}
-
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Output edit area inside the HTML stream.
* Output depends on this->tool (fckeditor, ckeditor, textarea, ...)
@@ -151,6 +151,7 @@ class DolEditor
*/
function Create($noprint=0, $morejs='', $disallowAnyContent=true, $titlecontent='', $option='')
{
+ // phpcs:enable
global $conf,$langs;
$fullpage=false;
@@ -345,6 +346,4 @@ class DolEditor
if ($noprint) return $out;
else print $out;
}
-
}
-
diff --git a/htdocs/core/class/dolgraph.class.php b/htdocs/core/class/dolgraph.class.php
index f40d30f389e..618716ce0e4 100644
--- a/htdocs/core/class/dolgraph.class.php
+++ b/htdocs/core/class/dolgraph.class.php
@@ -69,7 +69,11 @@ class DolGraph
var $showpercent=0;
var $combine=0; // 0.05 if you want to combine records < 5% into "other"
var $graph; // Objet Graph (Artichow, Phplot...)
- var $error;
+
+ /**
+ * @var string Error code (or message)
+ */
+ public $error='';
var $bordercolor; // array(R,G,B)
var $bgcolor; // array(R,G,B)
@@ -124,6 +128,7 @@ class DolGraph
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Set Y precision
*
@@ -132,10 +137,12 @@ class DolGraph
*/
function SetPrecisionY($which_prec)
{
+ // phpcs:enable
$this->PrecisionY = $which_prec;
return true;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Utiliser SetNumTicks ou SetHorizTickIncrement mais pas les 2
*
@@ -144,10 +151,12 @@ class DolGraph
*/
function SetHorizTickIncrement($xi)
{
+ // phpcs:enable
$this->horizTickIncrement = $xi;
return true;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Utiliser SetNumTicks ou SetHorizTickIncrement mais pas les 2
*
@@ -156,10 +165,12 @@ class DolGraph
*/
function SetNumXTicks($xt)
{
+ // phpcs:enable
$this->SetNumXTicks = $xt;
return true;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Set label interval to reduce number of labels
*
@@ -168,10 +179,12 @@ class DolGraph
*/
function SetLabelInterval($x)
{
+ // phpcs:enable
$this->labelInterval = $x;
return true;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Hide X grid
*
@@ -180,10 +193,12 @@ class DolGraph
*/
function SetHideXGrid($bool)
{
+ // phpcs:enable
$this->hideXGrid = $bool;
return true;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Hide Y grid
*
@@ -192,10 +207,12 @@ class DolGraph
*/
function SetHideYGrid($bool)
{
+ // phpcs:enable
$this->hideYGrid = $bool;
return true;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Set y label
*
@@ -204,9 +221,11 @@ class DolGraph
*/
function SetYLabel($label)
{
+ // phpcs:enable
$this->YLabel = $label;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Set width
*
@@ -215,9 +234,11 @@ class DolGraph
*/
function SetWidth($w)
{
+ // phpcs:enable
$this->width = $w;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Set title
*
@@ -226,9 +247,11 @@ class DolGraph
*/
function SetTitle($title)
{
+ // phpcs:enable
$this->title = $title;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Set data
*
@@ -238,9 +261,11 @@ class DolGraph
*/
function SetData($data)
{
+ // phpcs:enable
$this->data = $data;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Set data
*
@@ -249,9 +274,11 @@ class DolGraph
*/
function SetDataColor($datacolor)
{
+ // phpcs:enable
$this->datacolor = $datacolor;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Set type
*
@@ -260,9 +287,11 @@ class DolGraph
*/
function SetType($type)
{
+ // phpcs:enable
$this->type = $type;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Set legend
*
@@ -271,9 +300,11 @@ class DolGraph
*/
function SetLegend($legend)
{
+ // phpcs:enable
$this->Legend = $legend;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Set min width
*
@@ -282,9 +313,11 @@ class DolGraph
*/
function SetLegendWidthMin($legendwidthmin)
{
+ // phpcs:enable
$this->LegendWidthMin = $legendwidthmin;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Set max value
*
@@ -293,9 +326,11 @@ class DolGraph
*/
function SetMaxValue($max)
{
+ // phpcs:enable
$this->MaxValue = $max;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Get max value
*
@@ -303,9 +338,11 @@ class DolGraph
*/
function GetMaxValue()
{
+ // phpcs:enable
return $this->MaxValue;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Set min value
*
@@ -314,9 +351,11 @@ class DolGraph
*/
function SetMinValue($min)
{
+ // phpcs:enable
$this->MinValue = $min;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Get min value
*
@@ -324,9 +363,11 @@ class DolGraph
*/
function GetMinValue()
{
+ // phpcs:enable
return $this->MinValue;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Set height
*
@@ -335,9 +376,11 @@ class DolGraph
*/
function SetHeight($h)
{
+ // phpcs:enable
$this->height = $h;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Set shading
*
@@ -346,9 +389,11 @@ class DolGraph
*/
function SetShading($s)
{
+ // phpcs:enable
$this->SetShading = $s;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Set shading
*
@@ -357,9 +402,11 @@ class DolGraph
*/
function SetCssPrefix($s)
{
+ // phpcs:enable
$this->cssprefix = $s;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Reset bg color
*
@@ -367,9 +414,11 @@ class DolGraph
*/
function ResetBgColor()
{
+ // phpcs:enable
unset($this->bgcolor);
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Reset bgcolorgrid
*
@@ -377,6 +426,7 @@ class DolGraph
*/
function ResetBgColorGrid()
{
+ // phpcs:enable
unset($this->bgcolorgrid);
}
@@ -425,6 +475,7 @@ class DolGraph
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Define background color of complete image
*
@@ -433,6 +484,7 @@ class DolGraph
*/
function SetBgColor($bg_color = array(255,255,255))
{
+ // phpcs:enable
global $theme_bgcolor,$theme_bgcoloronglet;
if (! is_array($bg_color))
@@ -453,6 +505,7 @@ class DolGraph
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Define background color of grid
*
@@ -461,6 +514,7 @@ class DolGraph
*/
function SetBgColorGrid($bg_colorgrid = array(255,255,255))
{
+ // phpcs:enable
global $theme_bgcolor,$theme_bgcoloronglet;
if (! is_array($bg_colorgrid))
@@ -481,6 +535,7 @@ class DolGraph
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Reset data color
*
@@ -488,9 +543,11 @@ class DolGraph
*/
function ResetDataColor()
{
+ // phpcs:enable
unset($this->datacolor);
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Get max value
*
@@ -498,6 +555,7 @@ class DolGraph
*/
function GetMaxValueInData()
{
+ // phpcs:enable
$k = 0;
$vals = array();
@@ -516,6 +574,7 @@ class DolGraph
return $vals[0];
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Return min value of all data
*
@@ -523,6 +582,7 @@ class DolGraph
*/
function GetMinValueInData()
{
+ // phpcs:enable
$k = 0;
$vals = array();
@@ -541,6 +601,7 @@ class DolGraph
return $vals[0];
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Return max value of all data
*
@@ -548,6 +609,7 @@ class DolGraph
*/
function GetCeilMaxValue()
{
+ // phpcs:enable
$max = $this->GetMaxValueInData();
if ($max != 0) $max++;
$size=dol_strlen(abs(ceil($max)));
@@ -564,6 +626,7 @@ class DolGraph
return $res;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Return min value of all data
*
@@ -571,6 +634,7 @@ class DolGraph
*/
function GetFloorMinValue()
{
+ // phpcs:enable
$min = $this->GetMinValueInData();
if ($min == '') $min=0;
if ($min != 0) $min--;
@@ -618,6 +682,7 @@ class DolGraph
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Build a graph onto disk using Artichow library and return img string to it
*
@@ -627,6 +692,7 @@ class DolGraph
*/
private function draw_artichow($file,$fileurl)
{
+ // phpcs:enable
global $artichow_defaultfont;
dol_syslog(get_class($this)."::draw_artichow this->type=".join(',',$this->type));
@@ -797,6 +863,7 @@ class DolGraph
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Build a graph using JFlot library. Input when calling this method should be:
* $this->data = array(array(0=>'labelxA',1=>yA), array('labelxB',yB));
@@ -815,6 +882,7 @@ class DolGraph
*/
private function draw_jflot($file,$fileurl)
{
+ // phpcs:enable
global $artichow_defaultfont;
dol_syslog(get_class($this)."::draw_jflot this->type=".join(',',$this->type)." this->MaxValue=".$this->MaxValue);
@@ -924,7 +992,7 @@ class DolGraph
var percent=Math.round(series.percent);
var number=series.data[0][1];
return \'';
- $this->stringtoshow.='';
+ $this->stringtoshow.='';
if ($urltemp) $this->stringtoshow.='';
$this->stringtoshow.='\'+';
$this->stringtoshow.=($showlegend?'':'label+\' \'+'); // Hide label if already shown in legend
@@ -932,7 +1000,7 @@ class DolGraph
$this->stringtoshow.=($showpercent?'\'
\'+percent+\'%\'+':'');
$this->stringtoshow.='\'';
if ($urltemp) $this->stringtoshow.='';
- $this->stringtoshow.='\';
+ $this->stringtoshow.='\';
},
background: {
opacity: 0.0,
@@ -1093,6 +1161,4 @@ class DolGraph
}
return 0;
}
-
}
-
diff --git a/htdocs/core/class/dolreceiptprinter.class.php b/htdocs/core/class/dolreceiptprinter.class.php
index 2499176b58b..8734c4126e7 100644
--- a/htdocs/core/class/dolreceiptprinter.class.php
+++ b/htdocs/core/class/dolreceiptprinter.class.php
@@ -1,6 +1,6 @@
+ * Copyright (C) 2015-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
@@ -45,7 +45,7 @@
* Cut ticket partially
* Open cash drawer
* Activate buzzer
- *
+ *
* Code which can be placed everywhere
* Print QR Code
* Print date AAAA-MM-DD
@@ -94,7 +94,7 @@
require_once DOL_DOCUMENT_ROOT .'/includes/mike42/escpos-php/Escpos.php';
-
+
/**
* Class to manage Receipt Printers
*/
@@ -105,12 +105,25 @@ class dolReceiptPrinter extends Escpos
const CONNECTOR_NETWORK_PRINT = 3;
const CONNECTOR_WINDOWS_PRINT = 4;
//const CONNECTOR_JAVA = 5;
- var $db;
+
+ /**
+ * @var DoliDB Database handler.
+ */
+ public $db;
+
var $tags;
var $printer;
var $template;
- var $error;
- var $errors;
+
+ /**
+ * @var string Error code (or message)
+ */
+ public $error='';
+
+ /**
+ * @var string[] Error codes (or messages)
+ */
+ public $errors = array();
@@ -191,7 +204,6 @@ class dolReceiptPrinter extends Escpos
'dol_print_if_customer_tax_number',
'dol_print_if_customer_account_balance_positive',
);
-
}
/**
@@ -204,6 +216,7 @@ class dolReceiptPrinter extends Escpos
global $conf;
$error = 0;
$line = 0;
+ $obj = array();
$sql = 'SELECT rowid, name, fk_type, fk_profile, parameter';
$sql.= ' FROM '.MAIN_DB_PREFIX.'printer_receipt';
$sql.= ' WHERE entity = '.$conf->entity;
@@ -271,6 +284,7 @@ class dolReceiptPrinter extends Escpos
global $conf;
$error = 0;
$line = 0;
+ $obj = array();
$sql = 'SELECT rowid, name, template';
$sql.= ' FROM '.MAIN_DB_PREFIX.'printer_receipt_template';
$sql.= ' WHERE entity = '.$conf->entity;
@@ -300,16 +314,16 @@ class dolReceiptPrinter extends Escpos
function selectTypePrinter($selected='', $htmlname='printertypeid')
{
global $langs;
-
+
$options = array(
1 => $langs->trans('CONNECTOR_DUMMY'),
2 => $langs->trans('CONNECTOR_FILE_PRINT'),
3 => $langs->trans('CONNECTOR_NETWORK_PRINT'),
4 => $langs->trans('CONNECTOR_WINDOWS_PRINT')
);
-
+
$this->resprint = Form::selectarray($htmlname, $options, $selected);
-
+
return 0;
}
@@ -324,7 +338,7 @@ class dolReceiptPrinter extends Escpos
function selectProfilePrinter($selected='', $htmlname='printerprofileid')
{
global $langs;
-
+
$options = array(
0 => $langs->trans('PROFILE_DEFAULT'),
1 => $langs->trans('PROFILE_SIMPLE'),
@@ -332,12 +346,13 @@ class dolReceiptPrinter extends Escpos
3 => $langs->trans('PROFILE_P822D'),
4 => $langs->trans('PROFILE_STAR')
);
-
+
$this->profileresprint = Form::selectarray($htmlname, $options, $selected);
return 0;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Function to Add a printer in db
*
@@ -349,6 +364,7 @@ class dolReceiptPrinter extends Escpos
*/
function AddPrinter($name, $type, $profile, $parameter)
{
+ // phpcs:enable
global $conf;
$error = 0;
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'printer_receipt';
@@ -362,6 +378,7 @@ class dolReceiptPrinter extends Escpos
return $error;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Function to Update a printer in db
*
@@ -374,6 +391,7 @@ class dolReceiptPrinter extends Escpos
*/
function UpdatePrinter($name, $type, $profile, $parameter, $printerid)
{
+ // phpcs:enable
global $conf;
$error = 0;
$sql = 'UPDATE '.MAIN_DB_PREFIX.'printer_receipt';
@@ -390,6 +408,7 @@ class dolReceiptPrinter extends Escpos
return $error;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Function to Delete a printer from db
*
@@ -398,6 +417,7 @@ class dolReceiptPrinter extends Escpos
*/
function DeletePrinter($printerid)
{
+ // phpcs:enable
global $conf;
$error = 0;
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.'printer_receipt';
@@ -410,6 +430,7 @@ class dolReceiptPrinter extends Escpos
return $error;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Function to Update a printer template in db
*
@@ -420,6 +441,7 @@ class dolReceiptPrinter extends Escpos
*/
function UpdateTemplate($name, $template, $templateid)
{
+ // phpcs:enable
global $conf;
$error = 0;
$sql = 'UPDATE '.MAIN_DB_PREFIX.'printer_receipt_template';
@@ -435,6 +457,7 @@ class dolReceiptPrinter extends Escpos
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Function to Send Test page to Printer
*
@@ -443,6 +466,7 @@ class dolReceiptPrinter extends Escpos
*/
function SendTestToPrinter($printerid)
{
+ // phpcs:enable
global $conf;
$error = 0;
$img = new EscposImage(DOL_DOCUMENT_ROOT .'/theme/common/dolibarr_logo_bw.png');
@@ -469,6 +493,7 @@ class dolReceiptPrinter extends Escpos
return $error;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Function to Print Receipt Ticket
*
@@ -479,6 +504,7 @@ class dolReceiptPrinter extends Escpos
*/
function SendToPrinter($object, $templateid, $printerid)
{
+ // phpcs:enable
global $conf;
$error = 0;
$ret = $this->loadTemplate($templateid);
@@ -520,11 +546,11 @@ class dolReceiptPrinter extends Escpos
$ret = $this->InitPrinter($printerid);
if ($ret>0) {
setEventMessages($this->error, $this->errors, 'errors');
- }
- else
+ }
+ else
{
$nboflines = count($vals);
- for ($line=0; $line < $nboflines; $line++)
+ for ($line=0; $line < $nboflines; $line++)
{
switch ($vals[$line]['tag']) {
case 'DOL_ALIGN_CENTER':
@@ -632,6 +658,7 @@ class dolReceiptPrinter extends Escpos
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Function Init Printer
*
@@ -640,6 +667,7 @@ class dolReceiptPrinter extends Escpos
*/
function InitPrinter($printerid)
{
+ // phpcs:enable
global $conf;
$error=0;
$sql = 'SELECT rowid, name, fk_type, fk_profile, parameter';
diff --git a/htdocs/core/class/emailsenderprofile.class.php b/htdocs/core/class/emailsenderprofile.class.php
index 7f34165030b..d2bf33b5461 100644
--- a/htdocs/core/class/emailsenderprofile.class.php
+++ b/htdocs/core/class/emailsenderprofile.class.php
@@ -39,14 +39,17 @@ class EmailSenderProfile extends CommonObject
* @var string ID to identify managed object
*/
public $element = 'emailsenderprofile';
+
/**
* @var string Name of table without prefix where object is stored
*/
public $table_element = 'c_email_senderprofile';
+
/**
* @var array Does emailsenderprofile support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
*/
public $ismultientitymanaged = 1;
+
/**
* @var string String with name of icon for emailsenderprofile
*/
@@ -85,8 +88,17 @@ class EmailSenderProfile extends CommonObject
'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'visible'=>-1, 'enabled'=>1, 'position'=>500, 'notnull'=>1,),
'active' => array('type'=>'integer', 'label'=>'Status', 'visible'=>1, 'enabled'=>1, 'position'=>1000, 'notnull'=>-1, 'index'=>1),
);
+
+ /**
+ * @var int ID
+ */
public $rowid;
+
+ /**
+ * @var int Entity
+ */
public $entity;
+
public $label;
public $email;
public $date_creation;
@@ -307,6 +319,7 @@ class EmailSenderProfile extends CommonObject
return $this->LibStatut($this->status,$mode);
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Return the status
*
@@ -318,38 +331,32 @@ class EmailSenderProfile extends CommonObject
{
global $langs;
- if ($mode == 0)
- {
- $prefix='';
- if ($status == 1) return $langs->trans('Enabled');
- if ($status == 0) return $langs->trans('Disabled');
- }
- if ($mode == 1)
+ if ($mode == 0 || $mode == 1)
{
if ($status == 1) return $langs->trans('Enabled');
if ($status == 0) return $langs->trans('Disabled');
}
- if ($mode == 2)
+ elseif ($mode == 2)
{
if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled');
if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled');
}
- if ($mode == 3)
+ elseif ($mode == 3)
{
if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4');
if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5');
}
- if ($mode == 4)
+ elseif ($mode == 4)
{
if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled');
if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled');
}
- if ($mode == 5)
+ elseif ($mode == 5)
{
if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4');
if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5');
}
- if ($mode == 6)
+ elseif ($mode == 6)
{
if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4');
if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5');
@@ -420,7 +427,6 @@ class EmailSenderProfile extends CommonObject
{
$this->initAsSpecimenCommon();
}
-
}
/**
diff --git a/htdocs/core/class/events.class.php b/htdocs/core/class/events.class.php
index abdbb1689f8..2ac2a51d2ed 100644
--- a/htdocs/core/class/events.class.php
+++ b/htdocs/core/class/events.class.php
@@ -30,29 +30,50 @@
/**
- * Events class
+ * Events class
*/
class Events // extends CommonObject
{
- public $element='events'; //!< Id that identify managed objects
- public $table_element='events'; //!< Name of table without prefix where object is stored
+ /**
+ * @var string ID to identify managed object
+ */
+ public $element='events';
- var $id;
- var $db;
+ /**
+ * @var string Name of table without prefix where object is stored
+ */
+ public $table_element='events';
- var $error;
+ /**
+ * @var int ID
+ */
+ public $id;
+
+ /**
+ * @var DoliDB Database handler.
+ */
+ public $db;
+
+ /**
+ * @var string Error code (or message)
+ */
+ public $error='';
var $tms;
var $type;
var $entity;
var $dateevent;
- var $description;
+
+ /**
+ * @var string description
+ */
+ public $description;
// List of all Audit/Security events supported by triggers
var $eventstolog=array(
- array('id'=>'USER_LOGIN', 'test'=>1),
+ /*array('id'=>'USER_LOGIN', 'test'=>1),
array('id'=>'USER_LOGIN_FAILED', 'test'=>1),
- array('id'=>'USER_LOGOUT', 'test'=>1),
+ array('id'=>'USER_LOGOUT', 'test'=>1),*/
array('id'=>'USER_CREATE', 'test'=>1),
array('id'=>'USER_MODIFY', 'test'=>1),
array('id'=>'USER_NEW_PASSWORD', 'test'=>1),
@@ -280,5 +301,4 @@ class Events // extends CommonObject
$this->dateevent=time();
$this->description='This is a specimen event';
}
-
}
diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php
index 174e01bf74c..c86bd3eff3f 100644
--- a/htdocs/core/class/extrafields.class.php
+++ b/htdocs/core/class/extrafields.class.php
@@ -9,6 +9,7 @@
* Copyright (C) 2015 Charles-Fr BENKE
* Copyright (C) 2016 Raphaël Doursenaud
* Copyright (C) 2017 Nicolas ZABOURI
+ * 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
@@ -36,7 +37,10 @@
*/
class ExtraFields
{
- var $db;
+ /**
+ * @var DoliDB Database handler.
+ */
+ public $db;
// type of element (for what object is the extrafield)
// @deprecated
@@ -87,7 +91,11 @@ class ExtraFields
// New array to store extrafields definition
var $attributes;
- var $error;
+ /**
+ * @var string Error code (or message)
+ */
+ public $error='';
+
var $errno;
@@ -256,10 +264,10 @@ class ExtraFields
if ($type == 'varchar' && empty($lengthdb)) $lengthdb='255';
}
$field_desc = array(
- 'type'=>$typedb,
- 'value'=>$lengthdb,
- 'null'=>($required?'NOT NULL':'NULL'),
- 'default' => $default_value
+ 'type'=>$typedb,
+ 'value'=>$lengthdb,
+ 'null'=>($required?'NOT NULL':'NULL'),
+ 'default' => $default_value
);
$result=$this->db->DDLAddField(MAIN_DB_PREFIX.$table, $attrname, $field_desc);
@@ -285,6 +293,7 @@ class ExtraFields
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Add description of a new optional attribute
*
@@ -310,6 +319,7 @@ class ExtraFields
*/
private function create_label($attrname, $label='', $type='', $pos=0, $size=0, $elementtype='member', $unique=0, $required=0, $param='', $alwayseditable=0, $perms='', $list='-1', $help='', $default='', $computed='',$entity='', $langfile='', $enabled='1')
{
+ // phpcs:enable
global $conf,$user;
if ($elementtype == 'thirdparty') $elementtype='societe';
@@ -376,8 +386,8 @@ class ExtraFields
$sql.= " '".$this->db->escape($list)."',";
$sql.= " ".($default?"'".$this->db->escape($default)."'":"null").",";
$sql.= " ".($computed?"'".$this->db->escape($computed)."'":"null").",";
- $sql .= " " . $user->id . ",";
- $sql .= " " . $user->id . ",";
+ $sql .= " " . (is_object($user) ? $user->id : 0). ",";
+ $sql .= " " . (is_object($user) ? $user->id : 0). ",";
$sql .= "'" . $this->db->idate(dol_now()) . "',";
$sql.= " ".($enabled?"'".$this->db->escape($enabled)."'":"1").",";
$sql.= " ".($help?"'".$this->db->escape($help)."'":"null");
@@ -452,9 +462,9 @@ class ExtraFields
{
return 0;
}
-
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Delete description of an optional attribute
*
@@ -464,6 +474,7 @@ class ExtraFields
*/
private function delete_label($attrname, $elementtype='member')
{
+ // phpcs:enable
global $conf;
if ($elementtype == 'thirdparty') $elementtype='societe';
@@ -492,7 +503,6 @@ class ExtraFields
{
return 0;
}
-
}
/**
@@ -516,14 +526,15 @@ class ExtraFields
* @param string $entity Entity of extrafields
* @param string $langfile Language file
* @param string $enabled Condition to have the field enabled or not
+ * @param int $totalizable Is extrafield totalizable on list
* @return int >0 if OK, <=0 if KO
*/
- function update($attrname, $label, $type, $length, $elementtype, $unique=0, $required=0, $pos=0, $param='', $alwayseditable=0, $perms='', $list='', $help='', $default='', $computed='', $entity='', $langfile='', $enabled='1')
+ function update($attrname, $label, $type, $length, $elementtype, $unique=0, $required=0, $pos=0, $param='', $alwayseditable=0, $perms='', $list='', $help='', $default='', $computed='', $entity='', $langfile='', $enabled='1', $totalizable=0)
{
if ($elementtype == 'thirdparty') $elementtype='societe';
if ($elementtype == 'contact') $elementtype='socpeople';
- $table=$elementtype.'_extrafields';
+ $table=$elementtype.'_extrafields';
if ($elementtype == 'categorie') $table='categories_extrafields';
if (isset($attrname) && $attrname != '' && preg_match("/^\w[a-zA-Z0-9-_]*$/",$attrname))
@@ -568,7 +579,7 @@ class ExtraFields
{
if ($label)
{
- $result=$this->update_label($attrname,$label,$type,$length,$elementtype,$unique,$required,$pos,$param,$alwayseditable,$perms,$list,$help,$default,$computed,$entity,$langfile,$enabled);
+ $result=$this->update_label($attrname,$label,$type,$length,$elementtype,$unique,$required,$pos,$param,$alwayseditable,$perms,$list,$help,$default,$computed,$entity,$langfile,$enabled, $totalizable);
}
if ($result > 0)
{
@@ -601,9 +612,9 @@ class ExtraFields
{
return 0;
}
-
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Modify description of personalized attribute
*
@@ -625,12 +636,14 @@ class ExtraFields
* @param string $entity Entity of extrafields
* @param string $langfile Language file
* @param string $enabled Condition to have the field enabled or not
- * @return int <=0 if KO, >0 if OK
+ * @param int $totalizable Is extrafield totalizable on list
+ * @return int <=0 if KO, >0 if OK
*/
- private function update_label($attrname,$label,$type,$size,$elementtype,$unique=0,$required=0,$pos=0,$param='',$alwayseditable=0,$perms='',$list='0',$help='',$default='',$computed='',$entity='',$langfile='',$enabled='1')
+ private function update_label($attrname,$label,$type,$size,$elementtype,$unique=0,$required=0,$pos=0,$param='',$alwayseditable=0,$perms='',$list='0',$help='',$default='',$computed='',$entity='',$langfile='',$enabled='1', $totalizable=0)
{
+ // phpcs:enable
global $conf, $user;
- dol_syslog(get_class($this)."::update_label ".$attrname.", ".$label.", ".$type.", ".$size.", ".$elementtype.", ".$unique.", ".$required.", ".$pos.", ".$alwayseditable.", ".$perms.", ".$list.", ".$notused.", ".$default.", ".$computed.", ".$entity.", ".$langfile.", ".$enabled);
+ dol_syslog(get_class($this)."::update_label ".$attrname.", ".$label.", ".$type.", ".$size.", ".$elementtype.", ".$unique.", ".$required.", ".$pos.", ".$alwayseditable.", ".$perms.", ".$list.", ".$default.", ".$computed.", ".$entity.", ".$langfile.", ".$enabled.", ".$totalizable);
// Clean parameters
if ($elementtype == 'thirdparty') $elementtype='societe';
@@ -638,6 +651,9 @@ class ExtraFields
if (empty($pos)) $pos=0;
if (empty($list)) $list='0';
+ if (empty($totalizable)) {
+ $totalizable = 0;
+ }
if (empty($required)) $required=0;
if (empty($unique)) $unique=0;
if (empty($alwayseditable)) $alwayseditable=0;
@@ -659,11 +675,22 @@ class ExtraFields
$params='';
}
- $sql_del = "DELETE FROM ".MAIN_DB_PREFIX."extrafields";
- $sql_del.= " WHERE name = '".$attrname."'";
- $sql_del.= " AND entity = ".($entity===''?$conf->entity:$entity);
- $sql_del.= " AND elementtype = '".$elementtype."'";
-
+ if ($entity === '' || $entity != '0')
+ {
+ // We dont want on all entities, we delete all and current
+ $sql_del = "DELETE FROM ".MAIN_DB_PREFIX."extrafields";
+ $sql_del.= " WHERE name = '".$attrname."'";
+ $sql_del.= " AND entity IN (0, ".($entity===''?$conf->entity:$entity).")";
+ $sql_del.= " AND elementtype = '".$elementtype."'";
+ }
+ else
+ {
+ // We want on all entities ($entities = '0'), we delete on all only (we keep setup specific to each entity)
+ $sql_del = "DELETE FROM ".MAIN_DB_PREFIX."extrafields";
+ $sql_del.= " WHERE name = '".$attrname."'";
+ $sql_del.= " AND entity = 0";
+ $sql_del.= " AND elementtype = '".$elementtype."'";
+ }
$resql1=$this->db->query($sql_del);
$sql = "INSERT INTO ".MAIN_DB_PREFIX."extrafields(";
@@ -681,6 +708,7 @@ class ExtraFields
$sql.= " alwayseditable,";
$sql.= " param,";
$sql.= " list,";
+ $sql.= " totalizable,";
$sql.= " fielddefault,";
$sql.= " fieldcomputed,";
$sql.= " fk_user_author,";
@@ -703,6 +731,7 @@ class ExtraFields
$sql.= " '".$this->db->escape($alwayseditable)."',";
$sql.= " '".$this->db->escape($params)."',";
$sql.= " '".$this->db->escape($list)."', ";
+ $sql.= " ".$totalizable.",";
$sql.= " ".(($default!='')?"'".$this->db->escape($default)."'":"null").",";
$sql.= " ".($computed?"'".$this->db->escape($computed)."'":"null").",";
$sql .= " " . $user->id . ",";
@@ -733,6 +762,7 @@ class ExtraFields
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Load array this->attributes, or old this->attribute_xxx like attribute_label, attribute_type, ...
*
@@ -742,12 +772,14 @@ class ExtraFields
*/
function fetch_name_optionals_label($elementtype,$forceload=false)
{
+ // phpcs:enable
global $conf;
if (empty($elementtype)) return array();
if ($elementtype == 'thirdparty') $elementtype='societe';
if ($elementtype == 'contact') $elementtype='socpeople';
+ if ($elementtype == 'order_supplier') $elementtype='commande_fournisseur';
$array_name_label=array();
@@ -773,7 +805,7 @@ class ExtraFields
// We should not have several time this log. If we have, there is some optimization to do by calling a simple $object->fetch_optionals() that include cache management.
dol_syslog("fetch_name_optionals_label elementtype=".$elementtype);
- $sql = "SELECT rowid,name,label,type,size,elementtype,fieldunique,fieldrequired,param,pos,alwayseditable,perms,langs,list,fielddefault,fieldcomputed,entity,enabled,help";
+ $sql = "SELECT rowid,name,label,type,size,elementtype,fieldunique,fieldrequired,param,pos,alwayseditable,perms,langs,list,totalizable,fielddefault,fieldcomputed,entity,enabled,help";
$sql.= " FROM ".MAIN_DB_PREFIX."extrafields";
$sql.= " WHERE entity IN (0,".$conf->entity.")";
if ($elementtype) $sql.= " AND elementtype = '".$elementtype."'"; // Filed with object->table_element
@@ -807,6 +839,7 @@ class ExtraFields
$this->attribute_perms[$tab->name]=(strlen($tab->perms) == 0 ? 1 : $tab->perms);
$this->attribute_langfile[$tab->name]=$tab->langs;
$this->attribute_list[$tab->name]=$tab->list;
+ $this->attribute_totalizable[$tab->name]=$tab->totalizable;
$this->attribute_entityid[$tab->name]=$tab->entity;
$this->attribute_entitylabel[$tab->name]=(empty($labelmulticompany[$tab->entity])?'Entity'.$tab->entity:$labelmulticompany[$tab->entity]);
@@ -825,6 +858,7 @@ class ExtraFields
$this->attributes[$tab->elementtype]['perms'][$tab->name]=(strlen($tab->perms) == 0 ? 1 : $tab->perms);
$this->attributes[$tab->elementtype]['langfile'][$tab->name]=$tab->langs;
$this->attributes[$tab->elementtype]['list'][$tab->name]=$tab->list;
+ $this->attributes[$tab->elementtype]['totalizable'][$tab->name]=$tab->totalizable;
$this->attributes[$tab->elementtype]['entityid'][$tab->name]=$tab->entity;
$this->attributes[$tab->elementtype]['entitylabel'][$tab->name]=(empty($labelmulticompany[$tab->entity])?'Entity'.$tab->entity:$labelmulticompany[$tab->entity]);
$this->attributes[$tab->elementtype]['enabled'][$tab->name]=$tab->enabled;
@@ -886,6 +920,7 @@ class ExtraFields
$perms=dol_eval($this->attributes[$extrafieldsobjectkey]['perms'][$key], 1);
$langfile=$this->attributes[$extrafieldsobjectkey]['langfile'][$key];
$list=dol_eval($this->attributes[$extrafieldsobjectkey]['list'][$key], 1);
+ $totalizable=$this->attributes[$extrafieldsobjectkey]['totalizable'][$key];
$help=$this->attributes[$extrafieldsobjectkey]['help'][$key];
$hidden=(empty($list) ? 1 : 0); // If empty, we are sure it is hidden, otherwise we show. If it depends on mode (view/create/edit form or list, this must be filtered by caller)
}
@@ -902,6 +937,7 @@ class ExtraFields
$param=$this->attribute_param[$key];
$langfile=$this->attribute_langfile[$key];
$list=$this->attribute_list[$key];
+ $totalizable=$this->attribute_totalizable[$key];
$hidden=(empty($list) ? 1 : 0); // If empty, we are sure it is hidden, otherwise we show. If it depends on mode (view/create/edit form or list, this must be filtered by caller)
}
@@ -961,11 +997,11 @@ class ExtraFields
$showtime = in_array($type,array('datetime')) ? 1 : 0;
- // Do not show current date when field not required (see select_date() method)
+ // Do not show current date when field not required (see selectDate() method)
if (!$required && $value == '') $value = '-1';
// TODO Must also support $moreparam
- $out = $form->select_date($value, $keyprefix.$key.$keysuffix, $showtime, $showtime, $required, '', 1, (($keyprefix != 'search_' && $keyprefix != 'search_options_') ? 1 : 0), 1, 0, 1);
+ $out = $form->selectDate($value, $keyprefix.$key.$keysuffix, $showtime, $showtime, $required, '', 1, (($keyprefix != 'search_' && $keyprefix != 'search_options_') ? 1 : 0), 1, 0);
}
elseif (in_array($type,array('int','integer')))
{
@@ -1753,7 +1789,7 @@ class ExtraFields
$align='';
- if ($type == 'date')
+ if ($type == 'date')
{
$align="center";
}
@@ -1781,6 +1817,10 @@ class ExtraFields
{
$align="center";
}
+ elseif ($type == 'price')
+ {
+ $align="right";
+ }
return $align;
}
diff --git a/htdocs/core/class/fiscalyear.class.php b/htdocs/core/class/fiscalyear.class.php
index 987033d35e3..de4dc46ac90 100644
--- a/htdocs/core/class/fiscalyear.class.php
+++ b/htdocs/core/class/fiscalyear.class.php
@@ -16,7 +16,7 @@
*/
/**
- * \file htdocs/core/class/fiscalyear.php
+ * \file htdocs/core/class/fiscalyear.class.php
* \ingroup fiscal year
* \brief File of class to manage fiscal years
*/
@@ -28,23 +28,46 @@ require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php';
*/
class Fiscalyear extends CommonObject
{
+ /**
+ * @var string ID to identify managed object
+ */
public $element='fiscalyear';
+
+ /**
+ * @var string Name of table without prefix where object is stored
+ */
public $table_element='accounting_fiscalyear';
+
+ /**
+ * @var int Name of subtable line
+ */
public $table_element_line = '';
+
+ /**
+ * @var int Field with ID of parent key if this field has a parent
+ */
public $fk_element = '';
+
public $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
- var $rowid;
+ /**
+ * @var int ID
+ */
+ public $rowid;
- var $label;
- var $date_start;
- var $date_end;
- var $datec;
- var $statut; // 0=open, 1=closed
- var $entity;
+ /**
+ * @var string fiscal year label
+ */
+ public $label;
- var $statuts=array();
- var $statuts_short=array();
+ public $date_start;
+ public $date_end;
+ public $datec;
+ public $statut; // 0=open, 1=closed
+ public $entity;
+
+ public $statuts=array();
+ public $statuts_short=array();
/**
* Constructor
@@ -238,6 +261,7 @@ class Fiscalyear extends CommonObject
return $this->LibStatut($this->statut,$mode);
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Give a label from a status
*
@@ -247,35 +271,36 @@ class Fiscalyear extends CommonObject
*/
function LibStatut($statut,$mode=0)
{
+ // phpcs:enable
global $langs;
if ($mode == 0)
{
return $langs->trans($this->statuts[$statut]);
}
- if ($mode == 1)
+ elseif ($mode == 1)
{
return $langs->trans($this->statuts_short[$statut]);
}
- if ($mode == 2)
+ elseif ($mode == 2)
{
if ($statut==0) return img_picto($langs->trans($this->statuts_short[$statut]),'statut4').' '.$langs->trans($this->statuts_short[$statut]);
- if ($statut==1) return img_picto($langs->trans($this->statuts_short[$statut]),'statut8').' '.$langs->trans($this->statuts_short[$statut]);
+ elseif ($statut==1) return img_picto($langs->trans($this->statuts_short[$statut]),'statut8').' '.$langs->trans($this->statuts_short[$statut]);
}
- if ($mode == 3)
+ elseif ($mode == 3)
{
if ($statut==0 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]),'statut4');
- if ($statut==1 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]),'statut8');
+ elseif ($statut==1 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]),'statut8');
}
- if ($mode == 4)
+ elseif ($mode == 4)
{
if ($statut==0 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]),'statut4').' '.$langs->trans($this->statuts[$statut]);
- if ($statut==1 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]),'statut8').' '.$langs->trans($this->statuts[$statut]);
+ elseif ($statut==1 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]),'statut8').' '.$langs->trans($this->statuts[$statut]);
}
- if ($mode == 5)
+ elseif ($mode == 5)
{
if ($statut==0 && ! empty($this->statuts_short[$statut])) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]),'statut4');
- if ($statut==1 && ! empty($this->statuts_short[$statut])) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]),'statut6');
+ elseif ($statut==1 && ! empty($this->statuts_short[$statut])) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]),'statut6');
}
}
@@ -323,5 +348,4 @@ class Fiscalyear extends CommonObject
dol_print_error($this->db);
}
}
-
}
diff --git a/htdocs/core/class/genericobject.class.php b/htdocs/core/class/genericobject.class.php
index c89b5c31fea..993d884c88b 100644
--- a/htdocs/core/class/genericobject.class.php
+++ b/htdocs/core/class/genericobject.class.php
@@ -24,20 +24,18 @@ require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php';
/**
- * Class of a generic business object
+ * Class of a generic business object
*/
class GenericObject extends CommonObject
{
- /**
- * Constructor
- *
- * @param DoliDB $db Database handler
- */
- function __construct($db)
- {
- $this->db=$db;
- }
-
+ /**
+ * Constructor
+ *
+ * @param DoliDB $db Database handler
+ */
+ function __construct($db)
+ {
+ $this->db=$db;
+ }
}
-
diff --git a/htdocs/core/class/google.class.php b/htdocs/core/class/google.class.php
index e923ec12252..5756acd90e0 100644
--- a/htdocs/core/class/google.class.php
+++ b/htdocs/core/class/google.class.php
@@ -26,8 +26,15 @@
*/
class GoogleAPI
{
- var $db;
- var $error;
+ /**
+ * @var DoliDB Database handler.
+ */
+ public $db;
+
+ /**
+ * @var string Error code (or message)
+ */
+ public $error='';
var $key;
diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php
index 439e31caae1..b078fdc0405 100644
--- a/htdocs/core/class/hookmanager.class.php
+++ b/htdocs/core/class/hookmanager.class.php
@@ -29,9 +29,20 @@
*/
class HookManager
{
- var $db;
- var $error;
- var $errors=array();
+ /**
+ * @var DoliDB Database handler.
+ */
+ public $db;
+
+ /**
+ * @var string Error code (or message)
+ */
+ public $error='';
+
+ /**
+ * @var string[] Error codes (or messages)
+ */
+ public $errors = array();
// Context hookmanager was created for ('thirdpartycard', 'thirdpartydao', ...)
var $contextarray=array();
@@ -272,5 +283,4 @@ class HookManager
return ($error?-1:$resaction);
}
-
}
diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index 88377edfad9..177b05850ed 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -17,6 +17,7 @@
* Copyright (C) 2012-2015 Raphaël Doursenaud
* Copyright (C) 2014 Alexandre Spangaro
* Copyright (C) 2018 Ferran Marcet
+ * 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
@@ -47,8 +48,16 @@
*/
class Form
{
- var $db;
- var $error;
+ /**
+ * @var DoliDB Database handler.
+ */
+ public $db;
+
+ /**
+ * @var string Error code (or message)
+ */
+ public $error='';
+
var $num;
// Cache arrays
@@ -193,15 +202,20 @@ class Form
$morealt=' style="width: '.$cols.'"';
$cols='';
}
- $ret.='';
+
+ $valuetoshow = ($editvalue?$editvalue:$value);
+
+ $ret.='';
}
else if ($typeofdata == 'day' || $typeofdata == 'datepicker')
{
- $ret.=$this->select_date($value,$htmlname,0,0,1,'form'.$htmlname,1,0,1);
+ $ret.=$this->selectDate($value,$htmlname,0,0,1,'form'.$htmlname,1,0);
}
else if ($typeofdata == 'dayhour' || $typeofdata == 'datehourpicker')
{
- $ret.=$this->select_date($value,$htmlname,1,1,1,'form'.$htmlname,1,0,1);
+ $ret.=$this->selectDate($value,$htmlname,1,1,1,'form'.$htmlname,1,0);
}
else if (preg_match('/^select;/',$typeofdata))
{
@@ -640,6 +654,7 @@ class Form
return $ret;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Return combo list of activated countries, into language of user
*
@@ -655,6 +670,7 @@ class Form
*/
function select_country($selected='', $htmlname='country_id', $htmloption='', $maxlength=0, $morecss='minwidth300', $usecodeaskey='', $showempty=1, $disablefavorites=0)
{
+ // phpcs:enable
global $conf,$langs;
$langs->load("dict");
@@ -736,6 +752,7 @@ class Form
return $out;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Return select list of incoterms
*
@@ -750,6 +767,7 @@ class Form
*/
function select_incoterms($selected='', $location_incoterms='', $page='', $htmlname='incoterm_id', $htmloption='', $forcecombo=1, $events=array())
{
+ // phpcs:enable
global $conf,$langs;
$langs->load("dict");
@@ -828,6 +846,7 @@ class Form
return $out;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Return list of types of lines (product or service)
* Example: 0=product, 1=service, 9=other (for external module)
@@ -841,6 +860,7 @@ class Form
*/
function select_type_of_lines($selected='',$htmlname='type',$showempty=0,$hidetext=0,$forceall=0)
{
+ // phpcs:enable
global $db,$langs,$user,$conf;
// If product & services are enabled or both disabled.
@@ -883,6 +903,7 @@ class Form
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Load into cache cache_types_fees, array of types of fees
*
@@ -890,6 +911,7 @@ class Form
*/
function load_cache_types_fees()
{
+ // phpcs:enable
global $langs;
$num = count($this->cache_types_fees);
@@ -930,6 +952,7 @@ class Form
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Return list of types of notes
*
@@ -940,6 +963,7 @@ class Form
*/
function select_type_fees($selected='',$htmlname='type',$showempty=0)
{
+ // phpcs:enable
global $user, $langs;
dol_syslog(__METHOD__." selected=".$selected.", htmlname=".$htmlname, LOG_DEBUG);
@@ -968,6 +992,7 @@ class Form
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Return HTML code to select a company.
*
@@ -982,9 +1007,11 @@ class Form
*/
function select_thirdparty($selected='', $htmlname='socid', $filter='', $limit=20, $ajaxoptions=array(), $forcecombo=0)
{
+ // phpcs:enable
return $this->select_thirdparty_list($selected,$htmlname,$filter,1,0,$forcecombo,array(),'',0, $limit);
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Output html form to select a third party
*
@@ -1006,6 +1033,7 @@ class Form
*/
function select_company($selected='', $htmlname='socid', $filter='', $showempty='', $showtype=0, $forcecombo=0, $events=array(), $limit=0, $morecss='minwidth100', $moreparam='', $selected_input_value='', $hidelabel=1, $ajaxoptions=array(), $multiple=false)
{
+ // phpcs:enable
global $conf,$user,$langs;
$out='';
@@ -1047,6 +1075,7 @@ class Form
return $out;
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Output html form to select a third party.
* Note, you must use the select_company to get the component to select a third party. This function must only be called by select_company.
@@ -1068,22 +1097,37 @@ class Form
*/
function select_thirdparty_list($selected='',$htmlname='socid',$filter='',$showempty='', $showtype=0, $forcecombo=0, $events=array(), $filterkey='', $outputmode=0, $limit=0, $morecss='minwidth100', $moreparam='', $multiple=false)
{
+ // phpcs:enable
global $conf,$user,$langs;
$out='';
$num=0;
$outarray=array();
-
+
if ($selected === '') $selected = array();
else if (!is_array($selected)) $selected = array($selected);
-
+
// Clean $filter that may contains sql conditions so sql code
- if (function_exists('test_sql_and_script_inject')) $filter = test_sql_and_script_inject($filter, 3);
+ if (function_exists('test_sql_and_script_inject')) {
+ if (test_sql_and_script_inject($filter, 3)>0) {
+ $filter ='';
+ }
+ }
// On recherche les societes
$sql = "SELECT s.rowid, s.nom as name, s.name_alias, s.client, s.fournisseur, s.code_client, s.code_fournisseur";
- $sql.= " FROM ".MAIN_DB_PREFIX ."societe as s";
+
+ if ($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST) {
+ $sql .= " ,s.address, s.zip, s.town";
+ $sql .= " , dictp.code as country_code";
+ }
+
+ $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.= " )";
+ if ($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST) {
+ $sql.= " LEFT OUTER JOIN ".MAIN_DB_PREFIX."c_country as dictp ON dictp.rowid=s.fk_pays";
+ }
$sql.= " WHERE s.entity IN (".getEntity('societe').")";
if (! empty($user->socid)) $sql.= " AND s.rowid = ".$user->socid;
if ($filter) $sql.= " AND (".$filter.")";
@@ -1106,8 +1150,9 @@ class Form
if (count($scrit) > 1) $sql.=")";
if (! empty($conf->barcode->enabled))
{
- $sql .= " OR s.barcode LIKE '".$this->db->escape($filterkey)."%'";
+ $sql .= " OR s.barcode LIKE '".$this->db->escape($prefix.$filterkey)."%'";
}
+ $sql.= " OR s.code_client LIKE '".$this->db->escape($prefix.$filterkey)."%' OR s.code_fournisseur LIKE '".$this->db->escape($prefix.$filterkey)."%'";
$sql.=")";
}
$sql.=$this->db->order("nom","ASC");
@@ -1172,6 +1217,13 @@ class Form
if ($obj->client || $obj->fournisseur) $label.=')';
}
+ if ($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST) {
+ $label.='-'.$obj->address.'-'. $obj->zip.' '. $obj->town;
+ if (!empty($obj->country_code)) {
+ $label.= ' '. $langs->trans('Country'.$obj->country_code);
+ }
+ }
+
if (empty($outputmode))
{
if (in_array($obj->rowid,$selected))
@@ -1206,6 +1258,7 @@ class Form
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Return HTML combo list of absolute discounts
*
@@ -1218,6 +1271,7 @@ class Form
*/
function select_remises($selected, $htmlname, $filter, $socid, $maxvalue=0)
{
+ // phpcs:enable
global $langs,$conf;
// On recherche les remises
@@ -1281,13 +1335,14 @@ class Form
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Return list of all contacts (for a third party or all)
*
* @param int $socid Id ot third party or 0 for all
* @param string $selected Id contact pre-selectionne
* @param string $htmlname Name of HTML field ('none' for a not editable field)
- * @param int $showempty 0=no empty value, 1=add an empty value
+ * @param int $showempty 0=no empty value, 1=add an empty value, 2=add line 'Internal' (used by user edit), 3=add an empty value only if more than one record into list
* @param string $exclude List of contacts id to exclude
* @param string $limitto Disable answers that are not id in this array list
* @param integer $showfunction Add function into label
@@ -1303,6 +1358,7 @@ class Form
*/
function select_contacts($socid,$selected='',$htmlname='contactid',$showempty=0,$exclude='',$limitto='',$showfunction=0, $moreclass='', $showsoc=0, $forcecombo=0, $events=array(), $options_only=false, $moreparam='', $htmlid='')
{
+ // phpcs:enable
print $this->selectcontacts($socid,$selected,$htmlname,$showempty,$exclude,$limitto,$showfunction, $moreclass, $options_only, $showsoc, $forcecombo, $events, $moreparam, $htmlid);
return $this->num;
}
@@ -1311,17 +1367,17 @@ class Form
* Return HTML code of the SELECT of list of all contacts (for a third party or all).
* This also set the number of contacts found into $this->num
*
- * @param int $socid Id ot third party or 0 for all
+ * @param int $socid Id ot third party or 0 for all or -1 for empty list
* @param array|int $selected Array of ID of pre-selected contact id
* @param string $htmlname Name of HTML field ('none' for a not editable field)
- * @param int $showempty 0=no empty value, 1=add an empty value, 2=add line 'Internal' (used by user edit)
+ * @param int $showempty 0=no empty value, 1=add an empty value, 2=add line 'Internal' (used by user edit), 3=add an empty value only if more than one record into list
* @param string $exclude List of contacts id to exclude
* @param string $limitto Disable answers that are not id in this array list
* @param integer $showfunction Add function into label
* @param string $moreclass Add more class to class style
* @param bool $options_only Return options only (for ajax treatment)
* @param integer $showsoc Add company into label
- * @param int $forcecombo Force to use combo box
+ * @param int $forcecombo Force to use combo box (so no ajax beautify effect)
* @param array $events Event options. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled')))
* @param string $moreparam Add more parameters onto the select tag. For example 'style="width: 95%"' to avoid select2 component to go over parent container
* @param string $htmlid Html id to use instead of htmlname
@@ -1335,7 +1391,7 @@ class Form
$langs->load('companies');
if (empty($htmlid)) $htmlid = $htmlname;
-
+
if ($selected === '') $selected = array();
else if (!is_array($selected)) $selected = array($selected);
$out='';
@@ -1346,7 +1402,7 @@ class Form
$sql.= " FROM ".MAIN_DB_PREFIX ."socpeople as sp";
if ($showsoc > 0) $sql.= " LEFT OUTER JOIN ".MAIN_DB_PREFIX ."societe as s ON s.rowid=sp.fk_soc";
$sql.= " WHERE sp.entity IN (".getEntity('socpeople').")";
- if ($socid > 0) $sql.= " AND sp.fk_soc=".$socid;
+ if ($socid > 0 || $socid == -1) $sql.= " AND sp.fk_soc=".$socid;
if (! empty($conf->global->CONTACT_HIDE_INACTIVE_IN_COMBOBOX)) $sql.= " AND sp.statut <> 0";
$sql.= " ORDER BY sp.lastname ASC";
@@ -1363,7 +1419,7 @@ class Form
}
if ($htmlname != 'none' || $options_only) $out.= '