diff --git a/ChangeLog b/ChangeLog index fd431b407d1..a7bbaf440ae 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,7 @@ English Dolibarr ChangeLog For developers: NEW: Add a lot of API REST: dictionaryevents, memberstypes, ... +NEW: Big refactorization of multicompany transverse mode NEW: getEntity function use true $shared value by default WARNING: @@ -22,6 +23,7 @@ Following changes may create regression for some external modules, but were nece * Removed Societe::set_commnucation_level (was deprecated in 4.0). Was not used. * Removed the trigger file of PAYPAL module that stored data that was not used by Dolibarr. The trigger event still exists, but if an external module need action on it, it must provides itself its trigger file. +* Use $conf->global->MULTICOMPANY_TRANSVERSE_MODE instead $conf->multicompany->transverse_mode * Use getEntity('xxx') instead getEntity('xxx', 1) and use getEntity('xxx', 0) instead getEntity('xxx') ***** ChangeLog for 5.0.3 compared to 5.0.2 ***** diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 369dd7afcec..60e283eea2c 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -2,7 +2,7 @@ /* Copyright (C) 2013-2016 Olivier Geffroy * Copyright (C) 2013-2016 Florian Henry * Copyright (C) 2013-2017 Alexandre Spangaro - * Copyright (C) 2016 Laurent Destailleur + * Copyright (C) 2016 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -463,10 +463,10 @@ print ''; print ''; print price($total_debit); print ''; -print ''; +print ''; print price($total_credit); print ''; -print ''; +print ''; print ''; print ""; diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 8ba8d185ede..0fc4a936117 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -85,6 +85,7 @@ class BookKeeping extends CommonObject public $fk_user_author; public $import_key; public $code_journal; + public $journal_label; public $piece_num; /** @@ -156,6 +157,9 @@ class BookKeeping extends CommonObject if (isset($this->code_journal)) { $this->code_journal = trim($this->code_journal); } + if (isset($this->journal_label)) { + $this->journal_label = trim($this->journal_label); + } if (isset($this->piece_num)) { $this->piece_num = trim($this->piece_num); } @@ -250,6 +254,7 @@ class BookKeeping extends CommonObject $sql .= ", fk_user_author"; $sql .= ", import_key"; $sql .= ", code_journal"; + $sql .= ", journal_label"; $sql .= ", piece_num"; $sql .= ', entity'; $sql .= ") VALUES ("; @@ -268,6 +273,7 @@ class BookKeeping extends CommonObject $sql .= ",'" . $this->fk_user_author . "'"; $sql .= ",'" . $this->db->idate($this->date_create). "'"; $sql .= ",'" . $this->code_journal . "'"; + $sql .= ",'" . $this->journal_label . "'"; $sql .= "," . $this->piece_num; $sql .= ", " . (! isset($this->entity) ? '1' : $this->entity); $sql .= ")"; @@ -384,6 +390,9 @@ class BookKeeping extends CommonObject if (isset($this->code_journal)) { $this->code_journal = trim($this->code_journal); } + if (isset($this->journal_label)) { + $this->journal_label = trim($this->journal_label); + } if (isset($this->piece_num)) { $this->piece_num = trim($this->piece_num); } @@ -410,6 +419,7 @@ class BookKeeping extends CommonObject $sql .= 'fk_user_author,'; $sql .= 'import_key,'; $sql .= 'code_journal,'; + $sql .= 'journal_label,'; $sql .= 'piece_num,'; $sql .= 'entity'; $sql .= ') VALUES ('; @@ -428,6 +438,7 @@ class BookKeeping extends CommonObject $sql .= ' ' . $user->id . ','; $sql .= ' ' . (! isset($this->import_key) ? 'NULL' : "'" . $this->db->escape($this->import_key) . "'") . ','; $sql .= ' ' . (empty($this->code_journal) ? 'NULL' : "'" . $this->db->escape($this->code_journal) . "'") . ','; + $sql .= ' ' . (empty($this->journal_label) ? 'NULL' : "'" . $this->db->escape($this->journal_label) . "'") . ','; $sql .= ' ' . (empty($this->piece_num) ? 'NULL' : $this->piece_num).','; $sql .= ' ' . (! isset($this->entity) ? '1' : $this->entity); $sql .= ')'; @@ -458,11 +469,11 @@ class BookKeeping extends CommonObject // Commit or rollback if ($error) { $this->db->rollback(); - + return - 1 * $error; } else { $this->db->commit(); - + return $this->id; } } @@ -478,7 +489,7 @@ class BookKeeping extends CommonObject public function fetch($id, $ref = null) { global $conf; - dol_syslog(__METHOD__, LOG_DEBUG); + dol_syslog(__METHOD__, LOG_DEBUG); $sql = 'SELECT'; $sql .= ' t.rowid,'; @@ -497,6 +508,7 @@ class BookKeeping extends CommonObject $sql .= " t.fk_user_author,"; $sql .= " t.import_key,"; $sql .= " t.code_journal,"; + $sql .= " t.journal_label,"; $sql .= " t.piece_num"; $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; $sql .= ' WHERE 1 = 1'; @@ -530,6 +542,7 @@ class BookKeeping extends CommonObject $this->fk_user_author = $obj->fk_user_author; $this->import_key = $obj->import_key; $this->code_journal = $obj->code_journal; + $this->journal_label = $obj->journal_label; $this->piece_num = $obj->piece_num; } $this->db->free($resql); @@ -581,6 +594,7 @@ class BookKeeping extends CommonObject $sql .= " t.fk_user_author,"; $sql .= " t.import_key,"; $sql .= " t.code_journal,"; + $sql .= " t.journal_label,"; $sql .= " t.piece_num"; // Manage filter $sqlwhere = array (); @@ -643,6 +657,7 @@ class BookKeeping extends CommonObject $line->fk_user_author = $obj->fk_user_author; $line->import_key = $obj->import_key; $line->code_journal = $obj->code_journal; + $line->journal_label = $obj->journal_label; $line->piece_num = $obj->piece_num; $this->lines[] = $line; @@ -693,6 +708,7 @@ class BookKeeping extends CommonObject $sql .= " t.fk_user_author,"; $sql .= " t.import_key,"; $sql .= " t.code_journal,"; + $sql .= " t.journal_label,"; $sql .= " t.piece_num"; $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; // Manage filter @@ -752,6 +768,7 @@ class BookKeeping extends CommonObject $line->fk_user_author = $obj->fk_user_author; $line->import_key = $obj->import_key; $line->code_journal = $obj->code_journal; + $line->journal_label = $obj->journal_label; $line->piece_num = $obj->piece_num; $this->lines[] = $line; @@ -903,6 +920,9 @@ class BookKeeping extends CommonObject if (isset($this->code_journal)) { $this->code_journal = trim($this->code_journal); } + if (isset($this->journal_label)) { + $this->journal_label = trim($this->journal_label); + } if (isset($this->piece_num)) { $this->piece_num = trim($this->piece_num); } @@ -927,6 +947,7 @@ class BookKeeping extends CommonObject $sql .= ' fk_user_author = ' . (isset($this->fk_user_author) ? $this->fk_user_author : "null") . ','; $sql .= ' import_key = ' . (isset($this->import_key) ? "'" . $this->db->escape($this->import_key) . "'" : "null") . ','; $sql .= ' code_journal = ' . (isset($this->code_journal) ? "'" . $this->db->escape($this->code_journal) . "'" : "null") . ','; + $sql .= ' journal_label = ' . (isset($this->journal_label) ? "'" . $this->db->escape($this->journal_label) . "'" : "null") . ','; $sql .= ' piece_num = ' . (isset($this->piece_num) ? $this->piece_num : "null"); $sql .= ' WHERE rowid=' . $this->id; @@ -1185,6 +1206,7 @@ class BookKeeping extends CommonObject $this->fk_user_author = $user->id; $this->import_key = ''; $this->code_journal = ''; + $this->journal_label = ''; $this->piece_num = ''; } @@ -1197,7 +1219,7 @@ class BookKeeping extends CommonObject public function fetchPerMvt($piecenum) { global $conf; - $sql = "SELECT piece_num,doc_date,code_journal,doc_ref,doc_type"; + $sql = "SELECT piece_num,doc_date,code_journal,journal_label,doc_ref,doc_type"; $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; $sql .= " WHERE piece_num = " . $piecenum; $sql .= " AND entity IN (" . getEntity('accountancy') . ")"; @@ -1209,6 +1231,7 @@ class BookKeeping extends CommonObject $this->piece_num = $obj->piece_num; $this->code_journal = $obj->code_journal; + $this->journal_label = $obj->journal_label; $this->doc_date = $this->db->jdate($obj->doc_date); $this->doc_ref = $obj->doc_ref; $this->doc_type = $obj->doc_type; @@ -1260,7 +1283,7 @@ class BookKeeping extends CommonObject $sql = "SELECT rowid, doc_date, doc_type,"; $sql .= " doc_ref, fk_doc, fk_docdet, code_tiers,"; $sql .= " numero_compte, label_compte, debit, credit,"; - $sql .= " montant, sens, fk_user_author, import_key, code_journal, piece_num"; + $sql .= " montant, sens, fk_user_author, import_key, code_journal, journal_label, piece_num"; $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element; $sql .= " WHERE piece_num = " . $piecenum; $sql .= " AND entity IN (" . getEntity('accountancy') . ")"; @@ -1288,6 +1311,7 @@ class BookKeeping extends CommonObject $line->montant = $obj->montant; $line->sens = $obj->sens; $line->code_journal = $obj->code_journal; + $line->journal_label = $obj->journal_label; $line->piece_num = $obj->piece_num; $this->linesmvt[] = $line; @@ -1533,5 +1557,6 @@ class BookKeepingLine public $fk_user_author; public $import_key; public $code_journal; + public $journal_label; public $piece_num; } diff --git a/htdocs/accountancy/index.php b/htdocs/accountancy/index.php index c7caa5daac3..02549be2a94 100644 --- a/htdocs/accountancy/index.php +++ b/htdocs/accountancy/index.php @@ -45,10 +45,13 @@ $langs->load("compta"); $langs->load("banks"); $langs->load("loans"); + /* * Actions */ +// None + /* * View @@ -73,35 +76,31 @@ print "
\n"; $step++; print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescJournalSetup", $step, ''.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("AccountingJournals").''); print "
\n"; -print "
\n"; $step++; print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescChartModel", $step, ''.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("Pcg_version").''); print "
\n"; -print "
\n"; $step++; print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescChart", $step, ''.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("Chartofaccounts").''); print "
\n"; -print "
\n"; +print "
\n"; print $langs->trans("AccountancyAreaDescActionOnceBis"); print "
\n"; print "
\n"; $step++; -print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescMisc", $step, ''.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").'')."
\n"; +print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescMisc", $step, ''.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").'')."\n"; print "
\n"; $step++; $textlink = ''.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup").'-'.$langs->transnoentitiesnoconv("MenuVatAccounts").''; print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescVat", $step, $textlink); print "
\n"; -print "
\n"; if (! empty($conf->tax->enabled)) { $textlink = ''.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup").'-'.$langs->transnoentitiesnoconv("MenuTaxAccounts").''; $step++; print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescContrib", $step, $textlink); print "
\n"; - print "
\n"; } /*if (! empty($conf->salaries->enabled)) { @@ -116,7 +115,6 @@ if (! empty($conf->expensereport->enabled)) // TODO Move this in the default ac $step++; print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescExpenseReport", $step, ''.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuExpenseReportAccounts").''); print "
\n"; - print "
\n"; } /* if (! empty($conf->loan->enabled)) @@ -124,26 +122,22 @@ if (! empty($conf->loan->enabled)) $step++; print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescLoan", $step, ''.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuSpecialExpenses").'-'.$langs->transnoentitiesnoconv("Loans").' '.$langs->transnoentitiesnoconv("or").' '.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").''); print "
\n"; - print "
\n"; } if (! empty($conf->don->enabled)) { $step++; print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescDonation", $step, ''.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDonationAccounts").''); print "
\n"; - print "
\n"; }*/ $step++; print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescProd", $step, ''.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("ProductsBinding").''); print "
\n"; -print "
\n"; $step++; $textlink=''.$langs->transnoentitiesnoconv("MenuBankCash").''; print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBank", $step, $textlink); print "
\n"; -print "
\n"; print "
\n"; @@ -155,19 +149,19 @@ $step = 0; $langs->loadLangs(array('bills', 'trips')); $step++; -print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBind", chr(64+$step), $langs->transnoentitiesnoconv("BillsCustomers"), ''.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy")."-".$langs->transnoentitiesnoconv("CustomersVentilation").'')."
\n"; +print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBind", chr(64+$step), $langs->transnoentitiesnoconv("BillsCustomers"), ''.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy")."-".$langs->transnoentitiesnoconv("CustomersVentilation").'')."\n"; print "
\n"; $step++; -print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBind", chr(64+$step), $langs->transnoentitiesnoconv("BillsSuppliers"), ''.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy")."-".$langs->transnoentitiesnoconv("SuppliersVentilation").'')."
\n"; +print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBind", chr(64+$step), $langs->transnoentitiesnoconv("BillsSuppliers"), ''.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy")."-".$langs->transnoentitiesnoconv("SuppliersVentilation").'')."\n"; print "
\n"; $step++; -print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBind", chr(64+$step), $langs->transnoentitiesnoconv("ExpenseReports"), ''.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy")."-".$langs->transnoentitiesnoconv("ExpenseReportsVentilation").'')."
\n"; +print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBind", chr(64+$step), $langs->transnoentitiesnoconv("ExpenseReports"), ''.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy")."-".$langs->transnoentitiesnoconv("ExpenseReportsVentilation").'')."\n"; print "
\n"; $step++; -print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescWriteRecords", chr(64+$step), $langs->transnoentitiesnoconv("Journalization"), $langs->transnoentitiesnoconv("WriteBookKeeping"))."
\n"; +print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescWriteRecords", chr(64+$step), $langs->transnoentitiesnoconv("Journalization"), $langs->transnoentitiesnoconv("WriteBookKeeping"))."\n"; print "
\n"; $step++; diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index cb3afb95f5a..9eae2072243 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -28,8 +28,6 @@ * \brief Page with bank journal */ require '../../main.inc.php'; - -// Class require_once DOL_DOCUMENT_ROOT . '/core/lib/report.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/bank.lib.php'; @@ -53,8 +51,6 @@ require_once DOL_DOCUMENT_ROOT . '/societe/class/client.class.php'; require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php'; require_once DOL_DOCUMENT_ROOT . '/expensereport/class/paymentexpensereport.class.php'; - -// Langs $langs->load("companies"); $langs->load("other"); $langs->load("compta"); @@ -77,6 +73,7 @@ $date_endyear = GETPOST('date_endyear'); $action = GETPOST('action','aZ09'); $now = dol_now(); +$action = GETPOST('action','aZ09'); // Security check if ($user->societe_id > 0 && empty($id_journal)) @@ -120,7 +117,7 @@ $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "bank_url as bu2 ON bu2.fk_bank = b.row $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe as soc on bu1.url_id=soc.rowid"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "user as u on bu2.url_id=u.rowid"; $sql .= " WHERE ba.fk_accountancy_journal=" . $id_journal; -$sql .= ' AND ba.entity IN ('.getEntity('bank_account', 0).')'; // We don't share object for accountancy +$sql .= ' AND ba.entity IN ('.getEntity('bank_account', 0).')'; // We don't share object for accountancy if ($date_start && $date_end) $sql .= " AND b.dateo >= '" . $db->idate($date_start) . "' AND b.dateo <= '" . $db->idate($date_end) . "'"; $sql .= " ORDER BY b.datev"; @@ -140,6 +137,7 @@ $paymentexpensereportstatic = new PaymentExpenseReport($db); $accountingjournalstatic = new AccountingJournal($db); $accountingjournalstatic->fetch($id_journal); $journal = $accountingjournalstatic->code; +$journal_label = $accountingjournalstatic->label; dol_syslog("accountancy/journal/bankjournal.php", LOG_DEBUG); $result = $db->query($sql); @@ -210,11 +208,11 @@ if ($result) { // Now loop on each link of record in bank. foreach ( $links as $key => $val ) { - if (in_array($links[$key]['type'], array('sc', 'payment_sc', 'payment', 'payment_supplier', 'payment_vat', 'payment_expensereport', 'banktransfert', 'payment_donation', 'payment_salary'))) // So we excluded 'company' here - { - // We save tabtype for a future use, to remember what kind of payment it is - $tabtype[$obj->rowid] = $links[$key]['type']; - } + if (in_array($links[$key]['type'], array('sc', 'payment_sc', 'payment', 'payment_supplier', 'payment_vat', 'payment_expensereport', 'banktransfert', 'payment_donation', 'payment_salary'))) // So we excluded 'company' here + { + // We save tabtype for a future use, to remember what kind of payment it is + $tabtype[$obj->rowid] = $links[$key]['type']; + } if ($links[$key]['type'] == 'payment') { $paymentstatic->id = $links[$key]['url_id']; @@ -298,22 +296,22 @@ if ($result) { // Check account number is ok - /*if ($action == 'writebookkeeping') // Make test now in such a case + /*if ($action == 'writebookkeeping') // Make test now in such a case { - reset($tabbq[$obj->rowid]); - $first_key_tabbq = key($tabbq[$obj->rowid]); - if (empty($first_key_tabbq)) - { - $error++; - setEventMessages($langs->trans('ErrorAccountancyCodeOnBankAccountNotDefined', $obj->baref), null, 'errors'); - } - reset($tabtp[$obj->rowid]); - $first_key_tabtp = key($tabtp[$obj->rowid]); - if (empty($first_key_tabtp)) - { - $error++; - setEventMessages($langs->trans('ErrorAccountancyCodeOnThirdPartyNotDefined'), null, 'errors'); - } + reset($tabbq[$obj->rowid]); + $first_key_tabbq = key($tabbq[$obj->rowid]); + if (empty($first_key_tabbq)) + { + $error++; + setEventMessages($langs->trans('ErrorAccountancyCodeOnBankAccountNotDefined', $obj->baref), null, 'errors'); + } + reset($tabtp[$obj->rowid]); + $first_key_tabtp = key($tabtp[$obj->rowid]); + if (empty($first_key_tabtp)) + { + $error++; + setEventMessages($langs->trans('ErrorAccountancyCodeOnThirdPartyNotDefined'), null, 'errors'); + } }*/ // if($obj->socid)$tabtp[$obj->rowid][$compta_soc] += $obj->amount; @@ -335,76 +333,77 @@ if (! $error && $action == 'writebookkeeping') { $now = dol_now(); $error = 0; - foreach ( $tabpay as $key => $val ) { // $key is rowid into llx_bank + foreach ( $tabpay as $key => $val ) { // $key is rowid into llx_bank - $errorforline = 0; + $errorforline = 0; - $db->begin(); + $db->begin(); // Bank if (! $errorforline) { - // Line into bank account - foreach ( $tabbq[$key] as $k => $mt ) - { - if ($mt) { - $bookkeeping = new BookKeeping($db); - $bookkeeping->doc_date = $val["date"]; - $bookkeeping->doc_ref = $val["ref"]; - $bookkeeping->doc_type = 'bank'; - $bookkeeping->fk_doc = $key; - $bookkeeping->fk_docdet = $val["fk_bank"]; - $bookkeeping->numero_compte = $k; - $bookkeeping->label_compte = $compte->label; - $bookkeeping->montant = ($mt < 0 ? - $mt : $mt); - $bookkeeping->sens = ($mt >= 0) ? 'D' : 'C'; - $bookkeeping->debit = ($mt >= 0 ? $mt : 0); - $bookkeeping->credit = ($mt < 0 ? - $mt : 0); - $bookkeeping->code_journal = $journal; - $bookkeeping->fk_user_author = $user->id; - $bookkeeping->date_create = $now; + // Line into bank account + foreach ( $tabbq[$key] as $k => $mt ) + { + if ($mt) { + $bookkeeping = new BookKeeping($db); + $bookkeeping->doc_date = $val["date"]; + $bookkeeping->doc_ref = $val["ref"]; + $bookkeeping->doc_type = 'bank'; + $bookkeeping->fk_doc = $key; + $bookkeeping->fk_docdet = $val["fk_bank"]; + $bookkeeping->numero_compte = $k; + $bookkeeping->label_compte = $compte->label; + $bookkeeping->montant = ($mt < 0 ? - $mt : $mt); + $bookkeeping->sens = ($mt >= 0) ? 'D' : 'C'; + $bookkeeping->debit = ($mt >= 0 ? $mt : 0); + $bookkeeping->credit = ($mt < 0 ? - $mt : 0); + $bookkeeping->code_journal = $journal; + $bookkeeping->journal_label = $journal_label; + $bookkeeping->fk_user_author = $user->id; + $bookkeeping->date_create = $now; - if ($tabtype[$key] == 'payment') { - $bookkeeping->code_tiers = $tabcompany[$key]['code_compta']; + if ($tabtype[$key] == 'payment') { + $bookkeeping->code_tiers = $tabcompany[$key]['code_compta']; - $sqlmid = 'SELECT fac.facnumber'; - $sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture fac"; - $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement_facture as payfac ON payfac.fk_facture=fac.rowid"; - $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement as pay ON payfac.fk_paiement=pay.rowid"; - $sqlmid .= " WHERE pay.fk_bank=" . $key; - dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG); - $resultmid = $db->query($sqlmid); - if ($resultmid) { - $objmid = $db->fetch_object($resultmid); - $bookkeeping->doc_ref = $objmid->facnumber; // Ref of invoice - } - } else if ($tabtype[$key] == 'payment_supplier') { - $bookkeeping->code_tiers = $tabcompany[$key]['code_compta']; + $sqlmid = 'SELECT fac.facnumber'; + $sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture fac"; + $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement_facture as payfac ON payfac.fk_facture=fac.rowid"; + $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement as pay ON payfac.fk_paiement=pay.rowid"; + $sqlmid .= " WHERE pay.fk_bank=" . $key; + dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG); + $resultmid = $db->query($sqlmid); + if ($resultmid) { + $objmid = $db->fetch_object($resultmid); + $bookkeeping->doc_ref = $objmid->facnumber; // Ref of invoice + } + } else if ($tabtype[$key] == 'payment_supplier') { + $bookkeeping->code_tiers = $tabcompany[$key]['code_compta']; - $sqlmid = 'SELECT facf.ref_supplier, facf.ref'; - $sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture_fourn facf"; - $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn_facturefourn as payfacf ON payfacf.fk_facturefourn=facf.rowid"; - $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn as payf ON payfacf.fk_paiementfourn=payf.rowid"; - $sqlmid .= " WHERE payf.fk_bank=" . $key; - dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG); - $resultmid = $db->query($sqlmid); - if ($resultmid) { - $objmid = $db->fetch_object($resultmid); - $bookkeeping->doc_ref = $objmid->ref_supplier . ' (' . $objmid->ref . ')'; // Ref on invoice - } - } else if ($tabtype[$key] == 'payment_expensereport') { - $bookkeeping->code_tiers = $tabuser[$key]['accountancy_code']; + $sqlmid = 'SELECT facf.ref_supplier, facf.ref'; + $sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture_fourn facf"; + $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn_facturefourn as payfacf ON payfacf.fk_facturefourn=facf.rowid"; + $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn as payf ON payfacf.fk_paiementfourn=payf.rowid"; + $sqlmid .= " WHERE payf.fk_bank=" . $key; + dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG); + $resultmid = $db->query($sqlmid); + if ($resultmid) { + $objmid = $db->fetch_object($resultmid); + $bookkeeping->doc_ref = $objmid->ref_supplier . ' (' . $objmid->ref . ')'; // Ref on invoice + } + } else if ($tabtype[$key] == 'payment_expensereport') { + $bookkeeping->code_tiers = $tabuser[$key]['accountancy_code']; - $sqlmid = 'SELECT e.ref'; - $sqlmid .= " FROM " . MAIN_DB_PREFIX . "expensereport as e"; - $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "payment_expensereport as payer ON payer.fk_expensereport=e.rowid"; - $sqlmid .= " WHERE payer.fk_expensereport=" . $val["fk_expensereport"]; - dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG); - $resultmid = $db->query($sqlmid); - if ($resultmid) { - $objmid = $db->fetch_object($resultmid); - $bookkeeping->doc_ref = $objmid->ref; // Ref of expensereport - } + $sqlmid = 'SELECT e.ref'; + $sqlmid .= " FROM " . MAIN_DB_PREFIX . "expensereport as e"; + $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "payment_expensereport as payer ON payer.fk_expensereport=e.rowid"; + $sqlmid .= " WHERE payer.fk_expensereport=" . $val["fk_expensereport"]; + dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG); + $resultmid = $db->query($sqlmid); + if ($resultmid) { + $objmid = $db->fetch_object($resultmid); + $bookkeeping->doc_ref = $objmid->ref; // Ref of expensereport + } } else if ($tabtype[$key] == 'payment_vat') { $bookkeeping->code_tiers = ''; $bookkeeping->doc_ref = $langs->trans("PaymentVat") . ' (' . $val["paymentvatid"] . ')'; // Rowid of vat payment @@ -417,75 +416,76 @@ if (! $error && $action == 'writebookkeeping') { $bookkeeping->doc_ref = $langs->trans("SalaryPayment") . ' (' . $val["paymentsalid"] . ')'; // Ref of salary payment } - $result = $bookkeeping->create($user); - if ($result < 0) { - if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists - { - $error++; - $errorforline++; - //setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->doc_ref.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); - } - else - { - $error++; - $errorforline++; - setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); - } - } - } - } + $result = $bookkeeping->create($user); + if ($result < 0) { + if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists + { + $error++; + $errorforline++; + //setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->doc_ref.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); + } + else + { + $error++; + $errorforline++; + setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); + } + } + } + } } // Third party if (! $errorforline) { - // Line into thirdparty account - foreach ( $tabtp[$key] as $k => $mt ) { - if ($mt) { - $bookkeeping = new BookKeeping($db); - $bookkeeping->doc_date = $val["date"]; - $bookkeeping->doc_ref = $val["ref"]; - $bookkeeping->doc_type = 'bank'; - $bookkeeping->fk_doc = $key; - $bookkeeping->fk_docdet = $val["fk_bank"]; - $bookkeeping->label_compte = $tabcompany[$key]['name']; - $bookkeeping->montant = ($mt < 0 ? - $mt : $mt); - $bookkeeping->sens = ($mt < 0) ? 'D' : 'C'; - $bookkeeping->debit = ($mt < 0 ? - $mt : 0); - $bookkeeping->credit = ($mt >= 0) ? $mt : 0; - $bookkeeping->code_journal = $journal; - $bookkeeping->fk_user_author = $user->id; - $bookkeeping->date_create = $now; + // Line into thirdparty account + foreach ( $tabtp[$key] as $k => $mt ) { + if ($mt) { + $bookkeeping = new BookKeeping($db); + $bookkeeping->doc_date = $val["date"]; + $bookkeeping->doc_ref = $val["ref"]; + $bookkeeping->doc_type = 'bank'; + $bookkeeping->fk_doc = $key; + $bookkeeping->fk_docdet = $val["fk_bank"]; + $bookkeeping->label_compte = $tabcompany[$key]['name']; + $bookkeeping->montant = ($mt < 0 ? - $mt : $mt); + $bookkeeping->sens = ($mt < 0) ? 'D' : 'C'; + $bookkeeping->debit = ($mt < 0 ? - $mt : 0); + $bookkeeping->credit = ($mt >= 0) ? $mt : 0; + $bookkeeping->code_journal = $journal; + $bookkeeping->journal_label = $journal_label; + $bookkeeping->fk_user_author = $user->id; + $bookkeeping->date_create = $now; - if (in_array($tabtype[$key], array('sc', 'payment_sc'))) { // If payment is payment of social contribution - $bookkeeping->code_tiers = ''; - $bookkeeping->numero_compte = $k; - } else if ($tabtype[$key] == 'payment') { // If payment is payment of customer invoice, we get ref of invoice - $sqlmid = 'SELECT fac.facnumber'; - $sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture fac "; - $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement_facture as payfac ON payfac.fk_facture=fac.rowid"; - $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement as pay ON payfac.fk_paiement=pay.rowid"; - $sqlmid .= " WHERE pay.fk_bank=" . $key; - dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG); - $resultmid = $db->query($sqlmid); - if ($resultmid) { - $objmid = $db->fetch_object($resultmid); - $bookkeeping->doc_ref = $objmid->facnumber; - } - $bookkeeping->code_tiers = $tabcompany[$key]['code_compta']; - $bookkeeping->numero_compte = $k; - } else if ($tabtype[$key] == 'payment_supplier') { // If payment is payment of supplier invoice, we get ref of invoice - $sqlmid = 'SELECT facf.ref_supplier,facf.ref'; - $sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture_fourn facf "; - $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn_facturefourn as payfacf ON payfacf.fk_facturefourn=facf.rowid"; - $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn as payf ON payfacf.fk_paiementfourn=payf.rowid"; - $sqlmid .= " WHERE payf.fk_bank=" . $key; - dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG); - $resultmid = $db->query($sqlmid); - if ($resultmid) { - $objmid = $db->fetch_object($resultmid); - $bookkeeping->doc_ref = $objmid->ref_supplier . ' (' . $objmid->ref . ')'; - } + if (in_array($tabtype[$key], array('sc', 'payment_sc'))) { // If payment is payment of social contribution + $bookkeeping->code_tiers = ''; + $bookkeeping->numero_compte = $k; + } else if ($tabtype[$key] == 'payment') { // If payment is payment of customer invoice, we get ref of invoice + $sqlmid = 'SELECT fac.facnumber'; + $sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture fac "; + $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement_facture as payfac ON payfac.fk_facture=fac.rowid"; + $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiement as pay ON payfac.fk_paiement=pay.rowid"; + $sqlmid .= " WHERE pay.fk_bank=" . $key; + dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG); + $resultmid = $db->query($sqlmid); + if ($resultmid) { + $objmid = $db->fetch_object($resultmid); + $bookkeeping->doc_ref = $objmid->facnumber; + } + $bookkeeping->code_tiers = $tabcompany[$key]['code_compta']; + $bookkeeping->numero_compte = $k; + } else if ($tabtype[$key] == 'payment_supplier') { // If payment is payment of supplier invoice, we get ref of invoice + $sqlmid = 'SELECT facf.ref_supplier,facf.ref'; + $sqlmid .= " FROM " . MAIN_DB_PREFIX . "facture_fourn facf "; + $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn_facturefourn as payfacf ON payfacf.fk_facturefourn=facf.rowid"; + $sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementfourn as payf ON payfacf.fk_paiementfourn=payf.rowid"; + $sqlmid .= " WHERE payf.fk_bank=" . $key; + dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG); + $resultmid = $db->query($sqlmid); + if ($resultmid) { + $objmid = $db->fetch_object($resultmid); + $bookkeeping->doc_ref = $objmid->ref_supplier . ' (' . $objmid->ref . ')'; + } $bookkeeping->code_tiers = $tabcompany[$key]['code_compta']; $bookkeeping->numero_compte = $k; } else if ($tabtype[$key] == 'payment_vat') { @@ -504,52 +504,52 @@ if (! $error && $action == 'writebookkeeping') { } else if ($tabtype[$key] == 'banktransfert') { $bookkeeping->code_tiers = ''; $bookkeeping->numero_compte = $k; - } else { - // FIXME Should be a temporary account ??? - $bookkeeping->doc_ref = $k; - //$bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER; - $bookkeeping->numero_compte = 'CodeNotDef'; - } + } else { + // FIXME Should be a temporary account ??? + $bookkeeping->doc_ref = $k; + //$bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER; + $bookkeeping->numero_compte = 'CodeNotDef'; + } - $result = $bookkeeping->create($user); - if ($result < 0) { - if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists - { - $error++; - $errorforline++; - //setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->doc_ref.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); - } - else - { - $error++; - $errorforline++; - setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); - } - } - } - } + $result = $bookkeeping->create($user); + if ($result < 0) { + if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists + { + $error++; + $errorforline++; + //setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->doc_ref.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); + } + else + { + $error++; + $errorforline++; + setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); + } + } + } + } } if (! $errorforline) { - $db->commit(); + $db->commit(); } else { - $db->rollback(); + $db->rollback(); } } if (empty($error)) { - setEventMessages($langs->trans("GeneralLedgerIsWritten"), null, 'mesgs'); + setEventMessages($langs->trans("GeneralLedgerIsWritten"), null, 'mesgs'); } elseif (count($tabpay) == $error) { - setEventMessages($langs->trans("NoNewRecordSaved"), null, 'warnings'); + setEventMessages($langs->trans("NoNewRecordSaved"), null, 'warnings'); } else { - setEventMessages($langs->trans("GeneralLedgerSomeRecordWasNotRecorded"), null, 'warnings'); + setEventMessages($langs->trans("GeneralLedgerSomeRecordWasNotRecorded"), null, 'warnings'); } $action = ''; @@ -758,24 +758,24 @@ if (empty($action) || $action == 'view') { print ''; }*/ - print '
'; + print '
'; print ''; - print '
'; + print '
'; // TODO Avoid using js. We can use a direct link with $param print ' '; @@ -799,7 +799,7 @@ if (empty($action) || $action == 'view') { $r = ''; - foreach ( $tabpay as $key => $val ) { // $key is rowid in llx_bank + foreach ( $tabpay as $key => $val ) { // $key is rowid in llx_bank $date = dol_print_date($db->jdate($val["date"]), 'day'); $reflabel = $val["ref"]; @@ -825,45 +825,45 @@ if (empty($action) || $action == 'view') { $ref=$reflabel; if ($tabtype[$key] == 'payment') { - $sqlmid = 'SELECT payfac.fk_facture as id'; - $sqlmid .= " FROM ".MAIN_DB_PREFIX."paiement_facture as payfac"; - $sqlmid .= " WHERE payfac.fk_paiement=" . $val["paymentid"]; - dol_syslog("accountancy/journal/bankjournal.php::sqlmid=" . $sqlmid, LOG_DEBUG); - $resultmid = $db->query($sqlmid); - if ($resultmid) { - $objmid = $db->fetch_object($resultmid); - $invoicestatic->fetch($objmid->id); - $ref=$langs->trans("Invoice").' '.$invoicestatic->getNomUrl(1); - } - else dol_print_error($db); + $sqlmid = 'SELECT payfac.fk_facture as id'; + $sqlmid .= " FROM ".MAIN_DB_PREFIX."paiement_facture as payfac"; + $sqlmid .= " WHERE payfac.fk_paiement=" . $val["paymentid"]; + dol_syslog("accountancy/journal/bankjournal.php::sqlmid=" . $sqlmid, LOG_DEBUG); + $resultmid = $db->query($sqlmid); + if ($resultmid) { + $objmid = $db->fetch_object($resultmid); + $invoicestatic->fetch($objmid->id); + $ref=$langs->trans("Invoice").' '.$invoicestatic->getNomUrl(1); + } + else dol_print_error($db); } elseif ($tabtype[$key] == 'payment_supplier') { - $sqlmid = 'SELECT payfac.fk_facturefourn as id'; - $sqlmid .= " FROM " . MAIN_DB_PREFIX . "paiementfourn_facturefourn as payfac"; - $sqlmid .= " WHERE payfac.fk_paiementfourn=" . $val["paymentsupplierid"]; - dol_syslog("accountancy/journal/bankjournal.php::sqlmid=" . $sqlmid, LOG_DEBUG); - $resultmid = $db->query($sqlmid); - if ($resultmid) { - $objmid = $db->fetch_object($resultmid); - $invoicesupplierstatic->fetch($objmid->id); - $ref=$langs->trans("SupplierInvoice").' '.$invoicesupplierstatic->getNomUrl(1); - } - else dol_print_error($db); + $sqlmid = 'SELECT payfac.fk_facturefourn as id'; + $sqlmid .= " FROM " . MAIN_DB_PREFIX . "paiementfourn_facturefourn as payfac"; + $sqlmid .= " WHERE payfac.fk_paiementfourn=" . $val["paymentsupplierid"]; + dol_syslog("accountancy/journal/bankjournal.php::sqlmid=" . $sqlmid, LOG_DEBUG); + $resultmid = $db->query($sqlmid); + if ($resultmid) { + $objmid = $db->fetch_object($resultmid); + $invoicesupplierstatic->fetch($objmid->id); + $ref=$langs->trans("SupplierInvoice").' '.$invoicesupplierstatic->getNomUrl(1); + } + else dol_print_error($db); } elseif ($tabtype[$key] == 'payment_expensereport') { - $sqlmid = 'SELECT payer.fk_expensereport as id'; - $sqlmid .= " FROM " . MAIN_DB_PREFIX . "payment_expensereport as payer"; - $sqlmid .= " WHERE payer.fk_expensereport=" . $val["fk_expensereport"]; - dol_syslog("accountancy/journal/bankjournal.php::sqlmid=" . $sqlmid, LOG_DEBUG); - $resultmid = $db->query($sqlmid); - if ($resultmid) { - $objmid = $db->fetch_object($resultmid); - $expensereportstatic->fetch($objmid->id); - $ref=$langs->trans("ExpenseReport").' '.$expensereportstatic->getNomUrl(1); - } - else dol_print_error($db); + $sqlmid = 'SELECT payer.fk_expensereport as id'; + $sqlmid .= " FROM " . MAIN_DB_PREFIX . "payment_expensereport as payer"; + $sqlmid .= " WHERE payer.fk_expensereport=" . $val["fk_expensereport"]; + dol_syslog("accountancy/journal/bankjournal.php::sqlmid=" . $sqlmid, LOG_DEBUG); + $resultmid = $db->query($sqlmid); + if ($resultmid) { + $objmid = $db->fetch_object($resultmid); + $expensereportstatic->fetch($objmid->id); + $ref=$langs->trans("ExpenseReport").' '.$expensereportstatic->getNomUrl(1); + } + else dol_print_error($db); } elseif ($tabtype[$key] == 'payment_vat') { @@ -881,17 +881,17 @@ if (empty($action) || $action == 'view') { } elseif ($tabtype[$key] == 'payment_donation') { - $sqlmid = 'SELECT payd.fk_donation as id'; - $sqlmid .= " FROM " . MAIN_DB_PREFIX . "payment_donation as payd"; - $sqlmid .= " WHERE payd.fk_donation=" . $val["paymentdonationid"]; - dol_syslog("accountancy/journal/bankjournal.php::sqlmid=" . $sqlmid, LOG_DEBUG); - $resultmid = $db->query($sqlmid); - if ($resultmid) { - $objmid = $db->fetch_object($resultmid); - $donationstatic->fetch($objmid->id); - $ref=$langs->trans("Donation").' '.$donationstatic->getNomUrl(1); - } - else dol_print_error($db); + $sqlmid = 'SELECT payd.fk_donation as id'; + $sqlmid .= " FROM " . MAIN_DB_PREFIX . "payment_donation as payd"; + $sqlmid .= " WHERE payd.fk_donation=" . $val["paymentdonationid"]; + dol_syslog("accountancy/journal/bankjournal.php::sqlmid=" . $sqlmid, LOG_DEBUG); + $resultmid = $db->query($sqlmid); + if ($resultmid) { + $objmid = $db->fetch_object($resultmid); + $donationstatic->fetch($objmid->id); + $ref=$langs->trans("Donation").' '.$donationstatic->getNomUrl(1); + } + else dol_print_error($db); } elseif ($tabtype[$key] == 'payment_salary') { @@ -915,15 +915,15 @@ if (empty($action) || $action == 'view') { // Bank foreach ( $tabbq[$key] as $k => $mt ) { - print ''; - print ""; - print "" . $date . ""; + print ''; + print ""; + print "" . $date . ""; print "" . $ref . ""; print ""; $accountoshow = length_accountg($k); if (empty($accountoshow) || $accountoshow == 'NotDefined') { - print ''.$langs->trans("BankAccountNotDefined").''; + print ''.$langs->trans("BankAccountNotDefined").''; } else print $accountoshow; print ""; @@ -947,12 +947,12 @@ if (empty($action) || $action == 'view') { print "" . $date . ""; print "" . $ref . ""; print ""; - $accountoshow = length_accounta($k); - if (empty($accountoshow) || $accountoshow == 'NotDefined') - { - print ''.$langs->trans("ThirdpartyAccountNotDefined").''; - } - else print $accountoshow; + $accountoshow = length_accounta($k); + if (empty($accountoshow) || $accountoshow == 'NotDefined') + { + print ''.$langs->trans("ThirdpartyAccountNotDefined").''; + } + else print $accountoshow; print ""; print "" . $reflabel . ' ' . $val['soclib'] . ""; print "" . $val["type_payment"] . ""; @@ -968,10 +968,10 @@ if (empty($action) || $action == 'view') { print "" . $date . ""; print "" . $ref . ""; print ""; - if (empty($accountoshow) || $accountoshow == 'NotDefined') - { - print ''.$langs->trans("WaitAccountNotDefined").''; - } + if (empty($accountoshow) || $accountoshow == 'NotDefined') + { + print ''.$langs->trans("WaitAccountNotDefined").''; + } else print length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE); print ""; print "" . $reflabel . ""; diff --git a/htdocs/accountancy/journal/expensereportsjournal.php b/htdocs/accountancy/journal/expensereportsjournal.php index 0b6f0923e13..557218a0ee6 100644 --- a/htdocs/accountancy/journal/expensereportsjournal.php +++ b/htdocs/accountancy/journal/expensereportsjournal.php @@ -22,13 +22,11 @@ */ /** - * \file htdocs/accountancy/journal/expensereportsjournal.php - * \ingroup Advanced accountancy - * \brief Page with expense reports journal + * \file htdocs/accountancy/journal/expensereportsjournal.php + * \ingroup Advanced accountancy + * \brief Page with expense reports journal */ require '../../main.inc.php'; - -// Class require_once DOL_DOCUMENT_ROOT . '/core/lib/report.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; @@ -38,7 +36,6 @@ require_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php'; require_once DOL_DOCUMENT_ROOT . '/user/class/user.class.php'; require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php'; -// Langs $langs->load("compta"); $langs->load("bills"); $langs->load("other"); @@ -46,8 +43,8 @@ $langs->load("main"); $langs->load("accountancy"); $langs->load("trips"); -// Multi journal $id_journal = GETPOST('id_journal', 'int'); +$action = GETPOST('action','aZ09'); $date_startmonth = GETPOST('date_startmonth'); $date_startday = GETPOST('date_startday'); @@ -62,16 +59,15 @@ $now = dol_now(); if ($user->societe_id > 0) accessforbidden(); -$action = GETPOST('action','aZ09'); - - /* * Actions */ -// Get code of finance journal + +// Get informations of journal $accountingjournalstatic = new AccountingJournal($db); $accountingjournalstatic->fetch($id_journal); $journal = $accountingjournalstatic->code; +$journal_label = $accountingjournalstatic->label; $year_current = strftime("%Y", dol_now()); $pastmonth = strftime("%m", dol_now()) - 1; @@ -187,6 +183,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->debit = ($mt <= 0) ? $mt : 0; $bookkeeping->credit = ($mt > 0) ? $mt : 0; $bookkeeping->code_journal = $journal; + $bookkeeping->journal_label = $journal_label; $bookkeeping->fk_user_author = $user->id; $result = $bookkeeping->create($user); @@ -233,6 +230,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->debit = ($mt > 0) ? $mt : 0; $bookkeeping->credit = ($mt <= 0) ? $mt : 0; $bookkeeping->code_journal = $journal; + $bookkeeping->journal_label = $journal_label; $bookkeeping->fk_user_author = $user->id; $result = $bookkeeping->create($user); @@ -277,6 +275,7 @@ if ($action == 'writebookkeeping') { $bookkeeping->debit = ($mt > 0) ? $mt : 0; $bookkeeping->credit = ($mt <= 0) ? $mt : 0; $bookkeeping->code_journal = $journal; + $bookkeeping->journal_label = $journal_label; $bookkeeping->fk_user_author = $user->id; $result = $bookkeeping->create($user); @@ -444,7 +443,7 @@ if (empty($action) || $action == 'view') { llxHeader('', $langs->trans("ExpenseReportsJournal")); - $nom = $langs->trans("ExpenseReportsJournal"); + $nom = $langs->trans("ExpenseReportsJournal") . ' - ' . $accountingjournalstatic->getNomUrl(1); $nomlink = ''; $periodlink = ''; $exportlink = ''; diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index a8dd976ba9e..3729860d29d 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -1,11 +1,11 @@ - * Copyright (C) 2007-2010 Jean Heimburger - * Copyright (C) 2011 Juanjo Menent - * Copyright (C) 2012 Regis Houssin - * Copyright (C) 2013-2015 Alexandre Spangaro +/* Copyright (C) 2007-2010 Laurent Destailleur + * Copyright (C) 2007-2010 Jean Heimburger + * Copyright (C) 2011 Juanjo Menent + * Copyright (C) 2012 Regis Houssin + * Copyright (C) 2013-2015 Alexandre Spangaro * Copyright (C) 2013-2016 Olivier Geffroy - * Copyright (C) 2013-2016 Florian Henry + * Copyright (C) 2013-2016 Florian Henry * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,28 +22,29 @@ */ /** - * \file htdocs/accountancy/journal/purchasesjournal.php - * \ingroup Advanced accountancy - * \brief Page with purchases journal + * \file htdocs/accountancy/journal/purchasesjournal.php + * \ingroup Advanced accountancy + * \brief Page with purchases journal */ require '../../main.inc.php'; - -// Class require_once DOL_DOCUMENT_ROOT . '/core/lib/report.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php'; +require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php'; require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php'; require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.class.php'; require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php'; -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php'; -// Langs $langs->load("compta"); $langs->load("bills"); $langs->load("other"); $langs->load("main"); $langs->load("accountancy"); +$id_journal = GETPOST('id_journal', 'int'); +$action = GETPOST('action','aZ09'); + $date_startmonth = GETPOST('date_startmonth'); $date_startday = GETPOST('date_startday'); $date_startyear = GETPOST('date_startyear'); @@ -57,13 +58,16 @@ $now = dol_now(); if ($user->societe_id > 0) accessforbidden(); -$action = GETPOST('action','aZ09'); - - /* * Actions */ +// Get informations of journal +$accountingjournalstatic = new AccountingJournal($db); +$accountingjournalstatic->fetch($id_journal); +$journal = $accountingjournalstatic->code; +$journal_label = $accountingjournalstatic->label; + $year_current = strftime("%Y", dol_now()); $pastmonth = strftime("%m", dol_now()) - 1; $pastmonthyear = $year_current; @@ -148,11 +152,11 @@ if ($result) { $tabfac[$obj->rowid]["type"] = $obj->type; $tabfac[$obj->rowid]["description"] = $obj->description; //$tabfac[$obj->rowid]["fk_facturefourndet"] = $obj->fdid; - - // Avoid warnings - if (! isset($tabttc[$obj->rowid][$compta_soc])) $tabttc[$obj->rowid][$compta_soc] = 0; - if (! isset($tabht[$obj->rowid][$compta_prod])) $tabht[$obj->rowid][$compta_prod] = 0; - if (! isset($tabtva[$obj->rowid][$compta_tva])) $tabtva[$obj->rowid][$compta_tva] = 0; + + // Avoid warnings + if (! isset($tabttc[$obj->rowid][$compta_soc])) $tabttc[$obj->rowid][$compta_soc] = 0; + if (! isset($tabht[$obj->rowid][$compta_prod])) $tabht[$obj->rowid][$compta_prod] = 0; + if (! isset($tabtva[$obj->rowid][$compta_tva])) $tabtva[$obj->rowid][$compta_tva] = 0; $tabttc[$obj->rowid][$compta_soc] += $obj->total_ttc; $tabht[$obj->rowid][$compta_prod] += $obj->total_ht; @@ -177,10 +181,10 @@ if ($action == 'writebookkeeping') { foreach ($tabfac as $key => $val) // Loop on each invoice { - $errorforline = 0; - - $db->begin(); - + $errorforline = 0; + + $db->begin(); + $companystatic = new Societe($db); $invoicestatic = new FactureFournisseur($db); @@ -198,160 +202,161 @@ if ($action == 'writebookkeeping') { $companystatic->code_fournisseur = $tabcompany[$key]['code_fournisseur']; $companystatic->client = $tabcompany[$key]['code_client']; - if (! $errorforline) - { - foreach ( $tabttc[$key] as $k => $mt ) { - // get compte id and label - if ($mt) { - $bookkeeping = new BookKeeping($db); - $bookkeeping->doc_date = $val["date"]; - $bookkeeping->doc_ref = $val["ref"]; - $bookkeeping->date_create = $now; - $bookkeeping->doc_type = 'supplier_invoice'; - $bookkeeping->fk_doc = $key; - $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add - $bookkeeping->code_tiers = $tabcompany[$key]['code_fournisseur']; - $bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("Code_tiers"); - $bookkeeping->numero_compte = $tabcompany[$key]['code_compta_fournisseur']; - $bookkeeping->montant = $mt; - $bookkeeping->sens = ($mt >= 0) ? 'C' : 'D'; - $bookkeeping->debit = ($mt <= 0) ? $mt : 0; - $bookkeeping->credit = ($mt > 0) ? $mt : 0; - $bookkeeping->code_journal = $conf->global->ACCOUNTING_PURCHASE_JOURNAL; - $bookkeeping->fk_user_author = $user->id; - - $result = $bookkeeping->create($user); - if ($result < 0) { - if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists - { - $error++; - $errorforline++; - //setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->doc_ref.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); - } - else - { - $error++; - $errorforline++; - setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); - } - } - } - } - } - + if (! $errorforline) + { + foreach ( $tabttc[$key] as $k => $mt ) { + // get compte id and label + if ($mt) { + $bookkeeping = new BookKeeping($db); + $bookkeeping->doc_date = $val["date"]; + $bookkeeping->doc_ref = $val["ref"]; + $bookkeeping->date_create = $now; + $bookkeeping->doc_type = 'supplier_invoice'; + $bookkeeping->fk_doc = $key; + $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add + $bookkeeping->code_tiers = $tabcompany[$key]['code_fournisseur']; + $bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("Code_tiers"); + $bookkeeping->numero_compte = $tabcompany[$key]['code_compta_fournisseur']; + $bookkeeping->montant = $mt; + $bookkeeping->sens = ($mt >= 0) ? 'C' : 'D'; + $bookkeeping->debit = ($mt <= 0) ? $mt : 0; + $bookkeeping->credit = ($mt > 0) ? $mt : 0; + $bookkeeping->code_journal = $journal; + $bookkeeping->journal_label = $journal_label; + $bookkeeping->fk_user_author = $user->id; + + $result = $bookkeeping->create($user); + if ($result < 0) { + if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists + { + $error++; + $errorforline++; + //setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->doc_ref.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); + } + else + { + $error++; + $errorforline++; + setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); + } + } + } + } + } + // Product / Service - if (! $errorforline) - { - foreach ( $tabht[$key] as $k => $mt ) { - $accountingaccount = new AccountingAccount($db); - $accountingaccount->fetch(null, $k, true); - if ($mt) { - // get compte id and label - $accountingaccount = new AccountingAccount($db); - if ($accountingaccount->fetch(null, $k, true)) { - $bookkeeping = new BookKeeping($db); - $bookkeeping->doc_date = $val["date"]; - $bookkeeping->doc_ref = $val["ref"]; - $bookkeeping->date_create = $now; - $bookkeeping->doc_type = 'supplier_invoice'; - $bookkeeping->fk_doc = $key; - $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add - $bookkeeping->code_tiers = ''; - $bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $accountingaccount->label; - $bookkeeping->numero_compte = $k; - $bookkeeping->montant = $mt; - $bookkeeping->sens = ($mt < 0) ? 'C' : 'D'; - $bookkeeping->debit = ($mt > 0) ? $mt : 0; - $bookkeeping->credit = ($mt <= 0) ? $mt : 0; - $bookkeeping->code_journal = $conf->global->ACCOUNTING_PURCHASE_JOURNAL; - $bookkeeping->fk_user_author = $user->id; - - $result = $bookkeeping->create($user); - if ($result < 0) { - if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists - { - $error++; - $errorforline++; - //setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->doc_ref.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); - } - else - { - $error++; - $errorforline++; - setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); - } - } - } - } - } - } - + if (! $errorforline) + { + foreach ( $tabht[$key] as $k => $mt ) { + $accountingaccount = new AccountingAccount($db); + $accountingaccount->fetch(null, $k, true); + if ($mt) { + // get compte id and label + $accountingaccount = new AccountingAccount($db); + if ($accountingaccount->fetch(null, $k, true)) { + $bookkeeping = new BookKeeping($db); + $bookkeeping->doc_date = $val["date"]; + $bookkeeping->doc_ref = $val["ref"]; + $bookkeeping->date_create = $now; + $bookkeeping->doc_type = 'supplier_invoice'; + $bookkeeping->fk_doc = $key; + $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add + $bookkeeping->code_tiers = ''; + $bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $accountingaccount->label; + $bookkeeping->numero_compte = $k; + $bookkeeping->montant = $mt; + $bookkeeping->sens = ($mt < 0) ? 'C' : 'D'; + $bookkeeping->debit = ($mt > 0) ? $mt : 0; + $bookkeeping->credit = ($mt <= 0) ? $mt : 0; + $bookkeeping->code_journal = $journal; + $bookkeeping->journal_label = $journal_label; + $bookkeeping->fk_user_author = $user->id; + + $result = $bookkeeping->create($user); + if ($result < 0) { + if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists + { + $error++; + $errorforline++; + //setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->doc_ref.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); + } + else + { + $error++; + $errorforline++; + setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); + } + } + } + } + } + } + // VAT // var_dump($tabtva); - if (! $errorforline) - { - foreach ( $tabtva[$key] as $k => $mt ) { - if ($mt) { - // get compte id and label - $bookkeeping = new BookKeeping($db); - $bookkeeping->doc_date = $val["date"]; - $bookkeeping->doc_ref = $val["ref"]; - $bookkeeping->date_create = $now; - $bookkeeping->doc_type = 'supplier_invoice'; - $bookkeeping->fk_doc = $key; - $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add - $bookkeeping->code_tiers = ''; - $bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("VAT"). ' '.$def_tva[$key]; - $bookkeeping->numero_compte = $k; - $bookkeeping->montant = $mt; - $bookkeeping->sens = ($mt < 0) ? 'C' : 'D'; - $bookkeeping->debit = ($mt > 0) ? $mt : 0; - $bookkeeping->credit = ($mt <= 0) ? $mt : 0; - $bookkeeping->code_journal = $conf->global->ACCOUNTING_PURCHASE_JOURNAL; - $bookkeeping->fk_user_author = $user->id; - - $result = $bookkeeping->create($user); - if ($result < 0) { - if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists - { - $error++; - $errorforline++; - //setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->doc_ref.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); - } - else - { - $error++; - $errorforline++; - setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); - } - } - } - } - } + if (! $errorforline) + { + foreach ( $tabtva[$key] as $k => $mt ) { + if ($mt) { + // get compte id and label + $bookkeeping = new BookKeeping($db); + $bookkeeping->doc_date = $val["date"]; + $bookkeeping->doc_ref = $val["ref"]; + $bookkeeping->date_create = $now; + $bookkeeping->doc_type = 'supplier_invoice'; + $bookkeeping->fk_doc = $key; + $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add + $bookkeeping->code_tiers = ''; + $bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("VAT"). ' '.$def_tva[$key]; + $bookkeeping->numero_compte = $k; + $bookkeeping->montant = $mt; + $bookkeeping->sens = ($mt < 0) ? 'C' : 'D'; + $bookkeeping->debit = ($mt > 0) ? $mt : 0; + $bookkeeping->credit = ($mt <= 0) ? $mt : 0; + $bookkeeping->code_journal = $journal; + $bookkeeping->journal_label = $journal_label; + $bookkeeping->fk_user_author = $user->id; + + $result = $bookkeeping->create($user); + if ($result < 0) { + if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists + { + $error++; + $errorforline++; + //setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->doc_ref.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); + } + else + { + $error++; + $errorforline++; + setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); + } + } + } + } + } if (! $errorforline) { - $db->commit(); + $db->commit(); } else { - $db->rollback(); + $db->rollback(); } - } if (empty($error) && count($tabpay)) { - setEventMessages($langs->trans("GeneralLedgerIsWritten"), null, 'mesgs'); + setEventMessages($langs->trans("GeneralLedgerIsWritten"), null, 'mesgs'); } elseif (count($tabpay) == $error) { - setEventMessages($langs->trans("NoNewRecordSaved"), null, 'warnings'); + setEventMessages($langs->trans("NoNewRecordSaved"), null, 'warnings'); } else { - setEventMessages($langs->trans("GeneralLedgerSomeRecordWasNotRecorded"), null, 'warnings'); + setEventMessages($langs->trans("GeneralLedgerSomeRecordWasNotRecorded"), null, 'warnings'); } - $action=''; } @@ -488,7 +493,7 @@ if (empty($action) || $action == 'view') { llxHeader('', $langs->trans("PurchasesJournal")); - $nom = $langs->trans("PurchasesJournal"); + $nom = $langs->trans("PurchasesJournal") . ' - ' . $accountingjournalstatic->getNomUrl(1); $nomlink = ''; $periodlink = ''; $exportlink = ''; @@ -502,8 +507,10 @@ if (empty($action) || $action == 'view') { } $period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1); - - journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => '')); + + $varlink = 'id_journal=' . $id_journal; + + journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => ''), '', $varlink); /*if ($conf->global->ACCOUNTING_EXPORT_MODELCSV != 1 && $conf->global->ACCOUNTING_EXPORT_MODELCSV != 2) { print ''; @@ -511,21 +518,21 @@ if (empty($action) || $action == 'view') { print ''; }*/ - print '
'; + print '
'; print ''; - print '
'; - + print '
'; + print ' '; @@ -537,7 +544,6 @@ if (empty($action) || $action == 'view') { $i = 0; print ""; print ""; - // /print ""; print ""; print ""; print ""; @@ -574,12 +580,12 @@ if (empty($action) || $action == 'view') { print ""; print ""; print ""; $companystatic->id = $tabcompany[$key]['id']; $companystatic->name = $tabcompany[$key]['name']; @@ -590,6 +596,7 @@ if (empty($action) || $action == 'view') { print ""; } } + // VAT foreach ( $tabtva[$key] as $k => $mt ) { if ($mt) { @@ -598,12 +605,12 @@ if (empty($action) || $action == 'view') { print ""; print ""; print ""; print ""; print '"; @@ -614,9 +621,9 @@ if (empty($action) || $action == 'view') { // Third party foreach ( $tabttc[$key] as $k => $mt ) { - print ''; - print ""; - print ""; + print ''; + print ""; + print ""; print ""; $companystatic->id = $tabcompany[$key]['id']; $companystatic->name = $tabcompany[$key]['name']; @@ -624,10 +631,10 @@ if (empty($action) || $action == 'view') { $accountoshow = length_accounta($k); if (empty($accountoshow) || $accountoshow == 'NotDefined') { - print ''.$langs->trans("ThirdpartyAccountNotDefined").''; + print ''.$langs->trans("ThirdpartyAccountNotDefined").''; } else print $accountoshow; - print ""; + print ""; print ""; // print ""; print ""; print ""; - print ""; + print ""; } // Product / Service @@ -609,12 +619,12 @@ if (empty($action) || $action == 'view') { print ""; print ""; print ""; // print ""; print ""; @@ -632,12 +642,12 @@ if (empty($action) || $action == 'view') { print ""; print ""; print ""; print ""; // print ""; diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 1234f75e059..81aa2c7c6ad 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -96,7 +96,7 @@ if ($id > 0) // Define variables to know what current user can do on properties of user linked to edited member if ($object->user_id) { - // $ User is the user who edits, $ object->user_id is the id of the related user in the edited member + // $ User is the user who edits, $ object->user_id is the id of the related user in the edited member $caneditfielduser=((($user->id == $object->user_id) && $user->rights->user->self->creer) || (($user->id != $object->user_id) && $user->rights->user->user->creer)); $caneditpassworduser=((($user->id == $object->user_id) && $user->rights->user->self->password) @@ -213,7 +213,7 @@ if (empty($reshook)) { if ($result > 0) { - // User creation + // User creation $company = new Societe($db); $result=$company->create_from_member($object,GETPOST('companyname')); @@ -714,7 +714,7 @@ if (empty($reshook)) } } } - + // Actions to build doc $upload_dir = $conf->adherent->dir_output; $permissioncreate=$user->rights->adherent->creer; @@ -834,7 +834,7 @@ else print ''; print ''; } - + // Type print ''; - } - - // Login Dolibarr - print ''; - */ print ''; print "
".$langs->trans("JournalNum")."" . $langs->trans("Date") . "" . $langs->trans("Piece") . ' (' . $langs->trans("InvoiceRef") . ")" . $date . "" . $invoicestatic->getNomUrl(1) . ""; - $accountoshow = length_accountg($k); - if (empty($accountoshow) || $accountoshow == 'NotDefined') - { - print ''.$langs->trans("ProductAccountNotDefined").''; - } - else print $accountoshow; + $accountoshow = length_accountg($k); + if (empty($accountoshow) || $accountoshow == 'NotDefined') + { + print ''.$langs->trans("ProductAccountNotDefined").''; + } + else print $accountoshow; print "
" . $date . "" . $invoicestatic->getNomUrl(1) . ""; - $accountoshow = length_accountg($k); - if (empty($accountoshow) || $accountoshow == 'NotDefined') - { - print ''.$langs->trans("VatAccountNotDefined").''; - } - else print $accountoshow; + $accountoshow = length_accountg($k); + if (empty($accountoshow) || $accountoshow == 'NotDefined') + { + print ''.$langs->trans("VatAccountNotDefined").''; + } + else print $accountoshow; print "" . $companystatic->getNomUrl(0, 'supplier', 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("VAT"). ' '.$def_tva[$key]. "' . ($mt >= 0 ? price($mt) : '') . "
" . $date . "
" . $date . "" . $invoicestatic->getNomUrl(1) . "" . $companystatic->getNomUrl(0, 'supplier', 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("Code_tiers") . "" . $langs->trans("ThirdParty"); // print ' (' . $companystatic->getNomUrl(0, 'supplier', 16) . ')'; diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index 85ce7361394..0d2e7ac19cc 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -1,13 +1,13 @@ - * Copyright (C) 2007-2010 Jean Heimburger - * Copyright (C) 2011 Juanjo Menent - * Copyright (C) 2012 Regis Houssin - * Copyright (C) 2013 Christophe Battarel - * Copyright (C) 2013-2016 Alexandre Spangaro - * Copyright (C) 2013-2016 Florian Henry - * Copyright (C) 2013-2016 Olivier Geffroy - * Copyright (C) 2014 Raphaël Doursenaud +/* Copyright (C) 2007-2010 Laurent Destailleur + * Copyright (C) 2007-2010 Jean Heimburger + * Copyright (C) 2011 Juanjo Menent + * Copyright (C) 2012 Regis Houssin + * Copyright (C) 2013 Christophe Battarel + * Copyright (C) 2013-2017 Alexandre Spangaro + * Copyright (C) 2013-2016 Florian Henry + * Copyright (C) 2013-2016 Olivier Geffroy + * Copyright (C) 2014 Raphaël Doursenaud * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -29,17 +29,15 @@ * \brief Page with sells journal */ require '../../main.inc.php'; - -// Class require_once DOL_DOCUMENT_ROOT . '/core/lib/report.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php'; +require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php'; require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT . '/societe/class/client.class.php'; require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php'; -require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php'; -// Langs $langs->load("commercial"); $langs->load("compta"); $langs->load("bills"); @@ -47,6 +45,9 @@ $langs->load("other"); $langs->load("main"); $langs->load("accountancy"); +$id_journal = GETPOST('id_journal', 'int'); +$action = GETPOST('action','aZ09'); + $date_startmonth = GETPOST('date_startmonth'); $date_startday = GETPOST('date_startday'); $date_startyear = GETPOST('date_startyear'); @@ -60,19 +61,23 @@ $now = dol_now(); if ($user->societe_id > 0) accessforbidden(); -$action = GETPOST('action','aZ09'); - /* * Actions */ +// Get informations of journal +$accountingjournalstatic = new AccountingJournal($db); +$accountingjournalstatic->fetch($id_journal); +$journal = $accountingjournalstatic->code; +$journal_label = $accountingjournalstatic->label; + $year_current = strftime("%Y", dol_now()); $pastmonth = strftime("%m", dol_now()) - 1; $pastmonthyear = $year_current; if ($pastmonth == 0) { - $pastmonth = 12; - $pastmonthyear --; + $pastmonth = 12; + $pastmonthyear --; } $date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear); @@ -80,8 +85,8 @@ $date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear); if (empty($date_start) || empty($date_end)) // We define date_start and date_end { - $date_start = dol_get_first_day($pastmonthyear, $pastmonth, false); - $date_end = dol_get_last_day($pastmonthyear, $pastmonth, false); + $date_start = dol_get_first_day($pastmonthyear, $pastmonth, false); + $date_end = dol_get_last_day($pastmonthyear, $pastmonth, false); } $p = explode(":", $conf->global->MAIN_INFO_SOCIETE_COUNTRY); @@ -99,274 +104,277 @@ $sql .= " JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture"; $sql .= " JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_tva as ct ON fd.tva_tx = ct.taux AND ct.fk_pays = '" . $idpays . "'"; $sql .= " WHERE fd.fk_code_ventilation > 0"; -$sql .= " AND f.entity IN (".getEntity('facture', 0).')'; // We don't share object for accountancy +$sql .= " AND f.entity IN (".getEntity('facture', 0).')'; // We don't share object for accountancy $sql .= " AND f.fk_statut > 0"; // TODO Facture annulée ? if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { - $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")"; + $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")"; } else { - $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_STANDARD . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")"; + $sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_STANDARD . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_DEPOSIT . "," . Facture::TYPE_SITUATION . ")"; } $sql .= " AND fd.product_type IN (0,1)"; if ($date_start && $date_end) - $sql .= " AND f.datef >= '" . $db->idate($date_start) . "' AND f.datef <= '" . $db->idate($date_end) . "'"; + $sql .= " AND f.datef >= '" . $db->idate($date_start) . "' AND f.datef <= '" . $db->idate($date_end) . "'"; $sql .= " ORDER BY f.datef"; dol_syslog('accountancy/journal/sellsjournal.php', LOG_DEBUG); $result = $db->query($sql); if ($result) { - $tabfac = array (); - $tabht = array (); - $tabtva = array (); - $def_tva = array (); - $tabttc = array (); - $tabcompany = array (); + $tabfac = array (); + $tabht = array (); + $tabtva = array (); + $def_tva = array (); + $tabttc = array (); + $tabcompany = array (); - $num = $db->num_rows($result); - $i = 0; + $num = $db->num_rows($result); + $i = 0; - $cptcli = (! empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER)) ? $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER : $langs->trans("CodeNotDef"); - - while ( $i < $num ) { - $obj = $db->fetch_object($result); - - // les variables - $compta_soc = (! empty($obj->code_compta)) ? $obj->code_compta : $cptcli; + $cptcli = (! empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER)) ? $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER : $langs->trans("CodeNotDef"); - $compta_prod = $obj->compte; - if (empty($compta_prod)) { - if ($obj->product_type == 0) - $compta_prod = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef"); - else - $compta_prod = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef"); - } - $cpttva = (! empty($conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT : $langs->trans("CodeNotDef"); - $compta_tva = (! empty($obj->account_tva) ? $obj->account_tva : $cpttva); + while ( $i < $num ) { + $obj = $db->fetch_object($result); + + // les variables + $compta_soc = (! empty($obj->code_compta)) ? $obj->code_compta : $cptcli; + + $compta_prod = $obj->compte; + if (empty($compta_prod)) { + if ($obj->product_type == 0) + $compta_prod = (! empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef"); + else + $compta_prod = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef"); + } + $cpttva = (! empty($conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_SOLD_ACCOUNT : $langs->trans("CodeNotDef"); + $compta_tva = (! empty($obj->account_tva) ? $obj->account_tva : $cpttva); - //Define array for display vat tx - $def_tva[$obj->rowid]=price($obj->tva_tx); + //Define array for display vat tx + $def_tva[$obj->rowid]=price($obj->tva_tx); - // Situation invoices handling - $line = new FactureLigne($db); - $line->fetch($obj->fdid); - $prev_progress = $line->get_prev_progress($obj->fdid); - if ($obj->type == Facture::TYPE_SITUATION) { - // Avoid divide by 0 - if ($obj->situation_percent == 0) { - $situation_ratio = 0; - } else { - $situation_ratio = ($obj->situation_percent - $prev_progress) / $obj->situation_percent; - } - } else { - $situation_ratio = 1; - } + // Situation invoices handling + $line = new FactureLigne($db); + $line->fetch($obj->fdid); + $prev_progress = $line->get_prev_progress($obj->fdid); + if ($obj->type == Facture::TYPE_SITUATION) { + // Avoid divide by 0 + if ($obj->situation_percent == 0) { + $situation_ratio = 0; + } else { + $situation_ratio = ($obj->situation_percent - $prev_progress) / $obj->situation_percent; + } + } else { + $situation_ratio = 1; + } - // Invoice lines - $tabfac[$obj->rowid]["date"] = $db->jdate($obj->df); - $tabfac[$obj->rowid]["ref"] = $obj->facnumber; - $tabfac[$obj->rowid]["type"] = $obj->type; - $tabfac[$obj->rowid]["description"] = $obj->label_compte; - //$tabfac[$obj->rowid]["fk_facturedet"] = $obj->fdid; - - // Avoid warnings - if (! isset($tabttc[$obj->rowid][$compta_soc])) $tabttc[$obj->rowid][$compta_soc] = 0; - if (! isset($tabht[$obj->rowid][$compta_prod])) $tabht[$obj->rowid][$compta_prod] = 0; - if (! isset($tabtva[$obj->rowid][$compta_tva])) $tabtva[$obj->rowid][$compta_tva] = 0; + // Invoice lines + $tabfac[$obj->rowid]["date"] = $db->jdate($obj->df); + $tabfac[$obj->rowid]["ref"] = $obj->facnumber; + $tabfac[$obj->rowid]["type"] = $obj->type; + $tabfac[$obj->rowid]["description"] = $obj->label_compte; + //$tabfac[$obj->rowid]["fk_facturedet"] = $obj->fdid; - $tabttc[$obj->rowid][$compta_soc] += $obj->total_ttc * $situation_ratio; - $tabht[$obj->rowid][$compta_prod] += $obj->total_ht * $situation_ratio; - $tabtva[$obj->rowid][$compta_tva] += $obj->total_tva * $situation_ratio; - $tabcompany[$obj->rowid] = array ( - 'id' => $obj->socid, - 'name' => $obj->name, - 'code_client' => $obj->code_client, - 'code_compta' => $compta_soc - ); + // Avoid warnings + if (! isset($tabttc[$obj->rowid][$compta_soc])) $tabttc[$obj->rowid][$compta_soc] = 0; + if (! isset($tabht[$obj->rowid][$compta_prod])) $tabht[$obj->rowid][$compta_prod] = 0; + if (! isset($tabtva[$obj->rowid][$compta_tva])) $tabtva[$obj->rowid][$compta_tva] = 0; - $i ++; - } + $tabttc[$obj->rowid][$compta_soc] += $obj->total_ttc * $situation_ratio; + $tabht[$obj->rowid][$compta_prod] += $obj->total_ht * $situation_ratio; + $tabtva[$obj->rowid][$compta_tva] += $obj->total_tva * $situation_ratio; + $tabcompany[$obj->rowid] = array ( + 'id' => $obj->socid, + 'name' => $obj->name, + 'code_client' => $obj->code_client, + 'code_compta' => $compta_soc + ); + + $i ++; + } } else { - dol_print_error($db); + dol_print_error($db); } // Bookkeeping Write if ($action == 'writebookkeeping') { - $now = dol_now(); - $error = 0; + $now = dol_now(); + $error = 0; - foreach ( $tabfac as $key => $val ) { // Loop on each invoice - - $errorforline = 0; + foreach ( $tabfac as $key => $val ) { // Loop on each invoice - $db->begin(); + $errorforline = 0; - $companystatic = new Societe($db); - $invoicestatic = new Facture($db); + $db->begin(); - $companystatic->id = $tabcompany[$key]['id']; - $companystatic->name = $tabcompany[$key]['name']; + $companystatic = new Societe($db); + $invoicestatic = new Facture($db); + + $companystatic->id = $tabcompany[$key]['id']; + $companystatic->name = $tabcompany[$key]['name']; $companystatic->code_compta = $tabcompany[$key]['code_compta']; $companystatic->code_compta_fournisseur = $tabcompany[$key]['code_compta_fournisseur']; $companystatic->code_client = $tabcompany[$key]['code_client']; $companystatic->code_fournisseur = $tabcompany[$key]['code_fournisseur']; - $companystatic->client = $tabcompany[$key]['code_client']; + $companystatic->client = $tabcompany[$key]['code_client']; - $invoicestatic->id = $key; - $invoicestatic->ref = (string) $val["ref"]; + $invoicestatic->id = $key; + $invoicestatic->ref = (string) $val["ref"]; - // Thirdparty - if (! $errorforline) - { - foreach ( $tabttc[$key] as $k => $mt ) { - if ($mt) { - $bookkeeping = new BookKeeping($db); - $bookkeeping->doc_date = $val["date"]; - $bookkeeping->doc_ref = $val["ref"]; - $bookkeeping->date_create = $now; - $bookkeeping->doc_type = 'customer_invoice'; - $bookkeeping->fk_doc = $key; - $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add - $bookkeeping->code_tiers = $tabcompany[$key]['code_client']; - $bookkeeping->numero_compte = $tabcompany[$key]['code_compta']; - // $bookkeeping->label_compte = $tabcompany[$key]['name']; - $bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers"); - $bookkeeping->montant = $mt; - $bookkeeping->sens = ($mt >= 0) ? 'D' : 'C'; - $bookkeeping->debit = ($mt >= 0) ? $mt : 0; - $bookkeeping->credit = ($mt < 0) ? $mt : 0; - $bookkeeping->code_journal = $conf->global->ACCOUNTING_SELL_JOURNAL; - $bookkeeping->fk_user_author = $user->id; - - $result = $bookkeeping->create($user); - if ($result < 0) { - if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists - { - $error++; - $errorforline++; - //setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->doc_ref.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); - } - else - { - $error++; - $errorforline++; - setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); - } - } - } - } - } - - // Product / Service - if (! $errorforline) - { - foreach ( $tabht[$key] as $k => $mt ) { - if ($mt) { - // get compte id and label - $accountingaccount = new AccountingAccount($db); - if ($accountingaccount->fetch(null, $k, true)) { - $bookkeeping = new BookKeeping($db); - $bookkeeping->doc_date = $val["date"]; - $bookkeeping->doc_ref = $val["ref"]; - $bookkeeping->date_create = $now; - $bookkeeping->doc_type = 'customer_invoice'; - $bookkeeping->fk_doc = $key; - $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add; - $bookkeeping->code_tiers = ''; - $bookkeeping->numero_compte = $k; - $bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $accountingaccount->label; - $bookkeeping->montant = $mt; - $bookkeeping->sens = ($mt < 0) ? 'D' : 'C'; - $bookkeeping->debit = ($mt < 0) ? $mt : 0; - $bookkeeping->credit = ($mt >= 0) ? $mt : 0; - $bookkeeping->code_journal = $conf->global->ACCOUNTING_SELL_JOURNAL; - $bookkeeping->fk_user_author = $user->id; - - $result = $bookkeeping->create($user); - if ($result < 0) { - if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists - { - $error++; - $errorforline++; - //setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->doc_ref.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); - } - else - { - $error++; - $errorforline++; - setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); - } - } - } - } - } - } - - // VAT - // var_dump($tabtva); - if (! $errorforline) - { - foreach ( $tabtva[$key] as $k => $mt ) { - if ($mt) { - $bookkeeping = new BookKeeping($db); - $bookkeeping->doc_date = $val["date"]; - $bookkeeping->doc_ref = $val["ref"]; - $bookkeeping->date_create = $now; - $bookkeeping->doc_type = 'customer_invoice'; - $bookkeeping->fk_doc = $key; - $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add - $bookkeeping->code_tiers = ''; - $bookkeeping->numero_compte = $k; - $bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT").' '.$def_tva[$key]; - $bookkeeping->montant = $mt; - $bookkeeping->sens = ($mt < 0) ? 'D' : 'C'; - $bookkeeping->debit = ($mt < 0) ? $mt : 0; - $bookkeeping->credit = ($mt >= 0) ? $mt : 0; - $bookkeeping->code_journal = $conf->global->ACCOUNTING_SELL_JOURNAL; - $bookkeeping->fk_user_author = $user->id; - - $result = $bookkeeping->create($user); - if ($result < 0) { - if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists - { - $error++; - $errorforline++; - //setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->doc_ref.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); - } - else - { - $error++; - $errorforline++; - setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); - } - } - } - } - } + // Thirdparty + if (! $errorforline) + { + foreach ( $tabttc[$key] as $k => $mt ) { + if ($mt) { + $bookkeeping = new BookKeeping($db); + $bookkeeping->doc_date = $val["date"]; + $bookkeeping->doc_ref = $val["ref"]; + $bookkeeping->date_create = $now; + $bookkeeping->doc_type = 'customer_invoice'; + $bookkeeping->fk_doc = $key; + $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add + $bookkeeping->code_tiers = $tabcompany[$key]['code_client']; + $bookkeeping->numero_compte = $tabcompany[$key]['code_compta']; + // $bookkeeping->label_compte = $tabcompany[$key]['name']; + $bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers"); + $bookkeeping->montant = $mt; + $bookkeeping->sens = ($mt >= 0) ? 'D' : 'C'; + $bookkeeping->debit = ($mt >= 0) ? $mt : 0; + $bookkeeping->credit = ($mt < 0) ? $mt : 0; + $bookkeeping->code_journal = $journal; + $bookkeeping->journal_label = $journal_label; + $bookkeeping->fk_user_author = $user->id; - if (! $errorforline) - { - $db->commit(); - } - else - { - $db->rollback(); - } + $result = $bookkeeping->create($user); + if ($result < 0) { + if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists + { + $error++; + $errorforline++; + //setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->doc_ref.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); + } + else + { + $error++; + $errorforline++; + setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); + } + } + } + } + } - } + // Product / Service + if (! $errorforline) + { + foreach ( $tabht[$key] as $k => $mt ) { + if ($mt) { + // get compte id and label + $accountingaccount = new AccountingAccount($db); + if ($accountingaccount->fetch(null, $k, true)) { + $bookkeeping = new BookKeeping($db); + $bookkeeping->doc_date = $val["date"]; + $bookkeeping->doc_ref = $val["ref"]; + $bookkeeping->date_create = $now; + $bookkeeping->doc_type = 'customer_invoice'; + $bookkeeping->fk_doc = $key; + $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add; + $bookkeeping->code_tiers = ''; + $bookkeeping->numero_compte = $k; + $bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $accountingaccount->label; + $bookkeeping->montant = $mt; + $bookkeeping->sens = ($mt < 0) ? 'D' : 'C'; + $bookkeeping->debit = ($mt < 0) ? $mt : 0; + $bookkeeping->credit = ($mt >= 0) ? $mt : 0; + $bookkeeping->code_journal = $journal; + $bookkeeping->journal_label = $journal_label; + $bookkeeping->fk_user_author = $user->id; - if (empty($error) && count($tabpay) > 0) { - setEventMessages($langs->trans("GeneralLedgerIsWritten"), null, 'mesgs'); - } - elseif (count($tabpay) == $error) - { - setEventMessages($langs->trans("NoNewRecordSaved"), null, 'warnings'); - } - else - { - setEventMessages($langs->trans("GeneralLedgerSomeRecordWasNotRecorded"), null, 'warnings'); - } - - $action=''; + $result = $bookkeeping->create($user); + if ($result < 0) { + if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists + { + $error++; + $errorforline++; + //setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->doc_ref.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); + } + else + { + $error++; + $errorforline++; + setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); + } + } + } + } + } + } + + // VAT + // var_dump($tabtva); + if (! $errorforline) + { + foreach ( $tabtva[$key] as $k => $mt ) { + if ($mt) { + $bookkeeping = new BookKeeping($db); + $bookkeeping->doc_date = $val["date"]; + $bookkeeping->doc_ref = $val["ref"]; + $bookkeeping->date_create = $now; + $bookkeeping->doc_type = 'customer_invoice'; + $bookkeeping->fk_doc = $key; + $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add + $bookkeeping->code_tiers = ''; + $bookkeeping->numero_compte = $k; + $bookkeeping->label_compte = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT").' '.$def_tva[$key]; + $bookkeeping->montant = $mt; + $bookkeeping->sens = ($mt < 0) ? 'D' : 'C'; + $bookkeeping->debit = ($mt < 0) ? $mt : 0; + $bookkeeping->credit = ($mt >= 0) ? $mt : 0; + $bookkeeping->code_journal = $journal; + $bookkeeping->journal_label = $journal_label; + $bookkeeping->fk_user_author = $user->id; + + $result = $bookkeeping->create($user); + if ($result < 0) { + if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') // Already exists + { + $error++; + $errorforline++; + //setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->doc_ref.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); + } + else + { + $error++; + $errorforline++; + setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); + } + } + } + } + } + + if (! $errorforline) + { + $db->commit(); + } + else + { + $db->rollback(); + } + + } + + if (empty($error) && count($tabpay) > 0) { + setEventMessages($langs->trans("GeneralLedgerIsWritten"), null, 'mesgs'); + } + elseif (count($tabpay) == $error) + { + setEventMessages($langs->trans("NoNewRecordSaved"), null, 'warnings'); + } + else + { + setEventMessages($langs->trans("GeneralLedgerSomeRecordWasNotRecorded"), null, 'warnings'); + } + + $action=''; } @@ -380,123 +388,123 @@ $form = new Form($db); // Export /*if ($action == 'export_csv') { - $sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV; - $sell_journal = $conf->global->ACCOUNTING_SELL_JOURNAL; + $sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV; + $sell_journal = $conf->global->ACCOUNTING_SELL_JOURNAL; - include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php'; + include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php'; - $companystatic = new Client($db); + $companystatic = new Client($db); - // Model Cegid Expert Export - if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 2) { - $sep = ";"; + // Model Cegid Expert Export + if ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 2) { + $sep = ";"; - foreach ( $tabfac as $key => $val ) { - $companystatic->id = $tabcompany[$key]['id']; - $companystatic->name = $tabcompany[$key]['name']; - $companystatic->client = $tabcompany[$key]['code_client']; + foreach ( $tabfac as $key => $val ) { + $companystatic->id = $tabcompany[$key]['id']; + $companystatic->name = $tabcompany[$key]['name']; + $companystatic->client = $tabcompany[$key]['code_client']; - $invoicestatic->id = $key; - $invoicestatic->ref = $val["ref"]; + $invoicestatic->id = $key; + $invoicestatic->ref = $val["ref"]; - $date = dol_print_date($val["date"], '%d%m%Y'); + $date = dol_print_date($val["date"], '%d%m%Y'); - foreach ( $tabttc[$key] as $k => $mt ) { - print $date . $sep; - print $sell_journal . $sep; - print length_accountg($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) . $sep; - print length_accounta(html_entity_decode($k)) . $sep; - print ($mt < 0 ? 'C' : 'D') . $sep; - print ($mt <= 0 ? price(- $mt) : $mt) . $sep; - print dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers") . $sep; - print $val["ref"]; - print "\n"; - } + foreach ( $tabttc[$key] as $k => $mt ) { + print $date . $sep; + print $sell_journal . $sep; + print length_accountg($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) . $sep; + print length_accounta(html_entity_decode($k)) . $sep; + print ($mt < 0 ? 'C' : 'D') . $sep; + print ($mt <= 0 ? price(- $mt) : $mt) . $sep; + print dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers") . $sep; + print $val["ref"]; + print "\n"; + } - // Product / Service - foreach ( $tabht[$key] as $k => $mt ) { - $accountingaccount_static = new AccountingAccount($db); - if ($accountingaccount_static->fetch(null, $k, true)) { - print $date . $sep; - print $sell_journal . $sep; - print length_accountg(html_entity_decode($k)) . $sep; - print $sep; - print ($mt < 0 ? 'D' : 'C') . $sep; - print ($mt <= 0 ? price(- $mt) : $mt) . $sep; - print dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $accountingaccount_static->label . $sep; - print $val["ref"]; - print "\n"; - } - } + // Product / Service + foreach ( $tabht[$key] as $k => $mt ) { + $accountingaccount_static = new AccountingAccount($db); + if ($accountingaccount_static->fetch(null, $k, true)) { + print $date . $sep; + print $sell_journal . $sep; + print length_accountg(html_entity_decode($k)) . $sep; + print $sep; + print ($mt < 0 ? 'D' : 'C') . $sep; + print ($mt <= 0 ? price(- $mt) : $mt) . $sep; + print dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $accountingaccount_static->label . $sep; + print $val["ref"]; + print "\n"; + } + } - // TVA - foreach ( $tabtva[$key] as $k => $mt ) { - if ($mt) { - print $date . $sep; - print $sell_journal . $sep; - print length_accountg(html_entity_decode($k)) . $sep; - print $sep; - print ($mt < 0 ? 'D' : 'C') . $sep; - print ($mt <= 0 ? price(- $mt) : $mt) . $sep; - print dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT") . $sep; - // print $langs->trans("VAT") . $sep; - print $val["ref"]; - print "\n"; - } - } - } - } elseif ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 1) { - // Model Classic Export - foreach ( $tabfac as $key => $val ) { - $companystatic->id = $tabcompany[$key]['id']; - $companystatic->name = $tabcompany[$key]['name']; - $companystatic->client = $tabcompany[$key]['code_client']; + // TVA + foreach ( $tabtva[$key] as $k => $mt ) { + if ($mt) { + print $date . $sep; + print $sell_journal . $sep; + print length_accountg(html_entity_decode($k)) . $sep; + print $sep; + print ($mt < 0 ? 'D' : 'C') . $sep; + print ($mt <= 0 ? price(- $mt) : $mt) . $sep; + print dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT") . $sep; + // print $langs->trans("VAT") . $sep; + print $val["ref"]; + print "\n"; + } + } + } + } elseif ($conf->global->ACCOUNTING_EXPORT_MODELCSV == 1) { + // Model Classic Export + foreach ( $tabfac as $key => $val ) { + $companystatic->id = $tabcompany[$key]['id']; + $companystatic->name = $tabcompany[$key]['name']; + $companystatic->client = $tabcompany[$key]['code_client']; - $invoicestatic->id = $key; - $invoicestatic->ref = $val["ref"]; + $invoicestatic->id = $key; + $invoicestatic->ref = $val["ref"]; - $date = dol_print_date($val["date"], 'day'); + $date = dol_print_date($val["date"], 'day'); - foreach ( $tabttc[$key] as $k => $mt ) { - print '"' . $date . '"' . $sep; - print '"' . $val["ref"] . '"' . $sep; - print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; - print '"' . dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers") . '"' . $sep; - print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep; - print '"' . ($mt < 0 ? price(- $mt) : '') . '"'; - print "\n"; - } + foreach ( $tabttc[$key] as $k => $mt ) { + print '"' . $date . '"' . $sep; + print '"' . $val["ref"] . '"' . $sep; + print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep; + print '"' . dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers") . '"' . $sep; + print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep; + print '"' . ($mt < 0 ? price(- $mt) : '') . '"'; + print "\n"; + } - // Product / Service - foreach ( $tabht[$key] as $k => $mt ) { - $accountingaccount = new AccountingAccount($db); - $accountingaccount->fetch(null, $k, true); + // Product / Service + foreach ( $tabht[$key] as $k => $mt ) { + $accountingaccount = new AccountingAccount($db); + $accountingaccount->fetch(null, $k, true); - if ($mt) { - print '"' . $date . '"' . $sep; - print '"' . $val["ref"] . '"' . $sep; - print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; - print '"' . dol_trunc($companystatic->name, 16) . ' - ' . dol_trunc($accountingaccount->label, 32) . '"' . $sep; - print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep; - print '"' . ($mt >= 0 ? price($mt) : '') . '"'; - print "\n"; - } - } + if ($mt) { + print '"' . $date . '"' . $sep; + print '"' . $val["ref"] . '"' . $sep; + print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; + print '"' . dol_trunc($companystatic->name, 16) . ' - ' . dol_trunc($accountingaccount->label, 32) . '"' . $sep; + print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep; + print '"' . ($mt >= 0 ? price($mt) : '') . '"'; + print "\n"; + } + } - // VAT - foreach ( $tabtva[$key] as $k => $mt ) { - if ($mt) { - print '"' . $date . '"' . $sep; - print '"' . $val["ref"] . '"' . $sep; - print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; - print '"' . dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT") . '"' . $sep; - print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep; - print '"' . ($mt >= 0 ? price($mt) : '') . '"'; - print "\n"; - } - } - } - } + // VAT + foreach ( $tabtva[$key] as $k => $mt ) { + if ($mt) { + print '"' . $date . '"' . $sep; + print '"' . $val["ref"] . '"' . $sep; + print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep; + print '"' . dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT") . '"' . $sep; + print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep; + print '"' . ($mt >= 0 ? price($mt) : '') . '"'; + print "\n"; + } + } + } + } } */ @@ -505,7 +513,7 @@ if (empty($action) || $action == 'view') { llxHeader('', $langs->trans("SellsJournal")); - $nom = $langs->trans("SellsJournal"); + $nom = $langs->trans("SellsJournal") . ' - ' . $accountingjournalstatic->getNomUrl(1); $nomlink = ''; $periodlink = ''; $exportlink = ''; @@ -517,29 +525,31 @@ if (empty($action) || $action == 'view') { else $description .= $langs->trans("DepositsAreIncluded"); $period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1); - - journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => '')); + + $varlink = 'id_journal=' . $id_journal; + + journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => ''), '', $varlink); /*if ($conf->global->ACCOUNTING_EXPORT_MODELCSV != 1 && $conf->global->ACCOUNTING_EXPORT_MODELCSV != 2) { print ''; } else { print ''; }*/ - print '
'; + print '
'; print ''; - print '
'; - + print '
'; + print ' '; @@ -586,7 +596,7 @@ if (empty($action) || $action == 'view') { $accountoshow = length_accounta($k); if (empty($accountoshow) || $accountoshow == 'NotDefined') { - print ''.$langs->trans("ThirdpartyAccountNotDefined").''; + print ''.$langs->trans("ThirdpartyAccountNotDefined").''; } else print $accountoshow; // print "
" . $langs->trans("ThirdParty"); @@ -595,7 +605,7 @@ if (empty($action) || $action == 'view') { print "" . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers") . "" . ($mt >= 0 ? price($mt) : '') . "" . ($mt < 0 ? price(- $mt) : '') . "
" . $date . "" . $invoicestatic->getNomUrl(1) . ""; - $accountoshow = length_accountg($k); - if (empty($accountoshow) || $accountoshow == 'NotDefined') - { - print ''.$langs->trans("ProductNotDefined").''; - } - else print $accountoshow; + $accountoshow = length_accountg($k); + if (empty($accountoshow) || $accountoshow == 'NotDefined') + { + print ''.$langs->trans("ProductNotDefined").''; + } + else print $accountoshow; print "" . $accountingaccount->label . "" . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref . ' - ' . $accountingaccount->label . "" . $date . "" . $invoicestatic->getNomUrl(1) . ""; - $accountoshow = length_accountg($k); - if (empty($accountoshow) || $accountoshow == 'NotDefined') - { - print ''.$langs->trans("VATAccountNotDefined").''; - } - else print $accountoshow; + $accountoshow = length_accountg($k); + if (empty($accountoshow) || $accountoshow == 'NotDefined') + { + print ''.$langs->trans("VATAccountNotDefined").''; + } + else print $accountoshow; print "" . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT") . ' '.$def_tva[$key]. "" . $langs->trans("VAT") . "
'.$langs->trans("MemberType").''; $listetype=$adht->liste_array(); @@ -948,20 +948,6 @@ else print $object->showOptionals($extrafields,'edit'); } - /* - // Third party Dolibarr - if (! empty($conf->societe->enabled)) - { - print '
'.$langs->trans("LinkedToDolibarrThirdParty").''; - print $form->select_company($object->fk_soc,'socid','',1); - print '
'.$langs->trans("LinkedToDolibarrUser").''; - print $form->select_dolusers($object->user_id, 'userid', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); - print '
\n"; @@ -1061,12 +1047,12 @@ else print ''; // Ref - print ''; + print ''; // Login if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { - print ''; + print ''; } // Password @@ -1095,7 +1081,7 @@ else print ""; // Company - print ''; + print ''; // Civility print ''; // Lastname - print ''; + print ''; print ''; // Firstname - print ''; + print ''; print ''; // Photo @@ -1131,7 +1117,7 @@ else // Address print ''; // Zip / Town @@ -1143,7 +1129,7 @@ else // Country //$object->country_id=$object->country_id?$object->country_id:$mysoc->country_id; // In edit mode we don't force to company country if not defined - print ''; @@ -1168,7 +1154,7 @@ else // Skype if (! empty($conf->skype->enabled)) { - print ''; + print ''; } // Birthday @@ -1185,7 +1171,7 @@ else if (! empty( $conf->categorie->enabled ) && !empty( $user->rights->categorie->lire )) { print ''; - print '
'.$langs->trans("Ref").''.$object->id.'
'.$langs->trans("Ref").''.$object->id.'
'.$langs->trans("Login").' / '.$langs->trans("Id").'login).'">
'.$langs->trans("Login").' / '.$langs->trans("Id").'login).'">
'.$langs->trans("Company").'societe).'">
'.$langs->trans("Company").'societe).'">
'.$langs->trans("UserTitle").''; @@ -1104,11 +1090,11 @@ else print '
'.$langs->trans("Lastname").'lastname).'">
'.$langs->trans("Lastname").'lastname).'">
'.$langs->trans("Firstname").'firstname).'">
'.$langs->trans("Firstname").'firstname).'">
'.$langs->trans("Address").''; - print ''; + print ''; print '
'.$langs->trans('Country').''; + print '
'.$langs->trans('Country').''; print $form->select_country(isset($_POST["country_id"])?$_POST["country_id"]:$object->country_id,'country_id'); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); print '
'.$langs->trans("Skype").'skype).'">
'.$langs->trans("Skype").'skype).'">
' . fieldLabel('Categories', 'memcats') . ''; + print ''; $cate_arbo = $form->select_all_categories(Categorie::TYPE_MEMBER, null, null, null, null, 1); $c = new Categorie($db); $cats = $c->containing($object->id, Categorie::TYPE_MEMBER); @@ -1197,7 +1183,7 @@ else } // Other attributes - $parameters=array("colspan"=>2); + $parameters=array(); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook if (empty($reshook) && ! empty($extrafields->attribute_label)) { @@ -1416,12 +1402,12 @@ else if (! empty($conf->societe->enabled)) $rowspan++; $linkback = ''.$langs->trans("BackToList").''; - + dol_banner_tab($object, 'rowid', $linkback); - + print '
'; print '
'; - + print '
'; print ''; @@ -1463,15 +1449,15 @@ else } print ''; } - + print '
'; - + print '
'; print '
'; - + print '
'; print ''; - + // Birthday print ''; @@ -1487,13 +1473,8 @@ else print ''; } - // Other attributes - $parameters=array('colspan'=>2); - $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook - if (empty($reshook) && ! empty($extrafields->attribute_label)) - { - print $object->showOptionals($extrafields, 'view', $parameters); - } + // Other attributes + include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; // Date end subscription print ''; - + // Third party Dolibarr if (! empty($conf->societe->enabled)) { @@ -1595,12 +1576,12 @@ else print '
'; dol_fiche_end(); - - + + /* * Hotbar */ - + print '
'; $parameters = array(); $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been @@ -1616,7 +1597,7 @@ else { print '
'.$langs->trans("Modify").'
'; } - + // Validate if ($object->statut == -1) { @@ -1629,7 +1610,7 @@ else print '
'.$langs->trans("Validate").'
'; } } - + // Reactivate if ($object->statut == 0) { @@ -1642,7 +1623,7 @@ else print '
'.$langs->trans("Reenable")."
"; } } - + // Send card by email if ($user->rights->adherent->creer) { @@ -1660,7 +1641,7 @@ else { print '
'.$langs->trans("SendCardByMail")."
"; } - + // Terminate if ($object->statut >= 1) { @@ -1673,7 +1654,7 @@ else print '
'.$langs->trans("Resiliate")."
"; } } - + // Create third party if (! empty($conf->societe->enabled) && ! $object->fk_soc) { @@ -1687,7 +1668,7 @@ else print '
'.$langs->trans("CreateDolibarrThirdParty")."
"; } } - + // Create user if (! $user->societe_id && ! $object->user_id) { @@ -1701,7 +1682,7 @@ else print '
'.$langs->trans("CreateDolibarrLogin")."
"; } } - + // Delete if ($user->rights->adherent->supprimer) { @@ -1711,12 +1692,12 @@ else { print '
'.$langs->trans("Delete")."
"; } - + // Action SPIP if (! empty($conf->mailmanspip->enabled) && ! empty($conf->global->ADHERENT_USE_SPIP)) { $isinspip = $mailmanspip->is_in_spip($object); - + if ($isinspip == 1) { print '\n"; @@ -1726,7 +1707,7 @@ else print '\n"; } } - + } } print '
'; @@ -1736,11 +1717,11 @@ else print '

'.$langs->trans('SPIPConnectionFailed').': '.$mailmanspip->error.''; } - - + + print '
'; print ''; // ancre - + // Documents generes $filename = dol_sanitizeFileName($object->ref); //$filename = 'tmp_cards.php'; @@ -1752,15 +1733,15 @@ else print $formfile->showdocuments('member', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $object->default_lang, '', $object); $somethingshown = $formfile->numoffiles; - + // Show links to link elements //$linktoelem = $form->showLinkToObjectBlock($object, null, array('subscription')); //$somethingshown = $form->showLinkedObjectBlock($object, ''); - + // Show links to link elements /*$linktoelem = $form->showLinkToObjectBlock($object,array('order')); if ($linktoelem) print ($somethingshown?'':'
').$linktoelem; - + // Link for paypal payment /* if (! empty($conf->paypal->enabled) && $object->statut != 0) { @@ -1769,15 +1750,15 @@ else } */ print '
'; - + // List of actions on element /* Already in tab Agenda/Events include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; $formactions = new FormActions($db); $somethingshown = $formactions->showactions($object, 'member', $socid); */ - print '
'; - + print ''; + } } diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index 1874a0b37a7..21de6e305b5 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -389,7 +389,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && ! { $invoice->linked_objects = array_merge($invoice->linked_objects, $_POST['other_linked_objects']); } - + $result=$invoice->create($user); if ($result <= 0) { @@ -581,12 +581,12 @@ if ($rowid > 0) dol_fiche_head($head, 'subscription', $langs->trans("Member"), -1, 'user'); $linkback = ''.$langs->trans("BackToList").''; - + dol_banner_tab($object, 'rowid', $linkback); - + print '
'; print '
'; - + print '
'; print '
'.$langs->trans("Birthday").''.dol_print_date($object->birth,'day').'
'.$langs->trans("SubscriptionEndDate").''; @@ -1518,7 +1499,7 @@ else } } print '
'; @@ -624,13 +624,13 @@ if ($rowid > 0) } print '
'; - + print '
'; print '
'; - + print '
'; print ''; - + // Birthday print ''; @@ -646,13 +646,9 @@ if ($rowid > 0) print ''; } - // Other attributes - $parameters=array('colspan'=>2); - $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook - if (empty($reshook) && ! empty($extrafields->attribute_label)) - { - print $object->showOptionals($extrafields, 'view', $parameters); - } + // Other attributes + $cols=2; + include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; // Date end subscription print ''; - + // Third party Dolibarr if (! empty($conf->societe->enabled)) { @@ -752,7 +748,7 @@ if ($rowid > 0) print "\n"; print '
'; - + dol_fiche_end(); print ''; diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index 20adc36dec5..4935b6c4c6d 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -336,14 +336,8 @@ if ($rowid > 0) print '"; - // Other attributes - $parameters=array(); - $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$act,$action); // Note that $action and $object may have been modified by hook - if (empty($reshook) && ! empty($extrafields->attribute_label)) - { - // View extrafields - print $object->showOptionals($extrafields); - } + // Other attributes + include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; print '
'.$langs->trans("Birthday").''.dol_print_date($object->birth,'day').'
'.$langs->trans("SubscriptionEndDate").''; @@ -677,7 +673,7 @@ if ($rowid > 0) } } print '
'.$langs->trans("WelcomeEMail").''; print nl2br($object->mail_valid)."
'; print '
'; @@ -674,6 +668,10 @@ if ($rowid > 0) // Other attributes $parameters=array(); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$act,$action); // Note that $action and $object may have been modified by hook + if (empty($reshook) && ! empty($extrafields->attribute_label)) + { + print $object->showOptionals($extrafields,'edit'); + } print '
'; diff --git a/htdocs/admin/boxes.php b/htdocs/admin/boxes.php index c76c35dfdeb..03e4a0ec9f3 100644 --- a/htdocs/admin/boxes.php +++ b/htdocs/admin/boxes.php @@ -235,7 +235,7 @@ $sql = "SELECT b.rowid, b.box_id, b.position, b.box_order,"; $sql.= " bd.rowid as boxid"; $sql.= " FROM ".MAIN_DB_PREFIX."boxes as b, ".MAIN_DB_PREFIX."boxes_def as bd"; $sql.= " WHERE b.box_id = bd.rowid"; -$sql.= " AND b.entity IN (0,".(! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)?"1,":"").$conf->entity.")"; +$sql.= " AND b.entity IN (0,".$conf->entity.")"; $sql.= " AND b.fk_user=0"; $sql.= " ORDER by b.position, b.box_order"; @@ -342,7 +342,7 @@ print "\n"; $var=true; foreach($boxtoadd as $box) { - + if (preg_match('/^([^@]+)@([^@]+)$/i',$box->boximg)) { @@ -479,7 +479,7 @@ print ''; // Activate FileCache - Developement if ($conf->global->MAIN_FEATURES_LEVEL == 2 || ! empty($conf->global->MAIN_ACTIVATE_FILECACHE)) { - + print ''.$langs->trans("EnableFileCache").''; print $form->selectyesno('MAIN_ACTIVATE_FILECACHE',$conf->global->MAIN_ACTIVATE_FILECACHE,1); print ''; diff --git a/htdocs/admin/compta.php b/htdocs/admin/compta.php index 0c42659357a..70bf15d03f3 100644 --- a/htdocs/admin/compta.php +++ b/htdocs/admin/compta.php @@ -148,7 +148,6 @@ print "\n"; foreach ($list as $key) { - print ''; // Param diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 85694a5c88b..880c9a9ba1a 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -569,8 +569,8 @@ if ($id == 10) if (GETPOST('button_removefilter') || GETPOST('button_removefilter.x') || GETPOST('button_removefilter_x')) { - $search_country_id = ''; - $search_code = ''; + $search_country_id = ''; + $search_code = ''; } // Actions add or modify an entry into a dictionary @@ -660,11 +660,11 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) if ($_POST["accountancy_code"] <= 0) $_POST["accountancy_code"]=''; // If empty, we force to null if ($_POST["accountancy_code_sell"] <= 0) $_POST["accountancy_code_sell"]=''; // If empty, we force to null if ($_POST["accountancy_code_buy"] <= 0) $_POST["accountancy_code_buy"]=''; // If empty, we force to null - if ($id == 10 && isset($_POST["code"])) // Spaces are not allowed into code + if ($id == 10 && isset($_POST["code"])) // Spaces are not allowed into code { $_POST["code"]=preg_replace('/\s/','',$_POST["code"]); } - + // Si verif ok et action add, on ajoute la ligne if ($ok && GETPOST('actionadd')) { @@ -945,7 +945,7 @@ if ($id) if (! preg_match('/ WHERE /',$sql)) $sql.= " WHERE 1 = 1"; if ($search_country_id > 0) $sql.= " AND c.rowid = ".$search_country_id; if ($search_code != '') $sql.= natural_search("code", $search_code); - + if ($sortfield) { // If sort order is "country", we use country_code instead @@ -972,16 +972,16 @@ if ($id) print '
'; print ''; print ''; - + // Form to add a new line if ($tabname[$id]) { $alabelisused=0; - + $fieldlist=explode(',',$tabfield[$id]); print ''; - + // Line for title print ''; foreach ($fieldlist as $field => $value) @@ -1012,9 +1012,9 @@ if ($id) if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') { if ($id != 25) $valuetoshow=$form->textwithtooltip($langs->trans("Label"), $langs->trans("LabelUsedByDefault"),2,1,img_help(1,'')); - else $valuetoshow=$langs->trans("Label"); + else $valuetoshow=$langs->trans("Label"); } - if ($fieldlist[$field]=='libelle_facture') { + if ($fieldlist[$field]=='libelle_facture') { $valuetoshow=$form->textwithtooltip($langs->trans("LabelOnDocuments"), $langs->trans("LabelUsedByDefault"),2,1,img_help(1,'')); } if ($fieldlist[$field]=='country') { @@ -1055,7 +1055,7 @@ if ($id) if ($fieldlist[$field]=='affect') { $valuetoshow=$langs->trans("WithCounter"); } if ($fieldlist[$field]=='delay') { $valuetoshow=$langs->trans("NoticePeriod"); } if ($fieldlist[$field]=='newbymonth') { $valuetoshow=$langs->trans("NewByMonth"); } - + if ($id == 2) // Special cas for state page { if ($fieldlist[$field]=='region_id') { $valuetoshow=' '; $showfield=1; } @@ -1120,7 +1120,7 @@ if ($id) if ($id == 4) $colspan++; print '
'; - + /*if (! empty($alabelisused) && $id != 25) // If there is one label among fields, we show legend of * { print '* '.$langs->trans("LabelUsedByDefault").'.
'; @@ -1130,11 +1130,11 @@ if ($id) print '
'; print '
'; - + print '
'; print ''; print ''; - + // List of available record in database dol_syslog("htdocs/admin/dict", LOG_DEBUG); $resql=$db->query($sql); @@ -1150,29 +1150,29 @@ if ($id) } print ''; - + // Title line with search boxes print ''; $filterfound=0; foreach ($fieldlist as $field => $value) { $showfield=1; // By defaut - + if ($fieldlist[$field]=='region_id' || $fieldlist[$field]=='country_id') { $showfield=0; } - + if ($showfield) { if ($value == 'country') { print ''; $filterfound++; } elseif ($value == 'code') { print ''; $filterfound++; } @@ -1193,7 +1193,7 @@ if ($id) } print ''; print ''; - + // Title of lines print ''; foreach ($fieldlist as $field => $value) @@ -1235,7 +1235,7 @@ if ($id) //else $valuetoshow=$langs->trans("Label"); $valuetoshow=$langs->trans("Label"); } - if ($fieldlist[$field]=='libelle_facture') { + if ($fieldlist[$field]=='libelle_facture') { //$valuetoshow=$form->textwithtooltip($langs->trans("LabelOnDocuments"), $langs->trans("LabelUsedByDefault"),2,1,img_help(1,'')); $valuetoshow=$langs->trans("LabelOnDocuments"); } @@ -1368,7 +1368,7 @@ if ($id) if ($value == 'private') { $valuetoshow = yn($elementList[$valuetoshow]); - } + } else if ($fieldlist[$field]=='libelle_facture') { $langs->load("bills"); $key=$langs->trans("PaymentCondition".strtoupper($obj->code)); @@ -1516,7 +1516,7 @@ if ($id) if ($obj->code == 'RECEP') $canbemodified=1; if ($tabname[$id] == MAIN_DB_PREFIX."c_actioncomm") $canbemodified=1; - // Url + // Url $rowidcol=$tabrowid[$id]; // If rowidcol not defined if (empty($rowidcol) || in_array($id, array(6,7,8,13,17,19,27))) $rowidcol='rowid'; @@ -1565,7 +1565,7 @@ if ($id) $i++; } } - + print '
'; - print $form->select_country($search_country_id, 'search_country_id', '', 28, 'maxwidth200 maxwidthonsmartphone'); + print $form->select_country($search_country_id, 'search_country_id', '', 28, 'maxwidth150 maxwidthonsmartphone'); print ''; - print ''; + print ''; print '
'; } else { @@ -1598,12 +1598,12 @@ else { if ($showemptyline) { - + print '   '; $showemptyline=0; } - + $value=$tabname[$i]; print ''; if (! empty($tabcond[$i])) @@ -1764,7 +1764,7 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='') print ''; $transfound=0; // Special case for labels - if ($tabname == MAIN_DB_PREFIX.'c_payment_term') + if ($tabname == MAIN_DB_PREFIX.'c_payment_term') { $langs->load("bills"); $transkey="PaymentCondition".strtoupper($obj->code); diff --git a/htdocs/admin/fichinter.php b/htdocs/admin/fichinter.php index 43ad7ad8178..68d2d87800a 100644 --- a/htdocs/admin/fichinter.php +++ b/htdocs/admin/fichinter.php @@ -547,7 +547,6 @@ print '' print "\n"; print '
'; // print products on fichinter -$var=! $var; print '
'; print ''; print ''; diff --git a/htdocs/admin/perms.php b/htdocs/admin/perms.php index 0c7ed656d9f..7528fb09115 100644 --- a/htdocs/admin/perms.php +++ b/htdocs/admin/perms.php @@ -131,7 +131,7 @@ print ''; $sql = "SELECT r.id, r.libelle, r.module, r.perms, r.subperms, r.bydefault"; $sql.= " FROM ".MAIN_DB_PREFIX."rights_def as r"; $sql.= " WHERE r.libelle NOT LIKE 'tou%'"; // On ignore droits "tous" -$sql.= " AND entity IN (".(! empty($conf->multicompany->transverse_mode)?"1,":"").$conf->entity.")"; +$sql.= " AND entity = ".$conf->entity; if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) $sql.= " AND r.perms NOT LIKE '%_advance'"; // Hide advanced perms if option is not enabled $sql.= " ORDER BY r.module, r.id"; @@ -185,7 +185,7 @@ if ($result) print "\n"; } - + print ''; print ''; +$parameters=array(); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook if (empty($reshook) && ! empty($extrafields->attribute_label)) { diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index 665b033936e..11aff01dc99 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -235,11 +235,8 @@ print $langs->trans("Color").''; -$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook -if (empty($reshook) && ! empty($extrafields->attribute_label)) -{ - print $object->showOptionals($extrafields); -} +// Other attributes +include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; print '
'.img_object('',$picto).' '.$objMod->getName(); print ' '; diff --git a/htdocs/categories/edit.php b/htdocs/categories/edit.php index 9981d09cda0..c2f93c17ccd 100644 --- a/htdocs/categories/edit.php +++ b/htdocs/categories/edit.php @@ -173,6 +173,7 @@ print '
'.$langs->trans("In").''; print $form->select_all_categories($type,$object->fk_parent,'parent',64,$object->id); print '
'; print $formother->showColor($object->color); print '
'; print ''; @@ -290,7 +287,7 @@ else if (count($cats) > 0) { foreach ($cats as $cat) - { + { print "\t".''."\n"; print "\t\t".''; print "".$cat->label.""; @@ -359,7 +356,7 @@ if ($object->type == Categorie::TYPE_PRODUCT) if (count($prods) > 0) { foreach ($prods as $prod) - { + { print "\t".''."\n"; print ''; print $prod->getNomUrl(1); @@ -408,7 +405,7 @@ if ($object->type == Categorie::TYPE_SUPPLIER) if (count($socs) > 0) { foreach ($socs as $soc) - { + { print "\t".''."\n"; print ''; print $soc->getNomUrl(1); @@ -462,7 +459,7 @@ if($object->type == Categorie::TYPE_CUSTOMER) if ($user->societe_id > 0 && $soc->id != $user->societe_id) continue; // External user always see only themself $i++; - + print "\t".''."\n"; print ''; print $soc->getNomUrl(1); @@ -513,7 +510,7 @@ if ($object->type == Categorie::TYPE_MEMBER) if (count($prods) > 0) { foreach ($prods as $key => $member) - { + { print "\t".''."\n"; print ''; $member->ref=$member->login; @@ -567,7 +564,7 @@ if($object->type == Categorie::TYPE_CONTACT) foreach ($contacts as $key => $contact) { $i++; - + print "\t".''."\n"; print ''; print $contact->getNomUrl(1,'category'); @@ -619,7 +616,7 @@ if ($object->type == Categorie::TYPE_ACCOUNT) if (count($accounts) > 0) { foreach ($accounts as $key => $account) - { + { print "\t".''."\n"; print ''; print $account->getNomUrl(1,0); @@ -672,7 +669,7 @@ if ($object->type == Categorie::TYPE_PROJECT) if (count($projects) > 0) { foreach ($projects as $key => $project) - { + { print "\t".''."\n"; print ''; print $project->getNomUrl(1,0); diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 3c9bee038ff..971f38271cd 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -121,7 +121,7 @@ if (GETPOST('removedassigned') || GETPOST('removedassigned') == '0') $donotclearsession=1; if ($action == 'add') $action = 'create'; if ($action == 'update') $action = 'edit'; - + $listUserAssignedUpdated = true; } @@ -739,7 +739,7 @@ if ($action == 'create') print '
'; print $form->select_dolusers_forevent(($action=='create'?'add':'update'), 'assignedtouser', 1, '', 0, '', '', 0, 0, 0, 'AND u.statut != 0'); print '
'; - if (in_array($user->id,array_keys($listofuserid))) + if (in_array($user->id,array_keys($listofuserid))) { print '
'; print $langs->trans("MyAvailability").': '.$langs->trans("Busy"); @@ -757,8 +757,8 @@ if ($action == 'create') print ''; print '

'; - - + + print ''; // Related company @@ -835,12 +835,9 @@ if ($action == 'create') $doleditor->Create(); print ''; - // Other attributes - $parameters=array('id'=>$object->id); + $parameters=array(); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook - - if (empty($reshook) && ! empty($extrafields->attribute_label)) { print $object->showOptionals($extrafields,'edit'); @@ -868,11 +865,11 @@ if ($id > 0) $result3=$object->fetch_contact(); $result4=$object->fetch_userassigned(); $result5=$object->fetch_optionals($id,$extralabels); - - if ($listUserAssignedUpdated || $donotclearsession) + + if ($listUserAssignedUpdated || $donotclearsession) { $percentage=in_array(GETPOST('status'),array(-1,100))?GETPOST('status'):(in_array(GETPOST('complete'),array(-1,100))?GETPOST('complete'):GETPOST("percentage")); // If status is -1 or 100, percentage is not defined and we must use status - + $datep=dol_mktime($fulldayevent?'00':$aphour, $fulldayevent?'00':$apmin, 0, $_POST["apmonth"], $_POST["apday"], $_POST["apyear"]); $datef=dol_mktime($fulldayevent?'23':$p2hour, $fulldayevent?'59':$p2min, $fulldayevent?'59':'0', $_POST["p2month"], $_POST["p2day"], $_POST["p2year"]); @@ -890,7 +887,7 @@ if ($id > 0) //$object->societe->id = $_POST["socid"]; // deprecated //$object->contact->id = $_POST["contactid"]; // deprecated $object->fk_project = GETPOST("projectid",'int'); - + $object->note = GETPOST("note"); } @@ -1082,11 +1079,11 @@ if ($id > 0) $listofuserid=json_decode($_SESSION['assignedtouser'], true); } } - + print '
'; print $form->select_dolusers_forevent(($action=='create'?'add':'update'), 'assignedtouser', 1, '', 0, '', '', 0, 0, 0, 'AND u.statut != 0'); print '
'; - if (in_array($user->id,array_keys($listofuserid))) + if (in_array($user->id,array_keys($listofuserid))) { print '
'; print $langs->trans("MyAvailability").': id]['transparency']?' checked':'').'>'.$langs->trans("Busy"); @@ -1104,10 +1101,10 @@ if ($id > 0) print '
'; - + print '

'; - + print ''; if ($conf->societe->enabled) @@ -1171,7 +1168,7 @@ if ($id > 0) print ''; // Other attributes - $parameters=array('id'=>$object->id); + $parameters=array(); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook if (empty($reshook) && ! empty($extrafields->attribute_label)) { @@ -1218,8 +1215,8 @@ if ($id > 0) $out.=img_picto($langs->trans("ViewDay"),'object_calendarday','class="hideonsmartphone pictoactionview"'); $out.=''.$langs->trans("ViewDay").''; $linkback.=$out; - - + + $morehtmlref='
'; // Thirdparty //$morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1); @@ -1259,14 +1256,14 @@ if ($id > 0) } } $morehtmlref.='
'; - - + + dol_banner_tab($object, 'id', $linkback, ($user->societe_id?0:1), 'id', 'ref', $morehtmlref); - + print '
'; - + print '
'; - + // Affichage fiche action en mode visu print '
'; @@ -1330,7 +1327,7 @@ if ($id > 0) print '
'; print $form->select_dolusers_forevent('view', 'assignedtouser', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); print '
'; - if ($object->datep != $object->datef && in_array($user->id,array_keys($listofuserid))) + if ($object->datep != $object->datef && in_array($user->id,array_keys($listofuserid))) { print '
'; print $langs->trans("MyAvailability").': '.(($object->userassigned[$user->id]['transparency'] > 0)?$langs->trans("Busy"):$langs->trans("Available")); // We show nothing if event is assigned to nobody @@ -1370,7 +1367,7 @@ if ($id > 0) } } print ''; - + // Related contact print '
'; print ''; } - + // Priority print ''; // Other attributes - $parameters=array('colspan'=>' colspan="3"', 'colspanvalue'=>'3', 'id'=>$object->id); - $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + $cols=3; + include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; print '
'.$langs->trans("ActionOnContact").''; @@ -1401,7 +1398,7 @@ if ($id > 0) } print '
'.$langs->trans("Priority").''; print ($object->priority?$object->priority:''); @@ -1425,38 +1422,13 @@ if ($id > 0) print '
'; - //Extra field - if (empty($reshook) && ! empty($extrafields->attribute_label)) - { - print '

'; - print '
'; - print ''; - foreach($extrafields->attribute_label as $key=>$label) - { - if (isset($_POST["options_" . $key])) { - if (is_array($_POST["options_" . $key])) { - // $_POST["options"] is an array but following code expects a comma separated string - $value = implode(",", $_POST["options_" . $key]); - } else { - $value = $_POST["options_" . $key]; - } - } else { - $value = $object->array_options["options_" . $key]; - } - print '\n"; - } - print '
'.$label.''; - print $extrafields->showOutputField($key,$value); - print "
'; - } - print '
'; - + dol_fiche_end(); } diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index d9b41b2d08f..f9d9309a755 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -131,7 +131,7 @@ if (empty($reshook)) $result=$object->setBankAccount(GETPOST('fk_account','int')); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } - + // customer preferred shipping method if ($action == 'setshippingmethod' && $user->rights->societe->creer) { @@ -207,9 +207,9 @@ if ($id > 0) dol_fiche_head($head, 'customer', $langs->trans("ThirdParty"), -1, 'company'); $linkback = ''.$langs->trans("BackToList").''; - + dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom'); - + print '
'; print '
'; @@ -376,11 +376,11 @@ if ($id > 0) $limit_field_type = (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE)) ? 'numeric' : 'amount'; print $form->editfieldval("OutstandingBill",'outstanding_limit',$object->outstanding_limit,$object,$user->rights->societe->creer,$limit_field_type,($object->outstanding_limit != '' ? price($object->outstanding_limit) : '')); //if (empty($object->outstanding_limit)) print $langs->trans("NoLimit"); - + print ''; print ''; } - + // Multiprice level if (! empty($conf->global->PRODUIT_MULTIPRICES)) { @@ -432,13 +432,8 @@ if ($id > 0) } // Other attributes - $parameters=array('socid'=>$object->id, 'colspan' => ' colspan="3"', 'colspanvalue' => '3'); - $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - if (empty($reshook) && ! empty($extrafields->attribute_label)) - { - print $object->showOptionals($extrafields); - } + $parameters=array('socid'=>$object->id); + include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; // Sales representative include DOL_DOCUMENT_ROOT.'/societe/tpl/linesalesrepresentative.tpl.php'; @@ -471,10 +466,10 @@ if ($id > 0) if ($object->client == 2 || $object->client == 3) { print '
'; - + print '
'; print ''; - + // Level of prospect print ''; print ''; print ''; print ''; print '
'; print ''; print "
'; @@ -508,12 +503,12 @@ if ($id > 0) print '
"; } - + print '
'; $boxstat = ''; - + // Nbre max d'elements des petites listes $MAXLIST=$conf->global->MAIN_SIZE_SHORTLIST_LIMIT; @@ -521,7 +516,7 @@ if ($id > 0) $boxstat.='
'; $boxstat.=''; $boxstat.=''; $boxstat.='
'; - + if ($conf->propal->enabled) { // Box proposals @@ -557,14 +552,14 @@ if ($id > 0) $boxstat.=''; if ($link) $boxstat.=''; } - + if ($conf->facture->enabled) { $tmp = $object->getOutstandingBills(); $outstandingOpened=$tmp['opened']; $outstandingTotal=$tmp['total_ht']; $outstandingTotalIncTax=$tmp['total_ttc']; - + $text=$langs->trans("OverAllInvoices"); $link=''; $icon='bill'; @@ -574,7 +569,7 @@ if ($id > 0) $boxstat.=''.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).''; $boxstat.=''; if ($link) $boxstat.=''; - + // Box outstanding bill $warn = ''; if ($object->outstanding_limit != '' && $object->outstanding_limit < $outstandingOpened) @@ -591,13 +586,13 @@ if ($id > 0) $boxstat.=''; if ($link) $boxstat.=''; } - + $boxstat.='
'; $boxstat.='
'; - + print $boxstat; - + $now=dol_now(); /* @@ -639,7 +634,7 @@ if ($id > 0) while ($i < $num && $i < $MAXLIST) { $objp = $db->fetch_object($resql); - + print '
'; $propal_static->id = $objp->propalid; @@ -723,7 +718,7 @@ if ($id > 0) while ($i < $num && $i < $MAXLIST) { $objp = $db->fetch_object($resql); - + print '
'; $commande_static->id = $objp->cid; @@ -849,7 +844,7 @@ if ($id > 0) $contrat=new Contrat($db); $objp = $db->fetch_object($resql); - + print '
'; $contrat->id=$objp->id; @@ -905,7 +900,7 @@ if ($id > 0) print ''.img_picto($langs->trans("Statistics"),'stats').'
'; print ''; - + } $i = 0; while ($i < $num && $i < $MAXLIST) @@ -921,7 +916,7 @@ if ($id > 0) print ''.convertSecondToTime($objp->duration).''."\n"; print ''.$fichinter_static->getLibStatut(5).''."\n"; print ''; - + $i++; } $db->free($resql); @@ -977,7 +972,7 @@ if ($id > 0) while ($i < $num && $i < $MAXLIST) { $objp = $db->fetch_object($resql); - + print ''; print ''; $facturestatic->id = $objp->facid; @@ -1006,7 +1001,7 @@ if ($id > 0) print price($objp->total_ttc); print ''; } - + print ''.($facturestatic->LibStatut($objp->paye,$objp->statut,5,$objp->am)).''; print "\n"; $i++; @@ -1042,31 +1037,31 @@ if ($id > 0) { print ''; } - + if (! empty($conf->propal->enabled) && $user->rights->propal->creer && $object->status==1) { $langs->load("propal"); print ''; } - + if (! empty($conf->commande->enabled) && $user->rights->commande->creer && $object->status==1) { $langs->load("orders"); print ''; } - + if ($user->rights->contrat->creer && $object->status==1) { $langs->load("contracts"); print ''; } - + if (! empty($conf->ficheinter->enabled) && $user->rights->ficheinter->creer && $object->status==1) { $langs->load("fichinter"); print ''; } - + // Add invoice if ($user->societe_id == 0) { @@ -1075,7 +1070,7 @@ if ($id > 0) $langs->load("trips"); print ''; } - + if (! empty($conf->facture->enabled) && $object->status==1) { if (empty($user->rights->facture->creer)) @@ -1086,7 +1081,7 @@ if ($id > 0) { $langs->load("bills"); $langs->load("orders"); - + if (! empty($conf->commande->enabled)) { if ($object->client != 0 && $object->client != 2) @@ -1099,11 +1094,11 @@ if ($id > 0) if ($object->client != 0 && $object->client != 2) print ''; else print ''; - + } } } - + // Add action if (! empty($conf->agenda->enabled) && ! empty($conf->global->MAIN_REPEATTASKONEACHTAB) && $object->status==1) { @@ -1117,7 +1112,7 @@ if ($id > 0) } } } - + print '
'; if (! empty($conf->global->MAIN_REPEATCONTACTONEACHTAB)) diff --git a/htdocs/comm/mailing/advtargetemailing.php b/htdocs/comm/mailing/advtargetemailing.php index 0a9cdca7abc..0262a50d65c 100644 --- a/htdocs/comm/mailing/advtargetemailing.php +++ b/htdocs/comm/mailing/advtargetemailing.php @@ -767,16 +767,15 @@ if ($object->fetch($id) >= 0) { } else { $std_soc = new Societe($db); $action_search = 'query'; + // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array include_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php'; $hookmanager = new HookManager($db); - $hookmanager->initHooks(array ( - 'thirdpartycard' - )); + $hookmanager->initHooks(array ('thirdpartycard')); + + $parameters=array(); if (! empty($advTarget->id)) { - $parameters = array ( - 'array_query' => $advTarget->filtervalue - ); + $parameters = array('array_query' => $advTarget->filtervalue); } // Module extrafield feature $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $std_soc, $action_search); diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index 0b4c3c239f9..956710e2abc 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -231,10 +231,10 @@ if (empty($reshook)) if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYPAL_ORDER__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); else $substitutionarray['__SECUREKEYPAYPAL_ORDER__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . 'order' . $obj->source_id, 2); - + if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYPAL_INVOICE__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); else $substitutionarray['__SECUREKEYPAYPAL_INVOICE__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . 'invoice' . $obj->source_id, 2); - + if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYPAL_CONTRACTLINE__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); else $substitutionarray['__SECUREKEYPAYPAL_CONTRACTLINE__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . 'contractline' . $obj->source_id, 2); } @@ -700,11 +700,11 @@ if ($action == 'create') } $htmltext.=''; - + $availablelink=$form->textwithpicto($langs->trans("AvailableVariables"), $htmltext, 1, 'help', '', 0, 2, 'availvar'); //print ''.img_picto($langs->trans("ClickToShowDescription"), $imginfo).''; - - + + // Print mail form print load_fiche_titre($langs->trans("NewMailing"), $availablelink, 'title_generic'); @@ -733,14 +733,14 @@ if ($action == 'create') print ''; print ''; - + print '
'; // Editeur wysiwyg require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $doleditor=new DolEditor('body',$_POST['body'],'',600,'dolibarr_mailings','',true,true,$conf->global->FCKEDITOR_ENABLE_MAILING,20,'90%'); $doleditor->Create(); print '
'; - + dol_fiche_end(); print '
'; @@ -809,7 +809,7 @@ else { if (! empty($conf->global->MAILING_LIMIT_WARNING_PHPMAIL) && $sendingmode == 'mail') setEventMessages($langs->transnoentitiesnoconv($conf->global->MAILING_LIMIT_WARNING_PHPMAIL), null, 'warnings'); if (! empty($conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL) && $sendingmode != 'mail') setEventMessages($langs->transnoentitiesnoconv($conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL), null, 'warnings'); - + // The feature is forbidden from GUI, we show just message to use from command line. setEventMessages($langs->trans("MailingNeedCommand"), null, 'warnings'); setEventMessages('', null, 'warnings'); @@ -823,7 +823,7 @@ else { if (! empty($conf->global->MAILING_LIMIT_WARNING_PHPMAIL) && $sendingmode == 'mail') setEventMessages($langs->transnoentitiesnoconv($conf->global->MAILING_LIMIT_WARNING_PHPMAIL), null, 'warnings'); if (! empty($conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL) && $sendingmode != 'mail') setEventMessages($langs->transnoentitiesnoconv($conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL), null, 'warnings'); - + $text=''; if ($conf->global->MAILING_LIMIT_SENDBYCLI >= 0) { @@ -841,12 +841,12 @@ else $morehtmlright=''; if ($object->statut == 2) $morehtmlright.=' ('.$object->countNbOfTargets('alreadysent').'/'.$object->nbemail.') '; - + dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', '', '', 0, '', $morehtmlright); print '
'; print '
'; - + print ''; // Description @@ -863,7 +863,7 @@ else print ''; - + // Nb of distinct emails print ''; // Other attributes - $parameters=array(); - $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook - if (empty($reshook) && ! empty($extrafields->attribute_label)) - { - print $object->showOptionals($extrafields); - } + include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; print '
'.$form->editfieldkey("MailErrorsTo",'email_errorsto',$object->email_errorsto,$object,$user->rights->mailing->creer && $object->statut < 3,'string').''; print $form->editfieldval("MailErrorsTo",'email_errorsto',$object->email_errorsto,$object,$user->rights->mailing->creer && $object->statut < 3,'string'); print '
'; print $langs->trans("TotalNbOfDistinctRecipients"); @@ -895,20 +895,15 @@ else print '
'; print "
"; - + dol_fiche_end(); - + // Clone confirmation if ($action == 'clone') { @@ -1053,12 +1048,12 @@ else $htmltext.=$key.' = '.$langs->trans($val).'
'; } $htmltext.=''; - + // Print mail content print load_fiche_titre($langs->trans("EMail"), $form->textwithpicto($langs->trans("AvailableVariables"), $htmltext, 1, 'help', '', 0, 2, 'emailsubstitionhelp'), 'title_generic'); - + dol_fiche_head('', '', '', -1); - + print ''; // Subject @@ -1086,9 +1081,9 @@ else /*print '';*/ - + print '
'.$langs->trans("BackgroundColorByDefault").''; print $htmlother->selectColor($object->bgcolor,'bgcolor','edit_mailing',0); print '
'; - + // Message print '
'; if (empty($object->bgcolor) || strtolower($object->bgcolor) == 'ffffff') @@ -1103,23 +1098,23 @@ else print '
'; dol_fiche_end(); - + } else { /* * Mailing en mode edition */ - + dol_fiche_head($head, 'card', $langs->trans("Mailing"), -1, 'email'); - + $linkback = ''.$langs->trans("BackToList").''; $morehtmlright=''; if ($object->statut == 2) $morehtmlright.=' ('.$object->countNbOfTargets('alreadysent').'/'.$object->nbemail.') '; - + dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', '', '', 0, '', $morehtmlright); - + print '
'; print '
'; @@ -1131,7 +1126,7 @@ else print $form->showrefnav($object,'id', $linkback); print ''; */ - + // Topic print ''.$langs->trans("MailTitle").''.$object->titre.''; // From @@ -1171,24 +1166,24 @@ else print "
\n"; - + print ''."\n"; print ''; print ''; print ''; - + $htmltext = ''.$langs->trans("FollowingConstantsWillBeSubstituted").':
'; foreach($object->substitutionarray as $key => $val) { $htmltext.=$key.' = '.$langs->trans($val).'
'; } $htmltext.='
'; - + // Print mail content print load_fiche_titre($langs->trans("EMail"), $form->textwithpicto($langs->trans("AvailableVariables"), $htmltext, 1, 'help', '', 0, 2, 'emailsubstitionhelp'), 'title_generic'); dol_fiche_head(); - + print ''; // Subject @@ -1237,9 +1232,9 @@ else print ''; - + print '
'.$langs->trans("BackgroundColorByDefault").''; print $htmlother->selectColor($object->bgcolor,'bgcolor','edit_mailing',0); print '
'; - + // Message print '
'; // Editeur wysiwyg diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 61fa4ee5789..4e26437fd19 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -499,7 +499,7 @@ if (empty($reshook)) $tva_tx = $lines[$i]->tva_tx; if (! empty($lines[$i]->vat_src_code) && ! preg_match('/\(/', $tva_tx)) $tva_tx .= ' ('.$lines[$i]->vat_src_code.')'; - + $result = $object->addline($desc, $lines[$i]->subprice, $lines[$i]->qty, $tva_tx, $lines[$i]->localtax1_tx, $lines[$i]->localtax2_tx, $lines[$i]->fk_product, $lines[$i]->remise_percent, 'HT', 0, $lines[$i]->info_bits, $product_type, $lines[$i]->rang, $lines[$i]->special_code, $fk_parent_line, $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, $label, $date_start, $date_end, $array_options, $lines[$i]->fk_unit); if ($result > 0) { @@ -755,7 +755,7 @@ if (empty($reshook)) $db->begin(); // $tva_tx can be 'x.x (XXX)' - + // Ecrase $pu par celui du produit // Ecrase $desc par celui du produit // Ecrase $tva_tx par celui du produit @@ -770,7 +770,7 @@ if (empty($reshook)) $tva_tx = get_default_tva($mysoc, $object->thirdparty, $prod->id); $tva_npr = get_default_npr($mysoc, $object->thirdparty, $prod->id); if (empty($tva_tx)) $tva_npr=0; - + $pu_ht = $prod->price; $pu_ttc = $prod->price_ttc; $price_min = $prod->price_min; @@ -811,7 +811,7 @@ if (empty($reshook)) $tmpvat = price2num(preg_replace('/\s*\(.*\)/', '', $tva_tx)); $tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx)); - + // if price ht is forced (ie: calculated by margin rate and cost price). TODO Why this ? if (! empty($price_ht)) { $pu_ht = price2num($price_ht, 'MU'); @@ -1170,27 +1170,12 @@ if (empty($reshook)) $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute')); if ($ret < 0) $error++; - if (! $error) { - // Actions on extra fields (by external module or standard code) - // TODO le hook fait double emploi avec le trigger !! - $hookmanager->initHooks(array('propaldao')); - $parameters = array('id' => $object->id); - $reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $object, $action); // Note that $action and $object may have been - // modified by - // some hooks - if (empty($reshook)) { - $result = $object->insertExtraFields(); - if ($result < 0) { - $error ++; - } - } else if ($reshook < 0) - $error ++; + $result = $object->insertExtraFields(); + if ($result < 0) $error++; } - - if ($error) - $action = 'edit_extras'; + if ($error) $action = 'edit_extras'; } if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->propal->creer) @@ -1325,7 +1310,7 @@ if ($action == 'create') // Replicate extrafields $objectsrc->fetch_optionals($originid); $object->array_options = $objectsrc->array_options; - + if (!empty($conf->multicurrency->enabled)) { if (!empty($objectsrc->multicurrency_code)) $currency_code = $objectsrc->multicurrency_code; @@ -1355,10 +1340,10 @@ if ($action == 'create') print ''; // Reference - print ''; + print ''; // Ref customer - print ''; print ''; @@ -1366,7 +1351,7 @@ if ($action == 'create') print ''; print ''; if ($socid > 0) { - print ''; @@ -1374,7 +1359,7 @@ if ($action == 'create') $shipping_method_id = $soc->shipping_method_id; } } else { - print ''; } @@ -1404,7 +1389,7 @@ if ($action == 'create') if ($socid > 0) { // Ligne info remises tiers - print ''; // Validaty duration - print ''; + print ''; // Terms of payment - print ''; // Mode of payment - print ''; // Bank Account if (! empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL) && ! empty($conf->banque->enabled)) { - print ''; } @@ -1450,20 +1435,20 @@ if ($action == 'create') print ''; // Delivery delay - print ''; // Shipping Method if (! empty($conf->expedition->enabled)) { - print ''; } // Delivery date (or manufacturing) print ''; - print ''; - print ''; @@ -1495,7 +1480,7 @@ if ($action == 'create') { print ''; print ''; - print ''; } @@ -1503,7 +1488,7 @@ if ($action == 'create') // Template to use by default print ''; print ''; - print '"; @@ -1513,7 +1498,7 @@ if ($action == 'create') { print ''; print ''; - print ''; } @@ -1521,7 +1506,7 @@ if ($action == 'create') // Public note print ''; print ''; - print ''; print ''; - print ''; - print ''; - print '"; + print ''; + print ''; + print '"; if ($mysoc->localtax1_assuj == "1" || $objectsrc->total_localtax1 != 0 ) // Localtax1 { - print '"; + print '"; } if ($mysoc->localtax2_assuj == "1" || $objectsrc->total_localtax2 != 0) // Localtax2 { - print '"; + print '"; } - print '"; + print '"; } print "
' . $langs->trans('Ref') . '' . $langs->trans("Draft") . '
' . $langs->trans('Ref') . '' . $langs->trans("Draft") . '
' . $langs->trans('RefCustomer') . ''; + print '
' . $langs->trans('RefCustomer') . ''; print '
' . $langs->trans('Customer') . ''; + print ''; print $soc->getNomUrl(1); print ''; print ''; + print ''; print $form->select_company('', 'socid', '(s.client = 1 OR s.client = 2 OR s.client = 3) AND status=1', 'SelectThirdParty'); // reload page to retrieve customer informations if (!empty($conf->global->RELOAD_PAGE_ON_CUSTOMER_CHANGE)) @@ -1396,7 +1381,7 @@ if ($action == 'create') // Contacts (ask contact only if thirdparty already defined). TODO do this also into order and invoice. if ($socid > 0) { - print "
" . $langs->trans("DefaultContact") . ''; + print "
" . $langs->trans("DefaultContact") . ''; $form->select_contacts($soc->id, $contactid, 'contactid', 1, $srccontactslist); print '
' . $langs->trans('Discounts') . ''; + print '
' . $langs->trans('Discounts') . ''; if ($soc->remise_percent) print $langs->trans("CompanyHasRelativeDiscount", $soc->remise_percent); else @@ -1420,26 +1405,26 @@ if ($action == 'create') } // Date - print '
' . $langs->trans('Date') . ''; + print '
' . $langs->trans('Date') . ''; $form->select_date('', '', '', '', '', "addprop", 1, 1); print '
' . $langs->trans("ValidityDuration") . ' ' . $langs->trans("days") . '
' . $langs->trans("ValidityDuration") . ' ' . $langs->trans("days") . '
' . $langs->trans('PaymentConditionsShort') . ''; + print '
' . $langs->trans('PaymentConditionsShort') . ''; $form->select_conditions_paiements($soc->cond_reglement_id, 'cond_reglement_id'); print '
' . $langs->trans('PaymentMode') . ''; + print '
' . $langs->trans('PaymentMode') . ''; $form->select_types_paiements($soc->mode_reglement_id, 'mode_reglement_id'); print '
' . $langs->trans('BankAccount') . ''; + print '
' . $langs->trans('BankAccount') . ''; $form->select_comptes($fk_account, 'fk_account', 0, '', 1); print '
' . $langs->trans('AvailabilityPeriod') . ''; + print '
' . $langs->trans('AvailabilityPeriod') . ''; $form->selectAvailabilityDelay('', 'availability_id', '', 1); print '
' . $langs->trans('SendingMethod') . ''; + print '
' . $langs->trans('SendingMethod') . ''; print $form->selectShippingMethod($shipping_method_id, 'shipping_method_id', '', 1); print '
' . $langs->trans("DeliveryDate") . ''; + print ''; if ($conf->global->DATE_LIVRAISON_WEEK_DELAY != "") { $tmpdte = time() + ((7 * $conf->global->DATE_LIVRAISON_WEEK_DELAY) * 24 * 60 * 60); $syear = date("Y", $tmpdte); @@ -1483,7 +1468,7 @@ if ($action == 'create') $langs->load("projects"); print '
' . $langs->trans("Project") . ''; + print '' . $langs->trans("Project") . ''; $numprojet = $formproject->select_projects($soc->id, $projectid, 'projectid', 0); print '   id).'">' . $langs->trans("AddProject") . ''; print '
'; + print ''; print $form->select_incoterms((!empty($soc->fk_incoterms) ? $soc->fk_incoterms : ''), (!empty($soc->location_incoterms)?$soc->location_incoterms:'')); print '
' . $langs->trans("DefaultModel") . ''; + print ''; $liste = ModelePDFPropales::liste_modeles($db); print $form->selectarray('model', $liste, ($conf->global->PROPALE_ADDON_PDF_ODT_DEFAULT ? $conf->global->PROPALE_ADDON_PDF_ODT_DEFAULT : $conf->global->PROPALE_ADDON_PDF)); print "
'.fieldLabel('Currency','multicurrency_code').''; + print ''; print $form->selectMultiCurrency($currency_code, 'multicurrency_code', 0); print '
' . $langs->trans('NotePublic') . ''; + print ''; $note_public = $object->getDefaultCreateValueFor('note_public', (is_object($objectsrc)?$objectsrc->note_public:null)); $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); print $doleditor->Create(1); @@ -1531,7 +1516,7 @@ if ($action == 'create') { print '
' . $langs->trans('NotePrivate') . ''; + print ''; $note_private = $object->getDefaultCreateValueFor('note_private', ((! empty($origin) && ! empty($originid) && is_object($objectsrc))?$objectsrc->note_private:null)); $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); print $doleditor->Create(1); @@ -1540,10 +1525,8 @@ if ($action == 'create') } // Other attributes - $parameters = array('colspan' => ' colspan="3"'); - $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified - // by - // hook + $parameters = array(); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook) && ! empty($extrafields->attribute_label)) { print $object->showOptionals($extrafields, 'edit'); } @@ -1578,19 +1561,19 @@ if ($action == 'create') elseif ($newclassname == 'Fichinter') $newclassname = 'Intervention'; - print '
' . $langs->trans($newclassname) . '' . $objectsrc->getNomUrl(1) . '
' . $langs->trans('TotalHT') . '' . price($objectsrc->total_ht, 0, $langs, 1, -1, -1, $conf->currency) . '
' . $langs->trans('TotalVAT') . '' . price($objectsrc->total_tva, 0, $langs, 1, -1, -1, $conf->currency) . "
' . $langs->trans($newclassname) . '' . $objectsrc->getNomUrl(1) . '
' . $langs->trans('TotalHT') . '' . price($objectsrc->total_ht, 0, $langs, 1, -1, -1, $conf->currency) . '
' . $langs->trans('TotalVAT') . '' . price($objectsrc->total_tva, 0, $langs, 1, -1, -1, $conf->currency) . "
' . $langs->transcountry("AmountLT1", $mysoc->country_code) . '' . price($objectsrc->total_localtax1, 0, $langs, 1, -1, -1, $conf->currency) . "
' . $langs->transcountry("AmountLT1", $mysoc->country_code) . '' . price($objectsrc->total_localtax1, 0, $langs, 1, -1, -1, $conf->currency) . "
' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '' . price($objectsrc->total_localtax2, 0, $langs, 1, -1, -1, $conf->currency) . "
' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '' . price($objectsrc->total_localtax2, 0, $langs, 1, -1, -1, $conf->currency) . "
' . $langs->trans('TotalTTC') . '' . price($objectsrc->total_ttc, 0, $langs, 1, -1, -1, $conf->currency) . "
' . $langs->trans('TotalTTC') . '' . price($objectsrc->total_ttc, 0, $langs, 1, -1, -1, $conf->currency) . "
\n"; @@ -2036,43 +2019,6 @@ if ($action == 'create') print ''; } - // Project - /* - if (! empty($conf->projet->enabled)) - { - $langs->load("projects"); - print ''; - print ''; - if ($user->rights->propal->creer) - { - if ($action != 'classify') - print ''; - print '
'; - print $langs->trans('Project') . '' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '
'; - print ''; - if ($action == 'classify') { - $form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1); - } else { - $form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0); - } - print ''; - } else { - print ''; - if (! empty($object->fk_project)) { - print ''; - $proj = new Project($db); - $proj->fetch($object->fk_project); - print ''; - print $proj->ref; - print ''; - print ''; - } else { - print ' '; - } - } - print ''; - }*/ - if ($soc->outstanding_limit) { // Outstanding Bill @@ -2129,7 +2075,6 @@ if ($action == 'create') } // Other attributes - $cols = 2; include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; print ''; diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index ebd8864568a..189d13c3ced 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -49,7 +49,7 @@ if (! empty($conf->projet->enabled)) { require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php'; } - + require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; if (!empty($conf->variants->enabled)) { @@ -116,7 +116,7 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (empty($reshook)) { - if ($cancel) + if ($cancel) { if ($action != 'addlink' && $action != 'updateline') { @@ -130,7 +130,7 @@ if (empty($reshook)) } $action=''; } - + include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once @@ -379,7 +379,7 @@ if (empty($reshook)) $tva_tx = $lines[$i]->tva_tx; if (! empty($lines[$i]->vat_src_code) && ! preg_match('/\(/', $tva_tx)) $tva_tx .= ' ('.$lines[$i]->vat_src_code.')'; - + $result = $object->addline($desc, $lines[$i]->subprice, $lines[$i]->qty, $tva_tx, $lines[$i]->localtax1_tx, $lines[$i]->localtax2_tx, $lines[$i]->fk_product, $lines[$i]->remise_percent, $lines[$i]->info_bits, $lines[$i]->fk_remise_except, 'HT', 0, $date_start, $date_end, $product_type, $lines[$i]->rang, $lines[$i]->special_code, $fk_parent_line, $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, $label, $array_options, $lines[$i]->fk_unit, $object->origin, $lines[$i]->rowid); if ($result < 0) { @@ -779,7 +779,7 @@ if (empty($reshook)) $tmpvat = price2num(preg_replace('/\s*\(.*\)/', '', $tva_tx)); $tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx)); - + // if price ht is forced (ie: calculated by margin rate and cost price). TODO Why this ? if (! empty($price_ht)) { $pu_ht = price2num($price_ht, 'MU'); @@ -1457,10 +1457,10 @@ if ($action == 'create' && $user->rights->commande->creer) print ''; // Reference - print ''; + print ''; // Reference client - print ''; else @@ -1471,12 +1471,12 @@ if ($action == 'create' && $user->rights->commande->creer) print ''; print ''; if ($socid > 0) { - print ''; } else { - print ''; // Ligne info remises tiers - print ''; } // Date - print ''; // Delivery date planed - print ""; // Conditions de reglement - print ''; // Mode de reglement - print ''; // Bank Account if (! empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_ORDER) && ! empty($conf->banque->enabled)) { - print ''; } // Delivery delay - print ''; // Shipping Method if (! empty($conf->expedition->enabled)) { - print ''; } @@ -1565,13 +1565,13 @@ if ($action == 'create' && $user->rights->commande->creer) if (! empty($conf->expedition->enabled) && ! empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER)) { require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; $formproduct=new FormProduct($db); - print ''; } // What trigger creation - print ''; @@ -1582,7 +1582,7 @@ if ($action == 'create' && $user->rights->commande->creer) { $langs->load("projects"); print ''; - print ''; @@ -1594,7 +1594,7 @@ if ($action == 'create' && $user->rights->commande->creer) { print ''; print ''; - print ''; - print ''; print ''; - print ''; } @@ -1635,7 +1634,7 @@ if ($action == 'create' && $user->rights->commande->creer) // Note public print ''; print ''; - print ''; print ''; - print ''; - print ''; - print '"; + print ''; + print ''; + print '"; if ($mysoc->localtax1_assuj == "1" || $objectsrc->total_localtax1 != 0) // Localtax1 RE { - print '"; + print '"; } if ($mysoc->localtax2_assuj == "1" || $objectsrc->total_localtax2 != 0) // Localtax2 IRPF { - print '"; + print '"; } - print '"; + print '"; if (!empty($conf->multicurrency->enabled)) { - print ''; - print '"; - print '"; + print ''; + print '"; + print '"; } } @@ -2240,7 +2239,7 @@ if ($action == 'create' && $user->rights->commande->creer) } print ''; */ - + $tmparray=$object->getTotalWeightVolume(); $totalWeight=$tmparray['weight']; $totalVolume=$tmparray['volume']; @@ -2269,7 +2268,7 @@ if ($action == 'create' && $user->rights->commande->creer) else print ' '; print '
' . $langs->trans('Ref') . '' . $langs->trans("Draft") . '
' . $langs->trans('Ref') . '' . $langs->trans("Draft") . '
' . $langs->trans('RefCustomer') . ''; + print '
' . $langs->trans('RefCustomer') . ''; if (!empty($conf->global->MAIN_USE_PROPAL_REFCLIENT_FOR_ORDER) && ! empty($origin) && ! empty($originid)) print '
' . $langs->trans('Customer') . ''; + print ''; print $soc->getNomUrl(1); print ''; print ''; + print ''; print $form->select_company('', 'socid', 's.client = 1 OR s.client = 3', 'SelectThirdParty'); // reload page to retrieve customer informations if (!empty($conf->global->RELOAD_PAGE_ON_CUSTOMER_CHANGE)) @@ -1497,12 +1497,12 @@ if ($action == 'create' && $user->rights->commande->creer) // Contact of order if ($socid > 0) { - print "
" . $langs->trans("DefaultContact") . ''; + print "
" . $langs->trans("DefaultContact") . ''; $form->select_contacts($soc->id, $setcontact, 'contactid', 1, $srccontactslist); print '
' . $langs->trans('Discounts') . ''; + print '
' . $langs->trans('Discounts') . ''; if ($soc->remise_percent) print $langs->trans("CompanyHasRelativeDiscount", $soc->remise_percent); else @@ -1517,12 +1517,12 @@ if ($action == 'create' && $user->rights->commande->creer) print '
' . $langs->trans('Date') . ''; + print '
' . $langs->trans('Date') . ''; $form->select_date('', 're', '', '', '', "crea_commande", 1, 1); // Always autofill date with current date print '
".$langs->trans("DateDeliveryPlanned").''; + print "
".$langs->trans("DateDeliveryPlanned").''; if (empty($datedelivery)) { if (! empty($conf->global->DATE_LIVRAISON_WEEK_DELAY)) $datedelivery = time() + ((7*$conf->global->DATE_LIVRAISON_WEEK_DELAY) * 24 * 60 * 60); @@ -1532,31 +1532,31 @@ if ($action == 'create' && $user->rights->commande->creer) print "
' . $langs->trans('PaymentConditionsShort') . ''; + print '
' . $langs->trans('PaymentConditionsShort') . ''; $form->select_conditions_paiements($cond_reglement_id, 'cond_reglement_id', - 1, 1); print '
' . $langs->trans('PaymentMode') . ''; + print '
' . $langs->trans('PaymentMode') . ''; $form->select_types_paiements($mode_reglement_id, 'mode_reglement_id'); print '
' . $langs->trans('BankAccount') . ''; + print '
' . $langs->trans('BankAccount') . ''; $form->select_comptes($fk_account, 'fk_account', 0, '', 1); print '
' . $langs->trans('AvailabilityPeriod') . ''; + print '
' . $langs->trans('AvailabilityPeriod') . ''; $form->selectAvailabilityDelay($availability_id, 'availability_id', '', 1); print '
' . $langs->trans('SendingMethod') . ''; + print '
' . $langs->trans('SendingMethod') . ''; print $form->selectShippingMethod($shipping_method_id, 'shipping_method_id', '', 1); print '
' . $langs->trans('Warehouse') . ''; + print '
' . $langs->trans('Warehouse') . ''; print $formproduct->selectWarehouses($warehouse_id, 'warehouse_id', '', 1); print '
' . $langs->trans('Source') . ''; + print '
' . $langs->trans('Source') . ''; $form->selectInputReason($demand_reason_id, 'demand_reason_id', '', 1); print '
' . $langs->trans("Project") . ''; + print '' . $langs->trans("Project") . ''; $numprojet = $formproject->select_projects($soc->id, $projectid, 'projectid', 0); print '   id).'">' . $langs->trans("AddProject") . ''; print '
'; + print ''; $incoterm_id = GETPOST('incoterm_id'); $incoterm_location = GETPOST('location_incoterms'); if (empty($incoterm_id)) @@ -1607,16 +1607,15 @@ if ($action == 'create' && $user->rights->commande->creer) } // Other attributes - $parameters = array('objectsrc' => $objectsrc, 'colspan' => ' colspan="3"', 'socid'=>$socid); + $parameters = array('objectsrc' => $objectsrc, 'socid'=>$socid); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by - // hook if (empty($reshook) && ! empty($extrafields->attribute_label)) { print $object->showOptionals($extrafields, 'edit'); } // Template to use by default print '
' . $langs->trans('DefaultModel') . ''; + print ''; include_once DOL_DOCUMENT_ROOT . '/core/modules/commande/modules_commande.php'; $liste = ModelePDFCommandes::liste_modeles($db); print $form->selectarray('model', $liste, $conf->global->COMMANDE_ADDON_PDF); @@ -1627,7 +1626,7 @@ if ($action == 'create' && $user->rights->commande->creer) { print '
'.fieldLabel('Currency','multicurrency_code').''; + print ''; print $form->selectMultiCurrency($currency_code, 'multicurrency_code'); print '
' . $langs->trans('NotePublic') . ''; + print ''; $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); print $doleditor->Create(1); @@ -1646,7 +1645,7 @@ if ($action == 'create' && $user->rights->commande->creer) if (empty($user->societe_id)) { print '
' . $langs->trans('NotePrivate') . ''; + print ''; $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); print $doleditor->Create(1); @@ -1689,26 +1688,26 @@ if ($action == 'create' && $user->rights->commande->creer) $newclassname = $classname; } - print '
' . $langs->trans($newclassname) . '' . $objectsrc->getNomUrl(1) . '
' . $langs->trans('TotalHT') . '' . price($objectsrc->total_ht) . '
' . $langs->trans('TotalVAT') . '' . price($objectsrc->total_tva) . "
' . $langs->trans($newclassname) . '' . $objectsrc->getNomUrl(1) . '
' . $langs->trans('TotalHT') . '' . price($objectsrc->total_ht) . '
' . $langs->trans('TotalVAT') . '' . price($objectsrc->total_tva) . "
' . $langs->transcountry("AmountLT1", $mysoc->country_code) . '' . price($objectsrc->total_localtax1) . "
' . $langs->transcountry("AmountLT1", $mysoc->country_code) . '' . price($objectsrc->total_localtax1) . "
' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '' . price($objectsrc->total_localtax2) . "
' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '' . price($objectsrc->total_localtax2) . "
' . $langs->trans('TotalTTC') . '' . price($objectsrc->total_ttc) . "
' . $langs->trans('TotalTTC') . '' . price($objectsrc->total_ttc) . "
' . $langs->trans('MulticurrencyTotalHT') . '' . price($objectsrc->multicurrency_total_ht) . '
' . $langs->trans('MulticurrencyTotalVAT') . '' . price($objectsrc->multicurrency_total_tva) . "
' . $langs->trans('MulticurrencyTotalTTC') . '' . price($objectsrc->multicurrency_total_ttc) . "
' . $langs->trans('MulticurrencyTotalHT') . '' . price($objectsrc->multicurrency_total_ht) . '
' . $langs->trans('MulticurrencyTotalVAT') . '' . price($objectsrc->multicurrency_total_tva) . "
' . $langs->trans('MulticurrencyTotalTTC') . '' . price($objectsrc->multicurrency_total_ttc) . "
'; print ''; - print ''; + print ''; if ($action != 'editincoterm') { print $form->textwithpicto($object->display_incoterms(), $object->libelle_incoterms, 1); @@ -2291,7 +2290,7 @@ if ($action == 'create' && $user->rights->commande->creer) if ($action != 'editbankaccount' && $user->rights->commande->creer) print 'id.'">'.img_edit($langs->trans('SetBankAccount'),1).''; print ''; - print ''; + print ''; if ($action == 'editbankaccount') { $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1); } else { @@ -2302,7 +2301,6 @@ if ($action == 'create' && $user->rights->commande->creer) } // Other attributes - $cols = 2; include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; print ''; @@ -2320,18 +2318,18 @@ if ($action == 'create' && $user->rights->commande->creer) print '' . fieldLabel('MulticurrencyAmountHT','multicurrency_total_ht') . ''; print '' . price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . ''; print ''; - + // Multicurrency Amount VAT print '' . fieldLabel('MulticurrencyAmountVAT','multicurrency_total_tva') . ''; print '' . price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . ''; print ''; - + // Multicurrency Amount TTC print '' . fieldLabel('MulticurrencyAmountTTC','multicurrency_total_ttc') . ''; print '' . price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . ''; print ''; } - + // Total HT print '' . $langs->trans('AmountHT') . ''; print '' . price($object->total_ht, 1, '', 1, - 1, - 1, $conf->currency) . ''; diff --git a/htdocs/commande/orderstoinvoice.php b/htdocs/commande/orderstoinvoice.php index 9c79b030456..95e896160ce 100644 --- a/htdocs/commande/orderstoinvoice.php +++ b/htdocs/commande/orderstoinvoice.php @@ -411,17 +411,17 @@ if ($action == 'create' && !$error) print ''; // Ref - print ''; + print ''; // Third party - print ''; print ''."\n"; // Type - print ''; // Payment term - print ''; // Payment mode - print ''; // Project @@ -451,7 +451,7 @@ if ($action == 'create' && !$error) $formproject=new FormProjets($db); $langs->load('projects'); - print ''; } @@ -469,9 +469,8 @@ if ($action == 'create' && !$error) } // Other attributes - $parameters=array('objectsrc' => $objectsrc, 'idsrc' => $listoforders, 'colspan' => ' colspan="3"'); + $parameters=array('objectsrc' => $objectsrc, 'idsrc' => $listoforders); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook - if (empty($reshook) && ! empty($extrafields->attribute_label)) { $object=new Facture($db); @@ -489,8 +488,8 @@ if ($action == 'create' && !$error) // Public note print ''; print ''; - print ''; } @@ -622,7 +621,7 @@ if (($action != 'create' && $action != 'add') || ($action == 'create' && $error) print ''; - + //DATE ORDER print ''; - + //ALL/NONE print ''; print ''; - print ''; + print ''; // Label print ''; - print ''; + print ''; // Type print ''; - print ''; // Currency print ''; - print ''; - print ''; @@ -362,13 +362,13 @@ if ($action == 'create') $object->country_code = getCountry($selectedcode, 2); // Force country code on account to have following field on bank fields matching country rules print ''; - print ''; // State - print ''; - print ''; + print ''; // Tags-Categories - if ($conf->categorie->enabled) + if ($conf->categorie->enabled) { - print ''; - print ''; // Other attributes - $parameters=array('colspan' => 3); + $parameters=array(); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook if (empty($reshook) && ! empty($extrafields->attribute_label)) { @@ -422,18 +422,18 @@ if ($action == 'create') // Sold print ''; - print ''; + print ''; print ''; - print ''; print ''; - print ''; + print ''; print ''; - print ''; + print ''; print '
'.$langs->trans('Ref').''.$langs->trans('Draft').'
'.$langs->trans('Ref').''.$langs->trans('Draft').'
'.$langs->trans('Customer').''; + print '
'.$langs->trans('Customer').''; print $soc->getNomUrl(1); print ''; print '
'.$langs->trans('Type').''; + print '
'.$langs->trans('Type').''; print ''."\n"; // Standard invoice @@ -434,15 +434,15 @@ if ($action == 'create' && !$error) print '
'; // Date invoice - print '
'.$langs->trans('Date').''; + print '
'.$langs->trans('Date').''; $html->select_date('','','','','',"add",1,1); print '
'.$langs->trans('PaymentConditionsShort').''; + print '
'.$langs->trans('PaymentConditionsShort').''; $html->select_conditions_paiements(isset($_POST['cond_reglement_id'])?$_POST['cond_reglement_id']:$cond_reglement_id,'cond_reglement_id'); print '
'.$langs->trans('PaymentMode').''; + print '
'.$langs->trans('PaymentMode').''; $html->select_types_paiements(isset($_POST['mode_reglement_id'])?$_POST['mode_reglement_id']:$mode_reglement_id,'mode_reglement_id'); print '
'.$langs->trans('Project').''; + print '
'.$langs->trans('Project').''; $formproject->select_projects($soc->id, $projectid, 'projectid'); print '
'.$langs->trans('NotePublic').''; - print '
'; print ''; print ''; print $period; @@ -637,7 +636,7 @@ if (($action != 'create' && $action != 'add') || ($action == 'create' && $error) print ''; print ''; print ''; if ($conf->use_javascript_ajax) print ''.$langs->trans("All").' / '.$langs->trans("None").''; @@ -653,7 +652,7 @@ if (($action != 'create' && $action != 'add') || ($action == 'create' && $error) while ($i < $num) { $objp = $db->fetch_object($resql); - + print '
'; diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index 2cb90b6a44a..7267769379e 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -75,7 +75,7 @@ if ($action == 'add') $error=0; $db->begin(); - + // Create account $object = new Account($db); @@ -116,7 +116,7 @@ if ($action == 'add') $object->comment = trim(GETPOST("account_comment")); $object->fk_user_author = $user->id; - + if ($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED && empty($object->account_number)) { setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired",$langs->transnoentitiesnoconv("AccountancyCode")), null, 'errors'); @@ -149,7 +149,7 @@ if ($action == 'add') $object->setCategories($categories); $_GET["id"]=$id; // Force chargement page en mode visu - + $action=''; } else { @@ -159,7 +159,7 @@ if ($action == 'add') $action='create'; // Force chargement page en mode creation } } - + if (! $error) { $db->commit(); @@ -324,21 +324,21 @@ if ($action == 'create') // Ref print '
'.$langs->trans("Ref").'ref).'" maxlength="12">
ref).'" maxlength="12">
'.$langs->trans("LabelBankCashAccount").'
'.$langs->trans("AccountType").''; + print ''; $formbank->selectTypeOfBankAccount(isset($_POST["type"])?$_POST["type"]: Account::TYPE_CURRENT,"type"); print '
'.$langs->trans("Currency").''; + print ''; $selectedcode=$object->currency_code; if (! $selectedcode) $selectedcode=$conf->currency; print $form->selectCurrency((isset($_POST["account_currency_code"])?$_POST["account_currency_code"]:$selectedcode), 'account_currency_code'); @@ -348,7 +348,7 @@ if ($action == 'create') // Status print '
'.$langs->trans("Status").''; + print ''; print $form->selectarray("clos", $object->status,(isset($_POST["clos"])?$_POST["clos"]:$object->clos)); print '
'.$langs->trans("BankAccountCountry").''; + print ''; print $form->select_country($selectedcode,'account_country_id'); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); print '
'.$langs->trans('State').''; + print '
'.$langs->trans('State').''; if ($selectedcode) { $formcompany->select_departement(isset($_POST["account_state_id"])?$_POST["account_state_id"]:'',$selectedcode,'account_state_id'); @@ -381,12 +381,12 @@ if ($action == 'create') // Web print '
'.$langs->trans("Web").'
'.$langs->trans("Categories").''; + print '
'.$langs->trans("Categories").''; $cate_arbo = $form->select_all_categories(Categorie::TYPE_ACCOUNT, '', 'parent', 64, 0, 1); $c = new Categorie($db); $cats = $c->containing($object->id,Categorie::TYPE_ACCOUNT); @@ -399,7 +399,7 @@ if ($action == 'create') // Comment print '
'.$langs->trans("Comment").''; + print ''; // Editor wysiwyg require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $doleditor=new DolEditor('account_comment',(GETPOST("account_comment")?GETPOST("account_comment"):$object->comment),'',90,'dolibarr_notes','',false,true,$conf->global->FCKEDITOR_ENABLE_SOCIETE,ROWS_4,'90%'); @@ -407,7 +407,7 @@ if ($action == 'create') print '
'.$langs->trans("InitialBankBalance").'solde)).'">
solde)).'">
'.$langs->trans("Date").''; + print ''; $form->select_date('', 're', 0, 0, 0, 'formsoc'); print '
'.$langs->trans("BalanceMinimalAllowed").'min_allowed).'">
min_allowed).'">
'.$langs->trans("BalanceMinimalDesired").'min_desired).'">
min_desired).'">
'; print '
'; @@ -444,7 +444,7 @@ if ($action == 'create') // If bank account print ''.$langs->trans("BankName").''; - print ''; + print ''; print ''; // Show fields of bank account @@ -477,21 +477,21 @@ if ($action == 'create') // IBAN print ''.$langs->trans($ibankey).''; - print ''; + print ''; print ''.$langs->trans($bickey).''; - print ''; + print ''; - print ''.$langs->trans("BankAccountDomiciliation").''; + print ''.$langs->trans("BankAccountDomiciliation").''; print ""; print ''.$langs->trans("BankAccountOwner").''; - print ''; + print ''; print ''; - print ''.$langs->trans("BankAccountOwnerAddress").''; + print ''.$langs->trans("BankAccountOwnerAddress").''; print ""; @@ -503,8 +503,8 @@ if ($action == 'create') print ''; // Accountancy code $fieldrequired=''; - if (! empty($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED)) $fieldrequired='fieldrequired '; - + if (! empty($conf->global->MAIN_BANK_ACCOUNTANCY_CODE_ALWAYS_REQUIRED)) $fieldrequired='fieldrequired '; + if (! empty($conf->accounting->enabled)) { print ''; @@ -515,7 +515,7 @@ if ($action == 'create') else { print ''; - print ''; + print ''; } // Accountancy journal @@ -565,10 +565,10 @@ else // Onglets $head=bank_prepare_head($object); - dol_fiche_head($head, 'bankname', $langs->trans("FinancialAccount"),0,'account'); + dol_fiche_head($head, 'bankname', $langs->trans("FinancialAccount"), -1, 'account'); $formconfirm = ''; - + // Confirmation to delete if ($action == 'delete') { @@ -578,24 +578,24 @@ else // Print form confirm print $formconfirm; - + $linkback = ''.$langs->trans("BackToList").''; - + $morehtmlref=''; dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); - - + + print '
'; print '
'; print '
'; - + print '
'.$langs->trans("AccountancyCode").'
'.$langs->trans("AccountancyCode").'account_number).'">
account_number).'">
'; // Ref /* print ''; - print '';*/ @@ -662,25 +662,25 @@ else print $object->account_number; } print ''; - + // Accountancy journal if (! empty($conf->accounting->enabled)) { print ''; print ''; } - + // Other attributes $cols = 2; include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; - + print '
'.$langs->trans("Ref").''; + print ''; print $form->showrefnav($object, 'ref', $linkback, 1, 'ref'); print '
'.$langs->trans("AccountancyJournal").''; - + $accountingjournal = new AccountingJournal($db); $accountingjournal->fetch($object->fk_accountancy_journal); print $accountingjournal->getNomUrl(0,1,1,'',1); - + print '
'; print '
'; @@ -689,7 +689,7 @@ else print '
'; print ''; - + // Categories if ($conf->categorie->enabled) { print '"; - print ''; @@ -374,7 +374,7 @@ else if ($id) // Public note print ''; - print ''; - print '
'.$langs->trans("Categories").''; @@ -705,9 +705,9 @@ else if ($object->type == Account::TYPE_SAVINGS || $object->type == Account::TYPE_CURRENT) { print '
'; - + print '
'; - + print ''; print ''; @@ -726,7 +726,7 @@ else } print ''; - print ''; + print ''; print ''; } @@ -776,7 +776,7 @@ else print ''; print '
'; - + dol_fiche_end(); /* @@ -839,7 +839,7 @@ else dol_fiche_head(''); print '
'; - + print '
'.$langs->trans("BankName").'
'.$langs->trans($val).''.$content.''.$content.'
'; // Ref @@ -921,7 +921,7 @@ else print ''; // Tags-Categories - if ($conf->categorie->enabled) + if ($conf->categorie->enabled) { print ''; // Other attributes - $parameters=array('colspan' => 3); + $parameters=array(); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook if (empty($reshook) && ! empty($extrafields->attribute_label)) { print $object->showOptionals($extrafields,'edit'); } + print '
'.$langs->trans("Categories").''; $cate_arbo = $form->select_all_categories(Categorie::TYPE_ACCOUNT, '', 'parent', 64, 0, 1); @@ -944,12 +944,13 @@ else print '
'; print '
'; diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index b544c99dd4c..43b6dace19c 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -6,7 +6,7 @@ * Copyright (C) 2005-2010 Regis Houssin * Copyright (C) 2013 Florian Henry * Copyright (C) 2015-2016 Marcos García - * Copyright (C) 2015 Alexandre Spangaro + * Copyright (C) 2015-2017 Alexandre Spangaro * Copyright (C) 2016 Ferran Marcet * * This program is free software; you can redistribute it and/or modify @@ -2028,6 +2028,7 @@ class AccountLine extends CommonObject $result.=$langs->trans("BankAccount").': '; $accountstatic=new Account($this->db); $accountstatic->id=$this->fk_account; + $accountstatic->ref=$this->bank_account_ref; $accountstatic->label=$this->bank_account_label; $result.=$accountstatic->getNomUrl(0).', '; } diff --git a/htdocs/compta/bank/various_payment/card.php b/htdocs/compta/bank/various_payment/card.php index 20c49c71468..c0481829425 100644 --- a/htdocs/compta/bank/various_payment/card.php +++ b/htdocs/compta/bank/various_payment/card.php @@ -74,7 +74,7 @@ if ($action == 'add' && empty($cancel)) $datep=dol_mktime(12,0,0, GETPOST("datepmonth"), GETPOST("datepday"), GETPOST("datepyear")); $datev=dol_mktime(12,0,0, GETPOST("datevmonth"), GETPOST("datevday"), GETPOST("datevyear")); if (empty($datev)) $datev=$datep; - + $object->accountid=GETPOST("accountid") > 0 ? GETPOST("accountid","int") : 0; $object->datev=$datev; $object->datep=$datep; @@ -207,7 +207,7 @@ if ($action == 'create') print load_fiche_titre($langs->trans("NewVariousPayment"),'', 'title_accountancy.png'); dol_fiche_head('', ''); - + print ''; // Date payment @@ -274,7 +274,7 @@ if ($action == 'create') print $formaccounting->select_account($accountancy_code, 'accountancy_code', 1, null, 1, 1, ''); print ''; } - else // For external software + else // For external software { print ''; print '
'.$langs->trans("AccountAccounting").''; @@ -282,7 +282,7 @@ if ($action == 'create') } // Other attributes - $parameters=array('colspan' => ' colspan="1"'); + $parameters=array(); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook print '
'; @@ -315,7 +315,7 @@ if ($id) print ''; $linkback = ''.$langs->trans("BackToList").''; - + print ""; print '
'.$langs->trans("Ref").''; print $form->showrefnav($object, 'id', $linkback, 1, 'rowid', 'ref', ''); @@ -372,14 +372,14 @@ if ($id) } // Other attributes - $parameters=array('colspan' => ' colspan="1"'); - $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + $parameters=array('socid'=>$object->id); + include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; print '
'; dol_fiche_end(); - + /* * Action buttons */ diff --git a/htdocs/compta/deplacement/card.php b/htdocs/compta/deplacement/card.php index aa315e5c854..949a7701698 100644 --- a/htdocs/compta/deplacement/card.php +++ b/htdocs/compta/deplacement/card.php @@ -251,7 +251,7 @@ if ($action == 'create') print ''; print ""; - print ''; @@ -277,7 +277,7 @@ if ($action == 'create') // Public note print ''; print ''; - print ''; print ''; - print '
'.$langs->trans("Type").''; + print ''.$langs->trans("Type").''; $form->select_type_fees(GETPOST('type','int'),'type',1); print '
'.$langs->trans('NotePublic').''; + print ''; $doleditor = new DolEditor('note_public', GETPOST('note_public', 'alpha'), '', 200, 'dolibarr_notes', 'In', false, true, true, ROWS_8,'90%'); print $doleditor->Create(1); @@ -289,7 +289,7 @@ if ($action == 'create') { print '
'.$langs->trans('NotePrivate').''; + print ''; $doleditor = new DolEditor('note_private', GETPOST('note_private', 'alpha'), '', 200, 'dolibarr_notes', 'In', false, true, true, ROWS_8, '90%'); print $doleditor->Create(1); @@ -298,7 +298,7 @@ if ($action == 'create') } // Other attributes - $parameters=array('colspan' => ' colspan="2"'); + $parameters=array(); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook print '
'; @@ -340,7 +340,7 @@ else if ($id) // Ref print "
'.$langs->trans("Ref").''; + print ''.$langs->trans("Ref").''; print $object->ref; print '
'.$langs->trans("NotePublic").''; + print ''; $doleditor = new DolEditor('note_public', $object->note_public, '', 200, 'dolibarr_notes', 'In', false, true, true, ROWS_8, '90%'); print $doleditor->Create(1); @@ -385,7 +385,7 @@ else if ($id) if (empty($user->societe_id)) { print '
'.$langs->trans("NotePrivate").''; + print ''; $doleditor = new DolEditor('note_private', $object->note_private, '', 200, 'dolibarr_notes', 'In', false, true, true, ROWS_8, '90%'); print $doleditor->Create(1); @@ -394,7 +394,7 @@ else if ($id) } // Other attributes - $parameters=array('colspan' => ' colspan="3"'); + $parameters=array(); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook print '
'; @@ -412,7 +412,7 @@ else if ($id) else { /* - * Confirm delete trip + * Confirm delete trip */ if ($action == 'delete') { @@ -501,9 +501,9 @@ else if ($id) // Statut print ''.$langs->trans("Status").''.$object->getLibStatut(4).''; - // Other attributes - $parameters=array('colspan' => ' colspan="3"', 'showblocbydefault' => 1); - $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + // Other attributes + $parameters=array('socid'=>$object->id); + include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; print "
"; diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index b739e551b9d..e9be0a0b962 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -615,7 +615,7 @@ if (empty($reshook)) $db->begin(); $amount_ht = $amount_tva = $amount_ttc = array(); - + // Loop on each vat rate $i = 0; foreach ($object->lines as $line) @@ -644,19 +644,19 @@ if (empty($reshook)) $discount->fk_facture_source = $object->id; $error = 0; - - if ($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT || $object->type == Facture::TYPE_SITUATION) + + if ($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT || $object->type == Facture::TYPE_SITUATION) { // If we're on a standard invoice, we have to get excess received to create a discount in TTC without VAT - + $sql = 'SELECT SUM(pf.amount) as total_paiements FROM llx_c_paiement as c, llx_paiement_facture as pf, llx_paiement as p WHERE pf.fk_facture = '.$object->id.' AND p.fk_paiement = c.id AND pf.fk_paiement = p.rowid ORDER BY p.datep, p.tms'; - + $resql = $db->query($sql); $res = $db->fetch_object($resql); $total_paiements = $res->total_paiements; - + $discount->amount_ht = $discount->amount_ttc = $total_paiements - $object->total_ttc; $discount->amount_tva = 0; $discount->tva_tx = 0; @@ -666,7 +666,7 @@ if (empty($reshook)) { $error++; } - + } if ($object->type == Facture::TYPE_CREDIT_NOTE || $object->type == Facture::TYPE_DEPOSIT) { @@ -676,7 +676,7 @@ if (empty($reshook)) $discount->amount_tva = abs($amount_tva[$tva_tx]); $discount->amount_ttc = abs($amount_ttc[$tva_tx]); $discount->tva_tx = abs($tva_tx); - + $result = $discount->create($user); if ($result < 0) { @@ -684,7 +684,7 @@ if (empty($reshook)) break; } } - + } if (empty($error)) @@ -1027,7 +1027,7 @@ if (empty($reshook)) } $id = $object->create($user); // This include class to add_object_linked() and add add_contact() - + if ($id > 0) { dol_include_once('/' . $element . '/class/' . $subelement . '.class.php'); @@ -1049,13 +1049,13 @@ if (empty($reshook)) { if ($typeamount == 'amount') $amount = $valuedeposit; else $amount = $srcobject->total_ttc * ($valuedeposit / 100); - + $TTotalByTva = array(); foreach ($srcobject->lines as &$line) { $TTotalByTva[$line->tva_tx] += $line->total_ttc ; } - + $amount_to_diff = 0; foreach ($TTotalByTva as $tva => &$total) { @@ -1099,10 +1099,10 @@ if (empty($reshook)) $error ++; } } - + $amount_ttc_diff = $amountdeposit[0]; } - + foreach ($amountdeposit as $tva => $amount) { $result = $object->addline( @@ -1116,7 +1116,7 @@ if (empty($reshook)) 0, // remise_percent 0, // date_start 0, // date_end - 0, + 0, $lines[$i]->info_bits, // info_bits 0, 'HT', @@ -1132,16 +1132,16 @@ if (empty($reshook)) $langs->trans('Deposit') ); } - + $diff = $object->total_ttc - $amount_ttc_diff; - + if (!empty($conf->global->MAIN_DEPOSIT_MULTI_TVA) && $diff != 0) { $object->fetch_lines(); $subprice_diff = $object->lines[0]->subprice - $diff / (1 + $object->lines[0]->tva_tx / 100); $object->updateline($object->lines[0]->id, $object->lines[0]->desc, $subprice_diff, $object->lines[0]->qty, $object->lines[0]->remise_percent, $object->lines[0]->date_start, $object->lines[0]->date_end, $object->lines[0]->tva_tx, 0, 0, 'HT', $object->lines[0]->info_bits, $object->lines[0]->product_type, 0, 0, 0, $object->lines[0]->pa_ht, $object->lines[0]->label, 0, array(), 100); } - + } else { @@ -1219,7 +1219,7 @@ if (empty($reshook)) $tva_tx = $lines[$i]->tva_tx; if (! empty($lines[$i]->vat_src_code) && ! preg_match('/\(/', $tva_tx)) $tva_tx .= ' ('.$lines[$i]->vat_src_code.')'; - + // View third's localtaxes for NOW and do not use value from origin. // TODO Is this really what we want ? Yes if source if template invoice but what if proposal or order ? $localtax1_tx = get_localtax($tva_tx, 1, $object->thirdparty); @@ -1556,7 +1556,7 @@ if (empty($reshook)) $tmpvat = price2num(preg_replace('/\s*\(.*\)/', '', $tva_tx)); $tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx)); - + // if price ht was forced (ie: from gui when calculated by margin rate and cost price). TODO Why this ? if (! empty($price_ht)) { @@ -2123,11 +2123,11 @@ if ($action == 'create') if (!empty($conf->multicurrency->enabled) && !empty($soc->multicurrency_code)) $currency_code = $soc->multicurrency_code; } - + if (!empty($soc->id)) $absolute_discount = $soc->getAvailableDiscounts(); $note_public = $object->getDefaultCreateValueFor('note_public', (is_object($objectsrc)?$objectsrc->note_public:null)); $note_private = $object->getDefaultCreateValueFor('note_private', ((! empty($origin) && ! empty($originid) && is_object($objectsrc))?$objectsrc->note_private:null)); - + if (! empty($conf->use_javascript_ajax)) { require_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; @@ -2331,7 +2331,7 @@ if ($action == 'create') if ((empty($origin)) || ((($origin == 'propal') || ($origin == 'commande')) && (! empty($originid)))) { // Deposit - if (empty($conf->global->INVOICE_DISABLE_DEPOSIT)) + if (empty($conf->global->INVOICE_DISABLE_DEPOSIT)) { print '
'; $tmp=' '; @@ -2342,7 +2342,7 @@ if ($action == 'create') }); }); '; - + $desc = $form->textwithpicto($tmp.$langs->trans("InvoiceDeposit"), $langs->transnoentities("InvoiceDepositDesc"), 1, 'help', '', 0, 3); print '
'; print $desc; @@ -2356,7 +2356,7 @@ if ($action == 'create') print '' . $langs->trans('Value') . ':'; } print '
'; - + print '
'; } } @@ -2388,7 +2388,7 @@ if ($action == 'create') } // Replacement - if (empty($conf->global->INVOICE_DISABLE_REPLACEMENT)) + if (empty($conf->global->INVOICE_DISABLE_REPLACEMENT)) { print ''; print '
'; @@ -2435,7 +2435,7 @@ if ($action == 'create') if ($socid > 0) { // Credit note - if (empty($conf->global->INVOICE_DISABLE_CREDIT_NOTE)) + if (empty($conf->global->INVOICE_DISABLE_CREDIT_NOTE)) { print '
'; $tmp='textwithpicto($text, $langs->transnoentities("InvoiceAvoirDesc"), 1, 'help', '', 0, 3); print $desc; - + print '
'; print '    0 ? 'checked':'').' /> "; print '
    0 ? 'checked':'').' /> "; print '
'; - + print '
'; } } @@ -2492,7 +2492,7 @@ if ($action == 'create') print '
' . "\n"; } } - + // Template invoice print '
'; $tmp=' '; @@ -2589,9 +2589,8 @@ if ($action == 'create') } // Other attributes - $parameters = array('objectsrc' => $objectsrc,'colspan' => ' colspan="3"'); - $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by - // hook + $parameters = array('objectsrc' => $objectsrc,'colspan' => ' colspan="2"', 'cols'=>2); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook) && ! empty($extrafields->attribute_label)) { print $object->showOptionals($extrafields, 'edit'); } @@ -2731,7 +2730,7 @@ if ($action == 'create') { print '' . $langs->trans('MulticurrencyTotalHT') . '' . price($objectsrc->multicurrency_total_ht) . ''; print '' . $langs->trans('MulticurrencyTotalVAT') . '' . price($objectsrc->multicurrency_total_tva) . ""; - print '' . $langs->trans('MulticurrencyTotalTTC') . '' . price($objectsrc->multicurrency_total_ttc) . ""; + print '' . $langs->trans('MulticurrencyTotalTTC') . '' . price($objectsrc->multicurrency_total_ttc) . ""; } } @@ -3488,21 +3487,21 @@ else if ($id > 0 || ! empty($ref)) print '
'; print '
'; print '
'; - + print ''; - + if (!empty($conf->multicurrency->enabled) && ($object->multicurrency_code != $conf->currency)) { // Multicurrency Amount HT print ''; print ''; print ''; - + // Multicurrency Amount VAT print ''; print ''; print ''; - + // Multicurrency Amount TTC print ''; print ''; @@ -3584,12 +3583,12 @@ else if ($id > 0 || ! empty($ref)) $nbrows += 5; if (! empty($conf->incoterm->enabled)) $nbrows += 1; - - if ($object->type == Facture::TYPE_SITUATION && ! empty($conf->global->INVOICE_USE_SITUATION)) + + if ($object->type == Facture::TYPE_SITUATION && ! empty($conf->global->INVOICE_USE_SITUATION)) { if (count($object->tab_previous_situation_invoice) > 0 || count($object->tab_next_situation_invoice) > 0) print '
' . fieldLabel('MulticurrencyAmountHT','multicurrency_total_ht') . '' . price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '
' . fieldLabel('MulticurrencyAmountVAT','multicurrency_total_tva') . '' . price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '
' . fieldLabel('MulticurrencyAmountTTC','multicurrency_total_ttc') . '' . price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '
'; - + if (count($object->tab_previous_situation_invoice) > 0) { // List of previous invoices print ''; @@ -3601,7 +3600,7 @@ else if ($id > 0 || ! empty($ref)) print ''; print ''; print ''; - + $total_prev_ht = $total_prev_ttc = 0; foreach ($object->tab_previous_situation_invoice as $prev_invoice) { $totalpaye = $prev_invoice->getSommePaiement(); @@ -3616,9 +3615,9 @@ else if ($id > 0 || ! empty($ref)) print ''; print ''; print ''; - + } - + print ''; print ''; print ''; @@ -3626,7 +3625,7 @@ else if ($id > 0 || ! empty($ref)) print ''; print ''; } - + if (count($object->tab_next_situation_invoice) > 0) { // List of next invoices print ''; @@ -3637,9 +3636,9 @@ else if ($id > 0 || ! empty($ref)) print ''; print ''; print ''; - + $total_next_ht = $total_next_ttc = 0; - + foreach ($object->tab_next_situation_invoice as $next_invoice) { $totalpaye = $next_invoice->getSommePaiement(); $total_next_ht += $next_invoice->total_ht; @@ -3652,9 +3651,9 @@ else if ($id > 0 || ! empty($ref)) print ''; print ''; print ''; - + } - + print ''; print ''; if (! empty($conf->banque->enabled)) print ''; @@ -3664,7 +3663,7 @@ else if ($id > 0 || ! empty($ref)) print ''; print ''; } - + if (count($object->tab_previous_situation_invoice) > 0 || count($object->tab_next_situation_invoice) > 0) print '
' . $langs->trans('AmountTTC') . ' 
' . price($prev_invoice->total_ttc) . '' . $prev_invoice->getLibStatut(3, $totalpaye) . '
' . price($total_prev_ht) . ' 
' . $langs->trans('AmountTTC') . ' 
' . price($next_invoice->total_ttc) . '' . $next_invoice->getLibStatut(3, $totalpaye) . '
 
'; } @@ -3741,7 +3740,7 @@ else if ($id > 0 || ! empty($ref)) print ''; $i ++; } - } + } /*else { print '' . $langs->trans("None") . ''; }*/ @@ -3837,7 +3836,7 @@ else if ($id > 0 || ! empty($ref)) // Billed print '' . $langs->trans("Billed") . ' :' . price($object->total_ttc) . ' '; - + // Remainder to pay print ''; if ($resteapayeraffiche >= 0) @@ -3847,11 +3846,11 @@ else if ($id > 0 || ! empty($ref)) print ' :'; print '' . price($resteapayeraffiche) . ''; print ' '; - } + } else // Credit note { $cssforamountpaymentcomplete=''; - + // Total already paid back print ''; print $langs->trans('AlreadyPaidBack'); @@ -3909,14 +3908,14 @@ else if ($id > 0 || ! empty($ref)) { if ($object->situation_cycle_ref && $object->statut == 0) { print '
'; - + print ''; print ''; print ''; print ''; - + print ''; - + print ''; if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { @@ -3954,11 +3953,11 @@ else if ($id > 0 || ! empty($ref)) print ''; print ''; print ''; - + print '
%
'; - + print ''; - + print '
'; } } @@ -3969,14 +3968,14 @@ else if ($id > 0 || ! empty($ref)) '; - + if (! empty($conf->use_javascript_ajax) && $object->statut == 0) { include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php'; } - + print '
'; print ''; - + // Show object lines if (! empty($object->lines)) $ret = $object->printObjectLines($action, $mysoc, $soc, $lineid, 1); @@ -4037,10 +4036,10 @@ else if ($id > 0 || ! empty($ref)) } } } - + $discount = new DiscountAbsolute($db); $result = $discount->fetch(0, $object->id); - + // Reopen a standard paid invoice if ((($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT) || ($object->type == Facture::TYPE_CREDIT_NOTE && empty($discount->id)) @@ -4097,7 +4096,7 @@ else if ($id > 0 || ! empty($ref)) //print ''.$langs->trans("MakeWithdrawRequest").''; } } - + // Create payment if ($object->type != Facture::TYPE_CREDIT_NOTE && $object->statut == 1 && $object->paye == 0 && $user->rights->facture->paiement) { if ($objectidnext) { @@ -4253,7 +4252,7 @@ else if ($id > 0 || ! empty($ref)) // Show links to link elements $linktoelem = $form->showLinkToObjectBlock($object, null, array('invoice')); $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); - + // Link for paypal payment if (! empty($conf->paypal->enabled) && $object->statut != 0) { include_once DOL_DOCUMENT_ROOT . '/paypal/lib/paypal.lib.php'; diff --git a/htdocs/compta/localtax/card.php b/htdocs/compta/localtax/card.php index 1772b6861dd..315b89637af 100644 --- a/htdocs/compta/localtax/card.php +++ b/htdocs/compta/localtax/card.php @@ -158,7 +158,7 @@ if ($id) if ($action == 'create') { print load_fiche_titre($langs->transcountry($lttype==2?"newLT2Payment":"newLT1Payment",$mysoc->country_code)); - + print ''."\n"; print ''; print ''; @@ -193,14 +193,14 @@ if ($action == 'create') $form->select_types_paiements(GETPOST("paiementtype"), "paiementtype"); print "\n"; print ""; - + // Number print ''."\n"; } // Other attributes - $parameters=array('colspan' => ' colspan="1"'); + $parameters=array(); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook print '
'.$langs->trans('Numero'); print ' ('.$langs->trans("ChequeOrTransferNumber").')'; print '
'; @@ -237,20 +237,20 @@ if ($id) print ''; print ""; - print ''; print ""; - print ''; - print ''; - print ''; + print ''; if (! empty($conf->banque->enabled)) { @@ -261,7 +261,7 @@ if ($id) print ''; print ''; - print ''; print ''; @@ -269,13 +269,13 @@ if ($id) } // Other attributes - $parameters=array('colspan' => ' colspan="3"'); + $parameters=array(); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$vatpayment,$action); // Note that $action and $object may have been modified by hook - + print '
'.$langs->trans("Ref").''; + print ''.$langs->trans("Ref").''; print $vatpayment->ref; print '
'.$langs->trans("DatePayment").''; + print ''.$langs->trans("DatePayment").''; print dol_print_date($vatpayment->datep,'day'); print '
'.$langs->trans("DateValue").''; + print '
'.$langs->trans("DateValue").''; print dol_print_date($vatpayment->datev,'day'); print '
'.$langs->trans("Amount").''.price($vatpayment->amount).'
'.$langs->trans("Amount").''.price($vatpayment->amount).'
'.$langs->trans('BankTransactionLine').''; + print ''; print $bankline->getNomUrl(1,0,'showall'); print '
'; dol_fiche_end(); - + /* * Boutons d'actions diff --git a/htdocs/compta/prelevement/bons.php b/htdocs/compta/prelevement/bons.php index 41f6abb25c5..9a5585c2513 100644 --- a/htdocs/compta/prelevement/bons.php +++ b/htdocs/compta/prelevement/bons.php @@ -1,6 +1,6 @@ - * Copyright (C) 2005-2008 Laurent Destailleur + * Copyright (C) 2005-2017 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2010-2012 Juanjo Menent * @@ -107,33 +107,32 @@ if ($result) print ''; print ''; print ''; - + print_barre_liste($langs->trans("WithdrawalsReceipts"), $page, $_SERVER["PHP_SELF"], $urladd, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_generic', 0, '', '', $limit); $moreforfilter=''; - + print '
'; print ''."\n"; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; print_liste_field_titre($langs->trans("WithdrawalsReceipts"),$_SERVER["PHP_SELF"],"p.ref",'','','class="liste_titre"'); print_liste_field_titre($langs->trans("Date"),$_SERVER["PHP_SELF"],"p.datec","","",'class="liste_titre" align="center"'); print_liste_field_titre($langs->trans("Amount"),$_SERVER["PHP_SELF"],"","","",'align="center"'); print "\n"; - print ''; - print ''; - print ''; - print ''; - print ''; - - while ($i < min($num,$limit)) { - $obj = $db->fetch_object($result); + $obj = $db->fetch_object($result); print '
 '; + $searchpicto=$form->showFilterButtons(); + print $searchpicto; + print '
 '; - $searchpicto=$form->showFilterAndCheckAddButtons(0); - print $searchpicto; - print '
'; @@ -151,9 +150,9 @@ if ($result) } print "
"; print '
'; - + print ''; - + $db->free($result); } else diff --git a/htdocs/compta/prelevement/create.php b/htdocs/compta/prelevement/create.php index 5d77a9b9771..0834b3500a7 100644 --- a/htdocs/compta/prelevement/create.php +++ b/htdocs/compta/prelevement/create.php @@ -94,9 +94,7 @@ llxHeader('', $langs->trans("NewStandingOrder")); if (prelevement_check_config() < 0) { $langs->load("errors"); - print '
'; - print $langs->trans("ErrorModuleSetupNotComplete"); - print '
'; + setEventMessages($langs->trans("ErrorModuleSetupNotComplete"), null, 'errors'); } /*$h=0; @@ -148,7 +146,7 @@ if ($nb) } else { - print ''.$langs->trans("CreateAll")."\n"; + print 'transnoentitiesnoconv("StandingOrders"))).'">'.$langs->trans("CreateAll")."\n"; } print "
\n"; @@ -194,7 +192,7 @@ if ($resql) while ($i < $num && $i < 20) { $obj = $db->fetch_object($resql); - + print ''; print ''; $invoicestatic->id=$obj->rowid; @@ -268,7 +266,7 @@ if ($result) while ($i < min($num,$limit)) { $obj = $db->fetch_object($result); - + print ''; diff --git a/htdocs/compta/prelevement/index.php b/htdocs/compta/prelevement/index.php index 32257a71a0f..271ce4da7fe 100644 --- a/htdocs/compta/prelevement/index.php +++ b/htdocs/compta/prelevement/index.php @@ -129,7 +129,7 @@ if ($resql) $invoicestatic->type=$obj->type; $alreadypayed=$invoicestatic->getSommePaiement(); - + print ''; print $invoicestatic->getNomUrl(1,'withdraw'); print ''; @@ -157,7 +157,7 @@ if ($resql) } else { - print ''.$langs->trans("NoInvoiceToWithdraw").''; + print ''.$langs->trans("NoInvoiceToWithdraw", $langs->transnoentitiesnoconv("StandingOrders")).''; } print "
"; } @@ -197,7 +197,7 @@ if ($result) while ($i < min($num,$limit)) { $obj = $db->fetch_object($result); - + print ''; diff --git a/htdocs/compta/prelevement/list.php b/htdocs/compta/prelevement/list.php index e9e46b6afff..208be88aeae 100644 --- a/htdocs/compta/prelevement/list.php +++ b/htdocs/compta/prelevement/list.php @@ -130,10 +130,24 @@ if ($result) print '
'; $moreforfilter=''; - + print '
'; print ''."\n"; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; print_liste_field_titre($langs->trans("Line"),$_SERVER["PHP_SELF"]); print_liste_field_titre($langs->trans("WithdrawalsReceipts"),$_SERVER["PHP_SELF"],"p.ref"); @@ -144,24 +158,10 @@ if ($result) print_liste_field_titre($langs->trans("Amount"),$_SERVER["PHP_SELF"],"pl.amount","","",'align="right"'); print_liste_field_titre(''); print "\n"; - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; while ($i < min($num,$limit)) { - $obj = $db->fetch_object($result); + $obj = $db->fetch_object($result); print '
   '; + $searchpicto=$form->showFilterButtons(); + print $searchpicto; + print '
   '; - $searchpicto=$form->showFilterAndCheckAddButtons(0); - print $searchpicto; - print '
'; @@ -199,9 +199,9 @@ if ($result) } print "
"; print '
'; - + print '
'; - + $db->free($result); } else diff --git a/htdocs/compta/salaries/card.php b/htdocs/compta/salaries/card.php index 68f59d03cfa..9abbecd35fc 100644 --- a/htdocs/compta/salaries/card.php +++ b/htdocs/compta/salaries/card.php @@ -1,8 +1,8 @@ +/* Copyright (C) 2011-2017 Alexandre Spangaro * Copyright (C) 2014 Laurent Destailleur * Copyright (C) 2015 Jean-François Ferry - * Copyright (C) 2015 Charlie BENKE + * Copyright (C) 2015 Charlie BENKE * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,9 +19,9 @@ */ /** - * \file htdocs/compta/salaries/card.php - * \ingroup salaries - * \brief Page of salaries payments + * \file htdocs/compta/salaries/card.php + * \ingroup salaries + * \brief Page of salaries payments */ require '../../main.inc.php'; @@ -72,7 +72,7 @@ if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel")) $datesp=dol_mktime(12,0,0, $_POST["datespmonth"], $_POST["datespday"], $_POST["datespyear"]); $dateep=dol_mktime(12,0,0, $_POST["dateepmonth"], $_POST["dateepday"], $_POST["dateepyear"]); if (empty($datev)) $datev=$datep; - + $object->accountid=GETPOST("accountid") > 0 ? GETPOST("accountid","int") : 0; $object->fk_user=GETPOST("fk_user") > 0 ? GETPOST("fk_user","int") : 0; $object->datev=$datev; @@ -116,7 +116,7 @@ if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel")) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankAccount")), null, 'errors'); $error++; } - + if (! $error) { $db->begin(); @@ -229,7 +229,7 @@ if ($action == 'create') print load_fiche_titre($langs->trans("NewSalaryPayment"),'', 'title_accountancy.png'); dol_fiche_head('', ''); - + print ''; // Date payment @@ -300,7 +300,7 @@ if ($action == 'create') } // Other attributes - $parameters=array('colspan' => ' colspan="1"'); + $parameters=array(); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook print '
'; @@ -340,35 +340,35 @@ if ($id) $morehtmlref.=$langs->trans('Employee') . ' : ' . $userstatic->getNomUrl(1); $morehtmlref.='
'; - dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', ''); + dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', ''); - print '
'; + print '
'; print '
'; - print ''; + print '
'; // Label print ''; print ""; - print ''; - print ''; print ""; - print ''; - print ''; - print ''; + print ''; if (! empty($conf->banque->enabled)) { @@ -379,7 +379,7 @@ if ($id) print ''; print ''; - print ''; print ''; @@ -387,7 +387,7 @@ if ($id) } // Other attributes - $parameters=array('colspan' => ' colspan="3"'); + $parameters=array(); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook print '
'.$langs->trans("Label").''.$object->label.'
'.$langs->trans("DateStartPeriod").''; + print ''.$langs->trans("DateStartPeriod").''; print dol_print_date($object->datesp,'day'); print '
'.$langs->trans("DateEndPeriod").''; + print '
'.$langs->trans("DateEndPeriod").''; print dol_print_date($object->dateep,'day'); print '
'.$langs->trans("DatePayment").''; + print ''.$langs->trans("DatePayment").''; print dol_print_date($object->datep,'day'); print '
'.$langs->trans("DateValue").''; + print '
'.$langs->trans("DateValue").''; print dol_print_date($object->datev,'day'); print '
'.$langs->trans("Amount").''.price($object->amount,0,$outputlangs,1,-1,-1,$conf->currency).'
'.$langs->trans("Amount").''.price($object->amount,0,$outputlangs,1,-1,-1,$conf->currency).'
'.$langs->trans('BankTransactionLine').''; + print ''; print $bankline->getNomUrl(1,0,'showall'); print '
'; @@ -396,7 +396,7 @@ if ($id) dol_fiche_end(); - + /* * Action buttons */ @@ -405,7 +405,7 @@ if ($id) { if (! empty($user->rights->salaries->delete)) { - print ''.$langs->trans("Delete").''; + print ''.$langs->trans("Delete").''; } else { diff --git a/htdocs/compta/tva/card.php b/htdocs/compta/tva/card.php index e33ec6b3d55..4a3ea9ee516 100644 --- a/htdocs/compta/tva/card.php +++ b/htdocs/compta/tva/card.php @@ -65,7 +65,7 @@ if ($action == 'setdatev' && $user->rights->tax->charges->creer) $object->datev=dol_mktime(12,0,0,$_POST['datevmonth'],$_POST['datevday'],$_POST['datevyear']); $result=$object->update($user); if ($result < 0) dol_print_error($db,$object->error); - + $action=''; } @@ -81,7 +81,7 @@ if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel")) $object->num_payment=GETPOST("num_payment"); $object->datev=$datev; $object->datep=$datep; - + $amount = price2num(GETPOST("amount")); if ($refund == 1) { $amount= -$amount; @@ -89,7 +89,7 @@ if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel")) $object->amount= $amount; $object->label=GETPOST("label"); $object->note=GETPOST("note"); - + if (empty($object->datev)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DateValue")), null, 'errors'); @@ -207,11 +207,11 @@ if ($action == 'create') print '$(document).ready(function () { $("#radiopayment").click(function() { $("#label").val($(this).data("label")); - + }); $("#radiorefund").click(function() { $("#label").val($(this).data("label")); - + }); });'; print ''."\n"; @@ -282,7 +282,7 @@ if ($action == 'create') print ''."\n"; // Other attributes - $parameters=array('colspan' => ' colspan="1"'); + $parameters=array(); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook print ''; @@ -349,7 +349,8 @@ if ($id) } // Other attributes - $reshook=$hookmanager->executeHooks('formObjectOptions','',$object,$action); // Note that $action and $object may have been modified by hook + $parameters=array(); + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook print ''; diff --git a/htdocs/conf/conf.php.example b/htdocs/conf/conf.php.example index 89e1458d4fd..356e76ba374 100644 --- a/htdocs/conf/conf.php.example +++ b/htdocs/conf/conf.php.example @@ -324,14 +324,4 @@ $dolibarr_nocsrfcheck='0'; // External module //############################## -// multicompany_transverse_mode -// Prerequisite: Need external module "multicompany" -// Pyramidal (0): The rights and groups are managed in each entity. Each user belongs to the entity he was created into. -// Transversal (1): The user is created and managed only into master entity but can login to all entities if he is admmin -// of entity or belongs to at least one user group created into entity. - -// Default value: 0 (pyramidal) -// Examples: -// $multicompany_transverse_mode='1'; - diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index fde2e428169..67a7d9b31e4 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -316,7 +316,7 @@ if (empty($reshook)) $object->photo = dol_sanitizeFileName($_FILES['photo']['name']); // Create thumbs - $object->addThumbs($newfile); + $object->addThumbs($newfile); } } } @@ -664,7 +664,7 @@ else } // Other attributes - $parameters=array('colspan' => ' colspan="3"'); + $parameters=array('colspan' => ' colspan="3"','cols'=>3); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook if (empty($reshook) && ! empty($extrafields->attribute_label)) { @@ -674,7 +674,7 @@ else print "
"; print '
'; - + // Add personnal information print load_fiche_titre('
'.$langs->trans("PersonalInformations").'
','',''); @@ -787,7 +787,7 @@ else print $object->ref; print ''; } - + // Lastname print ''; print 'lastname).'" autofocus="autofocus">'; @@ -932,7 +932,7 @@ else } // Other attributes - $parameters=array('colspan' => ' colspan="3"'); + $parameters=array('colspan' => ' colspan="3"', 'cols'=>3); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook if (empty($reshook) && ! empty($extrafields->attribute_label)) { @@ -1054,7 +1054,7 @@ else } $linkback = ''.$langs->trans("BackToList").''; - + $morehtmlref='
'; if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) { @@ -1064,14 +1064,14 @@ else if ($objsoc->id > 0) $morehtmlref.=$objsoc->getNomUrl(1); else $morehtmlref.=$langs->trans("ContactNotLinkedToCompany"); } - $morehtmlref.='
'; - + $morehtmlref.='
'; + dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref); - - + + print '
'; print '
'; - + print '
'; print ''; @@ -1102,26 +1102,14 @@ else print $object->LibPubPriv($object->priv); print ''; - // Note Public - /* - print ''; - - // Note Private - print ''; - */ - print '
'.$langs->trans("NotePublic").''; - print nl2br($object->note_public); - print '
'.$langs->trans("NotePrivate").''; - print nl2br($object->note_private); - print '
'; - + print '
'; print '
'; - + print '
'; print ''; - + // Categories if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire)) { print ''; @@ -1130,14 +1118,10 @@ else print ''; } - // Other attributes - $parameters=array('socid'=>$socid, 'colspan' => ' colspan="3"'); - $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - if (empty($reshook) && ! empty($extrafields->attribute_label)) - { - print $object->showOptionals($extrafields); - } + // Other attributes + $cols = 3; + $parameyers=array('socid'=>$socid); + include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; $object->load_ref_elements(); @@ -1193,10 +1177,10 @@ else print ''; print "
' . $langs->trans("Categories") . '
"; - + print '
'; print '
'; - + print dol_fiche_end(); // Barre d'actions diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 31e5d6f3094..3c644e4260c 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -104,13 +104,13 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (empty($reshook)) { include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once - + include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once - + if ($action == 'confirm_active' && $confirm == 'yes' && $user->rights->contrat->activer) { $result = $object->active_line($user, GETPOST('ligne'), GETPOST('date'), GETPOST('dateend'), GETPOST('comment')); - + if ($result > 0) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); @@ -136,13 +136,13 @@ if (empty($reshook)) header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; } - else + else { setEventMessages($object->error, $object->errors, 'errors'); } } } - + // Si ajout champ produit predefini if (GETPOST('mode')=='predefined') { @@ -157,7 +157,7 @@ if (empty($reshook)) $date_end=dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), 0, GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear')); } } - + // Si ajout champ produit libre if (GETPOST('mode')=='libre') { @@ -172,7 +172,7 @@ if (empty($reshook)) $date_end_sl=dol_mktime(GETPOST('date_end_slhour'), GETPOST('date_end_slmin'), 0, GETPOST('date_end_slmonth'), GETPOST('date_end_slday'), GETPOST('date_end_slyear')); } } - + // Param dates $date_contrat=''; $date_start_update=''; @@ -199,7 +199,7 @@ if (empty($reshook)) { $datecontrat = dol_mktime(GETPOST('rehour'), GETPOST('remin'), 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); } - + // Add contract if ($action == 'add' && $user->rights->contrat->creer) { @@ -210,29 +210,29 @@ if (empty($reshook)) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors'); $action='create'; } - + if ($socid<1) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ThirdParty")), null, 'errors'); $action='create'; $error++; } - + // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost($extralabels, $object); if ($ret < 0) { $error ++; $action = 'create'; } - + if (! $error) { $object->socid = $socid; $object->date_contrat = $datecontrat; - + $object->commercial_suivi_id = GETPOST('commercial_suivi_id','int'); $object->commercial_signature_id = GETPOST('commercial_signature_id','int'); - + $object->note_private = GETPOST('note_private','alpha'); $object->note_public = GETPOST('note_public','alpha'); $object->fk_project = GETPOST('projectid','int'); @@ -251,33 +251,33 @@ if (empty($reshook)) $element = $regs[1]; $subelement = $regs[2]; } - + // For compatibility if ($element == 'order') { $element = $subelement = 'commande'; } if ($element == 'propal') { $element = 'comm/propal'; $subelement = 'propal'; } - + $object->origin = $origin; $object->origin_id = $originid; - + // Possibility to add external linked objects with hooks $object->linked_objects[$object->origin] = $object->origin_id; if (is_array($_POST['other_linked_objects']) && ! empty($_POST['other_linked_objects'])) { $object->linked_objects = array_merge($object->linked_objects, $_POST['other_linked_objects']); } - + $id = $object->create($user); if ($id < 0) { setEventMessages($object->error, $object->errors, 'errors'); } - + if ($id > 0) { dol_include_once('/'.$element.'/class/'.$subelement.'.class.php'); - + $classname = ucfirst($subelement); $srcobject = new $classname($db); - + dol_syslog("Try to find source object origin=".$object->origin." originid=".$object->origin_id." to add lines"); $result=$srcobject->fetch($object->origin_id); if ($result > 0) @@ -289,27 +289,27 @@ if (empty($reshook)) $srcobject->fetch_lines(); $lines = $srcobject->lines; } - + $fk_parent_line=0; $num=count($lines); - + for ($i=0;$i<$num;$i++) { $product_type=($lines[$i]->product_type?$lines[$i]->product_type:0); - + if ($product_type == 1 || (! empty($conf->global->CONTRACT_SUPPORT_PRODUCTS) && in_array($product_type, array(0,1)))) { // TODO Exclude also deee // service prédéfini if ($lines[$i]->fk_product > 0) { $product_static = new Product($db); - + // Define output language if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { $prod = new Product($db); $prod->id=$lines[$i]->fk_product; $prod->getMultiLangs(); - + $outputlangs = $langs; $newlang=''; if (empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id'); @@ -319,14 +319,14 @@ if (empty($reshook)) $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($newlang); } - + $label = (! empty($prod->multilangs[$outputlangs->defaultlang]["libelle"])) ? $prod->multilangs[$outputlangs->defaultlang]["libelle"] : $lines[$i]->product_label; } else { $label = $lines[$i]->product_label; } - + $desc .= ($lines[$i]->desc && $lines[$i]->desc!=$lines[$i]->libelle)?dol_htmlentitiesbr($lines[$i]->desc):''; } else { @@ -338,7 +338,7 @@ if (empty($reshook)) // View third's localtaxes for now $localtax1_tx = get_localtax($txtva, 1, $object->thirdparty); $localtax2_tx = get_localtax($txtva, 2, $object->thirdparty); - + $result = $object->addline( $desc, $lines[$i]->subprice, @@ -358,7 +358,7 @@ if (empty($reshook)) array(), $lines[$i]->fk_unit ); - + if ($result < 0) { $error++; @@ -372,13 +372,13 @@ if (empty($reshook)) setEventMessages($srcobject->error, $srcobject->errors, 'errors'); $error++; } - + // Hooks $parameters = array('objFrom' => $srcobject); $reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been // modified by hook if ($reshook < 0) - $error++; + $error++; } else { @@ -401,12 +401,12 @@ if (empty($reshook)) } } } - + else if ($action == 'classin' && $user->rights->contrat->creer) { $object->setProject(GETPOST('projectid')); } - + // Add a new line else if ($action == 'addline' && $user->rights->contrat->creer) { @@ -425,10 +425,10 @@ if (empty($reshook)) $idprod=GETPOST('idprod', 'int'); $tva_tx = ''; } - + $qty = GETPOST('qty'.$predef); $remise_percent = GETPOST('remise_percent'.$predef); - + if ($qty == '') { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Qty")), null, 'errors'); @@ -439,7 +439,7 @@ if (empty($reshook)) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Description")), null, 'errors'); $error++; } - + // Extrafields $extrafieldsline = new ExtraFields($db); $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); @@ -458,7 +458,7 @@ if (empty($reshook)) $date_start=dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start'.$predef.'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year')); $date_end=dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end'.$predef.'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year')); $price_base_type = (GETPOST('price_base_type', 'alpha')?GETPOST('price_base_type', 'alpha'):'HT'); - + // Ecrase $pu par celui du produit // Ecrase $desc par celui du produit // Ecrase $tva_tx par celui du produit @@ -467,17 +467,17 @@ if (empty($reshook)) { $prod = new Product($db); $prod->fetch($idprod); - + // Update if prices fields are defined $tva_tx = get_default_tva($mysoc,$object->thirdparty,$prod->id); $tva_npr = get_default_npr($mysoc,$object->thirdparty,$prod->id); if (empty($tva_tx)) $tva_npr=0; - + $pu_ht = $prod->price; $pu_ttc = $prod->price_ttc; $price_min = $prod->price_min; $price_base_type = $prod->price_base_type; - + // On defini prix unitaire if ($conf->global->PRODUIT_MULTIPRICES && $object->thirdparty->price_level) { @@ -489,11 +489,11 @@ if (empty($reshook)) elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php'; - + $prodcustprice = new Productcustomerprice($db); - + $filter = array('t.fk_product' => $prod->id,'t.fk_soc' => $object->thirdparty->id); - + $result = $prodcustprice->fetch_all('', '', 0, 0, $filter); if ($result) { if (count($prodcustprice->lines) > 0) { @@ -504,10 +504,10 @@ if (empty($reshook)) } } } - + $tmpvat = price2num(preg_replace('/\s*\(.*\)/', '', $tva_tx)); $tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx)); - + // On reevalue prix selon taux tva car taux tva transaction peut etre different // de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur). if ($tmpvat != $tmpprodvat) @@ -521,7 +521,7 @@ if (empty($reshook)) $pu_ttc = price2num($pu_ht * (1 + ($tmpvat/100)), 'MU'); } } - + $desc=$prod->description; $desc=dol_concatdesc($desc,$product_desc); $fk_unit = $prod->fk_unit; @@ -535,20 +535,20 @@ if (empty($reshook)) $desc=$product_desc; $fk_unit= GETPOST('units', 'alpha'); } - + $localtax1_tx=get_localtax($tva_tx,1,$object->thirdparty,$mysoc,$tva_npr); $localtax2_tx=get_localtax($tva_tx,2,$object->thirdparty,$mysoc,$tva_npr); - + // ajout prix achat $fk_fournprice = $_POST['fournprice']; if ( ! empty($_POST['buying_price']) ) $pa_ht = $_POST['buying_price']; else $pa_ht = null; - + $info_bits=0; if ($tva_npr) $info_bits |= 0x01; - + if($price_min && (price2num($pu_ht)*(1-price2num($remise_percent)/100) < price2num($price_min))) { $object->error = $langs->trans("CantBeLessThanMinPrice",price(price2num($price_min,'MU'),0,$langs,0,0,-1,$conf->currency)); @@ -577,7 +577,7 @@ if (empty($reshook)) $fk_unit ); } - + if ($result > 0) { // Define output language @@ -591,14 +591,14 @@ if (empty($reshook)) $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); } - + $ret = $object->fetch($id); // Reload to get new records - + $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } - + unset($_POST ['prod_entry_mode']); - + unset($_POST['qty']); unset($_POST['type']); unset($_POST['remise_percent']); @@ -615,7 +615,7 @@ if (empty($reshook)) unset($_POST ['np_markRate']); unset($_POST['dp_desc']); unset($_POST['idprod']); - + unset($_POST['date_starthour']); unset($_POST['date_startmin']); unset($_POST['date_startsec']); @@ -635,30 +635,30 @@ if (empty($reshook)) } } } - + else if ($action == 'updateline' && $user->rights->contrat->creer && ! GETPOST('cancel')) { $objectline = new ContratLigne($db); if ($objectline->fetch(GETPOST('elrowid'))) { $db->begin(); - + if ($date_start_real_update == '') $date_start_real_update=$objectline->date_ouverture; if ($date_end_real_update == '') $date_end_real_update=$objectline->date_cloture; - + $vat_rate = GETPOST('eltva_tx'); // Define info_bits $info_bits = 0; if (preg_match('/\*/', $vat_rate)) $info_bits |= 0x01; - + // Define vat_rate $vat_rate = str_replace('*', '', $vat_rate); $localtax1_tx=get_localtax($vat_rate, 1, $object->thirdparty, $mysoc); $localtax2_tx=get_localtax($vat_rate, 2, $object->thirdparty, $mysoc); - + $txtva = $vat_rate; - + // Clean vat code $vat_src_code=''; if (preg_match('/\((.*)\)/', $txtva, $reg)) @@ -666,16 +666,16 @@ if (empty($reshook)) $vat_src_code = $reg[1]; $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. } - + // ajout prix d'achat $fk_fournprice = $_POST['fournprice']; if ( ! empty($_POST['buying_price']) ) $pa_ht = $_POST['buying_price']; else $pa_ht = null; - + $fk_unit = GETPOST('unit', 'alpha'); - + $objectline->description=GETPOST('product_desc'); $objectline->price_ht=GETPOST('elprice'); $objectline->subprice=GETPOST('elprice'); @@ -692,21 +692,21 @@ if (empty($reshook)) $objectline->fk_user_cloture=$user->id; $objectline->fk_fournprice=$fk_fournprice; $objectline->pa_ht=$pa_ht; - + if ($fk_unit > 0) { $objectline->fk_unit = GETPOST('unit'); } else { $objectline->fk_unit = null; } - + // Extrafields $extrafieldsline = new ExtraFields($db); $extralabelsline = $extrafieldsline->fetch_name_optionals_label($objectline->table_element); $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef); $objectline->array_options=$array_options; - + // TODO verifier price_min si fk_product et multiprix - + $result=$objectline->update($user); if ($result > 0) { @@ -723,11 +723,11 @@ if (empty($reshook)) setEventMessages($objectline->error, $objectline->errors, 'errors'); } } - + else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->contrat->creer) { $result = $object->deleteline(GETPOST('lineid'),$user); - + if ($result >= 0) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); @@ -738,23 +738,23 @@ if (empty($reshook)) setEventMessages($object->error, $object->errors, 'errors'); } } - + else if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->contrat->creer) { $result = $object->validate($user); } - + else if ($action == 'reopen' && $user->rights->contrat->creer) { $result = $object->reopen($user); } - + // Close all lines else if ($action == 'confirm_close' && $confirm == 'yes' && $user->rights->contrat->creer) { $object->cloture($user); } - + else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->contrat->supprimer) { $result=$object->delete($user); @@ -768,7 +768,7 @@ if (empty($reshook)) setEventMessages($object->error, $object->errors, 'errors'); } } - + else if ($action == 'confirm_move' && $confirm == 'yes' && $user->rights->contrat->creer) { if (GETPOST('newcid') > 0) @@ -791,39 +791,39 @@ if (empty($reshook)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("RefNewContract")), null, 'errors'); } - } - else if ($action == 'update_extras') + } + else if ($action == 'update_extras') { // Fill array 'array_options' with data from update form $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute')); if ($ret < 0) $error ++; - + if (! $error) { - + $result = $object->insertExtraFields(); if ($result < 0) { $error ++; } } else if ($reshook < 0) $error ++; - + if ($error) { $action = 'edit_extras'; setEventMessages($object->error, $object->errors, 'errors'); } - } - elseif ($action=='setref_supplier') + } + elseif ($action=='setref_supplier') { $cancelbutton = GETPOST('cancel'); if (!$cancelbutton) { - + $result = $object->fetch($id); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } - + $result = $object->setValueFrom('ref_supplier', GETPOST('ref_supplier','alpha'), '', null, 'text', '', $user, 'CONTRACT_MODIFY'); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -838,17 +838,17 @@ if (empty($reshook)) exit; } } - elseif ($action=='setref_customer') + elseif ($action=='setref_customer') { $cancelbutton = GETPOST('cancel'); - + if (!$cancelbutton) { $result = $object->fetch($id); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } - + $result = $object->setValueFrom('ref_customer', GETPOST('ref_customer','alpha'), '', null, 'text', '', $user, 'CONTRACT_MODIFY'); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -863,16 +863,16 @@ if (empty($reshook)) exit; } } - elseif ($action=='setref') + elseif ($action=='setref') { $cancelbutton = GETPOST('cancel'); - + if (!$cancelbutton) { $result = $object->fetch($id); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } - + $result = $object->setValueFrom('ref', GETPOST('ref','alpha'), '', null, 'text', '', $user, 'CONTRACT_MODIFY'); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -886,11 +886,11 @@ if (empty($reshook)) header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $id); exit; } - } - elseif ($action=='setdate_contrat') + } + elseif ($action=='setdate_contrat') { $cancelbutton = GETPOST('cancel'); - + if (!$cancelbutton) { $result = $object->fetch($id); if ($result < 0) { @@ -911,13 +911,13 @@ if (empty($reshook)) exit; } } - + // Generation doc (depuis lien ou depuis cartouche doc) else if ($action == 'builddoc' && $user->rights->contrat->creer) { if (GETPOST('model')) { $object->setDocModel($user, GETPOST('model')); } - + // Define output language $outputlangs = $langs; if (! empty($conf->global->MAIN_MULTILANGS)) { @@ -933,12 +933,12 @@ if (empty($reshook)) $action=''; } } - + // Remove file in doc form else if ($action == 'remove_file' && $user->rights->contrat->creer) { if ($object->id > 0) { require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; - + $langs->load("other"); $upload_dir = $conf->contrat->dir_output; $file = $upload_dir . '/' . GETPOST('file'); @@ -965,7 +965,7 @@ if (empty($reshook)) { $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); $result = $object->add_contact($contactid, GETPOST('type'), GETPOST('source')); - + if ($result >= 0) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); @@ -984,18 +984,18 @@ if (empty($reshook)) } } } - + // bascule du statut d'un contact else if ($action == 'swapstatut') { $result=$object->swapContactStatus(GETPOST('ligne')); } - + // Efface un contact else if ($action == 'deletecontact') { $result = $object->delete_contact(GETPOST('lineid')); - + if ($result >= 0) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); @@ -1040,7 +1040,7 @@ llxHeader('',$langs->trans("Contract"),""); $form = new Form($db); $formfile = new FormFile($db); if (! empty($conf->projet->enabled)) $formproject = new FormProjets($db); - + $objectlignestatic=new ContratLigne($db); // Load object modContract @@ -1209,7 +1209,7 @@ if ($action == 'create') } // Other attributes - $parameters=array('objectsrc' => $objectsrc,'colspan' => ' colspan="3"'); + $parameters=array('objectsrc' => $objectsrc,'colspan' => ' colspan="3"', 'cols'=>3); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook // Other attributes @@ -1333,7 +1333,7 @@ else $linkback = ''.$langs->trans("BackToList").''; - + $morehtmlref=''; if (! empty($modCodeContract->code_auto)) { $morehtmlref.=$object->ref; @@ -1341,7 +1341,7 @@ else $morehtmlref.=$form->editfieldkey("",'ref',$object->ref,$object,$user->rights->contrat->creer,'string','',0,3); $morehtmlref.=$form->editfieldval("",'ref',$object->ref,$object,$user->rights->contrat->creer,'string','',0,2); } - + $morehtmlref.='
'; // Ref customer $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_customer', $object->ref_customer, $object, $user->rights->contrat->creer, 'string', '', 0, 1); @@ -1392,10 +1392,10 @@ else print '
'; print '
'; - - + + print ''; - + // Ligne info remises tiers print '
'.$langs->trans('Discount').''; if ($object->thirdparty->remise_percent) print $langs->trans("CompanyHasRelativeDiscount",$object->thirdparty->remise_percent); @@ -1423,7 +1423,7 @@ else print "
"; print '
'; - + if (! empty($object->brouillon) && $user->rights->contrat->creer) { print ''; @@ -1615,7 +1615,7 @@ else { print dol_print_date($db->jdate($objp->date_debut)); // Warning si date prevu passee et pas en service - if ($objp->statut == 0 && $db->jdate($objp->date_debut) < ($now - $conf->contrat->services->inactifs->warning_delay)) { + if ($objp->statut == 0 && $db->jdate($objp->date_debut) < ($now - $conf->contrat->services->inactifs->warning_delay)) { $warning_delay=$conf->contrat->services->inactifs->warning_delay / 3600 / 24; $textlate = $langs->trans("Late").' = '.$langs->trans("DateReference").' > '.$langs->trans("DateToday").' '.(ceil($warning_delay) >= 0 ? '+' : '').ceil($warning_delay).' '.$langs->trans("days"); print " ".img_warning($textlate); @@ -1627,7 +1627,7 @@ else if ($objp->date_fin) { print dol_print_date($db->jdate($objp->date_fin)); - if ($objp->statut == 4 && $db->jdate($objp->date_fin) < ($now - $conf->contrat->services->expires->warning_delay)) { + if ($objp->statut == 4 && $db->jdate($objp->date_fin) < ($now - $conf->contrat->services->expires->warning_delay)) { $warning_delay=$conf->contrat->services->expires->warning_delay / 3600 / 24; $textlate = $langs->trans("Late").' = '.$langs->trans("DateReference").' > '.$langs->trans("DateToday").' '.(ceil($warning_delay) >= 0 ? '+' : '').ceil($warning_delay).' '.$langs->trans("days"); print " ".img_warning($textlate); @@ -1814,13 +1814,13 @@ else $tmpaction='activateline'; $tmpactionpicto='play'; $tmpactiontext=$langs->trans("Activate"); - if ($objp->statut == 4) + if ($objp->statut == 4) { $tmpaction='unactivateline'; $tmpactionpicto='playstop'; $tmpactiontext=$langs->trans("Unactivate"); } - if (($tmpaction=='activateline' && $user->rights->contrat->activer) || ($tmpaction=='unactivateline' && $user->rights->contrat->desactiver)) + if (($tmpaction=='activateline' && $user->rights->contrat->activer) || ($tmpaction=='unactivateline' && $user->rights->contrat->desactiver)) { print ''; print img_picto($tmpactiontext, $tmpactionpicto); @@ -1962,7 +1962,7 @@ else print ''; print ''; print ''; - + print ''; print ''; @@ -1997,7 +1997,7 @@ else $var = true; $forcetoshowtitlelines=1; - + // Add free products/services $object->formAddObjectLine(1, $mysoc, $soc); @@ -2037,7 +2037,7 @@ else if ($user->rights->contrat->creer) print ''; else print ''; } - + if (! empty($conf->facture->enabled) && $object->statut > 0 && $object->nbofservicesclosed < $nbofservices) { $langs->load("bills"); @@ -2051,7 +2051,7 @@ else if ($user->rights->commande->creer) print ''; else print ''; } - + // Clone if ($user->rights->contrat->creer) { print ''; @@ -2083,16 +2083,16 @@ else print "
"; } - + // Select mail models is same action as presend if (GETPOST('modelselected')) { $action = 'presend'; } - + if ($action != 'presend') { print '
'; - + /* * Documents generes */ @@ -2101,25 +2101,25 @@ else $urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id; $genallowed = $user->rights->contrat->creer; $delallowed = $user->rights->contrat->supprimer; - + $var = true; - + print $formfile->showdocuments('contract', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', 0, '', $soc->default_lang); - - + + // Show links to link elements $linktoelem = $form->showLinkToObjectBlock($object, null, array('contrat')); $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); - - + + print '
'; - + // List of actions on element include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; $formactions = new FormActions($db); $somethingshown = $formactions->showactions($object, 'contract', $socid); - + print '
'; } diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 01ffb706586..b65ab35527e 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -89,13 +89,13 @@ abstract class CommonObject * @var Object To store a cloned copy of object before to edit it and keep track of old properties */ public $oldcopy; - + /** * @var string Column name of the ref field. */ protected $table_ref_field = ''; - + // Following vars are used by some objects only. We keep this property here in CommonObject to be able to provide common method using them. @@ -330,10 +330,10 @@ abstract class CommonObject public $firstname; public $civility_id; - + // No constructor as it is an abstract class - + /** * Check an object id/ref exists * If you don't need/want to instantiate object and just need to know if object exists, use this method instead of fetch @@ -398,7 +398,7 @@ abstract class CommonObject $lastname=$this->lastname; $firstname=$this->firstname; if (empty($lastname)) $lastname=(isset($this->lastname)?$this->lastname:(isset($this->name)?$this->name:(isset($this->nom)?$this->nom:(isset($this->societe)?$this->societe:(isset($this->company)?$this->company:''))))); - + $ret=''; if ($option && $this->civility_id) { @@ -597,11 +597,11 @@ abstract class CommonObject dol_syslog("CODE_NOT_VALID_FOR_THIS_ELEMENT"); return -3; } - + $datecreate = dol_now(); $this->db->begin(); - + // Insertion dans la base $sql = "INSERT INTO ".MAIN_DB_PREFIX."element_contact"; $sql.= " (element_id, fk_socpeople, datecreate, statut, fk_c_type_contact) "; @@ -1238,19 +1238,19 @@ abstract class CommonObject function setValueFrom($field, $value, $table='', $id=null, $format='', $id_field='', $fuser=null, $trigkey='') { global $user,$langs,$conf; - + if (empty($table)) $table=$this->table_element; if (empty($id)) $id=$this->id; if (empty($format)) $format='text'; if (empty($id_field)) $id_field='rowid'; $error=0; - + $this->db->begin(); // Special case if ($table == 'product' && $field == 'note_private') $field='note'; - + $sql = "UPDATE ".MAIN_DB_PREFIX.$table." SET "; if ($format == 'text') $sql.= $field." = '".$this->db->escape($value)."'"; else if ($format == 'int') $sql.= $field." = ".$this->db->escape($value); @@ -1396,13 +1396,13 @@ abstract class CommonObject } $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - if ($this->table_element == 'actioncomm') + if ($this->table_element == 'actioncomm') { if ($projectid) $sql.= ' SET fk_project = '.$projectid; else $sql.= ' SET fk_project = NULL'; - $sql.= ' WHERE id = '.$this->id; + $sql.= ' WHERE id = '.$this->id; } - else + else { if ($projectid) $sql.= ' SET fk_projet = '.$projectid; else $sql.= ' SET fk_projet = NULL'; @@ -1535,7 +1535,7 @@ abstract class CommonObject if($mode == 1) { $line->subprice = 0; } - + switch ($this->element) { case 'propal': $this->updateline($line->id, $line->subprice, $line->qty, $line->remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, $line->desc, 'HT', $line->info_bits, $line->special_code, $line->fk_parent_line, $line->skip_update_total, $line->fk_fournprice, $line->pa_ht, $line->label, $line->product_type, $line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $line->multicurrency_subprice); @@ -1626,7 +1626,7 @@ abstract class CommonObject /** * Define delivery address * @deprecated - * + * * @param int $id Address id * @return int <0 si ko, >0 si ok */ @@ -1950,7 +1950,7 @@ abstract class CommonObject { $fieldposition = 'rang'; if ($this->table_element_line == 'ecm_files') $fieldposition = 'position'; - + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.$rang; $sql.= ' WHERE rowid = '.$rowid; @@ -2163,7 +2163,7 @@ abstract class CommonObject function update_note($note,$suffix='') { global $user; - + if (! $this->table_element) { dol_syslog(get_class($this)."::update_note was called on objet with property table_element not defined", LOG_ERR); @@ -2177,7 +2177,7 @@ abstract class CommonObject // Special cas //var_dump($this->table_element);exit; if ($this->table_element == 'product') $suffix=''; - + $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $sql.= " SET note".$suffix." = ".(!empty($note)?("'".$this->db->escape($note)."'"):"NULL"); $sql.= " ,".(in_array($this->table_element, array('actioncomm', 'adherent', 'advtargetemailing', 'cronjob', 'establishment'))?"fk_user_mod":"fk_user_modif")." = ".$user->id; @@ -2188,7 +2188,7 @@ abstract class CommonObject { if ($suffix == '_public') $this->note_public = $note; else if ($suffix == '_private') $this->note_private = $note; - else + else { $this->note = $note; // deprecated $this->note_private = $note; @@ -2437,7 +2437,7 @@ abstract class CommonObject // Special case if ($origin == 'order') $origin='commande'; if ($origin == 'invoice') $origin='facture'; - + $this->db->begin(); $sql = "INSERT INTO ".MAIN_DB_PREFIX."element_element ("; @@ -2470,10 +2470,10 @@ abstract class CommonObject * Fetch array of objects linked to current object. Links are loaded into this->linkedObjects array and this->linkedObjectsIds * Possible usage for parameters: * - all parameters empty -> we look all link to current object (current object can be source or target) - * - source id+type -> will get target list linked to source - * - target id+type -> will get source list linked to target - * - source id+type + target type -> will get target list of the type - * - target id+type + target source -> will get source list of the type + * - source id+type -> will get target list linked to source + * - target id+type -> will get source list linked to target + * - source id+type + target type -> will get target list of the type + * - target id+type + target source -> will get source list of the type * * @param int $sourceid Object source id (if not defined, id of object) * @param string $sourcetype Object source type (if not defined, element name of object) @@ -2791,7 +2791,7 @@ abstract class CommonObject global $user,$langs,$conf; $savElementId=$elementId; // To be used later to know if we were using the method using the id of this or not. - + $elementId = (!empty($elementId)?$elementId:$this->id); $elementTable = (!empty($elementType)?$elementType:$this->table_element); @@ -2821,7 +2821,7 @@ abstract class CommonObject if ($this->element == 'fichinter' && $status == 3) $trigkey='FICHINTER_CLASSIFY_DONE'; if ($this->element == 'fichinter' && $status == 2) $trigkey='FICHINTER_CLASSIFY_BILLED'; if ($this->element == 'fichinter' && $status == 1) $trigkey='FICHINTER_CLASSIFY_UNBILLED'; - + if ($trigkey) { // Appel des triggers @@ -2837,7 +2837,7 @@ abstract class CommonObject if (! $error) { $this->db->commit(); - + if (empty($savElementId)) // If the element we update was $this (so $elementId is null) { $this->statut = $status; @@ -2932,7 +2932,7 @@ abstract class CommonObject function isObjectUsed($id=0) { if (empty($id)) $id=$this->id; - + // Check parameters if (! isset($this->childtables) || ! is_array($this->childtables) || count($this->childtables) == 0) { @@ -3049,12 +3049,12 @@ abstract class CommonObject foreach ($this->lines as $line) { - if (isset($line->qty_asked)) + if (isset($line->qty_asked)) { if (empty($totalOrdered)) $totalOrdered=0; // Avoid warning because $totalOrdered is '' $totalOrdered+=$line->qty_asked; // defined for shipment only } - if (isset($line->qty_shipped)) + if (isset($line->qty_shipped)) { if (empty($totalToShip)) $totalToShip=0; // Avoid warning because $totalToShip is '' $totalToShip+=$line->qty_shipped; // defined for shipment only @@ -3082,7 +3082,7 @@ abstract class CommonObject if (empty($totalWeight)) $totalWeight=0; // Avoid warning because $totalWeight is '' if (empty($totalVolume)) $totalVolume=0; // Avoid warning because $totalVolume is '' - + //var_dump($line->volume_units); if ($weight_units < 50) // >50 means a standard unit (power of 10 of official unit), > 50 means an exotic unit (like inch) { @@ -3318,54 +3318,54 @@ abstract class CommonObject if (! empty($conf->margin->enabled) && ! empty($this->element) && in_array($this->element,array('facture','propal','commande'))) $usemargins=1; $num = count($this->lines); - + //Line extrafield require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; $extrafieldsline = new ExtraFields($this->db); $extralabelslines=$extrafieldsline->fetch_name_optionals_label($this->table_element_line); - + $parameters = array('num'=>$num,'i'=>$i,'dateSelector'=>$dateSelector,'seller'=>$seller,'buyer'=>$buyer,'selected'=>$selected, 'extrafieldsline'=>$extrafieldsline); $reshook = $hookmanager->executeHooks('printObjectLineTitle', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if (empty($reshook)) { print ''; - + if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) print ' '; - + // Description print ''.$langs->trans('Description').''; - + if ($this->element == 'supplier_proposal') { print ''.$langs->trans("SupplierProposalRefFourn").''; } - + // VAT print ''.$langs->trans('VAT').''; - + // Price HT print ''.$langs->trans('PriceUHT').''; - + // Multicurrency if (!empty($conf->multicurrency->enabled)) print ''.$langs->trans('PriceUHTCurrency', $this->multicurrency_code).''; - + if ($inputalsopricewithtax) print ''.$langs->trans('PriceUTTC').''; - + // Qty print ''.$langs->trans('Qty').''; - + if($conf->global->PRODUCT_USE_UNITS) { print ''.$langs->trans('Unit').''; } - + // Reduction short print ''.$langs->trans('ReductionShort').''; - + if ($this->situation_cycle_ref) { print '' . $langs->trans('Progress') . ''; } - + if ($usemargins && ! empty($conf->margin->enabled) && empty($user->societe_id)) { if (!empty($user->rights->margins->creer)) @@ -3373,32 +3373,32 @@ abstract class CommonObject if ($conf->global->MARGIN_TYPE == "1") print ''.$langs->trans('BuyingPrice').''; else - print ''.$langs->trans('CostPrice').''; + print ''.$langs->trans('CostPrice').''; } - + if (! empty($conf->global->DISPLAY_MARGIN_RATES) && $user->rights->margins->liretous) print ''.$langs->trans('MarginRate').''; if (! empty($conf->global->DISPLAY_MARK_RATES) && $user->rights->margins->liretous) print ''.$langs->trans('MarkRate').''; } - + // Total HT print ''.$langs->trans('TotalHTShort').''; - + // Multicurrency if (!empty($conf->multicurrency->enabled)) print ''.$langs->trans('TotalHTShortCurrency', $this->multicurrency_code).''; - + if ($outputalsopricetotalwithtax) print ''.$langs->trans('TotalTTCShort').''; - + print ''; // No width to allow autodim - + print ''; - + print ''; - + print "\n"; } - + $var = true; $i = 0; @@ -3407,7 +3407,7 @@ abstract class CommonObject //Line extrafield $line->fetch_optionals($line->id,$extralabelslines); - + //if (is_object($hookmanager) && (($line->product_type == 9 && ! empty($line->special_code)) || ! empty($line->fk_parent_line))) if (is_object($hookmanager)) // Old code is commented on preceding line. @@ -3588,7 +3588,7 @@ abstract class CommonObject foreach ($this->lines as $line) { - + if (is_object($hookmanager) && (($line->product_type == 9 && ! empty($line->special_code)) || ! empty($line->fk_parent_line))) { @@ -3868,7 +3868,7 @@ abstract class CommonObject $modele=$tmp[0]; $srctemplatepath=$tmp[1]; } - + // Search template files $file=''; $classname=''; $filefound=0; @@ -3897,7 +3897,7 @@ abstract class CommonObject if ($filefound) { global $db; // Required to solve a conception default in commonstickergenerator.class.php making an include of code using $db - + require_once $file; $obj = new $classname($this->db); @@ -3956,7 +3956,7 @@ abstract class CommonObject // output format that does not support UTF8. $sav_charset_output=$outputlangs->charset_output; - if (in_array(get_class($this), array('Adherent'))) + if (in_array(get_class($this), array('Adherent'))) { $arrayofrecords = array(); // The write_file of templates of adherent class need this $resultwritefile = $obj->write_file($this, $outputlangs, $srctemplatepath, 'member', 1, $moreparams); @@ -4104,25 +4104,36 @@ abstract class CommonObject * Function to get extra fields of a member into $this->array_options * This method is in most cases called by method fetch of objects but you can call it separately. * - * @param int $rowid Id of line - * @param array $optionsArray Array resulting of call of extrafields->fetch_name_optionals_label() + * @param int $rowid Id of line. Use the id of object if not defined. Deprecated. Function must be called without parameters. + * @param array $optionsArray Array resulting of call of extrafields->fetch_name_optionals_label(). Deprecated. Function must be called without parameters. * @return int <0 if error, 0 if no optionals to find nor found, 1 if a line is found and optional loaded */ function fetch_optionals($rowid=null,$optionsArray=null) { if (empty($rowid)) $rowid=$this->id; - //To avoid SQL errors. Probably not the better solution though + // To avoid SQL errors. Probably not the better solution though if (!$this->table_element) { return 0; } if (! is_array($optionsArray)) { - // optionsArray not already loaded, so we load it - require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; - $extrafields = new ExtraFields($this->db); - $optionsArray = $extrafields->fetch_name_optionals_label($this->table_element); + // $extrafields is not a known object, we initialize it. Best practice is to have $extrafields defined into card.php or list.php page. + // TODO Use of existing extrafield is not yet ready (must mutualize code that use extrafields in form first) + // global $extrafields; + //if (! is_object($extrafields)) + //{ + require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; + $extrafields = new ExtraFields($this->db); + //} + + // Load array of extrafields for elementype = $this->table_element + if (empty($extrafields->attributes[$this->table_element]['loaded'])) + { + $extrafields->fetch_name_optionals_label($this->table_element); + } + $optionsArray = $extrafields->attributes[$this->table_element]['label']; } // Request to get complementary values @@ -4131,12 +4142,15 @@ abstract class CommonObject $sql = "SELECT rowid"; foreach ($optionsArray as $name => $label) { - $sql.= ", ".$name; + if (empty($extrafields->attributes[$this->table_element]['type'][$name]) || $extrafields->attributes[$this->table_element]['type'][$name] != 'separate') + { + $sql.= ", ".$name; + } } $sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element."_extrafields"; $sql.= " WHERE fk_object = ".$rowid; - dol_syslog(get_class($this)."::fetch_optionals", LOG_DEBUG); + dol_syslog(get_class($this)."::fetch_optionals get extrafields data for ".$this->table_element, LOG_DEBUG); $resql=$this->db->query($sql); if ($resql) { @@ -4217,7 +4231,7 @@ abstract class CommonObject require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; $extrafields = new ExtraFields($this->db); $target_extrafields=$extrafields->fetch_name_optionals_label($this->table_element); - + //Eliminate copied source object extra_fields that do not exist in target object $new_array_options=array(); foreach ($this->array_options as $key => $value) { @@ -4266,7 +4280,7 @@ abstract class CommonObject { if (is_numeric($value)) $res=$object->fetch($value); else $res=$object->fetch('',$value); - + if ($res > 0) $this->array_options[$key]=$object->id; else { @@ -4678,7 +4692,7 @@ abstract class CommonObject } return $buyPrice; } - + /** * Function test if type is date * @@ -4690,7 +4704,7 @@ abstract class CommonObject if(isset($info['type']) && $info['type']=='date') return true; else return false; } - + /** * Function test if type is array * @@ -4706,7 +4720,7 @@ abstract class CommonObject } else return false; } - + /** * Function test if type is null * @@ -4722,7 +4736,7 @@ abstract class CommonObject } else return false; } - + /** * Function test if type is integer * @@ -4738,7 +4752,7 @@ abstract class CommonObject } else return false; } - + /** * Function test if type is float * @@ -4754,7 +4768,7 @@ abstract class CommonObject } else return false; } - + /** * Function test if type is text * @@ -4770,7 +4784,7 @@ abstract class CommonObject } else return false; } - + /** * Function test if is indexed * @@ -4786,7 +4800,7 @@ abstract class CommonObject } else return false; } - + /** * Function to prepare the values to insert * @@ -4829,7 +4843,7 @@ abstract class CommonObject $query[$field] = $this->{$field}; } } - + return $query; } @@ -4843,30 +4857,30 @@ abstract class CommonObject */ public function createCommon(User $user, $notrigger = false) { - + $fields = array_merge(array('datec'=>$this->db->idate(dol_now())), $this->set_save_query()); - + foreach ($fields as $k => $v) { - + $keys[] = $k; $values[] = $this->quote($v); - + } $sql = 'INSERT INTO '.MAIN_DB_PREFIX.$this->table_element.' ( '.implode( ",", $keys ).' ) VALUES ( '.implode( ",", $values ).' ) '; $res = $this->db->query( $sql ); if($res===false) { - + return false; } - + // TODO Add triggers - + return true; - + } - + /** * Function to load data into current object this * @@ -4905,10 +4919,10 @@ abstract class CommonObject { $this->{$field} = $obj->{$field}; } - + } } - + /** * Function to concat keys of fields * @@ -4919,7 +4933,7 @@ abstract class CommonObject $keys = array_keys($this->fields); return implode(',', $keys); } - + /** * Load object in memory from the database * @@ -4930,12 +4944,12 @@ abstract class CommonObject */ public function fetchCommon($id, $ref = null) { - + if (empty($id) && empty($ref)) return false; - + $sql = 'SELECT '.$this->get_field_list().', datec, tms'; $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element; - + if(!empty($id)) $sql.= ' WHERE rowid = '.$id; else $sql.= ' WHERE ref = \''.$this->quote($ref).'\''; @@ -4946,10 +4960,10 @@ abstract class CommonObject { $this->id = $id; $this->set_vars_by_db($obj); - + $this->datec = $this->db->idate($obj->datec); $this->tms = $this->db->idate($obj->tms); - + return $this->id; } else @@ -4978,9 +4992,9 @@ abstract class CommonObject public function updateCommon(User $user, $notrigger = false) { $fields = $this->set_save_query(); - + foreach ($fields as $k => $v) { - + if (is_array($key)){ $i=array_search($k, $key); if ( $i !== false) { @@ -4993,22 +5007,22 @@ abstract class CommonObject continue; } } - + $tmp[] = $k.'='.$this->quote($v); } $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element.' SET '.implode( ',', $tmp ).' WHERE rowid='.$this->id ; $res = $this->db->query( $sql ); - + if($res===false) { //error return false; } - + // TODO Add triggers - + return true; } - + /** * Delete object in database * @@ -5020,14 +5034,14 @@ abstract class CommonObject public function deleteCommon(User $user, $notrigger = false) { $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.' WHERE rowid='.$this->id; - + $res = $this->db->query( $sql ); if($res===false) { return false; } - + // TODO Add triggers - + return true; } @@ -5038,12 +5052,12 @@ abstract class CommonObject * @return string|int */ protected function quote($value) { - + if(is_null($value)) return 'NULL'; else if(is_numeric($value)) return $value; else return "'".$this->db->escape( $value )."'"; - + } - + } diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index edac78e9b30..8a96e18bf7d 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -132,14 +132,7 @@ class Conf $sql = "SELECT ".$db->decrypt('name')." as name,"; $sql.= " ".$db->decrypt('value')." as value, entity"; $sql.= " FROM ".MAIN_DB_PREFIX."const"; - if (! empty($this->multicompany->transverse_mode)) - { - $sql.= " WHERE entity IN (0,1,".$this->entity.")"; - } - else - { - $sql.= " WHERE entity IN (0,".$this->entity.")"; - } + $sql.= " WHERE entity IN (0,".$this->entity.")"; $sql.= " ORDER BY entity"; // This is to have entity 0 first, then entity 1 that overwrite. $resql = $db->query($sql); diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index bd1daca8886..754a8300366 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -39,7 +39,7 @@ class ExtraFields // type of element (for what object is the extrafield) var $attribute_elementtype; - + // Array with type of the extra field var $attribute_type; // Array with label of extra field @@ -68,7 +68,10 @@ class ExtraFields var $attribute_list; // Array to store if extra field is hidden var $attribute_hidden; // warning, do not rely on this. If your module need a hidden data, it must use its own table. - + + // New array to store extrafields definition + var $attributes; + var $error; var $errno; @@ -95,7 +98,7 @@ class ExtraFields 'separate' => 'ExtrafieldSeparator', ); - + /** * Constructor * @@ -149,7 +152,7 @@ class ExtraFields // Create field into database except for separator type which is not stored in database if ($type != 'separate') { - $result=$this->create($attrname, $type, $size, $elementtype, $unique, $required, $default_value, $param, $perms, $list, $copmputed); + $result=$this->create($attrname, $type, $size, $elementtype, $unique, $required, $default_value, $param, $perms, $list, $computed); } $err1=$this->errno; if ($result > 0 || $err1 == 'DB_ERROR_COLUMN_ALREADY_EXISTS' || $type == 'separate') @@ -349,7 +352,7 @@ class ExtraFields $table=$elementtype.'_extrafields'; $error=0; - + if (! empty($attrname) && preg_match("/^\w[a-zA-Z0-9-_]*$/",$attrname)) { $result=$this->delete_label($attrname,$elementtype); @@ -381,7 +384,7 @@ class ExtraFields } } } - + return $result; } else @@ -640,26 +643,29 @@ class ExtraFields /** - * Load array this->attribute_xxx like attribute_label, attribute_type, ... + * Load array this->attributes, or old this->attribute_xxx like attribute_label, attribute_type, ... * - * @param string $elementtype Type of element ('adherent', 'commande', 'thirdparty', 'facture', 'propal', 'product', ...) - * @param boolean $forceload Force load of extra fields whatever is option MAIN_EXTRAFIELDS_DISABLED - * @return array Array of attributes for all extra fields + * @param string $elementtype Type of element ('adherent', 'commande', 'thirdparty', 'facture', 'propal', 'product', ...). + * @param boolean $forceload Force load of extra fields whatever is option MAIN_EXTRAFIELDS_DISABLED. Deprecated. Should not be required. + * @return array Array of attributes keys+label for all extra fields. */ function fetch_name_optionals_label($elementtype,$forceload=false) { global $conf; - if ( empty($elementtype) ) return array(); + if (empty($elementtype) ) return array(); if ($elementtype == 'thirdparty') $elementtype='societe'; if ($elementtype == 'contact') $elementtype='socpeople'; $array_name_label=array(); - // For avoid conflicts with external modules + // To avoid conflicts with external modules. TODO Remove this. if (!$forceload && !empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) return $array_name_label; + // We should not have several time this log. If we have, there is some optimization to do by calling a simple $object->fetch_optionals() that include cache management. + dol_syslog("fetch_name_optionals_label elementtype=".$elementtype); + $sql = "SELECT rowid,name,label,type,size,elementtype,fieldunique,fieldrequired,param,pos,alwayseditable,perms,list,ishidden,fielddefault,fieldcomputed"; $sql.= " FROM ".MAIN_DB_PREFIX."extrafields"; $sql.= " WHERE entity IN (0,".$conf->entity.")"; @@ -673,12 +679,13 @@ class ExtraFields { while ($tab = $this->db->fetch_object($resql)) { - // we can add this attribute to adherent object + // We can add this attribute to object. TODO Remove this and return $this->attributes[$elementtype]['label'] if ($tab->type != 'separate') { $array_name_label[$tab->name]=$tab->label; } + // Old usage $this->attribute_type[$tab->name]=$tab->type; $this->attribute_label[$tab->name]=$tab->label; $this->attribute_size[$tab->name]=$tab->size; @@ -693,8 +700,25 @@ class ExtraFields $this->attribute_perms[$tab->name]=$tab->perms; $this->attribute_list[$tab->name]=$tab->list; $this->attribute_hidden[$tab->name]=$tab->ishidden; + + // New usage + $this->attributes[$tab->elementtype]['type'][$tab->name]=$tab->type; + $this->attributes[$tab->elementtype]['label'][$tab->name]=$tab->label; + $this->attributes[$tab->elementtype]['size'][$tab->name]=$tab->size; + $this->attributes[$tab->elementtype]['elementtype'][$tab->name]=$tab->elementtype; + $this->attributes[$tab->elementtype]['default'][$tab->name]=$tab->fielddefault; + $this->attributes[$tab->elementtype]['computed'][$tab->name]=$tab->fieldcomputed; + $this->attributes[$tab->elementtype]['unique'][$tab->name]=$tab->fieldunique; + $this->attributes[$tab->elementtype]['required'][$tab->name]=$tab->fieldrequired; + $this->attributes[$tab->elementtype]['param'][$tab->name]=($tab->param ? unserialize($tab->param) : ''); + $this->attributes[$tab->elementtype]['pos'][$tab->name]=$tab->pos; + $this->attributes[$tab->elementtype]['alwayseditable'][$tab->name]=$tab->alwayseditable; + $this->attributes[$tab->elementtype]['perms'][$tab->name]=$tab->perms; + $this->attributes[$tab->elementtype]['list'][$tab->name]=$tab->list; + $this->attributes[$tab->elementtype]['ishidden'][$tab->name]=$tab->ishidden; } } + if ($elementtype) $this->attributes[$elementtype]['loaded']=1; } else { @@ -736,7 +760,7 @@ class ExtraFields $hidden=$this->attribute_hidden[$key]; if ($computed) return ''.$langs->trans("AutomaticallyCalculated").''; - + if (empty($showsize)) { if ($type == 'date') @@ -772,14 +796,14 @@ class ExtraFields { $showsize = 'minwidth200imp'; } - else + else { //$showsize=48; $showsize = 'minwidth400imp'; } } } - + if (in_array($type,array('date','datetime'))) { $tmp=explode(',',$size); @@ -1029,7 +1053,7 @@ class ExtraFields { require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; $form = new Form($db); - + $value_arr=explode(',',$value); $out=$form->multiselectarray($keysuffix.'options_'.$key.$keyprefix, $param['options'], $value_arr, '', 0, '', 0, '100%'); @@ -1124,9 +1148,9 @@ class ExtraFields if ($resql) { $num = $this->db->num_rows($resql); $i = 0; - + $data=array(); - + while ( $i < $num ) { $labeltoshow = ''; $obj = $this->db->fetch_object($resql); @@ -1152,9 +1176,9 @@ class ExtraFields $labeltoshow = dol_trunc($obj->$field_toshow, 18) . ' '; } } - + $data[$obj->rowid]=$labeltoshow; - + } else { if (! $notrans) { $translabel = $langs->trans($obj->{$InfoFieldList[1]}); @@ -1177,16 +1201,16 @@ class ExtraFields $data[$obj->rowid]=$labeltoshow; } - + $i ++; } $this->db->free($resql); - + require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; $form = new Form($db); - + $out=$form->multiselectarray($keysuffix.'options_'.$key.$keyprefix, $data, $value_arr, '', 0, '', 0, '100%'); - + } else { print 'Error in request ' . $sql . ' ' . $this->db->lasterror() . '. Check setup of extra parameters.
'; } @@ -1205,11 +1229,11 @@ class ExtraFields if ($InfoFieldList[0] && class_exists($InfoFieldList[0])) { $valuetoshow=$value; - if (!empty($value)) + if (!empty($value)) { $object = new $InfoFieldList[0]($this->db); $resfetch=$object->fetch($value); - if ($resfetch > 0) + if ($resfetch > 0) { $valuetoshow=$object->ref; if ($object->element == 'societe') $valuetoshow=$object->name; // Special case for thirdparty because ->ref is not name but id (because name is not unique) @@ -1269,7 +1293,7 @@ class ExtraFields //var_dump($computed); $value = dol_eval($computed, 1, 0); } - + $showsize=0; if ($type == 'date') { @@ -1477,7 +1501,7 @@ class ExtraFields } } $value='
    '.implode(' ', $toprint).'
'; - + } else { dol_syslog(get_class($this) . '::showOutputField error ' . $this->db->lasterror(), LOG_WARNING); } diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index afb670dc267..8faea875ab5 100644 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -59,15 +59,14 @@ class HookManager /** * Init array $this->hooks with instantiated action controlers. - * First, a hook is declared by a module by adding a constant MAIN_MODULE_MYMODULENAME_HOOKS - * with value 'nameofcontext1:nameofcontext2:...' into $this->const of module descriptor file. + * First, a hook is declared by a module by adding a constant MAIN_MODULE_MYMODULENAME_HOOKS with value 'nameofcontext1:nameofcontext2:...' into $this->const of module descriptor file. * This makes $conf->hooks_modules loaded with an entry ('modulename'=>array(nameofcontext1,nameofcontext2,...)) * When initHooks function is called, with initHooks(list_of_contexts), an array $this->hooks is defined with instance of controler * class found into file /mymodule/class/actions_mymodule.class.php (if module has declared the context as a managed context). * Then when a hook executeHooks('aMethod'...) is called, the method aMethod found into class will be executed. * * @param string[] $arraycontext Array list of searched hooks tab/features. For example: 'thirdpartycard' (for hook methods into page card thirdparty), 'thirdpartydao' (for hook methods into Societe), ... - * @return int Always 1 + * @return int Always 1 */ function initHooks($arraycontext) { diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 1646e660c9f..cbda43de19a 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -984,6 +984,7 @@ class Form if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->COMPANY_USE_SEARCH_TO_SELECT) && ! $forcecombo) { + // No immediate load of all database $placeholder=''; if ($selected && empty($selected_input_value)) { @@ -1016,6 +1017,7 @@ class Form } else { + // Immediate load of all database $out.=$this->select_thirdparty_list($selected, $htmlname, $filter, $showempty, $showtype, $forcecombo, $events, '', 0, $limit, $morecss, $moreparam); } @@ -1023,7 +1025,8 @@ class Form } /** - * Output html form to select a third party + * Output html form to select a third party. + * Note, you must use the select_company to get the component to select a third party. This function must only be called by select_company. * * @param string $selected Preselected type * @param string $htmlname Name of field in form @@ -1085,8 +1088,6 @@ class Form $resql=$this->db->query($sql); if ($resql) { - $events = null; - if ($conf->use_javascript_ajax && ! $forcecombo) { include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; @@ -1474,7 +1475,7 @@ class Form } else { - if (! empty($conf->multicompany->transverse_mode)) + if (! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ug"; $sql.= " ON ug.fk_user = u.rowid"; @@ -1571,7 +1572,7 @@ class Form $moreinfo++; } } - if (! empty($conf->multicompany->enabled) && empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity) + if (! empty($conf->multicompany->enabled) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && ! $user->entity) { if ($obj->admin && ! $obj->entity) { @@ -6202,7 +6203,7 @@ class Form $out.= '>'; $out.= $obj->name; - if (! empty($conf->multicompany->enabled) && empty($conf->multicompany->transverse_mode) && $conf->entity == 1) + if (! empty($conf->multicompany->enabled) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1) { $out.= " (".$obj->label.")"; } diff --git a/htdocs/core/class/infobox.class.php b/htdocs/core/class/infobox.class.php index 419f31dca4d..e77a1196530 100644 --- a/htdocs/core/class/infobox.class.php +++ b/htdocs/core/class/infobox.class.php @@ -60,7 +60,7 @@ class InfoBox $sql.= " d.rowid as box_id, d.file, d.note, d.tms"; $sql.= " FROM ".MAIN_DB_PREFIX."boxes as b, ".MAIN_DB_PREFIX."boxes_def as d"; $sql.= " WHERE b.box_id = d.rowid"; - $sql.= " AND b.entity IN (0,".(! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)?"1,":"").$conf->entity.")"; + $sql.= " AND b.entity IN (0,".$conf->entity.")"; if ($zone >= 0) $sql.= " AND b.position = ".$zone; if (is_object($user)) $sql.= " AND b.fk_user IN (0,".$user->id.")"; else $sql.= " AND b.fk_user = 0"; @@ -70,9 +70,9 @@ class InfoBox { $sql = "SELECT d.rowid as box_id, d.file, d.note, d.tms"; $sql.= " FROM ".MAIN_DB_PREFIX."boxes_def as d"; - $sql.= " WHERE d.entity IN (0,".(! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)?"1,":"").$conf->entity.")"; + $sql.= " WHERE d.entity IN (0,".$conf->entity.")"; } - + dol_syslog(get_class()."::listBoxes get default box list for mode=".$mode." userid=".(is_object($user)?$user->id:'')."", LOG_DEBUG); $resql = $db->query($sql); if ($resql) diff --git a/htdocs/core/class/menubase.class.php b/htdocs/core/class/menubase.class.php index ed6b9929a32..a6770b57c37 100644 --- a/htdocs/core/class/menubase.class.php +++ b/htdocs/core/class/menubase.class.php @@ -508,7 +508,7 @@ class Menubase $sql = "SELECT m.rowid, m.type, m.module, m.fk_menu, m.fk_mainmenu, m.fk_leftmenu, m.url, m.titre, m.langs, m.perms, m.enabled, m.target, m.mainmenu, m.leftmenu, m.position"; $sql.= " FROM ".MAIN_DB_PREFIX."menu as m"; - $sql.= " WHERE m.entity IN (0,".(! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)?"1,":"").$conf->entity.")"; + $sql.= " WHERE m.entity IN (0,".$conf->entity.")"; $sql.= " AND m.menu_handler IN ('".$menu_handler."','all')"; if ($type_user == 0) $sql.= " AND m.usertype IN (0,2)"; if ($type_user == 1) $sql.= " AND m.usertype IN (1,2)"; diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index c3d8714ab89..b68d7706e43 100755 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -98,7 +98,7 @@ function dolGetModulesDirs($subdir='') while (($file = readdir($handle))!==false) { if (preg_match('/disabled/',$file)) continue; // We discard module if it contains disabled into name. - + if (is_dir($dirroot.'/'.$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS' && $file != 'includes') { if (is_dir($dirroot . '/' . $file . '/core/modules'.$subdir.'/')) @@ -207,7 +207,7 @@ function dol_print_object_info($object, $usetable=0) //print "x".$deltadateforserver." - ".$deltadateforclient." - ".$deltadateforuser; if ($usetable) print ''; - + // Import key if (! empty($object->import_key)) { @@ -378,7 +378,7 @@ function dol_print_object_info($object, $usetable=0) if ($usetable) print ''; else print '
'; } - + // Date approve if (! empty($object->date_approve2)) { @@ -391,7 +391,7 @@ function dol_print_object_info($object, $usetable=0) if ($usetable) print ''; else print '
'; } - + // User close if (! empty($object->user_cloture)) { @@ -476,7 +476,7 @@ function dol_print_object_info($object, $usetable=0) if ($usetable) print ''; else print '
'; } - + if ($usetable) print '
'; } @@ -799,7 +799,7 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m if(!empty($user->array_options['options_'.$extra])){ $mask = preg_replace('#('.$start.')(.*?)('.$end.')#si', $user->array_options['options_'.$extra], $mask); } - } + } $maskwithonlyymcode=$mask; $maskwithonlyymcode=preg_replace('/\{(0+)([@\+][0-9\-\+\=]+)?([@\+][0-9\-\+\=]+)?\}/i',$maskcounter,$maskwithonlyymcode); $maskwithonlyymcode=preg_replace('/\{dd\}/i','dd',$maskwithonlyymcode); @@ -928,11 +928,11 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m //print "masktri=".$masktri." maskcounter=".$maskcounter." maskraz=".$maskraz." maskoffset=".$maskoffset."
\n"; // Define $sqlstring - if (function_exists('mb_strrpos')) + if (function_exists('mb_strrpos')) { $posnumstart=mb_strrpos($maskwithnocode,$maskcounter, 'UTF-8'); - } - else + } + else { $posnumstart=strrpos($maskwithnocode,$maskcounter); } // Pos of counter in final string (from 0 to ...) @@ -1123,7 +1123,7 @@ function get_string_between($string, $start, $end){ $string = " ".$string; $ini = strpos($string,$start); if ($ini == 0) return ""; - $ini += strlen($start); + $ini += strlen($start); $len = strpos($string,$end,$ini) - $ini; return substr($string,$ini,$len); } @@ -1539,9 +1539,9 @@ function getListOfModels($db,$type,$maxfilenamelength=0) $sql = "SELECT nom as id, nom as lib, libelle as label, description as description"; $sql.= " FROM ".MAIN_DB_PREFIX."document_model"; $sql.= " WHERE type = '".$type."'"; - $sql.= " AND entity IN (0,".(! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)?"1,":"").$conf->entity.")"; + $sql.= " AND entity IN (0,".$conf->entity.")"; $sql.= " ORDER BY description DESC"; - + dol_syslog('/core/lib/function2.lib.php::getListOfModels', LOG_DEBUG); $resql = $db->query($sql); if ($resql) @@ -1625,7 +1625,7 @@ function getListOfModels($db,$type,$maxfilenamelength=0) /** * This function evaluates a string that should be a valid IPv4 * Note: For ip 169.254.0.0, it returns 0 with some PHP (5.6.24) and 2 with some minor patchs of PHP (5.6.25). See https://github.com/php/php-src/pull/1954. - * + * * @param string $ip IP Address * @return int 0 if not valid or reserved range, 1 if valid and public IP, 2 if valid and private range IP */ diff --git a/htdocs/core/lib/usergroups.lib.php b/htdocs/core/lib/usergroups.lib.php index 1c919237f44..f39e6ecd628 100644 --- a/htdocs/core/lib/usergroups.lib.php +++ b/htdocs/core/lib/usergroups.lib.php @@ -1,6 +1,6 @@ - * Copyright (C) 2010-2012 Regis Houssin + * Copyright (C) 2010-2017 Regis Houssin * Copyright (C) 2015 Alexandre Spangaro * * This program is free software; you can redistribute it and/or modify @@ -76,7 +76,7 @@ function user_prepare_head($object) { if (empty($conf->global->AGENDA_EXT_NB)) $conf->global->AGENDA_EXT_NB=5; $MAXAGENDA=$conf->global->AGENDA_EXT_NB; - + $i=1; $nbagenda = 0; while ($i <= $MAXAGENDA) @@ -87,10 +87,10 @@ function user_prepare_head($object) $offsettz='AGENDA_EXT_OFFSETTZ_'.$object->id.'_'.$key; $color='AGENDA_EXT_COLOR_'.$object->id.'_'.$key; $i++; - + if (! empty($object->conf->$name)) $nbagenda++; } - + $head[$h][0] = DOL_URL_ROOT.'/user/agenda_extsites.php?id='.$object->id; $head[$h][1] = $langs->trans("ExtSites").($nbagenda ? ' '.$nbagenda.'' : ''); $head[$h][2] = 'extsites'; @@ -238,8 +238,6 @@ function group_prepare_head($object) return $head; } - - /** * Prepare array with list of tabs * @@ -283,32 +281,6 @@ function user_admin_prepare_head() return $head; } - - -/** - * Prepare array with list of tabs - * - * @param Object $object Object related to tabs - * @param array $aEntities Entities array - * @return array Array of tabs - */ -function entity_prepare_head($object, $aEntities) -{ - global $mc; - - $head = array(); - - foreach($aEntities as $entity) - { - $mc->getInfo($entity); - $head[$entity][0] = $_SERVER['PHP_SELF'].'?id='.$object->id.'&entity='.$entity; - $head[$entity][1] = $mc->label; - $head[$entity][2] = $entity; - } - - return $head; -} - /** * Show list of themes. Show all thumbs of themes * @@ -485,7 +457,7 @@ function show_theme($fuser,$edit=0,$foruserprofile=false) print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis")); print ''; } - + // Background color THEME_ELDY_BACKBODY if ($foruserprofile) { @@ -508,7 +480,7 @@ function show_theme($fuser,$edit=0,$foruserprofile=false) else print ''; } if ($edit) print '
('.$langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis").')'; - print '';*/ + print '';*/ } else { @@ -530,7 +502,7 @@ function show_theme($fuser,$edit=0,$foruserprofile=false) print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis")); print ''; } - + // TopMenuBackgroundColor if ($foruserprofile) { @@ -553,13 +525,13 @@ function show_theme($fuser,$edit=0,$foruserprofile=false) else print ''; } if ($edit) print '
('.$langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis").')'; - print '';*/ + print '';*/ } else { $default='5a6482'; if ($conf->theme == 'md') $default='5a3278'; - + print ''; print ''.$langs->trans("TopMenuBackgroundColor").''; print ''; @@ -577,15 +549,15 @@ function show_theme($fuser,$edit=0,$foruserprofile=false) print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis")); print ''; } - + // BackgroundTableTitleColor if ($foruserprofile) { - - + + } else - { + { print ''; print ''.$langs->trans("BackgroundTableTitleColor").''; print ''; @@ -613,7 +585,7 @@ function show_theme($fuser,$edit=0,$foruserprofile=false) { $default='ffffff'; if ($conf->theme == 'md') $default='ffffff'; - + print ''; print ''.$langs->trans("BackgroundTableLineOddColor").''; print ''; @@ -631,17 +603,17 @@ function show_theme($fuser,$edit=0,$foruserprofile=false) print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis")); print ''; } - + // BackgroundTableLineEvenColor if ($foruserprofile) { - + } else { $default='f8f8f8'; if ($conf->theme == 'md') $default='f8f8f8'; - + print ''; print ''.$langs->trans("BackgroundTableLineEvenColor").''; print ''; @@ -659,12 +631,12 @@ function show_theme($fuser,$edit=0,$foruserprofile=false) print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis")); print ''; } - + // TextTitleColor if ($foruserprofile) { - - + + } else { @@ -681,12 +653,12 @@ function show_theme($fuser,$edit=0,$foruserprofile=false) } print '   ('.$langs->trans("Default").': 3c3c14) '; print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis")); - + print ''; - + print ''; } - + // Text LinkColor if ($foruserprofile) { @@ -724,7 +696,7 @@ function show_theme($fuser,$edit=0,$foruserprofile=false) { $color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_TEXTLINK,array()),''); if ($color) print ''; - else + else { //print ''; //print ''.$langs->trans("Default").''; @@ -735,7 +707,7 @@ function show_theme($fuser,$edit=0,$foruserprofile=false) print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis")); print ''; } - + // Use Hover if ($foruserprofile) { @@ -767,7 +739,7 @@ function show_theme($fuser,$edit=0,$foruserprofile=false) { if ($conf->global->THEME_ELDY_USE_HOVER == '1') $color='edf4fb'; else $color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_USE_HOVER,array()),''); - if ($color) + if ($color) { if ($color != 'edf4fb') print ''; else print $langs->trans("Default"); @@ -779,7 +751,6 @@ function show_theme($fuser,$edit=0,$foruserprofile=false) print ''; print ''; } - + print ''; } - diff --git a/htdocs/core/login/functions_dolibarr.php b/htdocs/core/login/functions_dolibarr.php index daf82b2f995..190d779d90b 100644 --- a/htdocs/core/login/functions_dolibarr.php +++ b/htdocs/core/login/functions_dolibarr.php @@ -39,7 +39,7 @@ function check_user_password_dolibarr($usertotest,$passwordtotest,$entitytotest= // Force master entity in transversal mode $entity=$entitytotest; - if (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)) $entity=1; + if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) $entity=1; $login=''; diff --git a/htdocs/core/login/functions_ldap.php b/htdocs/core/login/functions_ldap.php index c94312c8aa2..129bbcedf38 100644 --- a/htdocs/core/login/functions_ldap.php +++ b/htdocs/core/login/functions_ldap.php @@ -45,7 +45,7 @@ function check_user_password_ldap($usertotest,$passwordtotest,$entitytotest) // Force master entity in transversal mode $entity=$entitytotest; - if (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)) $entity=1; + if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) $entity=1; $login=''; $resultFetchUser=''; diff --git a/htdocs/core/menus/init_menu_auguria.sql b/htdocs/core/menus/init_menu_auguria.sql index 7a60f330727..a32d3ef6886 100644 --- a/htdocs/core/menus/init_menu_auguria.sql +++ b/htdocs/core/menus/init_menu_auguria.sql @@ -63,9 +63,9 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left -- Home - Menu users and groups insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '1', __HANDLER__, 'left', 400__+MAX_llx_menu__, 'home', 'users', 1__+MAX_llx_menu__, '/user/home.php?leftmenu=users', 'MenuUsersAndGroups', 0, 'users', '', '', 2, 4, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$leftmenu=="users"', __HANDLER__, 'left', 401__+MAX_llx_menu__, 'home', '', 400__+MAX_llx_menu__, '/user/index.php?leftmenu=users', 'Users', 1, 'users', '$user->rights->user->user->lire || $user->admin', '', 2, 0, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$leftmenu=="users"', __HANDLER__, 'left', 402__+MAX_llx_menu__, 'home', '', 401__+MAX_llx_menu__, '/user/card.php?leftmenu=users&action=create', 'NewUser', 2, 'users', '$user->rights->user->user->creer || $user->admin', '', 2, 0, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$leftmenu=="users"', __HANDLER__, 'left', 403__+MAX_llx_menu__, 'home', '', 400__+MAX_llx_menu__, '/user/group/index.php?leftmenu=users', 'Groups', 1, 'users', '($conf->global->MAIN_USE_ADVANCED_PERMS?$user->rights->user->group_advance->read:$user->rights->user->user->lire) || $user->admin', '', 2, 1, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$leftmenu=="users"', __HANDLER__, 'left', 404__+MAX_llx_menu__, 'home', '', 403__+MAX_llx_menu__, '/user/group/card.php?leftmenu=users&action=create', 'NewGroup', 2, 'users', '($conf->global->MAIN_USE_ADVANCED_PERMS?$user->rights->user->group_advance->write:$user->rights->user->user->creer) || $user->admin', '', 2, 0, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$leftmenu=="users"', __HANDLER__, 'left', 402__+MAX_llx_menu__, 'home', '', 401__+MAX_llx_menu__, '/user/card.php?leftmenu=users&action=create', 'NewUser', 2, 'users', '($user->rights->user->user->creer || $user->admin) && !(! empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE)', '', 2, 0, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$leftmenu=="users"', __HANDLER__, 'left', 403__+MAX_llx_menu__, 'home', '', 400__+MAX_llx_menu__, '/user/group/index.php?leftmenu=users', 'Groups', 1, 'users', '(($conf->global->MAIN_USE_ADVANCED_PERMS?$user->rights->user->group_advance->read:$user->rights->user->user->lire) || $user->admin) && !(! empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE)', '', 2, 1, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$leftmenu=="users"', __HANDLER__, 'left', 404__+MAX_llx_menu__, 'home', '', 403__+MAX_llx_menu__, '/user/group/card.php?leftmenu=users&action=create', 'NewGroup', 2, 'users', '(($conf->global->MAIN_USE_ADVANCED_PERMS?$user->rights->user->group_advance->write:$user->rights->user->user->creer) || $user->admin) && !(! empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE)', '', 2, 0, __ENTITY__); -- Third parties insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->societe->enabled', __HANDLER__, 'left', 500__+MAX_llx_menu__, 'companies', 'thirdparties', 2__+MAX_llx_menu__, '/societe/index.php?leftmenu=thirdparties', 'ThirdParty', 0, 'companies', '$user->rights->societe->lire', '', 2, 0, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->societe->enabled', __HANDLER__, 'left', 501__+MAX_llx_menu__, 'companies', '', 500__+MAX_llx_menu__, '/societe/card.php?action=create', 'MenuNewThirdParty', 1, 'companies', '$user->rights->societe->lire', '', 2, 0, __ENTITY__); @@ -211,7 +211,7 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2400__+MAX_llx_menu__, 'accountancy', 'accounting', 6__+MAX_llx_menu__, '/accountancy/index.php?leftmenu=accountancy', 'MenuAccountancy', 0, 'accountancy', '! empty($conf->accounting->enabled) || $user->rights->accounting->bind->write || $user->rights->accounting->bind->write || $user->rights->compta->resultat->lire', '', 0, 7, __ENTITY__); -- Setup insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2451__+MAX_llx_menu__, 'accountancy', 'accountancy_admin', 2400__+MAX_llx_menu__, '/accountancy/index.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'Setup', 1, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 1, __ENTITY__); - insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2457__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_journal', 2451__+MAX_llx_menu__, '/accountancy/admin/journals_list.php?id=35&mainmenu=accountancy&leftmenu=accountancy_admin', 'AccountingJournals', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 10, __ENTITY__); + insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2454__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_journal', 2451__+MAX_llx_menu__, '/accountancy/admin/journals_list.php?id=35&mainmenu=accountancy&leftmenu=accountancy_admin', 'AccountingJournals', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 10, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2455__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_chartmodel', 2451__+MAX_llx_menu__, '/accountancy/admin/account.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'Pcg_version', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 20, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2456__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_chart', 2451__+MAX_llx_menu__, '/accountancy/admin/account.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'Chartofaccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 30, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2457__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_chart_group', 2451__+MAX_llx_menu__, '/accountancy/admin/categories_list.php?id=32&mainmenu=accountancy&leftmenu=accountancy_admin', 'AccountingCategory', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 40, __ENTITY__); diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 8b6b26d772c..7a1dfcd4ecf 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -597,12 +597,12 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu if ($usemenuhider || empty($leftmenu) || $leftmenu=="users") { $newmenu->add("", $langs->trans("Users"), 1, $user->rights->user->user->lire || $user->admin); - $newmenu->add("/user/card.php?leftmenu=users&action=create", $langs->trans("NewUser"),2, $user->rights->user->user->creer || $user->admin, '', 'home'); + $newmenu->add("/user/card.php?leftmenu=users&action=create", $langs->trans("NewUser"),2, ($user->rights->user->user->creer || $user->admin) && !(! empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE), '', 'home'); $newmenu->add("/user/index.php?leftmenu=users", $langs->trans("ListOfUsers"), 2, $user->rights->user->user->lire || $user->admin); $newmenu->add("/user/hierarchy.php?leftmenu=users", $langs->trans("HierarchicView"), 2, $user->rights->user->user->lire || $user->admin); - $newmenu->add("", $langs->trans("Groups"), 1, $user->rights->user->user->lire || $user->admin); - $newmenu->add("/user/group/card.php?leftmenu=users&action=create", $langs->trans("NewGroup"), 2, ($conf->global->MAIN_USE_ADVANCED_PERMS?$user->rights->user->group_advance->write:$user->rights->user->user->creer) || $user->admin); - $newmenu->add("/user/group/index.php?leftmenu=users", $langs->trans("ListOfGroups"), 2, ($conf->global->MAIN_USE_ADVANCED_PERMS?$user->rights->user->group_advance->read:$user->rights->user->user->lire) || $user->admin); + $newmenu->add("", $langs->trans("Groups"), 1, ($user->rights->user->user->lire || $user->admin) && !(! empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE)); + $newmenu->add("/user/group/card.php?leftmenu=users&action=create", $langs->trans("NewGroup"), 2, (($conf->global->MAIN_USE_ADVANCED_PERMS?$user->rights->user->group_advance->write:$user->rights->user->user->creer) || $user->admin) && !(! empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE)); + $newmenu->add("/user/group/index.php?leftmenu=users", $langs->trans("ListOfGroups"), 2, (($conf->global->MAIN_USE_ADVANCED_PERMS?$user->rights->user->group_advance->read:$user->rights->user->user->lire) || $user->admin) && !(! empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE)); } } diff --git a/htdocs/core/tpl/extrafields_view.tpl.php b/htdocs/core/tpl/extrafields_view.tpl.php index fcb92f1b525..9c9813e18ca 100644 --- a/htdocs/core/tpl/extrafields_view.tpl.php +++ b/htdocs/core/tpl/extrafields_view.tpl.php @@ -17,22 +17,28 @@ * * Need to have following variables defined: * $object (invoice, order, ...) + * $action * $conf * $langs * + * $parameters * $cols */ ?> - + fetch_optionals($object->id, $extralabels); -$parameters = array('colspan' => ' colspan="'.$cols.'"', 'cols' => $cols, 'socid' => $object->fk_soc); -$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); +if (! is_array($parameters)) $parameters = array(); +if (! empty($cols)) $parameters['colspan'] = ' colspan="'.$cols.'"'; +if (! empty($cols)) $parameters['cols'] = $cols; +if (! empty($object->fk_soc)) $parameters['socid'] = $object->fk_soc; -if (empty($reshook) && ! empty($extrafields->attribute_label)) +$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +if (empty($reshook) && ! empty($extrafields->attributes[$object->table_element]['label'])) { - foreach ($extrafields->attribute_label as $key => $label) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $label) { if ($action == 'edit_extras') { @@ -42,54 +48,63 @@ if (empty($reshook) && ! empty($extrafields->attribute_label)) { $value = $object->array_options["options_" . $key]; } - if ($extrafields->attribute_type[$key] == 'separate') + if ($extrafields->attributes[$object->table_element]['type'][$key] == 'separate') { print $extrafields->showSeparator($key); } else { - if (!empty($extrafields->attribute_hidden[$key])) print ''; + if (! empty($extrafields->attributes[$object->table_element]['ishidden'][$key])) print ''; else print ''; print ''; print ''; print 'attribute_required[$key])) print ' class="fieldrequired"'; + if ((! empty($action) && ($action == 'create' || $action == 'edit')) && ! empty($extrafields->attributes[$object->table_element]['required'][$key])) print ' class="fieldrequired"'; print '>' . $langs->trans($label) . ''; //TODO Improve element and rights detection //var_dump($user->rights); $permok=false; + $keyforperm=$object->element; if ($object->element == 'fichinter') $keyforperm='ficheinter'; if (isset($user->rights->$keyforperm)) $permok=$user->rights->$keyforperm->creer||$user->rights->$keyforperm->create||$user->rights->$keyforperm->write; - if ($object->element=='order_supplier') $permok=$user->rights->fournisseur->commande->creer; + + if ($object->element=='order_supplier') $permok=$user->rights->fournisseur->commande->creer; if ($object->element=='invoice_supplier') $permok=$user->rights->fournisseur->facture->creer; - if ($object->element=='shipping') $permok=$user->rights->expedition->creer; - if ($object->element=='delivery') $permok=$user->rights->expedition->livraison->creer; - if ($object->element=='productlot') $permok=$user->rights->stock->creer; - - if (($object->statut == 0 || $extrafields->attribute_alwayseditable[$key]) - && $permok && ($action != 'edit_extras' || GETPOST('attribute') != $key)) - print ''; + if ($object->element=='shipping') $permok=$user->rights->expedition->creer; + if ($object->element=='delivery') $permok=$user->rights->expedition->livraison->creer; + if ($object->element=='productlot') $permok=$user->rights->stock->creer; + if (($object->statut == 0 || ! empty($extrafields->attributes[$object->table_element]['alwayseditable'][$key])) + && $permok && ($action != 'edit_extras' || GETPOST('attribute') != $key) + && empty($extrafields->attributes[$object->table_element]['computed'][$key])) + { + $fieldid='id'; + if ($object->table_element == 'societe') $fieldid='socid'; + print ''; + } print '
' . img_edit().'' . img_edit().'
'; $html_id = !empty($object->id) ? $object->element.'_extras_'.$key.'_'.$object->id : ''; print ''; // Convert date into timestamp format - if (in_array($extrafields->attribute_type[$key], array('date','datetime'))) { + if (in_array($extrafields->attributes[$object->table_element]['type'][$key], array('date','datetime'))) { $value = isset($_POST["options_" . $key]) ? dol_mktime($_POST["options_" . $key . "hour"], $_POST["options_" . $key . "min"], 0, $_POST["options_" . $key . "month"], $_POST["options_" . $key . "day"], $_POST["options_" . $key . "year"]) : $db->jdate($object->array_options['options_' . $key]); } //TODO Improve element and rights detection if ($action == 'edit_extras' && $permok && GETPOST('attribute') == $key) { - print '
'; + $fieldid='id'; + if ($object->table_element == 'societe') $fieldid='socid'; + + print ''; print ''; print ''; print ''; - print ''; + print ''; print $extrafields->showInputField($key, $value,'','','',0,$object->id); @@ -102,8 +117,41 @@ if (empty($reshook) && ! empty($extrafields->attribute_label)) print $extrafields->showOutputField($key, $value); } print '' . "\n"; + + print "\n"; + // Add code to manage list depending on others + if (! empty($conf->use_javascript_ajax)) + print ' + '."\n"; } } } ?> - \ No newline at end of file + \ No newline at end of file diff --git a/htdocs/don/card.php b/htdocs/don/card.php index 882b80ec339..8e1bd00d893 100644 --- a/htdocs/don/card.php +++ b/htdocs/don/card.php @@ -50,7 +50,7 @@ $cancel=GETPOST('cancel'); $amount=GETPOST('amount'); $donation_date=dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); $projectid = (GETPOST('projectid') ? GETPOST('projectid', 'int') : 0); - + $object = new Don($db); $extrafields = new ExtraFields($db); @@ -336,7 +336,7 @@ if ($action == 'create') print ''; // Country - print ''; + print ''; print $form->select_country(GETPOST('country_id')!=''?GETPOST('country_id'):$object->country_id); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); print ''; @@ -346,7 +346,7 @@ if ($action == 'create') // Public note print ''; print '' . $langs->trans('NotePublic') . ''; - print ''; + print ''; $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); print $doleditor->Create(1); @@ -356,7 +356,7 @@ if ($action == 'create') if (empty($user->societe_id)) { print ''; print '' . $langs->trans('NotePrivate') . ''; - print ''; + print ''; $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); print $doleditor->Create(1); @@ -371,7 +371,7 @@ if ($action == 'create') } // Other attributes - $parameters=array('colspan' => 3); + $parameters=array(); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook if (empty($reshook) && ! empty($extrafields->attribute_label)) { @@ -442,7 +442,7 @@ if (! empty($id) && $action == 'edit') } else { - print ''.$langs->trans("Amount").''; + print ''.$langs->trans("Amount").''; print price($object->amount,0,$langs,0,0,-1,$conf->currency); print ''; } @@ -467,7 +467,7 @@ if (! empty($id) && $action == 'edit') print ''; // Country - print ''.$langs->trans('Country').''; + print ''.$langs->trans('Country').''; print $form->select_country((!empty($object->country_id)?$object->country_id:$mysoc->country_code),'country_id'); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); print ''; @@ -496,7 +496,7 @@ if (! empty($id) && $action == 'edit') } // Other attributes - $parameters=array('colspan' => ' colspan="2"'); + $parameters=array(); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook if (empty($reshook) && ! empty($extrafields->attribute_label)) { @@ -544,9 +544,9 @@ if (! empty($id) && $action != 'edit') // Print form confirm print $formconfirm; - + $linkback = ''.$langs->trans("BackToList").''; - + $morehtmlref='
'; // Project if (! empty($conf->projet->enabled)) @@ -581,8 +581,8 @@ if (! empty($id) && $action != 'edit') } } $morehtmlref.='
'; - - + + dol_banner_tab($object, 'rowid', $linkback, 1, 'rowid', 'ref', $morehtmlref); @@ -620,7 +620,7 @@ if (! empty($id) && $action != 'edit') // Zip / Town print ''.$langs->trans("Zip").' / '.$langs->trans("Town").''; print $object->zip.($object->zip && $object->town?' / ':'').$object->town.''; - + // Country print ''.$langs->trans('Country').''; if (! empty($object->country_code)) @@ -634,18 +634,18 @@ if (! empty($id) && $action != 'edit') print $object->country_olddata; } print ''; - + // EMail print "".''.$langs->trans("EMail").''.dol_print_email($object->email).''; */ - + // Payment mode print "".$langs->trans("PaymentMode").""; $form->form_modes_reglement(null, $object->modepaymentid,'none'); print "\n"; - + //print "".''.$langs->trans("Status").''.$object->getLibStatut(4).''; - + // Project /* if (! empty($conf->projet->enabled)) @@ -660,7 +660,7 @@ if (! empty($id) && $action != 'edit') print ''; print ''; }*/ - + // Other attributes $cols = 2; include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; @@ -702,7 +702,7 @@ if (! empty($id) && $action != 'edit') while ($i < $num) { $objp = $db->fetch_object($resql); - + print ''; print ''.img_object($langs->trans("Payment"),"payment").' '.$objp->rowid.''; print ''.dol_print_date($db->jdate($objp->dp),'day')."\n"; diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index b4345c72878..966f1f95972 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -115,12 +115,12 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (empty($reshook)) { - if ($cancel) - { - $action = ''; + if ($cancel) + { + $action = ''; $object->fetch($id); // show shipment also after canceling modification } - + include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once // Set incoterm @@ -129,13 +129,13 @@ if (empty($reshook)) $object->fetch($id); $result = $object->reOpen(); } - + // Set incoterm if ($action == 'set_incoterms' && !empty($conf->incoterm->enabled)) { $result = $object->setIncoterms(GETPOST('incoterm_id', 'int'), GETPOST('location_incoterms', 'alpha')); } - + if ($action == 'setref_customer') { $result = $object->fetch($id); @@ -152,14 +152,14 @@ if (empty($reshook)) exit; } } - + if ($action == 'update_extras') { // Fill array 'array_options' with data from update form $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute')); if ($ret < 0) $error++; - + if (! $error) { // Actions on extra fields (by external module or standard code) @@ -175,11 +175,11 @@ if (empty($reshook)) } else if ($reshook < 0) $error++; } - + if ($error) $action = 'edit_extras'; } - + // Create shipment if ($action == 'add' && $user->rights->expedition->creer) { @@ -251,18 +251,18 @@ if (empty($reshook)) $sub_qty[$j]['q']=GETPOST($qty,'int'); // the qty we want to move for this stock record $sub_qty[$j]['id_batch']=GETPOST($batch,'int'); // the id into llx_product_batch of stock record to move $subtotalqty+=$sub_qty[$j]['q']; - + //var_dump($qty);var_dump($batch);var_dump($sub_qty[$j]['q']);var_dump($sub_qty[$j]['id_batch']); - + $j++; $batch="batchl".$i."_".$j; $qty = "qtyl".$i.'_'.$j; } - + $batch_line[$i]['detail']=$sub_qty; // array of details $batch_line[$i]['qty']=$subtotalqty; $batch_line[$i]['ix_l']=GETPOST($idl,'int'); - + $totalqty+=$subtotalqty; } else @@ -289,11 +289,11 @@ if (empty($reshook)) $stockLine[$i][$j]['ix_l']=GETPOST($idl,'int'); $totalqty+=GETPOST($qty,'int'); - + $j++; $stockLocation="ent1".$i."_".$j; $qty = "qtyl".$i.'_'.$j; - } + } } else { @@ -301,7 +301,7 @@ if (empty($reshook)) //shipment line for product with no batch management and no multiple stock location if (GETPOST($qty,'int') > 0) $totalqty+=GETPOST($qty,'int'); } - + // Extrafields $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); $array_options[$i] = $extrafieldsline->getOptionalsFromPost($extralabelsline, $i); @@ -312,9 +312,9 @@ if (empty($reshook)) unset($_POST["options_" . $key]); } } - + } - + //var_dump($batch_line[2]); if ($totalqty > 0) // There is at least one thing to ship @@ -324,7 +324,7 @@ if (empty($reshook)) { $qty = "qtyl".$i; if (! isset($batch_line[$i])) - { + { // not batch mode if (isset($stockLine[$i])) { @@ -352,7 +352,7 @@ if (empty($reshook)) $entrepot_id = is_numeric(GETPOST($ent,'int'))?GETPOST($ent,'int'):GETPOST('entrepot_id','int'); if ($entrepot_id < 0) $entrepot_id=''; if (! ($objectsrc->lines[$i]->fk_product > 0)) $entrepot_id = 0; - + $ret=$object->addline($entrepot_id, GETPOST($idl,'int'), GETPOST($qty,'int'), $array_options[$i]); if ($ret < 0) { @@ -363,7 +363,7 @@ if (empty($reshook)) } } else - { + { // batch mode if ($batch_line[$i]['qty']>0) { @@ -375,11 +375,11 @@ if (empty($reshook)) } } } - } + } // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost($extralabels, $object); if ($ret < 0) $error++; - + if (! $error) { $ret=$object->create($user); // This create shipment (like Odoo picking) and line of shipments. Stock movement will when validating shipment. @@ -433,9 +433,9 @@ if (empty($reshook)) ) { $object->fetch_thirdparty(); - + $result = $object->valid($user); - + if ($result < 0) { $langs->load("errors"); @@ -627,7 +627,7 @@ if ($action == 'create2') $action=''; $id=''; $ref=''; } -// Mode creation. +// Mode creation. if ($action == 'create') { $expe = new Expedition($db); @@ -740,7 +740,7 @@ if ($action == 'create') // Weight print ''; print $langs->trans("Weight"); - print ' '; + print ' '; $text=$formproduct->select_measuring_units("weight_units","weight",GETPOST('weight_units','int')); $htmltext=$langs->trans("KeepEmptyForAutoCalculation"); print $form->textwithpicto($text, $htmltext); @@ -770,15 +770,15 @@ if ($action == 'create') print ''; print ''; print "\n"; - + // Other attributes $parameters = array('objectsrc' => $objectsrc, 'colspan' => ' colspan="3"', 'socid'=>$socid); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$expe,$action); // Note that $action and $object may have been modified by hook - + if (empty($reshook) && ! empty($extrafields->attribute_label)) { print $expe->showOptionals($extrafields, 'edit'); } - + // Incoterms if (!empty($conf->incoterm->enabled)) @@ -800,12 +800,12 @@ if ($action == 'create') print $form->selectarray('model', $liste, $conf->global->EXPEDITION_ADDON_PDF); print "\n"; } - + print ""; dol_fiche_end(); - + // Shipment lines $numAsked = count($object->lines); @@ -833,14 +833,14 @@ if ($action == 'create') print '
'; - - + + print ''; // Load shipments already done for same order $object->loadExpeditions(); - + if ($numAsked) { print ''; @@ -848,7 +848,7 @@ if ($action == 'create') print ''; print ''; print ''."\n"; - + // Product label if ($line->fk_product > 0) // If predefined product { @@ -913,7 +913,7 @@ if ($action == 'create') { print ($line->desc && $line->desc!=$line->product_label)?'
'.dol_htmlentitiesbr($line->desc):''; } - + print ''; } else @@ -958,7 +958,7 @@ if ($action == 'create') $quantityToBeDelivered = $quantityAsked - $quantityDelivered; } $warehouse_id = GETPOST('entrepot_id','int'); - + $warehouseObject = null; if ($warehouse_id > 0 || ! ($line->fk_product > 0) || empty($conf->stock->enabled)) // If warehouse was already selected or if product is not a predefined, we go into this part with no multiwarehouse selection { @@ -1040,10 +1040,10 @@ if ($action == 'create') { // Product need lot print ''; // end line and start a new one for lot/serial - + $staticwarehouse=new Entrepot($db); if ($warehouse_id > 0) $staticwarehouse->fetch($warehouse_id); - + $subj=0; // Define nb of lines suggested for this order line $nbofsuggested=0; @@ -1066,11 +1066,11 @@ if ($action == 'create') print ''; - + print ''; - + print ''; } } } - else + else { // ship from multiple locations if (empty($conf->productbatch->enabled) || ! $product->hasbatch()) { print ''; // end line and start a new one for each warehouse print ''; - + print ''; $subj=0; // Define nb of lines suggested for this order line $nbofsuggested=0; foreach ($product->stock_warehouse as $warehouse_id=>$stock_warehouse) { - if ($stock_warehouse->real > 0) + if ($stock_warehouse->real > 0) { $nbofsuggested++; } @@ -1119,7 +1119,7 @@ if ($action == 'create') foreach ($product->stock_warehouse as $warehouse_id=>$stock_warehouse) // $stock_warehouse is product_stock { $tmpwarehouseObject->fetch($warehouse_id); - if ($stock_warehouse->real > 0) + if ($stock_warehouse->real > 0) { $stock = + $stock_warehouse->real; // Convert it to number $deliverableQty = min($quantityToBeDelivered,$stock); @@ -1134,7 +1134,7 @@ if ($action == 'create') } else print $langs->trans("NA"); print ''; - + // Stock if (! empty($conf->stock->enabled)) { @@ -1142,10 +1142,10 @@ if ($action == 'create') if ($line->product_type == 0 || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) { print $tmpwarehouseObject->getNomUrl(0).' '; - + print ''; print '('.$stock.')'; - + } else { @@ -1193,7 +1193,7 @@ if ($action == 'create') $subj=0; print ''; - + $tmpwarehouseObject=new Entrepot($db); $productlotObject=new Productlot($db); // Define nb of lines suggested for this order line @@ -1207,7 +1207,7 @@ if ($action == 'create') } } } - foreach ($product->stock_warehouse as $warehouse_id=>$stock_warehouse) + foreach ($product->stock_warehouse as $warehouse_id=>$stock_warehouse) { $tmpwarehouseObject->fetch($warehouse_id); if (($stock_warehouse->real > 0) && (count($stock_warehouse->detail_batch))) { @@ -1219,11 +1219,11 @@ if ($action == 'create') print ''; - + print ''; - + print ''; } } - - + + //Display lines extrafields - if (is_array($extralabelslines) && count($extralabelslines)>0) + if (is_array($extralabelslines) && count($extralabelslines)>0) { $colspan=5; $line = new ExpeditionLigne($db); @@ -1340,14 +1340,14 @@ else if ($id || $ref) $soc = new Societe($db); $soc->fetch($object->socid); - + $res = $object->fetch_optionals($object->id, $extralabels); $head=shipping_prepare_head($object); dol_fiche_head($head, 'shipping', $langs->trans("Shipment"), 0, 'sending'); $formconfirm=''; - + // Confirm deleteion if ($action == 'delete') { @@ -1393,18 +1393,18 @@ else if ($id || $ref) if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint; } - + // Print form confirm print $formconfirm; - - + + // Calculate totalWeight and totalVolume for all products // by adding weight and volume of each product line. $tmparray=$object->getTotalWeightVolume(); $totalWeight=$tmparray['weight']; $totalVolume=$tmparray['volume']; - - + + if ($typeobject == 'commande' && $object->$typeobject->id && ! empty($conf->commande->enabled)) { $objectsrc=new Commande($db); @@ -1459,15 +1459,15 @@ else if ($id || $ref) } } $morehtmlref.=''; - + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); - - + + print '
'; print '
'; print '
'; - + print '
'.$langs->trans("QtyOrdered").''.$langs->trans("QtyShipped").''.$langs->trans("QtyToShip"); - if (empty($conf->productbatch->enabled)) + if (empty($conf->productbatch->enabled)) { print '
('.$langs->trans("Fill").''; print ' / '.$langs->trans("Reset").')'; @@ -875,7 +875,7 @@ if ($action == 'create') $product = new Product($db); $line = $object->lines[$indiceAsked]; - + // Show product and description $type=$line->product_type?$line->product_type:$line->fk_product_type; @@ -885,7 +885,7 @@ if ($action == 'create') if (! empty($line->date_end)) $type=1; print '
'; print ''; print ''; - + print $staticwarehouse->getNomUrl(0).' / '; - + print ''; print ''; print $langs->trans("DetailBatchFormat", $dbatch->batch, dol_print_date($dbatch->eatby,"day"), dol_print_date($dbatch->sellby,"day"), $dbatch->qty); @@ -1089,28 +1089,28 @@ if ($action == 'create') print '
'; print ' '; print ''; print img_warning().' '.$langs->trans("NoProductToShipFoundIntoStock", $staticwarehouse->libelle); print '
'; print ''; print ''; - + print $tmpwarehouseObject->getNomUrl(0).' / '; - + print ''; print ''; //print $langs->trans("DetailBatchFormat", $dbatch->batch, dol_print_date($dbatch->eatby,"day"), dol_print_date($dbatch->sellby,"day"), $dbatch->qty); @@ -1242,7 +1242,7 @@ if ($action == 'create') } } } - + } if ($subj == 0) // Line not shown yet, we show it { @@ -1262,12 +1262,12 @@ if ($action == 'create') print $langs->trans("NA"); } print ''; if ($line->product_type == 0 || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) { - $warehouse_selected_id = GETPOST('entrepot_id','int'); - if ($warehouse_selected_id > 0) + $warehouse_selected_id = GETPOST('entrepot_id','int'); + if ($warehouse_selected_id > 0) { $warehouseObject=new Entrepot($db); $warehouseObject->fetch($warehouse_selected_id); @@ -1287,10 +1287,10 @@ if ($action == 'create') print '
'; // Linked documents @@ -1550,7 +1550,7 @@ else if ($id || $ref) if (!empty($object->trueWeight)) print ' ('.$langs->trans("SumOfProductWeights").': '; //print $totalWeight.' '.measuring_units_string(0,"weight"); print showDimensionInBestUnit($totalWeight, 0, "weight", $langs, isset($conf->global->MAIN_WEIGHT_DEFAULT_ROUND)?$conf->global->MAIN_WEIGHT_DEFAULT_ROUND:-1, isset($conf->global->MAIN_WEIGHT_DEFAULT_UNIT)?$conf->global->MAIN_WEIGHT_DEFAULT_UNIT:'no'); - //if (empty($object->trueWeight)) print ' ('.$langs->trans("Calculated").')'; + //if (empty($object->trueWeight)) print ' ('.$langs->trans("Calculated").')'; if (!empty($object->trueWeight)) print ')'; } print ''; @@ -1597,7 +1597,7 @@ else if ($id || $ref) print '
'; $calculatedVolume=0; $volumeUnit=0; - if ($object->trueWidth && $object->trueHeight && $object->trueDepth) + if ($object->trueWidth && $object->trueHeight && $object->trueDepth) { $calculatedVolume=($object->trueWidth * $object->trueHeight * $object->trueDepth); $volumeUnit=$object->size_units * 3; @@ -1605,7 +1605,7 @@ else if ($id || $ref) // If sending volume not defined we use sum of products if ($calculatedVolume > 0) { - if ($volumeUnit < 50) + if ($volumeUnit < 50) { //print $calculatedVolume.' '.measuring_units_string($volumeUnit,"volume"); print showDimensionInBestUnit($calculatedVolume, $volumeUnit, "volume", $langs, isset($conf->global->MAIN_VOLUME_DEFAULT_ROUND)?$conf->global->MAIN_VOLUME_DEFAULT_ROUND:-1, isset($conf->global->MAIN_VOLUME_DEFAULT_UNIT)?$conf->global->MAIN_VOLUME_DEFAULT_UNIT:'no'); @@ -1626,14 +1626,14 @@ else if ($id || $ref) // Other attributes $cols = 2; include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; - + print '
'; - + print '
'; print '
'; print '
'; print '
'; - + print ''; // Sending method @@ -1667,7 +1667,7 @@ else if ($id || $ref) } print ''; print ''; - + // Tracking Number print '
'.$form->editfieldkey("TrackingNumber",'trackingnumber',$object->tracking_number,$object,$user->rights->expedition->creer).''; print $form->editfieldval("TrackingNumber",'trackingnumber',$object->tracking_url,$object,$user->rights->expedition->creer,'string',$object->tracking_number); @@ -1697,19 +1697,19 @@ else if ($id || $ref) } print "
"; - + print '
'; print '
'; print '
'; - + print '
'; - + /* * Lines of products */ print '
'; - + print '
'; print ''; print ''; @@ -1732,7 +1732,7 @@ else if ($id || $ref) { print ''; } - + print ''; print ''; //print ''; @@ -1793,7 +1793,7 @@ else if ($id || $ref) { $num = $db->num_rows($resql); $i = 0; - + while($i < $num) { $obj = $db->fetch_object($resql); @@ -1900,7 +1900,7 @@ else if ($id || $ref) } } } - } + } print ''; // Weight @@ -1960,7 +1960,7 @@ else if ($id || $ref) } print $form->textwithtooltip(img_picto('', 'object_barcode').' '.$langs->trans("DetailBatchNumber"),$detail); } - else + else { print $langs->trans("NA"); } @@ -1970,7 +1970,7 @@ else if ($id || $ref) } } print ""; - + // Display lines extrafields if (is_array($extralabelslines) && count($extralabelslines)>0) { $colspan= empty($conf->productbatch->enabled) ? 5 : 6; @@ -1981,11 +1981,11 @@ else if ($id || $ref) print ''; } - + } - + // TODO Show also lines ordered but not delivered - + print "
'.$langs->trans("QtyInOtherShipments").''.$langs->trans("CalculatedWeight").''.$langs->trans("CalculatedVolume").''.$langs->trans("Size").'
\n"; print '
'; } @@ -1996,7 +1996,7 @@ else if ($id || $ref) $object->fetchObjectLinked($object->id,$object->element); - + /* * Boutons actions */ @@ -2023,14 +2023,14 @@ else if ($id || $ref) print ''.$langs->trans("Validate").''; } } - + // TODO add alternative status // 0=draft, 1=validated, 2=billed, we miss a status "delivered" (only available on order) if ($object->statut == 2 && $object->billed && $user->rights->expedition->creer) { print ''.$langs->trans("ReOpen").''; } - + // Send if ($object->statut > 0) { @@ -2040,7 +2040,7 @@ else if ($id || $ref) } else print ''.$langs->trans('SendByMail').''; } - + // Create bill and Close shipment if (! empty($conf->facture->enabled) && $object->statut > 0) { @@ -2049,7 +2049,7 @@ else if ($id || $ref) print ''.$langs->trans("CreateBill").''; } } - + // This is just to generate a delivery receipt //var_dump($object->linkedObjectsIds['delivery']); if ($conf->livraison_bon->enabled && ($object->statut == 1 || $object->statut == 2) && $user->rights->expedition->livraison->creer && count($object->linkedObjectsIds['delivery']) == 0) @@ -2071,14 +2071,14 @@ else if ($id || $ref) print ''.$langs->trans($label).''; } } - + if ($user->rights->expedition->supprimer) { print ''.$langs->trans("Delete").''; } - + } - + print '
'; } @@ -2086,11 +2086,11 @@ else if ($id || $ref) /* * Documents generated */ - + if ($action != 'presend') { print '
'; - + $objectref = dol_sanitizeFileName($object->ref); $filedir = $conf->expedition->dir_output . "/sending/" .$objectref; @@ -2101,12 +2101,12 @@ else if ($id || $ref) print $formfile->showdocuments('expedition',$objectref,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf,1,0,0,28,0,'','','',$soc->default_lang); - + // Show links to link elements //$linktoelem = $form->showLinkToObjectBlock($object, null, array('order')); $somethingshown = $form->showLinkedObjectBlock($object, ''); - + print '
'; // List of actions on element @@ -2117,11 +2117,11 @@ else if ($id || $ref) print '
'; } - + /* * Action presend */ - + //Select mail models is same action as presend if (GETPOST('modelselected')) { $action = 'presend'; @@ -2182,7 +2182,7 @@ else if ($id || $ref) { include DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; $formmail->frommail=dolAddEmailTrackId($formmail->frommail, 'shi'.$object->id); - } + } $formmail->withfrom=1; $liste=array(); foreach ($object->thirdparty->thirdparty_and_contact_email_array(1) as $key=>$value) $liste[$key]=$value; @@ -2215,7 +2215,7 @@ else if ($id || $ref) { $contactarr=$objectsrc->liste_contact(-1,'external'); } - + if (is_array($contactarr) && count($contactarr)>0) { foreach($contactarr as $contact) { diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php index 2bb2121411f..6d14f47af10 100644 --- a/htdocs/filefunc.inc.php +++ b/htdocs/filefunc.inc.php @@ -156,9 +156,6 @@ if (empty($dolibarr_main_limit_users)) $dolibarr_main_limit_users=0; if (empty($dolibarr_mailing_limit_sendbyweb)) $dolibarr_mailing_limit_sendbyweb=0; if (empty($dolibarr_mailing_limit_sendbycli)) $dolibarr_mailing_limit_sendbycli=0; if (empty($dolibarr_strict_mode)) $dolibarr_strict_mode=0; // For debug in php strict mode -// TODO Multicompany Remove this. Useless. -if (empty($multicompany_transverse_mode)) $multicompany_transverse_mode=0; -if (empty($multicompany_force_entity)) $multicompany_force_entity=0; // To force entity in login page // Security: CSRF protection // This test check if referrer ($_SERVER['HTTP_REFERER']) is same web site than Dolibarr ($_SERVER['HTTP_HOST']) diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index 0c1f3e56c5b..7b24ee4f082 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -133,9 +133,9 @@ if ($object->id > 0) dol_fiche_head($head, 'supplier', $langs->trans("ThirdParty"), -1, 'company'); $linkback = ''.$langs->trans("BackToList").''; - + dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom'); - + print '
'; print '
'; @@ -243,12 +243,7 @@ if ($object->id > 0) // Other attributes $parameters=array('socid'=>$object->id, 'colspan' => ' colspan="3"', 'colspanvalue' => '3'); - $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - if (empty($reshook) && ! empty($extrafields->attribute_label)) - { - print $object->showOptionals($extrafields); - } + include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; // Module Adherent if (! empty($conf->adherent->enabled)) @@ -278,15 +273,15 @@ if ($object->id > 0) print '
'; $boxstat = ''; - + // Nbre max d'elements des petites listes $MAXLIST=$conf->global->MAIN_SIZE_SHORTLIST_LIMIT; - + // Lien recap $boxstat.='
'; $boxstat.=''; $boxstat.=''; $boxstat.='
'; - + if ($conf->supplier_proposal->enabled) { // Box proposals @@ -304,7 +299,7 @@ if ($object->id > 0) $boxstat.=''; if ($link) $boxstat.=''; } - + if ($conf->fournisseur->enabled) { // Box proposals @@ -322,14 +317,14 @@ if ($object->id > 0) $boxstat.=''; if ($link) $boxstat.=''; } - + if ($conf->fournisseur->enabled) { $tmp = $object->getOutstandingBills('supplier'); $outstandingOpened=$tmp['opened']; $outstandingTotal=$tmp['total_ht']; $outstandingTotalIncTax=$tmp['total_ttc']; - + $text=$langs->trans("OverAllInvoices"); $link=''; $icon='bill'; @@ -339,7 +334,7 @@ if ($object->id > 0) $boxstat.=''.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).''; $boxstat.=''; if ($link) $boxstat.=''; - + // Box outstanding bill $text=$langs->trans("CurrentOutstandingBill"); $link=DOL_URL_ROOT.'/fourn/recap-fourn.php?socid='.$object->id; @@ -351,14 +346,14 @@ if ($object->id > 0) $boxstat.=''; if ($link) $boxstat.=''; } - + $boxstat.='
'; $boxstat.='
'; - + print $boxstat; - - + + $var=true; $MAXLIST=$conf->global->MAIN_SIZE_SHORTLIST_LIMIT; @@ -395,10 +390,10 @@ if ($object->id > 0) $sql.= ' AND pfp.fk_soc = '.$object->id; $sql .= $db->order('pfp.tms', 'desc'); $sql.= $db->plimit($MAXLIST); - + $query = $db->query($sql); if (! $query) dol_print_error($db); - + $return = array(); if ($db->num_rows($query)) { @@ -407,7 +402,7 @@ if ($object->id > 0) while ($objp = $db->fetch_object($query)) { - + $productstatic->id = $objp->rowid; $productstatic->ref = $objp->ref; @@ -445,12 +440,12 @@ if ($object->id > 0) print ''; } - + /* * Last supplier proposal */ $proposalstatic = new SupplierProposal($db); - + if ($user->rights->supplier_proposal->lire) { $sql = "SELECT p.rowid, p.ref, p.date_valid as dc, p.fk_statut, p.total_ht, p.tva as total_tva, p.total as total_ttc"; @@ -459,17 +454,17 @@ if ($object->id > 0) $sql.= " AND p.entity =".$conf->entity; $sql.= " ORDER BY p.date_valid DESC"; $sql.= " ".$db->plimit($MAXLIST); - + $resql=$db->query($sql); if ($resql) { $i = 0 ; $num = $db->num_rows($resql); - + if ($num > 0) { print ''; - + print ''; print ''; } - + $var = True; while ($i < $num && $i <= $MAXLIST) { $obj = $db->fetch_object($resql); - - + + print ''; print '
'; print ''; @@ -478,13 +473,13 @@ if ($object->id > 0) print '
'.$langs->trans("LastSupplierProposals",($num<$MAXLIST?"":$MAXLIST)).'
'; print '
'; $proposalstatic->id = $obj->rowid; @@ -509,14 +504,14 @@ if ($object->id > 0) $i++; } $db->free($resql); - + if ($num >0) print "
"; } else { dol_print_error($db); } - } + } /* * Last supplier orders @@ -558,7 +553,7 @@ if ($object->id > 0) $object_count = $db->fetch_object($resql); $num = $object_count->total; } - + $sql = "SELECT p.rowid,p.ref, p.date_commande as dc, p.fk_statut, p.total_ht, p.tva as total_tva, p.total_ttc"; $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as p "; $sql.= " WHERE p.fk_soc =".$object->id; @@ -587,7 +582,7 @@ if ($object->id > 0) while ($i < $num && $i < $MAXLIST) { $obj = $db->fetch_object($resql); - + print ''; print ''; @@ -660,7 +655,7 @@ if ($object->id > 0) while ($i < min($num,$MAXLIST)) { $obj = $db->fetch_object($resql); - + print ''; print ''; print ''; @@ -712,7 +707,7 @@ if ($object->id > 0) { print ''; } - + if ($conf->supplier_proposal->enabled && $user->rights->supplier_proposal->creer && $object->status==1) { $langs->load("supplier_proposal"); @@ -750,9 +745,9 @@ if ($object->id > 0) } } } - + print '
'; - + if (! empty($conf->global->MAIN_REPEATCONTACTONEACHTAB)) { diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index a6f0cc248f1..f77eb949c9a 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -279,7 +279,7 @@ if (empty($reshook)) if ($action == 'addline' && $user->rights->fournisseur->commande->creer) { $db->begin(); - + $langs->load('errors'); $error = 0; @@ -469,7 +469,7 @@ if (empty($reshook)) if (! $error && $result > 0) { $db->commit(); - + $ret=$object->fetch($object->id); // Reload to get new records // Define output language @@ -526,7 +526,7 @@ if (empty($reshook)) $db->rollback(); setEventMessages($object->error, $object->errors, 'errors'); } - + $action = ''; } @@ -1617,7 +1617,7 @@ elseif (! empty($object->id)) $res=$object->fetch_optionals($object->id,$extralabels); - + $head = ordersupplier_prepare_head($object); $title=$langs->trans("SupplierOrder"); @@ -1754,11 +1754,11 @@ elseif (! empty($object->id)) // Print form confirm print $formconfirm; - + // Supplier order card $linkback = ''.$langs->trans("BackToList").''; - + $morehtmlref='
'; // Ref supplier $morehtmlref.=$form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->fournisseur->commande->creer, 'string', '', 0, 1); @@ -1798,15 +1798,15 @@ elseif (! empty($object->id)) } } $morehtmlref.='
'; - - - dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); - + + + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + print '
'; print '
'; print '
'; - + print ''; // Date @@ -1995,16 +1995,15 @@ elseif (! empty($object->id)) } // Other attributes - $cols = 2; include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; print '
'; - + print '
'; print '
'; print '
'; print '
'; - + print ''; if (!empty($conf->multicurrency->enabled)) @@ -2013,18 +2012,18 @@ elseif (! empty($object->id)) print ''; print ''; print ''; - + // Multicurrency Amount VAT print ''; print ''; print ''; - + // Multicurrency Amount TTC print ''; print ''; print ''; } - + // Total print ''; print ''; @@ -2053,19 +2052,19 @@ elseif (! empty($object->id)) print ''; print '
' . fieldLabel('MulticurrencyAmountHT','multicurrency_total_ht') . '' . price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '
' . fieldLabel('MulticurrencyAmountVAT','multicurrency_total_tva') . '' . price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '
' . fieldLabel('MulticurrencyAmountTTC','multicurrency_total_ttc') . '' . price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '
'.$langs->trans("AmountHT").''.price($object->total_ht,'',$langs,1,-1,-1,$conf->currency).'
'; - + // Margin Infos /*if (! empty($conf->margin->enabled)) { $formmargin->displayMarginInfos($object); }*/ - - + + print '
'; print '
'; print '
'; - + print '

'; - + if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { $blocname = 'contacts'; diff --git a/htdocs/fourn/commande/orderstoinvoice.php b/htdocs/fourn/commande/orderstoinvoice.php index 32f1a5538b5..9fb9a63828d 100644 --- a/htdocs/fourn/commande/orderstoinvoice.php +++ b/htdocs/fourn/commande/orderstoinvoice.php @@ -76,9 +76,9 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extralabels=$extrafields->fetch_name_optionals_label('facture_fourn'); -if ($action == 'create') +if ($action == 'create') { - if (! is_array($selected)) + if (! is_array($selected)) { $error++; setEventMessages($langs->trans('Error_OrderNotChecked'), null, 'errors'); @@ -246,10 +246,10 @@ if (($action == 'create' || $action == 'add') && ! $error) { // End of object creation, we show it if ($id > 0 && ! $error) { - + foreach($orders_id as $fk_supplier_order) { $supplier_order = new CommandeFournisseur($db); - if ($supplier_order->fetch($fk_supplier_order)>0 && $supplier_order->statut == 5) + if ($supplier_order->fetch($fk_supplier_order)>0 && $supplier_order->statut == 5) { if ($supplier_order->classifyBilled($user) < 0) { @@ -258,20 +258,20 @@ if (($action == 'create' || $action == 'add') && ! $error) { $_GET["origin"] = $_POST["origin"]; $_GET["originid"] = $_POST["originid"]; $mesgs[] = '
' . $object->error . '
'; - + $error++; break; } - + } } - + if(!$error) { $db->commit(); header('Location: ' . DOL_URL_ROOT . '/fourn/facture/card.php?facid=' . $id); exit(); } - + } else { $db->rollback(); $action = 'create'; @@ -366,7 +366,8 @@ if ($action == 'create' && !$error) { $parameters = array ( 'objectsrc' => $objectsrc, 'idsrc' => $listoforders, - 'colspan' => ' colspan="3"' + 'colspan' => ' colspan="2"', + 'cols'=>2 ); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook @@ -494,7 +495,7 @@ if (($action != 'create' && $action != 'add') && !$error) { $companystatic->nom = $soc->nom; print '

' . $companystatic->getNomUrl(1, 'customer') . '

'; } - + print ''; print ''; print ''; @@ -517,7 +518,7 @@ if (($action != 'create' && $action != 'add') && !$error) { print ''; - + // DATE ORDER print ''; // Payment term - print ''; // Payment mode - print ''; // Bank Account - print ''; @@ -1724,7 +1724,7 @@ if ($action == 'create') { print ''; print ''; - print ''; } @@ -1735,7 +1735,7 @@ if ($action == 'create') $formproject = new FormProjets($db); $langs->load('projects'); - print ''; } @@ -1790,7 +1790,7 @@ if ($action == 'create') $langs->load('orders'); $txt=$langs->trans("SupplierOrder"); } - print ''; - print ''; - print '"; + print ''; + print '"; if ($mysoc->localtax1_assuj=="1" || $object->total_localtax1 != 0) //Localtax1 { - print '"; + print '"; } if ($mysoc->localtax2_assuj=="1" || $object->total_localtax2 != 0) //Localtax2 { - print '"; + print '"; } - print '"; + print '"; if (!empty($conf->multicurrency->enabled)) { - print ''; - print '"; - print '"; + print ''; + print '"; + print '"; } } // Other options - $parameters=array('colspan' => ' colspan="6"'); + $parameters=array(); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook // Bouton "Create Draft" @@ -2347,7 +2347,7 @@ else while ($i < $num) { $objp = $db->fetch_object($result); - + print '
'; print ''; print ''; print $period; @@ -606,9 +607,9 @@ if (($action != 'create' && $action != 'add') && !$error) { print ''; print ''; print ''; - + print ''; - + $db->free($resql); } else { print dol_print_error($db); diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 04e6ea98481..0ec657ccdfe 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -206,7 +206,7 @@ if (empty($reshook)) } $model=$object->modelpdf; $ret = $object->fetch($id); // Reload to get new records - + $result=$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result < 0) dol_print_error($db,$result); } @@ -1198,7 +1198,7 @@ if (empty($reshook)) $upload_dir = $conf->fournisseur->facture->dir_output; $permissioncreate = $user->rights->fournisseur->facture->creer; include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; - + // Make calculation according to calculationrule if ($action == 'calculate') { @@ -1674,7 +1674,7 @@ if ($action == 'create') if ($socid > 0) { // Discounts for third party - print '
' . $langs->trans('Discounts') . ''; + print '
' . $langs->trans('Discounts') . ''; if ($soc->remise_percent) print $langs->trans("CompanyHasRelativeDiscount", '' . $soc->remise_percent . ''); else @@ -1705,17 +1705,17 @@ if ($action == 'create') print '
'.$langs->trans('PaymentConditionsShort').''; + print '
'.$langs->trans('PaymentConditionsShort').''; $form->select_conditions_paiements(isset($_POST['cond_reglement_id'])?$_POST['cond_reglement_id']:$cond_reglement_id, 'cond_reglement_id'); print '
'.$langs->trans('PaymentMode').''; + print '
'.$langs->trans('PaymentMode').''; $form->select_types_paiements(isset($_POST['mode_reglement_id'])?$_POST['mode_reglement_id']:$mode_reglement_id, 'mode_reglement_id', 'DBIT'); print '
'.$langs->trans('BankAccount').''; + print '
'.$langs->trans('BankAccount').''; $form->select_comptes($fk_account, 'fk_account', 0, '', 1); print '
'.fieldLabel('Currency','multicurrency_code').''; + print ''; print $form->selectMultiCurrency($currency_code, 'multicurrency_code'); print '
' . $langs->trans('Project') . ''; + print '
' . $langs->trans('Project') . ''; $formproject->select_projects((empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS)?$societe->id:-1), $projectid, 'projectid', 0, 0, 1, 1); print '
'.$txt.''.$objectsrc->getNomUrl(1); + print '
'.$txt.''.$objectsrc->getNomUrl(1); // We check if Origin document (id and type is known) has already at least one invoice attached to it $objectsrc->fetchObjectLinked($originid,$origin,'','invoice_supplier'); $cntinvoice=count($objectsrc->linkedObjects['invoice_supplier']); @@ -1800,29 +1800,29 @@ if ($action == 'create') echo ' ('.$langs->trans('LatestRelatedBill').end($objectsrc->linkedObjects['invoice_supplier'])->getNomUrl(1).')'; } echo '
'.$langs->trans('TotalHT').''.price($objectsrc->total_ht).'
'.$langs->trans('TotalVAT').''.price($objectsrc->total_tva)."
'.$langs->trans('TotalHT').''.price($objectsrc->total_ht).'
'.$langs->trans('TotalVAT').''.price($objectsrc->total_tva)."
'.$langs->transcountry("AmountLT1",$mysoc->country_code).''.price($objectsrc->total_localtax1)."
'.$langs->transcountry("AmountLT1",$mysoc->country_code).''.price($objectsrc->total_localtax1)."
'.$langs->transcountry("AmountLT2",$mysoc->country_code).''.price($objectsrc->total_localtax2)."
'.$langs->transcountry("AmountLT2",$mysoc->country_code).''.price($objectsrc->total_localtax2)."
'.$langs->trans('TotalTTC').''.price($objectsrc->total_ttc)."
'.$langs->trans('TotalTTC').''.price($objectsrc->total_ttc)."
' . $langs->trans('MulticurrencyTotalHT') . '' . price($objectsrc->multicurrency_total_ht) . '
' . $langs->trans('MulticurrencyTotalVAT') . '' . price($objectsrc->multicurrency_total_tva) . "
' . $langs->trans('MulticurrencyTotalTTC') . '' . price($objectsrc->multicurrency_total_ttc) . "
' . $langs->trans('MulticurrencyTotalHT') . '' . price($objectsrc->multicurrency_total_ht) . '
' . $langs->trans('MulticurrencyTotalVAT') . '' . price($objectsrc->multicurrency_total_tva) . "
' . $langs->trans('MulticurrencyTotalTTC') . '' . price($objectsrc->multicurrency_total_ttc) . "
'; $paymentstatic->id=$objp->rowid; $paymentstatic->datepaye=$db->jdate($objp->dp); diff --git a/htdocs/fourn/product/list.php b/htdocs/fourn/product/list.php index 9d62747a1cb..d6af4d3b1ac 100644 --- a/htdocs/fourn/product/list.php +++ b/htdocs/fourn/product/list.php @@ -31,8 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; -$langs->load("products"); -$langs->load("suppliers"); +$langs->loadLangs(array("products","suppliers")); if (!$user->rights->produit->lire && !$user->rights->service->lire) accessforbidden(); @@ -42,40 +41,66 @@ $snom = GETPOST('snom'); $type = GETPOST('type'); $optioncss = GETPOST('optioncss','alpha'); -$sortfield = GETPOST('sortfield'); -$sortorder = GETPOST('sortorder'); -$page = GETPOST('page'); -if ($page < 0) { - $page = 0 ; -} +// Load variable for pagination +$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; +$sortfield = GETPOST('sortfield','alpha'); +$sortorder = GETPOST('sortorder','alpha'); +$page = GETPOST('page','int'); +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +$offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; +if (! $sortfield) $sortfield="p.ref"; // Set here default search field +if (! $sortorder) $sortorder="ASC"; -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; -$offset = $limit * $page ; +$fourn_id = GETPOST('fourn_id', 'intcomma'); +$catid = GETPOST('catid', 'intcomma'); -if (! $sortfield) $sortfield = 'p.ref'; -if (! $sortorder) $sortorder = 'DESC'; +// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array +$hookmanager->initHooks(array('supplierpricelist')); +$extrafields = new ExtraFields($db); -if (GETPOST('button_removefilter')) -{ - $sref = ''; - $sRefSupplier = ''; - $snom = ''; -} - -$fourn_id = GETPOST('fourn_id', 'int'); - -if (isset($_REQUEST['catid'])) -{ - $catid = $_REQUEST['catid']; -} /* -* Mode Liste -* -*/ + * ACTIONS + * + * Put here all code to do according to value of "action" parameter + */ +if (GETPOST('cancel')) { $action='list'; $massaction=''; } +if (! GETPOST('confirmmassaction') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } + +$parameters=array(); +$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +if (empty($reshook)) +{ + // Selection of new fields + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; + + // Purge search criteria + if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") ||GETPOST("button_removefilter")) // All tests are required to be compatible with all browsers + { + $sref = ''; + $sRefSupplier = ''; + $snom = ''; + $search_field1=''; + $search_field2=''; + $search_date_creation=''; + $search_date_update=''; + $toselect=''; + $search_array_options=array(); + } +} + +/* + * View + */ + +$form = new Form($db); $productstatic = new Product($db); $companystatic = new Societe($db); @@ -87,6 +112,17 @@ if ($fourn_id) $supplier->fetch($fourn_id); } + + +$arrayofmassactions = array( + 'presend'=>$langs->trans("SendByMail"), + 'builddoc'=>$langs->trans("PDFMerge"), +); +if ($user->rights->mymodule->supprimer) $arrayofmassactions['delete']=$langs->trans("Delete"); +if ($massaction == 'presend') $arrayofmassactions=array(); +$massactionbutton=$form->selectMassAction('', $arrayofmassactions); + + $sql = "SELECT p.rowid, p.label, p.ref, p.fk_product_type, p.entity,"; $sql.= " ppf.fk_soc, ppf.ref_fourn, ppf.price as price, ppf.quantity as qty, ppf.unitprice,"; $sql.= " s.rowid as socid, s.nom as name"; @@ -155,7 +191,7 @@ if ($resql) print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords); - if (isset($catid)) + if (! empty($catid)) { print "
"; $c = new Categorie($db); @@ -175,17 +211,6 @@ if ($resql) print ''; - // Lignes des titres - print ""; - print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"], "p.ref",$param,"","",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("RefSupplierShort"),$_SERVER["PHP_SELF"], "ppf.ref_fourn",$param,"","",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Label"),$_SERVER["PHP_SELF"], "p.label",$param,"","",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Supplier"),$_SERVER["PHP_SELF"], "ppf.fk_soc",$param,"","",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("BuyingPrice"),$_SERVER["PHP_SELF"], "ppf.price",$param,"",'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("QtyMin"),$_SERVER["PHP_SELF"], "ppf.quantity",$param,"",'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("UnitPrice"),$_SERVER["PHP_SELF"], "ppf.unitprice",$param,"",'align="right"',$sortfield,$sortorder); - print "\n"; - // Lignes des champs de filtre print ''; print ''; - print ''; + print ''; + print ''; + print ''; + print ''; print ''; + // Lignes des titres + print ''; + print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"], "p.ref",$param,"","",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("RefSupplierShort"),$_SERVER["PHP_SELF"], "ppf.ref_fourn",$param,"","",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Label"),$_SERVER["PHP_SELF"], "p.label",$param,"","",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Supplier"),$_SERVER["PHP_SELF"], "ppf.fk_soc",$param,"","",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("BuyingPrice"),$_SERVER["PHP_SELF"], "ppf.price",$param,"",'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("QtyMin"),$_SERVER["PHP_SELF"], "ppf.quantity",$param,"",'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("UnitPrice"),$_SERVER["PHP_SELF"], "ppf.unitprice",$param,"",'align="right"',$sortfield,$sortorder); + print_liste_field_titre('',$_SERVER["PHP_SELF"]); + print "\n"; + $oldid = ''; $var=True; while ($i < min($num,$limit)) { $objp = $db->fetch_object($resql); - + print ''; print ''; + print ''; + print "\n"; $i++; } diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 03d3c23f5cc..e6a3d3d2f0e 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -1209,7 +1209,7 @@ class Holiday extends CommonObject $sql = "SELECT u.rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; - if (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)) + if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { $sql.= ", ".MAIN_DB_PREFIX."usergroup_user as ug"; $sql.= " WHERE (ug.fk_user = u.rowid"; @@ -1305,7 +1305,7 @@ class Holiday extends CommonObject $sql = "SELECT u.rowid, u.lastname, u.firstname, u.gender, u.photo, u.employee, u.statut"; $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; - if (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)) + if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { $sql.= ", ".MAIN_DB_PREFIX."usergroup_user as ug"; $sql.= " WHERE (ug.fk_user = u.rowid"; diff --git a/htdocs/index.php b/htdocs/index.php index 5303587150e..90c014b0e99 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -1,9 +1,9 @@ - * Copyright (C) 2004-2015 Laurent Destailleur - * Copyright (C) 2005-2015 Regis Houssin - * Copyright (C) 2011-2012 Juanjo Menent - * Copyright (C) 2015 Marcos García +/* Copyright (C) 2001-2004 Rodolphe Quiedeville + * Copyright (C) 2004-2015 Laurent Destailleur + * Copyright (C) 2005-2017 Regis Houssin + * Copyright (C) 2011-2012 Juanjo Menent + * Copyright (C) 2015 Marcos García * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -165,7 +165,7 @@ if (empty($user->societe_id)) DOL_DOCUMENT_ROOT."/contact/class/contact.class.php", DOL_DOCUMENT_ROOT."/adherents/class/adherent.class.php", DOL_DOCUMENT_ROOT."/product/class/product.class.php", - DOL_DOCUMENT_ROOT."/product/class/service.class.php", + DOL_DOCUMENT_ROOT."/product/class/product.class.php", DOL_DOCUMENT_ROOT."/comm/propal/class/propal.class.php", DOL_DOCUMENT_ROOT."/commande/class/commande.class.php", DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php", diff --git a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql index 317fb6b7ff2..85b9d3106cf 100644 --- a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql +++ b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql @@ -380,4 +380,18 @@ create table llx_loan_schedule fk_user_modif integer )ENGINE=innodb; -ALTER TABLE llx_tva ADD COLUMN datec date AFTER tms; \ No newline at end of file +ALTER TABLE llx_tva ADD COLUMN datec date AFTER tms; + +ALTER TABLE llx_user_rights ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER rowid; +ALTER TABLE llx_user_rights DROP FOREIGN KEY fk_user_rights_fk_user_user; +ALTER TABLE llx_user_rights DROP INDEX uk_user_rights; +ALTER TABLE llx_user_rights DROP INDEX fk_user; +ALTER TABLE llx_user_rights ADD UNIQUE INDEX uk_user_rights (entity, fk_user, fk_id); +ALTER TABLE llx_user_rights ADD CONSTRAINT fk_user_rights_fk_user_user FOREIGN KEY (fk_user) REFERENCES llx_user (rowid); + +ALTER TABLE llx_usergroup_rights ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER rowid; +ALTER TABLE llx_usergroup_rights DROP FOREIGN KEY fk_usergroup_rights_fk_usergroup; +ALTER TABLE llx_usergroup_rights DROP INDEX fk_usergroup; +ALTER TABLE llx_usergroup_rights ADD UNIQUE INDEX uk_usergroup_rights (entity, fk_usergroup, fk_id); +ALTER TABLE llx_usergroup_rights ADD CONSTRAINT fk_usergroup_rights_fk_usergroup FOREIGN KEY (fk_usergroup) REFERENCES llx_usergroup (rowid); + diff --git a/htdocs/install/mysql/tables/llx_user_rights.key.sql b/htdocs/install/mysql/tables/llx_user_rights.key.sql index 6e87568e247..8fae1c1a160 100644 --- a/htdocs/install/mysql/tables/llx_user_rights.key.sql +++ b/htdocs/install/mysql/tables/llx_user_rights.key.sql @@ -1,6 +1,7 @@ -- ============================================================================ --- Copyright (C) 2003 Rodolphe Quiedeville --- Copyright (C) 2005 Laurent Destailleur +-- Copyright (C) 2003 Rodolphe Quiedeville +-- Copyright (C) 2005 Laurent Destailleur +-- Copyright (C) 2017 Regis Houssin -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by @@ -21,7 +22,6 @@ -- Delete orphans -- V4 DELETE llx_user_rights FROM llx_user_rights LEFT JOIN llx_user ON llx_user_rights.fk_user = llx_user.rowid WHERE llx_user.rowid IS NULL; +ALTER TABLE llx_user_rights ADD UNIQUE INDEX uk_user_rights (entity, fk_user, fk_id); ALTER TABLE llx_user_rights ADD CONSTRAINT fk_user_rights_fk_user_user FOREIGN KEY (fk_user) REFERENCES llx_user (rowid); - -ALTER TABLE llx_user_rights ADD UNIQUE INDEX uk_user_rights (fk_user, fk_id); diff --git a/htdocs/install/mysql/tables/llx_user_rights.sql b/htdocs/install/mysql/tables/llx_user_rights.sql index bd4c0afc242..cedfa8a00c9 100644 --- a/htdocs/install/mysql/tables/llx_user_rights.sql +++ b/htdocs/install/mysql/tables/llx_user_rights.sql @@ -1,5 +1,6 @@ -- ============================================================================ --- Copyright (C) 2003 Rodolphe Quiedeville +-- Copyright (C) 2003 Rodolphe Quiedeville +-- Copyright (C) 2017 Regis Houssin -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by @@ -18,8 +19,9 @@ create table llx_user_rights ( - rowid integer AUTO_INCREMENT PRIMARY KEY, - fk_user integer NOT NULL, - fk_id integer NOT NULL + rowid integer AUTO_INCREMENT PRIMARY KEY, + entity integer DEFAULT 1 NOT NULL, -- multi company id + fk_user integer NOT NULL, + fk_id integer NOT NULL )ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_usergroup_rights.key.sql b/htdocs/install/mysql/tables/llx_usergroup_rights.key.sql index 119ce8982b5..f08a6f62637 100644 --- a/htdocs/install/mysql/tables/llx_usergroup_rights.key.sql +++ b/htdocs/install/mysql/tables/llx_usergroup_rights.key.sql @@ -1,5 +1,6 @@ -- ============================================================================ --- Copyright (C) 2005 Laurent Destailleur +-- Copyright (C) 2005 Laurent Destailleur +-- Copyright (C) 2017 Regis Houssin -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by @@ -20,5 +21,6 @@ -- Supprime orhpelins pour permettre montee de la cle -- V4 DELETE llx_usergroup_rights FROM llx_usergroup_rights LEFT JOIN llx_usergroup ON llx_usergroup_rights.fk_usergroup = llx_usergroup.rowid WHERE llx_usergroup.rowid IS NULL; +ALTER TABLE llx_usergroup_rights ADD UNIQUE INDEX uk_usergroup_rights (entity, fk_usergroup, fk_id); ALTER TABLE llx_usergroup_rights ADD CONSTRAINT fk_usergroup_rights_fk_usergroup FOREIGN KEY (fk_usergroup) REFERENCES llx_usergroup (rowid); diff --git a/htdocs/install/mysql/tables/llx_usergroup_rights.sql b/htdocs/install/mysql/tables/llx_usergroup_rights.sql index 850648edea4..e8a3af37e7c 100644 --- a/htdocs/install/mysql/tables/llx_usergroup_rights.sql +++ b/htdocs/install/mysql/tables/llx_usergroup_rights.sql @@ -1,5 +1,6 @@ -- ============================================================================ --- Copyright (C) 2005 Laurent Destailleur +-- Copyright (C) 2005 Laurent Destailleur +-- Copyright (C) 2017 Regis Houssin -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by @@ -18,10 +19,10 @@ create table llx_usergroup_rights ( - rowid integer AUTO_INCREMENT PRIMARY KEY, - fk_usergroup integer NOT NULL, - fk_id integer NOT NULL, + rowid integer AUTO_INCREMENT PRIMARY KEY, + entity integer DEFAULT 1 NOT NULL, -- multi company id + fk_usergroup integer NOT NULL, + fk_id integer NOT NULL - UNIQUE(fk_usergroup,fk_id) )ENGINE=innodb; diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index e2d18947310..24aa86a4788 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -136,6 +136,7 @@ if (! GETPOST('action','aZ09') || preg_match('/upgrade/i',GETPOST('action','aZ09 // Create the global $hookmanager object include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; $hookmanager=new HookManager($db); + $hookmanager->initHooks(array('upgrade')); if (!$db->connected) { @@ -493,9 +494,13 @@ if (! GETPOST('action','aZ09') || preg_match('/upgrade/i',GETPOST('action','aZ09 } else { - print ''; + //if (! empty($conf->modules)) + if (! empty($conf->modules_parts['hooks'])) // If there is at least one module with one hook, we show message to say nothing was done + { + print ''; + } } } diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index fe292db145d..03af3ddfe88 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -390,7 +390,7 @@ ExtrafieldCheckBox=Checkboxes ExtrafieldCheckBoxFromList=Checkboxes from table ExtrafieldLink=Link to an object ComputedFormula=Computed field -ComputedFormulaDesc=You can enter here a formula using other properties of object or any PHP coding to get a dynamic computed value. You can use any PHP compatible formulas including the "?" condition operator, and following global object: $db, $conf, $langs, $mysoc, $user, $object.
WARNING: Only some properties of $object may be available. If you need a properties not loaded, just fetch yourself the object into your formula like in the second example.
Using a computed field means you can't enter yourself any value from interface. Also, if there is a syntax error, the formula may return nothing.

Example of formula:
$object->id < 5 ? round($object->id / 2, 2) : ($object->id + 2*$user->id) * (int) substr($mysoc->zip, 1, 2)

Example of formula to force load of object and its parent object:
(($reloadedobj = new Task($db)) && ($reloadedobj->fetch($object->id) > 0) && ($secondloadedobj = new Project($db)) && ($secondloadedobj->fetch($reloadedobj->fk_project) > 0)) ? $secondloadedobj->ref : 'Parent project not found'

Other example to reload object
(($reloadedobj = new Societe($db)) && ($reloadedobj->fetch($obj->id ? $obj->id : ($obj->rowid ? $obj->rowid : $object->id)) > 0)) ? round($reloadedobj->capital / 5) : '-1' +ComputedFormulaDesc=You can enter here a formula using other properties of object or any PHP coding to get a dynamic computed value. You can use any PHP compatible formulas including the "?" condition operator, and following global object: $db, $conf, $langs, $mysoc, $user, $object.
WARNING: Only some properties of $object may be available. If you need a properties not loaded, just fetch yourself the object into your formula like in the second example.
Using a computed field means you can't enter yourself any value from interface. Also, if there is a syntax error, the formula may return nothing.

Example of formula:
$object->id < 10 ? round($object->id / 2, 2) : ($object->id + 2 * $user->id) * (int) substr($mysoc->zip, 1, 2)

Example to reload object
(($reloadedobj = new Societe($db)) && ($reloadedobj->fetch($obj->id ? $obj->id : ($obj->rowid ? $obj->rowid : $object->id)) > 0)) ? $reloadedobj->array_options['options_extrafieldkey'] * $reloadedobj->capital / 5 : '-1'

Other example of formula to force load of object and its parent object:
(($reloadedobj = new Task($db)) && ($reloadedobj->fetch($object->id) > 0) && ($secondloadedobj = new Project($db)) && ($secondloadedobj->fetch($reloadedobj->fk_project) > 0)) ? $secondloadedobj->ref : 'Parent project not found' ExtrafieldParamHelpselect=Parameters list have to be like key,value

for example :
1,value1
2,value2
3,value3
...

In order to have the list depending on another complementary attribute list :
1,value1|options_parent_list_code:parent_key
2,value2|options_parent_list_code:parent_key

In order to have the list depending on another list :
1,value1|parent_list_code:parent_key
2,value2|parent_list_code:parent_key ExtrafieldParamHelpcheckbox=Parameters list have to be like key,value

for example :
1,value1
2,value2
3,value3
... ExtrafieldParamHelpradio=Parameters list have to be like key,value

for example :
1,value1
2,value2
3,value3
... diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 91e00c274ff..8ea14fdb305 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -726,7 +726,7 @@ ViewPrivateNote=View notes XMoreLines=%s line(s) hidden PublicUrl=Public URL AddBox=Add box -SelectElementAndClickRefresh=Select an element and click Refresh +SelectElementAndClick=Select an element and click %s PrintFile=Print File %s ShowTransaction=Show entry on bank account GoIntoSetupToChangeLogo=Go into Home - Setup - Company to change logo or go into Home - Setup - Display to hide. diff --git a/htdocs/langs/en_US/withdrawals.lang b/htdocs/langs/en_US/withdrawals.lang index 1eb906f1acc..8e80a111516 100644 --- a/htdocs/langs/en_US/withdrawals.lang +++ b/htdocs/langs/en_US/withdrawals.lang @@ -17,7 +17,7 @@ NbOfInvoiceToWithdrawWithInfo=Nb. of customer invoice with direct debit payment InvoiceWaitingWithdraw=Invoice waiting for direct debit AmountToWithdraw=Amount to withdraw WithdrawsRefused=Direct debit refused -NoInvoiceToWithdraw=No customer invoice in payment mode "withdraw" is waiting. Go on 'Withdraw' tab on invoice card to make a request. +NoInvoiceToWithdraw=No customer invoice with open 'Direct debit requests' is waiting. Go on tab '%s' on invoice card to make a request. ResponsibleUser=Responsible user WithdrawalsSetup=Direct debit payment setup WithdrawStatistics=Direct debit payment statistics diff --git a/htdocs/master.inc.php b/htdocs/master.inc.php index 90a4cb70611..ecb1c46478f 100644 --- a/htdocs/master.inc.php +++ b/htdocs/master.inc.php @@ -1,14 +1,14 @@ - * Copyright (C) 2003 Xavier Dutoit - * Copyright (C) 2004-2012 Laurent Destailleur - * Copyright (C) 2004 Sebastien Di Cintio - * Copyright (C) 2004 Benoit Mortier - * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2005 Simon Tosser - * Copyright (C) 2006 Andre Cianfarani - * Copyright (C) 2010 Juanjo Menent - * Copyright (C) 2011 Philippe Grand +/* Copyright (C) 2002-2007 Rodolphe Quiedeville + * Copyright (C) 2003 Xavier Dutoit + * Copyright (C) 2004-2012 Laurent Destailleur + * Copyright (C) 2004 Sebastien Di Cintio + * Copyright (C) 2004 Benoit Mortier + * Copyright (C) 2005-2017 Regis Houssin + * Copyright (C) 2005 Simon Tosser + * Copyright (C) 2006 Andre Cianfarani + * Copyright (C) 2010 Juanjo Menent + * Copyright (C) 2011 Philippe Grand * Copyright (C) 2014 Teddy Andreotti <125155@supinfo.com> * * This program is free software; you can redistribute it and/or modify @@ -98,11 +98,6 @@ if (! empty($dolibarr_main_document_root_alt)) } } -// Set properties specific to multicompany -// TODO Multicompany Remove this. Useless. Var should be read when required. -$conf->multicompany->transverse_mode = empty($multicompany_transverse_mode)?'':$multicompany_transverse_mode; // Force Multi-Company transverse mode -$conf->multicompany->force_entity = empty($multicompany_force_entity)?'':(int) $multicompany_force_entity; // Force entity in login page - // Chargement des includes principaux de librairies communes if (! defined('NOREQUIREUSER')) require_once DOL_DOCUMENT_ROOT .'/user/class/user.class.php'; // Need 500ko memory if (! defined('NOREQUIRETRAN')) require_once DOL_DOCUMENT_ROOT .'/core/class/translate.class.php'; @@ -170,10 +165,6 @@ if (! defined('NOREQUIREDB')) { $conf->entity = $_COOKIE['DOLENTITY']; } - else if (! empty($conf->multicompany->force_entity) && is_numeric($conf->multicompany->force_entity)) // To force entity in login page - { - $conf->entity = $conf->multicompany->force_entity; - } // Sanitize entity if (! is_numeric($conf->entity)) $conf->entity=1; diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index b35519826d3..f2d4daee8d4 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -53,7 +53,7 @@ class MyModuleObject extends CommonObject * @var array Array with all fields and their property */ public $fields; - + /** * @var mixed Sample property 1 */ @@ -62,11 +62,11 @@ class MyModuleObject extends CommonObject * @var mixed Sample property 2 */ public $prop2; - + //... - + protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe - + public $table_element_line = 'mymoduleobjectdet'; public $class_element_line = 'MyModuleObjectline'; public $fk_element = 'fk_mymoduleobject'; @@ -75,9 +75,9 @@ class MyModuleObject extends CommonObject * @var MyModuleObjectLine[] Lines */ public $lines = array(); - - - + + + /** * Constructor * @@ -163,10 +163,9 @@ class MyModuleObject extends CommonObject /** * Load object in memory from the database * - * @param int $id Id object - * @param string $ref Ref - * - * @return int <0 if KO, 0 if not found, >0 if OK + * @param int $id Id object + * @param string $ref Ref + * @return int <0 if KO, 0 if not found, >0 if OK */ public function fetch($id, $ref = null) { @@ -199,20 +198,13 @@ class MyModuleObject extends CommonObject $this->prop2 = $obj->field2; //... } - - // Retrieve all extrafields for invoice - // fetch optionals attributes and labels - /* - require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; - $extrafields=new ExtraFields($this->db); - $extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true); - $this->fetch_optionals($this->id,$extralabels); - */ - - // $this->fetch_lines(); - + $this->db->free($resql); + $this->fetch_optionals(); + + // $this->fetch_lines(); + if ($numrows) { return 1; } else { @@ -221,7 +213,6 @@ class MyModuleObject extends CommonObject } else { $this->errors[] = 'Error ' . $this->db->lasterror(); dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR); - return - 1; } } @@ -306,7 +297,7 @@ class MyModuleObject extends CommonObject dol_syslog(__METHOD__, LOG_DEBUG); $error = 0; - + // Clean parameters if (isset($this->prop1)) { $this->prop1 = trim($this->prop1); @@ -386,7 +377,7 @@ class MyModuleObject extends CommonObject } // If you need to delete child tables to, you can insert them here - + if (!$error) { $sql = 'DELETE FROM ' . MAIN_DB_PREFIX . $this->table_element; $sql .= ' WHERE rowid=' . $this->id; @@ -475,7 +466,7 @@ class MyModuleObject extends CommonObject global $menumanager; if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips - + $result = ''; $companylink = ''; @@ -484,7 +475,7 @@ class MyModuleObject extends CommonObject $label.= '' . $langs->trans('Ref') . ': ' . $this->ref; $url = DOL_URL_ROOT.'/mymodule/'.$this->table_name.'_card.php?id='.$this->id; - + $linkclose=''; if (empty($notooltip)) { @@ -497,7 +488,7 @@ class MyModuleObject extends CommonObject $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; } else $linkclose = ($morecss?' class="'.$morecss.'"':''); - + $linkstart = ''; $linkend=''; diff --git a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php index 5799d5bbab7..9e8f5ca9975 100644 --- a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php +++ b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php @@ -69,7 +69,7 @@ class modMyModule extends DolibarrModules $this->descriptionlong = "MyModuleDescription (Long)"; $this->editor_name = 'Editor name'; $this->editor_url = 'https://www.example.com'; - + // Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z' $this->version = '1.0'; // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) @@ -151,7 +151,7 @@ class modMyModule extends DolibarrModules $conf->mymodule=new stdClass(); $conf->mymodule->enabled=0; } - + // Dictionaries $this->dictionaries=array(); /* Example: @@ -169,8 +169,9 @@ class modMyModule extends DolibarrModules ); */ + // Boxes - // Add here list of php file(s) stored in core/boxes that contains class to show a box. + // Add here list of php file(s) stored in core/boxes that contains class to show a widget. $this->boxes = array(); // List of boxes // Example: //$this->boxes=array( @@ -179,24 +180,38 @@ class modMyModule extends DolibarrModules // 2=>array('file'=>'myboxc.php@mymodule','note'=>'') //); + // Cronjobs $this->cronjobs = array(); // List of cron jobs entries to add // Example: $this->cronjobs=array(0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'/dir/class/file.class.php', 'objectname'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'test'=>true), // 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24, 'test'=>true) // ); + // Permissions $this->rights = array(); // Permission array used by this module - $r=0; - // Add here list of permission defined by an id, a label, a boolean and two constant strings. - // Example: - // $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) - // $this->rights[$r][1] = 'Permision label'; // Permission label - // $this->rights[$r][3] = 1; // Permission by default for new user (0/1) - // $this->rights[$r][4] = 'level1'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) - // $this->rights[$r][5] = 'level2'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) - // $r++; + $r=0; + $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) + $this->rights[$r][1] = 'Read objects of My Module'; // Permission label + $this->rights[$r][3] = 1; // Permission by default for new user (0/1) + $this->rights[$r][4] = 'read'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) + $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) + + $r++; + $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) + $this->rights[$r][1] = 'Create/Update objects of My Module'; // Permission label + $this->rights[$r][3] = 1; // Permission by default for new user (0/1) + $this->rights[$r][4] = 'create'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) + $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) + + $r++; + $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) + $this->rights[$r][1] = 'Delete objects of My Module'; // Permission label + $this->rights[$r][3] = 1; // Permission by default for new user (0/1) + $this->rights[$r][4] = 'delete'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) + $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) + // Main menu entries $this->menu = array(); // List of menus to add diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php index 1d22c464212..56e0ea1d3ed 100644 --- a/htdocs/modulebuilder/template/myobject_card.php +++ b/htdocs/modulebuilder/template/myobject_card.php @@ -96,18 +96,18 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (empty($reshook)) { - if ($cancel) + if ($cancel) { if ($action != 'addlink') { $urltogo=$backtopage?$backtopage:dol_buildpath('/mymodule/list.php',1); header("Location: ".$urltogo); exit; - } + } if ($id > 0 || ! empty($ref)) $ret = $object->fetch($id,$ref); $action=''; } - + // Action to add record if ($action == 'add' && ! empty($user->rights->mymodule->create)) { @@ -268,19 +268,19 @@ if ($action == 'create') if (($id || $ref) && $action == 'edit') { print load_fiche_titre($langs->trans("MyModule")); - + print '
'; print ''; print ''; print ''; - + dol_fiche_head(); print '
'; @@ -197,19 +222,34 @@ if ($resql) print ''; print ''; print ''; - print ''; - print '  '; - print ''; + print ''; + $searchpicto=$form->showFilterButtons(); + print $searchpicto; print '
'; @@ -236,6 +276,8 @@ if ($resql) print ''.(isset($objp->unitprice) ? price($objp->unitprice) : '').'
'; - print ''.$langs->trans('UpgradeExternalModule').': '.$langs->trans("None"); - print '
'; + print ''.$langs->trans('UpgradeExternalModule').': '.$langs->trans("None"); + print '
'."\n"; // print ''; // LIST_OF_TD_LABEL_FIELDS_EDIT print '
'.$langs->trans("Label").'
'; - + dol_fiche_end(); print '
'; @@ -299,14 +299,14 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $head = mymodule_prepare_head($object); dol_fiche_head($head, 'order', $langs->trans("CustomerOrder"), -1, 'order'); - + $formconfirm = ''; - + // Confirmation to delete if ($action == 'delete') { $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteOrder'), $langs->trans('ConfirmDeleteOrder'), 'confirm_delete', '', 0, 1); } - + // Confirmation of action xxxx if ($action == 'xxx') { @@ -317,28 +317,28 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), // array('type' => 'other', 'name' => 'idwarehouse', 'label' => $langs->trans("SelectWarehouseForStockDecrease"), 'value' => $formproduct->selectWarehouses(GETPOST('idwarehouse')?GETPOST('idwarehouse'):'ifone', 'idwarehouse', '', 1))); - }*/ + }*/ $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('XXX'), $text, 'confirm_xxx', $formquestion, 0, 1, 220); } - + if (! $formconfirm) { $parameters = array('lineid' => $lineid); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint; } - + // Print form confirm print $formconfirm; - - - + + + // Object card // ------------------------------------------------------------ - + $linkback = '' . $langs->trans("BackToList") . ''; - - + + $morehtmlref='
'; /* // Ref bis @@ -382,11 +382,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } */ $morehtmlref.='
'; - - + + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); - - + + print '
'; print '
'; print '
'; @@ -396,7 +396,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Other attributes - $cols = 2; include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; print '
'; @@ -405,16 +404,16 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '
'; print '
'; print ''; - - + + print '
'; print '
'; print '
'; print '
'; - + print '

'; - + dol_fiche_end(); @@ -424,14 +423,14 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $parameters=array(); $reshook=$hookmanager->executeHooks('addMoreActionsButtons',$parameters,$object,$action); // Note that $action and $object may have been modified by hook if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - + if (empty($reshook)) { if ($user->rights->mymodule->write) { print ''."\n"; } - + if ($user->rights->mymodule->delete) { print ''."\n"; @@ -440,12 +439,12 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '
'."\n"; } - + // Select mail models is same action as presend if (GETPOST('modelselected')) { $action = 'presend'; } - + if ($action != 'presend') { print '
'; @@ -458,23 +457,23 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $genallowed = $user->rights->mymodule->creer; $delallowed = $user->rights->mymodule->supprimer; print $formfile->showdocuments('mymodule', $comref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang); - - + + // Show links to link elements $linktoelem = $form->showLinkToObjectBlock($object, null, array('order')); $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); - - + + print '
'; - + // List of actions on element include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; $formactions = new FormActions($db); $somethingshown = $formactions->showactions($object, 'order', $socid); - + print '
'; } - + /* * Action presend diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index 86de7b337c3..baca7249a51 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -35,7 +35,7 @@ //if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); //if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) -// Change this following line to use the correct relative path (../, ../../, etc) +// Change this following lines to use the correct relative path (../, ../../, etc) $res=0; if (! $res && file_exists("../main.inc.php")) $res=@include '../main.inc.php'; // to work if your module directory is into dolibarr root htdocs directory if (! $res && file_exists("../../main.inc.php")) $res=@include '../../main.inc.php'; // to work if your module directory is into a subdir of root htdocs directory @@ -49,8 +49,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; dol_include_once('/mymodule/class/myobject.class.php'); // Load traductions files requiredby by page -$langs->load("mymodule"); -$langs->load("other"); +$langs->loadLangs(array("mymodule","other")); $action=GETPOST('action','alpha'); $massaction=GETPOST('massaction','alpha'); @@ -89,14 +88,14 @@ if ($user->societe_id > 0) } // Initialize technical object to manage context to save list fields -$contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'mymodulelist'; +$contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'myobjectlist'; // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array -$hookmanager->initHooks(array('mymodulelist')); +$hookmanager->initHooks(array('myobjectlist')); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels -$extralabels = $extrafields->fetch_name_optionals_label('mymodule'); +$extralabels = $extrafields->fetch_name_optionals_label('myobject'); $search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); // List of fields to search into when doing a "search in all" @@ -110,7 +109,7 @@ if (empty($user->socid)) $fieldstosearchall["t.note_private"]="NotePrivate"; $arrayfields=array( 't.field1'=>array('label'=>"Field1", 'checked'=>1), 't.field2'=>array('label'=>"Field2", 'checked'=>1), - //'t.entity'=>array('label'=>"Entity", 'checked'=>1, 'enabled'=>(! empty($conf->multicompany->enabled) && empty($conf->multicompany->transverse_mode))), + //'t.entity'=>array('label'=>"Entity", 'checked'=>1, 'enabled'=>(! empty($conf->multicompany->enabled) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))), 't.datec'=>array('label'=>"DateCreationShort", 'checked'=>0, 'position'=>500), 't.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500), //'t.statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000), @@ -227,7 +226,7 @@ foreach ($search_array_options as $key => $val) $typ=$extrafields->attribute_type[$tmpkey]; $mode=0; if (in_array($typ, array('int','double'))) $mode=1; // Search on a numeric - if ($val && ( ($crit != '' && ! in_array($typ, array('select'))) || ! empty($crit))) + if ($val && ( ($crit != '' && ! in_array($typ, array('select'))) || ! empty($crit))) { $sql .= natural_search('ef.'.$tmpkey, $crit, $mode); } @@ -244,7 +243,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); -} +} $sql.= $db->plimit($limit+1, $offset); @@ -263,7 +262,7 @@ if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && { $obj = $db->fetch_object($resql); $id = $obj->rowid; - header("Location: ".DOL_URL_ROOT.'/skeleton/card.php?id='.$id); + header("Location: ".DOL_URL_ROOT.'/mymodule/myobject_card.php?id='.$id); exit; } @@ -283,13 +282,13 @@ foreach ($search_array_options as $key => $val) $crit=$val; $tmpkey=preg_replace('/search_options_/','',$key); if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); -} +} $arrayofmassactions = array( 'presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge"), ); -if ($user->rights->mymodule->supprimer) $arrayofmassactions['delete']=$langs->trans("Delete"); +if ($user->rights->mymodule->delete) $arrayofmassactions['delete']=$langs->trans("Delete"); if ($massaction == 'presend') $arrayofmassactions=array(); $massactionbutton=$form->selectMassAction('', $arrayofmassactions); @@ -330,38 +329,11 @@ if (! empty($moreforfilter)) $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); print '
'; print ''."\n"; -// Fields title -print ''; -// LIST_OF_TD_TITLE_FIELDS -//if (! empty($arrayfields['t.field1']['checked'])) print_liste_field_titre($arrayfields['t.field1']['label'],$_SERVER['PHP_SELF'],'t.field1','',$param,'',$sortfield,$sortorder); -//if (! empty($arrayfields['t.field2']['checked'])) print_liste_field_titre($arrayfields['t.field2']['label'],$_SERVER['PHP_SELF'],'t.field2','',$param,'',$sortfield,$sortorder); -// Extra fields -if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) -{ - foreach($extrafields->attribute_label as $key => $val) - { - if (! empty($arrayfields["ef.".$key]['checked'])) - { - $align=$extrafields->getAlignFlag($key); - $sortonfield = "ef.".$key; - if (! empty($extrafields->attribute_computed[$key])) $sortonfield=''; - print_liste_field_titre($langs->trans($extralabels[$key]),$_SERVER["PHP_SELF"],$sortonfield,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder); - } - } -} -// Hook fields -$parameters=array('arrayfields'=>$arrayfields); -$reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook -print $hookmanager->resPrint; -if (! empty($arrayfields['t.datec']['checked'])) print_liste_field_titre($arrayfields['t.datec']['label'],$_SERVER["PHP_SELF"],"t.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); -if (! empty($arrayfields['t.tms']['checked'])) print_liste_field_titre($arrayfields['t.tms']['label'],$_SERVER["PHP_SELF"],"t.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); -//if (! empty($arrayfields['t.status']['checked'])) print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"t.status","",$param,'align="center"',$sortfield,$sortorder); -print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch '); -print ''."\n"; // Fields title search print ''; @@ -371,22 +343,22 @@ print ''; // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { - foreach($extrafields->attribute_label as $key => $val) + foreach($extrafields->attribute_label as $key => $val) { if (! empty($arrayfields["ef.".$key]['checked'])) { $align=$extrafields->getAlignFlag($key); $typeofextrafield=$extrafields->attribute_type[$key]; print ''; } } @@ -408,19 +380,48 @@ if (! empty($arrayfields['t.tms']['checked'])) print ''; } /*if (! empty($arrayfields['u.statut']['checked'])) -{ - // Status - print ''; -}*/ + { + // Status + print ''; + }*/ // Action column print ''; print ''."\n"; - + +// Fields title +print ''; +// LIST_OF_TD_TITLE_FIELDS +//if (! empty($arrayfields['t.field1']['checked'])) print_liste_field_titre($arrayfields['t.field1']['label'],$_SERVER['PHP_SELF'],'t.field1','',$param,'',$sortfield,$sortorder); +//if (! empty($arrayfields['t.field2']['checked'])) print_liste_field_titre($arrayfields['t.field2']['label'],$_SERVER['PHP_SELF'],'t.field2','',$param,'',$sortfield,$sortorder); +// Extra fields +if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) +{ + foreach($extrafields->attribute_label as $key => $val) + { + if (! empty($arrayfields["ef.".$key]['checked'])) + { + $align=$extrafields->getAlignFlag($key); + $sortonfield = "ef.".$key; + if (! empty($extrafields->attribute_computed[$key])) $sortonfield=''; + print_liste_field_titre($langs->trans($extralabels[$key]),$_SERVER["PHP_SELF"],$sortonfield,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder); + } + } +} +// Hook fields +$parameters=array('arrayfields'=>$arrayfields); +$reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; +if (! empty($arrayfields['t.datec']['checked'])) print_liste_field_titre($arrayfields['t.datec']['label'],$_SERVER["PHP_SELF"],"t.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); +if (! empty($arrayfields['t.tms']['checked'])) print_liste_field_titre($arrayfields['t.tms']['label'],$_SERVER["PHP_SELF"],"t.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); +//if (! empty($arrayfields['t.status']['checked'])) print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"t.status","",$param,'align="center"',$sortfield,$sortorder); +print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch '); +print ''."\n"; + // Detect if we need a fetch on each output line $needToFetchEachLine=0; @@ -441,12 +442,12 @@ while ($i < min($num, $limit)) print ''; // LIST_OF_TD_FIELDS_LIST /* - if (! empty($arrayfields['t.field1']['checked'])) + if (! empty($arrayfields['t.field1']['checked'])) { print ''; if (! $i) $totalarray['nbfield']++; } - if (! empty($arrayfields['t.field2']['checked'])) + if (! empty($arrayfields['t.field2']['checked'])) { print ''; if (! $i) $totalarray['nbfield']++; @@ -454,9 +455,9 @@ while ($i < min($num, $limit)) // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { - foreach($extrafields->attribute_label as $key => $val) + foreach($extrafields->attribute_label as $key => $val) { - if (! empty($arrayfields["ef.".$key]['checked'])) + if (! empty($arrayfields["ef.".$key]['checked'])) { print 'getAlignFlag($key); diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 5c6690b44f2..02ad2f5172c 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -145,9 +145,9 @@ if (empty($reshook)) $upload_dir = $conf->produit->dir_output; $permissioncreate = $user->rights->produit->creer; include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; - + include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; - + // Barcode type if ($action == 'setfk_barcode_type' && $createbarcode) { @@ -203,7 +203,7 @@ if (empty($reshook)) $action = "create"; $error++; } - + if (! $error) { $units = GETPOST('units', 'int'); @@ -630,7 +630,7 @@ if (empty($reshook)) $tmpvat = price2num(preg_replace('/\s*\(.*\)/', '', $tva_tx)); $tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx)); - + // On reevalue prix selon taux tva car taux tva transaction peut etre different // de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur). if ($tmpvat != $tmpprodvat) { @@ -640,7 +640,7 @@ if (empty($reshook)) $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU'); } } - + if (GETPOST('propalid') > 0) { // Define cost price for margin calculation $buyprice=0; @@ -653,7 +653,7 @@ if (empty($reshook)) { $buyprice = $result; } - + $result = $propal->addline( $desc, $pu_ht, @@ -696,7 +696,7 @@ if (empty($reshook)) { $buyprice = $result; } - + $result = $commande->addline( $desc, $pu_ht, @@ -882,7 +882,7 @@ else dol_fiche_head(''); print '
'; - if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select')) && empty($extrafields->attribute_computed[$key])) - { - $crit=$val; - $tmpkey=preg_replace('/search_options_/','',$key); - $searchclass=''; - if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; - if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; - print ''; - } + if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select')) && empty($extrafields->attribute_computed[$key])) + { + $crit=$val; + $tmpkey=preg_replace('/search_options_/','',$key); + $searchclass=''; + if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; + if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; + print ''; + } print ''; - print $form->selectarray('search_statut', array('-1'=>'','0'=>$langs->trans('Disabled'),'1'=>$langs->trans('Enabled')),$search_statut); - print ''; + print $form->selectarray('search_statut', array('-1'=>'','0'=>$langs->trans('Disabled'),'1'=>$langs->trans('Enabled')),$search_statut); + print ''; -$searchpicto=$form->showFilterAndCheckAddButtons($massactionbutton?1:0, 'checkforselect', 1); +$searchpicto=$form->showFilterButtons(); print $searchpicto; print '
'.$obj->field1.''.$obj->field2.'
'; - + print ''; $tmpcode=''; if (! empty($modCodeProduct->code_auto)) $tmpcode=$modCodeProduct->getNextValue($object,$type); @@ -1045,7 +1045,7 @@ else } // Other attributes - $parameters=array('colspan' => 3); + $parameters=array('cols' => 3); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook if (empty($reshook) && ! empty($extrafields->attribute_label)) { @@ -1056,14 +1056,14 @@ else //if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB)) available in create mode //{ print '"; //} - + if($conf->categorie->enabled) { // Categories print ''; } - else // For external software + else // For external software { // Accountancy_code_sell print ''; @@ -1364,7 +1364,7 @@ else } // Other attributes - $parameters=array('colspan' => ' colspan="2"'); + $parameters=array('colspan' => ' colspan="3"', 'cols'=>3); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook if (empty($reshook) && ! empty($extrafields->attribute_label)) { @@ -1372,7 +1372,7 @@ else } // Tags-Categories - if ($conf->categorie->enabled) + if ($conf->categorie->enabled) { print '"; } - + print '
'.$langs->trans("NoteNotVisibleOnBill").''; - + // We use dolibarr_details as type of DolEditor here, because we must not accept images as description is included into PDF and not accepted by TCPDF. $doleditor = new DolEditor('note_private', GETPOST('note_private'), '', 140, 'dolibarr_details', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_8, '90%'); $doleditor->Create(); - + print "
'.$langs->trans("Categories").''; @@ -1123,7 +1123,7 @@ else print $formaccounting->select_account(GETPOST('accountancy_code_buy'), 'accountancy_code_buy', 1, null, 1, 1, ''); print '
'.$langs->trans("ProductAccountancySellCode").'
'.$langs->trans("Categories").''; $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, '', 'parent', 64, 0, 1); @@ -1389,13 +1389,13 @@ else if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB)) { print '
'.$langs->trans("NoteNotVisibleOnBill").''; - + $doleditor = new DolEditor('note_private', $object->note_private, '', 140, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_4, '90%'); $doleditor->Create(); - + print "
'; print '
'; @@ -1416,7 +1416,7 @@ else print $formaccounting->select_account($object->accountancy_code_buy, 'accountancy_code_buy', 1, '', 1, 1); print ''; } - else // For external software + else // For external software { // Accountancy_code_sell print ''.$langs->trans("ProductAccountancySellCode").''; @@ -1449,21 +1449,21 @@ else $head=product_prepare_head($object); $titre=$langs->trans("CardProduct".$object->type); $picto=($object->type== Product::TYPE_SERVICE?'service':'product'); - + dol_fiche_head($head, 'card', $titre, -1, $picto); $linkback = ''.$langs->trans("BackToList").''; $object->next_prev_filter=" fk_product_type = ".$object->type; dol_banner_tab($object, 'ref', $linkback, ($user->societe_id?0:1), 'ref'); - - + + print '
'; print '
'; - + print '
'; print ''; - + // Type if (! empty($conf->produit->enabled) && ! empty($conf->service->enabled)) { @@ -1577,7 +1577,7 @@ else } print ''; */ - + // Batch number management (to batch) if (! empty($conf->productbatch->enabled)) { print '
'.$langs->trans("ManageLotSerial").''; @@ -1616,10 +1616,10 @@ else print '
'; print '
'; print '
'; - + print '
'; print ''; - + // Nature if($object->type!= Product::TYPE_SERVICE) { @@ -1727,11 +1727,7 @@ else // Other attributes $parameters=array('colspan' => ' colspan="'.(2+(($showphoto||$showbarcode)?1:0)).'"'); - $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook - if (empty($reshook) && ! empty($extrafields->attribute_label)) - { - print $object->showOptionals($extrafields); - } + include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; // Categories if($conf->categorie->enabled) { @@ -1747,13 +1743,13 @@ else print ''."\n"; print ' '."\n"; } - + print "
'.$langs->trans("NotePrivate").''.(dol_textishtml($object->note_private)?$object->note_private:dol_nl2br($object->note_private,1,true)).'
\n"; print '
'; - + print '
'; print '
'; - + dol_fiche_end(); } @@ -1814,16 +1810,16 @@ if (($action == 'clone' && (empty($conf->use_javascript_ajax) || ! empty($conf-> if ($action != 'create' && $action != 'edit') { print "\n".'
'."\n"; - + $parameters=array(); $reshook=$hookmanager->executeHooks('addMoreActionsButtons',$parameters,$object,$action); // Note that $action and $object may have been modified by hook if (empty($reshook)) { - if (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->creer ) || + if (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->creer ) || ($object->type == Product::TYPE_SERVICE && $user->rights->service->creer)) { if (! isset($object->no_button_edit) || $object->no_button_edit <> 1) print ''; - + if (! isset($object->no_button_copy) || $object->no_button_copy <> 1) { if (! empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile)) @@ -1837,7 +1833,7 @@ if ($action != 'create' && $action != 'edit') } } $object_is_used = $object->isObjectUsed($object->id); - + if (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->supprimer) || ($object->type == Product::TYPE_SERVICE && $user->rights->service->supprimer)) { @@ -1862,7 +1858,7 @@ if ($action != 'create' && $action != 'edit') print ''; } } - + print "\n
\n"; } @@ -1957,7 +1953,7 @@ if (! empty($conf->global->PRODUCT_ADD_FORM_ADD_TO) && $object->id && ($action = print ''; print load_fiche_titre($langs->trans("AddToDraft"),'',''); - + dol_fiche_head(''); $html .= ''.$langs->trans("Quantity").' '; @@ -1969,7 +1965,7 @@ if (! empty($conf->global->PRODUCT_ADD_FORM_ADD_TO) && $object->id && ($action = print ''; print $html; print '
'; - + print '
'; print ''; print '
'; @@ -2000,7 +1996,7 @@ if ($action != 'create' && $action != 'edit' && $action != 'delete') print $formfile->showdocuments($modulepart,$object->ref,$filedir,$urlsource,$genallowed,$delallowed,'',0,0,0,28,0,'',0,'',$object->default_lang, '', $object); $somethingshown=$formfile->numoffiles; - + print '
'; print '
'; diff --git a/htdocs/product/document.php b/htdocs/product/document.php index d0b58c9909c..2cf2f36b419 100644 --- a/htdocs/product/document.php +++ b/htdocs/product/document.php @@ -72,7 +72,7 @@ if ($id > 0 || ! empty($ref)) if (! empty($conf->product->enabled)) $upload_dir = $conf->product->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 0, $object, 'product').dol_sanitizeFileName($object->ref); elseif (! empty($conf->service->enabled)) $upload_dir = $conf->service->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 0, $object, 'product').dol_sanitizeFileName($object->ref); - + if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) // For backward compatiblity, we scan also old dirs { if (! empty($conf->product->enabled)) $upload_dirold = $conf->product->multidir_output[$object->entity].'/'.substr(substr("000".$object->id, -2),1,1).'/'.substr(substr("000".$object->id, -2),0,1).'/'.$object->id."/photos"; @@ -188,12 +188,13 @@ if ($object->id) $head=product_prepare_head($object); $titre=$langs->trans("CardProduct".$object->type); $picto=($object->type== Product::TYPE_SERVICE?'service':'product'); - + dol_fiche_head($head, 'documents', $titre, -1, $picto); + $parameters=array(); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - + // Construit liste des fichiers $filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1); @@ -213,9 +214,9 @@ if ($object->id) $linkback = ''.$langs->trans("BackToList").''; $object->next_prev_filter=" fk_product_type = ".$object->type; dol_banner_tab($object, 'ref', $linkback, ($user->societe_id?0:1), 'ref'); - + print '
'; - + print '
'; print ''; @@ -225,14 +226,14 @@ if ($object->id) print ''; print '
'; - + dol_fiche_end(); $permission = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->creer) || ($object->type == Product::TYPE_SERVICE && $user->rights->service->creer)); $param = '&id=' . $object->id; include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php'; - + // Merge propal PDF document PDF files if (!empty($conf->global->PRODUIT_PDF_MERGE_PROPAL)) { @@ -308,17 +309,17 @@ if ($object->id) $checked = ''; $filename = $filetoadd['name']; - if ($conf->global->MAIN_MULTILANGS) + if ($conf->global->MAIN_MULTILANGS) { - if (array_key_exists($filetoadd['name'] . '_' . $delauft_lang, $filetomerge->lines)) + if (array_key_exists($filetoadd['name'] . '_' . $delauft_lang, $filetomerge->lines)) { $filename = $filetoadd['name'] . ' - ' . $langs->trans('Language_' . $delauft_lang); $checked = ' checked '; } } - else + else { - if (array_key_exists($filetoadd['name'], $filetomerge->lines)) + if (array_key_exists($filetoadd['name'], $filetomerge->lines)) { $checked = ' checked '; } diff --git a/htdocs/product/inventory/listview.class.php b/htdocs/product/inventory/listview.class.php index 1c03d0b524f..ac5ec68f51a 100644 --- a/htdocs/product/inventory/listview.class.php +++ b/htdocs/product/inventory/listview.class.php @@ -41,6 +41,11 @@ class Listview $this->totalRow=0; $this->TField=array(); + + require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; + $this->extrafields = new ExtraFields($this->db); + $this->extralabels = $this->extrafields->fetch_name_optionals_label('product'); + $this->search_array_options=$this->extrafields->getOptionalsFromPost($this->extralabels,'','search_'); } /** @@ -808,6 +813,9 @@ class Listview } else { + // Overrive search from extrafields + // for the type as 'checkbox', 'chkbxlst', 'sellist' we should use code instead of id (example: I declare a 'chkbxlst' to have a link with dictionnairy, I have to extend it with the 'code' instead 'rowid') + if (isset($this->extralabels[$field])) $TParam['search'][$field] = $this->extrafields->showInputField($field, $this->search_array_options['search_options_'.$field], '', '', 'search_'); $visible = 1; } diff --git a/htdocs/product/list-with-listview.php b/htdocs/product/list-with-listview.php index 46bf98cd1e8..61f6233f32e 100644 --- a/htdocs/product/list-with-listview.php +++ b/htdocs/product/list-with-listview.php @@ -611,7 +611,7 @@ else } //var_dump($arraytitle,$arrayhide); - $list=new Listview($db, 'products'); + $list=new Listview($db, 'product'); $listHTML = $list->render($sql,array( 'list'=>array( 'title'=>$texte diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index 3ad426eda8c..81942468ab3 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -111,10 +111,10 @@ $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if ($action == 'addlimitstockwarehouse') { - + $seuil_stock_alerte = GETPOST('seuil_stock_alerte'); $desiredstock = GETPOST('desiredstock'); - + $maj_ok = true; if($seuil_stock_alerte == '') { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("StockLimit")), null, 'errors'); @@ -124,44 +124,44 @@ if ($action == 'addlimitstockwarehouse') { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DesiredStock")), null, 'errors'); $maj_ok = false; } - + if($maj_ok) { - + $pse = new ProductStockEntrepot($db); if($pse->fetch('', GETPOST('id'), GETPOST('fk_entrepot')) > 0) { - + // Update $pse->seuil_stock_alerte = $seuil_stock_alerte; $pse->desiredstock = $desiredstock; if($pse->update($user) > 0) setEventMessage($langs->trans('ProductStockWarehouseUpdated')); - + } else { - + // Create $pse->fk_entrepot = GETPOST('fk_entrepot'); $pse->fk_product = GETPOST('id'); $pse->seuil_stock_alerte = GETPOST('seuil_stock_alerte'); $pse->desiredstock = GETPOST('desiredstock'); if($pse->create($user) > 0) setEventMessage($langs->trans('ProductStockWarehouseCreated')); - + } - + } header("Location: ".$_SERVER["PHP_SELF"]."?id=".GETPOST('id')); exit; - + } if($action == 'delete_productstockwarehouse') { - + $pse = new ProductStockEntrepot($db); $pse->fetch(GETPOST('fk_productstockwarehouse')); if($pse->delete($user) > 0) setEventMessage($langs->trans('ProductStockWarehouseDeleted')); - + $action = ''; - + } // Set stock limit @@ -233,7 +233,7 @@ if ($action == "correct_stock" && ! $cancel) $origin_element = 'project'; $origin_id = GETPOST('projectid', 'int'); } - + if (empty($object)) { $object = new Product($db); $result=$object->fetch($id); @@ -317,7 +317,7 @@ if ($action == "transfert_stock" && ! $cancel) { $object = new Product($db); $result=$object->fetch($id); - + if ($object->hasbatch() && ! $batchnumber) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("batch_number")), null, 'errors'); @@ -325,7 +325,7 @@ if ($action == "transfert_stock" && ! $cancel) $action='transfert'; } } - + if (! $error) { if ($id) @@ -341,7 +341,7 @@ if ($action == "transfert_stock" && ! $cancel) $pricesrc=0; if (isset($object->pmp)) $pricesrc=$object->pmp; $pricedest=$pricesrc; - + if ($object->hasbatch()) { $pdluo = new Productbatch($db); @@ -514,7 +514,7 @@ if ($id > 0 || $ref) { $object = new Product($db); $result = $object->fetch($id,$ref); - + $object->load_stock(); $title = $langs->trans('ProductServiceCard'); @@ -538,21 +538,21 @@ if ($id > 0 || $ref) $head=product_prepare_head($object); $titre=$langs->trans("CardProduct".$object->type); $picto=($object->type==Product::TYPE_SERVICE?'service':'product'); - + dol_fiche_head($head, 'stock', $titre, -1, $picto); dol_htmloutput_events(); $linkback = ''.$langs->trans("BackToList").''; - + dol_banner_tab($object, 'ref', $linkback, ($user->societe_id?0:1), 'ref'); - + print '
'; - + print '
'; print '
'; - - if ($conf->productbatch->enabled) + + if ($conf->productbatch->enabled) { print ''; - + // Hook formObject - $parameters=array('colspan' => 3); + $parameters=array('cols'=>2); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook - + // Desired stock print ''; $stocktheo = price2num($object->stock_theorique, 'MS'); - + $found=0; $helpondiff=''.$langs->trans("StockDiffPhysicTeoric").':
'; // Number of customer orders running @@ -655,7 +655,7 @@ if ($id > 0 || $ref) if ($result < 0) dol_print_error($db,$object->error); $helpondiff.=' ('.$langs->trans("ProductQtyInDraft").': '.$object->stats_commande['qty'].')'; } - + // Number of product from customer order already sent (partial shipping) if (! empty($conf->expedition->enabled)) { @@ -663,7 +663,7 @@ if ($id > 0 || $ref) $result=$object->load_stats_sending(0,'2'); $helpondiff.=$langs->trans("ProductQtyInShipmentAlreadySent").': '.$object->stats_expedition['qty']; } - + // Number of supplier order running if (! empty($conf->fournisseur->enabled)) { @@ -674,14 +674,14 @@ if ($id > 0 || $ref) if ($result < 0) dol_print_error($db,$object->error); $helpondiff.=' ('.$langs->trans("ProductQtyInDraftOrWaitingApproved").': '.$object->stats_commande_fournisseur['qty'].')'; } - + // Number of product from supplier order already received (partial receipt) if (! empty($conf->fournisseur->enabled)) { if ($found) $helpondiff.='
'; else $found=1; $helpondiff.=$langs->trans("ProductQtyInSuppliersShipmentAlreadyRecevied").': '.$object->stats_reception['qty']; } - + // Calculating a theorical value print ''; print ''; print ''; print ''; - + // Skype if (! empty($conf->skype->enabled)) { @@ -1215,7 +1230,7 @@ else print ''; - + } elseif($mysoc->localtax1_assuj=="1") { @@ -1229,7 +1244,7 @@ else print $form->selectyesno('localtax2assuj_value',(isset($conf->global->THIRDPARTY_DEFAULT_USELOCALTAX2)?$conf->global->THIRDPARTY_DEFAULT_USELOCALTAX2:0),1); print ''; } - + // Type - Size print ''; - + if($object->localtax1_assuj=="1" && (! isOnlyOneLocalTax(1))) { print ''; @@ -2145,7 +2160,7 @@ else print ''; } print ''; - + } } elseif($mysoc->localtax2_assuj=="1" && $mysoc->localtax1_assuj!="1") @@ -2155,7 +2170,7 @@ else print ''; if($object->localtax2_assuj=="1" && (! isOnlyOneLocalTax(2))) { - + print ''; print ''; print ''; @@ -2168,7 +2183,7 @@ else print ''; } print ''; - + } } /* @@ -2179,7 +2194,7 @@ else print ''; } */ - + // VAT Code print ''; print ''; } - // Other attributes - $parameters=array('socid'=>$socid, 'colspan' => ' colspan="3"', 'colspanvalue' => '3'); - $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - if (empty($reshook) && ! empty($extrafields->attribute_label)) - { - print $object->showOptionals($extrafields); - } + // Other attributes + $parameters=array('socid'=>$socid, 'colspan' => ' colspan="3"', 'colspanvalue' => '3'); + include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; // Parent company if (empty($conf->global->SOCIETE_DISABLE_PARENTCOMPANY)) @@ -2574,10 +2584,10 @@ else // Subsidiaries list if (empty($conf->global->SOCIETE_DISABLE_SUBSIDIARIES)) - { + { $result=show_subsidiaries($conf,$langs,$db,$object); } - + // Contacts list if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) { diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 2610ea7071f..8069f59c372 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1062,7 +1062,6 @@ class Societe extends CommonObject else if ($idprof6) $sql .= " WHERE s.idprof6 = '".$this->db->escape($idprof6)."' AND s.entity IN (".getEntity($this->element, 1).")"; $resql=$this->db->query($sql); - dol_syslog(get_class($this)."::fetch ".$sql); if ($resql) { $num=$this->db->num_rows($resql); @@ -1196,11 +1195,7 @@ class Societe extends CommonObject $result = 1; // Retreive all extrafield for thirdparty - // fetch optionals attributes and labels - require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'); - $extrafields=new ExtraFields($this->db); - $extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true); - $this->fetch_optionals($this->id,$extralabels); + $this->fetch_optionals(); } else { @@ -1695,7 +1690,7 @@ class Societe extends CommonObject $sql = "SELECT DISTINCT u.rowid, u.login, u.lastname, u.firstname, u.email, u.statut, u.entity, u.photo"; $sql.= " FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc, ".MAIN_DB_PREFIX."user as u"; - if (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)) + if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { $sql.= ", ".MAIN_DB_PREFIX."usergroup_user as ug"; $sql.= " WHERE ((ug.fk_user = sc.fk_user"; @@ -1843,16 +1838,16 @@ class Societe extends CommonObject && ($conf->global->SOCIETE_ADD_REF_IN_LIST == 1 || $conf->global->SOCIETE_ADD_REF_IN_LIST == 2 ) - ) + ) $code = $this->code_client . ' - '; if (($this->fournisseur) && (! empty ( $this->code_fournisseur )) && ($conf->global->SOCIETE_ADD_REF_IN_LIST == 1 || $conf->global->SOCIETE_ADD_REF_IN_LIST == 3 ) - ) + ) $code .= $this->code_fournisseur . ' - '; - + if ($conf->global->SOCIETE_ADD_REF_IN_LIST == 1) $name =$code.' '.$name; else @@ -1870,7 +1865,7 @@ class Societe extends CommonObject $label.= Form::showphoto('societe', $this, 80, 0, 0, 'photowithmargin', 'mini'); $label.= '
'; } - + $label.= '
'; if ($option == 'customer' || $option == 'compta' || $option == 'category' || $option == 'category_supplier') @@ -1903,7 +1898,7 @@ class Societe extends CommonObject $label.= '' . $langs->trans("ShowMargin") . ''; $linkstart = 'id; @@ -3376,7 +3371,7 @@ class Societe extends CommonObject else return array(); } - + /** * Return amount of order not paid and total * @@ -3387,7 +3382,7 @@ class Societe extends CommonObject { $table='commande'; if ($mode == 'supplier') $table = 'commande_fournisseur'; - + $sql = "SELECT rowid, total_ht, total_ttc, fk_statut FROM ".MAIN_DB_PREFIX.$table." as f"; $sql .= " WHERE fk_soc = ". $this->id; @@ -3411,7 +3406,7 @@ class Societe extends CommonObject else return array(); } - + /** * Return amount of bill not paid and total * @@ -3422,7 +3417,7 @@ class Societe extends CommonObject { $table='facture'; if ($mode == 'supplier') $table = 'facture_fourn'; - + /* Accurate value of remain to pay is to sum remaintopay for each invoice $paiement = $invoice->getSommePaiement(); $creditnotes=$invoice->getSumCreditNotesUsed(); @@ -3455,7 +3450,7 @@ class Societe extends CommonObject $tmpobject->id=$obj->rowid; if ($obj->fk_statut != 0 // Not a draft && ! ($obj->fk_statut == 3 && $obj->close_code == 'replaced') // Not a replaced invoice - ) + ) { $outstandingTotal+= $obj->total_ht; $outstandingTotalIncTax+= $obj->total_ttc; @@ -3474,12 +3469,12 @@ class Societe extends CommonObject } return array('opened'=>$outstandingOpened, 'total_ht'=>$outstandingTotal, 'total_ttc'=>$outstandingTotalIncTax); } - else + else { return array(); } } - + /** * Return amount of bill not paid * @@ -3502,7 +3497,7 @@ class Societe extends CommonObject //$sql .= " AND (fk_statut <> 3 OR close_code <> 'abandon')"; // Not abandonned for undefined reason $sql .= " AND fk_statut <> 3"; // Not abandonned $sql .= " AND fk_statut <> 2"; // Not clasified as paid - + dol_syslog("get_OutstandingBill", LOG_DEBUG); $resql=$this->db->query($sql); if ($resql) @@ -3522,7 +3517,7 @@ class Societe extends CommonObject else return 0; } - + /** * Return label of status customer is prospect/customer * @@ -3592,9 +3587,9 @@ class Societe extends CommonObject return 0; } } - + $modelpath = "core/modules/societe/doc/"; - + $result=$this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); } @@ -3615,7 +3610,7 @@ class Societe extends CommonObject public function setCategories($categories, $type) { require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; - + // Decode type if ($type == 'customer') { $type_id = Categorie::TYPE_CUSTOMER; diff --git a/htdocs/societe/commerciaux.php b/htdocs/societe/commerciaux.php index 89bb836d119..da9b7c4a8f3 100644 --- a/htdocs/societe/commerciaux.php +++ b/htdocs/societe/commerciaux.php @@ -115,9 +115,9 @@ if (! empty($socid)) dol_fiche_head($head, 'salesrepresentative', $langs->trans("ThirdParty"), -1, 'company'); $linkback = ''.$langs->trans("BackToList").''; - + dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom'); - + print '
'; print '
'; @@ -142,13 +142,13 @@ if (! empty($socid)) $sql = "SELECT DISTINCT u.rowid, u.login, u.fk_soc, u.lastname, u.firstname, u.statut, u.entity, u.photo"; $sql .= " FROM ".MAIN_DB_PREFIX."user as u"; $sql .= " , ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - if (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)) + if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { $sql.= ", ".MAIN_DB_PREFIX."usergroup_user as ug"; } $sql .= " WHERE sc.fk_soc =".$object->id; $sql .= " AND sc.fk_user = u.rowid"; - if (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)) + if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { $sql.= " AND ((ug.fk_user = sc.fk_user"; $sql.= " AND ug.entity = ".$conf->entity.")"; @@ -167,17 +167,14 @@ if (! empty($socid)) $i = 0; $tmpuser = new User($db); - + while ($i < $num) { $obj = $db->fetch_object($resql); $parameters=array('socid'=>$object->id); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$obj,$action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) { - - null; // actions in normal case - } + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); $tmpuser->id = $obj->rowid; $tmpuser->firstname = $obj->firstname; @@ -188,7 +185,7 @@ if (! empty($socid)) $tmpuser->societe_id = $obj->fk_soc; $tmpuser->photo = $obj->photo; print $tmpuser->getNomUrl(-1); - + /*print ''; print img_object($langs->trans("ShowUser"),"user").' '; print dolGetFirstLastname($obj->firstname, $obj->lastname)."\n"; @@ -216,7 +213,7 @@ if (! empty($socid)) print '
'.$langs->trans("ManageLotSerial").''; print $object->getLibStatut(0,2); @@ -614,11 +614,11 @@ if ($id > 0 || $ref) print '
'.$form->editfieldkey("StockLimit",'seuil_stock_alerte',$object->seuil_stock_alerte,$object,$user->rights->produit->creer).''; print $form->editfieldval("StockLimit",'seuil_stock_alerte',$object->seuil_stock_alerte,$object,$user->rights->produit->creer,'string'); print '
'.$form->editfieldkey($form->textwithpicto($langs->trans("DesiredStock"), $langs->trans("DesiredStockDesc"), 1),'desiredstock',$object->desiredstock,$object,$user->rights->produit->creer); print ''; @@ -643,7 +643,7 @@ if ($id > 0 || $ref) print '
'; print $form->textwithpicto($langs->trans("VirtualStock"), $langs->trans("VirtualStockDesc")); @@ -723,7 +723,7 @@ if ($id > 0 || $ref) print ''; print '
'; - + dol_fiche_end(); } @@ -762,18 +762,18 @@ if (empty($reshook)) if (empty($action) && $object->id) { print "
\n"; - + if ($user->rights->stock->mouvement->creer) { print ''.$langs->trans("StockCorrection").''; } - + //if (($user->rights->stock->mouvement->creer) && ! $object->hasbatch()) if ($user->rights->stock->mouvement->creer) { print ''.$langs->trans("StockTransfer").''; } - + print '
'; } @@ -897,7 +897,7 @@ if ($resql) } } $i++; - + } } else dol_print_error($db); @@ -929,25 +929,25 @@ if (!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE)) print '

'; print_titre($langs->trans('AddNewProductStockWarehouse')); //print '
'; - + print ''; print ''; print ''; print ''; - + print ''; print ''; print ''; print ''; print ''; - + $pse = new ProductStockEntrepot($db); $lines = $pse->fetchAll(GETPOST('id')); - - if (!empty($lines)) + + if (!empty($lines)) { $var=false; - foreach($lines as $line) + foreach($lines as $line) { $ent = new Entrepot($db); $ent->fetch($line['fk_entrepot']); @@ -956,12 +956,12 @@ if (!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE)) print ''; print ''; print ''; - + } } - + print "
'.$formproduct->selectWarehouses('', 'fk_entrepot').'
'.$line['desiredstock'].''.img_delete().'
"; - + print ''; } diff --git a/htdocs/product/stock/productlot_list.php b/htdocs/product/stock/productlot_list.php index 35f9e582874..de245b9b04a 100644 --- a/htdocs/product/stock/productlot_list.php +++ b/htdocs/product/stock/productlot_list.php @@ -102,7 +102,7 @@ $arrayfields=array( 't.eatby'=>array('label'=>$langs->trans("EatByDate"), 'checked'=>1), 't.sellby'=>array('label'=>$langs->trans("SellByDate"), 'checked'=>1), //'t.import_key'=>array('label'=>$langs->trans("ImportKey"), 'checked'=>1), - //'t.entity'=>array('label'=>$langs->trans("Entity"), 'checked'=>1, 'enabled'=>(! empty($conf->multicompany->enabled) && empty($conf->multicompany->transverse_mode))), + //'t.entity'=>array('label'=>$langs->trans("Entity"), 'checked'=>1, 'enabled'=>(! empty($conf->multicompany->enabled) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))), //'t.fk_user_creat'=>array('label'=>$langs->trans("UserCreationShort"), 'checked'=>0, 'position'=>500), //'t.fk_user_modif'=>array('label'=>$langs->trans("UserModificationShort"), 'checked'=>0, 'position'=>500), 't.datec'=>array('label'=>$langs->trans("DateCreationShort"), 'checked'=>0, 'position'=>500), diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index f3078f0e3e7..6a53be25c54 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -39,7 +39,7 @@ class Project extends CommonObject public $fk_element = 'fk_projet'; protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe public $picto = 'projectpub'; - + /** * {@inheritdoc} */ @@ -102,7 +102,7 @@ class Project extends CommonObject * @var Task[] */ public $lines; - + /** * Constructor @@ -146,7 +146,7 @@ class Project extends CommonObject dol_syslog(get_class($this)."::create error -1 ref null", LOG_ERR); return -1; } - + $this->db->begin(); $sql = "INSERT INTO " . MAIN_DB_PREFIX . "projet ("; @@ -261,7 +261,7 @@ class Project extends CommonObject dol_syslog(get_class($this)."::update error -3 " . $this->error, LOG_ERR); return -3; } - + if (dol_strlen(trim($this->ref)) > 0) { $this->db->begin(); @@ -392,7 +392,9 @@ class Project extends CommonObject $resql = $this->db->query($sql); if ($resql) { - if ($this->db->num_rows($resql)) + $num_rows = $this->db->num_rows($resql); + + if ($num_rows) { $obj = $this->db->fetch_object($resql); @@ -423,12 +425,16 @@ class Project extends CommonObject $this->db->free($resql); + // Retreive all extrafield for thirdparty + $this->fetch_optionals(); + return 1; } - else - { - return 0; - } + + $this->db->free($resql); + + if ($num_rows) return 1; + else return 0; } else { @@ -745,7 +751,7 @@ class Project extends CommonObject $this->error=$langs->trans("ErrorFieldFormat",$langs->transnoentities("Label")).'. '.$langs->trans('RemoveString',$langs->transnoentitiesnoconv("CopyOf")); return -1; } - + $this->db->begin(); $sql = "UPDATE " . MAIN_DB_PREFIX . "projet"; @@ -764,7 +770,7 @@ class Project extends CommonObject if ($result < 0) { $error++; } // End call triggers } - + if (!$error) { $this->statut=1; @@ -847,7 +853,7 @@ class Project extends CommonObject return -1; } } - + return 0; } @@ -936,9 +942,9 @@ class Project extends CommonObject global $conf, $langs, $user; if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips - + $result = ''; - + $label=''; if ($option != 'nolink') $label = '' . $langs->trans("ShowProject") . ''; $label .= ($label?'
':'').'' . $langs->trans('Ref') . ': ' . $this->ref; // The space must be after the : to not being explode when showing the title in img_picto @@ -965,11 +971,11 @@ class Project extends CommonObject $url = DOL_URL_ROOT . '/projet/card.php?id=' . $this->id; } // Add param to save lastsearch_values or not - $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); + $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; } - + $linkclose=''; if (empty($notooltip) && $user->rights->propal->lire) { @@ -988,7 +994,7 @@ class Project extends CommonObject $linkstart = ''; $linkend=''; - + if ($withpicto) $result.=($linkstart . img_object(($notooltip?'':$label), $picto, ($notooltip?'':'class="classfortooltip"'), 0, 0, $notooltip?0:1) . $linkend); if ($withpicto && $withpicto != 2) $result.=' '; if ($withpicto != 2) $result.=$linkstart . $this->ref . $linkend . (($addlabel && $this->title) ? $sep . dol_trunc($this->title, ($addlabel > 1 ? $addlabel : 0)) : ''); @@ -1150,7 +1156,7 @@ class Project extends CommonObject { // No filter. Use this if user has permission to see all project } - + $sql.= $filter; //print $sql; @@ -1760,7 +1766,7 @@ class Project extends CommonObject $sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; $sql.= " WHERE"; $sql.= " p.entity IN (".getEntity('projet').")"; - if (! $user->rights->projet->all->lire) + if (! $user->rights->projet->all->lire) { $projectsListId = $this->getProjectsAuthorizedForUser($user,0,1); $sql .= "AND p.rowid IN (".$projectsListId.")"; @@ -1800,7 +1806,7 @@ class Project extends CommonObject $now = dol_now(); return ($this->datee ? $this->datee : $this->date_end) < ($now - $conf->projet->warning_delay); - } + } /** @@ -1911,10 +1917,10 @@ class Project extends CommonObject return 1; } - + /** * Create an array of tasks of current project - * + * * @param User $user Object user we want project allowed to * @return int >0 if OK, <0 if KO */ @@ -1925,6 +1931,6 @@ class Project extends CommonObject $this->lines = $taskstatic->getTasksArray(0, $user, $this->id, 0, 0); } - + } diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index 227ea68d41b..17d1b5fcf45 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -36,7 +36,7 @@ class Task extends CommonObject public $fk_element='fk_task'; public $picto = 'task'; protected $childtables=array('projet_task_time'); // To test if we can delete object - + var $fk_task_parent; var $label; var $description; @@ -59,7 +59,7 @@ class Task extends CommonObject var $timespent_nblinesnull; var $timespent_nblines; // For detail of lines of timespent record, there is the property ->lines in common - + // Var used to call method addTimeSpent(). Bad practice. var $timespent_id; var $timespent_duration; @@ -100,7 +100,7 @@ class Task extends CommonObject // Clean parameters $this->label = trim($this->label); $this->description = trim($this->description); - + // Check parameters // Put here code to add control on parameters values @@ -226,7 +226,7 @@ class Task extends CommonObject if ($resql) { $num_rows = $this->db->num_rows($resql); - + if ($num_rows) { $obj = $this->db->fetch_object($resql); @@ -250,6 +250,9 @@ class Task extends CommonObject $this->note_private = $obj->note_private; $this->note_public = $obj->note_public; $this->rang = $obj->rang; + + // Retreive all extrafield for thirdparty + $this->fetch_optionals(); } $this->db->free($resql); @@ -409,7 +412,7 @@ class Task extends CommonObject $this->db->rollback(); return 0; } - + if (! $error) { // Delete linked contacts @@ -534,7 +537,7 @@ class Task extends CommonObject return -1; } } - + /** * Return nb of time spent * @@ -579,14 +582,15 @@ class Task extends CommonObject * @param int $addlabel 0=Default, 1=Add label into string, >1=Add first chars into string * @param string $sep Separator between ref and label if option addlabel is set * @param int $notooltip 1=Disable tooltip + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @return string Chaine avec URL */ - function getNomUrl($withpicto=0,$option='',$mode='task', $addlabel=0, $sep=' - ', $notooltip=0) + function getNomUrl($withpicto=0,$option='',$mode='task', $addlabel=0, $sep=' - ', $notooltip=0, $save_lastsearch_value=-1) { global $conf, $langs, $user; if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips - + $result=''; $label = '' . $langs->trans("ShowTask") . ''; if (! empty($this->ref)) @@ -597,8 +601,12 @@ class Task extends CommonObject { $label .= "
".get_date_range($this->date_start,$this->date_end,'',$langs,0); } - + $url = DOL_URL_ROOT.'/projet/tasks/'.$mode.'.php?id='.$this->id.($option=='withproject'?'&withproject=1':''); + // Add param to save lastsearch_values or not + $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; + if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; $linkclose = ''; if (empty($notooltip)) @@ -611,11 +619,11 @@ class Task extends CommonObject $linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"'; $linkclose.=' class="classfortooltip"'; } - + $linkstart = ''; $linkend=''; - + $picto='projecttask'; if ($withpicto) $result.=($linkstart.img_object(($notooltip?'':$label), $picto, ($notooltip?'':'class="classfortooltip"'), 0, 0, $notooltip?0:1).$linkend); @@ -706,7 +714,7 @@ class Task extends CommonObject $sql.= ", ".MAIN_DB_PREFIX."element_contact as ec2"; $sql.= ", ".MAIN_DB_PREFIX."c_type_contact as ctc2"; } - else + else { $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t on t.fk_projet = p.rowid"; } @@ -790,7 +798,7 @@ class Task extends CommonObject $tasks[$i]->date_start = $this->db->jdate($obj->date_start); $tasks[$i]->date_end = $this->db->jdate($obj->date_end); $tasks[$i]->rang = $obj->rang; - + $tasks[$i]->thirdparty_id = $obj->thirdparty_id; $tasks[$i]->thirdparty_name = $obj->thirdparty_name; } @@ -963,7 +971,7 @@ class Task extends CommonObject $tasktime_id = $this->db->last_insert_id(MAIN_DB_PREFIX."projet_task_time"); $ret = $tasktime_id; $this->timespent_id = $ret; - + if (! $notrigger) { // Call trigger @@ -1027,10 +1035,10 @@ class Task extends CommonObject global $langs; $id=$this->id; - if (empty($id)) + if (empty($id)) { dol_syslog("getSummaryOfTimeSpent called on a not loaded task", LOG_ERR); - return -1; + return -1; } $result=array(); @@ -1045,7 +1053,7 @@ class Task extends CommonObject $sql.= " FROM ".MAIN_DB_PREFIX."projet_task_time as t"; $sql.= " WHERE t.fk_task = ".$id; if ($userid > 0) $sql.=" AND t.fk_user = ".$userid; - + dol_syslog(get_class($this)."::getSummaryOfTimeSpent", LOG_DEBUG); $resql=$this->db->query($sql); if ($resql) @@ -1055,14 +1063,14 @@ class Task extends CommonObject $result['min_date'] = $obj->min_date; // deprecated. use the ->timespent_xxx instead $result['max_date'] = $obj->max_date; // deprecated. use the ->timespent_xxx instead $result['total_duration'] = $obj->total_duration; // deprecated. use the ->timespent_xxx instead - + $this->timespent_min_date=$this->db->jdate($obj->min_date); $this->timespent_max_date=$this->db->jdate($obj->max_date); $this->timespent_total_duration=$obj->total_duration; $this->timespent_total_amount=$obj->total_amount; $this->timespent_nblinesnull=($obj->nblinesnull?$obj->nblinesnull:0); $this->timespent_nblines=($obj->nblines?$obj->nblines:0); - + $this->db->free($resql); } else @@ -1357,7 +1365,7 @@ class Task extends CommonObject $clone_task->fetch($fromid); $clone_task->fetch_optionals(); //var_dump($clone_task->array_options);exit; - + $origin_task->fetch($fromid); $defaultref=''; @@ -1680,7 +1688,7 @@ class Task extends CommonObject return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref); } - + /** * Load indicators for dashboard (this->nbtodo and this->nbtodolate) * @@ -1690,12 +1698,12 @@ class Task extends CommonObject function load_board($user) { global $conf, $langs; - + $mine=0; $socid=$user->societe_id; - + $projectstatic = new Project($this->db); $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,$mine,1,$socid); - + // List of tasks (does not care about permissions. Filtering will be done later) $sql = "SELECT p.rowid as projectid, p.fk_statut as projectstatus,"; $sql.= " t.rowid as taskid, t.progress as progress, t.fk_statut as status,"; @@ -1718,29 +1726,29 @@ class Task extends CommonObject if ($resql) { $task_static = new Task($this->db); - + $response = new WorkboardResponse(); $response->warning_delay = $conf->projet->task->warning_delay/60/60/24; $response->label = $langs->trans("OpenedTasks"); if ($user->rights->projet->all->lire) $response->url = DOL_URL_ROOT.'/projet/tasks/list.php?mainmenu=project'; else $response->url = DOL_URL_ROOT.'/projet/tasks/list.php?mode=mine&mainmenu=project'; $response->img = img_object('',"task"); - + // This assignment in condition is not a bug. It allows walking the results. while ($obj=$this->db->fetch_object($resql)) { $response->nbtodo++; - + $task_static->projectstatus = $obj->projectstatus; $task_static->progress = $obj->progress; $task_static->fk_statut = $obj->status; $task_static->date_end = $this->db->jdate($obj->datee); - + if ($task_static->hasDelay()) { $response->nbtodolate++; } } - + return $response; } else @@ -1749,7 +1757,7 @@ class Task extends CommonObject return -1; } } - + /** * Is the task delayed? * @@ -1758,7 +1766,7 @@ class Task extends CommonObject public function hasDelay() { global $conf; - + if (! ($this->progress >= 0 && $this->progress < 100)) { return false; } @@ -1768,5 +1776,5 @@ class Task extends CommonObject $datetouse = ($this->date_end > 0) ? $this->date_end : ($this->datee > 0 ? $this->datee : 0); return ($datetouse > 0 && ($datetouse < ($now - $conf->projet->task->warning_delay))); - } + } } diff --git a/htdocs/projet/tasks/contact.php b/htdocs/projet/tasks/contact.php index 9160f2b3795..d4029847534 100644 --- a/htdocs/projet/tasks/contact.php +++ b/htdocs/projet/tasks/contact.php @@ -174,7 +174,7 @@ if ($id > 0 || ! empty($ref)) if ($object->fetch($id, $ref) > 0) { $id = $object->id; // So when doing a search from ref, id is also set correctly. - + $result=$projectstatic->fetch($object->fk_project); if (! empty($projectstatic->socid)) $projectstatic->fetch_thirdparty(); @@ -192,83 +192,83 @@ if ($id > 0 || ! empty($ref)) $param=($mode=='mine'?'&mode=mine':''); // Project card - - $linkback = ''.$langs->trans("BackToList").''; - + + $linkback = ''.$langs->trans("BackToList").''; + $morehtmlref='
'; // Title $morehtmlref.=$projectstatic->title; // Thirdparty - if ($projectstatic->thirdparty->id > 0) + if ($projectstatic->thirdparty->id > 0) { $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $projectstatic->thirdparty->getNomUrl(1, 'project'); } $morehtmlref.='
'; - + // Define a complementary filter for search of next/prev ref. if (! $user->rights->projet->all->lire) { $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user,0,0); $projectstatic->next_prev_filter=" rowid in (".(count($objectsListId)?join(',',array_keys($objectsListId)):'0').")"; } - + dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref); - + print '
'; print '
'; print '
'; - + print ''; - + // Visibility print ''; - + // Date start - end print ''; - + // Budget print ''; - + // Other attributes $cols = 2; //include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; - + print '
'.$langs->trans("Visibility").''; if ($projectstatic->public) print $langs->trans('SharedProject'); else print $langs->trans('PrivateProject'); print '
'.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").''; print dol_print_date($projectstatic->date_start,'day'); $end=dol_print_date($projectstatic->date_end,'day'); if ($end) print ' - '.$end; print '
'.$langs->trans("Budget").''; if (strcmp($projectstatic->budget_amount, '')) print price($projectstatic->budget_amount,'',$langs,1,0,0,$conf->currency); print '
'; - + print '
'; print '
'; print '
'; print '
'; - + print ''; - + // Description print ''; - + // Categories if($conf->categorie->enabled) { print '"; } - + print '
'.$langs->trans("Description").''; print nl2br($projectstatic->description); print '
'.$langs->trans("Categories").''; print $form->showCategories($projectstatic->id,'project',1); print "
'; - + print '
'; print '
'; print '
'; - + print '
'; dol_fiche_end(); @@ -284,16 +284,16 @@ if ($id > 0 || ! empty($ref)) $param=(GETPOST('withproject')?'&withproject=1':''); $linkback=GETPOST('withproject')?''.$langs->trans("BackToList").'':''; - + if (! GETPOST('withproject') || empty($projectstatic->id)) { $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,0,1); $object->next_prev_filter=" fk_projet in (".$projectsListId.")"; } else $object->next_prev_filter=" fk_projet = ".$projectstatic->id; - + $morehtmlref=''; - + // Project if (empty($withproject)) { @@ -301,13 +301,13 @@ if ($id > 0 || ! empty($ref)) $morehtmlref.=$langs->trans("Project").': '; $morehtmlref.=$projectstatic->getNomUrl(1); $morehtmlref.='
'; - + // Third party $morehtmlref.=$langs->trans("ThirdParty").': '; $morehtmlref.=$projectstatic->thirdparty->getNomUrl(1); $morehtmlref.=''; } - + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, $param, 0, '', '', 1); dol_fiche_end(); @@ -385,7 +385,7 @@ if ($id > 0 || ! empty($ref)) print ''; if ($withproject) print ''; - + print '
'; diff --git a/htdocs/projet/tasks/document.php b/htdocs/projet/tasks/document.php index 661776b9b4d..649e1efd575 100644 --- a/htdocs/projet/tasks/document.php +++ b/htdocs/projet/tasks/document.php @@ -136,84 +136,84 @@ if ($object->id > 0) // Project card - $linkback = ''.$langs->trans("BackToList").''; - + $linkback = ''.$langs->trans("BackToList").''; + $morehtmlref='
'; // Title $morehtmlref.=$projectstatic->title; // Thirdparty - if ($projectstatic->thirdparty->id > 0) + if ($projectstatic->thirdparty->id > 0) { $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $projectstatic->thirdparty->getNomUrl(1, 'project'); } $morehtmlref.='
'; - + // Define a complementary filter for search of next/prev ref. if (! $user->rights->projet->all->lire) { $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user,0,0); $projectstatic->next_prev_filter=" rowid in (".(count($objectsListId)?join(',',array_keys($objectsListId)):'0').")"; } - + dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref); - + print '
'; print '
'; print '
'; - + print ''; - + // Visibility print ''; - + // Date start - end print ''; - + // Budget print ''; - + // Other attributes $cols = 2; //include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; - + print '
'.$langs->trans("Visibility").''; if ($projectstatic->public) print $langs->trans('SharedProject'); else print $langs->trans('PrivateProject'); print '
'.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").''; print dol_print_date($projectstatic->date_start,'day'); $end=dol_print_date($projectstatic->date_end,'day'); if ($end) print ' - '.$end; print '
'.$langs->trans("Budget").''; if (strcmp($projectstatic->budget_amount, '')) print price($projectstatic->budget_amount,'',$langs,1,0,0,$conf->currency); print '
'; - + print '
'; print '
'; print '
'; print '
'; - + print ''; - + // Description print ''; - + // Categories if($conf->categorie->enabled) { print '"; } - + print '
'.$langs->trans("Description").''; print nl2br($projectstatic->description); print '
'.$langs->trans("Categories").''; print $form->showCategories($projectstatic->id,'project',1); print "
'; - + print '
'; print '
'; print '
'; - + print '
'; - + dol_fiche_end(); } @@ -227,7 +227,7 @@ if ($object->id > 0) { $totalsize+=$file['size']; } - + $param=(GETPOST('withproject')?'&withproject=1':''); $linkback=GETPOST('withproject')?''.$langs->trans("BackToList").'':''; @@ -237,9 +237,9 @@ if ($object->id > 0) $object->next_prev_filter=" fk_projet in (".$projectsListId.")"; } else $object->next_prev_filter=" fk_projet = ".$projectstatic->id; - + $morehtmlref=''; - + // Project if (empty($withproject)) { @@ -247,17 +247,17 @@ if ($object->id > 0) $morehtmlref.=$langs->trans("Project").': '; $morehtmlref.=$projectstatic->getNomUrl(1); $morehtmlref.='
'; - + // Third party $morehtmlref.=$langs->trans("ThirdParty").': '; $morehtmlref.=$projectstatic->thirdparty->getNomUrl(1); $morehtmlref.=''; } - + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, $param); - + print '
'; - + print '
'; print ''; @@ -268,7 +268,7 @@ if ($object->id > 0) print "
\n"; print '
'; - + dol_fiche_end(); print '
'; diff --git a/htdocs/projet/tasks/note.php b/htdocs/projet/tasks/note.php index 0d6df7d85fd..13a8979ae91 100644 --- a/htdocs/projet/tasks/note.php +++ b/htdocs/projet/tasks/note.php @@ -114,9 +114,9 @@ if ($object->id > 0) $param=($mode=='mine'?'&mode=mine':''); // Project card - - $linkback = ''.$langs->trans("BackToList").''; - + + $linkback = ''.$langs->trans("BackToList").''; + $morehtmlref='
'; // Title $morehtmlref.=$projectstatic->title; @@ -126,92 +126,92 @@ if ($object->id > 0) $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $projectstatic->thirdparty->getNomUrl(1, 'project'); } $morehtmlref.='
'; - + // Define a complementary filter for search of next/prev ref. if (! $user->rights->projet->all->lire) { $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user,0,0); $projectstatic->next_prev_filter=" rowid in (".(count($objectsListId)?join(',',array_keys($objectsListId)):'0').")"; } - + dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref); - + print '
'; print '
'; print '
'; - + print ''; - + // Visibility print ''; - + // Date start - end print ''; - + // Budget print ''; - + // Other attributes $cols = 2; //include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; - + print '
'.$langs->trans("Visibility").''; if ($projectstatic->public) print $langs->trans('SharedProject'); else print $langs->trans('PrivateProject'); print '
'.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").''; print dol_print_date($projectstatic->date_start,'day'); $end=dol_print_date($projectstatic->date_end,'day'); if ($end) print ' - '.$end; print '
'.$langs->trans("Budget").''; if (strcmp($projectstatic->budget_amount, '')) print price($projectstatic->budget_amount,'',$langs,1,0,0,$conf->currency); print '
'; - + print '
'; print '
'; print '
'; print '
'; - + print ''; - + // Description print ''; - + // Categories if($conf->categorie->enabled) { print '"; } - + print '
'.$langs->trans("Description").''; print nl2br($projectstatic->description); print '
'.$langs->trans("Categories").''; print $form->showCategories($projectstatic->id,'project',1); print "
'; - + print '
'; print '
'; print '
'; - + print '
'; - + dol_fiche_end(); } $head = task_prepare_head($object); dol_fiche_head($head, 'task_notes', $langs->trans('Task'), -1, 'projecttask'); - + $param=(GETPOST('withproject')?'&withproject=1':''); $linkback=GETPOST('withproject')?''.$langs->trans("BackToList").'':''; - + if (! GETPOST('withproject') || empty($projectstatic->id)) { $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,0,1); $object->next_prev_filter=" fk_projet in (".$projectsListId.")"; } else $object->next_prev_filter=" fk_projet = ".$projectstatic->id; - + $morehtmlref=''; - + // Project if (empty($withproject)) { @@ -219,17 +219,17 @@ if ($object->id > 0) $morehtmlref.=$langs->trans("Project").': '; $morehtmlref.=$projectstatic->getNomUrl(1); $morehtmlref.='
'; - + // Third party $morehtmlref.=$langs->trans("ThirdParty").': '; $morehtmlref.=$projectstatic->thirdparty->getNomUrl(1); $morehtmlref.=''; } - + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, $param); - + print '
'; - + print '
'; $cssclass='titlefield'; @@ -237,7 +237,7 @@ if ($object->id > 0) include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; print '
'; - + dol_fiche_end(); } diff --git a/htdocs/projet/tasks/task.php b/htdocs/projet/tasks/task.php index 5f493167fd8..6018b8bef69 100644 --- a/htdocs/projet/tasks/task.php +++ b/htdocs/projet/tasks/task.php @@ -226,85 +226,85 @@ if ($id > 0 || ! empty($ref)) $param=($mode=='mine'?'&mode=mine':''); // Project card - - $linkback = ''.$langs->trans("BackToList").''; - + + $linkback = ''.$langs->trans("BackToList").''; + $morehtmlref='
'; // Title $morehtmlref.=$projectstatic->title; // Thirdparty - if ($projectstatic->thirdparty->id > 0) + if ($projectstatic->thirdparty->id > 0) { $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $projectstatic->thirdparty->getNomUrl(1, 'project'); } $morehtmlref.='
'; - + // Define a complementary filter for search of next/prev ref. if (! $user->rights->projet->all->lire) { $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user,0,0); $projectstatic->next_prev_filter=" rowid in (".(count($objectsListId)?join(',',array_keys($objectsListId)):'0').")"; } - + dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref); - + print '
'; print '
'; print '
'; - + print ''; - + // Visibility print ''; - + // Date start - end print ''; - + // Budget print ''; - + // Other attributes $cols = 2; //include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; - + print '
'.$langs->trans("Visibility").''; if ($projectstatic->public) print $langs->trans('SharedProject'); else print $langs->trans('PrivateProject'); print '
'.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").''; print dol_print_date($projectstatic->date_start,'day'); $end=dol_print_date($projectstatic->date_end,'day'); if ($end) print ' - '.$end; print '
'.$langs->trans("Budget").''; if (strcmp($projectstatic->budget_amount, '')) print price($projectstatic->budget_amount,'',$langs,1,0,0,$conf->currency); print '
'; - + print '
'; print '
'; print '
'; print '
'; - + print ''; - + // Description print ''; - + // Categories if($conf->categorie->enabled) { print '"; } - + print '
'.$langs->trans("Description").''; print nl2br($projectstatic->description); print '
'.$langs->trans("Categories").''; print $form->showCategories($projectstatic->id,'project',1); print "
'; - + print '
'; print '
'; print '
'; - + print '
'; - + dol_fiche_end(); print '
'; @@ -430,7 +430,7 @@ if ($id > 0 || ! empty($ref)) * Fiche tache en mode visu */ $param=($withproject?'&withproject=1':''); - $linkback=$withproject?''.$langs->trans("BackToList").'':''; + $linkback=$withproject?''.$langs->trans("BackToList").'':''; dol_fiche_head($head, 'task_task', $langs->trans("Task"), -1, 'projecttask'); @@ -445,9 +445,9 @@ if ($id > 0 || ! empty($ref)) $object->next_prev_filter=" fk_projet in (".$projectsListId.")"; } else $object->next_prev_filter=" fk_projet = ".$projectstatic->id; - + $morehtmlref=''; - + // Project if (empty($withproject)) { @@ -455,18 +455,18 @@ if ($id > 0 || ! empty($ref)) $morehtmlref.=$langs->trans("Project").': '; $morehtmlref.=$projectstatic->getNomUrl(1); $morehtmlref.='
'; - + // Third party $morehtmlref.=$langs->trans("ThirdParty").': '; $morehtmlref.=$projectstatic->thirdparty->getNomUrl(1); $morehtmlref.=''; } - + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, $param); - + print '
'; - - print '
'; + + print '
'; print ''; // Date start - Date end @@ -511,18 +511,15 @@ if ($id > 0 || ! empty($ref)) print nl2br($object->description); print ''; - // Other options - $parameters=array(); - $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook - if (empty($reshook) && ! empty($extrafields->attribute_label)) - { - print $object->showOptionals($extrafields); - } + // Other attributes + $cols = 3; + $parameyers=array('socid'=>$socid); + include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; print '
'; - + print '
'; - + dol_fiche_end(); } @@ -532,7 +529,7 @@ if ($id > 0 || ! empty($ref)) /* * Actions */ - + print '
'; $parameters = array(); @@ -549,7 +546,7 @@ if ($id > 0 || ! empty($ref)) { print ''.$langs->trans('Modify').''; } - + // Delete if ($user->rights->projet->supprimer) { @@ -566,13 +563,13 @@ if ($id > 0 || ! empty($ref)) { print ''.$langs->trans('Delete').''; } - + print '
'; } - + print '
'; print ''; // ancre - + /* * Documents generes */ @@ -587,7 +584,7 @@ if ($id > 0 || ! empty($ref)) print $formfile->showdocuments('project_task',$filename,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf); print '
'; - + print '
'; } } diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index b4ed0ab2928..ecd15a8aa3b 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -190,7 +190,7 @@ if ($action == 'updateline' && ! $_POST["cancel"] && $user->rights->projet->lire { $object->fetch($id, $ref); // TODO Check that ($task_time->fk_user == $user->id || in_array($task_time->fk_user, $childids)) - + $object->timespent_id = $_POST["lineid"]; $object->timespent_note = $_POST["timespent_note_line"]; $object->timespent_old_duration = $_POST["old_duration"]; @@ -262,10 +262,10 @@ $projectidforalltimes=0; if (GETPOST('projectid')) { $projectidforalltimes=GETPOST('projectid','int'); - + } - + /* * View */ @@ -292,10 +292,10 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) $result=$projectstatic->fetch($object->fk_project); if (! empty($projectstatic->socid)) $projectstatic->fetch_thirdparty(); $res=$projectstatic->fetch_optionals($object->id,$extralabels_projet); - + $object->project = clone $projectstatic; } - + $userWrite = $projectstatic->restrictedProjectArea($user,'write'); if ($projectstatic->id > 0) @@ -310,88 +310,88 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) $param=($mode=='mine'?'&mode=mine':''); // Project card - - $linkback = ''.$langs->trans("BackToList").''; - + + $linkback = ''.$langs->trans("BackToList").''; + $morehtmlref='
'; // Title $morehtmlref.=$projectstatic->title; // Thirdparty - if ($projectstatic->thirdparty->id > 0) + if ($projectstatic->thirdparty->id > 0) { $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $projectstatic->thirdparty->getNomUrl(1, 'project'); } $morehtmlref.='
'; - + // Define a complementary filter for search of next/prev ref. if (! $user->rights->projet->all->lire) { $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user,0,0); $projectstatic->next_prev_filter=" rowid in (".(count($objectsListId)?join(',',array_keys($objectsListId)):'0').")"; } - + dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref); - + print '
'; print '
'; print '
'; - + print ''; - + // Visibility print ''; - + // Date start - end print ''; - + // Budget print ''; - + // Other attributes $cols = 2; //include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; - + print '
'.$langs->trans("Visibility").''; if ($projectstatic->public) print $langs->trans('SharedProject'); else print $langs->trans('PrivateProject'); print '
'.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").''; print dol_print_date($projectstatic->date_start,'day'); $end=dol_print_date($projectstatic->date_end,'day'); if ($end) print ' - '.$end; print '
'.$langs->trans("Budget").''; if (strcmp($projectstatic->budget_amount, '')) print price($projectstatic->budget_amount,'',$langs,1,0,0,$conf->currency); print '
'; - + print '
'; print '
'; print '
'; print '
'; - + print ''; - + // Description print ''; - + // Categories if($conf->categorie->enabled) { print '"; } - + print '
'.$langs->trans("Description").''; print nl2br($projectstatic->description); print '
'.$langs->trans("Categories").''; print $form->showCategories($projectstatic->id,'project',1); print "
'; - + print '
'; print '
'; print '
'; - + print '
'; dol_fiche_end(); - - + + /* * Actions */ @@ -399,7 +399,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) if ((empty($id) && empty($ref)) || ! empty($projectidforalltimes)) { print '
'; - + if ($user->rights->projet->all->creer || $user->rights->projet->creer) { if ($object->public || $userWrite > 0) @@ -415,12 +415,12 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) { print ''.$langs->trans('AddTask').''; } - + print '
'; } } } - + if (empty($projectidforalltimes)) { $head=task_prepare_head($object); @@ -440,9 +440,9 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) $object->next_prev_filter=" fk_projet in (".$projectsListId.")"; } else $object->next_prev_filter=" fk_projet = ".$projectstatic->id; - + $morehtmlref=''; - + // Project if (empty($withproject)) { @@ -450,18 +450,18 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) $morehtmlref.=$langs->trans("Project").': '; $morehtmlref.=$projectstatic->getNomUrl(1); $morehtmlref.='
'; - + // Third party $morehtmlref.=$langs->trans("ThirdParty").': '; $morehtmlref.=$projectstatic->thirdparty->getNomUrl(1); $morehtmlref.=''; } - + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, $param); - + print '
'; print '
'; - + print '
'; print ''; @@ -482,12 +482,12 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) print '
'; print '
'; - + print '
'; - + print '
'; print ''; - + // Progress declared print ''; print '
'.$langs->trans("ProgressDeclared").''; print $object->progress.' %'; @@ -508,10 +508,10 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) print ''; print ''; - + print ''; print '
'; - + dol_fiche_end(); @@ -583,18 +583,18 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) print '
'; - + print '
'; } } - + if ($projectstatic->id > 0) - { + { if ($action == 'deleteline') { print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id.'&lineid='.$_GET["lineid"].($withproject?'&withproject=1':''),$langs->trans("DeleteATimeSpent"),$langs->trans("ConfirmDeleteATimeSpent"),"confirm_delete",'','',1); } - + // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array $hookmanager->initHooks(array('tasktimelist')); $extrafields = new ExtraFields($db); @@ -619,12 +619,12 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); } } - + /* * List of time spent */ $tasks = array(); - + $sql = "SELECT t.rowid, t.fk_task, t.task_date, t.task_datehour, t.task_date_withhour, t.task_duration, t.fk_user, t.note, t.thm,"; $sql .= " pt.ref, pt.label,"; $sql .= " u.lastname, u.firstname, u.login, u.photo"; @@ -638,7 +638,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) if ($search_task_label) $sql .= natural_search('pt.label', $search_task_label); if ($search_user > 0) $sql .= natural_search('t.fk_user', $search_user); $sql .= $db->order($sortfield, $sortorder); - + $var=true; $resql = $db->query($sql); if ($resql) @@ -668,9 +668,9 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) dol_print_error($db); } - + $arrayofselected=is_array($toselect)?$toselect:array(); - + $params=''; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; @@ -687,8 +687,8 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) if ($id) $params.='&id='.$id; if ($projectid) $params.='&projectid='.$projectid; if ($withproject) $params.='&withproject='.$withproject; - - + + $arrayofmassactions = array( //'presend'=>$langs->trans("SendByMail"), //'builddoc'=>$langs->trans("PDFMerge"), @@ -696,9 +696,9 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) //if ($user->rights->projet->creer) $arrayofmassactions['delete']=$langs->trans("Delete"); if ($massaction == 'presend') $arrayofmassactions=array(); $massactionbutton=$form->selectMassAction('', $arrayofmassactions); - - - + + + print '
'; if ($optioncss != '') print ''; print ''; @@ -708,31 +708,31 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) print ''; print ''; print ''; - + print ''; print ''; print ''; $moreforfilter = ''; - + $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint; - + if (! empty($moreforfilter)) { print '
'; print $moreforfilter; print '
'; } - + $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - + print '
'; print ''."\n"; - + // Fields title search print ''; // Date @@ -783,14 +783,14 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) $searchpicto=$form->showFilterAndCheckAddButtons($massactionbutton?1:0, 'checkforselect', 1); print $searchpicto; print ''; - print ''."\n"; - + print ''."\n"; + print ''; if (! empty($arrayfields['t.task_date']['checked'])) print_liste_field_titre($arrayfields['t.task_date']['label'],$_SERVER['PHP_SELF'],'t.task_date,t.task_datehour,t.rowid','',$params,'',$sortfield,$sortorder); if ((empty($id) && empty($ref)) || ! empty($projectidforalltimes)) // Not a dedicated task { - if (! empty($arrayfields['t.task_ref']['checked'])) print_liste_field_titre($arrayfields['t.task_ref']['label'],$_SERVER['PHP_SELF'],'pt.ref','',$params,'',$sortfield,$sortorder); - if (! empty($arrayfields['t.task_label']['checked'])) print_liste_field_titre($arrayfields['t.task_label']['label'],$_SERVER['PHP_SELF'],'pt.label','',$params,'',$sortfield,$sortorder); + if (! empty($arrayfields['t.task_ref']['checked'])) print_liste_field_titre($arrayfields['t.task_ref']['label'],$_SERVER['PHP_SELF'],'pt.ref','',$params,'',$sortfield,$sortorder); + if (! empty($arrayfields['t.task_label']['checked'])) print_liste_field_titre($arrayfields['t.task_label']['label'],$_SERVER['PHP_SELF'],'pt.label','',$params,'',$sortfield,$sortorder); } if (! empty($arrayfields['author']['checked'])) print_liste_field_titre($arrayfields['author']['label'],$_SERVER['PHP_SELF'],'','',$params,'',$sortfield,$sortorder); if (! empty($arrayfields['t.note']['checked'])) print_liste_field_titre($arrayfields['t.note']['label'],$_SERVER['PHP_SELF'],'t.note','',$params,'',$sortfield,$sortorder); @@ -800,9 +800,9 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) /* if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { - foreach($extrafields->attribute_label as $key => $val) + foreach($extrafields->attribute_label as $key => $val) { - if (! empty($arrayfields["ef.".$key]['checked'])) + if (! empty($arrayfields["ef.".$key]['checked'])) { $align=$extrafields->getAlignFlag($key); print_liste_field_titre($langs->trans($extralabels[$key]),$_SERVER["PHP_SELF"],"ef.".$key,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder); @@ -817,17 +817,17 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) print "\n"; $tasktmp = new Task($db); - + $i = 0; $childids = $user->getAllChildIds(); - + $total = 0; $totalvalue = 0; $totalarray=array(); foreach ($tasks as $task_time) { - + print ''; $date1=$db->jdate($task_time->task_date); @@ -858,26 +858,26 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) $tasktmp->id = $task_time->fk_task; $tasktmp->ref = $task_time->ref; $tasktmp->label = $task_time->label; - print $tasktmp->getNomUrl(1, 'withproject', 'time'); + print $tasktmp->getNomUrl(1, 'withproject', 'time'); print ''; if (! $i) $totalarray['nbfield']++; } } - + // Task label if (! empty($arrayfields['t.task_label']['checked'])) { if ((empty($id) && empty($ref)) || ! empty($projectidforalltimes)) // Not a dedicated task { print ''; if (! $i) $totalarray['nbfield']++; } } - + // User - if (! empty($arrayfields['author']['checked'])) + if (! empty($arrayfields['author']['checked'])) { print ''; if (! $i) $totalarray['nbfield']++; } - + // Time spent if (! empty($arrayfields['t.task_duration']['checked'])) { @@ -940,9 +940,9 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) if (! $i) $totalarray['totaldurationfield']=$totalarray['nbfield']; $totalarray['totalduration'] += $task_time->task_duration; } - + // Value spent - if (! empty($arrayfields['value']['checked'])) + if (! empty($arrayfields['value']['checked'])) { print ''; if (! $i) $totalarray['nbfield']++; - + print "\n"; - + $i++; } - + // Show total line if (isset($totalarray['totaldurationfield']) || isset($totalarray['totalvaluefield'])) { diff --git a/htdocs/resource/add.php b/htdocs/resource/add.php index c8b4d124fed..2e988d16025 100644 --- a/htdocs/resource/add.php +++ b/htdocs/resource/add.php @@ -175,7 +175,7 @@ if (! $action) print ''; // Other attributes - $parameters=array('objectsrc' => $objectsrc, 'colspan' => ' colspan="3"'); + $parameters=array('objectsrc' => $objectsrc); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook if (empty($reshook) && ! empty($extrafields->attribute_label)) { diff --git a/htdocs/resource/card.php b/htdocs/resource/card.php index 7f0a96a7ab4..a286eb60097 100644 --- a/htdocs/resource/card.php +++ b/htdocs/resource/card.php @@ -201,7 +201,7 @@ if ( $object->fetch($id) > 0 ) print ''; // Other attributes - $parameters=array('objectsrc' => $objectsrc, 'colspan' => ' colspan="3"'); + $parameters=array('objectsrc' => $objectsrc); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook if (empty($reshook) && ! empty($extrafields->attribute_label)) { @@ -224,7 +224,7 @@ if ( $object->fetch($id) > 0 ) dol_fiche_head($head, 'resource', $langs->trans("ResourceSingular"), -1, 'resource'); $formconfirm = ''; - + // Confirm deleting resource line if ($action == 'delete') { @@ -233,21 +233,21 @@ if ( $object->fetch($id) > 0 ) // Print form confirm print $formconfirm; - - + + $linkback = '' . $langs->trans("BackToList") . ''; - - + + $morehtmlref='
'; $morehtmlref.='
'; - - + + dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref); - - + + print '
'; print '
'; - + /*--------------------------------------- * View object */ @@ -269,21 +269,16 @@ if ( $object->fetch($id) > 0 ) print ''; // Other attributes - $parameters=array(); - $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook - if (empty($reshook) && ! empty($extrafields->attribute_label)) - { - print $object->showOptionals($extrafields); - } + include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; print ''; print '
'; - print $task_time->label; + print $task_time->label; print ''; if ($_GET['action'] == 'editline' && $_GET['lineid'] == $task_time->rowid) @@ -907,7 +907,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) } // Note - if (! empty($arrayfields['t.note']['checked'])) + if (! empty($arrayfields['t.note']['checked'])) { print ''; if ($_GET['action'] == 'editline' && $_GET['lineid'] == $task_time->rowid) @@ -921,7 +921,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) print ''; $value = price2num($task_time->thm * $task_time->task_duration / 3600); @@ -957,7 +957,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - + // Action column print ''; if ($action == 'editline' && $_GET['lineid'] == $task_time->rowid) @@ -975,7 +975,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) print 'rowid.($withproject?'&withproject=1':'').'">'; print img_edit(); print ''; - + print ' '; print 'rowid.($withproject?'&withproject=1':'').'">'; print img_delete(); @@ -984,12 +984,12 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) } print '
'; - + print '
'; - + print '

'; - + dol_fiche_end(); } diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index ba4383e6f8e..cb99949407b 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -140,7 +140,7 @@ if (empty($reshook)) if (!$errors) { // TODO Move the merge function into class of object. - + $db->begin(); // Recopy some data @@ -157,16 +157,16 @@ if (empty($reshook)) { if (empty($object->$property)) $object->$property = $soc_origin->$property; } - + // Concat some data $listofproperties=array( - 'note_public', 'note_private' + 'note_public', 'note_private' ); foreach ($listofproperties as $property) { $object->$property = dol_concatdesc($object->$property, $soc_origin->$property); } - + // Merge extrafields foreach ($soc_origin->array_options as $key => $val) { @@ -175,8 +175,8 @@ if (empty($reshook)) // TODO Merge categories $object->update($object->id, $user); - - // Move links + + // Move links $objects = array( 'Adherent' => '/adherents/class/adherent.class.php', 'Societe' => '/societe/class/societe.class.php', @@ -280,6 +280,21 @@ if (empty($reshook)) $res=$object->setValueFrom('localtax2_value', $value, '', null, 'text', '', $user, 'COMPANY_MODIFY'); } + if ($action == 'update_extras') { + $object->fetch($socid); + + // Fill array 'array_options' with data from update form + $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); + $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute')); + if ($ret < 0) $error++; + if (! $error) + { + $result = $object->insertExtraFields(); + if ($result < 0) $error++; + } + if ($error) $action = 'edit_extras'; + } + // Add new or update third party if ((! GETPOST('getcustomercode') && ! GETPOST('getsuppliercode')) && ($action == 'add' || $action == 'update') && $user->rights->societe->creer) @@ -487,7 +502,7 @@ if (empty($reshook)) if (empty($object->fournisseur)) $object->code_fournisseur=''; $result = $object->create($user); - + if ($result >= 0) { if ($object->particulier) @@ -557,7 +572,7 @@ if (empty($reshook)) $object->code_fournisseur = null; $object->code_client = null; } - + $error=$object->error; $errors=$object->errors; } @@ -851,7 +866,7 @@ else $object->particulier = $private; $object->prefix_comm = GETPOST('prefix_comm'); $object->client = GETPOST('client')?GETPOST('client'):$object->client; - + if(empty($duplicate_code_error)) { $object->code_client = GETPOST('code_client', 'alpha'); $object->fournisseur = GETPOST('fournisseur')?GETPOST('fournisseur'):$object->fournisseur; @@ -859,7 +874,7 @@ else else { setEventMessages($langs->trans('NewCustomerSupplierCodeProposed'),'', 'warnings'); } - + $object->code_fournisseur = GETPOST('code_fournisseur', 'alpha'); $object->address = GETPOST('address', 'alpha'); $object->zip = GETPOST('zipcode', 'alpha'); @@ -1135,7 +1150,7 @@ else print '
'.fieldLabel('Web','url').'
'.$langs->transcountry("LocalTax2IsUsed",$mysoc->country_code).''; print $form->selectyesno('localtax2assuj_value',(isset($conf->global->THIRDPARTY_DEFAULT_USELOCALTAX2)?$conf->global->THIRDPARTY_DEFAULT_USELOCALTAX2:0),1); print '
'.fieldLabel('ThirdPartyType','typent_id').''."\n"; $sortparam=(empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?'ASC':$conf->global->SOCIETE_SORT_ON_TYPEENT); // NONE means we keep sort of original array, so we sort on position. ASC, means next function will sort on label. @@ -1544,7 +1559,7 @@ else dol_fiche_head($head, 'card', $langs->trans("ThirdParty"), 0, 'company'); - print '
'; + print '
'; print ''; // Ref/ID @@ -1750,7 +1765,7 @@ else $formcompany->select_localtax(1,$object->localtax1_value, "lt1"); print ''; } - + print ''; - + } elseif($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj!="1") { @@ -1773,7 +1788,7 @@ else print ''; } print ''; - + } elseif($mysoc->localtax2_assuj=="1" && $mysoc->localtax1_assuj!="1") { @@ -1787,7 +1802,7 @@ else } print ''; } - + // VAT Code print ''; print '
'.fieldLabel($langs->transcountry("LocalTax2IsUsed",$mysoc->country_code),'localtax2assuj_value').''; print $form->selectyesno('localtax2assuj_value',$object->localtax2_assuj,1); if (! isOnlyOneLocalTax(2)) @@ -1760,7 +1775,7 @@ else print ''; } print '
'.fieldLabel('VATIntra','intra_vat').''; @@ -1935,7 +1950,7 @@ else print '
'; print '
'; - + dol_fiche_end(); print '
'; @@ -1952,7 +1967,7 @@ else /* * View */ - + if (!empty($object->id)) $res=$object->fetch_optionals($object->id,$extralabels); //if ($res < 0) { dol_print_error($db); exit; } @@ -2091,7 +2106,7 @@ else print '
'.$langs->transcountry("LocalTax2IsUsed",$mysoc->country_code).''; print yn($object->localtax2_assuj); print '
'.$object->localtax1_value.'
'.$object->localtax2_value.'
'.$langs->trans('VATIntra').''; @@ -2308,14 +2323,9 @@ else print '
'; print "
\n"; - + dol_fiche_end(); @@ -232,7 +229,7 @@ if (! empty($socid)) $sql = "SELECT DISTINCT u.rowid, u.lastname, u.firstname, u.login, u.email, u.statut, u.fk_soc, u.photo"; $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; - if (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)) + if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { $sql.= ", ".MAIN_DB_PREFIX."usergroup_user as ug"; $sql.= " WHERE ((ug.fk_user = u.rowid"; @@ -263,11 +260,11 @@ if (! empty($socid)) $var=True; $tmpuser=new User($db); - + while ($i < $num) { $obj = $db->fetch_object($resql); - + print ""; $tmpuser->id=$obj->rowid; $tmpuser->firstname=$obj->firstname; diff --git a/htdocs/societe/consumption.php b/htdocs/societe/consumption.php index 056a67e5587..29bc06ff760 100644 --- a/htdocs/societe/consumption.php +++ b/htdocs/societe/consumption.php @@ -359,16 +359,7 @@ if ($sql_select) print_barre_liste($langs->trans('ProductsIntoElements').' '.$typeElementString.' '.$button, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder,'',$num, $totalnboflines, '', 0, '', '', $limit); print ''."\n"; - // Titles with sort buttons - print ''; - print_liste_field_titre($langs->trans('Ref'),$_SERVER['PHP_SELF'],'doc_number','',$param,'align="left"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans('Date'),$_SERVER['PHP_SELF'],'dateprint','',$param,'align="center" width="150"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans('Status'),$_SERVER['PHP_SELF'],'fk_statut','',$param,'align="center"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans('Product'),$_SERVER['PHP_SELF'],'','',$param,'align="left"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans('Quantity'),$_SERVER['PHP_SELF'],'prod_qty','',$param,'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans('TotalHT'),$_SERVER['PHP_SELF'],'total_ht','',$param,'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans('UnitPrice'),$_SERVER['PHP_SELF'],'','',$param,'align="right"',$sortfield,$sortorder); - print "\n"; + // Filters print ''; print ''; print ''; + // Titles with sort buttons + print ''; + print_liste_field_titre($langs->trans('Ref'),$_SERVER['PHP_SELF'],'doc_number','',$param,'align="left"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans('Date'),$_SERVER['PHP_SELF'],'dateprint','',$param,'align="center" width="150"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans('Status'),$_SERVER['PHP_SELF'],'fk_statut','',$param,'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans('Product'),$_SERVER['PHP_SELF'],'','',$param,'align="left"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans('Quantity'),$_SERVER['PHP_SELF'],'prod_qty','',$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans('TotalHT'),$_SERVER['PHP_SELF'],'total_ht','',$param,'align="right"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans('UnitPrice'),$_SERVER['PHP_SELF'],'','',$param,'align="right"',$sortfield,$sortorder); + print "\n"; + + $i = 0; while (($objp = $db->fetch_object($resql)) && $i < min($num, $limit)) { @@ -407,7 +410,7 @@ if ($sql_select) if (is_object($documentstaticline)) $documentstaticline->statut=$objp->status; - + print ''; print '\n"; - print ''; + print ''; print "
'; @@ -393,6 +384,18 @@ if ($sql_select) print '
'; print $documentstatic->getNomUrl(1); @@ -609,7 +612,7 @@ else if (empty($type_element) || $type_element == -1) print_liste_field_titre($langs->trans('Quantity'),$_SERVER['PHP_SELF'],'prod_qty','',$param,'align="right"',$sortfield,$sortorder); print "
'.$langs->trans("SelectElementAndClickRefresh").'
'.$langs->trans("SelectElementAndClick", $langs->transnoentitiesnoconv("Search")).'
"; } diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 3ab173e958b..28d6ec27368 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -840,6 +840,11 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; print ''; } + else + { + // for the type as 'checkbox', 'chkbxlst', 'sellist' we should use code instead of id (example: I declare a 'chkbxlst' to have a link with dictionnairy, I have to extend it with the 'code' instead 'rowid') + echo $extrafields->showInputField($key, $search_array_options['search_options_'.$key], '', '', 'search_'); + } print ''; } } diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index 86c350ecc22..020473fee59 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -505,7 +505,7 @@ if (empty($reshook)) } // Add a product line - if ($action == 'addline' && $user->rights->supplier_proposal->creer) + if ($action == 'addline' && $user->rights->supplier_proposal->creer) { $langs->load('errors'); $error = 0; @@ -515,7 +515,7 @@ if (empty($reshook)) $product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):''); $date_start=dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start' . $predef . 'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year')); $date_end=dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end' . $predef . 'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year')); - + if (GETPOST('prod_entry_mode') == 'free') { $idprod=0; @@ -572,7 +572,7 @@ if (empty($reshook)) if ((GETPOST('prod_entry_mode') != 'free') && empty($error)) // With combolist mode idprodfournprice is > 0 or -1. With autocomplete, idprodfournprice is > 0 or '' { $productsupplier = new ProductFournisseur($db); - + if (empty($conf->global->SUPPLIER_PROPOSAL_WITH_NOPRICEDEFINED)) { $idprod=0; @@ -592,7 +592,7 @@ if (empty($reshook)) $idprod=$productsupplier->get_buyprice(GETPOST('idprodfournprice'), -1); // We force qty to -1 to be sure to find if a supplier price exist $res=$productsupplier->fetch($idprod); } - + if ($idprod > 0) { $pu_ht = $productsupplier->fourn_pu; @@ -601,7 +601,7 @@ if (empty($reshook)) $label = $productsupplier->label; $desc = $productsupplier->description; if (trim($product_desc) != trim($desc)) $desc = dol_concatdesc($desc, $product_desc); - + $tva_tx = get_default_tva($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice')); $tva_npr = get_default_npr($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice')); if (empty($tva_tx)) $tva_npr=0; @@ -659,13 +659,13 @@ if (empty($reshook)) $type = GETPOST('type'); $fk_unit= GETPOST('units', 'alpha'); - + $tva_tx = price2num($tva_tx); // When vat is text input field - + // Local Taxes $localtax1_tx= get_localtax($tva_tx, 1, $mysoc, $object->thirdparty); $localtax2_tx= get_localtax($tva_tx, 2, $mysoc, $object->thirdparty); - + if (GETPOST('price_ht')!=='') { $price_base_type = 'HT'; @@ -678,13 +678,13 @@ if (empty($reshook)) $ht = $ttc / (1 + ($tva_tx / 100)); $price_base_type = 'HT'; } - + $result = $object->addline($desc, $ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $ttc, $info_bits, $type, - 1, 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $array_options, $ref_fourn, $fk_unit); //$result = $object->addline($desc, $ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 0, '', $remise_percent, $price_base_type, $ttc, $type,'','', $date_start, $date_end, $array_options, $fk_unit); } - if (! $error && $result > 0) + if (! $error && $result > 0) { $db->commit(); @@ -701,7 +701,7 @@ if (empty($reshook)) } $model=$object->modelpdf; $ret = $object->fetch($id); // Reload to get new records - + $result=$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result < 0) dol_print_error($db,$result); } @@ -711,7 +711,7 @@ if (empty($reshook)) unset($_POST['qty']); unset($_POST['type']); unset($_POST['remise_percent']); - unset($_POST['pu']); + unset($_POST['pu']); unset($_POST['price_ht']); unset($_POST['multicurrency_price_ht']); unset($_POST['price_ttc']); @@ -742,8 +742,8 @@ if (empty($reshook)) unset($_POST['date_endday']); unset($_POST['date_endmonth']); unset($_POST['date_endyear']); - } - else + } + else { $db->rollback(); @@ -959,27 +959,13 @@ if (empty($reshook)) // Fill array 'array_options' with data from update form $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute')); - if ($ret < 0) - $error ++; - - if (! $error) { - // Actions on extra fields (by external module or standard code) - $hookmanager->initHooks(array('supplier_proposaldao')); - $parameters = array('id' => $object->id); - $reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $object, $action); // Note that $action and $object may have been - // modified by - // some hooks - if (empty($reshook)) { - $result = $object->insertExtraFields(); - if ($result < 0) { - $error ++; - } - } else if ($reshook < 0) - $error ++; + if ($ret < 0) $error++; + if (! $error) + { + $result = $object->insertExtraFields(); + if ($result < 0) $error++; } - - if ($error) - $action = 'edit_extras'; + if ($error) $action = 'edit_extras'; } } @@ -1163,9 +1149,7 @@ if ($action == 'create') // Other attributes $parameters = array('colspan' => ' colspan="3"'); - $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified - // by - // hook + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook) && ! empty($extrafields->attribute_label)) { print $object->showOptionals($extrafields, 'edit'); } @@ -1367,11 +1351,11 @@ if ($action == 'create') // Print form confirm print $formconfirm; - + // Supplier proposal card $linkback = '
' . $langs->trans("BackToList") . ''; - - + + $morehtmlref='
'; // Ref supplier //$morehtmlref.=$form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->fournisseur->commande->creer, 'string', '', 0, 1); @@ -1411,15 +1395,15 @@ if ($action == 'create') } } $morehtmlref.='
'; - - + + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); - - + + print '
'; print '
'; print '
'; - + print ''; // Payment term @@ -1563,14 +1547,14 @@ if ($action == 'create') include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; print '
'; - + print '
'; print '
'; print '
'; print '
'; - + print ''; - + if (!empty($conf->multicurrency->enabled) && ($object->multicurrency_code != $conf->currency)) { // Multicurrency Amount HT @@ -1588,7 +1572,7 @@ if ($action == 'create') print ''; print ''; } - + // Amount HT print ''; print ''; @@ -1619,18 +1603,18 @@ if ($action == 'create') print ''; print '
' . price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '
' . $langs->trans('AmountHT') . '' . price($object->total_ht, '', $langs, 0, - 1, - 1, $conf->currency) . '
'; - + // Margin Infos /*if (! empty($conf->margin->enabled)) { $formmargin->displayMarginInfos($object); - }*/ + }*/ print '
'; print '
'; print '
'; - + print '

'; - + if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { $blocname = 'contacts'; $title = $langs->trans('ContactsAddresses'); @@ -1667,7 +1651,7 @@ if ($action == 'create') // Add free products/services form global $forceall, $senderissupplier, $dateSelector; $forceall=1; $senderissupplier=2; $dateSelector=0; // $senderissupplier=2 is same than 1 but disable test on minimum qty. - + if (! empty($object->lines)) $ret = $object->printObjectLines($action, $soc, $mysoc, $lineid, 1); @@ -1810,12 +1794,12 @@ if ($action == 'create') print $formfile->showdocuments('supplier_proposal', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', 0, '', $soc->default_lang); - + // Show links to link elements $linktoelem = $form->showLinkToObjectBlock($object, null, array('supplier_proposal')); $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); - + print '
'; // List of actions on element diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 3912a9b80ff..c0738f004bc 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -265,7 +265,7 @@ input.select2-input { border-bottom: solid 1px rgba(0,0,0,.2) !important; /* required to avoid to lose bottom line when focus is lost on select2. */ } -.liste_titre input[name=monthvalid], .liste_titre input[name=search_smonth], .liste_titre input[name=search_emonth], .liste_titre input[name=smonth], .liste_titre input[name=month], .liste_titre input[name=month_lim] { +.liste_titre input[name=monthvalid], .liste_titre input[name=search_smonth], .liste_titre input[name=search_emonth], .liste_titre input[name=smonth], .liste_titre input[name=month], .liste_titre select[name=month], .liste_titre input[name=month_lim] { margin-right: 4px; } input[type=submit] { @@ -691,7 +691,7 @@ div.fiche>form>div.div-table-responsive, div.fiche>form>div.div-table-responsive overflow-x: auto; } div.fiche>form>div.div-table-responsive { - min-height: 390px; + min-height: 392px; } .flexcontainer { diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index d3f822bcca2..4557c6856fb 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -692,7 +692,7 @@ div.fiche>form>div.div-table-responsive, div.fiche>form>div.div-table-responsive overflow-x: auto; } div.fiche>form>div.div-table-responsive { - min-height: 390px; + min-height: 392px; } .flexcontainer { diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 92951de98e8..9e9e2b09e28 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -3,7 +3,7 @@ * Copyright (C) 2002-2003 Jean-Louis Bergamo * Copyright (C) 2004-2015 Laurent Destailleur * Copyright (C) 2004 Eric Seigne - * Copyright (C) 2005-2016 Regis Houssin + * Copyright (C) 2005-2017 Regis Houssin * Copyright (C) 2005 Lionel Cousteix * Copyright (C) 2011 Herve Prot * Copyright (C) 2012 Juanjo Menent @@ -57,6 +57,12 @@ $subaction = GETPOST('subaction','alpha'); $group = GETPOST("group","int",3); $cancel = GETPOST('cancel'); +// Users/Groups management only in master entity if transverse mode +if (($action == 'create' || $action == 'adduserldap') && ! empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE) +{ + accessforbidden(); +} + // Define value to know what current user can do on users $canadduser=(! empty($user->admin) || $user->rights->user->user->creer); $canreaduser=(! empty($user->admin) || $user->rights->user->user->lire); @@ -228,11 +234,11 @@ if (empty($reshook)) { // Set entity property $entity = GETPOST('entity', 'int'); - if (!empty($conf->multicompany->enabled)) { - if (!empty($_POST["superadmin"])) { + if (! empty($conf->multicompany->enabled)) { + if (GETPOST('superadmin', 'int')) { $object->entity = 0; } else { - if ($conf->multicompany->transverse_mode) { + if (! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { $object->entity = 1; // all users are forced into master entity } else { $object->entity = ($entity == '' ? 1 : $entity); @@ -249,8 +255,8 @@ if (empty($reshook)) { $id = $object->create($user); if ($id > 0) { - if (isset($_POST['password']) && trim($_POST['password'])) { - $object->setPassword($user, trim($_POST['password'])); + if (GETPOST('password')) { + $object->setPassword($user, GETPOST('password')); } if (! empty($conf->categorie->enabled)) { // Categories association @@ -283,10 +289,10 @@ if (empty($reshook)) { $object->fetch($id); if ($action == 'addgroup') { - $object->SetInGroup($group, ($conf->multicompany->transverse_mode ? GETPOST("entity") : $editgroup->entity)); + $object->SetInGroup($group, (! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) ? GETPOST('entity', 'int') : $editgroup->entity)); } if ($action == 'removegroup') { - $object->RemoveFromGroup($group, ($conf->multicompany->transverse_mode ? GETPOST("entity") : $editgroup->entity)); + $object->RemoveFromGroup($group, (! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) ? GETPOST('entity', 'int') : $editgroup->entity)); } if ($result > 0) { @@ -300,7 +306,7 @@ if (empty($reshook)) { } } - if ($action == 'update' && ! $cancel) + if ($action == 'update' && ! $cancel) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -319,7 +325,7 @@ if (empty($reshook)) { $error ++; } - if (!$error) + if (!$error) { $object->fetch($id); @@ -367,7 +373,7 @@ if (empty($reshook)) { { $object->entity = 0; } - else if ($conf->multicompany->transverse_mode) + else if (! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { $object->entity = 1; // all users in master entity } @@ -409,7 +415,7 @@ if (empty($reshook)) { } } - if (!$error && isset($_POST['contactid'])) { + if (!$error && GETPOST('contactid', 'int')) { $contactid = GETPOST('contactid', 'int'); if ($contactid > 0) { @@ -456,7 +462,7 @@ if (empty($reshook)) { setEventMessages($langs->trans("ErrorFailedToSaveFile"), null, 'errors'); } else { // Create thumbs - $object->addThumbs($newfile); + $object->addThumbs($newfile); } } else { $error ++; @@ -465,7 +471,7 @@ if (empty($reshook)) { } } } - + if (! $error && ! count($object->errors)) { // Then we add the associated categories @@ -476,7 +482,7 @@ if (empty($reshook)) { if (!$error && !count($object->errors)) { setEventMessages($langs->trans("UserModified"), null, 'mesgs'); $db->commit(); - + $login = $_SESSION["dol_login"]; if ($login && $login == $object->oldcopy->login && $object->oldcopy->login != $object->login) // Current user has changed its login { @@ -495,11 +501,11 @@ if (empty($reshook)) { if ($caneditpassword) // Case we can edit only password { dol_syslog("Not allowed to change fields, only password"); - + $object->fetch($id); - + $object->oldcopy = clone $object; - + $ret = $object->setPassword($user, GETPOST("password")); if ($ret < 0) { @@ -591,14 +597,14 @@ if (empty($reshook)) { setEventMessages($ldap->error, $ldap->errors, 'errors'); } } - + // Actions to send emails $trigger_name='USER_SENTBYMAIL'; $paramname='id'; // Name of param key to open the card $mode='emailfromuser'; $trackid='use'.$object->id; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; - + // Actions to build doc $upload_dir = $conf->user->dir_output; $permissioncreate=$user->rights->user->user->creer; @@ -617,7 +623,7 @@ $formfile = new FormFile($db); llxHeader('',$langs->trans("UserCard")); -if (($action == 'create') || ($action == 'adduserldap')) +if ($action == 'create' || $action == 'adduserldap') { /* ************************************************************************** */ /* */ @@ -858,7 +864,7 @@ if (($action == 'create') || ($action == 'adduserldap')) print ''; print $form->selectyesno('admin',GETPOST('admin'),1); - if (! empty($conf->multicompany->enabled) && ! $user->entity && empty($conf->multicompany->transverse_mode)) + if (! empty($conf->multicompany->enabled) && ! $user->entity && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { if (! empty($conf->use_javascript_ajax)) { @@ -888,8 +894,8 @@ if (($action == 'create') || ($action == 'adduserldap')) }); '; } - $checked=($_POST["superadmin"]?' checked':''); - $disabled=($_POST["superadmin"]?'':' disabled'); + $checked=(GETPOST('superadmin', 'int')?' checked':''); + $disabled=(GETPOST('superadmin', 'int')?'':' disabled'); print ' '.$langs->trans("SuperAdministrator"); } print "\n"; @@ -1005,9 +1011,9 @@ if (($action == 'create') || ($action == 'adduserldap')) print ''; // Multicompany - if (! empty($conf->multicompany->enabled)) + if (! empty($conf->multicompany->enabled) && is_object($mc)) { - if (empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity && is_object($mc)) + if (empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && ! $user->entity) { print "".''.$langs->trans("Entity").''; print "".$mc->select_entities($conf->entity); @@ -1027,9 +1033,9 @@ if (($action == 'create') || ($action == 'adduserldap')) print ''; print ''; } - + // TODO Move this into tab RH (HierarchicalResponsible must be on both tab) - + // Hierarchy print ''.$langs->trans("HierarchicalResponsible").''; print ''; @@ -1076,7 +1082,7 @@ if (($action == 'create') || ($action == 'adduserldap')) print ''; print ''; print "\n"; - + // Date employment print ''.$langs->trans("DateEmployment").''; print ''; @@ -1092,9 +1098,9 @@ if (($action == 'create') || ($action == 'adduserldap')) print $formother->selectColor(GETPOST('color')?GETPOST('color'):$object->color, 'color', null, 1, '', 'hideifnotset'); print ''; } - + // Categories - if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire)) + if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire)) { print '' . fieldLabel('Categories', 'usercats') . ''; $cate_arbo = $form->select_all_categories('user', null, 'parent', null, null, 1); @@ -1110,7 +1116,7 @@ if (($action == 'create') || ($action == 'adduserldap')) { print $object->showOptionals($extrafields,'edit'); } - + // Note print ''; print $langs->trans("Note"); @@ -1127,7 +1133,7 @@ if (($action == 'create') || ($action == 'adduserldap')) $doleditor=new DolEditor('signature',GETPOST('signature'),'',138,'dolibarr_mailings','In',true,true,empty($conf->global->FCKEDITOR_ENABLE_USERSIGN)?0:1,ROWS_4,'90%'); print $doleditor->Create(1); print ''; - + print "\n"; dol_fiche_end(); @@ -1153,7 +1159,7 @@ else $object->fetch($id, '', '', 1); if ($res < 0) { dol_print_error($db,$object->error); exit; } $res=$object->fetch_optionals($object->id,$extralabels); - + // Check if user has rights $object->getrights(); if(empty($object->nb_rights)) setEventMessages($langs->trans('UserHasNoPermissions'), null, 'warnings'); @@ -1226,7 +1232,7 @@ else */ if ($action == 'password') { - print $form->formconfirm("card.php?id=$object->id",$langs->trans("ReinitPassword"),$langs->trans("ConfirmReinitPassword",$object->login),"confirm_password", '', 0, 1); + print $form->formconfirm($_SERVER['PHP_SELF']."?id=$object->id",$langs->trans("ReinitPassword"),$langs->trans("ConfirmReinitPassword",$object->login),"confirm_password", '', 0, 1); } /* @@ -1234,7 +1240,7 @@ else */ if ($action == 'passwordsend') { - print $form->formconfirm("card.php?id=$object->id",$langs->trans("SendNewPassword"),$langs->trans("ConfirmSendNewPassword",$object->login),"confirm_passwordsend", '', 0, 1); + print $form->formconfirm($_SERVER['PHP_SELF']."?id=$object->id",$langs->trans("SendNewPassword"),$langs->trans("ConfirmSendNewPassword",$object->login),"confirm_passwordsend", '', 0, 1); } /* @@ -1242,7 +1248,7 @@ else */ if ($action == 'disable') { - print $form->formconfirm("card.php?id=$object->id",$langs->trans("DisableAUser"),$langs->trans("ConfirmDisableUser",$object->login),"confirm_disable", '', 0, 1); + print $form->formconfirm($_SERVER['PHP_SELF']."?id=$object->id",$langs->trans("DisableAUser"),$langs->trans("ConfirmDisableUser",$object->login),"confirm_disable", '', 0, 1); } /* @@ -1250,7 +1256,7 @@ else */ if ($action == 'enable') { - print $form->formconfirm("card.php?id=$object->id",$langs->trans("EnableAUser"),$langs->trans("ConfirmEnableUser",$object->login),"confirm_enable", '', 0, 1); + print $form->formconfirm($_SERVER['PHP_SELF']."?id=$object->id",$langs->trans("EnableAUser"),$langs->trans("ConfirmEnableUser",$object->login),"confirm_enable", '', 0, 1); } /* @@ -1258,7 +1264,7 @@ else */ if ($action == 'delete') { - print $form->formconfirm("card.php?id=$object->id",$langs->trans("DeleteAUser"),$langs->trans("ConfirmDeleteUser",$object->login),"confirm_delete", '', 0, 1); + print $form->formconfirm($_SERVER['PHP_SELF']."?id=$object->id",$langs->trans("DeleteAUser"),$langs->trans("ConfirmDeleteUser",$object->login),"confirm_delete", '', 0, 1); } /* @@ -1387,7 +1393,7 @@ else print ''.$langs->trans("AccountancyCode").''; print ''.$object->accountancy_code.''; } - + // TODO Move this into tab RH, visible when salarie or RH is visible (HierarchicalResponsible must be on both tab) // Hierarchy @@ -1468,7 +1474,7 @@ else } // Categories - if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire)) + if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire)) { print '' . $langs->trans( "Categories" ) . ''; print ''; @@ -1476,71 +1482,46 @@ else print ''; } - // Multicompany - // TODO This should be done with hook formObjectOption - if (is_object($mc)) - { - if (! empty($conf->multicompany->enabled) && empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity) - { - print ''.$langs->trans("Entity").''; - if (empty($object->entity)) - { - print $langs->trans("AllEntities"); - } - else - { - $mc->getInfo($object->entity); - print $mc->label; - } - print "\n"; - } - } - if (isset($conf->file->main_authentication) && preg_match('/openid/',$conf->file->main_authentication) && ! empty($conf->global->MAIN_OPENIDURL_PERUSER)) { print ''.$langs->trans("OpenIDURL").''; print ''.$object->openid.''; print "\n"; } - + print ''.$langs->trans("LastConnexion").''; print ''.dol_print_date($object->datelastlogin,"dayhour").''; print "\n"; - + print ''.$langs->trans("PreviousConnexion").''; print ''.dol_print_date($object->datepreviouslogin,"dayhour").''; print "\n"; - + // Other attributes - $parameters=array(); - $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook - if (empty($reshook) && ! empty($extrafields->attribute_label)) - { - print $object->showOptionals($extrafields); - } - + include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + // Company / Contact if (! empty($conf->societe->enabled)) { print ''.$langs->trans("LinkToCompanyContact").''; print ''; - if (isset($object->societe_id) && $object->societe_id > 0) + if (isset($object->socid) && $object->socid > 0) { $societe = new Societe($db); - $societe->fetch($object->societe_id); + $societe->fetch($object->socid); print $societe->getNomUrl(1,''); } else { print $langs->trans("ThisUserIsNot"); } - if (! empty($object->contact_id)) + if (! empty($object->contactid)) { $contact = new Contact($db); - $contact->fetch($object->contact_id); - if ($object->societe_id > 0) print ' / '; + $contact->fetch($object->contactid); + if ($object->socid > 0) print ' / '; else print '
'; - print ''.img_object($langs->trans("ShowContact"),'contact').' '.dol_trunc($contact->getFullName($langs),32).''; + print ''.img_object($langs->trans("ShowContact"),'contact').' '.dol_trunc($contact->getFullName($langs),32).''; } print ''; print ''."\n"; @@ -1598,8 +1579,8 @@ else $langs->load("mails"); print ''; } - - if ($caneditfield && (empty($conf->multicompany->enabled) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) + + if ($caneditfield && (empty($conf->multicompany->enabled) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) { if (! empty($conf->global->MAIN_ONLY_LOGIN_ALLOWED)) { @@ -1611,7 +1592,7 @@ else } } elseif ($caneditpassword && ! $object->ldap_sid && - (empty($conf->multicompany->enabled) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) + (empty($conf->multicompany->enabled) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) { print ''; } @@ -1624,7 +1605,7 @@ else print ''; } elseif (($user->id != $id && $caneditpassword) && $object->login && !$object->ldap_sid && - ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) + ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) { print ''; } @@ -1634,7 +1615,7 @@ else print ''; } else if (($user->id != $id && $caneditpassword) && $object->login && !$object->ldap_sid && - ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) + ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) { if ($object->email) print ''; else print ''; @@ -1643,19 +1624,19 @@ else // Activer if ($user->id <> $id && $candisableuser && $object->statut == 0 && - ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) + ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) { print ''; } // Desactiver if ($user->id <> $id && $candisableuser && $object->statut == 1 && - ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) + ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) { print ''; } // Delete if ($user->id <> $id && $candisableuser && - ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) + ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || ! $user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) { if ($user->admin || ! $object->admin) // If user edited is admin, delete is possible on for an admin { @@ -1680,36 +1661,36 @@ else /* * Affiche formulaire mail */ - + // By default if $action=='presend' $titreform='SendMail'; $topicmail=''; $action='send'; $modelmail='user'; - + print '
'; print load_fiche_titre($langs->trans($titreform)); - + dol_fiche_head(); - + // Define output language $outputlangs = $langs; $newlang = ''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang = $_REQUEST['lang_id']; - + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->default_lang; - + // Cree l'objet formulaire mail include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; $formmail = new FormMail($db); $formmail->param['langsmodels']=(empty($newlang)?$langs->defaultlang:$newlang); $formmail->fromtype = (GETPOST('fromtype')?GETPOST('fromtype'):(!empty($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE)?$conf->global->MAIN_MAIL_DEFAULT_FROMTYPE:'user')); - + if($formmail->fromtype === 'user'){ $formmail->fromid = $user->id; - + } $formmail->trackid='thi'.$object->id; if (! empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 2)) // If bit 2 is set @@ -1733,40 +1714,40 @@ else $formmail->substit['__FIRSTNAME__']=$object->firstname; $formmail->substit['__SIGNATURE__']=$user->signature; $formmail->substit['__PERSONALIZED__']=''; - + //Find the good contact adress /* $custcontact=''; $contactarr=array(); $contactarr=$object->liste_contact(-1,'external'); - + if (is_array($contactarr) && count($contactarr)>0) { foreach($contactarr as $contact) { if ($contact['libelle']==$langs->trans('TypeContact_facture_external_BILLING')) { - + require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php'; - + $contactstatic=new Contact($db); $contactstatic->fetch($contact['id']); $custcontact=$contactstatic->getFullName($langs,1); } } - + if (!empty($custcontact)) { $formmail->substit['__CONTACTCIVNAME__']=$custcontact; } }*/ - - + + // Tableau des parametres complementaires du post $formmail->param['action']=$action; $formmail->param['models']=$modelmail; $formmail->param['models_id']=GETPOST('modelmailselected','int'); $formmail->param['socid']=$object->id; $formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?id='.$object->id; - + // Init list of files if (GETPOST("mode")=='init') { @@ -1774,7 +1755,7 @@ else $formmail->add_attached_files($file,basename($file),dol_mimetype($file)); } print $formmail->get_form(); - + dol_fiche_end(); } @@ -1783,20 +1764,20 @@ else /* * List of groups of user */ - + if ($canreadgroup) { print load_fiche_titre($langs->trans("ListOfGroupsForUser"),'',''); - + // On selectionne les groupes auquel fait parti le user $exclude = array(); - + $usergroup=new UserGroup($db); $groupslist = $usergroup->listGroupsForUser($object->id); - + if (! empty($groupslist)) { - if (! (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode))) + if (! (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))) { foreach($groupslist as $groupforuser) { @@ -1804,46 +1785,54 @@ else } } } - + if ($caneditgroup) { print '
'."\n"; print ''; print ''; } - + print ''."\n"; print ''."\n"; - if(! empty($conf->multicompany->enabled) && !empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity) + if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && ! $user->entity) { print ''; } print ''; - print "'; + print "'."\n"; - + /* * Groups assigned to user */ @@ -1851,8 +1840,8 @@ else { foreach($groupslist as $group) { - - + + print ''; print ''; - if (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity) + if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && ! $user->entity) { print ''; } - + print "
'.$langs->trans("Groups").''.$langs->trans("Entity").''; if ($caneditgroup) { - print $form->select_dolgroups('', 'group', 1, $exclude, 0, '', '', $object->entity); - print '   '; - // Multicompany - if (! empty($conf->multicompany->enabled)) - { - if ($conf->entity == 1 && $conf->multicompany->transverse_mode) - { - print ''.$langs->trans("Entity").'".$mc->select_entities($conf->entity); - } - else - { - print ''; - } - } - else - { - print ''; - } - print ''; + // Users/Groups management only in master entity if transverse mode + if (! empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE) + { + // nothing + } + else + { + print $form->select_dolgroups('', 'group', 1, $exclude, 0, '', '', $object->entity); + print '   '; + // Multicompany + if (! empty($conf->multicompany->enabled)) + { + if ($conf->entity == 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE) + { + print ''.$langs->trans("Entity").'".$mc->select_entities($conf->entity); + } + else + { + print ''; + } + } + else + { + print ''; + } + print ''; + } } print '
'; if ($caneditgroup) @@ -1864,7 +1853,7 @@ else print img_object($langs->trans("ShowGroup"),"group").' '.$group->name; } print ''; if (! empty($group->usergroup_entity)) @@ -1882,7 +1871,7 @@ else } } print ''; - if ($caneditgroup && empty($conf->multicompany->transverse_mode)) + if ($caneditgroup && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { print ''; print img_delete($langs->trans("RemoveFromGroup")); @@ -1899,9 +1888,9 @@ else { print '
'.$langs->trans("None").'
"; - + if ($caneditgroup) { print '
'; @@ -1910,7 +1899,7 @@ else } } } - + /* * Fiche en mode edition */ @@ -2030,7 +2019,7 @@ else print "\n"; // API key - if(! empty($conf->api->enabled) && $user->admin) + if(! empty($conf->api->enabled) && $user->admin) { print ''.$langs->trans("ApiKey").''; print ''; @@ -2042,7 +2031,7 @@ else // Administrator print ''.$langs->trans("Administrator").''; - if ($object->societe_id > 0) + if ($object->socid > 0) { $langs->load("admin"); print ''; @@ -2067,7 +2056,7 @@ else { print $form->selectyesno('admin',$object->admin,1); - if (! empty($conf->multicompany->enabled) && ! $user->entity && empty($conf->multicompany->transverse_mode)) + if (! empty($conf->multicompany->enabled) && ! $user->entity && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { if ($conf->use_javascript_ajax) { @@ -2129,7 +2118,7 @@ else if ($user->id == $object->id || ! $user->admin) { $type=$langs->trans("Internal"); - if ($object->societe_id) $type=$langs->trans("External"); + if ($object->socid) $type=$langs->trans("External"); print $form->textwithpicto($type,$langs->trans("InternalExternalDesc")); if ($object->ldap_sid) print ' ('.$langs->trans("DomainUser").')'; } @@ -2280,9 +2269,9 @@ else print ''; print ""; } - + // TODO Move this into tab RH (HierarchicalResponsible must be on both tab) - + // Hierarchy print ''.$langs->trans("HierarchicalResponsible").''; print ''; @@ -2355,7 +2344,7 @@ else print $formother->selectColor(GETPOST('color')?GETPOST('color'):$object->color, 'color', null, 1, '', 'hideifnotset'); print ''; } - + // Photo print ''; print ''.$langs->trans("Photo").''; @@ -2363,9 +2352,9 @@ else print $form->showphoto('userphoto',$object,60,0,$caneditfield,'photowithmargin','small'); print ''; print ''; - + // Categories - if (!empty( $conf->categorie->enabled ) && !empty( $user->rights->categorie->lire )) + if (!empty( $conf->categorie->enabled ) && !empty( $user->rights->categorie->lire )) { print '' . fieldLabel( 'Categories', 'usercats' ) . ''; print ''; @@ -2390,16 +2379,16 @@ else { print ''.$langs->trans("LinkToCompanyContact").''; print ''; - if ($object->societe_id > 0) + if ($object->socid > 0) { $societe = new Societe($db); - $societe->fetch($object->societe_id); + $societe->fetch($object->socid); print $societe->getNomUrl(1,''); - if ($object->contact_id) + if ($object->contactid) { $contact = new Contact($db); - $contact->fetch($object->contact_id); - print ' / '.img_object($langs->trans("ShowContact"),'contact').' '.dol_trunc($contact->getFullName($langs),32).''; + $contact->fetch($object->contactid); + print ' / '.img_object($langs->trans("ShowContact"),'contact').' '.dol_trunc($contact->getFullName($langs),32).''; } } else @@ -2432,25 +2421,10 @@ else print "\n"; } - // Multicompany - // TODO check if user not linked with the current entity before change entity (thirdparty, invoice, etc.) !! - if (! empty($conf->multicompany->enabled) && is_object($mc)) - { - if (empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity) - { - print "".''.$langs->trans("Entity").''; - print "".$mc->select_entities($object->entity, 'entity', '', 0, 1); // last parameter 1 means, show also a choice 0=>'all entities' - print "\n"; - } - else - { - print ''; - } - } - // Other attributes $parameters=array('colspan' => ' colspan="2"'); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; if (empty($reshook) && ! empty($extrafields->attribute_label)) { print $object->showOptionals($extrafields,'edit'); @@ -2470,7 +2444,7 @@ else print dol_htmlentitiesbr($object->signature); } print ''; - + print ''; dol_fiche_end(); @@ -2495,27 +2469,28 @@ else $urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id; $genallowed = $user->rights->user->user->creer; $delallowed = $user->rights->user->user->supprimer; - - $somethingshown = $formfile->show_documents('user', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', 0, '', $soc->default_lang); - + + print $formfile->showdocuments('user', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', 0, '', $soc->default_lang); + $somethingshown = $formfile->numoffiles; + // Show links to link elements $linktoelem = $form->showLinkToObjectBlock($object, null, null); $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); - + print '
'; - + // List of actions on element include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; $formactions = new FormActions($db); $somethingshown = $formactions->showactions($object, 'user', $socid); - - + + print '
'; } - + if (! empty($conf->ldap->enabled) && ! empty($object->ldap_sid)) $ldap->close(); } - + } if (! empty($conf->api->enabled) && ! empty($conf->use_javascript_ajax)) diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 869059d359b..a69ed968dfb 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -107,16 +107,16 @@ class User extends CommonObject public $all_permissions_are_loaded; // All permission are loaded public $nb_rights; // Number of rights granted to the user private $_tab_loaded=array(); // Cache array of already loaded permissions - + public $conf; // To store personal config public $default_values; // To store default values for user public $lastsearch_values_tmp; // To store current search criterias for user public $lastsearch_values; // To store last saved search criterias for user - + public $users; // To store all tree of users hierarchy public $parentof; // To store an array of all parents for all ids. private $cache_childids; - + public $accountancy_code; // Accountancy code in prevision of the complete accountancy module public $thm; // Average cost of employee - Used for valuation of time spent @@ -207,7 +207,7 @@ class User extends CommonObject if ($entity < 0) { - if ((empty($conf->multicompany->enabled) || empty($conf->multicompany->transverse_mode)) && (! empty($user->entity))) + if ((empty($conf->multicompany->enabled) || empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) && (! empty($user->entity))) { $sql.= " WHERE u.entity IN (0,".$conf->entity.")"; } @@ -218,7 +218,7 @@ class User extends CommonObject } else // The fetch was forced on an entity { - if (!empty($conf->multicompany->enabled) && !empty($conf->multicompany->transverse_mode)) + if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) $sql.= " WHERE u.entity IS NOT NULL"; // multicompany is on in transverse mode or user making fetch is on entity 0, so user is allowed to fetch anywhere into database else $sql.= " WHERE u.entity IN (0, ".$conf->entity.")"; @@ -365,7 +365,7 @@ class User extends CommonObject $this->error=$this->db->lasterror(); return -2; } - + // Load user->default_values for user. TODO Save this in memcached ? $sql = "SELECT rowid, entity, type, page, param, value"; $sql.= " FROM ".MAIN_DB_PREFIX."default_values"; @@ -376,7 +376,7 @@ class User extends CommonObject { while ($obj = $this->db->fetch_object($resql)) { - if (! empty($obj->page) && ! empty($obj->type) && ! empty($obj->param)) + if (! empty($obj->page) && ! empty($obj->type) && ! empty($obj->param)) { $this->default_values[$obj->page][$obj->type][$obj->param]=$obj->value; } @@ -389,7 +389,7 @@ class User extends CommonObject return -3; } } - + return 1; } @@ -469,9 +469,9 @@ class User extends CommonObject $obj = $this->db->fetch_object($result); $nid = $obj->id; - $sql = "DELETE FROM ".MAIN_DB_PREFIX."user_rights WHERE fk_user = ".$this->id." AND fk_id=".$nid; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."user_rights WHERE fk_user = ".$this->id." AND fk_id=".$nid." AND entity = ".$entity; if (! $this->db->query($sql)) $error++; - $sql = "INSERT INTO ".MAIN_DB_PREFIX."user_rights (fk_user, fk_id) VALUES (".$this->id.", ".$nid.")"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."user_rights (entity, fk_user, fk_id) VALUES (".$entity.", ".$this->id.", ".$nid.")"; if (! $this->db->query($sql)) $error++; $i++; @@ -581,6 +581,7 @@ class User extends CommonObject $sql = "DELETE FROM ".MAIN_DB_PREFIX."user_rights"; $sql.= " WHERE fk_user = ".$this->id." AND fk_id=".$nid; + $sql.= " AND entity = ".$entity; if (! $this->db->query($sql)) $error++; $i++; @@ -660,7 +661,7 @@ class User extends CommonObject $sql.= " FROM ".MAIN_DB_PREFIX."user_rights as ur"; $sql.= ", ".MAIN_DB_PREFIX."rights_def as r"; $sql.= " WHERE r.id = ur.fk_id"; - $sql.= " AND r.entity IN (0,".(! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)?"1,":"").$conf->entity.")"; + $sql.= " AND ur.entity = ".$conf->entity; $sql.= " AND ur.fk_user= ".$this->id; $sql.= " AND r.perms IS NOT NULL"; if ($moduletag) $sql.= " AND r.module = '".$this->db->escape($moduletag)."'"; @@ -706,11 +707,8 @@ class User extends CommonObject $sql.= " ".MAIN_DB_PREFIX."usergroup_user as gu,"; $sql.= " ".MAIN_DB_PREFIX."rights_def as r"; $sql.= " WHERE r.id = gr.fk_id"; - if (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)) { - $sql.= " AND gu.entity IN (0,".$conf->entity.")"; - } else { - $sql.= " AND r.entity = ".$conf->entity; - } + $sql.= " AND gr.entity = ".$conf->entity; + $sql.= " AND r.entity = ".$conf->entity; $sql.= " AND gr.fk_usergroup = gu.fk_usergroup"; $sql.= " AND gu.fk_user = ".$this->id; $sql.= " AND r.perms IS NOT NULL"; @@ -2014,14 +2012,14 @@ class User extends CommonObject $result=''; $label=''; $link=''; $linkstart=''; $linkend=''; - + if (! empty($this->photo)) { $label.= '
'; $label.= Form::showphoto('userphoto', $this, 80, 0, 0, 'photowithmargin photologintooltip', 'small', 0, 1); $label.= '
'; } - + $label.= '
'; $label.= '' . $langs->trans("User") . '
'; $label.= '' . $langs->trans('Name') . ': ' . $this->getFullName($langs,'',''); @@ -2112,9 +2110,9 @@ class User extends CommonObject } $result.=$linkend; //if ($withpictoimg == -1) $result.='
'; - + $result.=$companylink; - + return $result; } @@ -2573,7 +2571,7 @@ class User extends CommonObject // Init $this->users array $sql = "SELECT DISTINCT u.rowid, u.firstname, u.lastname, u.fk_user, u.fk_soc, u.login, u.email, u.gender, u.admin, u.statut, u.photo, u.entity"; // Distinct reduce pb with old tables with duplicates $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; - if(! empty($conf->multicompany->enabled) && $conf->entity == 1 && (! empty($conf->multicompany->transverse_mode) || (! empty($user->admin) && empty($user->entity)))) + if(! empty($conf->multicompany->enabled) && $conf->entity == 1 && (! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) || (! empty($user->admin) && empty($user->entity)))) { $sql.= " WHERE u.entity IS NOT NULL"; } diff --git a/htdocs/user/class/usergroup.class.php b/htdocs/user/class/usergroup.class.php index af73e1305bb..be9bb0e1f4c 100644 --- a/htdocs/user/class/usergroup.class.php +++ b/htdocs/user/class/usergroup.class.php @@ -39,7 +39,7 @@ class UserGroup extends CommonObject protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe public $picto='group'; public $entity; // Entity of group - + /** * @deprecated * @see name @@ -252,16 +252,19 @@ class UserGroup extends CommonObject /** * Add a permission to a group * - * @param int $rid id du droit a ajouter - * @param string $allmodule Ajouter tous les droits du module allmodule - * @param string $allperms Ajouter tous les droits du module allmodule, perms allperms - * @return int > 0 if OK, < 0 if KO + * @param int $rid id du droit a ajouter + * @param string $allmodule Ajouter tous les droits du module allmodule + * @param string $allperms Ajouter tous les droits du module allmodule, perms allperms + * @param int $entity Entity to use + * @return int > 0 if OK, < 0 if KO */ - function addrights($rid,$allmodule='',$allperms='') + function addrights($rid, $allmodule='', $allperms='', $entity=0) { global $conf, $user, $langs; - dol_syslog(get_class($this)."::addrights $rid, $allmodule, $allperms"); + $entity = (! empty($entity)?$entity:$conf->entity); + + dol_syslog(get_class($this)."::addrights $rid, $allmodule, $allperms, $entity"); $error=0; $whereforadd=''; @@ -274,7 +277,7 @@ class UserGroup extends CommonObject $sql = "SELECT module, perms, subperms"; $sql.= " FROM ".MAIN_DB_PREFIX."rights_def"; $sql.= " WHERE id = '".$this->db->escape($rid)."'"; - $sql.= " AND entity = ".$conf->entity; + $sql.= " AND entity = ".$entity; $result=$this->db->query($sql); if ($result) { @@ -311,7 +314,7 @@ class UserGroup extends CommonObject $sql = "SELECT id"; $sql.= " FROM ".MAIN_DB_PREFIX."rights_def"; $sql.= " WHERE $whereforadd"; - $sql.= " AND entity = ".$conf->entity; + $sql.= " AND entity = ".$entity; $result=$this->db->query($sql); if ($result) @@ -323,9 +326,9 @@ class UserGroup extends CommonObject $obj = $this->db->fetch_object($result); $nid = $obj->id; - $sql = "DELETE FROM ".MAIN_DB_PREFIX."usergroup_rights WHERE fk_usergroup = $this->id AND fk_id=".$nid; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."usergroup_rights WHERE fk_usergroup = $this->id AND fk_id=".$nid." AND entity = ".$entity; if (! $this->db->query($sql)) $error++; - $sql = "INSERT INTO ".MAIN_DB_PREFIX."usergroup_rights (fk_usergroup, fk_id) VALUES ($this->id, $nid)"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."usergroup_rights (entity, fk_usergroup, fk_id) VALUES (".$entity.", ".$this->id.", ".$nid.")"; if (! $this->db->query($sql)) $error++; $i++; @@ -363,18 +366,21 @@ class UserGroup extends CommonObject /** * Remove a permission from group * - * @param int $rid id du droit a retirer - * @param string $allmodule Retirer tous les droits du module allmodule - * @param string $allperms Retirer tous les droits du module allmodule, perms allperms - * @return int > 0 if OK, < 0 if OK + * @param int $rid id du droit a retirer + * @param string $allmodule Retirer tous les droits du module allmodule + * @param string $allperms Retirer tous les droits du module allmodule, perms allperms + * @param int $entity Entity to use + * @return int > 0 if OK, < 0 if OK */ - function delrights($rid,$allmodule='',$allperms='') + function delrights($rid, $allmodule='', $allperms='', $entity=0) { global $conf, $user, $langs; $error=0; $wherefordel=''; + $entity = (! empty($entity)?$entity:$conf->entity); + $this->db->begin(); if (! empty($rid)) @@ -384,7 +390,7 @@ class UserGroup extends CommonObject $sql = "SELECT module, perms, subperms"; $sql.= " FROM ".MAIN_DB_PREFIX."rights_def"; $sql.= " WHERE id = '".$this->db->escape($rid)."'"; - $sql.= " AND entity = ".$conf->entity; + $sql.= " AND entity = ".$entity; $result=$this->db->query($sql); if ($result) { @@ -421,7 +427,7 @@ class UserGroup extends CommonObject $sql = "SELECT id"; $sql.= " FROM ".MAIN_DB_PREFIX."rights_def"; $sql.= " WHERE $wherefordel"; - $sql.= " AND entity = ".$conf->entity; + $sql.= " AND entity = ".$entity; $result=$this->db->query($sql); if ($result) @@ -435,6 +441,7 @@ class UserGroup extends CommonObject $sql = "DELETE FROM ".MAIN_DB_PREFIX."usergroup_rights"; $sql.= " WHERE fk_usergroup = $this->id AND fk_id=".$nid; + $sql.= " AND entity = ".$entity; if (! $this->db->query($sql)) $error++; $i++; @@ -498,6 +505,7 @@ class UserGroup extends CommonObject $sql.= " FROM ".MAIN_DB_PREFIX."usergroup_rights as u, ".MAIN_DB_PREFIX."rights_def as r"; $sql.= " WHERE r.id = u.fk_id"; $sql.= " AND r.entity = ".$conf->entity; + $sql.= " AND u.entity = ".$conf->entity; $sql.= " AND u.fk_usergroup = ".$this->id; $sql.= " AND r.perms IS NOT NULL"; if ($moduletag) $sql.= " AND r.module = '".$this->db->escape($moduletag)."'"; @@ -755,7 +763,7 @@ class UserGroup extends CommonObject { return $this->LibStatut(0,$mode); } - + /** * Renvoi le libelle d'un statut donne * @@ -769,7 +777,7 @@ class UserGroup extends CommonObject $langs->load('users'); return ''; } - + /** * Retourne chaine DN complete dans l'annuaire LDAP pour l'objet * @@ -849,7 +857,7 @@ class UserGroup extends CommonObject $user->id => $user ); } - + /** * Create a document onto disk according to template module. * diff --git a/htdocs/user/group/card.php b/htdocs/user/group/card.php index bbcbd38c168..8be0276e6ee 100644 --- a/htdocs/user/group/card.php +++ b/htdocs/user/group/card.php @@ -1,7 +1,7 @@ * Copyright (C) 2005-2015 Laurent Destailleur - * Copyright (C) 2005-2015 Regis Houssin + * Copyright (C) 2005-2017 Regis Houssin * Copyright (C) 2011 Herve Prot * Copyright (C) 2012 Florian Henry * @@ -54,7 +54,8 @@ $userid=GETPOST('user', 'int'); // Security check $result = restrictedArea($user, 'user', $id, 'usergroup&usergroup', 'user'); -if (! empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->multicompany->transverse_mode) +// Users/Groups management only in master entity if transverse mode +if (! empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE) { accessforbidden(); } @@ -105,7 +106,7 @@ if ($action == 'add') $ret = $extrafields->setOptionalsFromPost($extralabels,$object); if ($ret < 0) $error++; - if (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)) $object->entity = 0; + if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) $object->entity = 0; else $object->entity = $_POST["entity"]; $db->begin(); @@ -148,8 +149,8 @@ if ($action == 'adduser' || $action =='removeuser') $edituser = new User($db); $edituser->fetch($userid); - if ($action == 'adduser') $result=$edituser->SetInGroup($object->id,(! empty($conf->multicompany->transverse_mode)?GETPOST('entity','int'):$object->entity)); - if ($action == 'removeuser') $result=$edituser->RemoveFromGroup($object->id,(! empty($conf->multicompany->transverse_mode)?GETPOST('entity','int'):$object->entity)); + if ($action == 'adduser') $result=$edituser->SetInGroup($object->id,(! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)?GETPOST('entity','int'):$object->entity)); + if ($action == 'removeuser') $result=$edituser->RemoveFromGroup($object->id,(! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)?GETPOST('entity','int'):$object->entity)); if ($result > 0) { @@ -188,7 +189,7 @@ if ($action == 'update') $ret = $extrafields->setOptionalsFromPost($extralabels,$object); if ($ret < 0) $error++; - if (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)) $object->entity = 0; + if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) $object->entity = 0; else $object->entity = $_POST["entity"]; $ret=$object->update(); @@ -210,7 +211,7 @@ if ($action == 'update') setEventMessages($langs->trans('ErrorForbidden'), null, 'mesgs'); } } - + // Actions to build doc $upload_dir = $conf->usergroup->dir_output; $permissioncreate=$user->rights->user->user->creer; @@ -250,7 +251,7 @@ if ($action == 'create') // Multicompany if (! empty($conf->multicompany->enabled) && is_object($mc)) { - if (empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity) + if (empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && ! $user->entity) { print "".''.$langs->trans("Entity").''; print "".$mc->select_entities($conf->entity); @@ -317,10 +318,10 @@ else dol_fiche_head($head, 'group', $title, -1, 'group'); dol_banner_tab($object,'id','',$user->rights->user->user->lire || $user->admin); - + print '
'; print '
'; - + print ''; // Name @@ -333,7 +334,7 @@ else print "\n"; // Multicompany - if (! empty($conf->multicompany->enabled) && is_object($mc) && empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity) + if (! empty($conf->multicompany->enabled) && is_object($mc) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && ! $user->entity) { $mc->getInfo($object->entity); print "".''; @@ -348,15 +349,11 @@ else // Other attributes $parameters=array('colspan' => ' colspan="2"'); - $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook - if (empty($reshook) && ! empty($extrafields->attribute_label)) - { - print $object->showOptionals($extrafields); - } + include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; print "
'.$langs->trans("Entity").'
\n"; print '
'; - + dol_fiche_end(); @@ -386,7 +383,7 @@ else if (! empty($object->members)) { - if (! (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode))) + if (! (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))) { foreach($object->members as $useringroup) { @@ -408,7 +405,7 @@ else // Multicompany if (! empty($conf->multicompany->enabled) && is_object($mc)) { - if ($conf->entity == 1 && $conf->multicompany->transverse_mode) + if ($conf->entity == 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE) { print ''.$langs->trans("Entity").''; print "".$mc->select_entities($conf->entity); @@ -448,7 +445,7 @@ else { foreach($object->members as $useringroup) { - + print ''; print ''; @@ -458,7 +455,7 @@ else print ''; print ''.$useringroup->lastname.''; print ''.$useringroup->firstname.''; - if (! empty($conf->multicompany->enabled) && is_object($mc) && ! empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity) + if (! empty($conf->multicompany->enabled) && is_object($mc) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && ! $user->entity) { print ''; if (! empty($useringroup->usergroup_entity)) @@ -497,7 +494,7 @@ else } print ""; print "
"; - + /* * Documents generes */ @@ -506,21 +503,21 @@ else $urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id; $genallowed = $user->rights->user->user->creer; $delallowed = $user->rights->user->user->supprimer; - + $somethingshown = $formfile->show_documents('usergroup', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', 0, '', $soc->default_lang); - + // Show links to link elements $linktoelem = $form->showLinkToObjectBlock($object, null, null); $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); - + print '
'; - + // List of actions on element include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; $formactions = new FormActions($db); $somethingshown = $formactions->showactions($object, 'usergroup', $socid); - - + + print '
'; } @@ -543,7 +540,7 @@ else // Multicompany if (! empty($conf->multicompany->enabled) && is_object($mc)) { - if (empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity) + if (empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && ! $user->entity) { print "".''.$langs->trans("Entity").''; print "".$mc->select_entities($object->entity); diff --git a/htdocs/user/group/index.php b/htdocs/user/group/index.php index 38fdf68b2ba..16091381e8d 100644 --- a/htdocs/user/group/index.php +++ b/htdocs/user/group/index.php @@ -32,6 +32,12 @@ if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS)) accessforbidden(); } +// Users/Groups management only in master entity if transverse mode +if (! empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE) +{ + accessforbidden(); +} + $langs->load("users"); $sall=GETPOST('sall', 'alphanohtml'); @@ -95,7 +101,7 @@ llxHeader(); $sql = "SELECT g.rowid, g.nom as name, g.entity, g.datec, COUNT(DISTINCT ugu.fk_user) as nb"; $sql.= " FROM ".MAIN_DB_PREFIX."usergroup as g"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_usergroup = g.rowid"; -if (! empty($conf->multicompany->enabled) && $conf->entity == 1 && ($conf->multicompany->transverse_mode || ($user->admin && ! $user->entity))) +if (! empty($conf->multicompany->enabled) && $conf->entity == 1 && ($conf->global->MULTICOMPANY_TRANSVERSE_MODE || ($user->admin && ! $user->entity))) { $sql.= " WHERE g.entity IS NOT NULL"; } @@ -160,7 +166,7 @@ if ($resql) print ''; print_liste_field_titre($langs->trans("Group"),$_SERVER["PHP_SELF"],"g.nom",$param,"","",$sortfield,$sortorder); //multicompany - if(! empty($conf->multicompany->enabled) && empty($conf->multicompany->transverse_mode) && $conf->entity == 1) + if(! empty($conf->multicompany->enabled) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1) { print_liste_field_titre($langs->trans("Entity"),$_SERVER["PHP_SELF"],"g.entity",$param,"",'align="center"',$sortfield,$sortorder); } @@ -172,7 +178,7 @@ if ($resql) while ($i < $num) { $obj = $db->fetch_object($resql); - + print ''; print ''.img_object($langs->trans("ShowGroup"),"group").' '.$obj->name.''; @@ -182,7 +188,7 @@ if ($resql) } print ""; //multicompany - if (! empty($conf->multicompany->enabled) && is_object($mc) && empty($conf->multicompany->transverse_mode) && $conf->entity == 1) + if (! empty($conf->multicompany->enabled) && is_object($mc) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1) { $mc->getInfo($obj->entity); print ''.$mc->label.''; diff --git a/htdocs/user/group/ldap.php b/htdocs/user/group/ldap.php index 2ced8e11d4b..6d987be85cb 100644 --- a/htdocs/user/group/ldap.php +++ b/htdocs/user/group/ldap.php @@ -1,6 +1,6 @@ - * Copyright (C) 2006-2012 Regis Houssin + * Copyright (C) 2006-2017 Regis Houssin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -33,6 +33,12 @@ $langs->load("companies"); $langs->load("ldap"); $langs->load("users"); +// Users/Groups management only in master entity if transverse mode +if (! empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE) +{ + accessforbidden(); +} + $canreadperms=true; if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS)) { @@ -98,7 +104,7 @@ $head = group_prepare_head($object); dol_fiche_head($head, 'ldap', $langs->trans("Group"), -1, 'group'); dol_banner_tab($object,'id','',$user->rights->user->user->lire || $user->admin); - + print '
'; print '
'; diff --git a/htdocs/user/group/perms.php b/htdocs/user/group/perms.php index 5262857afb2..77532de7c3e 100644 --- a/htdocs/user/group/perms.php +++ b/htdocs/user/group/perms.php @@ -3,7 +3,7 @@ * Copyright (C) 2002-2003 Jean-Louis Bergamo * Copyright (C) 2004-2010 Laurent Destailleur * Copyright (C) 2004 Eric Seigne - * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2005-2017 Regis Houssin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -38,6 +38,12 @@ $confirm=GETPOST('confirm', 'alpha'); $module=GETPOST('module', 'alpha'); $rights=GETPOST('rights', 'int'); +// Users/Groups management only in master entity if transverse mode +if (! empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE) +{ + accessforbidden(); +} + // Defini si peux lire les permissions $canreadperms=($user->admin || $user->rights->user->user->lire); // Defini si peux modifier les permissions @@ -53,22 +59,44 @@ if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS)) if (! $canreadperms) accessforbidden(); +$object = new Usergroup($db); +$object->fetch($id); +$object->getrights(); + +$entity=$conf->entity; +if (! empty($conf->multicompany->enabled)) +{ + if (! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) + $entity=(GETPOST('entity','int') ? GETPOST('entity','int') : $conf->entity); + else + $entity=(! empty($object->entity) ? $object->entity : $conf->entity); +} + +// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +$hookmanager->initHooks(array('groupcard','globalcard')); + /** * Actions */ -if ($action == 'addrights' && $caneditperms) -{ - $editgroup = new Usergroup($db); - $result=$editgroup->fetch($id); - if ($result > 0) $editgroup->addrights($rights, $module); -} +$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 ($action == 'delrights' && $caneditperms) -{ - $editgroup = new Usergroup($db); - $result=$editgroup->fetch($id); - if ($result > 0) $editgroup->delrights($rights, $module); +if (empty($reshook)) { + if ($action == 'addrights' && $caneditperms) + { + $editgroup = new Usergroup($db); + $result=$editgroup->fetch($id); + if ($result > 0) $editgroup->addrights($rights, $module, '', $entity); + } + + if ($action == 'delrights' && $caneditperms) + { + $editgroup = new Usergroup($db); + $result=$editgroup->fetch($id); + if ($result > 0) $editgroup->delrights($rights, $module, '', $entity); + } } @@ -80,12 +108,8 @@ $form = new Form($db); llxHeader('',$langs->trans("Permissions")); -if ($id) +if ($object->id) { - $object = new Usergroup($db); - $object->fetch($id); - $object->getrights(); - /* * Affichage onglets */ @@ -127,7 +151,6 @@ if ($id) // Load all permissions if ($objMod->rights_class) { - $entity=((! empty($conf->multicompany->enabled) && ! empty($object->entity)) ? $object->entity : null); $ret=$objMod->insert_permissions(0, $entity); $modules[$objMod->rights_class]=$objMod; } @@ -140,56 +163,42 @@ if ($id) $db->commit(); // Lecture des droits groupes - $permsgroup = array(); + $permsgroupbyentity = array(); - $sql = "SELECT r.id, r.libelle, r.module "; - $sql.= " FROM ".MAIN_DB_PREFIX."rights_def as r"; - $sql.= ", ".MAIN_DB_PREFIX."usergroup_rights as ugr"; - $sql.= " WHERE ugr.fk_id = r.id"; - if(! empty($conf->multicompany->enabled)) - { - if (empty($conf->multicompany->transverse_mode)) - { - $sql.= " AND r.entity = ".$object->entity; - } - else - { - $sql.= " AND r.entity IN (0,1)"; - } - } - else - { - $sql.= " AND r.entity IN (0,".$conf->entity.")"; - } - - $sql.= " AND ugr.fk_usergroup = ".$object->id; + $sql = "SELECT DISTINCT r.id, r.libelle, r.module, gr.entity"; + $sql.= " FROM ".MAIN_DB_PREFIX."rights_def as r,"; + $sql.= " ".MAIN_DB_PREFIX."usergroup_rights as gr"; + $sql.= " WHERE gr.fk_id = r.id"; + $sql.= " AND gr.entity = ".$entity; + $sql.= " AND gr.fk_usergroup = ".$object->id; + dol_syslog("get user perms", LOG_DEBUG); $result=$db->query($sql); - if ($result) { - $num = $db->num_rows($result); - $i = 0; - while ($i < $num) - { - $obj = $db->fetch_object($result); - array_push($permsgroup,$obj->id); - $i++; - } - $db->free($result); + $num = $db->num_rows($result); + $i = 0; + while ($i < $num) + { + $obj = $db->fetch_object($result); + if (! isset($permsgroupbyentity[$obj->entity])) + $permsgroupbyentity[$obj->entity] = array(); + array_push($permsgroupbyentity[$obj->entity], $obj->id); + $i++; + } + $db->free($result); } else { - dol_print_error($db); + dol_print_error($db); } - - + dol_banner_tab($object,'id','',$user->rights->user->user->lire || $user->admin); - + print '
'; print '
'; - + /* * Ecran ajout/suppression permission */ @@ -214,6 +223,10 @@ if ($id) if ($user->admin) print info_admin($langs->trans("WarningOnlyPermissionOfActivatedModules")); + $parameters=array(); + $reshook=$hookmanager->executeHooks('insertExtraHeader',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + print ''; print ''; print ''; @@ -225,22 +238,7 @@ if ($id) $sql = "SELECT r.id, r.libelle, r.module"; $sql.= " FROM ".MAIN_DB_PREFIX."rights_def as r"; $sql.= " WHERE r.libelle NOT LIKE 'tou%'"; // On ignore droits "tous" - if(! empty($conf->multicompany->enabled)) - { - if (empty($conf->multicompany->transverse_mode)) - { - $sql.= " AND r.entity = ".$object->entity; - } - else - { - $sql.= " AND r.entity IN (0,1)"; - } - } - else - { - $sql.= " AND r.entity = ".$conf->entity; - } - + $sql.= " AND r.entity = " . $entity; if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) $sql.= " AND r.perms NOT LIKE '%_advance'"; // Hide advanced perms if option is disable $sql.= " ORDER BY r.module, r.id"; @@ -279,9 +277,9 @@ if ($id) print ''; print ''; print ''; print ''; @@ -293,25 +291,37 @@ if ($id) // Module print ''; - if (in_array($obj->id, $permsgroup)) + if (is_array($permsgroupbyentity[$entity])) { - // Own permission by group - if ($caneditperms) - { - print ''; - } - print ''; + if (in_array($obj->id, $permsgroupbyentity[$entity])) + { + // Own permission by group + if ($caneditperms) + { + print ''; + } + print ''; + } + else + { + // Do not own permission + if ($caneditperms) + { + print ''; + } + print ''; + } } else { - // Do not own permission - if ($caneditperms) - { - print ''; - } - print ''; + // Do not own permission + if ($caneditperms) + { + print ''; + } + print ''; } $perm_libelle=($conf->global->MAIN_USE_ADVANCED_PERMS && ($langs->trans("PermissionAdvanced".$obj->id)!=("PermissionAdvanced".$obj->id))?$langs->trans("PermissionAdvanced".$obj->id):(($langs->trans("Permission".$obj->id)!=("Permission".$obj->id))?$langs->trans("Permission".$obj->id):$langs->trans($obj->libelle))); @@ -323,9 +333,13 @@ if ($id) } } print '
'.$langs->trans("Module").''.img_object('',$picto).' '.$objMod->getName(); print ' '; - print ''.$langs->trans("All").""; + print 'module.'#'.$objMod->getName().'">'.$langs->trans("All").""; print '/'; - print ''.$langs->trans("None").""; + print 'module.'#'.$objMod->getName().'">'.$langs->trans("None").""; print ' 
'.img_object('',$picto).' '.$objMod->getName().''.img_edit_remove($langs->trans("Remove")).''; - print img_picto($langs->trans("Active"),'tick'); - print 'id.'">'.img_edit_remove($langs->trans("Remove")).''; + print img_picto($langs->trans("Active"),'tick'); + print 'id.'">'.img_edit_add($langs->trans("Add")).' '.img_edit_add($langs->trans("Add")).' id.'">'.img_edit_add($langs->trans("Add")).' 
'; - + print '
'; - + + $parameters=array(); + $reshook=$hookmanager->executeHooks('insertExtraFooter',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + dol_fiche_end(); } diff --git a/htdocs/user/hierarchy.php b/htdocs/user/hierarchy.php index 9e7f6583f6e..3e82e2b6357 100644 --- a/htdocs/user/hierarchy.php +++ b/htdocs/user/hierarchy.php @@ -73,7 +73,7 @@ $user_arbo = $userstatic->get_full_tree(0, ($search_statut != '' && $search_stat if (! is_array($user_arbo) && $user_arbo < 0) { - setEventMessages($userstatic->error, $userstatic->errors, 'warnings'); + setEventMessages($userstatic->error, $userstatic->errors, 'warnings'); } else { @@ -97,24 +97,21 @@ foreach($fulltree as $key => $val) $userstatic->admin=$val['admin']; $userstatic->entity=$val['entity']; $userstatic->photo=$val['photo']; - + $entity=$val['entity']; $entitystring=''; // TODO Set of entitystring should be done with a hook - if (is_object($mc)) + if (! empty($conf->multicompany->enabled) && is_object($mc)) { - if (! empty($conf->multicompany->enabled)) + if (empty($entity)) { - if (empty($entity)) - { - $entitystring=$langs->trans("AllEntities"); - } - else - { - $mc->getInfo($entity); - $entitystring=$mc->label; - } + $entitystring=$langs->trans("AllEntities"); + } + else + { + $mc->getInfo($entity); + $entitystring=$mc->label; } } @@ -128,7 +125,7 @@ foreach($fulltree as $key => $val) $li.=img_picto($langs->trans("Administrator"),'star'); } $li.=' ('.$val['login'].($entitystring?' - '.$entitystring:'').')'; - + $data[] = array( 'rowid'=>$val['rowid'], 'fk_menu'=>$val['fk_user'], diff --git a/htdocs/user/home.php b/htdocs/user/home.php index 66a4448491e..7c464ce2e45 100644 --- a/htdocs/user/home.php +++ b/htdocs/user/home.php @@ -100,7 +100,7 @@ $sql.= ", s.code_client"; $sql.= ", s.canvas"; $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON u.fk_soc = s.rowid"; -if (! empty($conf->multicompany->enabled) && $conf->entity == 1 && ($conf->multicompany->transverse_mode || ($user->admin && ! $user->entity))) +if (! empty($conf->multicompany->enabled) && $conf->entity == 1 && ($conf->global->MULTICOMPANY_TRANSVERSE_MODE || ($user->admin && ! $user->entity))) { $sql.= " WHERE u.entity IS NOT NULL"; } @@ -212,7 +212,7 @@ if ($canreadperms) $sql = "SELECT g.rowid, g.nom as name, g.note, g.entity, g.datec"; $sql.= " FROM ".MAIN_DB_PREFIX."usergroup as g"; - if(! empty($conf->multicompany->enabled) && $conf->entity == 1 && ($conf->multicompany->transverse_mode || ($user->admin && ! $user->entity))) + if(! empty($conf->multicompany->enabled) && $conf->entity == 1 && ($conf->global->MULTICOMPANY_TRANSVERSE_MODE || ($user->admin && ! $user->entity))) { $sql.= " WHERE g.entity IS NOT NULL"; } diff --git a/htdocs/user/index.php b/htdocs/user/index.php index 898851d2108..415665bc5fc 100644 --- a/htdocs/user/index.php +++ b/htdocs/user/index.php @@ -92,7 +92,7 @@ $arrayfields=array( 'u.accountancy_code'=>array('label'=>$langs->trans("AccountancyCode"), 'checked'=>0), 'u.email'=>array('label'=>$langs->trans("EMail"), 'checked'=>1), 'u.fk_soc'=>array('label'=>$langs->trans("Company"), 'checked'=>1), - 'u.entity'=>array('label'=>$langs->trans("Entity"), 'checked'=>1, 'enabled'=>(! empty($conf->multicompany->enabled) && empty($conf->multicompany->transverse_mode))), + 'u.entity'=>array('label'=>$langs->trans("Entity"), 'checked'=>1, 'enabled'=>(! empty($conf->multicompany->enabled) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))), 'u.fk_user'=>array('label'=>$langs->trans("HierarchicalResponsible"), 'checked'=>1), 'u.datelastlogin'=>array('label'=>$langs->trans("LastConnexion"), 'checked'=>1, 'position'=>100), 'u.datepreviouslogin'=>array('label'=>$langs->trans("PreviousConnexion"), 'checked'=>0, 'position'=>110), @@ -194,7 +194,7 @@ $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user_extrafields as ef on (u.rowid = ef.fk_object)"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON u.fk_soc = s.rowid"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u2 ON u.fk_user = u2.rowid"; -if(! empty($conf->multicompany->enabled) && $conf->entity == 1 && (! empty($conf->multicompany->transverse_mode) || (! empty($user->admin) && empty($user->entity)))) +if(! empty($conf->multicompany->enabled) && $conf->entity == 1 && (! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) || (! empty($user->admin) && empty($user->entity)))) { $sql.= " WHERE u.entity IS NOT NULL"; } @@ -545,7 +545,7 @@ while ($i < min($num,$limit)) print ''; } // Multicompany enabled - if (! empty($conf->multicompany->enabled) && empty($conf->multicompany->transverse_mode)) + if (! empty($conf->multicompany->enabled) && is_object($mc) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { if (! empty($arrayfields['u.entity']['checked'])) { @@ -556,12 +556,8 @@ while ($i < min($num,$limit)) } else { - // $mc is defined in conf.class.php if multicompany enabled. - if (is_object($mc)) - { - $mc->getInfo($obj->entity); - print $mc->label; - } + $mc->getInfo($obj->entity); + print $mc->label; } print ''; } @@ -581,7 +577,7 @@ while ($i < min($num,$limit)) $user2->photo=$obj->photo2; $user2->admin=$obj->admin2; $user2->email=$obj->email2; - $user2->societe_id=$obj->fk_soc2; + $user2->socid=$obj->fk_soc2; print $user2->getNomUrl(-1,'',0,0,24,0,''); if (! empty($conf->multicompany->enabled) && $obj->admin2 && ! $obj->entity2) { diff --git a/htdocs/user/perms.php b/htdocs/user/perms.php index b40c79f783e..5de1a3b80ac 100644 --- a/htdocs/user/perms.php +++ b/htdocs/user/perms.php @@ -3,7 +3,7 @@ * Copyright (C) 2002-2003 Jean-Louis Bergamo * Copyright (C) 2004-2015 Laurent Destailleur * Copyright (C) 2004 Eric Seigne - * Copyright (C) 2005-2015 Regis Houssin + * Copyright (C) 2005-2017 Regis Houssin * Copyright (C) 2012 Juanjo Menent * * This program is free software; you can redistribute it and/or modify @@ -38,7 +38,6 @@ $action=GETPOST('action', 'alpha'); $confirm=GETPOST('confirm', 'alpha'); $module=GETPOST('module', 'alpha'); $rights=GETPOST('rights', 'int'); -$entity=(GETPOST('entity','int')?GETPOST('entity','int'):$conf->entity); if (! isset($id) || empty($id)) accessforbidden(); @@ -71,6 +70,15 @@ $object = new User($db); $object->fetch($id, '', '', 1); $object->getrights(); +$entity=$conf->entity; +if (! empty($conf->multicompany->enabled)) +{ + if (! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) + $entity=(GETPOST('entity','int') ? GETPOST('entity','int') : $conf->entity); + else + $entity=(! empty($object->entity) ? $object->entity : $conf->entity); +} + // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array $hookmanager->initHooks(array('usercard','globalcard')); @@ -86,12 +94,11 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (empty($reshook)) { if ($action == 'addrights' && $caneditperms) { $edituser = new User($db); - $edituser->fetch($id); - //$edituser->addrights($rights, $module, '', $entity); // TODO unused for the moment - $edituser->addrights($rights, $module); + $edituser->fetch($object->id); + $edituser->addrights($rights, $module, '', $entity); // Si on a touche a ses propres droits, on recharge - if ($id == $user->id) { + if ($object->id == $user->id) { $user->clearrights(); $user->getrights(); $menumanager->loadMenu(); @@ -100,12 +107,11 @@ if (empty($reshook)) { if ($action == 'delrights' && $caneditperms) { $edituser = new User($db); - $edituser->fetch($id); - //$edituser->delrights($rights, $module, '', $entity); // TODO unused for the moment - $edituser->delrights($rights, $module); + $edituser->fetch($object->id); + $edituser->delrights($rights, $module, '', $entity); // Si on a touche a ses propres droits, on recharge - if ($id == $user->id) { + if ($object->id == $user->id) { $user->clearrights(); $user->getrights(); $menumanager->loadMenu(); @@ -161,8 +167,7 @@ foreach($modulesdir as $dir) // Load all permissions if ($objMod->rights_class) { - $forceEntity=((! empty($conf->multicompany->enabled) && ! empty($object->entity)) ? $object->entity : null); - $ret=$objMod->insert_permissions(0, $forceEntity); + $ret=$objMod->insert_permissions(0, $entity); $modules[$objMod->rights_class]=$objMod; //print "modules[".$objMod->rights_class."]=$objMod;"; } @@ -177,22 +182,11 @@ $db->commit(); // Lecture des droits utilisateurs $permsuser = array(); -$sql = "SELECT r.id, r.libelle, r.module"; +$sql = "SELECT DISTINCT r.id, r.libelle, r.module"; $sql.= " FROM ".MAIN_DB_PREFIX."rights_def as r,"; $sql.= " ".MAIN_DB_PREFIX."user_rights as ur"; $sql.= " WHERE ur.fk_id = r.id"; -if (! empty($conf->multicompany->enabled)) -{ - if (1==2 && ! empty($conf->multicompany->transverse_mode)) { - $sql.= " AND r.entity = ".(GETPOST('entity','int')?GETPOST('entity','int'):$conf->entity); // TODO unused for the moment - } else { - $sql.= " AND r.entity = ".(! empty($object->entity) ? $object->entity : $conf->entity); - } -} -else -{ - $sql.= " AND r.entity = ".$conf->entity; -} +$sql.= " AND ur.entity = ".$entity; $sql.= " AND ur.fk_user = ".$object->id; dol_syslog("get user perms", LOG_DEBUG); @@ -216,18 +210,13 @@ else // Lecture des droits groupes $permsgroupbyentity = array(); -$aEntities = array(); -$sql = "SELECT r.id, r.libelle, r.module, gu.entity"; +$sql = "SELECT DISTINCT r.id, r.libelle, r.module, gu.entity"; $sql.= " FROM ".MAIN_DB_PREFIX."rights_def as r,"; $sql.= " ".MAIN_DB_PREFIX."usergroup_rights as gr,"; $sql.= " ".MAIN_DB_PREFIX."usergroup_user as gu"; $sql.= " WHERE gr.fk_id = r.id"; -if (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)) { - $sql.= " AND gu.entity IS NOT NULL"; -} else { - $sql.= " AND r.entity = ".((! empty($conf->multicompany->enabled) && ! empty($object->entity)) ? $object->entity : $conf->entity); -} +$sql.= " AND gr.entity = ".$entity; $sql.= " AND gr.fk_usergroup = gu.fk_usergroup"; $sql.= " AND gu.fk_user = ".$object->id; @@ -272,17 +261,10 @@ if ($user->admin) print info_admin($langs->trans("WarningOnlyPermissionOfActivat // Show warning about external users if (empty($user->societe_id)) print info_admin(showModulesExludedForExternal($modules))."\n"; -// For multicompany transversal mode -// TODO Place a hook here -if (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)) -{ - $aEntities=array_keys($permsgroupbyentity); - sort($aEntities); - $entity = (GETPOST('entity', 'int')?GETPOST('entity', 'int'):$aEntities[0]); - $head = entity_prepare_head($object, $aEntities); - $title = $langs->trans("Entities"); - dol_fiche_head($head, $entity, $title, 1, 'multicompany@multicompany'); -} +$parameters=array('permsgroupbyentity'=>$permsgroupbyentity); +$reshook=$hookmanager->executeHooks('insertExtraHeader',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + print "\n"; print ''; @@ -297,7 +279,7 @@ print ''."\n"; $sql = "SELECT r.id, r.libelle, r.module"; $sql.= " FROM ".MAIN_DB_PREFIX."rights_def as r"; $sql.= " WHERE r.libelle NOT LIKE 'tou%'"; // On ignore droits "tous" -$sql.= " AND r.entity = ".((! empty($conf->multicompany->enabled) && ! empty($object->entity)) ? $object->entity : $conf->entity); +$sql.= " AND r.entity = " . $entity; if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) $sql.= " AND r.perms NOT LIKE '%_advance'"; // Hide advanced perms if option is disable $sql.= " ORDER BY r.module, r.id"; @@ -336,9 +318,9 @@ if ($result) print ''; print ''; print ''; print ''."\n"; @@ -365,7 +347,7 @@ if ($result) { if ($caneditperms) { - print ''; + print ''; } print ''; + print ''; } print ''; } @@ -401,7 +383,7 @@ if ($result) // Do not own permission if ($caneditperms) { - print ''; + print ''; } print ''; } @@ -417,13 +399,10 @@ if ($result) else dol_print_error($db); print '
'.img_object('',$picto).' '.$objMod->getName(); print ''; - print ''.$langs->trans("All").""; + print 'module.'">'.$langs->trans("All").""; print '/'; - print ''.$langs->trans("None").""; + print 'module.'">'.$langs->trans("None").""; print ' 
'.img_edit_remove($langs->trans("Remove")).'id.'">'.img_edit_remove($langs->trans("Remove")).''; print img_picto($langs->trans("Active"),'tick'); @@ -391,7 +373,7 @@ if ($result) // Do not own permission if ($caneditperms) { - print ''.img_edit_add($langs->trans("Add")).'id.'">'.img_edit_add($langs->trans("Add")).' '.img_edit_add($langs->trans("Add")).'id.'">'.img_edit_add($langs->trans("Add")).' 
'; +$parameters=array(); +$reshook=$hookmanager->executeHooks('insertExtraFooter',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -// For multicompany transversal mode -// TODO Place a hook here -if (! empty($conf->multicompany->enabled) && ! empty($conf->multicompany->transverse_mode)) -{ - dol_fiche_end(); -} dol_fiche_end(); diff --git a/htdocs/webservices/server_user.php b/htdocs/webservices/server_user.php index c4d8ce08724..3de5ef815c9 100644 --- a/htdocs/webservices/server_user.php +++ b/htdocs/webservices/server_user.php @@ -416,7 +416,7 @@ function getListOfGroups($authentication) $sql = "SELECT g.rowid, g.nom as name, g.entity, g.datec, COUNT(DISTINCT ugu.fk_user) as nb"; $sql.= " FROM ".MAIN_DB_PREFIX."usergroup as g"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_usergroup = g.rowid"; - if (! empty($conf->multicompany->enabled) && $conf->entity == 1 && ($conf->multicompany->transverse_mode || ($user->admin && ! $user->entity))) + if (! empty($conf->multicompany->enabled) && $conf->entity == 1 && ($conf->global->MULTICOMPANY_TRANSVERSE_MODE || ($user->admin && ! $user->entity))) { $sql.= " WHERE g.entity IS NOT NULL"; }