';
print_liste_field_titre("AccountAccounting", $_SERVER['PHP_SELF'], "t.numero_compte", "", $param, "", $sortfield, $sortorder);
print_liste_field_titre("Label", $_SERVER['PHP_SELF'], "t.label_operation", "", $param, "", $sortfield, $sortorder);
- print_liste_field_titre("Opening Balance", $_SERVER['PHP_SELF'], "", $param, "", 'class="right"', $sortfield, $sortorder);
+ print_liste_field_titre("OpeningBalance", $_SERVER['PHP_SELF'], "", $param, "", 'class="right"', $sortfield, $sortorder);
print_liste_field_titre("Debit", $_SERVER['PHP_SELF'], "t.debit", "", $param, 'class="right"', $sortfield, $sortorder);
print_liste_field_titre("Credit", $_SERVER['PHP_SELF'], "t.credit", "", $param, 'class="right"', $sortfield, $sortorder);
print_liste_field_titre("Balance", $_SERVER["PHP_SELF"], "", $param, "", 'class="right"', $sortfield, $sortorder);
diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php
index 9b6ad2fbbb0..e50112f7ff1 100644
--- a/htdocs/accountancy/bookkeeping/list.php
+++ b/htdocs/accountancy/bookkeeping/list.php
@@ -93,7 +93,7 @@ $search_not_reconciled = GETPOST('search_reconciled_option', 'alpha');
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
-$page = GETPOST('page', 'int');
+$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page < 0) { $page = 0; }
$offset = $limit * $page;
$pageprev = $page - 1;
@@ -204,7 +204,7 @@ if (empty($reshook))
$search_debit = '';
$search_credit = '';
$search_lettering_code = '';
- $search_not_reconciled='';
+ $search_not_reconciled = '';
}
// Must be after the remove filter action, before the export.
@@ -276,32 +276,32 @@ if (empty($reshook))
if (!empty($search_date_creation_start)) {
$filter['t.date_creation>='] = $search_date_creation_start;
$tmp = dol_getdate($search_date_creation_start);
- $param .= '&date_creation_startmonth=' . urlencode($tmp['mon']) . '&date_creation_startday=' . urlencode($tmp['mday']) . '&date_creation_startyear=' . urlencode($tmp['year']);
+ $param .= '&date_creation_startmonth='.urlencode($tmp['mon']).'&date_creation_startday='.urlencode($tmp['mday']).'&date_creation_startyear='.urlencode($tmp['year']);
}
if (!empty($search_date_creation_end)) {
$filter['t.date_creation<='] = $search_date_creation_end;
$tmp = dol_getdate($search_date_creation_end);
- $param .= '&date_creation_endmonth=' .urlencode($tmp['mon']) . '&date_creation_endday=' . urlencode($tmp['mday']) . '&date_creation_endyear=' . urlencode($tmp['year']);
+ $param .= '&date_creation_endmonth='.urlencode($tmp['mon']).'&date_creation_endday='.urlencode($tmp['mday']).'&date_creation_endyear='.urlencode($tmp['year']);
}
if (!empty($search_date_modification_start)) {
$filter['t.tms>='] = $search_date_modification_start;
$tmp = dol_getdate($search_date_modification_start);
- $param .= '&date_modification_startmonth=' . urlencode($tmp['mon']) . '&date_modification_startday=' . urlencode($tmp['mday']) . '&date_modification_startyear=' . urlencode($tmp['year']);
+ $param .= '&date_modification_startmonth='.urlencode($tmp['mon']).'&date_modification_startday='.urlencode($tmp['mday']).'&date_modification_startyear='.urlencode($tmp['year']);
}
if (!empty($search_date_modification_end)) {
$filter['t.tms<='] = $search_date_modification_end;
$tmp = dol_getdate($search_date_modification_end);
- $param .= '&date_modification_endmonth=' . urlencode($tmp['mon']) . '&date_modification_endday=' . urlencode($tmp['mday']) . '&date_modification_endyear=' . urlencode($tmp['year']);
+ $param .= '&date_modification_endmonth='.urlencode($tmp['mon']).'&date_modification_endday='.urlencode($tmp['mday']).'&date_modification_endyear='.urlencode($tmp['year']);
}
if (!empty($search_date_export_start)) {
$filter['t.date_export>='] = $search_date_export_start;
$tmp = dol_getdate($search_date_export_start);
- $param .= '&date_export_startmonth=' . urlencode($tmp['mon']) . '&date_export_startday=' . urlencode($tmp['mday']) . '&date_export_startyear=' . urlencode($tmp['year']);
+ $param .= '&date_export_startmonth='.urlencode($tmp['mon']).'&date_export_startday='.urlencode($tmp['mday']).'&date_export_startyear='.urlencode($tmp['year']);
}
if (!empty($search_date_export_end)) {
$filter['t.date_export<='] = $search_date_export_end;
$tmp = dol_getdate($search_date_export_end);
- $param .= '&date_export_endmonth=' . urlencode($tmp['mon']) . '&date_export_endday=' . urlencode($tmp['mday']) . '&date_export_endyear=' . urlencode($tmp['year']);
+ $param .= '&date_export_endmonth='.urlencode($tmp['mon']).'&date_export_endday='.urlencode($tmp['mday']).'&date_export_endyear='.urlencode($tmp['year']);
}
if (!empty($search_debit)) {
$filter['t.debit'] = $search_debit;
@@ -315,9 +315,9 @@ if (empty($reshook))
$filter['t.lettering_code'] = $search_lettering_code;
$param .= '&search_lettering_code='.urlencode($search_lettering_code);
}
- if (! empty($search_not_reconciled)) {
+ if (!empty($search_not_reconciled)) {
$filter['t.reconciled_option'] = $search_not_reconciled;
- $param .= '&search_not_reconciled=' . urlencode($search_not_reconciled);
+ $param .= '&search_not_reconciled='.urlencode($search_not_reconciled);
}
}
@@ -768,7 +768,7 @@ if (!empty($arrayfields['t.lettering_code']['checked']))
{
print '';
print ' ';
- print ' '.$langs->trans("NotReconciled").' ';
+ print ' '.$langs->trans("NotReconciled").' ';
print ' ';
}
// Code journal
@@ -953,9 +953,9 @@ while ($i < min($num, $limit))
$objectstatic->fetch($line->fk_doc);
//$modulepart = 'expensereport';
- $filename=dol_sanitizeFileName($line->doc_ref);
- $filedir=$conf->expensereport->dir_output . '/' . dol_sanitizeFileName($line->doc_ref);
- $urlsource=$_SERVER['PHP_SELF'].'?id='.$objectstatic->id;
+ $filename = dol_sanitizeFileName($line->doc_ref);
+ $filedir = $conf->expensereport->dir_output.'/'.dol_sanitizeFileName($line->doc_ref);
+ $urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id;
$documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
}
else
@@ -969,7 +969,7 @@ while ($i < min($num, $limit))
// Picto + Ref
print '';
- if($line->doc_type == 'customer_invoice' || $line->doc_type == 'supplier_invoice' || $line->doc_type == 'expense_report')
+ if ($line->doc_type == 'customer_invoice' || $line->doc_type == 'supplier_invoice' || $line->doc_type == 'expense_report')
{
print $objectstatic->getNomUrl(1, '', 0, 0, '', 0, -1, 1);
print $documentlink;
diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php
index 2cb28b59584..bb6f95d9047 100644
--- a/htdocs/accountancy/bookkeeping/listbyaccount.php
+++ b/htdocs/accountancy/bookkeeping/listbyaccount.php
@@ -62,7 +62,7 @@ $search_credit = GETPOST('search_credit', 'alpha');
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
-$page = GETPOST('page', 'int');
+$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page < 0) { $page = 0; }
$offset = $limit * $page;
$pageprev = $page - 1;
diff --git a/htdocs/accountancy/bookkeeping/thirdparty_lettering_customer.php b/htdocs/accountancy/bookkeeping/thirdparty_lettering_customer.php
index 91ce9f5e31a..1dfb324599c 100644
--- a/htdocs/accountancy/bookkeeping/thirdparty_lettering_customer.php
+++ b/htdocs/accountancy/bookkeeping/thirdparty_lettering_customer.php
@@ -47,7 +47,7 @@ $socid = GETPOST('socid', 'int')?GETPOST('socid', 'int'):GETPOST('id', 'int
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
-$page = GETPOST("page", 'int');
+$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == - 1) {
$page = 0;
} // If $page is not defined, or '' or -1
diff --git a/htdocs/accountancy/bookkeeping/thirdparty_lettering_supplier.php b/htdocs/accountancy/bookkeeping/thirdparty_lettering_supplier.php
index 867f5303ff8..5a5a4d36c21 100644
--- a/htdocs/accountancy/bookkeeping/thirdparty_lettering_supplier.php
+++ b/htdocs/accountancy/bookkeeping/thirdparty_lettering_supplier.php
@@ -46,7 +46,7 @@ $socid = GETPOST('socid', 'int')?GETPOST('socid', 'int'):GETPOST('id', 'int
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
-$page = GETPOST("page", 'int');
+$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == - 1) {
$page = 0;
} // If $page is not defined, or '' or -1
diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php
index 847aa3ef47e..bb1f1b8679c 100644
--- a/htdocs/accountancy/class/accountancyexport.class.php
+++ b/htdocs/accountancy/class/accountancyexport.class.php
@@ -54,6 +54,7 @@ class AccountancyExport
public static $EXPORT_TYPE_QUADRATUS = 60;
public static $EXPORT_TYPE_OPENCONCERTO = 100;
public static $EXPORT_TYPE_LDCOMPTA = 110;
+ public static $EXPORT_TYPE_LDCOMPTA10 = 120;
public static $EXPORT_TYPE_FEC = 1000;
@@ -110,8 +111,9 @@ class AccountancyExport
self::$EXPORT_TYPE_OPENCONCERTO => $langs->trans('Modelcsv_openconcerto'),
self::$EXPORT_TYPE_SAGE50_SWISS => $langs->trans('Modelcsv_Sage50_Swiss'),
self::$EXPORT_TYPE_LDCOMPTA => $langs->trans('Modelcsv_LDCompta'),
+ self::$EXPORT_TYPE_LDCOMPTA10 => $langs->trans('Modelcsv_LDCompta10'),
self::$EXPORT_TYPE_FEC => $langs->trans('Modelcsv_FEC'),
- self::$EXPORT_TYPE_CHARLEMAGNE => $langs->trans('Modelcsv_charlemagne'),
+ self::$EXPORT_TYPE_CHARLEMAGNE => $langs->trans('Modelcsv_charlemagne'),
);
ksort($listofexporttypes, SORT_NUMERIC);
@@ -140,6 +142,7 @@ class AccountancyExport
self::$EXPORT_TYPE_OPENCONCERTO => 'openconcerto',
self::$EXPORT_TYPE_SAGE50_SWISS => 'sage50ch',
self::$EXPORT_TYPE_LDCOMPTA => 'ldcompta',
+ self::$EXPORT_TYPE_LDCOMPTA10 => 'ldcompta10',
self::$EXPORT_TYPE_FEC => 'fec',
);
@@ -201,6 +204,10 @@ class AccountancyExport
self::$EXPORT_TYPE_LDCOMPTA => array(
'label' => $langs->trans('Modelcsv_LDCompta'),
'ACCOUNTING_EXPORT_FORMAT' => 'csv',
+ ),
+ self::$EXPORT_TYPE_LDCOMPTA10 => array(
+ 'label' => $langs->trans('Modelcsv_LDCompta10'),
+ 'ACCOUNTING_EXPORT_FORMAT' => 'csv',
),
self::$EXPORT_TYPE_FEC => array(
'label' => $langs->trans('Modelcsv_FEC'),
@@ -280,6 +287,9 @@ class AccountancyExport
case self::$EXPORT_TYPE_LDCOMPTA :
$this->exportLDCompta($TData);
break;
+ case self::$EXPORT_TYPE_LDCOMPTA10 :
+ $this->exportLDCompta10($TData);
+ break;
case self::$EXPORT_TYPE_FEC :
$this->exportFEC($TData);
break;
@@ -921,7 +931,7 @@ class AccountancyExport
/**
* Export format : LD Compta version 9 & higher
- * http://www.ldsysteme.fr/fileadmin/telechargement/np/ldcompta/Documentation/IntCptW10.pdf
+ * http://www.ldsysteme.fr/fileadmin/telechargement/np/ldcompta/Documentation/IntCptW9.pdf
*
* @param array $objectLines data
*
@@ -1051,6 +1061,261 @@ class AccountancyExport
}
}
+ /**
+ * Export format : LD Compta version 10 & higher
+ * http://www.ldsysteme.fr/fileadmin/telechargement/np/ldcompta/Documentation/IntCptW10.pdf
+ *
+ * @param array $objectLines data
+ *
+ * @return void
+ */
+ public function exportLDCompta10($objectLines)
+ {
+ require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
+
+ $separator = ';';
+ $end_line = "\r\n";
+ $last_codeinvoice = '';
+
+ foreach ($objectLines as $line) {
+ // TYPE C
+ if($last_codeinvoice != $line->doc_ref){
+ //recherche societe en fonction de son code client
+ $sql = "SELECT code_client, fk_forme_juridique, nom, address, zip, town, fk_pays, phone, siret FROM ".MAIN_DB_PREFIX."societe WHERE code_client = '".$line->thirdparty_code ."'";
+ $resql = $this->db->query($sql);
+
+ if($resql && $this->db->num_rows($resql)>0)
+ {
+ $soc = $this->db->fetch_object($resql);
+
+ $address = str_replace(array("\t", "\n", "\r"), " ", $soc->address);
+
+ $type_enregistrement = 'C';
+ print $type_enregistrement.$separator;
+ //NOCL
+ print $soc->code_client.$separator;
+ //NMCM
+ print $separator;
+ //LIBI
+ print $separator;
+ //TITR
+ print getFormeJuridiqueLabel($soc->fk_forme_juridique).$separator;
+ //RSSO
+ print $soc->nom.$separator;
+ //CAD1
+ print substr($address, 0, 40).$separator;
+ //CAD2
+ print substr($address, 41, 40).$separator;
+ //CAD3
+ print substr($address, 82, 40).$separator;
+ //COPO
+ print $soc->zip.$separator;
+ //BUDI
+ print substr($soc->town, 0, 40).$separator;
+ //CPAY
+ print $separator;
+ //PAYS
+ print substr(getCountry($soc->fk_pays), 0, 40).$separator;
+ //NTEL
+ print $soc->phone.$separator;
+ //TLEX
+ print $separator;
+ //TLPO
+ print $separator;
+ //TLCY
+ print $separator;
+ //NINT
+ print $separator;
+ //COMM
+ print $separator;
+ //SIRE
+ print $soc->siret.$separator;
+ //RIBP
+ print $separator;
+ //DOBQ
+ print $separator;
+ //IBBQ
+ print $separator;
+ //COBQ
+ print $separator;
+ //GUBQ
+ print $separator;
+ //CPBQ
+ print $separator;
+ //CLBQ
+ print $separator;
+ //BIBQ
+ print $separator;
+ //MOPM
+ print $separator;
+ //DJPM
+ print $separator;
+ //DMPM
+ print $separator;
+ //REFM
+ print $separator;
+ //SLVA
+ print $separator;
+ //PLCR
+ print $separator;
+ //ECFI
+ print $separator;
+ //CREP
+ print $separator;
+ //NREP
+ print $separator;
+ //TREP
+ print $separator;
+ //MREP
+ print $separator;
+ //GRRE
+ print $separator;
+ //LTTA
+ print $separator;
+ //CACT
+ print $separator;
+ //CODV
+ print $separator;
+ //GRTR
+ print $separator;
+ //NOFP
+ print $separator;
+ //BQAF
+ print $separator;
+ //BONP
+ print $separator;
+ //CESC
+ print $separator;
+
+ print $end_line;
+ }
+ }
+
+ $date_document = dol_print_date($line->doc_date, '%Y%m%d');
+ $date_creation = dol_print_date($line->date_creation, '%Y%m%d');
+ $date_lim_reglement = dol_print_date($line->date_lim_reglement, '%Y%m%d');
+
+ // TYPE E
+ $type_enregistrement = 'E'; // For write movement
+ print $type_enregistrement.$separator;
+ // JNAL
+ print substr($line->code_journal, 0, 2).$separator;
+ // NECR
+ print $line->id.$separator;
+ // NPIE
+ print $line->piece_num.$separator;
+ // DATP
+ print $date_document.$separator;
+ // LIBE
+ print dol_trunc($line->label_operation, 25, 'right', 'UTF-8', 1).$separator;
+ // DATH
+ print $date_lim_reglement.$separator;
+ // CNPI
+ if ($line->doc_type == 'supplier_invoice') {
+ if ($line->montant < 0) {
+ $nature_piece = 'AF';
+ } else {
+ $nature_piece = 'FF';
+ }
+ } elseif ($line->doc_type == 'customer_invoice') {
+ if ($line->montant < 0) {
+ $nature_piece = 'AC';
+ } else {
+ $nature_piece = 'FC';
+ }
+ } else {
+ $nature_piece = '';
+ }
+ print $nature_piece.$separator;
+ // RACI
+ // if (! empty($line->subledger_account)) {
+ // if ($line->doc_type == 'supplier_invoice') {
+ // $racine_subledger_account = '40';
+ // } elseif ($line->doc_type == 'customer_invoice') {
+ // $racine_subledger_account = '41';
+ // } else {
+ // $racine_subledger_account = '';
+ // }
+ // } else {
+ $racine_subledger_account = ''; // for records of type E leave this field blank
+ // }
+
+ print $racine_subledger_account . $separator; // deprecated CPTG & CPTA use instead
+ // MONT
+ print price(abs($line->montant), 0, '', 1, 2).$separator;
+ // CODC
+ print $line->sens.$separator;
+ // CPTG
+ print length_accountg($line->numero_compte).$separator;
+ // DATE
+ print $date_document.$separator;
+ // CLET
+ print $line->lettering_code.$separator;
+ // DATL
+ print $line->date_lettering.$separator;
+ // CPTA
+ if (!empty($line->subledger_account)) {
+ print length_accounta($line->subledger_account).$separator;
+ } else {
+ print $separator;
+ }
+ // CNAT
+ if ($line->doc_type == 'supplier_invoice' && !empty($line->subledger_account)) {
+ print 'F'.$separator;
+ } elseif ($line->doc_type == 'customer_invoice' && !empty($line->subledger_account)) {
+ print 'C'.$separator;
+ } else {
+ print $separator;
+ }
+ // SECT
+ print $separator;
+ // CTRE
+ print $separator;
+ // NORL
+ print $separator;
+ // DATV
+ print $separator;
+ // REFD
+ print $line->doc_ref.$separator;
+ // NECA
+ print '0'.$separator;
+ // CSEC
+ print $separator;
+ // CAFF
+ print $separator;
+ // CDES
+ print $separator;
+ // QTUE
+ print '0'.$separator;
+ // MTDV
+ print $separator;
+ // CODV
+ print '0'.$separator;
+ // TXDV
+ print $separator;
+ // MOPM
+ print $separator;
+ // BONP
+ print $separator;
+ // BQAF
+ print $separator;
+ // ECES
+ print $separator;
+ // TXTL
+ print $separator;
+ // ECRM
+ print $separator;
+ // DATK
+ print $separator;
+ // HEUK
+ print $separator;
+
+ print $end_line;
+
+ $last_codeinvoice = $line->doc_ref;
+ }
+ }
+
/**
* Export format : Charlemagne
*
diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php
index 21f7c1cb210..0178f87a32d 100644
--- a/htdocs/accountancy/class/accountingaccount.class.php
+++ b/htdocs/accountancy/class/accountingaccount.class.php
@@ -135,6 +135,11 @@ class AccountingAccount extends CommonObject
*/
public $active;
+ /**
+ * @var int reconciliable
+ */
+ public $reconciliable;
+
/**
* Constructor
*
@@ -162,7 +167,7 @@ class AccountingAccount extends CommonObject
global $conf;
if ($rowid || $account_number) {
- $sql = "SELECT a.rowid as rowid, a.datec, a.tms, a.fk_pcg_version, a.pcg_type, a.account_number, a.account_parent, a.label, a.labelshort, a.fk_accounting_category, a.fk_user_author, a.fk_user_modif, a.active";
+ $sql = "SELECT a.rowid as rowid, a.datec, a.tms, a.fk_pcg_version, a.pcg_type, a.account_number, a.account_parent, a.label, a.labelshort, a.fk_accounting_category, a.fk_user_author, a.fk_user_modif, a.active, a.reconciliable";
$sql .= ", ca.label as category_label";
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as a";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_accounting_category as ca ON a.fk_accounting_category = ca.rowid";
@@ -203,6 +208,7 @@ class AccountingAccount extends CommonObject
$this->fk_user_modif = $obj->fk_user_modif;
$this->active = $obj->active;
$this->status = $obj->active;
+ $this->reconciliable = $obj->reconciliable;
return $this->id;
} else {
@@ -261,6 +267,7 @@ class AccountingAccount extends CommonObject
$sql .= ", fk_accounting_category";
$sql .= ", fk_user_author";
$sql .= ", active";
+ $sql .= ", reconciliable";
$sql .= ") VALUES (";
$sql .= " '" . $this->db->idate($now) . "'";
$sql .= ", " . $conf->entity;
@@ -273,6 +280,7 @@ class AccountingAccount extends CommonObject
$sql .= ", " . (empty($this->account_category) ? 0 : (int) $this->account_category);
$sql .= ", " . $user->id;
$sql .= ", " . (int) $this->active;
+ $sql .= ", " . (int) $this->reconciliable;
$sql .= ")";
$this->db->begin();
@@ -340,6 +348,7 @@ class AccountingAccount extends CommonObject
$sql .= " , fk_accounting_category = " . (empty($this->account_category) ? 0 : (int) $this->account_category);
$sql .= " , fk_user_modif = " . $user->id;
$sql .= " , active = " . (int) $this->active;
+ $sql .= " , reconciliable = " . (int) $this->reconciliable;
$sql .= " WHERE rowid = " . $this->id;
dol_syslog(get_class($this) . "::update sql=" . $sql, LOG_DEBUG);
@@ -565,21 +574,31 @@ class AccountingAccount extends CommonObject
* Account deactivated
*
* @param int $id Id
+ * @param int $mode 0=field active, 1=field active_customer_list, 2=field_active_supplier_list
* @return int <0 if KO, >0 if OK
*/
- public function account_desactivate($id)
+ public function account_desactivate($id, $mode = 0)
{
// phpcs:enable
$result = $this->checkUsage();
+ if ($mode == 0)
+ {
+ $fieldtouse = 'active';
+ }
+ elseif ($mode == 1)
+ {
+ $fieldtouse = 'reconciliable';
+ }
+
if ($result > 0) {
$this->db->begin();
$sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_account ";
- $sql .= "SET active = '0'";
+ $sql .= "SET " . $fieldtouse . " = '0'";
$sql .= " WHERE rowid = " . $this->db->escape($id);
- dol_syslog(get_class($this) . "::desactivate sql=" . $sql, LOG_DEBUG);
+ dol_syslog(get_class($this) . "::account_desactivate " . $fieldtouse . " sql=" . $sql, LOG_DEBUG);
$result = $this->db->query($sql);
if ($result) {
@@ -600,18 +619,28 @@ class AccountingAccount extends CommonObject
* Account activated
*
* @param int $id Id
+ * @param int $mode 0=field active, 1=field reconciliable, 2=field active_customer_list, 3=field_active_supplier_list
* @return int <0 if KO, >0 if OK
*/
- public function account_activate($id)
+ public function account_activate($id, $mode = 0)
{
// phpcs:enable
$this->db->begin();
+ if ($mode == 0)
+ {
+ $fieldtouse = 'active';
+ }
+ elseif ($mode == 1)
+ {
+ $fieldtouse = 'reconciliable';
+ }
+
$sql = "UPDATE " . MAIN_DB_PREFIX . "accounting_account ";
- $sql .= "SET active = '1'";
+ $sql .= "SET " . $fieldtouse . " = '1'";
$sql .= " WHERE rowid = " . $this->db->escape($id);
- dol_syslog(get_class($this) . "::activate sql=" . $sql, LOG_DEBUG);
+ dol_syslog(get_class($this) . "::account_activate " . $fieldtouse . " sql=" . $sql, LOG_DEBUG);
$result = $this->db->query($sql);
if ($result) {
$this->db->commit();
diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php
index 48df5ce374a..19a5adcca34 100644
--- a/htdocs/accountancy/customer/index.php
+++ b/htdocs/accountancy/customer/index.php
@@ -122,8 +122,8 @@ if ($action == 'validatehistory') {
// Customer Invoice lines (must be same request than into page list.php for manual binding)
$sql = "SELECT f.rowid as facid, f.ref as ref, f.datef, f.type as ftype,";
$sql .= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,";
- $sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.accountancy_code_sell as code_sell, p.tva_tx as tva_tx_prod,";
- $sql .= " p.accountancy_code_sell_intra as code_sell_intra, p.accountancy_code_sell_export as code_sell_export,";
+ $sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.tva_tx as tva_tx_prod,";
+ $sql .= " p.accountancy_code_sell as code_sell, p.accountancy_code_sell_intra as code_sell_intra, p.accountancy_code_sell_export as code_sell_export,";
$sql .= " aa.rowid as aarowid, aa2.rowid as aarowid_intra, aa3.rowid as aarowid_export,";
$sql .= " co.code as country_code, co.label as country_label,";
$sql .= " s.tva_intra";
@@ -154,14 +154,22 @@ if ($action == 'validatehistory') {
$isBuyerInEEC = isInEEC($objp);
- // Search suggested account for product/service
+ // Search suggested account for product/service (similar code exists in page list.php to make manual binding)
$suggestedaccountingaccountfor = '';
if (($objp->country_code == $mysoc->country_code) || empty($objp->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country)
$objp->code_sell_p = $objp->code_sell;
$objp->aarowid_suggest = $objp->aarowid;
$suggestedaccountingaccountfor = '';
} else {
- if ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale
+ if ($isSellerInEEC && $isBuyerInEEC && $objp->tva_tx_line != 0) { // European intravat sale, but with VAT
+ $objp->code_sell_p = $objp->code_sell;
+ $objp->aarowid_suggest = $objp->aarowid;
+ $suggestedaccountingaccountfor = 'eecwithvat';
+ } elseif ($isSellerInEEC && $isBuyerInEEC && empty($objp->tva_intra)) { // European intravat sale, without VAT intra community number
+ $objp->code_sell_p = $objp->code_sell;
+ $objp->aarowid_suggest = 0; // There is a doubt, no automatic binding
+ $suggestedaccountingaccountfor = 'eecwithoutvatnumber';
+ } elseif ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale
$objp->code_sell_p = $objp->code_sell_intra;
$objp->aarowid_suggest = $objp->aarowid_intra;
$suggestedaccountingaccountfor = 'eec';
diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php
index d52c4c51f07..55342a98c27 100644
--- a/htdocs/accountancy/customer/lines.php
+++ b/htdocs/accountancy/customer/lines.php
@@ -60,7 +60,7 @@ $search_tvaintra = GETPOST('search_tvaintra', 'alpha');
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
-$page = GETPOST('page', 'int');
+$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page < 0) $page = 0;
$pageprev = $page - 1;
$pagenext = $page + 1;
diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php
index d964d348889..9e4f73d8f7a 100644
--- a/htdocs/accountancy/customer/list.php
+++ b/htdocs/accountancy/customer/list.php
@@ -69,7 +69,7 @@ $btn_ventil = GETPOST('ventil', 'alpha');
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
-$page = GETPOST('page', 'int');
+$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page < 0) { $page = 0; }
$offset = $limit * $page;
$pageprev = $page - 1;
@@ -206,8 +206,10 @@ if (empty($chartaccountcode))
// Customer Invoice lines
$sql = "SELECT f.rowid as facid, f.ref as ref, f.datef, f.type as ftype,";
$sql .= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,";
-$sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.accountancy_code_sell as code_sell, p.tva_tx as tva_tx_prod,";
-$sql .= " p.accountancy_code_sell_intra as code_sell_intra, p.accountancy_code_sell_export as code_sell_export,";
+$sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.tva_tx as tva_tx_prod,";
+$sql .= " p.accountancy_code_sell as code_sell, p.accountancy_code_sell_intra as code_sell_intra, p.accountancy_code_sell_export as code_sell_export,";
+$sql .= " p.accountancy_code_buy as code_buy, p.accountancy_code_buy_intra as code_buy_intra, p.accountancy_code_buy_export as code_buy_export,";
+$sql .= " p.tosell as status, p.tobuy as status_buy,";
$sql .= " aa.rowid as aarowid, aa2.rowid as aarowid_intra, aa3.rowid as aarowid_export,";
$sql .= " co.code as country_code, co.label as country_label,";
$sql .= " s.tva_intra";
@@ -399,7 +401,7 @@ if ($result) {
print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], "l.tva_tx", "", $param, '', $sortfield, $sortorder, 'right ');
print_liste_field_titre("Country", $_SERVER["PHP_SELF"], "co.label", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("VATIntra", $_SERVER["PHP_SELF"], "s.tva_intra", "", $param, '', $sortfield, $sortorder);
- print_liste_field_titre("AccountAccountingSuggest", '', '', '', '', '', '', '', 'center ');
+ print_liste_field_titre("AccountAccountingSuggest", '', '', '', '', '', '', '', 'nowraponall ');
print_liste_field_titre("IntoAccount", '', '', '', '', '', '', '', 'center ');
$checkpicto = '';
if ($massactionbutton) $checkpicto = $form->showCheckAddButtons('checkforselect', 1);
@@ -423,6 +425,14 @@ if ($result) {
$product_static->id = $objp->product_id;
$product_static->type = $objp->type;
$product_static->label = $objp->product_label;
+ $product_static->status = $objp->status;
+ $product_static->status_buy = $objp->status_buy;
+ $product_static->accountancy_code_sell = $objp->code_sell;
+ $product_static->accountancy_code_sell_intra = $objp->code_sell_intra;
+ $product_static->accountancy_code_sell_export = $objp->code_sell_export;
+ $product_static->accountancy_code_buy = $objp->code_buy;
+ $product_static->accountancy_code_buy_intra = $objp->code_buy_intra;
+ $product_static->accountancy_code_buy_export = $objp->code_buy_export;
$facture_static->ref = $objp->ref;
$facture_static->id = $objp->facid;
@@ -433,13 +443,20 @@ if ($result) {
$isBuyerInEEC = isInEEC($objp);
+ // Search suggested default account for product/service
$suggestedaccountingaccountbydefaultfor = '';
if ($objp->type_l == 1) {
if ($objp->country_code == $mysoc->country_code || empty($objp->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country)
$objp->code_sell_l = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : '');
$suggestedaccountingaccountbydefaultfor = '';
} else {
- if ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale
+ if ($isSellerInEEC && $isBuyerInEEC && $objp->tva_tx_line != 0) { // European intravat sale, but with a VAT
+ $objp->code_sell_l = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : '');
+ $suggestedaccountingaccountbydefaultfor = 'eecwithvat';
+ } elseif ($isSellerInEEC && $isBuyerInEEC && empty($objp->tva_intra)) { // European intravat sale, without VAT intra community number
+ $objp->code_sell_l = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : '');
+ $suggestedaccountingaccountbydefaultfor = 'eecwithoutvatnumber';
+ } elseif ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale
$objp->code_sell_l = (!empty($conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT : '');
$suggestedaccountingaccountbydefaultfor = 'eec';
} else { // Foreign sale
@@ -452,7 +469,13 @@ if ($result) {
$objp->code_sell_l = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : '');
$suggestedaccountingaccountbydefaultfor = '';
} else {
- if ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale
+ if ($isSellerInEEC && $isBuyerInEEC && $objp->tva_tx_line != 0) { // European intravat sale, but with a VAT
+ $objp->code_sell_l = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : '');
+ $suggestedaccountingaccountbydefaultfor = 'eecwithvat';
+ } elseif ($isSellerInEEC && $isBuyerInEEC && empty($objp->tva_intra)) { // European intravat sale, without VAT intra community number
+ $objp->code_sell_l = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : '');
+ $suggestedaccountingaccountbydefaultfor = 'eecwithoutvatnumber';
+ } elseif ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale
$objp->code_sell_l = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT : '');
$suggestedaccountingaccountbydefaultfor = 'eec';
} else {
@@ -463,14 +486,22 @@ if ($result) {
}
if ($objp->code_sell_l == -1) $objp->code_sell_l = '';
- // Search suggested account for product/service
+ // Search suggested account for product/service (similar code exists in page index.php to make automatic binding)
$suggestedaccountingaccountfor = '';
if (($objp->country_code == $mysoc->country_code) || empty($objp->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country)
$objp->code_sell_p = $objp->code_sell;
$objp->aarowid_suggest = $objp->aarowid;
$suggestedaccountingaccountfor = '';
} else {
- if ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale
+ if ($isSellerInEEC && $isBuyerInEEC && $objp->tva_tx_line != 0) { // European intravat sale, but with VAT
+ $objp->code_sell_p = $objp->code_sell;
+ $objp->aarowid_suggest = $objp->aarowid;
+ $suggestedaccountingaccountfor = 'eecwithvat';
+ } elseif ($isSellerInEEC && $isBuyerInEEC && empty($objp->tva_intra)) { // European intravat sale, without VAT intra community number
+ $objp->code_sell_p = $objp->code_sell;
+ $objp->aarowid_suggest = $objp->aarowid; // There is a doubt for this case. Is it an error on vat or we just forgot to fill vat number ?
+ $suggestedaccountingaccountfor = 'eecwithoutvatnumber';
+ } elseif ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale
$objp->code_sell_p = $objp->code_sell_intra;
$objp->aarowid_suggest = $objp->aarowid_intra;
$suggestedaccountingaccountfor = 'eec';
@@ -487,6 +518,7 @@ if ($result) {
$code_sell_p_notset = 'color:orange';
}
if (empty($objp->code_sell_l) && empty($objp->code_sell_p)) $code_sell_p_notset = 'color:red';
+ if ($suggestedaccountingaccountfor == 'eecwithoutvatnumber' && empty($code_sell_p_notset)) $code_sell_p_notset = 'color:orange';
// $objp->code_sell_l is now default code of product/service
// $objp->code_sell_p is now code of product/service
@@ -503,9 +535,10 @@ if ($result) {
// Ref Product
print ' ';
- if ($product_static->id > 0)
+ if ($product_static->id > 0) {
print $product_static->getNomUrl(1);
- if ($objp->product_label) print ' '.$objp->product_label;
+ }
+ if ($objp->product_label) print ''.$objp->product_label.' ';
print ' ';
print '';
@@ -535,7 +568,7 @@ if ($result) {
// Current account
print ' ';
- $s = (($objp->type_l == 1) ? $langs->trans("DefaultForService") : $langs->trans("DefaultForProduct")).': ';
+ $s = ''.(($objp->type_l == 1) ? $langs->trans("DefaultForService") : $langs->trans("DefaultForProduct")).': ';
$shelp = '';
if ($suggestedaccountingaccountbydefaultfor == 'eec') $shelp .= $langs->trans("SaleEEC");
elseif ($suggestedaccountingaccountbydefaultfor == 'export') $shelp .= $langs->trans("SaleExport");
@@ -544,9 +577,11 @@ if ($result) {
if ($objp->product_id > 0)
{
print ' ';
- $s = (($objp->type_l == 1) ? $langs->trans("ThisService") : $langs->trans("ThisProduct")).': ';
+ $s = ''.(($objp->type_l == 1) ? $langs->trans("ThisService") : $langs->trans("ThisProduct")).': ';
$shelp = '';
if ($suggestedaccountingaccountfor == 'eec') $shelp = $langs->trans("SaleEEC");
+ elseif ($suggestedaccountingaccountfor == 'eecwithvat') $shelp = $langs->trans("SaleEECWithVAT");
+ elseif ($suggestedaccountingaccountfor == 'eecwithoutvatnumber') $shelp = $langs->trans("SaleEECWithoutVATNumber");
elseif ($suggestedaccountingaccountfor == 'export') $shelp = $langs->trans("SaleExport");
$s .= (empty($objp->code_sell_p) ? $langs->trans("NotDefined") : length_accountg($objp->code_sell_p));
print $form->textwithpicto($s, $shelp, 1, 'help', '', 0, 2, '', 1);
@@ -582,6 +617,7 @@ if ($result) {
print ' ';
//var_dump($objp->aarowid);var_dump($objp->aarowid_intra);var_dump($objp->aarowid_export);var_dump($objp->aarowid_suggest);
$ischecked = $objp->aarowid_suggest;
+ if ($suggestedaccountingaccountfor == 'eecwithoutvatnumber') $ischecked = 0;
print ' ';
print ' ';
diff --git a/htdocs/accountancy/expensereport/lines.php b/htdocs/accountancy/expensereport/lines.php
index cc606555b37..63b142e1bdd 100644
--- a/htdocs/accountancy/expensereport/lines.php
+++ b/htdocs/accountancy/expensereport/lines.php
@@ -55,7 +55,7 @@ $search_year = GETPOST("search_year", "int");
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
-$page = GETPOST('page', 'int');
+$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page < 0) $page = 0;
$pageprev = $page - 1;
$pagenext = $page + 1;
diff --git a/htdocs/accountancy/expensereport/list.php b/htdocs/accountancy/expensereport/list.php
index c0d9d1a03b5..e03c717039f 100644
--- a/htdocs/accountancy/expensereport/list.php
+++ b/htdocs/accountancy/expensereport/list.php
@@ -62,7 +62,7 @@ $search_year = GETPOST("search_year", "int");
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
-$page = GETPOST('page', 'int');
+$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page < 0) { $page = 0; }
$offset = $limit * $page;
$pageprev = $page - 1;
@@ -313,8 +313,8 @@ if ($result) {
print_liste_field_titre("Description", $_SERVER["PHP_SELF"], "erd.comments", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "erd.total_ht", "", $param, '', $sortfield, $sortorder, 'right maxwidth50 ');
print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], "erd.tva_tx", "", $param, '', $sortfield, $sortorder, 'right ');
- print_liste_field_titre("AccountAccountingSuggest", '', '', '', '', '', $sortfield, $sortorder, 'center ');
- print_liste_field_titre("IntoAccount", '', '', '', '', '', $sortfield, $sortorder, 'center ');
+ print_liste_field_titre("AccountAccountingSuggest", '', '', '', '', '', '', '', 'nowraponall ');
+ print_liste_field_titre("IntoAccount", '', '', '', '', '', '', '', '');
$checkpicto = '';
if ($massactionbutton) $checkpicto = $form->showCheckAddButtons('checkforselect', 1);
print_liste_field_titre($checkpicto, '', '', '', '', '', '', '', 'center ');
@@ -366,12 +366,12 @@ if ($result) {
print '';
// Current account
- print '';
+ print ' ';
print length_accountg(html_entity_decode($objp->code_buy));
print ' ';
// Suggested accounting account
- print '';
+ print ' ';
print $formaccounting->select_account($objp->aarowid_suggest, 'codeventil'.$objp->rowid, 1, array(), 0, 0, 'codeventil maxwidth300 maxwidthonsmartphone', 'cachewithshowemptyone');
print ' ';
diff --git a/htdocs/accountancy/supplier/lines.php b/htdocs/accountancy/supplier/lines.php
index a035aed2b1f..ef44222568f 100644
--- a/htdocs/accountancy/supplier/lines.php
+++ b/htdocs/accountancy/supplier/lines.php
@@ -62,7 +62,7 @@ $search_tvaintra = GETPOST('search_tvaintra', 'alpha');
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
-$page = GETPOST('page', 'int');
+$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page < 0) $page = 0;
$offset = $limit * $page;
$pageprev = $page - 1;
diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php
index 2c8ad2432a3..b6c220c347a 100644
--- a/htdocs/accountancy/supplier/list.php
+++ b/htdocs/accountancy/supplier/list.php
@@ -69,7 +69,7 @@ $btn_ventil = GETPOST('ventil', 'alpha');
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
-$page = GETPOST('page', 'int');
+$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page < 0) { $page = 0; }
$offset = $limit * $page;
$pageprev = $page - 1;
@@ -210,8 +210,10 @@ if (empty($chartaccountcode))
// Supplier Invoice Lines
$sql = "SELECT f.rowid as facid, f.ref, f.ref_supplier, f.libelle as invoice_label, f.datef, f.type as ftype,";
$sql .= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,";
-$sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.accountancy_code_buy as code_buy, p.tva_tx as tva_tx_prod,";
-$sql .= " p.accountancy_code_buy_intra as code_buy_intra, p.accountancy_code_buy_export as code_buy_export,";
+$sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.tva_tx as tva_tx_prod,";
+$sql .= " p.accountancy_code_sell as code_sell, p.accountancy_code_sell_intra as code_sell_intra, p.accountancy_code_sell_export as code_sell_export,";
+$sql .= " p.accountancy_code_buy as code_buy, p.accountancy_code_buy_intra as code_buy_intra, p.accountancy_code_buy_export as code_buy_export,";
+$sql .= " p.tosell as status, p.tobuy as status_buy,";
$sql .= " aa.rowid as aarowid, aa2.rowid as aarowid_intra, aa3.rowid as aarowid_export,";
$sql .= " co.code as country_code, co.label as country_label,";
$sql .= " s.tva_intra";
@@ -399,7 +401,7 @@ if ($result) {
print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], "l.tva_tx", "", $param, '', $sortfield, $sortorder, 'right ');
print_liste_field_titre("Country", $_SERVER["PHP_SELF"], "co.label", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("VATIntra", $_SERVER["PHP_SELF"], "s.tva_intra", "", $param, '', $sortfield, $sortorder);
- print_liste_field_titre("AccountAccountingSuggest", '', '', '', '', '', '', '', 'center ');
+ print_liste_field_titre("AccountAccountingSuggest", '', '', '', '', '', '', '', 'nowraponall ');
print_liste_field_titre("IntoAccount", '', '', '', '', '', '', '', 'center ');
$checkpicto = '';
if ($massactionbutton) $checkpicto = $form->showCheckAddButtons('checkforselect', 1);
@@ -422,6 +424,14 @@ if ($result) {
$product_static->id = $objp->product_id;
$product_static->type = $objp->type;
$product_static->label = $objp->product_label;
+ $product_static->status = $objp->status;
+ $product_static->status_buy = $objp->status_buy;
+ $product_static->accountancy_code_sell = $objp->code_sell;
+ $product_static->accountancy_code_sell_intra = $objp->code_sell_intra;
+ $product_static->accountancy_code_sell_export = $objp->code_sell_export;
+ $product_static->accountancy_code_buy = $objp->code_buy;
+ $product_static->accountancy_code_buy_intra = $objp->code_buy_intra;
+ $product_static->accountancy_code_buy_export = $objp->code_buy_export;
$facturefourn_static->ref = $objp->ref;
$facturefourn_static->id = $objp->facid;
@@ -480,7 +490,7 @@ if ($result) {
}
}
- if (! empty($objp->code_buy_p)) {
+ if (!empty($objp->code_buy_p)) {
// Value was defined previously
} else {
$code_buy_p_notset = 'color:orange';
@@ -508,7 +518,7 @@ if ($result) {
print '';
if ($product_static->id > 0)
print $product_static->getNomUrl(1);
- if ($objp->product_label) print ' '.$objp->product_label;
+ if ($objp->product_label) print ''.$objp->product_label.' ';
print ' ';
// Description
@@ -539,8 +549,8 @@ if ($result) {
print ''.$objp->tva_intra.' ';
// Current account
- print '';
- $s = (($objp->type_l == 1) ? $langs->trans("DefaultForService") : $langs->trans("DefaultForProduct")).': ';
+ print ' ';
+ $s = ''.(($objp->type_l == 1) ? $langs->trans("DefaultForService") : $langs->trans("DefaultForProduct")).': ';
$shelp = '';
if ($suggestedaccountingaccountbydefaultfor == 'eec') $shelp .= $langs->trans("SaleEEC");
elseif ($suggestedaccountingaccountbydefaultfor == 'export') $shelp .= $langs->trans("SaleExport");
@@ -549,7 +559,7 @@ if ($result) {
if ($objp->product_id > 0)
{
print ' ';
- $s = (($objp->type_l == 1) ? $langs->trans("ThisService") : $langs->trans("ThisProduct")).': ';
+ $s = ''.(($objp->type_l == 1) ? $langs->trans("ThisService") : $langs->trans("ThisProduct")).': ';
$shelp = '';
if ($suggestedaccountingaccountfor == 'eec') $shelp = $langs->trans("SaleEEC");
elseif ($suggestedaccountingaccountfor == 'export') $shelp = $langs->trans("SaleExport");
@@ -561,7 +571,7 @@ if ($result) {
// Suggested accounting account
print ' ';
$suggestedid = $objp->aarowid_suggest;
- if (empty($suggestedid) && empty($objp->code_buy_p) && ! empty($objp->code_buy_l) && empty($conf->global->ACCOUNTANCY_DO_NOT_AUTOFILL_ACCOUNT_WITH_GENERIC))
+ if (empty($suggestedid) && empty($objp->code_buy_p) && !empty($objp->code_buy_l) && empty($conf->global->ACCOUNTANCY_DO_NOT_AUTOFILL_ACCOUNT_WITH_GENERIC))
{
if (empty($accountingaccount_codetotid_cache[$objp->code_buy_l]))
{
@@ -597,7 +607,7 @@ if ($result) {
print $db->error();
}
if ($db->type == 'mysqli') {
- $db->query("SET SQL_BIG_SELECTS=0"); // Enable MAX_JOIN_SIZE limitation
+ $db->query("SET SQL_BIG_SELECTS=0"); // Enable MAX_JOIN_SIZE limitation
}
// Add code to auto check the box when we select an account
diff --git a/htdocs/adherents/agenda.php b/htdocs/adherents/agenda.php
index bc738cfa18f..019f35f2908 100644
--- a/htdocs/adherents/agenda.php
+++ b/htdocs/adherents/agenda.php
@@ -41,7 +41,7 @@ $id = GETPOST('id', 'int') ?GETPOST('id', 'int') : GETPOST('rowid', 'int');
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
-$page = GETPOST("page", 'int');
+$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php
index a14cdec8fff..fa8ae9fc2f3 100644
--- a/htdocs/adherents/class/adherent.class.php
+++ b/htdocs/adherents/class/adherent.class.php
@@ -32,9 +32,9 @@
* \ingroup member
* \brief File of class to manage members of a foundation
*/
-require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php';
-require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
-require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
/**
@@ -341,7 +341,7 @@ class Adherent extends CommonObject
if (dol_textishtml($text, 0)) $msgishtml = 1;
}
- dol_syslog('send_an_email msgishtml=' . $msgishtml);
+ dol_syslog('send_an_email msgishtml='.$msgishtml);
$texttosend = $this->makeSubstitution($text);
$subjecttosend = $this->makeSubstitution($subject);
@@ -351,15 +351,15 @@ class Adherent extends CommonObject
$from = $conf->email_from;
if (!empty($conf->global->ADHERENT_MAIL_FROM)) $from = $conf->global->ADHERENT_MAIL_FROM;
- $trackid = 'mem' . $this->id;
+ $trackid = 'mem'.$this->id;
// Send email (substitutionarray must be done just before this)
- include_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php';
+ include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
$mailfile = new CMailFile($subjecttosend, $this->email, $from, $texttosend, $filename_list, $mimetype_list, $mimefilename_list, $addr_cc, $addr_bcc, $deliveryreceipt, $msgishtml, '', '', $trackid, $moreinheader);
if ($mailfile->sendfile()) {
return 1;
} else {
- $this->error = $langs->trans("ErrorFailedToSendMail", $from, $this->email) . '. ' . $mailfile->error;
+ $this->error = $langs->trans("ErrorFailedToSendMail", $from, $this->email).'. '.$mailfile->error;
return -1;
}
}
@@ -381,26 +381,26 @@ class Adherent extends CommonObject
if (dol_textishtml($text, 1)) $msgishtml = 1;
$infos = '';
- if ($this->civility_id) $infos .= $langs->transnoentities("UserTitle") . ": " . $this->getCivilityLabel() . "\n";
- $infos .= $langs->transnoentities("id") . ": " . $this->id . "\n";
- $infos .= $langs->transnoentities("Lastname") . ": " . $this->lastname . "\n";
- $infos .= $langs->transnoentities("Firstname") . ": " . $this->firstname . "\n";
- $infos .= $langs->transnoentities("Company") . ": " . $this->company . "\n";
- $infos .= $langs->transnoentities("Address") . ": " . $this->address . "\n";
- $infos .= $langs->transnoentities("Zip") . ": " . $this->zip . "\n";
- $infos .= $langs->transnoentities("Town") . ": " . $this->town . "\n";
- $infos .= $langs->transnoentities("Country") . ": " . $this->country . "\n";
- $infos .= $langs->transnoentities("EMail") . ": " . $this->email . "\n";
- $infos .= $langs->transnoentities("PhonePro") . ": " . $this->phone . "\n";
- $infos .= $langs->transnoentities("PhonePerso") . ": " . $this->phone_perso . "\n";
- $infos .= $langs->transnoentities("PhoneMobile") . ": " . $this->phone_mobile . "\n";
+ if ($this->civility_id) $infos .= $langs->transnoentities("UserTitle").": ".$this->getCivilityLabel()."\n";
+ $infos .= $langs->transnoentities("id").": ".$this->id."\n";
+ $infos .= $langs->transnoentities("Lastname").": ".$this->lastname."\n";
+ $infos .= $langs->transnoentities("Firstname").": ".$this->firstname."\n";
+ $infos .= $langs->transnoentities("Company").": ".$this->company."\n";
+ $infos .= $langs->transnoentities("Address").": ".$this->address."\n";
+ $infos .= $langs->transnoentities("Zip").": ".$this->zip."\n";
+ $infos .= $langs->transnoentities("Town").": ".$this->town."\n";
+ $infos .= $langs->transnoentities("Country").": ".$this->country."\n";
+ $infos .= $langs->transnoentities("EMail").": ".$this->email."\n";
+ $infos .= $langs->transnoentities("PhonePro").": ".$this->phone."\n";
+ $infos .= $langs->transnoentities("PhonePerso").": ".$this->phone_perso."\n";
+ $infos .= $langs->transnoentities("PhoneMobile").": ".$this->phone_mobile."\n";
if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) {
- $infos .= $langs->transnoentities("Login") . ": " . $this->login . "\n";
- $infos .= $langs->transnoentities("Password") . ": " . $this->pass . "\n";
+ $infos .= $langs->transnoentities("Login").": ".$this->login."\n";
+ $infos .= $langs->transnoentities("Password").": ".$this->pass."\n";
}
- $infos .= $langs->transnoentities("Birthday") . ": " . $birthday . "\n";
- $infos .= $langs->transnoentities("Photo") . ": " . $this->photo . "\n";
- $infos .= $langs->transnoentities("Public") . ": " . yn($this->public);
+ $infos .= $langs->transnoentities("Birthday").": ".$birthday."\n";
+ $infos .= $langs->transnoentities("Photo").": ".$this->photo."\n";
+ $infos .= $langs->transnoentities("Public").": ".yn($this->public);
// Substitutions
$substitutionarray = array('__ID__' => $this->id, '__MEMBER_ID__' => $this->id, '__CIVILITY__' => $this->getCivilityLabel(),
@@ -481,22 +481,22 @@ class Adherent extends CommonObject
$this->db->begin();
// Insert member
- $sql = "INSERT INTO " . MAIN_DB_PREFIX . "adherent";
+ $sql = "INSERT INTO ".MAIN_DB_PREFIX."adherent";
$sql .= " (datec,login,fk_user_author,fk_user_mod,fk_user_valid,morphy,fk_adherent_type,entity,import_key)";
$sql .= " VALUES (";
- $sql .= " '" . $this->db->idate($this->datec) . "'";
- $sql .= ", " . ($this->login ? "'" . $this->db->escape($this->login) . "'" : "null");
- $sql .= ", " . ($user->id > 0 ? $user->id : "null"); // Can be null because member can be created by a guest or a script
- $sql .= ", null, null, '" . $this->db->escape($this->morphy) . "'";
- $sql .= ", " . $this->typeid;
- $sql .= ", " . $conf->entity;
- $sql .= ", " . (!empty($this->import_key) ? "'" . $this->db->escape($this->import_key) . "'" : "null");
+ $sql .= " '".$this->db->idate($this->datec)."'";
+ $sql .= ", ".($this->login ? "'".$this->db->escape($this->login)."'" : "null");
+ $sql .= ", ".($user->id > 0 ? $user->id : "null"); // Can be null because member can be created by a guest or a script
+ $sql .= ", null, null, '".$this->db->escape($this->morphy)."'";
+ $sql .= ", ".$this->typeid;
+ $sql .= ", ".$conf->entity;
+ $sql .= ", ".(!empty($this->import_key) ? "'".$this->db->escape($this->import_key)."'" : "null");
$sql .= ")";
- dol_syslog(get_class($this) . "::create", LOG_DEBUG);
+ dol_syslog(get_class($this)."::create", LOG_DEBUG);
$result = $this->db->query($sql);
if ($result) {
- $id = $this->db->last_insert_id(MAIN_DB_PREFIX . "adherent");
+ $id = $this->db->last_insert_id(MAIN_DB_PREFIX."adherent");
if ($id > 0) {
$this->id = $id;
$this->ref = (string) $id;
@@ -511,10 +511,10 @@ class Adherent extends CommonObject
// Add link to user
if ($this->user_id) {
// Add link to user
- $sql = "UPDATE " . MAIN_DB_PREFIX . "user SET";
- $sql .= " fk_member = " . $this->id;
- $sql .= " WHERE rowid = " . $this->user_id;
- dol_syslog(get_class($this) . "::create", LOG_DEBUG);
+ $sql = "UPDATE ".MAIN_DB_PREFIX."user SET";
+ $sql .= " fk_member = ".$this->id;
+ $sql .= " WHERE rowid = ".$this->user_id;
+ dol_syslog(get_class($this)."::create", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql) {
$this->error = 'Failed to update user to make link with member';
@@ -533,7 +533,7 @@ class Adherent extends CommonObject
}
if (count($this->errors)) {
- dol_syslog(get_class($this) . "::create " . implode(',', $this->errors), LOG_ERR);
+ dol_syslog(get_class($this)."::create ".implode(',', $this->errors), LOG_ERR);
$this->db->rollback();
return -3;
} else {
@@ -542,7 +542,7 @@ class Adherent extends CommonObject
}
} else {
$this->error = 'Failed to get last insert id';
- dol_syslog(get_class($this) . "::create " . $this->error, LOG_ERR);
+ dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR);
$this->db->rollback();
return -2;
}
@@ -572,7 +572,7 @@ class Adherent extends CommonObject
$nbrowsaffected = 0;
$error = 0;
- dol_syslog(get_class($this) . "::update notrigger=" . $notrigger . ", nosyncuser=" . $nosyncuser . ", nosyncuserpass=" . $nosyncuserpass . " nosyncthirdparty=" . $nosyncthirdparty . ", email=" .
+ dol_syslog(get_class($this)."::update notrigger=".$notrigger.", nosyncuser=".$nosyncuser.", nosyncuserpass=".$nosyncuserpass." nosyncthirdparty=".$nosyncthirdparty.", email=".
$this->email);
// Clean parameters
@@ -598,43 +598,43 @@ class Adherent extends CommonObject
$this->db->begin();
- $sql = "UPDATE " . MAIN_DB_PREFIX . "adherent SET";
- $sql .= " civility = " . ($this->civility_id ? "'" . $this->db->escape($this->civility_id) . "'" : "null");
- $sql .= ", firstname = " . ($this->firstname ? "'" . $this->db->escape($this->firstname) . "'" : "null");
- $sql .= ", lastname = " . ($this->lastname ? "'" . $this->db->escape($this->lastname) . "'" : "null");
- $sql .= ", gender = " . ($this->gender != -1 ? "'" . $this->db->escape($this->gender) . "'" : "null"); // 'man' or 'woman'
- $sql .= ", login = " . ($this->login ? "'" . $this->db->escape($this->login) . "'" : "null");
- $sql .= ", societe = " . ($this->company ? "'" . $this->db->escape($this->company) . "'" : ($this->societe ? "'" . $this->db->escape($this->societe) . "'" : "null"));
- $sql .= ", fk_soc = " . ($this->socid > 0 ? $this->db->escape($this->socid) : "null");
- $sql .= ", address = " . ($this->address ? "'" . $this->db->escape($this->address) . "'" : "null");
- $sql .= ", zip = " . ($this->zip ? "'" . $this->db->escape($this->zip) . "'" : "null");
- $sql .= ", town = " . ($this->town ? "'" . $this->db->escape($this->town) . "'" : "null");
- $sql .= ", country = " . ($this->country_id > 0 ? $this->db->escape($this->country_id) : "null");
- $sql .= ", state_id = " . ($this->state_id > 0 ? $this->db->escape($this->state_id) : "null");
- $sql .= ", email = '" . $this->db->escape($this->email) . "'";
- $sql .= ", socialnetworks = '" . $this->db->escape(json_encode($this->socialnetworks)) . "'";
- $sql .= ", phone = " . ($this->phone ? "'" . $this->db->escape($this->phone) . "'" : "null");
- $sql .= ", phone_perso = " . ($this->phone_perso ? "'" . $this->db->escape($this->phone_perso) . "'" : "null");
- $sql .= ", phone_mobile = " . ($this->phone_mobile ? "'" . $this->db->escape($this->phone_mobile) . "'" : "null");
- $sql .= ", note_private = " . ($this->note_private ? "'" . $this->db->escape($this->note_private) . "'" : "null");
- $sql .= ", note_public = " . ($this->note_public ? "'" . $this->db->escape($this->note_public) . "'" : "null");
- $sql .= ", photo = " . ($this->photo ? "'" . $this->db->escape($this->photo) . "'" : "null");
- $sql .= ", public = '" . $this->db->escape($this->public) . "'";
- $sql .= ", statut = " . $this->db->escape($this->statut);
- $sql .= ", fk_adherent_type = " . $this->db->escape($this->typeid);
- $sql .= ", morphy = '" . $this->db->escape($this->morphy) . "'";
- $sql .= ", birth = " . ($this->birth ? "'" . $this->db->idate($this->birth) . "'" : "null");
- if ($this->socid) $sql .= ", fk_soc = '" . $this->db->escape($this->socid) . "'"; // Must be modified only when creating from a third-party
- if ($this->datefin) $sql .= ", datefin = '" . $this->db->idate($this->datefin) . "'"; // Must be modified only when deleting a subscription
- if ($this->datevalid) $sql .= ", datevalid = '" . $this->db->idate($this->datevalid) . "'"; // Must be modified only when validating a member
- $sql .= ", fk_user_mod = " . ($user->id > 0 ? $user->id : 'null'); // Can be null because member can be create by a guest
- $sql .= " WHERE rowid = " . $this->id;
+ $sql = "UPDATE ".MAIN_DB_PREFIX."adherent SET";
+ $sql .= " civility = ".($this->civility_id ? "'".$this->db->escape($this->civility_id)."'" : "null");
+ $sql .= ", firstname = ".($this->firstname ? "'".$this->db->escape($this->firstname)."'" : "null");
+ $sql .= ", lastname = ".($this->lastname ? "'".$this->db->escape($this->lastname)."'" : "null");
+ $sql .= ", gender = ".($this->gender != -1 ? "'".$this->db->escape($this->gender)."'" : "null"); // 'man' or 'woman'
+ $sql .= ", login = ".($this->login ? "'".$this->db->escape($this->login)."'" : "null");
+ $sql .= ", societe = ".($this->company ? "'".$this->db->escape($this->company)."'" : ($this->societe ? "'".$this->db->escape($this->societe)."'" : "null"));
+ $sql .= ", fk_soc = ".($this->socid > 0 ? $this->db->escape($this->socid) : "null");
+ $sql .= ", address = ".($this->address ? "'".$this->db->escape($this->address)."'" : "null");
+ $sql .= ", zip = ".($this->zip ? "'".$this->db->escape($this->zip)."'" : "null");
+ $sql .= ", town = ".($this->town ? "'".$this->db->escape($this->town)."'" : "null");
+ $sql .= ", country = ".($this->country_id > 0 ? $this->db->escape($this->country_id) : "null");
+ $sql .= ", state_id = ".($this->state_id > 0 ? $this->db->escape($this->state_id) : "null");
+ $sql .= ", email = '".$this->db->escape($this->email)."'";
+ $sql .= ", socialnetworks = '".$this->db->escape(json_encode($this->socialnetworks))."'";
+ $sql .= ", phone = ".($this->phone ? "'".$this->db->escape($this->phone)."'" : "null");
+ $sql .= ", phone_perso = ".($this->phone_perso ? "'".$this->db->escape($this->phone_perso)."'" : "null");
+ $sql .= ", phone_mobile = ".($this->phone_mobile ? "'".$this->db->escape($this->phone_mobile)."'" : "null");
+ $sql .= ", note_private = ".($this->note_private ? "'".$this->db->escape($this->note_private)."'" : "null");
+ $sql .= ", note_public = ".($this->note_public ? "'".$this->db->escape($this->note_public)."'" : "null");
+ $sql .= ", photo = ".($this->photo ? "'".$this->db->escape($this->photo)."'" : "null");
+ $sql .= ", public = '".$this->db->escape($this->public)."'";
+ $sql .= ", statut = ".$this->db->escape($this->statut);
+ $sql .= ", fk_adherent_type = ".$this->db->escape($this->typeid);
+ $sql .= ", morphy = '".$this->db->escape($this->morphy)."'";
+ $sql .= ", birth = ".($this->birth ? "'".$this->db->idate($this->birth)."'" : "null");
+ if ($this->socid) $sql .= ", fk_soc = '".$this->db->escape($this->socid)."'"; // Must be modified only when creating from a third-party
+ if ($this->datefin) $sql .= ", datefin = '".$this->db->idate($this->datefin)."'"; // Must be modified only when deleting a subscription
+ if ($this->datevalid) $sql .= ", datevalid = '".$this->db->idate($this->datevalid)."'"; // Must be modified only when validating a member
+ $sql .= ", fk_user_mod = ".($user->id > 0 ? $user->id : 'null'); // Can be null because member can be create by a guest
+ $sql .= " WHERE rowid = ".$this->id;
// If we change the type of membership, we set also label of new type
if (!empty($this->oldcopy) && $this->typeid != $this->oldcopy->typeid) {
$sql2 = "SELECT libelle as label";
- $sql2 .= " FROM " . MAIN_DB_PREFIX . "adherent_type";
- $sql2 .= " WHERE rowid = " . $this->typeid;
+ $sql2 .= " FROM ".MAIN_DB_PREFIX."adherent_type";
+ $sql2 .= " WHERE rowid = ".$this->typeid;
$resql2 = $this->db->query($sql2);
if ($resql2) {
while ($obj = $this->db->fetch_object($resql2)) {
@@ -643,7 +643,7 @@ class Adherent extends CommonObject
}
}
- dol_syslog(get_class($this) . "::update update member", LOG_DEBUG);
+ dol_syslog(get_class($this)."::update update member", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql) {
unset($this->country_code);
@@ -666,7 +666,7 @@ class Adherent extends CommonObject
// Update password
if (!$error && $this->pass) {
- dol_syslog(get_class($this) . "::update update password");
+ dol_syslog(get_class($this)."::update update password");
if ($this->pass != $this->pass_indatabase && $this->pass != $this->pass_indatabase_crypted) {
$isencrypted = empty($conf->global->DATABASE_PWD_ENCRYPTED) ? 0 : 1;
@@ -678,9 +678,9 @@ class Adherent extends CommonObject
// Remove links to user and replace with new one
if (!$error) {
- dol_syslog(get_class($this) . "::update update link to user");
- $sql = "UPDATE " . MAIN_DB_PREFIX . "user SET fk_member = NULL WHERE fk_member = " . $this->id;
- dol_syslog(get_class($this) . "::update", LOG_DEBUG);
+ dol_syslog(get_class($this)."::update update link to user");
+ $sql = "UPDATE ".MAIN_DB_PREFIX."user SET fk_member = NULL WHERE fk_member = ".$this->id;
+ dol_syslog(get_class($this)."::update", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql) {
$this->error = $this->db->error();
@@ -689,8 +689,8 @@ class Adherent extends CommonObject
}
// If there is a user linked to this member
if ($this->user_id > 0) {
- $sql = "UPDATE " . MAIN_DB_PREFIX . "user SET fk_member = " . $this->id . " WHERE rowid = " . $this->user_id;
- dol_syslog(get_class($this) . "::update", LOG_DEBUG);
+ $sql = "UPDATE ".MAIN_DB_PREFIX."user SET fk_member = ".$this->id." WHERE rowid = ".$this->user_id;
+ dol_syslog(get_class($this)."::update", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql) {
$this->error = $this->db->error();
@@ -704,9 +704,9 @@ class Adherent extends CommonObject
{
// Update information on linked user if it is an update
if (!$error && $this->user_id > 0 && !$nosyncuser) {
- require_once DOL_DOCUMENT_ROOT . '/user/class/user.class.php';
+ require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
- dol_syslog(get_class($this) . "::update update linked user");
+ dol_syslog(get_class($this)."::update update linked user");
$luser = new User($this->db);
$result = $luser->fetch($this->user_id);
@@ -743,7 +743,7 @@ class Adherent extends CommonObject
$result = $luser->update($user, 0, 1, 1); // Use nosync to 1 to avoid cyclic updates
if ($result < 0) {
$this->error = $luser->error;
- dol_syslog(get_class($this) . "::update " . $this->error, LOG_ERR);
+ dol_syslog(get_class($this)."::update ".$this->error, LOG_ERR);
$error++;
}
} else {
@@ -754,9 +754,9 @@ class Adherent extends CommonObject
// Update information on linked thirdparty if it is an update
if (!$error && $this->fk_soc > 0 && !$nosyncthirdparty) {
- require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
+ require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
- dol_syslog(get_class($this) . "::update update linked thirdparty");
+ dol_syslog(get_class($this)."::update update linked thirdparty");
// This member is linked with a thirdparty, so we also update thirdparty informations
// if this is an update.
@@ -779,7 +779,7 @@ class Adherent extends CommonObject
if ($result < 0) {
$this->error = $lthirdparty->error;
$this->errors = $lthirdparty->errors;
- dol_syslog(get_class($this) . "::update " . $this->error, LOG_ERR);
+ dol_syslog(get_class($this)."::update ".$this->error, LOG_ERR);
$error++;
}
} elseif ($result < 0) {
@@ -828,11 +828,11 @@ class Adherent extends CommonObject
// Search for last subscription id and end date
$sql = "SELECT rowid, datec as dateop, dateadh as datedeb, datef as datefin";
- $sql .= " FROM " . MAIN_DB_PREFIX . "subscription";
- $sql .= " WHERE fk_adherent=" . $this->id;
+ $sql .= " FROM ".MAIN_DB_PREFIX."subscription";
+ $sql .= " WHERE fk_adherent=".$this->id;
$sql .= " ORDER by dateadh DESC"; // Sort by start subscription date
- dol_syslog(get_class($this) . "::update_end_date", LOG_DEBUG);
+ dol_syslog(get_class($this)."::update_end_date", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql) {
$obj = $this->db->fetch_object($resql);
@@ -840,11 +840,11 @@ class Adherent extends CommonObject
$datedeb = $this->db->jdate($obj->datedeb);
$datefin = $this->db->jdate($obj->datefin);
- $sql = "UPDATE " . MAIN_DB_PREFIX . "adherent SET";
- $sql .= " datefin=" . ($datefin != '' ? "'" . $this->db->idate($datefin) . "'" : "null");
- $sql .= " WHERE rowid = " . $this->id;
+ $sql = "UPDATE ".MAIN_DB_PREFIX."adherent SET";
+ $sql .= " datefin=".($datefin != '' ? "'".$this->db->idate($datefin)."'" : "null");
+ $sql .= " WHERE rowid = ".$this->id;
- dol_syslog(get_class($this) . "::update_end_date", LOG_DEBUG);
+ dol_syslog(get_class($this)."::update_end_date", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql) {
$this->last_subscription_date = $dateop;
@@ -893,8 +893,8 @@ class Adherent extends CommonObject
}
// Remove category
- $sql = "DELETE FROM " . MAIN_DB_PREFIX . "categorie_member WHERE fk_member = " . $rowid;
- dol_syslog(get_class($this) . "::delete", LOG_DEBUG);
+ $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_member WHERE fk_member = ".$rowid;
+ dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql) {
$error++;
@@ -904,8 +904,8 @@ class Adherent extends CommonObject
// Remove subscription
if (!$error) {
- $sql = "DELETE FROM " . MAIN_DB_PREFIX . "subscription WHERE fk_adherent = " . $rowid;
- dol_syslog(get_class($this) . "::delete", LOG_DEBUG);
+ $sql = "DELETE FROM ".MAIN_DB_PREFIX."subscription WHERE fk_adherent = ".$rowid;
+ dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql) {
$error++;
@@ -932,15 +932,15 @@ class Adherent extends CommonObject
if ($result < 0) {
$error++;
$errorflag = -4;
- dol_syslog(get_class($this) . "::delete erreur " . $errorflag . " " . $this->error, LOG_ERR);
+ dol_syslog(get_class($this)."::delete erreur ".$errorflag." ".$this->error, LOG_ERR);
}
}
}
// Remove adherent
if (!$error) {
- $sql = "DELETE FROM " . MAIN_DB_PREFIX . "adherent WHERE rowid = " . $rowid;
- dol_syslog(get_class($this) . "::delete", LOG_DEBUG);
+ $sql = "DELETE FROM ".MAIN_DB_PREFIX."adherent WHERE rowid = ".$rowid;
+ dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql) {
$error++;
@@ -975,11 +975,11 @@ class Adherent extends CommonObject
$error = 0;
- dol_syslog(get_class($this) . "::setPassword user=" . $user->id . " password=" . preg_replace('/./i', '*', $password) . " isencrypted=" . $isencrypted);
+ dol_syslog(get_class($this)."::setPassword user=".$user->id." password=".preg_replace('/./i', '*', $password)." isencrypted=".$isencrypted);
// If new password not provided, we generate one
if (!$password) {
- require_once DOL_DOCUMENT_ROOT . '/core/lib/security2.lib.php';
+ require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
$password = getRandomPassword(false);
}
@@ -994,18 +994,18 @@ class Adherent extends CommonObject
$this->db->begin();
// Mise a jour
- $sql = "UPDATE " . MAIN_DB_PREFIX . "adherent";
- $sql .= " SET pass_crypted = '" . $this->db->escape($password_crypted) . "'";
+ $sql = "UPDATE ".MAIN_DB_PREFIX."adherent";
+ $sql .= " SET pass_crypted = '".$this->db->escape($password_crypted)."'";
//if (! empty($conf->global->DATABASE_PWD_ENCRYPTED))
if ($isencrypted) {
$sql .= ", pass = null";
} else {
- $sql .= ", pass = '" . $this->db->escape($password_indatabase) . "'";
+ $sql .= ", pass = '".$this->db->escape($password_indatabase)."'";
}
- $sql .= " WHERE rowid = " . $this->id;
+ $sql .= " WHERE rowid = ".$this->id;
//dol_syslog("Adherent::Password sql=hidden");
- dol_syslog(get_class($this) . "::setPassword", LOG_DEBUG);
+ dol_syslog(get_class($this)."::setPassword", LOG_DEBUG);
$result = $this->db->query($sql);
if ($result) {
$nbaffectedrows = $this->db->affected_rows($result);
@@ -1016,7 +1016,7 @@ class Adherent extends CommonObject
$this->pass_indatabase_crypted = $password_crypted;
if ($this->user_id && !$nosyncuser) {
- require_once DOL_DOCUMENT_ROOT . '/user/class/user.class.php';
+ require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
// This member is linked with a user, so we also update users informations
// if this is an update.
@@ -1027,7 +1027,7 @@ class Adherent extends CommonObject
$result = $luser->setPassword($user, $this->pass, 0, 0, 1);
if ($result < 0) {
$this->error = $luser->error;
- dol_syslog(get_class($this) . "::setPassword " . $this->error, LOG_ERR);
+ dol_syslog(get_class($this)."::setPassword ".$this->error, LOG_ERR);
$error++;
}
} else {
@@ -1074,8 +1074,8 @@ class Adherent extends CommonObject
$this->db->begin();
// If user is linked to this member, remove old link to this member
- $sql = "UPDATE " . MAIN_DB_PREFIX . "user SET fk_member = NULL WHERE fk_member = " . $this->id;
- dol_syslog(get_class($this) . "::setUserId", LOG_DEBUG);
+ $sql = "UPDATE ".MAIN_DB_PREFIX."user SET fk_member = NULL WHERE fk_member = ".$this->id;
+ dol_syslog(get_class($this)."::setUserId", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql) {
$this->error = $this->db->error();
@@ -1085,9 +1085,9 @@ class Adherent extends CommonObject
// Set link to user
if ($userid > 0) {
- $sql = "UPDATE " . MAIN_DB_PREFIX . "user SET fk_member = " . $this->id;
- $sql .= " WHERE rowid = " . $userid;
- dol_syslog(get_class($this) . "::setUserId", LOG_DEBUG);
+ $sql = "UPDATE ".MAIN_DB_PREFIX."user SET fk_member = ".$this->id;
+ $sql .= " WHERE rowid = ".$userid;
+ dol_syslog(get_class($this)."::setUserId", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql) {
$this->error = $this->db->error();
@@ -1116,18 +1116,18 @@ class Adherent extends CommonObject
// Remove link to third party onto any other members
if ($thirdpartyid > 0) {
- $sql = "UPDATE " . MAIN_DB_PREFIX . "adherent SET fk_soc = null";
- $sql .= " WHERE fk_soc = '" . $thirdpartyid . "'";
- $sql .= " AND entity = " . $conf->entity;
- dol_syslog(get_class($this) . "::setThirdPartyId", LOG_DEBUG);
+ $sql = "UPDATE ".MAIN_DB_PREFIX."adherent SET fk_soc = null";
+ $sql .= " WHERE fk_soc = '".$thirdpartyid."'";
+ $sql .= " AND entity = ".$conf->entity;
+ dol_syslog(get_class($this)."::setThirdPartyId", LOG_DEBUG);
$resql = $this->db->query($sql);
}
// Add link to third party for current member
- $sql = "UPDATE " . MAIN_DB_PREFIX . "adherent SET fk_soc = " . ($thirdpartyid > 0 ? $thirdpartyid : 'null');
- $sql .= " WHERE rowid = " . $this->id;
+ $sql = "UPDATE ".MAIN_DB_PREFIX."adherent SET fk_soc = ".($thirdpartyid > 0 ? $thirdpartyid : 'null');
+ $sql .= " WHERE rowid = ".$this->id;
- dol_syslog(get_class($this) . "::setThirdPartyId", LOG_DEBUG);
+ dol_syslog(get_class($this)."::setThirdPartyId", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql) {
$this->db->commit();
@@ -1152,9 +1152,9 @@ class Adherent extends CommonObject
// phpcs:enable
global $conf;
- $sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . "adherent";
- $sql .= " WHERE login='" . $this->db->escape($login) . "'";
- $sql .= " AND entity = " . $conf->entity;
+ $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."adherent";
+ $sql .= " WHERE login='".$this->db->escape($login)."'";
+ $sql .= " AND entity = ".$conf->entity;
$resql = $this->db->query($sql);
if ($resql) {
@@ -1180,10 +1180,10 @@ class Adherent extends CommonObject
// phpcs:enable
global $conf;
- $sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . "adherent";
- $sql .= " WHERE firstname='" . $this->db->escape($firstname) . "'";
- $sql .= " AND lastname='" . $this->db->escape($lastname) . "'";
- $sql .= " AND entity = " . $conf->entity;
+ $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."adherent";
+ $sql .= " WHERE firstname='".$this->db->escape($firstname)."'";
+ $sql .= " AND lastname='".$this->db->escape($lastname)."'";
+ $sql .= " AND entity = ".$conf->entity;
$resql = $this->db->query($sql);
if ($resql) {
@@ -1227,24 +1227,24 @@ class Adherent extends CommonObject
$sql .= " dep.nom as state, dep.code_departement as state_code,";
$sql .= " t.libelle as type, t.subscription as subscription,";
$sql .= " u.rowid as user_id, u.login as user_login";
- $sql .= " FROM " . MAIN_DB_PREFIX . "adherent_type as t, " . MAIN_DB_PREFIX . "adherent as d";
- $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_country as c ON d.country = c.rowid";
- $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_departements as dep ON d.state_id = dep.rowid";
- $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "user as u ON d.rowid = u.fk_member";
+ $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as t, ".MAIN_DB_PREFIX."adherent as d";
+ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON d.country = c.rowid";
+ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as dep ON d.state_id = dep.rowid";
+ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON d.rowid = u.fk_member";
$sql .= " WHERE d.fk_adherent_type = t.rowid";
if ($rowid)
- $sql .= " AND d.rowid=" . $rowid;
+ $sql .= " AND d.rowid=".$rowid;
elseif ($ref || $fk_soc) {
- $sql .= " AND d.entity IN (" . getEntity('adherent') . ")";
+ $sql .= " AND d.entity IN (".getEntity('adherent').")";
if ($ref)
- $sql .= " AND d.rowid='" . $this->db->escape($ref) . "'";
+ $sql .= " AND d.rowid='".$this->db->escape($ref)."'";
elseif ($fk_soc > 0)
- $sql .= " AND d.fk_soc=" . $fk_soc;
+ $sql .= " AND d.fk_soc=".$fk_soc;
} elseif ($ref_ext) {
- $sql .= " AND d.ref_ext='" . $this->db->escape($ref_ext) . "'";
+ $sql .= " AND d.ref_ext='".$this->db->escape($ref_ext)."'";
}
- dol_syslog(get_class($this) . "::fetch", LOG_DEBUG);
+ dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql) {
if ($this->db->num_rows($resql)) {
@@ -1257,7 +1257,7 @@ class Adherent extends CommonObject
$this->civility_id = $obj->civility_code; // Bad. Kept for backard compatibility
$this->civility_code = $obj->civility_code;
- $this->civility = $obj->civility_code ? ($langs->trans("Civility" . $obj->civility_code) != ("Civility" . $obj->civility_code) ? $langs->trans("Civility" . $obj->civility_code) : $obj->civility_code) : '';
+ $this->civility = $obj->civility_code ? ($langs->trans("Civility".$obj->civility_code) != ("Civility".$obj->civility_code) ? $langs->trans("Civility".$obj->civility_code) : $obj->civility_code) : '';
$this->firstname = $obj->firstname;
$this->lastname = $obj->lastname;
@@ -1281,8 +1281,8 @@ class Adherent extends CommonObject
$this->country_id = $obj->country_id;
$this->country_code = $obj->country_code;
- if ($langs->trans("Country" . $obj->country_code) != "Country" . $obj->country_code)
- $this->country = $langs->transnoentitiesnoconv("Country" . $obj->country_code);
+ if ($langs->trans("Country".$obj->country_code) != "Country".$obj->country_code)
+ $this->country = $langs->transnoentitiesnoconv("Country".$obj->country_code);
else
$this->country = $obj->country;
@@ -1354,17 +1354,17 @@ class Adherent extends CommonObject
// phpcs:enable
global $langs;
- require_once DOL_DOCUMENT_ROOT . '/adherents/class/subscription.class.php';
+ require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php';
$sql = "SELECT c.rowid, c.fk_adherent, c.fk_type, c.subscription, c.note, c.fk_bank,";
$sql .= " c.tms as datem,";
$sql .= " c.datec as datec,";
$sql .= " c.dateadh as dateh,";
$sql .= " c.datef as datef";
- $sql .= " FROM " . MAIN_DB_PREFIX . "subscription as c";
- $sql .= " WHERE c.fk_adherent = " . $this->id;
+ $sql .= " FROM ".MAIN_DB_PREFIX."subscription as c";
+ $sql .= " WHERE c.fk_adherent = ".$this->id;
$sql .= " ORDER BY c.dateadh";
- dol_syslog(get_class($this) . "::fetch_subscriptions", LOG_DEBUG);
+ dol_syslog(get_class($this)."::fetch_subscriptions", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql) {
@@ -1401,7 +1401,7 @@ class Adherent extends CommonObject
}
return 1;
} else {
- $this->error = $this->db->error() . ' sql=' . $sql;
+ $this->error = $this->db->error().' sql='.$sql;
return -1;
}
}
@@ -1425,7 +1425,7 @@ class Adherent extends CommonObject
{
global $conf, $langs, $user;
- require_once DOL_DOCUMENT_ROOT . '/adherents/class/subscription.class.php';
+ require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php';
$error = 0;
@@ -1505,12 +1505,12 @@ class Adherent extends CommonObject
$this->invoice = null; // This will contains invoice if an invoice is created
- dol_syslog("subscriptionComplementaryActions subscriptionid=" . $subscriptionid . " option=" . $option . " accountid=" . $accountid . " datesubscription=" . $datesubscription . " paymentdate=" .
- $paymentdate . " label=" . $label . " amount=" . $amount . " num_chq=" . $num_chq . " autocreatethirdparty=" . $autocreatethirdparty);
+ dol_syslog("subscriptionComplementaryActions subscriptionid=".$subscriptionid." option=".$option." accountid=".$accountid." datesubscription=".$datesubscription." paymentdate=".
+ $paymentdate." label=".$label." amount=".$amount." num_chq=".$num_chq." autocreatethirdparty=".$autocreatethirdparty);
// Insert into bank account directlty (if option choosed for) + link to llx_subscription if option is 'bankdirect'
if ($option == 'bankdirect' && $accountid) {
- require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php';
+ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
$acct = new Account($this->db);
$result = $acct->fetch($accountid);
@@ -1519,11 +1519,11 @@ class Adherent extends CommonObject
$insertid = $acct->addline($dateop, $operation, $label, $amount, $num_chq, '', $user, $emetteur_nom, $emetteur_banque);
if ($insertid > 0) {
- $inserturlid = $acct->add_url_line($insertid, $this->id, DOL_URL_ROOT . '/adherents/card.php?rowid=', $this->getFullname($langs), 'member');
+ $inserturlid = $acct->add_url_line($insertid, $this->id, DOL_URL_ROOT.'/adherents/card.php?rowid=', $this->getFullname($langs), 'member');
if ($inserturlid > 0) {
// Update table subscription
- $sql = "UPDATE " . MAIN_DB_PREFIX . "subscription SET fk_bank=" . $insertid;
- $sql .= " WHERE rowid=" . $subscriptionid;
+ $sql = "UPDATE ".MAIN_DB_PREFIX."subscription SET fk_bank=".$insertid;
+ $sql .= " WHERE rowid=".$subscriptionid;
dol_syslog("subscription::subscription", LOG_DEBUG);
$resql = $this->db->query($sql);
@@ -1546,8 +1546,8 @@ class Adherent extends CommonObject
// If option choosed, we create invoice
if (($option == 'bankviainvoice' && $accountid) || $option == 'invoiceonly') {
- require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';
- require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/paymentterm.class.php';
+ require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
+ require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/paymentterm.class.php';
$invoice = new Facture($this->db);
$customer = new Societe($this->db);
@@ -1659,9 +1659,9 @@ class Adherent extends CommonObject
// Add payment onto invoice
if (!$error && $option == 'bankviainvoice' && $accountid) {
- require_once DOL_DOCUMENT_ROOT . '/compta/paiement/class/paiement.class.php';
- require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php';
- require_once DOL_DOCUMENT_ROOT . '/core/lib/functions.lib.php';
+ require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
+ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
+ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php';
$amounts = array();
$amounts[$invoice->id] = price2num($amount);
@@ -1695,8 +1695,8 @@ class Adherent extends CommonObject
if (!$error && !empty($bank_line_id)) {
// Update fk_bank into subscription table
- $sql = 'UPDATE ' . MAIN_DB_PREFIX . 'subscription SET fk_bank=' . $bank_line_id;
- $sql .= ' WHERE rowid=' . $subscriptionid;
+ $sql = 'UPDATE '.MAIN_DB_PREFIX.'subscription SET fk_bank='.$bank_line_id;
+ $sql .= ' WHERE rowid='.$subscriptionid;
$result = $this->db->query($sql);
if (!$result) {
@@ -1751,19 +1751,19 @@ class Adherent extends CommonObject
// Check parameters
if ($this->statut == 1) {
- dol_syslog(get_class($this) . "::validate statut of member does not allow this", LOG_WARNING);
+ dol_syslog(get_class($this)."::validate statut of member does not allow this", LOG_WARNING);
return 0;
}
$this->db->begin();
- $sql = "UPDATE " . MAIN_DB_PREFIX . "adherent SET";
+ $sql = "UPDATE ".MAIN_DB_PREFIX."adherent SET";
$sql .= " statut = 1";
- $sql .= ", datevalid = '" . $this->db->idate($now) . "'";
- $sql .= ", fk_user_valid=" . $user->id;
- $sql .= " WHERE rowid = " . $this->id;
+ $sql .= ", datevalid = '".$this->db->idate($now)."'";
+ $sql .= ", fk_user_valid=".$user->id;
+ $sql .= " WHERE rowid = ".$this->id;
- dol_syslog(get_class($this) . "::validate", LOG_DEBUG);
+ dol_syslog(get_class($this)."::validate", LOG_DEBUG);
$result = $this->db->query($sql);
if ($result) {
$this->statut = 1;
@@ -1803,16 +1803,16 @@ class Adherent extends CommonObject
// Check parameters
if ($this->statut == 0) {
- dol_syslog(get_class($this) . "::resiliate statut of member does not allow this", LOG_WARNING);
+ dol_syslog(get_class($this)."::resiliate statut of member does not allow this", LOG_WARNING);
return 0;
}
$this->db->begin();
- $sql = "UPDATE " . MAIN_DB_PREFIX . "adherent SET";
+ $sql = "UPDATE ".MAIN_DB_PREFIX."adherent SET";
$sql .= " statut = 0";
- $sql .= ", fk_user_valid=" . $user->id;
- $sql .= " WHERE rowid = " . $this->id;
+ $sql .= ", fk_user_valid=".$user->id;
+ $sql .= " WHERE rowid = ".$this->id;
$result = $this->db->query($sql);
if ($result) {
@@ -1848,7 +1848,7 @@ class Adherent extends CommonObject
// phpcs:enable
global $conf, $langs;
- include_once DOL_DOCUMENT_ROOT . '/mailmanspip/class/mailmanspip.class.php';
+ include_once DOL_DOCUMENT_ROOT.'/mailmanspip/class/mailmanspip.class.php';
$mailmanspip = new MailmanSpip($this->db);
$err = 0;
@@ -1898,7 +1898,7 @@ class Adherent extends CommonObject
// phpcs:enable
global $conf, $langs;
- include_once DOL_DOCUMENT_ROOT . '/mailmanspip/class/mailmanspip.class.php';
+ include_once DOL_DOCUMENT_ROOT.'/mailmanspip/class/mailmanspip.class.php';
$mailmanspip = new MailmanSpip($this->db);
$err = 0;
@@ -1949,7 +1949,7 @@ class Adherent extends CommonObject
$code = (empty($this->civility_id) ? '' : $this->civility_id);
if (empty($code)) return '';
- return $langs->getLabelFromKey($this->db, "Civility" . $code, "c_civility", "code", "label", $code);
+ return $langs->getLabelFromKey($this->db, "Civility".$code, "c_civility", "code", "label", $code);
}
/**
@@ -1982,15 +1982,15 @@ class Adherent extends CommonObject
}
$label .= '';
- $label .= '' . $langs->trans("Member") . ' ';
- if (!empty($this->ref)) $label .= '' . $langs->trans('Ref') . ': ' . $this->ref;
- if (!empty($this->firstname) || !empty($this->lastname)) $label .= '' . $langs->trans('Name') . ': ' . $this->getFullName($langs);
- if (!empty($this->company)) $label .= '' . $langs->trans('Company') . ': ' . $this->company;
+ $label .= ''.$langs->trans("Member").' ';
+ if (!empty($this->ref)) $label .= ''.$langs->trans('Ref').': '.$this->ref;
+ if (!empty($this->firstname) || !empty($this->lastname)) $label .= ''.$langs->trans('Name').': '.$this->getFullName($langs);
+ if (!empty($this->company)) $label .= ''.$langs->trans('Company').': '.$this->company;
$label .= '
';
- $url = DOL_URL_ROOT . '/adherents/card.php?rowid=' . $this->id;
+ $url = DOL_URL_ROOT.'/adherents/card.php?rowid='.$this->id;
if ($option == 'subscription') {
- $url = DOL_URL_ROOT . '/adherents/subscription.php?rowid=' . $this->id;
+ $url = DOL_URL_ROOT.'/adherents/subscription.php?rowid='.$this->id;
}
if ($option != 'nolink') {
@@ -2000,19 +2000,19 @@ class Adherent extends CommonObject
if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1';
}
- $linkstart .= 'global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
$langs->load("users");
$label = $langs->trans("ShowUser");
- $linkclose .= ' alt="' . dol_escape_htmltag($label, 1) . '"';
+ $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
}
- $linkclose .= ' title="' . dol_escape_htmltag($label, 1) . '"';
- $linkclose .= ' class="classfortooltip' . ($morecss ? ' ' . $morecss : '') . '"';
+ $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
+ $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
}
- $linkstart .= $linkclose . '>';
+ $linkstart .= $linkclose.'>';
$linkend = ' ';
$result .= $linkstart;
@@ -2022,19 +2022,19 @@ class Adherent extends CommonObject
if (abs($withpictoimg) == 1) $paddafterimage = 'style="margin-right: 3px;"';
// Only picto
if ($withpictoimg > 0)
- $picto = '' .
- img_object('', 'user', $paddafterimage . ' ' . ($notooltip ? '' : 'class="classfortooltip"'), 0, 0, $notooltip ? 0 : 1) . ' ';
+ $picto = ''.
+ img_object('', 'user', $paddafterimage.' '.($notooltip ? '' : 'class="classfortooltip"'), 0, 0, $notooltip ? 0 : 1).' ';
// Picto must be a photo
else {
- $picto = '';
- $picto .= Form::showphoto('memberphoto', $this, 0, 0, 0, 'userphoto' . ($withpictoimg == -3 ? 'small' : ''), 'mini', 0, 1);
+ $picto = '';
+ $picto .= Form::showphoto('memberphoto', $this, 0, 0, 0, 'userphoto'.($withpictoimg == -3 ? 'small' : ''), 'mini', 0, 1);
$picto .= ' ';
}
$result .= $picto;
}
if ($withpictoimg > -2 && $withpictoimg != 2) {
- if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) $result .= '';
+ if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) $result .= '';
if ($mode == 'login')
$result .= dol_trunc($this->login, $maxlen);
elseif ($mode == 'ref')
@@ -2126,9 +2126,9 @@ class Adherent extends CommonObject
$this->nb = array();
$sql = "SELECT count(a.rowid) as nb";
- $sql .= " FROM " . MAIN_DB_PREFIX . "adherent as a";
+ $sql .= " FROM ".MAIN_DB_PREFIX."adherent as a";
$sql .= " WHERE a.statut > 0";
- $sql .= " AND a.entity IN (" . getEntity('adherent') . ")";
+ $sql .= " AND a.entity IN (".getEntity('adherent').")";
$resql = $this->db->query($sql);
if ($resql) {
@@ -2162,16 +2162,16 @@ class Adherent extends CommonObject
$now = dol_now();
$sql = "SELECT a.rowid, a.datefin, a.statut";
- $sql .= " FROM " . MAIN_DB_PREFIX . "adherent as a";
- $sql .= ", " . MAIN_DB_PREFIX . "adherent_type as t";
+ $sql .= " FROM ".MAIN_DB_PREFIX."adherent as a";
+ $sql .= ", ".MAIN_DB_PREFIX."adherent_type as t";
$sql .= " WHERE a.fk_adherent_type = t.rowid";
if ($mode == 'expired') {
$sql .= " AND a.statut = 1";
- $sql .= " AND a.entity IN (" . getEntity('adherent') . ")";
- $sql .= " AND ((a.datefin IS NULL or a.datefin < '" . $this->db->idate($now) . "') AND t.subscription = 1)";
+ $sql .= " AND a.entity IN (".getEntity('adherent').")";
+ $sql .= " AND ((a.datefin IS NULL or a.datefin < '".$this->db->idate($now)."') AND t.subscription = 1)";
} elseif ($mode == 'shift') {
$sql .= " AND a.statut = -1";
- $sql .= " AND a.entity IN (" . getEntity('adherent') . ")";
+ $sql .= " AND a.entity IN (".getEntity('adherent').")";
}
$resql = $this->db->query($sql);
@@ -2187,10 +2187,10 @@ class Adherent extends CommonObject
$warning_delay = $conf->adherent->subscription->warning_delay / 60 / 60 / 24;
$label = $langs->trans("MembersWithSubscriptionToReceive");
$labelShort = $langs->trans("MembersWithSubscriptionToReceiveShort");
- $url = DOL_URL_ROOT . '/adherents/list.php?mainmenu=members&statut=1&filter=outofdate';
+ $url = DOL_URL_ROOT.'/adherents/list.php?mainmenu=members&statut=1&filter=outofdate';
} elseif ($mode == 'shift') {
$warning_delay = $conf->adherent->subscription->warning_delay / 60 / 60 / 24;
- $url = DOL_URL_ROOT . '/adherents/list.php?mainmenu=members&statut=-1';
+ $url = DOL_URL_ROOT.'/adherents/list.php?mainmenu=members&statut=-1';
$label = $langs->trans("MembersListToValid");
$labelShort = $langs->trans("ToValidate");
}
@@ -2331,9 +2331,9 @@ class Adherent extends CommonObject
// phpcs:enable
global $conf;
$dn = '';
- if ($mode == 0) $dn = $conf->global->LDAP_KEY_MEMBERS . "=" . $info[$conf->global->LDAP_KEY_MEMBERS] . "," . $conf->global->LDAP_MEMBER_DN;
+ if ($mode == 0) $dn = $conf->global->LDAP_KEY_MEMBERS."=".$info[$conf->global->LDAP_KEY_MEMBERS].",".$conf->global->LDAP_MEMBER_DN;
if ($mode == 1) $dn = $conf->global->LDAP_MEMBER_DN;
- if ($mode == 2) $dn = $conf->global->LDAP_KEY_MEMBERS . "=" . $info[$conf->global->LDAP_KEY_MEMBERS];
+ if ($mode == 2) $dn = $conf->global->LDAP_KEY_MEMBERS."=".$info[$conf->global->LDAP_KEY_MEMBERS];
return $dn;
}
@@ -2413,7 +2413,7 @@ class Adherent extends CommonObject
if ($this->pass_indatabase_crypted && !empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED)) {
// Create OpenLDAP MD5 password from Dolibarr MD5 password
// Note: This suppose that "pass_indatabase_crypted" is a md5 (guaranted by the previous test if "(empty($conf->global->MAIN_SECURITY_HASH_ALGO))"
- $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED] = '{md5}' . base64_encode(hex2bin($this->pass_indatabase_crypted));
+ $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED] = '{md5}'.base64_encode(hex2bin($this->pass_indatabase_crypted));
}
}
} // Use $this->pass_indatabase value if exists
@@ -2445,10 +2445,10 @@ class Adherent extends CommonObject
$sql .= ' a.datevalid as datev,';
$sql .= ' a.tms as datem,';
$sql .= ' a.fk_user_author, a.fk_user_valid, a.fk_user_mod';
- $sql .= ' FROM ' . MAIN_DB_PREFIX . 'adherent as a';
- $sql .= ' WHERE a.rowid = ' . $id;
+ $sql .= ' FROM '.MAIN_DB_PREFIX.'adherent as a';
+ $sql .= ' WHERE a.rowid = '.$id;
- dol_syslog(get_class($this) . "::info", LOG_DEBUG);
+ dol_syslog(get_class($this)."::info", LOG_DEBUG);
$result = $this->db->query($sql);
if ($result) {
if ($this->db->num_rows($result)) {
@@ -2491,8 +2491,8 @@ class Adherent extends CommonObject
public function getNbOfEMailings()
{
$sql = "SELECT count(mc.email) as nb";
- $sql .= " FROM " . MAIN_DB_PREFIX . "mailing_cibles as mc";
- $sql .= " WHERE mc.email = '" . $this->db->escape($this->email) . "'";
+ $sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc";
+ $sql .= " WHERE mc.email = '".$this->db->escape($this->email)."'";
$sql .= " AND mc.statut NOT IN (-1,0)"; // -1 erreur, 0 non envoye, 1 envoye avec succes
$resql = $this->db->query($sql);
@@ -2526,7 +2526,7 @@ class Adherent extends CommonObject
}
// Get current categories
- require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
+ require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
$c = new Categorie($this->db);
$existing = $c->containing($this->id, Categorie::TYPE_MEMBER, 'id');
@@ -2627,7 +2627,7 @@ class Adherent extends CommonObject
$arraydaysbeforeend = explode(';', $daysbeforeendlist);
foreach ($arraydaysbeforeend as $daysbeforeend) // Loop on each delay
{
- dol_syslog(__METHOD__ . ' - Process delta = ' . $daysbeforeend, LOG_DEBUG);
+ dol_syslog(__METHOD__.' - Process delta = '.$daysbeforeend, LOG_DEBUG);
if (!is_numeric($daysbeforeend)) {
$blockingerrormsg = "Value for delta is not a positive or negative numeric";
@@ -2638,15 +2638,15 @@ class Adherent extends CommonObject
$tmp = dol_getdate($now);
$datetosearchfor = dol_time_plus_duree(dol_mktime(0, 0, 0, $tmp['mon'], $tmp['mday'], $tmp['year']), $daysbeforeend, 'd');
- $sql = 'SELECT rowid FROM ' . MAIN_DB_PREFIX . 'adherent';
- $sql .= " WHERE entity = " . $conf->entity; // Do not use getEntity('adherent').")" here, we want the batch to be on its entity only;
- $sql .= " AND datefin = '" . $this->db->idate($datetosearchfor) . "'";
+ $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'adherent';
+ $sql .= " WHERE entity = ".$conf->entity; // Do not use getEntity('adherent').")" here, we want the batch to be on its entity only;
+ $sql .= " AND datefin = '".$this->db->idate($datetosearchfor)."'";
$resql = $this->db->query($sql);
if ($resql) {
$num_rows = $this->db->num_rows($resql);
- include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
+ include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
$adherent = new Adherent($this->db);
$formmail = new FormMail($this->db);
@@ -2670,7 +2670,7 @@ class Adherent extends CommonObject
$outputlangs = new Translate('', $conf);
$outputlangs->setDefaultLang($languagecodeformember);
$outputlangs->loadLangs(array("main", "members"));
- dol_syslog("sendReminderForExpiredSubscription Language for member id " . $adherent->id . " set to " . $outputlangs->defaultlang . " mysoc->default_lang=" . $mysoc->default_lang);
+ dol_syslog("sendReminderForExpiredSubscription Language for member id ".$adherent->id." set to ".$outputlangs->defaultlang." mysoc->default_lang=".$mysoc->default_lang);
$arraydefaultmessage = null;
$labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_REMIND_EXPIRATION;
@@ -2687,10 +2687,10 @@ class Adherent extends CommonObject
$from = $conf->global->ADHERENT_MAIL_FROM;
$to = $adherent->email;
- $trackid = 'mem' . $adherent->id;
- $moreinheader = 'X-Dolibarr-Info: sendReminderForExpiredSubscription' . "\r\n";
+ $trackid = 'mem'.$adherent->id;
+ $moreinheader = 'X-Dolibarr-Info: sendReminderForExpiredSubscription'."\r\n";
- include_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php';
+ include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
$cmail = new CMailFile($subject, $to, $from, $msg, array(), array(), array(), '', '', 0, 1, '', '', $trackid, $moreinheader);
$result = $cmail->sendfile();
if (!$result) {
@@ -2713,24 +2713,24 @@ class Adherent extends CommonObject
$extraparams = '';
$actionmsg = '';
- $actionmsg2 = $langs->transnoentities('MailSentBy') . ' ' . CMailFile::getValidAddress($from, 4, 0, 1) . ' ' . $langs->transnoentities('To') . ' ' .
+ $actionmsg2 = $langs->transnoentities('MailSentBy').' '.CMailFile::getValidAddress($from, 4, 0, 1).' '.$langs->transnoentities('To').' '.
CMailFile::getValidAddress($sendto, 4, 0, 1);
if ($message) {
- $actionmsg = $langs->transnoentities('MailFrom') . ': ' . dol_escape_htmltag($from);
- $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTo') . ': ' . dol_escape_htmltag($sendto));
- if ($sendtocc) $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . dol_escape_htmltag($sendtocc));
- $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic') . ": " . $subject);
- $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody') . ":");
+ $actionmsg = $langs->transnoentities('MailFrom').': '.dol_escape_htmltag($from);
+ $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTo').': '.dol_escape_htmltag($sendto));
+ if ($sendtocc) $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc').": ".dol_escape_htmltag($sendtocc));
+ $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic').": ".$subject);
+ $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody').":");
$actionmsg = dol_concatdesc($actionmsg, $message);
}
- require_once DOL_DOCUMENT_ROOT . '/comm/action/class/actioncomm.class.php';
+ require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
// Insert record of emails sent
$actioncomm = new ActionComm($this->db);
$actioncomm->type_code = 'AC_OTH_AUTO'; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...)
- $actioncomm->code = 'AC_' . $actioncode;
+ $actioncomm->code = 'AC_'.$actioncode;
$actioncomm->label = $actionmsg2;
$actioncomm->note_private = $actionmsg;
$actioncomm->fk_project = 0;
@@ -2780,8 +2780,8 @@ class Adherent extends CommonObject
$this->error = $blockingerrormsg;
return 1;
} else {
- $this->output = 'Found ' . ($nbok + $nbko) . ' members to send reminder to.';
- $this->output .= ' Send email successfuly to ' . $nbok . ' members';
+ $this->output = 'Found '.($nbok + $nbko).' members to send reminder to.';
+ $this->output .= ' Send email successfuly to '.$nbok.' members';
if (is_array($listofmembersok)) {
$listofids = '';
$i = 0;
@@ -2801,7 +2801,7 @@ class Adherent extends CommonObject
$this->output .= $listofids;
}
if ($nbko) {
- $this->output .= ' - Canceled for ' . $nbko . ' member (no email or email sending error)';
+ $this->output .= ' - Canceled for '.$nbko.' member (no email or email sending error)';
if (is_array($listofmembersko)) {
$listofids = '';
$i = 0;
diff --git a/htdocs/adherents/document.php b/htdocs/adherents/document.php
index cc840f754bc..ca74d9bcbda 100644
--- a/htdocs/adherents/document.php
+++ b/htdocs/adherents/document.php
@@ -47,7 +47,7 @@ $result=restrictedArea($user, 'adherent', $id);
// Get parameters
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
-$page = GETPOST("page", 'int');
+$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $conf->liste_limit * $page ;
$pageprev = $page - 1;
diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php
index 7497ededc8f..aa487ad4174 100644
--- a/htdocs/adherents/list.php
+++ b/htdocs/adherents/list.php
@@ -74,7 +74,7 @@ if ($statut < -1) $statut = '';
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
-$page = GETPOST("page", 'int');
+$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php
index 380ff7a5019..12301b272a6 100644
--- a/htdocs/adherents/subscription.php
+++ b/htdocs/adherents/subscription.php
@@ -49,7 +49,7 @@ $typeid = GETPOST('typeid', 'int');
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
-$page = GETPOST('page', 'int');
+$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
diff --git a/htdocs/adherents/subscription/list.php b/htdocs/adherents/subscription/list.php
index af1e6c9bdb4..c75041705df 100644
--- a/htdocs/adherents/subscription/list.php
+++ b/htdocs/adherents/subscription/list.php
@@ -54,7 +54,7 @@ $date_select = GETPOST("date_select", 'alpha');
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
-$page = GETPOST("page", 'int');
+$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php
index b2b94fd5684..68989ee3ef9 100644
--- a/htdocs/adherents/type.php
+++ b/htdocs/adherents/type.php
@@ -50,7 +50,7 @@ $status = GETPOST('status', 'alpha');
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
-$page = GETPOST("page", 'int');
+$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
diff --git a/htdocs/admin/const.php b/htdocs/admin/const.php
index c4fa1e9240f..1f04b96f670 100644
--- a/htdocs/admin/const.php
+++ b/htdocs/admin/const.php
@@ -48,7 +48,7 @@ $constnote=GETPOST('constnote', 'alpha');
$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit;
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
-$page = GETPOST('page', 'int');
+$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
$offset = $limit * $page;
$pageprev = $page - 1;
diff --git a/htdocs/admin/defaultvalues.php b/htdocs/admin/defaultvalues.php
index d6981448ea6..9daf076cc5e 100644
--- a/htdocs/admin/defaultvalues.php
+++ b/htdocs/admin/defaultvalues.php
@@ -44,7 +44,7 @@ $mode = GETPOST('mode', 'aZ09') ?GETPOST('mode', 'aZ09') : 'createform'; // 'cre
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
-$page = GETPOST("page", 'int');
+$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php
index 25e09a09f2f..0dfa050f067 100644
--- a/htdocs/admin/dict.php
+++ b/htdocs/admin/dict.php
@@ -70,7 +70,7 @@ $active = 1;
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
-$page = GETPOST("page", 'int');
+$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $listlimit * $page;
$pageprev = $page - 1;
diff --git a/htdocs/admin/emailcollector_list.php b/htdocs/admin/emailcollector_list.php
index 9495123545b..120fce37b4c 100644
--- a/htdocs/admin/emailcollector_list.php
+++ b/htdocs/admin/emailcollector_list.php
@@ -53,7 +53,7 @@ $id = GETPOST('id', 'int');
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
-$page = GETPOST('page', 'int');
+$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
$offset = $limit * $page;
$pageprev = $page - 1;
diff --git a/htdocs/admin/ihm.php b/htdocs/admin/ihm.php
index 70ea29360c8..2f33b3ab49b 100644
--- a/htdocs/admin/ihm.php
+++ b/htdocs/admin/ihm.php
@@ -36,12 +36,12 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
// Load translation files required by the page
$langs->loadLangs(array('admin', 'languages', 'other', 'companies', 'products', 'members', 'projects', 'hrm', 'agenda'));
-if (! $user->admin) accessforbidden();
+if (!$user->admin) accessforbidden();
$action = GETPOST('action', 'aZ09');
-$contextpage=GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'adminihm'; // To manage different context of search
+$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'adminihm'; // To manage different context of search
-if (! defined("MAIN_MOTD")) define("MAIN_MOTD", "");
+if (!defined("MAIN_MOTD")) define("MAIN_MOTD", "");
@@ -49,13 +49,13 @@ if (! defined("MAIN_MOTD")) define("MAIN_MOTD", "");
* Action
*/
-$parameters=array();
-$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
+$parameters = array();
+$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if (GETPOST('cancel', 'alpha'))
{
- $action='';
+ $action = '';
}
// Convert action set_XXX and del_XXX to set var (this is used when no javascript on for ajax_constantonoff)
@@ -65,15 +65,15 @@ if (preg_match('/^(set|del)_([A-Z_]+)$/', $action, $regs)) {
else dolibarr_del_const($db, $regs[2], $conf->entity);
}
-if ($action == 'removebackgroundlogin' && ! empty($conf->global->MAIN_LOGIN_BACKGROUND))
+if ($action == 'removebackgroundlogin' && !empty($conf->global->MAIN_LOGIN_BACKGROUND))
{
- dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", (int) $conf->global->MAIN_IHM_PARAMS_REV+1, 'chaine', 0, '', $conf->entity);
+ dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", (int) $conf->global->MAIN_IHM_PARAMS_REV + 1, 'chaine', 0, '', $conf->entity);
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
- $logofile=$conf->mycompany->dir_output.'/logos/'.$conf->global->MAIN_LOGIN_BACKGROUND;
+ $logofile = $conf->mycompany->dir_output.'/logos/'.$conf->global->MAIN_LOGIN_BACKGROUND;
dol_delete_file($logofile);
dolibarr_del_const($db, "MAIN_LOGIN_BACKGROUND", $conf->entity);
- $mysoc->logo='';
+ $mysoc->logo = '';
/*$logosmallfile=$conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small;
dol_delete_file($logosmallfile);
@@ -89,7 +89,7 @@ if ($action == 'removebackgroundlogin' && ! empty($conf->global->MAIN_LOGIN_BACK
if ($action == 'update')
{
dolibarr_set_const($db, "MAIN_LANG_DEFAULT", GETPOST("MAIN_LANG_DEFAULT", 'aZ09'), 'chaine', 0, '', $conf->entity);
- dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", (int) $conf->global->MAIN_IHM_PARAMS_REV+1, 'chaine', 0, '', $conf->entity);
+ dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", (int) $conf->global->MAIN_IHM_PARAMS_REV + 1, 'chaine', 0, '', $conf->entity);
//dolibarr_set_const($db, "MAIN_MULTILANGS", $_POST["MAIN_MULTILANGS"], 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_THEME", GETPOST("main_theme", 'aZ09'), 'chaine', 0, '', $conf->entity);
@@ -98,53 +98,53 @@ if ($action == 'update')
if (! $val) dolibarr_del_const($db, 'THEME_TOPMENU_DISABLE_IMAGE', $conf->entity);
else dolibarr_set_const($db, 'THEME_TOPMENU_DISABLE_IMAGE', GETPOST('THEME_TOPMENU_DISABLE_IMAGE'), 'chaine', 0, '', $conf->entity);*/
- $val=(implode(',', (colorStringToArray(GETPOST('THEME_ELDY_BACKBODY'), array()))));
+ $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_BACKBODY'), array()))));
if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_BACKBODY', $conf->entity);
else dolibarr_set_const($db, 'THEME_ELDY_BACKBODY', $val, 'chaine', 0, '', $conf->entity);
- $val=(implode(',', (colorStringToArray(GETPOST('THEME_ELDY_TOPMENU_BACK1'), array()))));
+ $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_TOPMENU_BACK1'), array()))));
if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_TOPMENU_BACK1', $conf->entity);
else dolibarr_set_const($db, 'THEME_ELDY_TOPMENU_BACK1', $val, 'chaine', 0, '', $conf->entity);
- $val=(implode(',', (colorStringToArray(GETPOST('THEME_ELDY_VERMENU_BACK1'), array()))));
+ $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_VERMENU_BACK1'), array()))));
if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_VERMENU_BACK1', $conf->entity);
else dolibarr_set_const($db, 'THEME_ELDY_VERMENU_BACK1', $val, 'chaine', 0, '', $conf->entity);
- $val=(implode(',', (colorStringToArray(GETPOST('THEME_ELDY_TEXTTITLENOTAB'), array()))));
+ $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_TEXTTITLENOTAB'), array()))));
if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_TEXTTITLENOTAB', $conf->entity);
else dolibarr_set_const($db, 'THEME_ELDY_TEXTTITLENOTAB', $val, 'chaine', 0, '', $conf->entity);
- $val=(implode(',', (colorStringToArray(GETPOST('THEME_ELDY_BACKTITLE1'), array()))));
+ $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_BACKTITLE1'), array()))));
if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_BACKTITLE1', $conf->entity);
else dolibarr_set_const($db, 'THEME_ELDY_BACKTITLE1', $val, 'chaine', 0, '', $conf->entity);
- $val=(implode(',', (colorStringToArray(GETPOST('THEME_ELDY_TEXTTITLE'), array()))));
+ $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_TEXTTITLE'), array()))));
if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_TEXTTITLE', $conf->entity);
else dolibarr_set_const($db, 'THEME_ELDY_TEXTTITLE', $val, 'chaine', 0, '', $conf->entity);
- $val=(implode(',', (colorStringToArray(GETPOST('THEME_ELDY_LINEIMPAIR1'), array()))));
+ $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_LINEIMPAIR1'), array()))));
if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_LINEIMPAIR1', $conf->entity);
else dolibarr_set_const($db, 'THEME_ELDY_LINEIMPAIR1', $val, 'chaine', 0, '', $conf->entity);
- $val=(implode(',', (colorStringToArray(GETPOST('THEME_ELDY_LINEIMPAIR1'), array()))));
+ $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_LINEIMPAIR1'), array()))));
if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_LINEIMPAIR2', $conf->entity);
else dolibarr_set_const($db, 'THEME_ELDY_LINEIMPAIR2', $val, 'chaine', 0, '', $conf->entity);
- $val=(implode(',', (colorStringToArray(GETPOST('THEME_ELDY_LINEPAIR1'), array()))));
+ $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_LINEPAIR1'), array()))));
if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_LINEPAIR1', $conf->entity);
else dolibarr_set_const($db, 'THEME_ELDY_LINEPAIR1', $val, 'chaine', 0, '', $conf->entity);
- $val=(implode(',', (colorStringToArray(GETPOST('THEME_ELDY_LINEPAIR1'), array()))));
+ $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_LINEPAIR1'), array()))));
if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_LINEPAIR2', $conf->entity);
else dolibarr_set_const($db, 'THEME_ELDY_LINEPAIR2', $val, 'chaine', 0, '', $conf->entity);
- $val=(implode(',', (colorStringToArray(GETPOST('THEME_ELDY_TEXTLINK'), array()))));
+ $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_TEXTLINK'), array()))));
if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_TEXTLINK', $conf->entity);
else dolibarr_set_const($db, 'THEME_ELDY_TEXTLINK', $val, 'chaine', 0, '', $conf->entity);
- $val=(implode(',', (colorStringToArray(GETPOST('THEME_ELDY_USE_HOVER'), array()))));
+ $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_USE_HOVER'), array()))));
if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_USE_HOVER', $conf->entity);
else dolibarr_set_const($db, "THEME_ELDY_USE_HOVER", $val, 'chaine', 0, '', $conf->entity);
- $val=(implode(',', (colorStringToArray(GETPOST('THEME_ELDY_USE_CHECKED'), array()))));
+ $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_USE_CHECKED'), array()))));
if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_USE_CHECKED', $conf->entity);
else dolibarr_set_const($db, "THEME_ELDY_USE_CHECKED", $val, 'chaine', 0, '', $conf->entity);
@@ -158,29 +158,29 @@ if ($action == 'update')
dolibarr_set_const($db, "MAIN_DEFAULT_WORKING_HOURS", GETPOST("MAIN_DEFAULT_WORKING_HOURS", 'int'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_FIRSTNAME_NAME_POSITION", GETPOST("MAIN_FIRSTNAME_NAME_POSITION", 'aZ09'), 'chaine', 0, '', $conf->entity);
- dolibarr_set_const($db, "MAIN_HELPCENTER_DISABLELINK", GETPOST('MAIN_HELPCENTER_DISABLELINK', 'aZ09'), 'chaine', 0, '', 0); // Param for all entities
+ dolibarr_set_const($db, "MAIN_HELPCENTER_DISABLELINK", GETPOST('MAIN_HELPCENTER_DISABLELINK', 'aZ09'), 'chaine', 0, '', 0); // Param for all entities
dolibarr_set_const($db, "MAIN_MOTD", dol_htmlcleanlastbr(GETPOST("main_motd", 'none')), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_HOME", dol_htmlcleanlastbr(GETPOST("main_home", 'none')), 'chaine', 0, '', $conf->entity);
- dolibarr_set_const($db, "MAIN_HELP_DISABLELINK", GETPOST("MAIN_HELP_DISABLELINK", 'aZ09'), 'chaine', 0, '', 0); // Param for all entities
+ dolibarr_set_const($db, "MAIN_HELP_DISABLELINK", GETPOST("MAIN_HELP_DISABLELINK", 'aZ09'), 'chaine', 0, '', 0); // Param for all entities
dolibarr_set_const($db, "MAIN_BUGTRACK_ENABLELINK", GETPOST('MAIN_BUGTRACK_ENABLELINK', 'aZ09'), 'chaine', 0, '', $conf->entity);
- $varforimage='imagebackground'; $dirforimage=$conf->mycompany->dir_output.'/logos/';
+ $varforimage = 'imagebackground'; $dirforimage = $conf->mycompany->dir_output.'/logos/';
if ($_FILES[$varforimage]["tmp_name"])
{
$reg = array();
if (preg_match('/([^\\/:]+)$/i', $_FILES[$varforimage]["name"], $reg))
{
- $original_file=$reg[1];
+ $original_file = $reg[1];
- $isimage=image_format_supported($original_file);
+ $isimage = image_format_supported($original_file);
if ($isimage >= 0)
{
dol_syslog("Move file ".$_FILES[$varforimage]["tmp_name"]." to ".$dirforimage.$original_file);
- if (! is_dir($dirforimage))
+ if (!is_dir($dirforimage))
{
dol_mkdir($dirforimage);
}
- $result=dol_move_uploaded_file($_FILES[$varforimage]["tmp_name"], $dirforimage.$original_file, 1, 0, $_FILES[$varforimage]['error']);
+ $result = dol_move_uploaded_file($_FILES[$varforimage]["tmp_name"], $dirforimage.$original_file, 1, 0, $_FILES[$varforimage]['error']);
if ($result > 0)
{
dolibarr_set_const($db, "MAIN_LOGIN_BACKGROUND", $original_file, 'chaine', 0, '', $conf->entity);
@@ -189,7 +189,7 @@ if ($action == 'update')
{
$error++;
$langs->load("errors");
- $tmparray=explode(':', $result);
+ $tmparray = explode(':', $result);
setEventMessages($langs->trans('ErrorFileIsInfectedWithAVirus', $tmparray[1]), null, 'errors');
}
else
@@ -209,7 +209,7 @@ if ($action == 'update')
- $_SESSION["mainmenu"]=""; // Le gestionnaire de menu a pu changer
+ $_SESSION["mainmenu"] = ""; // Le gestionnaire de menu a pu changer
header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup");
exit;
@@ -220,12 +220,12 @@ if ($action == 'update')
* View
*/
-$wikihelp='EN:First_setup|FR:Premiers_paramétrages|ES:Primeras_configuraciones';
+$wikihelp = 'EN:First_setup|FR:Premiers_paramétrages|ES:Primeras_configuraciones';
llxHeader('', $langs->trans("Setup"), $wikihelp);
-$form=new Form($db);
-$formother=new FormOther($db);
-$formadmin=new FormAdmin($db);
+$form = new Form($db);
+$formother = new FormOther($db);
+$formadmin = new FormAdmin($db);
print load_fiche_titre($langs->trans("GUISetup"), '', 'title_setup');
@@ -281,12 +281,12 @@ print ' ';
print ' ';
// Max size of lists
-print ''.$langs->trans("BackgroundImageLogin").' (png,jpg) ';
print '';
$disabled = '';
-if (! empty($conf->global->ADD_UNSPLASH_LOGIN_BACKGROUND)) $disabled = ' disabled="disabled"';
+if (!empty($conf->global->ADD_UNSPLASH_LOGIN_BACKGROUND)) $disabled = ' disabled="disabled"';
print '
';
if ($disabled)
{
print '('.$langs->trans("DisabledByOptionADD_UNSPLASH_LOGIN_BACKGROUND").') ';
}
-if (! empty($conf->global->MAIN_LOGIN_BACKGROUND)) {
+if (!empty($conf->global->MAIN_LOGIN_BACKGROUND)) {
print '
'.img_delete($langs->trans("Delete")).' ';
if (file_exists($conf->mycompany->dir_output.'/logos/'.$conf->global->MAIN_LOGIN_BACKGROUND)) {
print ' ';
diff --git a/htdocs/admin/mails_senderprofile_list.php b/htdocs/admin/mails_senderprofile_list.php
index 137d4129929..1c50ebf0949 100644
--- a/htdocs/admin/mails_senderprofile_list.php
+++ b/htdocs/admin/mails_senderprofile_list.php
@@ -48,7 +48,7 @@ $id = GETPOST('id', 'int');
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
-$page = GETPOST('page', 'int');
+$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
$offset = $limit * $page;
$pageprev = $page - 1;
diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php
index 734bd9c88ce..1102f68ba5f 100644
--- a/htdocs/admin/mails_templates.php
+++ b/htdocs/admin/mails_templates.php
@@ -71,7 +71,7 @@ $active = 1;
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
-$page = GETPOST("page", 'int');
+$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $listlimit * $page;
$pageprev = $page - 1;
diff --git a/htdocs/admin/tools/dolibarr_export.php b/htdocs/admin/tools/dolibarr_export.php
index 854fd130bc5..05546fdee5a 100644
--- a/htdocs/admin/tools/dolibarr_export.php
+++ b/htdocs/admin/tools/dolibarr_export.php
@@ -33,7 +33,7 @@ $action = GETPOST('action', 'alpha');
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
-$page = GETPOST('page', 'int');
+$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (!$sortorder) $sortorder = "DESC";
if (!$sortfield) $sortfield = "date";
if (empty($page) || $page == -1) { $page = 0; }
diff --git a/htdocs/admin/tools/export.php b/htdocs/admin/tools/export.php
index e05e4fc143d..f2e423d9174 100644
--- a/htdocs/admin/tools/export.php
+++ b/htdocs/admin/tools/export.php
@@ -39,7 +39,7 @@ $file=GETPOST('filename_template', 'alpha');
$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit;
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
-$page = GETPOST("page", 'int');
+$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
$offset = $limit * $page;
if (! $sortorder) $sortorder="DESC";
diff --git a/htdocs/admin/tools/export_files.php b/htdocs/admin/tools/export_files.php
index c1c641b82f2..dec8da6aa53 100644
--- a/htdocs/admin/tools/export_files.php
+++ b/htdocs/admin/tools/export_files.php
@@ -41,7 +41,7 @@ $file = preg_replace('/(\.zip|\.tar|\.tgz|\.gz|\.tar\.gz|\.bz2)$/i', '', $file);
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
-$page = GETPOST("page", 'int');
+$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (! $sortorder) $sortorder="DESC";
if (! $sortfield) $sortfield="date";
if ($page < 0) { $page = 0; }
diff --git a/htdocs/admin/tools/listevents.php b/htdocs/admin/tools/listevents.php
index 52717200bce..f57a16332df 100644
--- a/htdocs/admin/tools/listevents.php
+++ b/htdocs/admin/tools/listevents.php
@@ -48,7 +48,7 @@ $langs->loadLangs(array("companies", "admin", "users", "other"));
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
-$page = GETPOST('page', 'int');
+$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
diff --git a/htdocs/admin/tools/listsessions.php b/htdocs/admin/tools/listsessions.php
index d909dc8610b..28d4fc3d51f 100644
--- a/htdocs/admin/tools/listsessions.php
+++ b/htdocs/admin/tools/listsessions.php
@@ -43,7 +43,7 @@ if ($user->socid > 0)
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
-$page = GETPOST("page", 'int');
+$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $conf->liste_limit * $page ;
$pageprev = $page - 1;
diff --git a/htdocs/admin/translation.php b/htdocs/admin/translation.php
index c641be11a59..cad874d89b2 100644
--- a/htdocs/admin/translation.php
+++ b/htdocs/admin/translation.php
@@ -45,7 +45,7 @@ $mode = GETPOST('mode', 'aZ09') ?GETPOST('mode', 'aZ09') : 'overwrite';
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
-$page = GETPOST("page", 'int');
+$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
diff --git a/htdocs/admin/website.php b/htdocs/admin/website.php
index 2d201421f20..dd7fd353ea2 100644
--- a/htdocs/admin/website.php
+++ b/htdocs/admin/website.php
@@ -55,7 +55,7 @@ $status = 1;
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
-$page = GETPOST('page', 'int');
+$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
diff --git a/htdocs/admin/website_options.php b/htdocs/admin/website_options.php
index 92c16a1123e..7d16aa3963b 100644
--- a/htdocs/admin/website_options.php
+++ b/htdocs/admin/website_options.php
@@ -48,7 +48,7 @@ $status = 1;
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
-$page = GETPOST('page', 'int');
+$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
diff --git a/htdocs/asset/document.php b/htdocs/asset/document.php
index c6488f9e0be..c6762c5c946 100644
--- a/htdocs/asset/document.php
+++ b/htdocs/asset/document.php
@@ -47,7 +47,7 @@ $ref = GETPOST('ref', 'alpha');
// Get parameters
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
-$page = GETPOST("page", 'int');
+$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $conf->liste_limit * $page;
$pageprev = $page - 1;
diff --git a/htdocs/asset/list.php b/htdocs/asset/list.php
index 2a9657baf90..e414193fb83 100644
--- a/htdocs/asset/list.php
+++ b/htdocs/asset/list.php
@@ -49,7 +49,7 @@ $id = GETPOST('id', 'int');
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
-$page = GETPOST('page', 'int');
+$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
$offset = $limit * $page;
$pageprev = $page - 1;
diff --git a/htdocs/asset/type.php b/htdocs/asset/type.php
index 542dbc8e23d..8df5ffe8c40 100644
--- a/htdocs/asset/type.php
+++ b/htdocs/asset/type.php
@@ -43,7 +43,7 @@ $type = GETPOST('type', 'alpha');
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
-$page = GETPOST("page", 'int');
+$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
diff --git a/htdocs/blockedlog/admin/blockedlog_list.php b/htdocs/blockedlog/admin/blockedlog_list.php
index becbbc3f151..3bd7f0097b9 100644
--- a/htdocs/blockedlog/admin/blockedlog_list.php
+++ b/htdocs/blockedlog/admin/blockedlog_list.php
@@ -58,7 +58,7 @@ if (($search_start == -1 || empty($search_start)) && ! GETPOSTISSET('search_star
$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit;
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
-$page = GETPOST('page', 'int');
+$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
diff --git a/htdocs/bom/bom_agenda.php b/htdocs/bom/bom_agenda.php
index 37197d641dc..a5b66b9886f 100644
--- a/htdocs/bom/bom_agenda.php
+++ b/htdocs/bom/bom_agenda.php
@@ -60,7 +60,7 @@ $search_agenda_label = GETPOST('search_agenda_label');
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
-$page = GETPOST("page", 'int');
+$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
diff --git a/htdocs/bom/bom_document.php b/htdocs/bom/bom_document.php
index 6ac836fdcae..0fc68ed276e 100644
--- a/htdocs/bom/bom_document.php
+++ b/htdocs/bom/bom_document.php
@@ -48,7 +48,7 @@ $ref = GETPOST('ref', 'alpha');
// Get parameters
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
-$page = GETPOST("page", 'int');
+$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $conf->liste_limit * $page;
$pageprev = $page - 1;
diff --git a/htdocs/bom/bom_list.php b/htdocs/bom/bom_list.php
index 12602f9744a..e33394edcf7 100644
--- a/htdocs/bom/bom_list.php
+++ b/htdocs/bom/bom_list.php
@@ -47,7 +47,7 @@ $id = GETPOST('id', 'int');
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
-$page = GETPOST('page', 'int');
+$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
$offset = $limit * $page;
$pageprev = $page - 1;
diff --git a/htdocs/bookmarks/list.php b/htdocs/bookmarks/list.php
index 4e9d6851399..067e2abeaa9 100644
--- a/htdocs/bookmarks/list.php
+++ b/htdocs/bookmarks/list.php
@@ -44,7 +44,7 @@ $optioncss = GETPOST('optioncss', 'alpha');
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
-$page = GETPOST('page', 'int');
+$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
$offset = $limit * $page;
$pageprev = $page - 1;
diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php
index ac4e5b030c1..e8296b96beb 100644
--- a/htdocs/categories/class/categorie.class.php
+++ b/htdocs/categories/class/categorie.class.php
@@ -1912,8 +1912,8 @@ class Categorie extends CommonObject
/**
* Return label of contact status
*
- * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
- * @return string Label of contact status
+ * @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 contact status
*/
public function getLibStatut($mode)
{
@@ -1968,8 +1968,9 @@ class Categorie extends CommonObject
*/
public static function getFilterJoinQuery($type, $rowIdName)
{
- return " LEFT JOIN ".MAIN_DB_PREFIX."categorie_".$type." as cp"
- . " ON ".$rowIdName." = cp.fk_".$type;
+ if ($type == 'bank_account') $type = 'account';
+
+ return " LEFT JOIN ".MAIN_DB_PREFIX."categorie_".$type." as cp ON ".$rowIdName." = cp.fk_".$type;
}
/**
@@ -1982,6 +1983,8 @@ class Categorie extends CommonObject
*/
public static function getFilterSelectQuery($type, $rowIdName, $searchList)
{
+ if ($type == 'bank_account') $type = 'account';
+
if (empty($searchList) && !is_array($searchList))
{
return "";
diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php
index 5d81ccd7d63..62538da0273 100644
--- a/htdocs/categories/viewcat.php
+++ b/htdocs/categories/viewcat.php
@@ -55,7 +55,7 @@ $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
-$page = GETPOST('page', 'int');
+$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
$offset = $limit * $page;
$pageprev = $page - 1;
diff --git a/htdocs/comm/action/document.php b/htdocs/comm/action/document.php
index f01f49921e7..31f608a9ee0 100644
--- a/htdocs/comm/action/document.php
+++ b/htdocs/comm/action/document.php
@@ -64,7 +64,7 @@ if ($id > 0)
// Get parameters
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
-$page = GETPOST("page", 'int');
+$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $conf->liste_limit * $page;
$pageprev = $page - 1;
diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php
index 31808d35991..b480586bc6a 100644
--- a/htdocs/comm/action/index.php
+++ b/htdocs/comm/action/index.php
@@ -58,7 +58,7 @@ if (empty($filtert) && empty($conf->global->AGENDA_ALL_CALENDARS))
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
-$page = GETPOST("page", "int");
+$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$offset = $limit * $page;
diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php
index 895136f82f0..e388bb25fb0 100644
--- a/htdocs/comm/action/list.php
+++ b/htdocs/comm/action/list.php
@@ -94,7 +94,7 @@ if (empty($filtert) && empty($conf->global->AGENDA_ALL_CALENDARS))
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
-$page = GETPOST("page", 'int');
+$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if ($page == -1 || $page == null) { $page = 0; }
$offset = $limit * $page;
if (!$sortorder)
diff --git a/htdocs/comm/action/pertype.php b/htdocs/comm/action/pertype.php
index 04f334a9551..b1d0ddc7ccc 100644
--- a/htdocs/comm/action/pertype.php
+++ b/htdocs/comm/action/pertype.php
@@ -56,7 +56,7 @@ if (empty($filtert) && empty($conf->global->AGENDA_ALL_CALENDARS))
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
-$page = GETPOST("page", "int");
+$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$offset = $limit * $page;
diff --git a/htdocs/comm/action/peruser.php b/htdocs/comm/action/peruser.php
index f906c4cab45..e8f7be097fa 100644
--- a/htdocs/comm/action/peruser.php
+++ b/htdocs/comm/action/peruser.php
@@ -56,7 +56,7 @@ $showbirthday = 0;
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
-$page = GETPOST("page", "int");
+$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$offset = $limit * $page;
diff --git a/htdocs/comm/action/rapport/index.php b/htdocs/comm/action/rapport/index.php
index 92744da332c..b9ab38a734e 100644
--- a/htdocs/comm/action/rapport/index.php
+++ b/htdocs/comm/action/rapport/index.php
@@ -41,7 +41,7 @@ $year=GETPOST('year');
$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
-$page = GETPOST("page", 'int');
+$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if ($page == -1 || $page == null) { $page = 0 ; }
$offset = $limit * $page ;
if (! $sortorder) $sortorder="DESC";
diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php
index 14929faf2ba..f1ea3c0923d 100644
--- a/htdocs/comm/card.php
+++ b/htdocs/comm/card.php
@@ -67,7 +67,7 @@ $mode = GETPOST("mode");
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
-$page = GETPOST("page", 'int');
+$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $conf->liste_limit * $page;
$pageprev = $page - 1;
@@ -751,7 +751,7 @@ if ($object->id > 0)
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as c";
$sql .= " WHERE c.fk_soc = s.rowid ";
$sql .= " AND s.rowid = ".$object->id;
- $sql .= " AND c.entity = ".$conf->entity;
+ $sql .= " AND c.entity IN (".getEntity('commande').')';
$sql .= " ORDER BY c.date_commande DESC";
$resql = $db->query($sql);
@@ -905,7 +905,7 @@ if ($object->id > 0)
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as c";
$sql .= " WHERE c.fk_soc = s.rowid ";
$sql .= " AND s.rowid = ".$object->id;
- $sql .= " AND c.entity = ".$conf->entity;
+ $sql .= " AND c.entity IN (".getEntity('contract').")";
$sql .= " ORDER BY c.datec DESC";
$resql = $db->query($sql);
@@ -975,7 +975,7 @@ if ($object->id > 0)
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."fichinter as f";
$sql .= " WHERE f.fk_soc = s.rowid";
$sql .= " AND s.rowid = ".$object->id;
- $sql .= " AND f.entity = ".$conf->entity;
+ $sql .= " AND f.entity IN (".getEntity('intervention').")";
$sql .= " ORDER BY f.tms DESC";
$resql = $db->query($sql);
@@ -1044,7 +1044,7 @@ if ($object->id > 0)
$sql .= ', s.nom, s.rowid as socid';
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_rec as f";
$sql .= " WHERE f.fk_soc = s.rowid AND s.rowid = ".$object->id;
- $sql .= " AND f.entity = ".$conf->entity;
+ $sql .= " AND f.entity IN (".getEntity('invoice').")";
$sql .= ' GROUP BY f.rowid, f.titre, f.total, f.tva, f.total_ttc,';
$sql .= ' f.date_last_gen, f.datec, f.frequency, f.unit_frequency,';
$sql .= ' f.suspended, f.date_when,';
diff --git a/htdocs/comm/contact.php b/htdocs/comm/contact.php
index 8b3f4cf4894..3121bc3f1b9 100644
--- a/htdocs/comm/contact.php
+++ b/htdocs/comm/contact.php
@@ -31,7 +31,7 @@ $langs->load("companies");
$sortfield=GETPOST('sortfield', 'alpha');
$sortorder=GETPOST('sortorder', 'alpha');
-$page=GETPOST('page', 'int');
+$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (! $sortorder) $sortorder="ASC";
if (! $sortfield) $sortfield="p.name";
if ($page < 0) { $page = 0; }
diff --git a/htdocs/comm/mailing/advtargetemailing.php b/htdocs/comm/mailing/advtargetemailing.php
index b85826339e5..b716790aa8f 100644
--- a/htdocs/comm/mailing/advtargetemailing.php
+++ b/htdocs/comm/mailing/advtargetemailing.php
@@ -48,7 +48,7 @@ if (!$user->rights->mailing->lire || $user->socid > 0)
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
-$page = GETPOST('page', 'int');
+$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
diff --git a/htdocs/comm/mailing/cibles.php b/htdocs/comm/mailing/cibles.php
index 41e49ed09b3..9babe88fd0b 100644
--- a/htdocs/comm/mailing/cibles.php
+++ b/htdocs/comm/mailing/cibles.php
@@ -43,7 +43,7 @@ if (!$user->rights->mailing->lire || $user->socid > 0) accessforbidden();
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
-$page = GETPOST('page', 'int');
+$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
diff --git a/htdocs/comm/mailing/list.php b/htdocs/comm/mailing/list.php
index 7e2baa7274b..1eadb2d0da0 100644
--- a/htdocs/comm/mailing/list.php
+++ b/htdocs/comm/mailing/list.php
@@ -34,7 +34,7 @@ $result = restrictedArea($user, 'mailing');
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
-$page = GETPOST("page", 'int');
+$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
$offset = $limit * $page;
$pageprev = $page - 1;
diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php
index f55861b00cc..9430fce4634 100644
--- a/htdocs/comm/propal/card.php
+++ b/htdocs/comm/propal/card.php
@@ -1893,7 +1893,7 @@ if ($action == 'create')
{
//Form to close proposal (signed or not)
$formquestion = array(
- array('type' => 'select', 'name' => 'statut', 'label' => $langs->trans("CloseAs"), 'values' => array(2=>$object->LibStatut(Propal::STATUS_SIGNED), 3=>$object->LibStatut(Propal::STATUS_NOTSIGNED))),
+ array('type' => 'select', 'name' => 'statut', 'label' => '
'.$langs->trans("CloseAs").' ', 'values' => array(2=>$object->LibStatut(Propal::STATUS_SIGNED), 3=>$object->LibStatut(Propal::STATUS_NOTSIGNED))),
array('type' => 'text', 'name' => 'note_private', 'label' => $langs->trans("Note"), 'value' => '') // Field to complete private note (not replace)
);
diff --git a/htdocs/comm/propal/class/api_proposals.class.php b/htdocs/comm/propal/class/api_proposals.class.php
index 9326082b193..87c91d0f621 100644
--- a/htdocs/comm/propal/class/api_proposals.class.php
+++ b/htdocs/comm/propal/class/api_proposals.class.php
@@ -119,16 +119,16 @@ class Proposals extends DolibarrApi
*/
private function _fetch($id, $ref = '', $ref_ext = '', $contact_list = 1)
{
- if(! DolibarrApiAccess::$user->rights->propal->lire) {
+ if (!DolibarrApiAccess::$user->rights->propal->lire) {
throw new RestException(401);
}
$result = $this->propal->fetch($id, $ref, $ref_ext);
- if( ! $result ) {
+ if (!$result) {
throw new RestException(404, 'Commercial Proposal not found');
}
- if( ! DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) {
+ if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
@@ -162,18 +162,18 @@ class Proposals extends DolibarrApi
// If the internal user must only see his customers, force searching by him
$search_sale = 0;
- if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) $search_sale = DolibarrApiAccess::$user->id;
+ if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) $search_sale = DolibarrApiAccess::$user->id;
$sql = "SELECT t.rowid";
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects)
- $sql.= " FROM ".MAIN_DB_PREFIX."propal as t";
+ $sql .= " FROM ".MAIN_DB_PREFIX."propal as t";
- if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale
+ if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale
- $sql.= ' WHERE t.entity IN ('.getEntity('propal').')';
- if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc";
- if ($socids) $sql.= " AND t.fk_soc IN (".$socids.")";
- if ($search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
+ $sql .= ' WHERE t.entity IN ('.getEntity('propal').')';
+ if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= " AND t.fk_soc = sc.fk_soc";
+ if ($socids) $sql .= " AND t.fk_soc IN (".$socids.")";
+ if ($search_sale > 0) $sql .= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
// Insert sale filter
if ($search_sale > 0)
{
@@ -182,23 +182,23 @@ class Proposals extends DolibarrApi
// Add sql filters
if ($sqlfilters)
{
- if (! DolibarrApi::_checkFilters($sqlfilters))
+ if (!DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
}
- $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
- $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
+ $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
+ $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
}
- $sql.= $db->order($sortfield, $sortorder);
- if ($limit) {
+ $sql .= $db->order($sortfield, $sortorder);
+ if ($limit) {
if ($page < 0)
{
$page = 0;
}
$offset = $limit * $page;
- $sql.= $db->plimit($limit + 1, $offset);
+ $sql .= $db->plimit($limit + 1, $offset);
}
dol_syslog("API Rest request");
@@ -213,7 +213,7 @@ class Proposals extends DolibarrApi
{
$obj = $db->fetch_object($result);
$proposal_static = new Propal($db);
- if($proposal_static->fetch($obj->rowid)) {
+ if ($proposal_static->fetch($obj->rowid)) {
// Add external contacts ids
$proposal_static->contacts_ids = $proposal_static->liste_contact(-1, 'external', 1);
$obj_ret[] = $this->_cleanObjectDatas($proposal_static);
@@ -224,7 +224,7 @@ class Proposals extends DolibarrApi
else {
throw new RestException(503, 'Error when retrieve propal list : '.$db->lasterror());
}
- if( ! count($obj_ret)) {
+ if (!count($obj_ret)) {
throw new RestException(404, 'No proposal found');
}
return $obj_ret;
@@ -238,13 +238,13 @@ class Proposals extends DolibarrApi
*/
public function post($request_data = null)
{
- if(! DolibarrApiAccess::$user->rights->propal->creer) {
+ if (!DolibarrApiAccess::$user->rights->propal->creer) {
throw new RestException(401, "Insuffisant rights");
}
// Check mandatory fields
$result = $this->_validate($request_data);
- foreach($request_data as $field => $value) {
+ foreach ($request_data as $field => $value) {
$this->propal->$field = $value;
}
/*if (isset($request_data["lines"])) {
@@ -272,16 +272,16 @@ class Proposals extends DolibarrApi
*/
public function getLines($id)
{
- if(! DolibarrApiAccess::$user->rights->propal->lire) {
+ if (!DolibarrApiAccess::$user->rights->propal->lire) {
throw new RestException(401);
}
$result = $this->propal->fetch($id);
- if( ! $result ) {
+ if (!$result) {
throw new RestException(404, 'Commercial Proposal not found');
}
- if( ! DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) {
+ if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$this->propal->getLinesArray();
@@ -304,16 +304,16 @@ class Proposals extends DolibarrApi
*/
public function postLine($id, $request_data = null)
{
- if (! DolibarrApiAccess::$user->rights->propal->creer) {
+ if (!DolibarrApiAccess::$user->rights->propal->creer) {
throw new RestException(401);
}
$result = $this->propal->fetch($id);
- if (! $result) {
+ if (!$result) {
throw new RestException(404, 'Commercial Proposal not found');
}
- if (! DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) {
+ if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
@@ -368,16 +368,16 @@ class Proposals extends DolibarrApi
*/
public function putLine($id, $lineid, $request_data = null)
{
- if(! DolibarrApiAccess::$user->rights->propal->creer) {
+ if (!DolibarrApiAccess::$user->rights->propal->creer) {
throw new RestException(401);
}
$result = $this->propal->fetch($id);
- if($result <= 0) {
+ if ($result <= 0) {
throw new RestException(404, 'Proposal not found');
}
- if( ! DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) {
+ if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
@@ -391,27 +391,27 @@ class Proposals extends DolibarrApi
$updateRes = $this->propal->updateline(
$lineid,
- isset($request_data->subprice)?$request_data->subprice:$propalline->subprice,
- isset($request_data->qty)?$request_data->qty:$propalline->qty,
- isset($request_data->remise_percent)?$request_data->remise_percent:$propalline->remise_percent,
- isset($request_data->tva_tx)?$request_data->tva_tx:$propalline->tva_tx,
- isset($request_data->localtax1_tx)?$request_data->localtax1_tx:$propalline->localtax1_tx,
- isset($request_data->localtax2_tx)?$request_data->localtax2_tx:$propalline->localtax2_tx,
- isset($request_data->desc)?$request_data->desc:$propalline->desc,
+ isset($request_data->subprice) ? $request_data->subprice : $propalline->subprice,
+ isset($request_data->qty) ? $request_data->qty : $propalline->qty,
+ isset($request_data->remise_percent) ? $request_data->remise_percent : $propalline->remise_percent,
+ isset($request_data->tva_tx) ? $request_data->tva_tx : $propalline->tva_tx,
+ isset($request_data->localtax1_tx) ? $request_data->localtax1_tx : $propalline->localtax1_tx,
+ isset($request_data->localtax2_tx) ? $request_data->localtax2_tx : $propalline->localtax2_tx,
+ isset($request_data->desc) ? $request_data->desc : $propalline->desc,
'HT',
- isset($request_data->info_bits)?$request_data->info_bits:$propalline->info_bits,
- isset($request_data->special_code)?$request_data->special_code:$propalline->special_code,
- isset($request_data->fk_parent_line)?$request_data->fk_parent_line:$propalline->fk_parent_line,
+ isset($request_data->info_bits) ? $request_data->info_bits : $propalline->info_bits,
+ isset($request_data->special_code) ? $request_data->special_code : $propalline->special_code,
+ isset($request_data->fk_parent_line) ? $request_data->fk_parent_line : $propalline->fk_parent_line,
0,
- isset($request_data->fk_fournprice)?$request_data->fk_fournprice:$propalline->fk_fournprice,
- isset($request_data->pa_ht)?$request_data->pa_ht:$propalline->pa_ht,
- isset($request_data->label)?$request_data->label:$propalline->label,
- isset($request_data->product_type)?$request_data->product_type:$propalline->product_type,
- isset($request_data->date_start)?$request_data->date_start:$propalline->date_start,
- isset($request_data->date_end)?$request_data->date_end:$propalline->date_end,
- isset($request_data->array_options)?$request_data->array_options:$propalline->array_options,
- isset($request_data->fk_unit)?$request_data->fk_unit:$propalline->fk_unit,
- isset($request_data->multicurrency_subprice)?$request_data->multicurrency_subprice:$propalline->subprice
+ isset($request_data->fk_fournprice) ? $request_data->fk_fournprice : $propalline->fk_fournprice,
+ isset($request_data->pa_ht) ? $request_data->pa_ht : $propalline->pa_ht,
+ isset($request_data->label) ? $request_data->label : $propalline->label,
+ isset($request_data->product_type) ? $request_data->product_type : $propalline->product_type,
+ isset($request_data->date_start) ? $request_data->date_start : $propalline->date_start,
+ isset($request_data->date_end) ? $request_data->date_end : $propalline->date_end,
+ isset($request_data->array_options) ? $request_data->array_options : $propalline->array_options,
+ isset($request_data->fk_unit) ? $request_data->fk_unit : $propalline->fk_unit,
+ isset($request_data->multicurrency_subprice) ? $request_data->multicurrency_subprice : $propalline->subprice
);
if ($updateRes > 0) {
@@ -438,16 +438,16 @@ class Proposals extends DolibarrApi
*/
public function deleteLine($id, $lineid)
{
- if(! DolibarrApiAccess::$user->rights->propal->creer) {
+ if (!DolibarrApiAccess::$user->rights->propal->creer) {
throw new RestException(401);
}
$result = $this->propal->fetch($id);
- if( ! $result ) {
+ if (!$result) {
throw new RestException(404, 'Proposal not found');
}
- if( ! DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) {
+ if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
@@ -479,13 +479,13 @@ class Proposals extends DolibarrApi
*/
public function postContact($id, $contactid, $type)
{
- if(!DolibarrApiAccess::$user->rights->propal->creer) {
+ if (!DolibarrApiAccess::$user->rights->propal->creer) {
throw new RestException(401);
}
$result = $this->propal->fetch($id);
- if(!$result) {
+ if (!$result) {
throw new RestException(404, 'Proposal not found');
}
@@ -493,7 +493,7 @@ class Proposals extends DolibarrApi
throw new RestException(500, 'Availables types: BILLING, SHIPPING OR CUSTOMER');
}
- if(!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) {
+ if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
@@ -522,17 +522,17 @@ class Proposals extends DolibarrApi
*/
public function deleteContact($id, $rowid)
{
- if(!DolibarrApiAccess::$user->rights->propal->creer) {
+ if (!DolibarrApiAccess::$user->rights->propal->creer) {
throw new RestException(401);
}
$result = $this->propal->fetch($id);
- if(!$result) {
+ if (!$result) {
throw new RestException(404, 'Proposal not found');
}
- if(!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) {
+ if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
@@ -555,16 +555,16 @@ class Proposals extends DolibarrApi
*/
public function put($id, $request_data = null)
{
- if (! DolibarrApiAccess::$user->rights->propal->creer) {
+ if (!DolibarrApiAccess::$user->rights->propal->creer) {
throw new RestException(401);
}
$result = $this->propal->fetch($id);
- if ( ! $result ) {
+ if (!$result) {
throw new RestException(404, 'Proposal not found');
}
- if ( ! DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) {
+ if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
foreach ($request_data as $field => $value) {
@@ -579,7 +579,7 @@ class Proposals extends DolibarrApi
}
if (!empty($this->propal->fin_validite))
{
- if($this->propal->set_echeance(DolibarrApiAccess::$user, $this->propal->fin_validite)<0)
+ if ($this->propal->set_echeance(DolibarrApiAccess::$user, $this->propal->fin_validite) < 0)
{
throw new RestException(500, $this->propal->error);
}
@@ -604,19 +604,19 @@ class Proposals extends DolibarrApi
*/
public function delete($id)
{
- if(! DolibarrApiAccess::$user->rights->propal->supprimer) {
+ if (!DolibarrApiAccess::$user->rights->propal->supprimer) {
throw new RestException(401);
}
$result = $this->propal->fetch($id);
- if( ! $result ) {
+ if (!$result) {
throw new RestException(404, 'Commercial Proposal not found');
}
- if( ! DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) {
+ if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
- if( ! $this->propal->delete(DolibarrApiAccess::$user)) {
+ if (!$this->propal->delete(DolibarrApiAccess::$user)) {
throw new RestException(500, 'Error when delete Commercial Proposal : '.$this->propal->error);
}
@@ -639,15 +639,15 @@ class Proposals extends DolibarrApi
*/
public function settodraft($id)
{
- if(! DolibarrApiAccess::$user->rights->propal->creer) {
+ if (!DolibarrApiAccess::$user->rights->propal->creer) {
throw new RestException(401);
}
$result = $this->propal->fetch($id);
- if( ! $result ) {
+ if (!$result) {
throw new RestException(404, 'Proposal not found');
}
- if( ! DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) {
+ if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
@@ -660,11 +660,11 @@ class Proposals extends DolibarrApi
}
$result = $this->propal->fetch($id);
- if( ! $result ) {
+ if (!$result) {
throw new RestException(404, 'Proposal not found');
}
- if( ! DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) {
+ if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
@@ -696,15 +696,15 @@ class Proposals extends DolibarrApi
*/
public function validate($id, $notrigger = 0)
{
- if(! DolibarrApiAccess::$user->rights->propal->creer) {
+ if (!DolibarrApiAccess::$user->rights->propal->creer) {
throw new RestException(401);
}
$result = $this->propal->fetch($id);
- if( ! $result ) {
+ if (!$result) {
throw new RestException(404, 'Commercial Proposal not found');
}
- if( ! DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) {
+ if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
@@ -717,11 +717,11 @@ class Proposals extends DolibarrApi
}
$result = $this->propal->fetch($id);
- if( ! $result ) {
+ if (!$result) {
throw new RestException(404, 'Commercial Proposal not found');
}
- if( ! DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) {
+ if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
@@ -744,15 +744,15 @@ class Proposals extends DolibarrApi
*/
public function close($id, $status, $note_private = '', $notrigger = 0)
{
- if(! DolibarrApiAccess::$user->rights->propal->creer) {
+ if (!DolibarrApiAccess::$user->rights->propal->creer) {
throw new RestException(401);
}
$result = $this->propal->fetch($id);
- if( ! $result ) {
+ if (!$result) {
throw new RestException(404, 'Commercial Proposal not found');
}
- if( ! DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) {
+ if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
@@ -765,11 +765,11 @@ class Proposals extends DolibarrApi
}
$result = $this->propal->fetch($id);
- if( ! $result ) {
+ if (!$result) {
throw new RestException(404, 'Proposal not found');
}
- if( ! DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) {
+ if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
@@ -789,15 +789,15 @@ class Proposals extends DolibarrApi
*/
public function setinvoiced($id)
{
- if (! DolibarrApiAccess::$user->rights->propal->creer) {
+ if (!DolibarrApiAccess::$user->rights->propal->creer) {
throw new RestException(401);
}
$result = $this->propal->fetch($id);
- if ( ! $result ) {
+ if (!$result) {
throw new RestException(404, 'Commercial Proposal not found');
}
- if ( ! DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) {
+ if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
@@ -807,11 +807,11 @@ class Proposals extends DolibarrApi
}
$result = $this->propal->fetch($id);
- if ( ! $result ) {
+ if (!$result) {
throw new RestException(404, 'Proposal not found');
}
- if( ! DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) {
+ if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php
index bea546eeae8..ff3038e85d1 100644
--- a/htdocs/comm/propal/class/propal.class.php
+++ b/htdocs/comm/propal/class/propal.class.php
@@ -252,13 +252,13 @@ class Propal extends CommonObject
/**
* @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor.
*/
- public $fields=array(
+ public $fields = array(
'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>10),
'entity' =>array('type'=>'integer', 'label'=>'Entity', 'default'=>1, 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>15, 'index'=>1),
'ref' =>array('type'=>'varchar(30)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'showoncombobox'=>1, 'position'=>20),
'ref_client' =>array('type'=>'varchar(255)', 'label'=>'RefCustomer', 'enabled'=>1, 'visible'=>-1, 'position'=>22),
'ref_ext' =>array('type'=>'varchar(255)', 'label'=>'RefExt', 'enabled'=>1, 'visible'=>0, 'position'=>40),
- 'ref_int' =>array('type'=>'varchar(255)', 'label'=>'RefInt', 'enabled'=>1, 'visible'=>0, 'position'=>45), // deprecated
+ 'ref_int' =>array('type'=>'varchar(255)', 'label'=>'RefInt', 'enabled'=>1, 'visible'=>0, 'position'=>45), // deprecated
'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>1, 'visible'=>-1, 'position'=>23),
'fk_projet' =>array('type'=>'integer:Project:projet/class/project.class.php:1:fk_statut=1', 'label'=>'Fk projet', 'enabled'=>1, 'visible'=>-1, 'position'=>24),
'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>25),
@@ -290,7 +290,7 @@ class Propal extends CommonObject
'date_livraison' =>array('type'=>'date', 'label'=>'DateDeliveryPlanned', 'enabled'=>1, 'visible'=>-1, 'position'=>185),
'fk_shipping_method' =>array('type'=>'integer', 'label'=>'ShippingMethod', 'enabled'=>1, 'visible'=>-1, 'position'=>190),
'fk_availability' =>array('type'=>'integer', 'label'=>'Availability', 'enabled'=>1, 'visible'=>-1, 'position'=>195),
- 'fk_delivery_address' =>array('type'=>'integer', 'label'=>'DeliveryAddress', 'enabled'=>1, 'visible'=>0, 'position'=>200), // deprecated
+ 'fk_delivery_address' =>array('type'=>'integer', 'label'=>'DeliveryAddress', 'enabled'=>1, 'visible'=>0, 'position'=>200), // deprecated
'fk_input_reason' =>array('type'=>'integer', 'label'=>'InputReason', 'enabled'=>1, 'visible'=>-1, 'position'=>205),
'extraparams' =>array('type'=>'varchar(255)', 'label'=>'Extraparams', 'enabled'=>1, 'visible'=>-1, 'position'=>215),
'fk_incoterms' =>array('type'=>'integer', 'label'=>'IncotermCode', 'enabled'=>'$conf->incoterm->enabled', 'visible'=>-1, 'position'=>220),
@@ -524,8 +524,8 @@ class Propal extends CommonObject
* @param int $date_end End date of the line
* @param array $array_options extrafields array
* @param string $fk_unit Code of the unit to use. Null to use the default one
- * @param string $origin 'order', ...
- * @param int $origin_id Id of origin object
+ * @param string $origin Depend on global conf MAIN_CREATEFROM_KEEP_LINE_ORIGIN_INFORMATION can be 'orderdet', 'propaldet'..., else 'order','propal,'....
+ * @param int $origin_id Depend on global conf MAIN_CREATEFROM_KEEP_LINE_ORIGIN_INFORMATION can be Id of origin object (aka line id), else object id
* @param double $pu_ht_devise Unit price in currency
* @param int $fk_remise_except Id discount if line is from a discount
* @return int >0 if OK, <0 if KO
@@ -1183,6 +1183,14 @@ class Propal extends CommonObject
$vatrate = $line->tva_tx;
if ($line->vat_src_code && !preg_match('/\(.*\)/', $vatrate)) $vatrate .= ' ('.$line->vat_src_code.')';
+ if(!empty($conf->global->MAIN_CREATEFROM_KEEP_LINE_ORIGIN_INFORMATION)) {
+ $originid=$line->origin_id;
+ $origintype=$line->origin;
+ } else {
+ $originid=$line->id;
+ $origintype=$this->element;
+ }
+
$result = $this->addline(
$line->desc,
$line->subprice,
@@ -1206,8 +1214,8 @@ class Propal extends CommonObject
$line->date_end,
$line->array_options,
$line->fk_unit,
- $this->element,
- $line->id
+ $origintype,
+ $originid
);
if ($result < 0)
@@ -3334,8 +3342,8 @@ class Propal extends CommonObject
$statusType = '';
if ($status == self::STATUS_DRAFT) $statusType = 'status0';
elseif ($status == self::STATUS_VALIDATED) $statusType = 'status1';
- elseif ($status == self::STATUS_SIGNED) $statusType = 'status3';
- elseif ($status == self::STATUS_NOTSIGNED) $statusType = 'status5';
+ elseif ($status == self::STATUS_SIGNED) $statusType = 'status4';
+ elseif ($status == self::STATUS_NOTSIGNED) $statusType = 'status9';
elseif ($status == self::STATUS_BILLED) $statusType = 'status6';
return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
diff --git a/htdocs/comm/propal/class/propalestats.class.php b/htdocs/comm/propal/class/propalestats.class.php
index ee42ca26471..d5c48006430 100644
--- a/htdocs/comm/propal/class/propalestats.class.php
+++ b/htdocs/comm/propal/class/propalestats.class.php
@@ -24,10 +24,10 @@
* \brief File of class to manage proposals statistics
*/
-include_once DOL_DOCUMENT_ROOT . '/core/class/stats.class.php';
-include_once DOL_DOCUMENT_ROOT . '/comm/propal/class/propal.class.php';
-include_once DOL_DOCUMENT_ROOT . '/supplier_proposal/class/supplier_proposal.class.php';
-include_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
+include_once DOL_DOCUMENT_ROOT.'/core/class/stats.class.php';
+include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
+include_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php';
+include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
/**
@@ -66,36 +66,36 @@ class PropaleStats extends Stats
if ($mode == 'customer')
{
- $object=new Propal($this->db);
+ $object = new Propal($this->db);
$this->from = MAIN_DB_PREFIX.$object->table_element." as p";
$this->from_line = MAIN_DB_PREFIX.$object->table_element_line." as tl";
- $this->field_date='p.datep';
- $this->field='total_ht';
- $this->field_line='total_ht';
+ $this->field_date = 'p.datep';
+ $this->field = 'total_ht';
+ $this->field_line = 'total_ht';
- $this->where.= " p.fk_statut > 0";
+ $this->where .= " p.fk_statut > 0";
}
if ($mode == 'supplier')
{
- $object=new SupplierProposal($this->db);
+ $object = new SupplierProposal($this->db);
$this->from = MAIN_DB_PREFIX.$object->table_element." as p";
$this->from_line = MAIN_DB_PREFIX.$object->table_element_line." as tl";
- $this->field_date='p.date_valid';
- $this->field='total_ht';
- $this->field_line='total_ht';
+ $this->field_date = 'p.date_valid';
+ $this->field = 'total_ht';
+ $this->field_line = 'total_ht';
- $this->where.= " p.fk_statut > 0"; // Validated, accepted, refused and closed
+ $this->where .= " p.fk_statut > 0"; // Validated, accepted, refused and closed
}
//$this->where.= " AND p.fk_soc = s.rowid AND p.entity = ".$conf->entity;
- $this->where.= " AND p.entity IN (".getEntity('propal').")";
- if (!$user->rights->societe->client->voir && !$this->socid) $this->where .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
- if($this->socid)
+ $this->where .= " AND p.entity IN (".getEntity('propal').")";
+ if (!$user->rights->societe->client->voir && !$this->socid) $this->where .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id;
+ if ($this->socid)
{
- $this->where.=" AND p.fk_soc = ".$this->socid;
+ $this->where .= " AND p.fk_soc = ".$this->socid;
}
- if ($this->userid > 0) $this->where.=' AND fk_user_author = '.$this->userid;
+ if ($this->userid > 0) $this->where .= ' AND fk_user_author = '.$this->userid;
}
@@ -111,14 +111,14 @@ class PropaleStats extends Stats
global $user;
$sql = "SELECT date_format(".$this->field_date.",'%m') as dm, COUNT(*) as nb";
- $sql.= " FROM ".$this->from;
- if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
- $sql.= " WHERE ".$this->field_date." BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'";
- $sql.= " AND ".$this->where;
- $sql.= " GROUP BY dm";
- $sql.= $this->db->order('dm', 'DESC');
+ $sql .= " FROM ".$this->from;
+ if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+ $sql .= " WHERE ".$this->field_date." BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'";
+ $sql .= " AND ".$this->where;
+ $sql .= " GROUP BY dm";
+ $sql .= $this->db->order('dm', 'DESC');
- $res=$this->_getNbByMonth($year, $sql, $format);
+ $res = $this->_getNbByMonth($year, $sql, $format);
return $res;
}
@@ -133,11 +133,11 @@ class PropaleStats extends Stats
global $user;
$sql = "SELECT date_format(".$this->field_date.",'%Y') as dm, COUNT(*) as nb, SUM(c.".$this->field.")";
- $sql.= " FROM ".$this->from;
- if (!$user->rights->societe->client->voir && !$this->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
- $sql.= " WHERE ".$this->where;
- $sql.= " GROUP BY dm";
- $sql.= $this->db->order('dm', 'DESC');
+ $sql .= " FROM ".$this->from;
+ if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+ $sql .= " WHERE ".$this->where;
+ $sql .= " GROUP BY dm";
+ $sql .= $this->db->order('dm', 'DESC');
return $this->_getNbByYear($sql);
}
@@ -154,14 +154,14 @@ class PropaleStats extends Stats
global $user;
$sql = "SELECT date_format(".$this->field_date.",'%m') as dm, SUM(p.".$this->field.")";
- $sql.= " FROM ".$this->from;
- if (!$user->rights->societe->client->voir && !$this->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
- $sql.= " WHERE ".$this->field_date." BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'";
- $sql.= " AND ".$this->where;
- $sql.= " GROUP BY dm";
- $sql.= $this->db->order('dm', 'DESC');
+ $sql .= " FROM ".$this->from;
+ if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+ $sql .= " WHERE ".$this->field_date." BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'";
+ $sql .= " AND ".$this->where;
+ $sql .= " GROUP BY dm";
+ $sql .= $this->db->order('dm', 'DESC');
- $res=$this->_getAmountByMonth($year, $sql, $format);
+ $res = $this->_getAmountByMonth($year, $sql, $format);
return $res;
}
@@ -176,12 +176,12 @@ class PropaleStats extends Stats
global $user;
$sql = "SELECT date_format(".$this->field_date.",'%m') as dm, AVG(p.".$this->field.")";
- $sql.= " FROM ".$this->from;
- if (!$user->rights->societe->client->voir && !$this->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
- $sql.= " WHERE ".$this->field_date." BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'";
- $sql.= " AND ".$this->where;
- $sql.= " GROUP BY dm";
- $sql.= $this->db->order('dm', 'DESC');
+ $sql .= " FROM ".$this->from;
+ if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+ $sql .= " WHERE ".$this->field_date." BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'";
+ $sql .= " AND ".$this->where;
+ $sql .= " GROUP BY dm";
+ $sql .= $this->db->order('dm', 'DESC');
return $this->_getAverageByMonth($year, $sql);
}
@@ -196,11 +196,11 @@ class PropaleStats extends Stats
global $user;
$sql = "SELECT date_format(".$this->field_date.",'%Y') as year, COUNT(*) as nb, SUM(".$this->field.") as total, AVG(".$this->field.") as avg";
- $sql.= " FROM ".$this->from;
- if (!$user->rights->societe->client->voir && !$this->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
- $sql.= " WHERE ".$this->where;
- $sql.= " GROUP BY year";
- $sql.= $this->db->order('year', 'DESC');
+ $sql .= " FROM ".$this->from;
+ if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+ $sql .= " WHERE ".$this->where;
+ $sql .= " GROUP BY year";
+ $sql .= $this->db->order('year', 'DESC');
return $this->_getAllByYear($sql);
}
@@ -219,13 +219,13 @@ class PropaleStats extends Stats
global $user;
$sql = "SELECT product.ref, COUNT(product.ref) as nb, SUM(tl.".$this->field_line.") as total, AVG(tl.".$this->field_line.") as avg";
- $sql.= " FROM ".$this->from.", ".$this->from_line.", ".MAIN_DB_PREFIX."product as product";
- if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
- $sql.= " WHERE ".$this->where;
- $sql.= " AND p.rowid = tl.fk_propal AND tl.fk_product = product.rowid";
- $sql.= " AND ".$this->field_date." BETWEEN '".$this->db->idate(dol_get_first_day($year, 1, false))."' AND '".$this->db->idate(dol_get_last_day($year, 12, false))."'";
- $sql.= " GROUP BY product.ref";
- $sql.= $this->db->order('nb', 'DESC');
+ $sql .= " FROM ".$this->from.", ".$this->from_line.", ".MAIN_DB_PREFIX."product as product";
+ if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+ $sql .= " WHERE ".$this->where;
+ $sql .= " AND p.rowid = tl.fk_propal AND tl.fk_product = product.rowid";
+ $sql .= " AND ".$this->field_date." BETWEEN '".$this->db->idate(dol_get_first_day($year, 1, false))."' AND '".$this->db->idate(dol_get_last_day($year, 12, false))."'";
+ $sql .= " GROUP BY product.ref";
+ $sql .= $this->db->order('nb', 'DESC');
//$sql.= $this->db->plimit(20);
return $this->_getAllByProduct($sql, $limit);
diff --git a/htdocs/comm/propal/document.php b/htdocs/comm/propal/document.php
index 9279da9b029..4ce7d10c9fd 100644
--- a/htdocs/comm/propal/document.php
+++ b/htdocs/comm/propal/document.php
@@ -55,7 +55,7 @@ $result = restrictedArea($user, 'propal', $id);
// Get parameters
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
-$page = GETPOST("page", 'int');
+$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $conf->liste_limit * $page;
$pageprev = $page - 1;
diff --git a/htdocs/comm/propal/index.php b/htdocs/comm/propal/index.php
index 11a9fa8eff6..66f4aa94fd2 100644
--- a/htdocs/comm/propal/index.php
+++ b/htdocs/comm/propal/index.php
@@ -82,7 +82,7 @@ if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useles
* Statistics
*/
-$sql = "SELECT count(p.rowid), p.fk_statut";
+$sql = "SELECT count(p.rowid) as nb, p.fk_statut as status";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql .= ", ".MAIN_DB_PREFIX."propal as p";
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
@@ -101,24 +101,26 @@ if ($resql)
$total = 0;
$totalinprocess = 0;
$dataseries = array();
+ $colorseries = array();
$vals = array();
+
// -1=Canceled, 0=Draft, 1=Validated, (2=Accepted/On process not managed for customer orders), 3=Closed (Sent/Received, billed or not)
while ($i < $num)
{
- $row = $db->fetch_row($resql);
- if ($row)
+ $obj = $db->fetch_object($resql);
+ if ($obj)
{
- //if ($row[1]!=-1 && ($row[1]!=3 || $row[2]!=1))
- {
- $vals[$row[1]] = $row[0];
- $totalinprocess += $row[0];
- }
- $total += $row[0];
+ $vals[$obj->status] = $obj->nb;
+ $totalinprocess += $obj->nb;
+
+ $total += $obj->nb;
}
$i++;
}
$db->free($resql);
+ include_once DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php';
+
print '
';
print '
';
print ''.$langs->trans("Statistics").' - '.$langs->trans("Proposals").' '."\n";
@@ -126,7 +128,13 @@ if ($resql)
foreach ($listofstatus as $status)
{
$dataseries[] = array($propalstatic->LibStatut($status, 1), (isset($vals[$status]) ? (int) $vals[$status] : 0));
- if (!$conf->use_javascript_ajax)
+ if ($status == Propal::STATUS_DRAFT) $colorseries[$status] = '-'.$badgeStatus0;
+ if ($status == Propal::STATUS_VALIDATED) $colorseries[$status] = $badgeStatus1;
+ if ($status == Propal::STATUS_SIGNED) $colorseries[$status] = $badgeStatus4;
+ if ($status == Propal::STATUS_NOTSIGNED) $colorseries[$status] = $badgeStatus9;
+ if ($status == Propal::STATUS_BILLED) $colorseries[$status] = $badgeStatus6;
+
+ if (empty($conf->use_javascript_ajax))
{
print '';
print ''.$propalstatic->LibStatut($status, 0).' ';
@@ -141,6 +149,7 @@ if ($resql)
include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
$dolgraph = new DolGraph();
$dolgraph->SetData($dataseries);
+ $dolgraph->SetDataColor(array_values($colorseries));
$dolgraph->setShowLegend(2);
$dolgraph->setShowPercent(1);
$dolgraph->SetType(array('pie'));
diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php
index 365308a224b..f41bdc4fc67 100644
--- a/htdocs/comm/propal/list.php
+++ b/htdocs/comm/propal/list.php
@@ -103,7 +103,7 @@ $mesg = (GETPOST("msg") ? GETPOST("msg") : GETPOST("mesg"));
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
-$page = GETPOST("page", 'int');
+$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1 || !empty($search_btn) || !empty($search_remove_btn) || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
@@ -167,15 +167,15 @@ $arrayfields = array(
'p.total_ht'=>array('label'=>"AmountHT", 'checked'=>1),
'p.total_vat'=>array('label'=>"AmountVAT", 'checked'=>0),
'p.total_ttc'=>array('label'=>"AmountTTC", 'checked'=>0),
- 'p.total_ht_invoiced'=>array('label'=>"AmountInvoicedHT", 'checked'=>0, 'enabled'=>! empty($conf->global->PROPOSAL_SHOW_INVOICED_AMOUNT)),
- 'p.total_invoiced'=>array('label'=>"AmountInvoicedTTC", 'checked'=>0, 'enabled'=>! empty($conf->global->PROPOSAL_SHOW_INVOICED_AMOUNT)),
+ 'p.total_ht_invoiced'=>array('label'=>"AmountInvoicedHT", 'checked'=>0, 'enabled'=>!empty($conf->global->PROPOSAL_SHOW_INVOICED_AMOUNT)),
+ 'p.total_invoiced'=>array('label'=>"AmountInvoicedTTC", 'checked'=>0, 'enabled'=>!empty($conf->global->PROPOSAL_SHOW_INVOICED_AMOUNT)),
'p.multicurrency_code'=>array('label'=>'Currency', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)),
'p.multicurrency_tx'=>array('label'=>'CurrencyRate', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)),
'p.multicurrency_total_ht'=>array('label'=>'MulticurrencyAmountHT', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)),
'p.multicurrency_total_vat'=>array('label'=>'MulticurrencyAmountVAT', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)),
'p.multicurrency_total_ttc'=>array('label'=>'MulticurrencyAmountTTC', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)),
- 'p.multicurrency_total_ht_invoiced'=>array('label'=>'MulticurrencyAmountInvoicedHT', 'checked'=>0, 'enabled'=>! empty($conf->multicurrency->enabled) && ! empty($conf->global->PROPOSAL_SHOW_INVOICED_AMOUNT)),
- 'p.multicurrency_total_invoiced'=>array('label'=>'MulticurrencyAmountInvoicedTTC', 'checked'=>0, 'enabled'=>! empty($conf->multicurrency->enabled) && ! empty($conf->global->PROPOSAL_SHOW_INVOICED_AMOUNT)),
+ 'p.multicurrency_total_ht_invoiced'=>array('label'=>'MulticurrencyAmountInvoicedHT', 'checked'=>0, 'enabled'=>!empty($conf->multicurrency->enabled) && !empty($conf->global->PROPOSAL_SHOW_INVOICED_AMOUNT)),
+ 'p.multicurrency_total_invoiced'=>array('label'=>'MulticurrencyAmountInvoicedTTC', 'checked'=>0, 'enabled'=>!empty($conf->multicurrency->enabled) && !empty($conf->global->PROPOSAL_SHOW_INVOICED_AMOUNT)),
'u.login'=>array('label'=>"Author", 'checked'=>1, 'position'=>10),
'sale_representative'=>array('label'=>"SaleRepresentativesOfThirdParty", 'checked'=>1),
'p.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500),
@@ -344,7 +344,7 @@ if ($search_login) $sql .= natural_search("u.login", $search_login);
if ($search_montant_ht != '') $sql .= natural_search("p.total_ht", $search_montant_ht, 1);
if ($search_montant_vat != '') $sql .= natural_search("p.tva", $search_montant_vat, 1);
if ($search_montant_ttc != '') $sql .= natural_search("p.total", $search_montant_ttc, 1);
-if ($search_multicurrency_code != '') $sql .= ' AND p.multicurrency_code = "' . $db->escape($search_multicurrency_code) . '"';
+if ($search_multicurrency_code != '') $sql .= ' AND p.multicurrency_code = "'.$db->escape($search_multicurrency_code).'"';
if ($search_multicurrency_tx != '') $sql .= natural_search('p.multicurrency_tx', $search_multicurrency_tx, 1);
if ($search_multicurrency_montant_ht != '') $sql .= natural_search('p.multicurrency_total_ht', $search_multicurrency_montant_ht, 1);
if ($search_multicurrency_montant_vat != '') $sql .= natural_search('p.multicurrency_total_tva', $search_multicurrency_montant_vat, 1);
@@ -1099,7 +1099,7 @@ if ($resql)
// Currency
if (!empty($arrayfields['p.multicurrency_code']['checked']))
{
- print ''.$obj->multicurrency_code . ' - ' . $langs->trans('Currency' . $obj->multicurrency_code)." \n";
+ print ''.$obj->multicurrency_code.' - '.$langs->trans('Currency'.$obj->multicurrency_code)." \n";
if (!$i) $totalarray['nbfield']++;
}
@@ -1107,7 +1107,7 @@ if ($resql)
if (!empty($arrayfields['p.multicurrency_tx']['checked']))
{
print '';
- $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $obj->rowid, $obj->multicurrency_tx, 'none', $obj->multicurrency_code);
+ $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$obj->rowid, $obj->multicurrency_tx, 'none', $obj->multicurrency_code);
print " \n";
if (!$i) $totalarray['nbfield']++;
}
diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php
index 03cdf990071..eb3c165d447 100644
--- a/htdocs/commande/class/api_orders.class.php
+++ b/htdocs/commande/class/api_orders.class.php
@@ -118,16 +118,16 @@ class Orders extends DolibarrApi
*/
private function _fetch($id, $ref = '', $ref_ext = '', $contact_list = 1)
{
- if(! DolibarrApiAccess::$user->rights->commande->lire) {
+ if (!DolibarrApiAccess::$user->rights->commande->lire) {
throw new RestException(401);
}
$result = $this->commande->fetch($id, $ref, $ref_ext);
- if( ! $result ) {
+ if (!$result) {
throw new RestException(404, 'Order not found');
}
- if( ! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) {
+ if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
@@ -163,18 +163,18 @@ class Orders extends DolibarrApi
// If the internal user must only see his customers, force searching by him
$search_sale = 0;
- if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) $search_sale = DolibarrApiAccess::$user->id;
+ if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) $search_sale = DolibarrApiAccess::$user->id;
$sql = "SELECT t.rowid";
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects)
- $sql.= " FROM ".MAIN_DB_PREFIX."commande as t";
+ $sql .= " FROM ".MAIN_DB_PREFIX."commande as t";
- if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale
+ if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale
- $sql.= ' WHERE t.entity IN ('.getEntity('commande').')';
- if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc";
- if ($socids) $sql.= " AND t.fk_soc IN (".$socids.")";
- if ($search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
+ $sql .= ' WHERE t.entity IN ('.getEntity('commande').')';
+ if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= " AND t.fk_soc = sc.fk_soc";
+ if ($socids) $sql .= " AND t.fk_soc IN (".$socids.")";
+ if ($search_sale > 0) $sql .= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
// Insert sale filter
if ($search_sale > 0)
{
@@ -183,23 +183,23 @@ class Orders extends DolibarrApi
// Add sql filters
if ($sqlfilters)
{
- if (! DolibarrApi::_checkFilters($sqlfilters))
+ if (!DolibarrApi::_checkFilters($sqlfilters))
{
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
}
- $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
- $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
+ $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
+ $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
}
- $sql.= $db->order($sortfield, $sortorder);
- if ($limit) {
+ $sql .= $db->order($sortfield, $sortorder);
+ if ($limit) {
if ($page < 0)
{
$page = 0;
}
$offset = $limit * $page;
- $sql.= $db->plimit($limit + 1, $offset);
+ $sql .= $db->plimit($limit + 1, $offset);
}
dol_syslog("API Rest request");
@@ -209,12 +209,12 @@ class Orders extends DolibarrApi
{
$num = $db->num_rows($result);
$min = min($num, ($limit <= 0 ? $num : $limit));
- $i=0;
+ $i = 0;
while ($i < $min)
{
$obj = $db->fetch_object($result);
$commande_static = new Commande($db);
- if($commande_static->fetch($obj->rowid)) {
+ if ($commande_static->fetch($obj->rowid)) {
// Add external contacts ids
$commande_static->contacts_ids = $commande_static->liste_contact(-1, 'external', 1);
$obj_ret[] = $this->_cleanObjectDatas($commande_static);
@@ -225,7 +225,7 @@ class Orders extends DolibarrApi
else {
throw new RestException(503, 'Error when retrieve commande list : '.$db->lasterror());
}
- if( ! count($obj_ret)) {
+ if (!count($obj_ret)) {
throw new RestException(404, 'No order found');
}
return $obj_ret;
@@ -239,13 +239,13 @@ class Orders extends DolibarrApi
*/
public function post($request_data = null)
{
- if(! DolibarrApiAccess::$user->rights->commande->creer) {
+ if (!DolibarrApiAccess::$user->rights->commande->creer) {
throw new RestException(401, "Insuffisant rights");
}
// Check mandatory fields
$result = $this->_validate($request_data);
- foreach($request_data as $field => $value) {
+ foreach ($request_data as $field => $value) {
$this->commande->$field = $value;
}
/*if (isset($request_data["lines"])) {
@@ -274,16 +274,16 @@ class Orders extends DolibarrApi
*/
public function getLines($id)
{
- if(! DolibarrApiAccess::$user->rights->commande->lire) {
+ if (!DolibarrApiAccess::$user->rights->commande->lire) {
throw new RestException(401);
}
$result = $this->commande->fetch($id);
- if( ! $result ) {
+ if (!$result) {
throw new RestException(404, 'Order not found');
}
- if( ! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) {
+ if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$this->commande->getLinesArray();
@@ -306,16 +306,16 @@ class Orders extends DolibarrApi
*/
public function postLine($id, $request_data = null)
{
- if(! DolibarrApiAccess::$user->rights->commande->creer) {
+ if (!DolibarrApiAccess::$user->rights->commande->creer) {
throw new RestException(401);
}
$result = $this->commande->fetch($id);
- if( ! $result ) {
+ if (!$result) {
throw new RestException(404, 'Order not found');
}
- if( ! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) {
+ if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$request_data = (object) $request_data;
@@ -368,16 +368,16 @@ class Orders extends DolibarrApi
*/
public function putLine($id, $lineid, $request_data = null)
{
- if(! DolibarrApiAccess::$user->rights->commande->creer) {
+ if (!DolibarrApiAccess::$user->rights->commande->creer) {
throw new RestException(401);
}
$result = $this->commande->fetch($id);
- if( ! $result ) {
+ if (!$result) {
throw new RestException(404, 'Order not found');
}
- if( ! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) {
+ if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$request_data = (object) $request_data;
@@ -430,16 +430,16 @@ class Orders extends DolibarrApi
*/
public function deleteLine($id, $lineid)
{
- if(! DolibarrApiAccess::$user->rights->commande->creer) {
+ if (!DolibarrApiAccess::$user->rights->commande->creer) {
throw new RestException(401);
}
$result = $this->commande->fetch($id);
- if( ! $result ) {
+ if (!$result) {
throw new RestException(404, 'Order not found');
}
- if( ! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) {
+ if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
@@ -469,16 +469,16 @@ class Orders extends DolibarrApi
*/
public function postContact($id, $contactid, $type)
{
- if (! DolibarrApiAccess::$user->rights->commande->creer) {
+ if (!DolibarrApiAccess::$user->rights->commande->creer) {
throw new RestException(401);
}
$result = $this->commande->fetch($id);
- if (! $result) {
+ if (!$result) {
throw new RestException(404, 'Order not found');
}
- if (! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) {
+ if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
@@ -507,16 +507,16 @@ class Orders extends DolibarrApi
*/
public function deleteContact($id, $rowid)
{
- if (! DolibarrApiAccess::$user->rights->commande->creer) {
+ if (!DolibarrApiAccess::$user->rights->commande->creer) {
throw new RestException(401);
}
$result = $this->commande->fetch($id);
- if (! $result) {
+ if (!$result) {
throw new RestException(404, 'Order not found');
}
- if (! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) {
+ if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
@@ -539,19 +539,19 @@ class Orders extends DolibarrApi
*/
public function put($id, $request_data = null)
{
- if (! DolibarrApiAccess::$user->rights->commande->creer) {
+ if (!DolibarrApiAccess::$user->rights->commande->creer) {
throw new RestException(401);
}
$result = $this->commande->fetch($id);
- if (! $result) {
+ if (!$result) {
throw new RestException(404, 'Order not found');
}
- if (! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) {
+ if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
- foreach($request_data as $field => $value) {
+ foreach ($request_data as $field => $value) {
if ($field == 'id') continue;
$this->commande->$field = $value;
}
@@ -580,19 +580,19 @@ class Orders extends DolibarrApi
*/
public function delete($id)
{
- if(! DolibarrApiAccess::$user->rights->commande->supprimer) {
+ if (!DolibarrApiAccess::$user->rights->commande->supprimer) {
throw new RestException(401);
}
$result = $this->commande->fetch($id);
- if( ! $result ) {
+ if (!$result) {
throw new RestException(404, 'Order not found');
}
- if( ! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) {
+ if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
- if( ! $this->commande->delete(DolibarrApiAccess::$user)) {
+ if (!$this->commande->delete(DolibarrApiAccess::$user)) {
throw new RestException(500, 'Error when deleting order : '.$this->commande->error);
}
@@ -628,15 +628,15 @@ class Orders extends DolibarrApi
*/
public function validate($id, $idwarehouse = 0, $notrigger = 0)
{
- if(! DolibarrApiAccess::$user->rights->commande->creer) {
+ if (!DolibarrApiAccess::$user->rights->commande->creer) {
throw new RestException(401);
}
$result = $this->commande->fetch($id);
- if( ! $result ) {
+ if (!$result) {
throw new RestException(404, 'Order not found');
}
- if( ! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) {
+ if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
@@ -648,11 +648,11 @@ class Orders extends DolibarrApi
throw new RestException(500, 'Error when validating Order: '.$this->commande->error);
}
$result = $this->commande->fetch($id);
- if( ! $result ) {
+ if (!$result) {
throw new RestException(404, 'Order not found');
}
- if( ! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) {
+ if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
@@ -681,21 +681,21 @@ class Orders extends DolibarrApi
public function reopen($id)
{
- if(! DolibarrApiAccess::$user->rights->commande->creer) {
+ if (!DolibarrApiAccess::$user->rights->commande->creer) {
throw new RestException(401);
}
- if(empty($id)) {
+ if (empty($id)) {
throw new RestException(400, 'Order ID is mandatory');
}
$result = $this->commande->fetch($id);
- if( ! $result ) {
+ if (!$result) {
throw new RestException(404, 'Order not found');
}
$result = $this->commande->set_reopen(DolibarrApiAccess::$user);
- if( $result < 0) {
+ if ($result < 0) {
throw new RestException(405, $this->commande->error);
- }elseif( $result == 0) {
+ }elseif ($result == 0) {
throw new RestException(304);
}
@@ -719,28 +719,28 @@ class Orders extends DolibarrApi
public function setinvoiced($id)
{
- if(! DolibarrApiAccess::$user->rights->commande->creer) {
+ if (!DolibarrApiAccess::$user->rights->commande->creer) {
throw new RestException(401);
}
- if(empty($id)) {
+ if (empty($id)) {
throw new RestException(400, 'Order ID is mandatory');
}
$result = $this->commande->fetch($id);
- if( ! $result ) {
+ if (!$result) {
throw new RestException(404, 'Order not found');
}
$result = $this->commande->classifyBilled(DolibarrApiAccess::$user);
- if( $result < 0) {
+ if ($result < 0) {
throw new RestException(400, $this->commande->error);
}
$result = $this->commande->fetch($id);
- if( ! $result ) {
+ if (!$result) {
throw new RestException(404, 'Order not found');
}
- if( ! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) {
+ if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
@@ -761,15 +761,15 @@ class Orders extends DolibarrApi
*/
public function close($id, $notrigger = 0)
{
- if(! DolibarrApiAccess::$user->rights->commande->creer) {
+ if (!DolibarrApiAccess::$user->rights->commande->creer) {
throw new RestException(401);
}
$result = $this->commande->fetch($id);
- if( ! $result ) {
+ if (!$result) {
throw new RestException(404, 'Order not found');
}
- if( ! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) {
+ if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
@@ -782,11 +782,11 @@ class Orders extends DolibarrApi
}
$result = $this->commande->fetch($id);
- if( ! $result ) {
+ if (!$result) {
throw new RestException(404, 'Order not found');
}
- if( ! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) {
+ if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
@@ -807,15 +807,15 @@ class Orders extends DolibarrApi
*/
public function settodraft($id, $idwarehouse = -1)
{
- if(! DolibarrApiAccess::$user->rights->commande->creer) {
+ if (!DolibarrApiAccess::$user->rights->commande->creer) {
throw new RestException(401);
}
$result = $this->commande->fetch($id);
- if( ! $result ) {
+ if (!$result) {
throw new RestException(404, 'Order not found');
}
- if( ! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) {
+ if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
@@ -828,11 +828,11 @@ class Orders extends DolibarrApi
}
$result = $this->commande->fetch($id);
- if( ! $result ) {
+ if (!$result) {
throw new RestException(404, 'Order not found');
}
- if( ! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) {
+ if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
@@ -859,26 +859,26 @@ class Orders extends DolibarrApi
public function createOrderFromProposal($proposalid)
{
- require_once DOL_DOCUMENT_ROOT . '/comm/propal/class/propal.class.php';
+ require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
- if(! DolibarrApiAccess::$user->rights->propal->lire) {
+ if (!DolibarrApiAccess::$user->rights->propal->lire) {
throw new RestException(401);
}
- if(! DolibarrApiAccess::$user->rights->commande->creer) {
+ if (!DolibarrApiAccess::$user->rights->commande->creer) {
throw new RestException(401);
}
- if(empty($proposalid)) {
+ if (empty($proposalid)) {
throw new RestException(400, 'Proposal ID is mandatory');
}
$propal = new Propal($this->db);
$result = $propal->fetch($proposalid);
- if( ! $result ) {
+ if (!$result) {
throw new RestException(404, 'Proposal not found');
}
$result = $this->commande->createFromProposal($propal, DolibarrApiAccess::$user);
- if( $result < 0) {
+ if ($result < 0) {
throw new RestException(405, $this->commande->error);
}
$this->commande->fetchObjectLinked();
@@ -921,7 +921,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];
}
return $commande;
diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php
index ddd6d7723d5..57eb78df405 100644
--- a/htdocs/commande/class/commande.class.php
+++ b/htdocs/commande/class/commande.class.php
@@ -262,12 +262,12 @@ class Commande extends CommonOrder
/**
* @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor.
*/
- public $fields=array(
+ public $fields = array(
'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>10),
'entity' =>array('type'=>'integer', 'label'=>'Entity', 'default'=>1, 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>20, 'index'=>1),
'ref' =>array('type'=>'varchar(30)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'showoncombobox'=>1, 'position'=>25),
'ref_ext' =>array('type'=>'varchar(255)', 'label'=>'RefExt', 'enabled'=>1, 'visible'=>0, 'position'=>26),
- 'ref_int' =>array('type'=>'varchar(255)', 'label'=>'RefInt', 'enabled'=>1, 'visible'=>0, 'position'=>27), // deprecated
+ 'ref_int' =>array('type'=>'varchar(255)', 'label'=>'RefInt', 'enabled'=>1, 'visible'=>0, 'position'=>27), // deprecated
'ref_client' =>array('type'=>'varchar(255)', 'label'=>'RefCustomer', 'enabled'=>1, 'visible'=>-1, 'position'=>28),
'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>20),
'fk_projet' =>array('type'=>'integer:Project:projet/class/project.class.php:1:fk_statut=1', 'label'=>'Project', 'enabled'=>1, 'visible'=>-1, 'position'=>25),
@@ -1016,6 +1016,14 @@ class Commande extends CommonOrder
$vatrate = $line->tva_tx;
if ($line->vat_src_code && !preg_match('/\(.*\)/', $vatrate)) $vatrate .= ' ('.$line->vat_src_code.')';
+ if(!empty($conf->global->MAIN_CREATEFROM_KEEP_LINE_ORIGIN_INFORMATION)) {
+ $originid=$line->origin_id;
+ $origintype=$line->origin;
+ } else {
+ $originid=$line->id;
+ $origintype=$this->element;
+ }
+
$result = $this->addline(
$line->desc,
$line->subprice,
@@ -1040,8 +1048,8 @@ class Commande extends CommonOrder
$line->label,
$line->array_options,
$line->fk_unit,
- $this->element,
- $line->id
+ $origintype,
+ $originid
);
if ($result < 0)
{
@@ -1444,8 +1452,8 @@ class Commande extends CommonOrder
* @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 $origin Depend on global conf MAIN_CREATEFROM_KEEP_LINE_ORIGIN_INFORMATION can be 'orderdet', 'propaldet'..., else 'order','propal,'....
+ * @param int $origin_id Depend on global conf MAIN_CREATEFROM_KEEP_LINE_ORIGIN_INFORMATION can be Id of origin object (aka line id), else object id
* @param double $pu_ht_devise Unit price in currency
* @return int >0 if OK, <0 if KO
*
diff --git a/htdocs/commande/class/commandestats.class.php b/htdocs/commande/class/commandestats.class.php
index 522bd7b2e31..8b6dc4db6ec 100644
--- a/htdocs/commande/class/commandestats.class.php
+++ b/htdocs/commande/class/commandestats.class.php
@@ -23,10 +23,10 @@
* \ingroup commandes
* \brief File of class to manage order statistics
*/
-include_once DOL_DOCUMENT_ROOT . '/core/class/stats.class.php';
-include_once DOL_DOCUMENT_ROOT . '/commande/class/commande.class.php';
-include_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.commande.class.php';
-include_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
+include_once DOL_DOCUMENT_ROOT.'/core/class/stats.class.php';
+include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
+include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
+include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
/**
@@ -67,31 +67,31 @@ class CommandeStats extends Stats
if ($mode == 'customer')
{
- $object=new Commande($this->db);
+ $object = new Commande($this->db);
$this->from = MAIN_DB_PREFIX.$object->table_element." as c";
$this->from_line = MAIN_DB_PREFIX.$object->table_element_line." as tl";
- $this->field='total_ht';
- $this->field_line='total_ht';
- $this->where.= " c.fk_statut > 0"; // Not draft and not cancelled
+ $this->field = 'total_ht';
+ $this->field_line = 'total_ht';
+ $this->where .= " c.fk_statut > 0"; // Not draft and not cancelled
}
elseif ($mode == 'supplier')
{
- $object=new CommandeFournisseur($this->db);
+ $object = new CommandeFournisseur($this->db);
$this->from = MAIN_DB_PREFIX.$object->table_element." as c";
$this->from_line = MAIN_DB_PREFIX.$object->table_element_line." as tl";
- $this->field='total_ht';
- $this->field_line='total_ht';
- $this->where.= " c.fk_statut > 2"; // Only approved & ordered
+ $this->field = 'total_ht';
+ $this->field_line = 'total_ht';
+ $this->where .= " c.fk_statut > 2"; // Only approved & ordered
}
//$this->where.= " AND c.fk_soc = s.rowid AND c.entity = ".$conf->entity;
- $this->where.= ' AND c.entity IN ('.getEntity('commande').')';
+ $this->where .= ' AND c.entity IN ('.getEntity('commande').')';
- if (!$user->rights->societe->client->voir && !$this->socid) $this->where .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
+ if (!$user->rights->societe->client->voir && !$this->socid) $this->where .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id;
if ($this->socid)
{
- $this->where.=" AND c.fk_soc = ".$this->socid;
+ $this->where .= " AND c.fk_soc = ".$this->socid;
}
- if ($this->userid > 0) $this->where.=' AND c.fk_user_author = '.$this->userid;
+ if ($this->userid > 0) $this->where .= ' AND c.fk_user_author = '.$this->userid;
}
/**
@@ -106,14 +106,14 @@ class CommandeStats extends Stats
global $user;
$sql = "SELECT date_format(c.date_commande,'%m') as dm, COUNT(*) as nb";
- $sql.= " FROM ".$this->from;
+ $sql .= " FROM ".$this->from;
if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
- $sql.= " WHERE c.date_commande BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'";
- $sql.= " AND ".$this->where;
- $sql.= " GROUP BY dm";
- $sql.= $this->db->order('dm', 'DESC');
+ $sql .= " WHERE c.date_commande BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'";
+ $sql .= " AND ".$this->where;
+ $sql .= " GROUP BY dm";
+ $sql .= $this->db->order('dm', 'DESC');
- $res=$this->_getNbByMonth($year, $sql, $format);
+ $res = $this->_getNbByMonth($year, $sql, $format);
return $res;
}
@@ -128,11 +128,11 @@ class CommandeStats extends Stats
global $user;
$sql = "SELECT date_format(c.date_commande,'%Y') as dm, COUNT(*) as nb, SUM(c.".$this->field.")";
- $sql.= " FROM ".$this->from;
+ $sql .= " FROM ".$this->from;
if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
- $sql.= " WHERE ".$this->where;
- $sql.= " GROUP BY dm";
- $sql.= $this->db->order('dm', 'DESC');
+ $sql .= " WHERE ".$this->where;
+ $sql .= " GROUP BY dm";
+ $sql .= $this->db->order('dm', 'DESC');
return $this->_getNbByYear($sql);
}
@@ -149,14 +149,14 @@ class CommandeStats extends Stats
global $user;
$sql = "SELECT date_format(c.date_commande,'%m') as dm, SUM(c.".$this->field.")";
- $sql.= " FROM ".$this->from;
+ $sql .= " FROM ".$this->from;
if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
- $sql.= " WHERE c.date_commande BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'";
- $sql.= " AND ".$this->where;
- $sql.= " GROUP BY dm";
- $sql.= $this->db->order('dm', 'DESC');
+ $sql .= " WHERE c.date_commande BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'";
+ $sql .= " AND ".$this->where;
+ $sql .= " GROUP BY dm";
+ $sql .= $this->db->order('dm', 'DESC');
- $res=$this->_getAmountByMonth($year, $sql, $format);
+ $res = $this->_getAmountByMonth($year, $sql, $format);
return $res;
}
@@ -171,12 +171,12 @@ class CommandeStats extends Stats
global $user;
$sql = "SELECT date_format(c.date_commande,'%m') as dm, AVG(c.".$this->field.")";
- $sql.= " FROM ".$this->from;
+ $sql .= " FROM ".$this->from;
if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
- $sql.= " WHERE c.date_commande BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'";
- $sql.= " AND ".$this->where;
- $sql.= " GROUP BY dm";
- $sql.= $this->db->order('dm', 'DESC');
+ $sql .= " WHERE c.date_commande BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'";
+ $sql .= " AND ".$this->where;
+ $sql .= " GROUP BY dm";
+ $sql .= $this->db->order('dm', 'DESC');
return $this->_getAverageByMonth($year, $sql);
}
@@ -191,11 +191,11 @@ class CommandeStats extends Stats
global $user;
$sql = "SELECT date_format(c.date_commande,'%Y') as year, COUNT(*) as nb, SUM(c.".$this->field.") as total, AVG(".$this->field.") as avg";
- $sql.= " FROM ".$this->from;
+ $sql .= " FROM ".$this->from;
if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
- $sql.= " WHERE ".$this->where;
- $sql.= " GROUP BY year";
- $sql.= $this->db->order('year', 'DESC');
+ $sql .= " WHERE ".$this->where;
+ $sql .= " GROUP BY year";
+ $sql .= $this->db->order('year', 'DESC');
return $this->_getAllByYear($sql);
}
@@ -212,13 +212,13 @@ class CommandeStats extends Stats
global $user;
$sql = "SELECT product.ref, COUNT(product.ref) as nb, SUM(tl.".$this->field_line.") as total, AVG(tl.".$this->field_line.") as avg";
- $sql.= " FROM ".$this->from.", ".$this->from_line.", ".MAIN_DB_PREFIX."product as product";
- if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
- $sql.= " WHERE ".$this->where;
- $sql.= " AND c.rowid = tl.fk_commande AND tl.fk_product = product.rowid";
- $sql.= " AND c.date_commande BETWEEN '".$this->db->idate(dol_get_first_day($year, 1, false))."' AND '".$this->db->idate(dol_get_last_day($year, 12, false))."'";
- $sql.= " GROUP BY product.ref";
- $sql.= $this->db->order('nb', 'DESC');
+ $sql .= " FROM ".$this->from.", ".$this->from_line.", ".MAIN_DB_PREFIX."product as product";
+ if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+ $sql .= " WHERE ".$this->where;
+ $sql .= " AND c.rowid = tl.fk_commande AND tl.fk_product = product.rowid";
+ $sql .= " AND c.date_commande BETWEEN '".$this->db->idate(dol_get_first_day($year, 1, false))."' AND '".$this->db->idate(dol_get_last_day($year, 12, false))."'";
+ $sql .= " GROUP BY product.ref";
+ $sql .= $this->db->order('nb', 'DESC');
//$sql.= $this->db->plimit(20);
return $this->_getAllByProduct($sql, $limit);
diff --git a/htdocs/commande/customer.php b/htdocs/commande/customer.php
index f6594b5694a..a3b754e0979 100644
--- a/htdocs/commande/customer.php
+++ b/htdocs/commande/customer.php
@@ -48,7 +48,7 @@ $langs->loadLangs(array("companies", "orders"));
$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
-$page = GETPOST("page", 'int');
+$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
diff --git a/htdocs/commande/document.php b/htdocs/commande/document.php
index 6f71cf5c153..82d71dbe9d0 100644
--- a/htdocs/commande/document.php
+++ b/htdocs/commande/document.php
@@ -54,7 +54,7 @@ $result = restrictedArea($user, 'commande', $id, '');
// Get parameters
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
-$page = GETPOST("page", 'int');
+$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $conf->liste_limit * $page;
$pageprev = $page - 1;
diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php
index 5e2353110e7..8448da5b022 100644
--- a/htdocs/commande/list.php
+++ b/htdocs/commande/list.php
@@ -102,7 +102,7 @@ $diroutputmassaction = $conf->commande->multidir_output[$conf->entity].'/temp/ma
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
-$page = GETPOST("page", 'int');
+$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1 || !empty($search_btn) || !empty($search_remove_btn) || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
@@ -346,7 +346,7 @@ if ($search_user > 0) $sql .= " AND ec.fk_c_type_contact
if ($search_total_ht != '') $sql .= natural_search('c.total_ht', $search_total_ht, 1);
if ($search_total_vat != '') $sql .= natural_search('c.tva', $search_total_vat, 1);
if ($search_total_ttc != '') $sql .= natural_search('c.total_ttc', $search_total_ttc, 1);
-if ($search_multicurrency_code != '') $sql .= ' AND c.multicurrency_code = "' . $db->escape($search_multicurrency_code) . '"';
+if ($search_multicurrency_code != '') $sql .= ' AND c.multicurrency_code = "'.$db->escape($search_multicurrency_code).'"';
if ($search_multicurrency_tx != '') $sql .= natural_search('c.multicurrency_tx', $search_multicurrency_tx, 1);
if ($search_multicurrency_montant_ht != '') $sql .= natural_search('c.multicurrency_total_ht', $search_multicurrency_montant_ht, 1);
if ($search_multicurrency_montant_vat != '') $sql .= natural_search('c.multicurrency_total_tva', $search_multicurrency_montant_vat, 1);
@@ -1168,7 +1168,7 @@ if ($resql)
// Currency
if (!empty($arrayfields['c.multicurrency_code']['checked']))
{
- print ''.$obj->multicurrency_code . ' - ' . $langs->trans('Currency' . $obj->multicurrency_code)." \n";
+ print ''.$obj->multicurrency_code.' - '.$langs->trans('Currency'.$obj->multicurrency_code)." \n";
if (!$i) $totalarray['nbfield']++;
}
@@ -1176,7 +1176,7 @@ if ($resql)
if (!empty($arrayfields['c.multicurrency_tx']['checked']))
{
print '';
- $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $obj->rowid, $obj->multicurrency_tx, 'none', $obj->multicurrency_code);
+ $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$obj->rowid, $obj->multicurrency_tx, 'none', $obj->multicurrency_code);
print " \n";
if (!$i) $totalarray['nbfield']++;
}
diff --git a/htdocs/compta/accounting-files.php b/htdocs/compta/accounting-files.php
index 7a8832be2b5..ff9f573bcc9 100644
--- a/htdocs/compta/accounting-files.php
+++ b/htdocs/compta/accounting-files.php
@@ -54,7 +54,7 @@ $hookmanager->initHooks(array('comptafileslist', 'globallist'));
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
-$page = GETPOST('page', 'int');
+$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
@@ -133,7 +133,7 @@ if (($action == "searchfiles" || $action == "dl")) {
// Customer invoices
if (GETPOST('selectinvoices')) {
- if (! empty($sql)) $sql .= " UNION ALL";
+ if (!empty($sql)) $sql .= " UNION ALL";
$sql .= "SELECT t.rowid as id, t.entity, t.ref, t.paye as paid, t.total as total_ht, t.total_ttc, t.tva as total_vat, t.fk_soc, t.datef as date, t.date_lim_reglement as date_due, 'Invoice' as item, s.nom as thirdparty_name, s.code_client as thirdparty_code, c.code as country_code, s.tva_intra as vatnum";
$sql .= " FROM ".MAIN_DB_PREFIX."facture as t LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = t.fk_soc LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = s.fk_pays";
$sql .= " WHERE datef between ".$wheretail;
@@ -142,7 +142,7 @@ if (($action == "searchfiles" || $action == "dl")) {
}
// Vendor invoices
if (GETPOST('selectsupplierinvoices')) {
- if (! empty($sql)) $sql .= " UNION ALL";
+ if (!empty($sql)) $sql .= " UNION ALL";
$sql .= " SELECT t.rowid as id, t.entity, t.ref, t.paye as paid, t.total_ht, t.total_ttc, t.total_tva as total_vat, t.fk_soc, t.datef as date, t.date_lim_reglement as date_due, 'SupplierInvoice' as item, s.nom as thirdparty_name, s.code_fournisseur as thirdparty_code, c.code as country_code, s.tva_intra as vatnum";
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as t LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = t.fk_soc LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = s.fk_pays";
$sql .= " WHERE datef between ".$wheretail;
@@ -151,7 +151,7 @@ if (($action == "searchfiles" || $action == "dl")) {
}
// Expense reports
if (GETPOST('selectexpensereports')) {
- if (! empty($sql)) $sql .= " UNION ALL";
+ if (!empty($sql)) $sql .= " UNION ALL";
$sql .= " SELECT t.rowid as id, t.entity, t.ref, t.paid, t.total_ht, t.total_ttc, t.total_tva as total_vat, t.fk_user_author as fk_soc, t.date_fin as date, t.date_fin as date_due, 'ExpenseReport' as item, CONCAT(CONCAT(u.lastname, ' '), u.firstname) as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum";
$sql .= " FROM ".MAIN_DB_PREFIX."expensereport as t LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = t.fk_user_author LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = u.fk_country";
$sql .= " WHERE date_fin between ".$wheretail;
@@ -160,7 +160,7 @@ if (($action == "searchfiles" || $action == "dl")) {
}
// Donations
if (GETPOST('selectdonations')) {
- if (! empty($sql)) $sql .= " UNION ALL";
+ if (!empty($sql)) $sql .= " UNION ALL";
$sql .= " SELECT t.rowid as id, t.entity, t.ref, paid, amount as total_ht, amount as total_ttc, 0 as total_vat, 0 as fk_soc, t.datedon as date, t.datedon as date_due, 'Donation' as item, t.societe as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum";
$sql .= " FROM ".MAIN_DB_PREFIX."don as t LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = t.fk_country";
$sql .= " WHERE datedon between ".$wheretail;
@@ -169,7 +169,7 @@ if (($action == "searchfiles" || $action == "dl")) {
}
// Paiements of salaries
if (GETPOST('selectpaymentsofsalaries')) {
- if (! empty($sql)) $sql .= " UNION ALL";
+ if (!empty($sql)) $sql .= " UNION ALL";
$sql .= " SELECT t.rowid as id, t.entity, t.ref as ref, 1 as paid, amount as total_ht, amount as total_ttc, 0 as total_vat, t.fk_user as fk_soc, t.datep as date, t.dateep as date_due, 'SalaryPayment' as item, CONCAT(CONCAT(u.lastname, ' '), u.firstname) as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum";
$sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as t LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = t.fk_user LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = u.fk_country";
$sql .= " WHERE datep between ".$wheretail;
@@ -178,7 +178,7 @@ if (($action == "searchfiles" || $action == "dl")) {
}
// Social contributions
if (GETPOST('selectsocialcontributions')) {
- if (! empty($sql)) $sql .= " UNION ALL";
+ if (!empty($sql)) $sql .= " UNION ALL";
$sql .= " SELECT t.rowid as id, t.entity, t.libelle as ref, t.paye as paid, t.amount as total_ht, t.amount as total_ttc, 0 as total_tva, 0 as fk_soc, t.date_creation as date, t.date_ech as date_due, 'SocialContributions' as item, '' as thirdparty_name, '' as thirdparty_code, '' as country_code, '' as vatnum";
$sql .= " FROM ".MAIN_DB_PREFIX."chargesociales as t";
$sql .= " WHERE date_creation between ".$wheretail;
@@ -467,7 +467,7 @@ print ' - '.$form->selectDate($date_stop, 'date_stop', 0, 0, 0, "", 1, 1, 0)."\n
if (!empty($conf->multicompany->enabled) && is_object($mc))
{
$mc->getInfo($conf->entity);
- print '('.$langs->trans("Entity").' : ';
+ print '('.$langs->trans("Entity").' : ';
print " ";
if (!empty($conf->global->MULTICOMPANY_ALLOW_EXPORT_ACCOUNTING_DOC_FOR_ALL_ENTITIES)) {
print $mc->select_entities(GETPOSTISSET('search_entity') ? GETPOST('search_entity', 'int') : $mc->id, 'search_entity', '', false, false, false, false, true);
@@ -488,8 +488,8 @@ $listofchoices = array(
'selectpaymentsofsalaries'=>array('label'=>'SalariesPayments', 'lang'=>'salaries'),
'selectsocialcontributions'=>array('label'=>'SocialContributions')
);
-foreach($listofchoices as $choice => $val) {
- $checked = (((! GETPOSTISSET('search') && $action != 'searchfiles') || GETPOST($choice))?' checked="checked"':'');
+foreach ($listofchoices as $choice => $val) {
+ $checked = (((!GETPOSTISSET('search') && $action != 'searchfiles') || GETPOST($choice)) ? ' checked="checked"' : '');
print ' '.$langs->trans($val['label']).'
';
}
@@ -508,8 +508,8 @@ if (!empty($date_start) && !empty($date_stop))
$param .= '&date_stopday='.GETPOST('date_stopday', 'int');
$param .= '&date_stopmonth='.GETPOST('date_stopmonth', 'int');
$param .= '&date_stopyear='.GETPOST('date_stopyear', 'int');
- foreach($listofchoices as $choice => $val) {
- $param.='&'.$choice.'='.(GETPOST($choice, 'int')?1:0);
+ foreach ($listofchoices as $choice => $val) {
+ $param .= '&'.$choice.'='.(GETPOST($choice, 'int') ? 1 : 0);
}
print '