Merge branch 'develop' of https://github.com/Dolibarr/dolibarr into new_event_with_multi_contact

This commit is contained in:
phf 2017-06-08 12:03:59 +02:00
commit d6d451b54a
113 changed files with 3315 additions and 3345 deletions

View File

@ -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 *****

View File

@ -2,7 +2,7 @@
/* Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2016 Laurent Destailleur <eldy@users.sourceforge.net>
*
* 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 '</td>';
print '<td align="right">';
print price($total_debit);
print '</td>';
print '<td align="right">';
print '<td align="right">';
print price($total_credit);
print '</td>';
print '<td></td>';
print '<td colspan="2"></td>';
print '</tr>';
print "</table>";

View File

@ -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;
}

View File

@ -45,10 +45,13 @@ $langs->load("compta");
$langs->load("banks");
$langs->load("loans");
/*
* Actions
*/
// None
/*
* View
@ -73,35 +76,31 @@ print "<br>\n";
$step++;
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescJournalSetup", $step, '<strong>'.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("AccountingJournals").'</strong>');
print "<br>\n";
print "<br>\n";
$step++;
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescChartModel", $step, '<strong>'.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("Pcg_version").'</strong>');
print "<br>\n";
print "<br>\n";
$step++;
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescChart", $step, '<strong>'.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("Chartofaccounts").'</strong>');
print "<br>\n";
print "<br>\n";
print "<br>\n";
print $langs->trans("AccountancyAreaDescActionOnceBis");
print "<br>\n";
print "<br>\n";
$step++;
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescMisc", $step, '<strong>'.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").'</strong>')."<br>\n";
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescMisc", $step, '<strong>'.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").'</strong>')."\n";
print "<br>\n";
$step++;
$textlink = '<strong>'.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup").'-'.$langs->transnoentitiesnoconv("MenuVatAccounts").'</strong>';
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescVat", $step, $textlink);
print "<br>\n";
print "<br>\n";
if (! empty($conf->tax->enabled))
{
$textlink = '<strong>'.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup").'-'.$langs->transnoentitiesnoconv("MenuTaxAccounts").'</strong>';
$step++;
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescContrib", $step, $textlink);
print "<br>\n";
print "<br>\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, '<strong>'.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuExpenseReportAccounts").'</strong>');
print "<br>\n";
print "<br>\n";
}
/*
if (! empty($conf->loan->enabled))
@ -124,26 +122,22 @@ if (! empty($conf->loan->enabled))
$step++;
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescLoan", $step, '<strong>'.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuSpecialExpenses").'-'.$langs->transnoentitiesnoconv("Loans").'</strong> '.$langs->transnoentitiesnoconv("or").' <strong>'.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").'</strong>');
print "<br>\n";
print "<br>\n";
}
if (! empty($conf->don->enabled))
{
$step++;
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescDonation", $step, '<strong>'.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDonationAccounts").'</strong>');
print "<br>\n";
print "<br>\n";
}*/
$step++;
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescProd", $step, '<strong>'.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("ProductsBinding").'</strong>');
print "<br>\n";
print "<br>\n";
$step++;
$textlink='<strong>'.$langs->transnoentitiesnoconv("MenuBankCash").'</strong>';
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBank", $step, $textlink);
print "<br>\n";
print "<br>\n";
print "<br>\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"), '<strong>'.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy")."-".$langs->transnoentitiesnoconv("CustomersVentilation").'</strong>')."<br>\n";
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBind", chr(64+$step), $langs->transnoentitiesnoconv("BillsCustomers"), '<strong>'.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy")."-".$langs->transnoentitiesnoconv("CustomersVentilation").'</strong>')."\n";
print "<br>\n";
$step++;
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBind", chr(64+$step), $langs->transnoentitiesnoconv("BillsSuppliers"), '<strong>'.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy")."-".$langs->transnoentitiesnoconv("SuppliersVentilation").'</strong>')."<br>\n";
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBind", chr(64+$step), $langs->transnoentitiesnoconv("BillsSuppliers"), '<strong>'.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy")."-".$langs->transnoentitiesnoconv("SuppliersVentilation").'</strong>')."\n";
print "<br>\n";
$step++;
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBind", chr(64+$step), $langs->transnoentitiesnoconv("ExpenseReports"), '<strong>'.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy")."-".$langs->transnoentitiesnoconv("ExpenseReportsVentilation").'</strong>')."<br>\n";
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBind", chr(64+$step), $langs->transnoentitiesnoconv("ExpenseReports"), '<strong>'.$langs->transnoentitiesnoconv("MenuFinancial").'-'.$langs->transnoentitiesnoconv("MenuAccountancy")."-".$langs->transnoentitiesnoconv("ExpenseReportsVentilation").'</strong>')."\n";
print "<br>\n";
$step++;
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescWriteRecords", chr(64+$step), $langs->transnoentitiesnoconv("Journalization"), $langs->transnoentitiesnoconv("WriteBookKeeping"))."<br>\n";
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescWriteRecords", chr(64+$step), $langs->transnoentitiesnoconv("Journalization"), $langs->transnoentitiesnoconv("WriteBookKeeping"))."\n";
print "<br>\n";
$step++;

View File

@ -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 '<input type="button" class="butAction" style="float: right;" value="' . $langs->trans("Export") . '" onclick="launch_export();" />';
}*/
print '<div class="tabsAction">';
print '<div class="tabsAction">';
print '<input type="button" class="butAction" value="' . $langs->trans("WriteBookKeeping") . '" onclick="writebookkeeping();" />';
print '</div>';
print '</div>';
// TODO Avoid using js. We can use a direct link with $param
print '
<script type="text/javascript">
function launch_export() {
console.log("Set value into form and submit");
$("div.fiche div.tabBar form input[name=\"action\"]").val("export_csv");
console.log("Set value into form and submit");
$("div.fiche div.tabBar form input[name=\"action\"]").val("export_csv");
$("div.fiche div.tabBar form input[type=\"submit\"]").click();
$("div.fiche div.tabBar form input[name=\"action\"]").val("");
$("div.fiche div.tabBar form input[name=\"action\"]").val("");
}
function writebookkeeping() {
console.log("Set value into form and submit");
$("div.fiche div.tabBar form input[name=\"action\"]").val("writebookkeeping");
console.log("Set value into form and submit");
$("div.fiche div.tabBar form input[name=\"action\"]").val("writebookkeeping");
$("div.fiche div.tabBar form input[type=\"submit\"]").click();
$("div.fiche div.tabBar form input[name=\"action\"]").val("");
$("div.fiche div.tabBar form input[name=\"action\"]").val("");
}
</script>';
@ -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 '<tr class="oddeven">';
print "<td><!-- Bank bank.rowid=".$key."--></td>";
print "<td>" . $date . "</td>";
print '<tr class="oddeven">';
print "<td><!-- Bank bank.rowid=".$key."--></td>";
print "<td>" . $date . "</td>";
print "<td>" . $ref . "</td>";
print "<td>";
$accountoshow = length_accountg($k);
if (empty($accountoshow) || $accountoshow == 'NotDefined')
{
print '<span class="error">'.$langs->trans("BankAccountNotDefined").'</span>';
print '<span class="error">'.$langs->trans("BankAccountNotDefined").'</span>';
}
else print $accountoshow;
print "</td>";
@ -947,12 +947,12 @@ if (empty($action) || $action == 'view') {
print "<td>" . $date . "</td>";
print "<td>" . $ref . "</td>";
print "<td>";
$accountoshow = length_accounta($k);
if (empty($accountoshow) || $accountoshow == 'NotDefined')
{
print '<span class="error">'.$langs->trans("ThirdpartyAccountNotDefined").'</span>';
}
else print $accountoshow;
$accountoshow = length_accounta($k);
if (empty($accountoshow) || $accountoshow == 'NotDefined')
{
print '<span class="error">'.$langs->trans("ThirdpartyAccountNotDefined").'</span>';
}
else print $accountoshow;
print "</td>";
print "<td>" . $reflabel . ' ' . $val['soclib'] . "</td>";
print "<td>" . $val["type_payment"] . "</td>";
@ -968,10 +968,10 @@ if (empty($action) || $action == 'view') {
print "<td>" . $date . "</td>";
print "<td>" . $ref . "</td>";
print "<td>";
if (empty($accountoshow) || $accountoshow == 'NotDefined')
{
print '<span class="error">'.$langs->trans("WaitAccountNotDefined").'</span>';
}
if (empty($accountoshow) || $accountoshow == 'NotDefined')
{
print '<span class="error">'.$langs->trans("WaitAccountNotDefined").'</span>';
}
else print length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE);
print "</td>";
print "<td>" . $reflabel . "</td>";

View File

@ -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 = '';

View File

@ -1,11 +1,11 @@
<?php
/* Copyright (C) 2007-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2007-2010 Jean Heimburger <jean@tiaris.info>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2012 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2013-2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
/* Copyright (C) 2007-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2007-2010 Jean Heimburger <jean@tiaris.info>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2012 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2013-2015 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro>
*
* 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 '<input type="button" class="butActionRefused" style="float: right;" value="' . $langs->trans("Export") . '" disabled="disabled" title="' . $langs->trans('ExportNotSupported') . '"/>';
@ -511,21 +518,21 @@ if (empty($action) || $action == 'view') {
print '<input type="button" class="butAction" style="float: right;" value="' . $langs->trans("Export") . '" onclick="launch_export();" />';
}*/
print '<div class="tabsAction">';
print '<div class="tabsAction">';
print '<input type="button" class="butAction" value="' . $langs->trans("WriteBookKeeping") . '" onclick="writebookkeeping();" />';
print '</div>';
print '</div>';
print '
<script type="text/javascript">
function launch_export() {
$("div.fiche div.tabBar form input[name=\"action\"]").val("export_csv");
$("div.fiche div.tabBar form input[name=\"action\"]").val("export_csv");
$("div.fiche div.tabBar form input[type=\"submit\"]").click();
$("div.fiche div.tabBar form input[name=\"action\"]").val("");
$("div.fiche div.tabBar form input[name=\"action\"]").val("");
}
function writebookkeeping() {
$("div.fiche div.tabBar form input[name=\"action\"]").val("writebookkeeping");
$("div.fiche div.tabBar form input[name=\"action\"]").val("writebookkeeping");
$("div.fiche div.tabBar form input[type=\"submit\"]").click();
$("div.fiche div.tabBar form input[name=\"action\"]").val("");
$("div.fiche div.tabBar form input[name=\"action\"]").val("");
}
</script>';
@ -537,7 +544,6 @@ if (empty($action) || $action == 'view') {
$i = 0;
print "<table class=\"noborder\" width=\"100%\">";
print "<tr class=\"liste_titre\">";
// /print "<td>".$langs->trans("JournalNum")."</td>";
print "<td></td>";
print "<td>" . $langs->trans("Date") . "</td>";
print "<td>" . $langs->trans("Piece") . ' (' . $langs->trans("InvoiceRef") . ")</td>";
@ -574,12 +580,12 @@ if (empty($action) || $action == 'view') {
print "<td>" . $date . "</td>";
print "<td>" . $invoicestatic->getNomUrl(1) . "</td>";
print "<td>";
$accountoshow = length_accountg($k);
if (empty($accountoshow) || $accountoshow == 'NotDefined')
{
print '<span class="error">'.$langs->trans("ProductAccountNotDefined").'</span>';
}
else print $accountoshow;
$accountoshow = length_accountg($k);
if (empty($accountoshow) || $accountoshow == 'NotDefined')
{
print '<span class="error">'.$langs->trans("ProductAccountNotDefined").'</span>';
}
else print $accountoshow;
print "</td>";
$companystatic->id = $tabcompany[$key]['id'];
$companystatic->name = $tabcompany[$key]['name'];
@ -590,6 +596,7 @@ if (empty($action) || $action == 'view') {
print "</tr>";
}
}
// VAT
foreach ( $tabtva[$key] as $k => $mt ) {
if ($mt) {
@ -598,12 +605,12 @@ if (empty($action) || $action == 'view') {
print "<td>" . $date . "</td>";
print "<td>" . $invoicestatic->getNomUrl(1) . "</td>";
print "<td>";
$accountoshow = length_accountg($k);
if (empty($accountoshow) || $accountoshow == 'NotDefined')
{
print '<span class="error">'.$langs->trans("VatAccountNotDefined").'</span>';
}
else print $accountoshow;
$accountoshow = length_accountg($k);
if (empty($accountoshow) || $accountoshow == 'NotDefined')
{
print '<span class="error">'.$langs->trans("VatAccountNotDefined").'</span>';
}
else print $accountoshow;
print "</td>";
print "<td>" . $companystatic->getNomUrl(0, 'supplier', 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("VAT"). ' '.$def_tva[$key]. "</td>";
print '<td align="right">' . ($mt >= 0 ? price($mt) : '') . "</td>";
@ -614,9 +621,9 @@ if (empty($action) || $action == 'view') {
// Third party
foreach ( $tabttc[$key] as $k => $mt ) {
print '<tr class="oddeven">';
print "<td><!-- Thirdparty --></td>";
print "<td>" . $date . "</td>";
print '<tr class="oddeven">';
print "<td><!-- Thirdparty --></td>";
print "<td>" . $date . "</td>";
print "<td>" . $invoicestatic->getNomUrl(1) . "</td>";
$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 '<span class="error">'.$langs->trans("ThirdpartyAccountNotDefined").'</span>';
print '<span class="error">'.$langs->trans("ThirdpartyAccountNotDefined").'</span>';
}
else print $accountoshow;
print "</td>";
print "</td>";
print "<td>" . $companystatic->getNomUrl(0, 'supplier', 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("Code_tiers") . "</td>";
// print "</td><td>" . $langs->trans("ThirdParty");
// print ' (' . $companystatic->getNomUrl(0, 'supplier', 16) . ')';

View File

@ -1,13 +1,13 @@
<?php
/* Copyright (C) 2007-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2007-2010 Jean Heimburger <jean@tiaris.info>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2012 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2013 Christophe Battarel <christophe.battarel@altairis.fr>
* Copyright (C) 2013-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
* Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
/* Copyright (C) 2007-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2007-2010 Jean Heimburger <jean@tiaris.info>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2012 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2013 Christophe Battarel <christophe.battarel@altairis.fr>
* Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
*
* 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 '<input type="button" class="butActionRefused" style="float: right;" value="' . $langs->trans("Export") . '" disabled="disabled" title="' . $langs->trans('ExportNotSupported') . '"/>';
} else {
print '<input type="button" class="butAction" style="float: right;" value="' . $langs->trans("Export") . '" onclick="launch_export();" />';
}*/
print '<div class="tabsAction">';
print '<div class="tabsAction">';
print '<input type="button" class="butAction" value="' . $langs->trans("WriteBookKeeping") . '" onclick="writebookkeeping();" />';
print '</div>';
print '</div>';
print '
<script type="text/javascript">
function launch_export() {
$("div.fiche div.tabBar form input[name=\"action\"]").val("export_csv");
$("div.fiche div.tabBar form input[name=\"action\"]").val("export_csv");
$("div.fiche div.tabBar form input[type=\"submit\"]").click();
$("div.fiche div.tabBar form input[name=\"action\"]").val("");
$("div.fiche div.tabBar form input[name=\"action\"]").val("");
}
function writebookkeeping() {
$("div.fiche div.tabBar form input[name=\"action\"]").val("writebookkeeping");
$("div.fiche div.tabBar form input[name=\"action\"]").val("writebookkeeping");
$("div.fiche div.tabBar form input[type=\"submit\"]").click();
$("div.fiche div.tabBar form input[name=\"action\"]").val("");
$("div.fiche div.tabBar form input[name=\"action\"]").val("");
}
</script>';
@ -586,7 +596,7 @@ if (empty($action) || $action == 'view') {
$accountoshow = length_accounta($k);
if (empty($accountoshow) || $accountoshow == 'NotDefined')
{
print '<span class="error">'.$langs->trans("ThirdpartyAccountNotDefined").'</span>';
print '<span class="error">'.$langs->trans("ThirdpartyAccountNotDefined").'</span>';
}
else print $accountoshow;
// print "</td><td>" . $langs->trans("ThirdParty");
@ -595,7 +605,7 @@ if (empty($action) || $action == 'view') {
print "<td>" . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers") . "</td>";
print "<td align='right'>" . ($mt >= 0 ? price($mt) : '') . "</td>";
print "<td align='right'>" . ($mt < 0 ? price(- $mt) : '') . "</td>";
print "</tr>";
print "</tr>";
}
// Product / Service
@ -609,12 +619,12 @@ if (empty($action) || $action == 'view') {
print "<td>" . $date . "</td>";
print "<td>" . $invoicestatic->getNomUrl(1) . "</td>";
print "<td>";
$accountoshow = length_accountg($k);
if (empty($accountoshow) || $accountoshow == 'NotDefined')
{
print '<span class="error">'.$langs->trans("ProductNotDefined").'</span>';
}
else print $accountoshow;
$accountoshow = length_accountg($k);
if (empty($accountoshow) || $accountoshow == 'NotDefined')
{
print '<span class="error">'.$langs->trans("ProductNotDefined").'</span>';
}
else print $accountoshow;
print "</td>";
// print "<td>" . $accountingaccount->label . "</td>";
print "<td>" . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref . ' - ' . $accountingaccount->label . "</td>";
@ -632,12 +642,12 @@ if (empty($action) || $action == 'view') {
print "<td>" . $date . "</td>";
print "<td>" . $invoicestatic->getNomUrl(1) . "</td>";
print "<td>";
$accountoshow = length_accountg($k);
if (empty($accountoshow) || $accountoshow == 'NotDefined')
{
print '<span class="error">'.$langs->trans("VATAccountNotDefined").'</span>';
}
else print $accountoshow;
$accountoshow = length_accountg($k);
if (empty($accountoshow) || $accountoshow == 'NotDefined')
{
print '<span class="error">'.$langs->trans("VATAccountNotDefined").'</span>';
}
else print $accountoshow;
print "</td>";
print "<td>" . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT") . ' '.$def_tva[$key]. "</td>";
// print "<td>" . $langs->trans("VAT") . "</td>";

View File

@ -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 '<input size="30" maxsize="32" type="text" name="password" value="'.$generated_password.'">';
print '</td></tr>';
}
// Type
print '<tr><td class="fieldrequired">'.$langs->trans("MemberType").'</td><td>';
$listetype=$adht->liste_array();
@ -948,20 +948,6 @@ else
print $object->showOptionals($extrafields,'edit');
}
/*
// Third party Dolibarr
if (! empty($conf->societe->enabled))
{
print '<tr><td>'.$langs->trans("LinkedToDolibarrThirdParty").'</td><td class="valeur">';
print $form->select_company($object->fk_soc,'socid','',1);
print '</td></tr>';
}
// Login Dolibarr
print '<tr><td>'.$langs->trans("LinkedToDolibarrUser").'</td><td class="valeur">';
print $form->select_dolusers($object->user_id, 'userid', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300');
print '</td></tr>';
*/
print '<tbody>';
print "</table>\n";
@ -1061,12 +1047,12 @@ else
print '<table class="border" width="100%">';
// Ref
print '<tr><td class="titlefieldcreate">'.$langs->trans("Ref").'</td><td class="valeur" colspan="2">'.$object->id.'</td></tr>';
print '<tr><td class="titlefieldcreate">'.$langs->trans("Ref").'</td><td class="valeur">'.$object->id.'</td></tr>';
// Login
if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED))
{
print '<tr><td><span class="fieldrequired">'.$langs->trans("Login").' / '.$langs->trans("Id").'</span></td><td colspan="2"><input type="text" name="login" class="maxwidth200" value="'.(isset($_POST["login"])?GETPOST("login",'alpha',2):$object->login).'"></td></tr>';
print '<tr><td><span class="fieldrequired">'.$langs->trans("Login").' / '.$langs->trans("Id").'</span></td><td><input type="text" name="login" class="maxwidth200" value="'.(isset($_POST["login"])?GETPOST("login",'alpha',2):$object->login).'"></td></tr>';
}
// Password
@ -1095,7 +1081,7 @@ else
print "</td></tr>";
// Company
print '<tr><td id="tdcompany">'.$langs->trans("Company").'</td><td><input type="text" name="societe" size="40" value="'.(isset($_POST["societe"])?GETPOST("societe",'',2):$object->societe).'"></td></tr>';
print '<tr><td id="tdcompany">'.$langs->trans("Company").'</td><td><input type="text" name="societe" class="minwidth100" value="'.(isset($_POST["societe"])?GETPOST("societe",'',2):$object->societe).'"></td></tr>';
// Civility
print '<tr><td>'.$langs->trans("UserTitle").'</td><td>';
@ -1104,11 +1090,11 @@ else
print '</tr>';
// Lastname
print '<tr><td id="tdlastname">'.$langs->trans("Lastname").'</td><td><input type="text" name="lastname" size="40" value="'.(isset($_POST["lastname"])?GETPOST("lastname",'',2):$object->lastname).'"></td>';
print '<tr><td id="tdlastname">'.$langs->trans("Lastname").'</td><td><input type="text" name="lastname" class="minwidth100" value="'.(isset($_POST["lastname"])?GETPOST("lastname",'',2):$object->lastname).'"></td>';
print '</tr>';
// Firstname
print '<tr><td id="tdfirstname">'.$langs->trans("Firstname").'</td><td><input type="text" name="firstname" size="40" value="'.(isset($_POST["firstname"])?GETPOST("firstname",'',3):$object->firstname).'"></td>';
print '<tr><td id="tdfirstname">'.$langs->trans("Firstname").'</td><td><input type="text" name="firstname" class="minwidth100" value="'.(isset($_POST["firstname"])?GETPOST("firstname",'',3):$object->firstname).'"></td>';
print '</tr>';
// Photo
@ -1131,7 +1117,7 @@ else
// Address
print '<tr><td>'.$langs->trans("Address").'</td><td>';
print '<textarea name="address" wrap="soft" class="quatrevingtpercent" rows="2">'.(isset($_POST["address"])?GETPOST("address",'',2):$object->address).'</textarea>';
print '<textarea name="address" wrap="soft" class="quatrevingtpercent" rows="'.ROWS_2.'">'.(isset($_POST["address"])?GETPOST("address",'',2):$object->address).'</textarea>';
print '</td></tr>';
// 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 '<tr><td width="25%">'.$langs->trans('Country').'</td><td>';
print '<tr><td>'.$langs->trans('Country').'</td><td>';
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 '</td></tr>';
@ -1168,7 +1154,7 @@ else
// Skype
if (! empty($conf->skype->enabled))
{
print '<tr><td>'.$langs->trans("Skype").'</td><td><input type="text" name="skype" size="40" value="'.(isset($_POST["skype"])?GETPOST("skype"):$object->skype).'"></td></tr>';
print '<tr><td>'.$langs->trans("Skype").'</td><td><input type="text" name="skype" class="minwidth100" value="'.(isset($_POST["skype"])?GETPOST("skype"):$object->skype).'"></td></tr>';
}
// Birthday
@ -1185,7 +1171,7 @@ else
if (! empty( $conf->categorie->enabled ) && !empty( $user->rights->categorie->lire ))
{
print '<tr><td>' . fieldLabel('Categories', 'memcats') . '</td>';
print '<td colspan="2">';
print '<td>';
$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 = '<a href="'.DOL_URL_ROOT.'/adherents/list.php">'.$langs->trans("BackToList").'</a>';
dol_banner_tab($object, 'rowid', $linkback);
print '<div class="fichecenter">';
print '<div class="fichehalfleft">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border centpercent">';
@ -1463,15 +1449,15 @@ else
}
print '</td></tr>';
}
print '</table>';
print '</div>';
print '<div class="fichehalfright"><div class="ficheaddleft">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border tableforfield" width="100%">';
// Birthday
print '<tr><td class="titlefield">'.$langs->trans("Birthday").'</td><td class="valeur">'.dol_print_date($object->birth,'day').'</td></tr>';
@ -1487,13 +1473,8 @@ else
print '</td></tr>';
}
// 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 '<tr><td>'.$langs->trans("SubscriptionEndDate").'</td><td class="valeur">';
@ -1518,7 +1499,7 @@ else
}
}
print '</td></tr>';
// Third party Dolibarr
if (! empty($conf->societe->enabled))
{
@ -1595,12 +1576,12 @@ else
print '<div style="clear:both"></div>';
dol_fiche_end();
/*
* Hotbar
*/
print '<div class="tabsAction">';
$parameters = array();
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been
@ -1616,7 +1597,7 @@ else
{
print '<div class="inline-block divButAction"><font class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("Modify").'</font></div>';
}
// Validate
if ($object->statut == -1)
{
@ -1629,7 +1610,7 @@ else
print '<div class="inline-block divButAction"><font class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("Validate").'</font></div>';
}
}
// Reactivate
if ($object->statut == 0)
{
@ -1642,7 +1623,7 @@ else
print '<div class="inline-block divButAction"><font class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("Reenable")."</font></div>";
}
}
// Send card by email
if ($user->rights->adherent->creer)
{
@ -1660,7 +1641,7 @@ else
{
print '<div class="inline-block divButAction"><font class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("SendCardByMail")."</font></div>";
}
// Terminate
if ($object->statut >= 1)
{
@ -1673,7 +1654,7 @@ else
print '<div class="inline-block divButAction"><font class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("Resiliate")."</font></div>";
}
}
// Create third party
if (! empty($conf->societe->enabled) && ! $object->fk_soc)
{
@ -1687,7 +1668,7 @@ else
print '<div class="inline-block divButAction"><font class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("CreateDolibarrThirdParty")."</font></div>";
}
}
// Create user
if (! $user->societe_id && ! $object->user_id)
{
@ -1701,7 +1682,7 @@ else
print '<div class="inline-block divButAction"><font class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("CreateDolibarrLogin")."</font></div>";
}
}
// Delete
if ($user->rights->adherent->supprimer)
{
@ -1711,12 +1692,12 @@ else
{
print '<div class="inline-block divButAction"><font class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("Delete")."</font></div>";
}
// Action SPIP
if (! empty($conf->mailmanspip->enabled) && ! empty($conf->global->ADHERENT_USE_SPIP))
{
$isinspip = $mailmanspip->is_in_spip($object);
if ($isinspip == 1)
{
print '<div class="inline-block divButAction"><a class="butAction" href="card.php?rowid='.$object->id.'&action=del_spip">'.$langs->trans("DeleteIntoSpip")."</a></div>\n";
@ -1726,7 +1707,7 @@ else
print '<div class="inline-block divButAction"><a class="butAction" href="card.php?rowid='.$object->id.'&action=add_spip">'.$langs->trans("AddIntoSpip")."</a></div>\n";
}
}
}
}
print '</div>';
@ -1736,11 +1717,11 @@ else
print '<br><br><font class="error">'.$langs->trans('SPIPConnectionFailed').': '.$mailmanspip->error.'</font>';
}
print '<div class="fichecenter"><div class="fichehalfleft">';
print '<a name="builddoc"></a>'; // 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?'':'<br>').$linktoelem;
// Link for paypal payment
/*
if (! empty($conf->paypal->enabled) && $object->statut != 0) {
@ -1769,15 +1750,15 @@ else
}
*/
print '</div><div class="fichehalfright"><div class="ficheaddleft">';
// 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 '</div></div></div>';
print '</div></div></div>';
}
}

View File

@ -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 = '<a href="'.DOL_URL_ROOT.'/adherents/list.php">'.$langs->trans("BackToList").'</a>';
dol_banner_tab($object, 'rowid', $linkback);
print '<div class="fichecenter">';
print '<div class="fichehalfleft">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
@ -624,13 +624,13 @@ if ($rowid > 0)
}
print '</table>';
print '</div>';
print '<div class="fichehalfright"><div class="ficheaddleft">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border tableforfield" width="100%">';
// Birthday
print '<tr><td class="titlefield">'.$langs->trans("Birthday").'</td><td class="valeur">'.dol_print_date($object->birth,'day').'</td></tr>';
@ -646,13 +646,9 @@ if ($rowid > 0)
print '</td></tr>';
}
// 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 '<tr><td>'.$langs->trans("SubscriptionEndDate").'</td><td class="valeur">';
@ -677,7 +673,7 @@ if ($rowid > 0)
}
}
print '</td></tr>';
// Third party Dolibarr
if (! empty($conf->societe->enabled))
{
@ -752,7 +748,7 @@ if ($rowid > 0)
print "</div></div></div>\n";
print '<div style="clear:both"></div>';
dol_fiche_end();
print '</form>';

View File

@ -336,14 +336,8 @@ if ($rowid > 0)
print '<tr><td class="tdtop">'.$langs->trans("WelcomeEMail").'</td><td>';
print nl2br($object->mail_valid)."</td></tr>";
// 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 '</table>';
print '</div>';
@ -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 '</table>';

View File

@ -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 "</tr>\n";
$var=true;
foreach($boxtoadd as $box)
{
if (preg_match('/^([^@]+)@([^@]+)$/i',$box->boximg))
{
@ -479,7 +479,7 @@ print '</tr>';
// Activate FileCache - Developement
if ($conf->global->MAIN_FEATURES_LEVEL == 2 || ! empty($conf->global->MAIN_ACTIVATE_FILECACHE)) {
print '<tr class="oddeven"><td width="35%">'.$langs->trans("EnableFileCache").'</td><td>';
print $form->selectyesno('MAIN_ACTIVATE_FILECACHE',$conf->global->MAIN_ACTIVATE_FILECACHE,1);
print '</td>';

View File

@ -148,7 +148,6 @@ print "</tr>\n";
foreach ($list as $key)
{
print '<tr class="oddeven value">';
// Param

View File

@ -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 '<form action="'.$_SERVER['PHP_SELF'].'?id='.$id.'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="from" value="'.dol_escape_htmltag(GETPOST('from','alpha')).'">';
// Form to add a new line
if ($tabname[$id])
{
$alabelisused=0;
$fieldlist=explode(',',$tabfield[$id]);
print '<table class="noborder" width="100%">';
// Line for title
print '<tr class="liste_titre">';
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='&nbsp;'; $showfield=1; }
@ -1120,7 +1120,7 @@ if ($id)
if ($id == 4) $colspan++;
print '</table>';
/*if (! empty($alabelisused) && $id != 25) // If there is one label among fields, we show legend of *
{
print '* '.$langs->trans("LabelUsedByDefault").'.<br>';
@ -1130,11 +1130,11 @@ if ($id)
print '</form>';
print '<br>';
print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$id.'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="from" value="'.dol_escape_htmltag(GETPOST('from','alpha')).'">';
// List of available record in database
dol_syslog("htdocs/admin/dict", LOG_DEBUG);
$resql=$db->query($sql);
@ -1150,29 +1150,29 @@ if ($id)
}
print '<table class="noborder" width="100%">';
// Title line with search boxes
print '<tr class="liste_titre_filter">';
$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 '<td class="liste_titre">';
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 '</td>';
$filterfound++;
}
elseif ($value == 'code')
{
print '<td class="liste_titre">';
print '<input type="text" name="search_code" value="'.dol_escape_htmltag($search_code).'">';
print '<input type="text" class="maxwidth100" name="search_code" value="'.dol_escape_htmltag($search_code).'">';
print '</td>';
$filterfound++;
}
@ -1193,7 +1193,7 @@ if ($id)
}
print '</td>';
print '</tr>';
// Title of lines
print '<tr class="liste_titre">';
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 '</table>';
}
else {
@ -1598,12 +1598,12 @@ else
{
if ($showemptyline)
{
print '<tr class="oddeven"><td width="30%">&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>';
$showemptyline=0;
}
$value=$tabname[$i];
print '<tr class="oddeven"><td width="50%">';
if (! empty($tabcond[$i]))
@ -1764,7 +1764,7 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='')
print '<td>';
$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);

View File

@ -547,7 +547,6 @@ print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">'
print "</td></tr>\n";
print '</form>';
// print products on fichinter
$var=! $var;
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="set_FICHINTER_PRINT_PRODUCTS">';

View File

@ -131,7 +131,7 @@ print '<table class="noborder" width="100%">';
$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 "</tr>\n";
}
print '<tr class="oddeven">';
print '<td>'.img_object('',$picto).' '.$objMod->getName();
print '<a name="'.$objMod->getName().'">&nbsp;</a>';

View File

@ -173,6 +173,7 @@ print '<tr><td>'.$langs->trans("In").'</td><td>';
print $form->select_all_categories($type,$object->fk_parent,'parent',64,$object->id);
print '</td></tr>';
$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))
{

View File

@ -235,11 +235,8 @@ print $langs->trans("Color").'</td><td>';
print $formother->showColor($object->color);
print '</td></tr>';
$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 '</table>';
print '</div>';
@ -290,7 +287,7 @@ else
if (count($cats) > 0)
{
foreach ($cats as $cat)
{
{
print "\t".'<tr class="oddeven">'."\n";
print "\t\t".'<td class="nowrap">';
print "<a href='viewcat.php?id=".$cat->id."&amp;type=".$type."'>".$cat->label."</a>";
@ -359,7 +356,7 @@ if ($object->type == Categorie::TYPE_PRODUCT)
if (count($prods) > 0)
{
foreach ($prods as $prod)
{
{
print "\t".'<tr class="oddeven">'."\n";
print '<td class="nowrap" valign="top">';
print $prod->getNomUrl(1);
@ -408,7 +405,7 @@ if ($object->type == Categorie::TYPE_SUPPLIER)
if (count($socs) > 0)
{
foreach ($socs as $soc)
{
{
print "\t".'<tr class="oddeven">'."\n";
print '<td class="nowrap" valign="top">';
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".'<tr class="oddeven">'."\n";
print '<td class="nowrap" valign="top">';
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".'<tr class="oddeven">'."\n";
print '<td class="nowrap" valign="top">';
$member->ref=$member->login;
@ -567,7 +564,7 @@ if($object->type == Categorie::TYPE_CONTACT)
foreach ($contacts as $key => $contact)
{
$i++;
print "\t".'<tr class="oddeven">'."\n";
print '<td class="nowrap" valign="top">';
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".'<tr class="oddeven">'."\n";
print '<td class="nowrap" valign="top">';
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".'<tr class="oddeven">'."\n";
print '<td class="nowrap" valign="top">';
print $project->getNomUrl(1,0);

View File

@ -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 '<div class="assignedtouser">';
print $form->select_dolusers_forevent(($action=='create'?'add':'update'), 'assignedtouser', 1, '', 0, '', '', 0, 0, 0, 'AND u.statut != 0');
print '</div>';
if (in_array($user->id,array_keys($listofuserid)))
if (in_array($user->id,array_keys($listofuserid)))
{
print '<div class="myavailability">';
print $langs->trans("MyAvailability").': <input id="transparency" type="checkbox" name="transparency"'.(((! isset($_GET['transparency']) && ! isset($_POST['transparency'])) || GETPOST('transparency'))?' checked':'').'> '.$langs->trans("Busy");
@ -757,8 +757,8 @@ if ($action == 'create')
print '</table>';
print '<br><br>';
print '<table class="border" width="100%">';
// Related company
@ -835,12 +835,9 @@ if ($action == 'create')
$doleditor->Create();
print '</td></tr>';
// 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 '<div class="assignedtouser">';
print $form->select_dolusers_forevent(($action=='create'?'add':'update'), 'assignedtouser', 1, '', 0, '', '', 0, 0, 0, 'AND u.statut != 0');
print '</div>';
if (in_array($user->id,array_keys($listofuserid)))
if (in_array($user->id,array_keys($listofuserid)))
{
print '<div class="myavailability">';
print $langs->trans("MyAvailability").': <input id="transparency" type="checkbox" name="transparency"'.($listofuserid[$user->id]['transparency']?' checked':'').'>'.$langs->trans("Busy");
@ -1104,10 +1101,10 @@ if ($id > 0)
print '</table>';
print '<br><br>';
print '<table class="border" width="100%">';
if ($conf->societe->enabled)
@ -1171,7 +1168,7 @@ if ($id > 0)
print '</td></tr>';
// 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.='<a href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_day&year='.dol_print_date($object->datep,'%Y').'&month='.dol_print_date($object->datep,'%m').'&day='.dol_print_date($object->datep,'%d').'">'.$langs->trans("ViewDay").'</a>';
$linkback.=$out;
$morehtmlref='<div class="refidno">';
// Thirdparty
//$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
@ -1259,14 +1256,14 @@ if ($id > 0)
}
}
$morehtmlref.='</div>';
dol_banner_tab($object, 'id', $linkback, ($user->societe_id?0:1), 'id', 'ref', $morehtmlref);
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
// Affichage fiche action en mode visu
print '<table class="border" width="100%">';
@ -1330,7 +1327,7 @@ if ($id > 0)
print '<div class="assignedtouser">';
print $form->select_dolusers_forevent('view', 'assignedtouser', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300');
print '</div>';
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 '<div class="myavailability">';
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 '</td></tr>';
// Related contact
print '<tr><td>'.$langs->trans("ActionOnContact").'</td>';
print '<td colspan="3">';
@ -1401,7 +1398,7 @@ if ($id > 0)
}
print '</td></tr>';
}
// Priority
print '<tr><td class="nowrap" class="titlefield">'.$langs->trans("Priority").'</td><td colspan="3">';
print ($object->priority?$object->priority:'');
@ -1425,38 +1422,13 @@ if ($id > 0)
print '</td></tr>';
// 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 '</table>';
//Extra field
if (empty($reshook) && ! empty($extrafields->attribute_label))
{
print '<br><br>';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
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 '<tr><td class="titlefield">'.$label.'</td><td>';
print $extrafields->showOutputField($key,$value);
print "</td></tr>\n";
}
print '</table>';
}
print '</div>';
dol_fiche_end();
}

View File

@ -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 = '<a href="'.DOL_URL_ROOT.'/societe/list.php">'.$langs->trans("BackToList").'</a>';
dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom');
print '<div class="fichecenter"><div class="fichehalfleft">';
print '<div class="underbanner clearboth"></div>';
@ -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 '</td>';
print '</tr>';
}
// 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 '<br>';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
// Level of prospect
print '<tr><td class="titlefield nowrap">';
print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
@ -508,12 +503,12 @@ if ($id > 0)
print '</div></td></tr>';
print "</table>";
}
print '</div><div class="fichehalfright"><div class="ficheaddleft">';
$boxstat = '';
// Nbre max d'elements des petites listes
$MAXLIST=$conf->global->MAIN_SIZE_SHORTLIST_LIMIT;
@ -521,7 +516,7 @@ if ($id > 0)
$boxstat.='<div class="box">';
$boxstat.='<table summary="'.dol_escape_htmltag($langs->trans("DolibarrStateBoard")).'" class="noborder boxtable boxtablenobottom" width="100%">';
$boxstat.='<tr class="impair"><td colspan="2" class="tdboxstats nohover">';
if ($conf->propal->enabled)
{
// Box proposals
@ -557,14 +552,14 @@ if ($id > 0)
$boxstat.='</div>';
if ($link) $boxstat.='</a>';
}
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.='<span class="boxstatsindicator">'.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).'</span>';
$boxstat.='</div>';
if ($link) $boxstat.='</a>';
// Box outstanding bill
$warn = '';
if ($object->outstanding_limit != '' && $object->outstanding_limit < $outstandingOpened)
@ -591,13 +586,13 @@ if ($id > 0)
$boxstat.='</div>';
if ($link) $boxstat.='</a>';
}
$boxstat.='</td></tr>';
$boxstat.='</table>';
$boxstat.='</div>';
print $boxstat;
$now=dol_now();
/*
@ -639,7 +634,7 @@ if ($id > 0)
while ($i < $num && $i < $MAXLIST)
{
$objp = $db->fetch_object($resql);
print '<tr class="oddeven">';
print '<td class="nowrap">';
$propal_static->id = $objp->propalid;
@ -723,7 +718,7 @@ if ($id > 0)
while ($i < $num && $i < $MAXLIST)
{
$objp = $db->fetch_object($resql);
print '<tr class="oddeven">';
print '<td class="nowrap">';
$commande_static->id = $objp->cid;
@ -849,7 +844,7 @@ if ($id > 0)
$contrat=new Contrat($db);
$objp = $db->fetch_object($resql);
print '<tr class="oddeven">';
print '<td class="nowrap">';
$contrat->id=$objp->id;
@ -905,7 +900,7 @@ if ($id > 0)
print '<td width="20px" align="right"><a href="'.DOL_URL_ROOT.'/fichinter/stats/index.php?socid='.$object->id.'">'.img_picto($langs->trans("Statistics"),'stats').'</a></td>';
print '</tr></table></td>';
print '</tr>';
}
$i = 0;
while ($i < $num && $i < $MAXLIST)
@ -921,7 +916,7 @@ if ($id > 0)
print '<td align="right" style="min-width: 60px">'.convertSecondToTime($objp->duration).'</td>'."\n";
print '<td align="right" class="nowrap" style="min-width: 60px">'.$fichinter_static->getLibStatut(5).'</td>'."\n";
print '</tr>';
$i++;
}
$db->free($resql);
@ -977,7 +972,7 @@ if ($id > 0)
while ($i < $num && $i < $MAXLIST)
{
$objp = $db->fetch_object($resql);
print '<tr class="oddeven">';
print '<td class="nowrap">';
$facturestatic->id = $objp->facid;
@ -1006,7 +1001,7 @@ if ($id > 0)
print price($objp->total_ttc);
print '</td>';
}
print '<td align="right" class="nowrap" style="min-width: 60px">'.($facturestatic->LibStatut($objp->paye,$objp->statut,5,$objp->am)).'</td>';
print "</tr>\n";
$i++;
@ -1042,31 +1037,31 @@ if ($id > 0)
{
print '<div class="inline-block divButAction"><a class="butActionRefused" title="'.dol_escape_js($langs->trans("ThirdPartyIsClosed")).'" href="#">'.$langs->trans("ThirdPartyIsClosed").'</a></div>';
}
if (! empty($conf->propal->enabled) && $user->rights->propal->creer && $object->status==1)
{
$langs->load("propal");
print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/comm/propal/card.php?socid='.$object->id.'&amp;action=create">'.$langs->trans("AddProp").'</a></div>';
}
if (! empty($conf->commande->enabled) && $user->rights->commande->creer && $object->status==1)
{
$langs->load("orders");
print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/commande/card.php?socid='.$object->id.'&amp;action=create">'.$langs->trans("AddOrder").'</a></div>';
}
if ($user->rights->contrat->creer && $object->status==1)
{
$langs->load("contracts");
print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/contrat/card.php?socid='.$object->id.'&amp;action=create">'.$langs->trans("AddContract").'</a></div>';
}
if (! empty($conf->ficheinter->enabled) && $user->rights->ficheinter->creer && $object->status==1)
{
$langs->load("fichinter");
print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/fichinter/card.php?socid='.$object->id.'&amp;action=create">'.$langs->trans("AddIntervention").'</a></div>';
}
// Add invoice
if ($user->societe_id == 0)
{
@ -1075,7 +1070,7 @@ if ($id > 0)
$langs->load("trips");
print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/compta/deplacement/card.php?socid='.$object->id.'&amp;action=create">'.$langs->trans("AddTrip").'</a></div>';
}
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 '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/compta/facture/card.php?action=create&socid='.$object->id.'">'.$langs->trans("AddBill").'</a></div>';
else print '<div class="inline-block divButAction"><a class="butActionRefused" title="'.dol_escape_js($langs->trans("ThirdPartyMustBeEditAsCustomer")).'" href="#">'.$langs->trans("AddBill").'</a></div>';
}
}
}
// Add action
if (! empty($conf->agenda->enabled) && ! empty($conf->global->MAIN_REPEATTASKONEACHTAB) && $object->status==1)
{
@ -1117,7 +1112,7 @@ if ($id > 0)
}
}
}
print '</div>';
if (! empty($conf->global->MAIN_REPEATCONTACTONEACHTAB))

View File

@ -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);

View File

@ -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.='</i>';
$availablelink=$form->textwithpicto($langs->trans("AvailableVariables"), $htmltext, 1, 'help', '', 0, 2, 'availvar');
//print '<a href="javascript:document_preview(\''.DOL_URL_ROOT.'/admin/modulehelp.php?id='.$objMod->numero.'\',\'text/html\',\''.dol_escape_js($langs->trans("Module")).'\')">'.img_picto($langs->trans("ClickToShowDescription"), $imginfo).'</a>';
// Print mail form
print load_fiche_titre($langs->trans("NewMailing"), $availablelink, 'title_generic');
@ -733,14 +733,14 @@ if ($action == 'create')
print '</td></tr>';
print '</table>';
print '<div style="padding-top: 10px">';
// 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 '</div>';
dol_fiche_end();
print '<div class="center"><input type="submit" class="button" value="'.$langs->trans("CreateMailing").'"></div>';
@ -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('<textarea cols="60" rows="'.ROWS_1.'" wrap="soft">php ./scripts/emailings/mailing-send.php '.$object->id.'</textarea>', 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 '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
// Description
@ -863,7 +863,7 @@ else
print '<tr><td>'.$form->editfieldkey("MailErrorsTo",'email_errorsto',$object->email_errorsto,$object,$user->rights->mailing->creer && $object->statut < 3,'string').'</td><td colspan="3">';
print $form->editfieldval("MailErrorsTo",'email_errorsto',$object->email_errorsto,$object,$user->rights->mailing->creer && $object->statut < 3,'string');
print '</td></tr>';
// Nb of distinct emails
print '<tr><td>';
print $langs->trans("TotalNbOfDistinctRecipients");
@ -895,20 +895,15 @@ else
print '</td></tr>';
// 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 '</table>';
print "</div>";
dol_fiche_end();
// Clone confirmation
if ($action == 'clone')
{
@ -1053,12 +1048,12 @@ else
$htmltext.=$key.' = '.$langs->trans($val).'<br>';
}
$htmltext.='</i>';
// 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 '<table class="border" width="100%">';
// Subject
@ -1086,9 +1081,9 @@ else
/*print '<tr><td width="15%">'.$langs->trans("BackgroundColorByDefault").'</td><td colspan="3">';
print $htmlother->selectColor($object->bgcolor,'bgcolor','edit_mailing',0);
print '</td></tr>';*/
print '</table>';
// Message
print '<div style="padding-top: 10px" bgcolor="'.($object->bgcolor?(preg_match('/^#/',$object->bgcolor)?'':'#').$object->bgcolor:'white').'">';
if (empty($object->bgcolor) || strtolower($object->bgcolor) == 'ffffff')
@ -1103,23 +1098,23 @@ else
print '</div>';
dol_fiche_end();
}
else
{
/*
* Mailing en mode edition
*/
dol_fiche_head($head, 'card', $langs->trans("Mailing"), -1, 'email');
$linkback = '<a href="'.DOL_URL_ROOT.'/comm/mailing/list.php">'.$langs->trans("BackToList").'</a>';
$morehtmlright='';
if ($object->statut == 2) $morehtmlright.=' ('.$object->countNbOfTargets('alreadysent').'/'.$object->nbemail.') ';
dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', '', '', 0, '', $morehtmlright);
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
@ -1131,7 +1126,7 @@ else
print $form->showrefnav($object,'id', $linkback);
print '</td></tr>';
*/
// Topic
print '<tr><td class="titlefield">'.$langs->trans("MailTitle").'</td><td colspan="3">'.$object->titre.'</td></tr>';
// From
@ -1171,24 +1166,24 @@ else
print "<br>\n";
print '<form name="edit_mailing" action="card.php" method="post" enctype="multipart/form-data">'."\n";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="update">';
print '<input type="hidden" name="id" value="'.$object->id.'">';
$htmltext = '<i>'.$langs->trans("FollowingConstantsWillBeSubstituted").':<br>';
foreach($object->substitutionarray as $key => $val)
{
$htmltext.=$key.' = '.$langs->trans($val).'<br>';
}
$htmltext.='</i>';
// 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 '<table class="border" width="100%">';
// Subject
@ -1237,9 +1232,9 @@ else
print '<tr><td>'.$langs->trans("BackgroundColorByDefault").'</td><td colspan="3">';
print $htmlother->selectColor($object->bgcolor,'bgcolor','edit_mailing',0);
print '</td></tr>';
print '</table>';
// Message
print '<div style="padding-top: 10px">';
// Editeur wysiwyg

View File

@ -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 '<table class="border" width="100%">';
// Reference
print '<tr><td class="titlefieldcreate fieldrequired">' . $langs->trans('Ref') . '</td><td colspan="2">' . $langs->trans("Draft") . '</td></tr>';
print '<tr><td class="titlefieldcreate fieldrequired">' . $langs->trans('Ref') . '</td><td>' . $langs->trans("Draft") . '</td></tr>';
// Ref customer
print '<tr><td>' . $langs->trans('RefCustomer') . '</td><td colspan="2">';
print '<tr><td>' . $langs->trans('RefCustomer') . '</td><td>';
print '<input type="text" name="ref_client" value="'.GETPOST('ref_client').'"></td>';
print '</tr>';
@ -1366,7 +1351,7 @@ if ($action == 'create')
print '<tr>';
print '<td class="fieldrequired">' . $langs->trans('Customer') . '</td>';
if ($socid > 0) {
print '<td colspan="2">';
print '<td>';
print $soc->getNomUrl(1);
print '<input type="hidden" name="socid" value="' . $soc->id . '">';
print '</td>';
@ -1374,7 +1359,7 @@ if ($action == 'create')
$shipping_method_id = $soc->shipping_method_id;
}
} else {
print '<td colspan="2">';
print '<td>';
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 "<tr><td>" . $langs->trans("DefaultContact") . '</td><td colspan="2">';
print "<tr><td>" . $langs->trans("DefaultContact") . '</td><td>';
$form->select_contacts($soc->id, $contactid, 'contactid', 1, $srccontactslist);
print '</td></tr>';
}
@ -1404,7 +1389,7 @@ if ($action == 'create')
if ($socid > 0)
{
// Ligne info remises tiers
print '<tr><td>' . $langs->trans('Discounts') . '</td><td colspan="2">';
print '<tr><td>' . $langs->trans('Discounts') . '</td><td>';
if ($soc->remise_percent)
print $langs->trans("CompanyHasRelativeDiscount", $soc->remise_percent);
else
@ -1420,26 +1405,26 @@ if ($action == 'create')
}
// Date
print '<tr><td class="fieldrequired">' . $langs->trans('Date') . '</td><td colspan="2">';
print '<tr><td class="fieldrequired">' . $langs->trans('Date') . '</td><td>';
$form->select_date('', '', '', '', '', "addprop", 1, 1);
print '</td></tr>';
// Validaty duration
print '<tr><td class="fieldrequired">' . $langs->trans("ValidityDuration") . '</td><td colspan="2"><input name="duree_validite" size="5" value="' . $conf->global->PROPALE_VALIDITY_DURATION . '"> ' . $langs->trans("days") . '</td></tr>';
print '<tr><td class="fieldrequired">' . $langs->trans("ValidityDuration") . '</td><td><input name="duree_validite" size="5" value="' . $conf->global->PROPALE_VALIDITY_DURATION . '"> ' . $langs->trans("days") . '</td></tr>';
// Terms of payment
print '<tr><td class="nowrap fieldrequired">' . $langs->trans('PaymentConditionsShort') . '</td><td colspan="2">';
print '<tr><td class="nowrap fieldrequired">' . $langs->trans('PaymentConditionsShort') . '</td><td>';
$form->select_conditions_paiements($soc->cond_reglement_id, 'cond_reglement_id');
print '</td></tr>';
// Mode of payment
print '<tr><td>' . $langs->trans('PaymentMode') . '</td><td colspan="2">';
print '<tr><td>' . $langs->trans('PaymentMode') . '</td><td>';
$form->select_types_paiements($soc->mode_reglement_id, 'mode_reglement_id');
print '</td></tr>';
// Bank Account
if (! empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL) && ! empty($conf->banque->enabled)) {
print '<tr><td>' . $langs->trans('BankAccount') . '</td><td colspan="2">';
print '<tr><td>' . $langs->trans('BankAccount') . '</td><td>';
$form->select_comptes($fk_account, 'fk_account', 0, '', 1);
print '</td></tr>';
}
@ -1450,20 +1435,20 @@ if ($action == 'create')
print '</td></tr>';
// Delivery delay
print '<tr class="fielddeliverydelay"><td>' . $langs->trans('AvailabilityPeriod') . '</td><td colspan="2">';
print '<tr class="fielddeliverydelay"><td>' . $langs->trans('AvailabilityPeriod') . '</td><td>';
$form->selectAvailabilityDelay('', 'availability_id', '', 1);
print '</td></tr>';
// Shipping Method
if (! empty($conf->expedition->enabled)) {
print '<tr><td>' . $langs->trans('SendingMethod') . '</td><td colspan="2">';
print '<tr><td>' . $langs->trans('SendingMethod') . '</td><td>';
print $form->selectShippingMethod($shipping_method_id, 'shipping_method_id', '', 1);
print '</td></tr>';
}
// Delivery date (or manufacturing)
print '<tr><td>' . $langs->trans("DeliveryDate") . '</td>';
print '<td colspan="2">';
print '<td>';
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 '<tr>';
print '<td>' . $langs->trans("Project") . '</td><td colspan="2">';
print '<td>' . $langs->trans("Project") . '</td><td>';
$numprojet = $formproject->select_projects($soc->id, $projectid, 'projectid', 0);
print ' &nbsp; <a href="'.DOL_URL_ROOT.'/projet/card.php?socid=' . $soc->id . '&action=create&status=1&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create&socid='.$soc->id).'">' . $langs->trans("AddProject") . '</a>';
print '</td>';
@ -1495,7 +1480,7 @@ if ($action == 'create')
{
print '<tr>';
print '<td><label for="incoterm_id">'.$form->textwithpicto($langs->trans("IncotermLabel"), $soc->libelle_incoterms, 1).'</label></td>';
print '<td colspan="3" class="maxwidthonsmartphone">';
print '<td class="maxwidthonsmartphone">';
print $form->select_incoterms((!empty($soc->fk_incoterms) ? $soc->fk_incoterms : ''), (!empty($soc->location_incoterms)?$soc->location_incoterms:''));
print '</td></tr>';
}
@ -1503,7 +1488,7 @@ if ($action == 'create')
// Template to use by default
print '<tr>';
print '<td>' . $langs->trans("DefaultModel") . '</td>';
print '<td colspan="2">';
print '<td>';
$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 "</td></tr>";
@ -1513,7 +1498,7 @@ if ($action == 'create')
{
print '<tr>';
print '<td>'.fieldLabel('Currency','multicurrency_code').'</td>';
print '<td colspan="3" class="maxwidthonsmartphone">';
print '<td class="maxwidthonsmartphone">';
print $form->selectMultiCurrency($currency_code, 'multicurrency_code', 0);
print '</td></tr>';
}
@ -1521,7 +1506,7 @@ if ($action == 'create')
// Public note
print '<tr>';
print '<td class="tdtop">' . $langs->trans('NotePublic') . '</td>';
print '<td valign="top" colspan="2">';
print '<td valign="top">';
$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 '<tr>';
print '<td class="tdtop">' . $langs->trans('NotePrivate') . '</td>';
print '<td valign="top" colspan="2">';
print '<td valign="top">';
$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 '<tr><td>' . $langs->trans($newclassname) . '</td><td colspan="2">' . $objectsrc->getNomUrl(1) . '</td></tr>';
print '<tr><td>' . $langs->trans('TotalHT') . '</td><td colspan="2">' . price($objectsrc->total_ht, 0, $langs, 1, -1, -1, $conf->currency) . '</td></tr>';
print '<tr><td>' . $langs->trans('TotalVAT') . '</td><td colspan="2">' . price($objectsrc->total_tva, 0, $langs, 1, -1, -1, $conf->currency) . "</td></tr>";
print '<tr><td>' . $langs->trans($newclassname) . '</td><td>' . $objectsrc->getNomUrl(1) . '</td></tr>';
print '<tr><td>' . $langs->trans('TotalHT') . '</td><td>' . price($objectsrc->total_ht, 0, $langs, 1, -1, -1, $conf->currency) . '</td></tr>';
print '<tr><td>' . $langs->trans('TotalVAT') . '</td><td>' . price($objectsrc->total_tva, 0, $langs, 1, -1, -1, $conf->currency) . "</td></tr>";
if ($mysoc->localtax1_assuj == "1" || $objectsrc->total_localtax1 != 0 ) // Localtax1
{
print '<tr><td>' . $langs->transcountry("AmountLT1", $mysoc->country_code) . '</td><td colspan="2">' . price($objectsrc->total_localtax1, 0, $langs, 1, -1, -1, $conf->currency) . "</td></tr>";
print '<tr><td>' . $langs->transcountry("AmountLT1", $mysoc->country_code) . '</td><td>' . price($objectsrc->total_localtax1, 0, $langs, 1, -1, -1, $conf->currency) . "</td></tr>";
}
if ($mysoc->localtax2_assuj == "1" || $objectsrc->total_localtax2 != 0) // Localtax2
{
print '<tr><td>' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '</td><td colspan="2">' . price($objectsrc->total_localtax2, 0, $langs, 1, -1, -1, $conf->currency) . "</td></tr>";
print '<tr><td>' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '</td><td>' . price($objectsrc->total_localtax2, 0, $langs, 1, -1, -1, $conf->currency) . "</td></tr>";
}
print '<tr><td>' . $langs->trans('TotalTTC') . '</td><td colspan="2">' . price($objectsrc->total_ttc, 0, $langs, 1, -1, -1, $conf->currency) . "</td></tr>";
print '<tr><td>' . $langs->trans('TotalTTC') . '</td><td>' . price($objectsrc->total_ttc, 0, $langs, 1, -1, -1, $conf->currency) . "</td></tr>";
}
print "</table>\n";
@ -2036,43 +2019,6 @@ if ($action == 'create')
print '</td></tr>';
}
// Project
/*
if (! empty($conf->projet->enabled))
{
$langs->load("projects");
print '<tr><td>';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('Project') . '</td>';
if ($user->rights->propal->creer)
{
if ($action != 'classify')
print '<td align="right"><a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a></td>';
print '</tr></table>';
print '</td><td colspan="5">';
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 '</td></tr>';
} else {
print '</td></tr></table>';
if (! empty($object->fk_project)) {
print '<td colspan="3">';
$proj = new Project($db);
$proj->fetch($object->fk_project);
print '<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
print $proj->ref;
print '</a>';
print '</td>';
} else {
print '<td colspan="3">&nbsp;</td>';
}
}
print '</tr>';
}*/
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 '</table>';

View File

@ -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 '<table class="border" width="100%">';
// Reference
print '<tr><td class="titlefieldcreate fieldrequired">' . $langs->trans('Ref') . '</td><td colspan="2">' . $langs->trans("Draft") . '</td></tr>';
print '<tr><td class="titlefieldcreate fieldrequired">' . $langs->trans('Ref') . '</td><td>' . $langs->trans("Draft") . '</td></tr>';
// Reference client
print '<tr><td>' . $langs->trans('RefCustomer') . '</td><td colspan="2">';
print '<tr><td>' . $langs->trans('RefCustomer') . '</td><td>';
if (!empty($conf->global->MAIN_USE_PROPAL_REFCLIENT_FOR_ORDER) && ! empty($origin) && ! empty($originid))
print '<input type="text" name="ref_client" value="'.$ref_client.'"></td>';
else
@ -1471,12 +1471,12 @@ if ($action == 'create' && $user->rights->commande->creer)
print '<tr>';
print '<td class="fieldrequired">' . $langs->trans('Customer') . '</td>';
if ($socid > 0) {
print '<td colspan="2">';
print '<td>';
print $soc->getNomUrl(1);
print '<input type="hidden" name="socid" value="' . $soc->id . '">';
print '</td>';
} else {
print '<td colspan="2">';
print '<td>';
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 "<tr><td>" . $langs->trans("DefaultContact") . '</td><td colspan="2">';
print "<tr><td>" . $langs->trans("DefaultContact") . '</td><td>';
$form->select_contacts($soc->id, $setcontact, 'contactid', 1, $srccontactslist);
print '</td></tr>';
// Ligne info remises tiers
print '<tr><td>' . $langs->trans('Discounts') . '</td><td colspan="2">';
print '<tr><td>' . $langs->trans('Discounts') . '</td><td>';
if ($soc->remise_percent)
print $langs->trans("CompanyHasRelativeDiscount", $soc->remise_percent);
else
@ -1517,12 +1517,12 @@ if ($action == 'create' && $user->rights->commande->creer)
print '</td></tr>';
}
// Date
print '<tr><td class="fieldrequired">' . $langs->trans('Date') . '</td><td colspan="2">';
print '<tr><td class="fieldrequired">' . $langs->trans('Date') . '</td><td>';
$form->select_date('', 're', '', '', '', "crea_commande", 1, 1); // Always autofill date with current date
print '</td></tr>';
// Delivery date planed
print "<tr><td>".$langs->trans("DateDeliveryPlanned").'</td><td colspan="2">';
print "<tr><td>".$langs->trans("DateDeliveryPlanned").'</td><td>';
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 "</td></tr>";
// Conditions de reglement
print '<tr><td class="nowrap">' . $langs->trans('PaymentConditionsShort') . '</td><td colspan="2">';
print '<tr><td class="nowrap">' . $langs->trans('PaymentConditionsShort') . '</td><td>';
$form->select_conditions_paiements($cond_reglement_id, 'cond_reglement_id', - 1, 1);
print '</td></tr>';
// Mode de reglement
print '<tr><td>' . $langs->trans('PaymentMode') . '</td><td colspan="2">';
print '<tr><td>' . $langs->trans('PaymentMode') . '</td><td>';
$form->select_types_paiements($mode_reglement_id, 'mode_reglement_id');
print '</td></tr>';
// Bank Account
if (! empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_ORDER) && ! empty($conf->banque->enabled))
{
print '<tr><td>' . $langs->trans('BankAccount') . '</td><td colspan="2">';
print '<tr><td>' . $langs->trans('BankAccount') . '</td><td>';
$form->select_comptes($fk_account, 'fk_account', 0, '', 1);
print '</td></tr>';
}
// Delivery delay
print '<tr class="fielddeliverydelay"><td>' . $langs->trans('AvailabilityPeriod') . '</td><td colspan="2">';
print '<tr class="fielddeliverydelay"><td>' . $langs->trans('AvailabilityPeriod') . '</td><td>';
$form->selectAvailabilityDelay($availability_id, 'availability_id', '', 1);
print '</td></tr>';
// Shipping Method
if (! empty($conf->expedition->enabled)) {
print '<tr><td>' . $langs->trans('SendingMethod') . '</td><td colspan="2">';
print '<tr><td>' . $langs->trans('SendingMethod') . '</td><td>';
print $form->selectShippingMethod($shipping_method_id, 'shipping_method_id', '', 1);
print '</td></tr>';
}
@ -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 '<tr><td>' . $langs->trans('Warehouse') . '</td><td colspan="2">';
print '<tr><td>' . $langs->trans('Warehouse') . '</td><td>';
print $formproduct->selectWarehouses($warehouse_id, 'warehouse_id', '', 1);
print '</td></tr>';
}
// What trigger creation
print '<tr><td>' . $langs->trans('Source') . '</td><td colspan="2">';
print '<tr><td>' . $langs->trans('Source') . '</td><td>';
$form->selectInputReason($demand_reason_id, 'demand_reason_id', '', 1);
print '</td></tr>';
@ -1582,7 +1582,7 @@ if ($action == 'create' && $user->rights->commande->creer)
{
$langs->load("projects");
print '<tr>';
print '<td>' . $langs->trans("Project") . '</td><td colspan="2">';
print '<td>' . $langs->trans("Project") . '</td><td>';
$numprojet = $formproject->select_projects($soc->id, $projectid, 'projectid', 0);
print ' &nbsp; <a href="'.DOL_URL_ROOT.'/projet/card.php?socid=' . $soc->id . '&action=create&status=1&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create&socid='.$soc->id).'">' . $langs->trans("AddProject") . '</a>';
print '</td>';
@ -1594,7 +1594,7 @@ if ($action == 'create' && $user->rights->commande->creer)
{
print '<tr>';
print '<td><label for="incoterm_id">'.$form->textwithpicto($langs->trans("IncotermLabel"), $objectsrc->libelle_incoterms, 1).'</label></td>';
print '<td colspan="3" class="maxwidthonsmartphone">';
print '<td class="maxwidthonsmartphone">';
$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 '<tr><td>' . $langs->trans('DefaultModel') . '</td>';
print '<td colspan="2">';
print '<td>';
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 '<tr>';
print '<td>'.fieldLabel('Currency','multicurrency_code').'</td>';
print '<td colspan="3" class="maxwidthonsmartphone">';
print '<td class="maxwidthonsmartphone">';
print $form->selectMultiCurrency($currency_code, 'multicurrency_code');
print '</td></tr>';
}
@ -1635,7 +1634,7 @@ if ($action == 'create' && $user->rights->commande->creer)
// Note public
print '<tr>';
print '<td class="tdtop">' . $langs->trans('NotePublic') . '</td>';
print '<td colspan="2">';
print '<td>';
$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 '<tr>';
print '<td class="tdtop">' . $langs->trans('NotePrivate') . '</td>';
print '<td colspan="2">';
print '<td>';
$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 '<tr><td>' . $langs->trans($newclassname) . '</td><td colspan="2">' . $objectsrc->getNomUrl(1) . '</td></tr>';
print '<tr><td>' . $langs->trans('TotalHT') . '</td><td colspan="2">' . price($objectsrc->total_ht) . '</td></tr>';
print '<tr><td>' . $langs->trans('TotalVAT') . '</td><td colspan="2">' . price($objectsrc->total_tva) . "</td></tr>";
print '<tr><td>' . $langs->trans($newclassname) . '</td><td>' . $objectsrc->getNomUrl(1) . '</td></tr>';
print '<tr><td>' . $langs->trans('TotalHT') . '</td><td>' . price($objectsrc->total_ht) . '</td></tr>';
print '<tr><td>' . $langs->trans('TotalVAT') . '</td><td>' . price($objectsrc->total_tva) . "</td></tr>";
if ($mysoc->localtax1_assuj == "1" || $objectsrc->total_localtax1 != 0) // Localtax1 RE
{
print '<tr><td>' . $langs->transcountry("AmountLT1", $mysoc->country_code) . '</td><td colspan="2">' . price($objectsrc->total_localtax1) . "</td></tr>";
print '<tr><td>' . $langs->transcountry("AmountLT1", $mysoc->country_code) . '</td><td>' . price($objectsrc->total_localtax1) . "</td></tr>";
}
if ($mysoc->localtax2_assuj == "1" || $objectsrc->total_localtax2 != 0) // Localtax2 IRPF
{
print '<tr><td>' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '</td><td colspan="2">' . price($objectsrc->total_localtax2) . "</td></tr>";
print '<tr><td>' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '</td><td>' . price($objectsrc->total_localtax2) . "</td></tr>";
}
print '<tr><td>' . $langs->trans('TotalTTC') . '</td><td colspan="2">' . price($objectsrc->total_ttc) . "</td></tr>";
print '<tr><td>' . $langs->trans('TotalTTC') . '</td><td>' . price($objectsrc->total_ttc) . "</td></tr>";
if (!empty($conf->multicurrency->enabled))
{
print '<tr><td>' . $langs->trans('MulticurrencyTotalHT') . '</td><td colspan="2">' . price($objectsrc->multicurrency_total_ht) . '</td></tr>';
print '<tr><td>' . $langs->trans('MulticurrencyTotalVAT') . '</td><td colspan="2">' . price($objectsrc->multicurrency_total_tva) . "</td></tr>";
print '<tr><td>' . $langs->trans('MulticurrencyTotalTTC') . '</td><td colspan="2">' . price($objectsrc->multicurrency_total_ttc) . "</td></tr>";
print '<tr><td>' . $langs->trans('MulticurrencyTotalHT') . '</td><td>' . price($objectsrc->multicurrency_total_ht) . '</td></tr>';
print '<tr><td>' . $langs->trans('MulticurrencyTotalVAT') . '</td><td>' . price($objectsrc->multicurrency_total_tva) . "</td></tr>";
print '<tr><td>' . $langs->trans('MulticurrencyTotalTTC') . '</td><td>' . price($objectsrc->multicurrency_total_ttc) . "</td></tr>";
}
}
@ -2240,7 +2239,7 @@ if ($action == 'create' && $user->rights->commande->creer)
}
print '</td></tr>';
*/
$tmparray=$object->getTotalWeightVolume();
$totalWeight=$tmparray['weight'];
$totalVolume=$tmparray['volume'];
@ -2269,7 +2268,7 @@ if ($action == 'create' && $user->rights->commande->creer)
else print '&nbsp;';
print '</td></tr></table>';
print '</td>';
print '<td colspan="3">';
print '<td>';
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 '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editbankaccount&amp;id='.$object->id.'">'.img_edit($langs->trans('SetBankAccount'),1).'</a></td>';
print '</tr></table>';
print '</td><td colspan="3">';
print '</td><td>';
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 '</table>';
@ -2320,18 +2318,18 @@ if ($action == 'create' && $user->rights->commande->creer)
print '<tr><td class="titlefieldmiddle">' . fieldLabel('MulticurrencyAmountHT','multicurrency_total_ht') . '</td>';
print '<td class="nowrap">' . price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>';
print '</tr>';
// Multicurrency Amount VAT
print '<tr><td>' . fieldLabel('MulticurrencyAmountVAT','multicurrency_total_tva') . '</td>';
print '<td class="nowrap">' . price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>';
print '</tr>';
// Multicurrency Amount TTC
print '<tr><td>' . fieldLabel('MulticurrencyAmountTTC','multicurrency_total_ttc') . '</td>';
print '<td class="nowrap">' . price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>';
print '</tr>';
}
// Total HT
print '<tr><td class="titlefieldmiddle">' . $langs->trans('AmountHT') . '</td>';
print '<td>' . price($object->total_ht, 1, '', 1, - 1, - 1, $conf->currency) . '</td>';

View File

@ -411,17 +411,17 @@ if ($action == 'create' && !$error)
print '<table class="border" width="100%">';
// Ref
print '<tr><td class="fieldrequired">'.$langs->trans('Ref').'</td><td colspan="2">'.$langs->trans('Draft').'</td></tr>';
print '<tr><td class="fieldrequired">'.$langs->trans('Ref').'</td><td>'.$langs->trans('Draft').'</td></tr>';
// Third party
print '<tr><td class="fieldrequired">'.$langs->trans('Customer').'</td><td colspan="2">';
print '<tr><td class="fieldrequired">'.$langs->trans('Customer').'</td><td>';
print $soc->getNomUrl(1);
print '<input type="hidden" name="socid" value="'.$soc->id.'">';
print '</td>';
print '</tr>'."\n";
// Type
print '<tr><td class="tdtop fieldrequired">'.$langs->trans('Type').'</td><td colspan="2">';
print '<tr><td class="tdtop fieldrequired">'.$langs->trans('Type').'</td><td>';
print '<table class="nobordernopadding">'."\n";
// Standard invoice
@ -434,15 +434,15 @@ if ($action == 'create' && !$error)
print '</table>';
// Date invoice
print '<tr><td class="fieldrequired">'.$langs->trans('Date').'</td><td colspan="2">';
print '<tr><td class="fieldrequired">'.$langs->trans('Date').'</td><td>';
$html->select_date('','','','','',"add",1,1);
print '</td></tr>';
// Payment term
print '<tr><td class="nowrap">'.$langs->trans('PaymentConditionsShort').'</td><td colspan="2">';
print '<tr><td class="nowrap">'.$langs->trans('PaymentConditionsShort').'</td><td>';
$html->select_conditions_paiements(isset($_POST['cond_reglement_id'])?$_POST['cond_reglement_id']:$cond_reglement_id,'cond_reglement_id');
print '</td></tr>';
// Payment mode
print '<tr><td>'.$langs->trans('PaymentMode').'</td><td colspan="2">';
print '<tr><td>'.$langs->trans('PaymentMode').'</td><td>';
$html->select_types_paiements(isset($_POST['mode_reglement_id'])?$_POST['mode_reglement_id']:$mode_reglement_id,'mode_reglement_id');
print '</td></tr>';
// Project
@ -451,7 +451,7 @@ if ($action == 'create' && !$error)
$formproject=new FormProjets($db);
$langs->load('projects');
print '<tr><td>'.$langs->trans('Project').'</td><td colspan="2">';
print '<tr><td>'.$langs->trans('Project').'</td><td>';
$formproject->select_projects($soc->id, $projectid, 'projectid');
print '</td></tr>';
}
@ -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 '<tr>';
print '<td class="border" valign="top">'.$langs->trans('NotePublic').'</td>';
print '<td valign="top" colspan="2">';
print '<textarea name="note_public" wrap="soft" cols="70" rows="'.ROWS_3.'">';
print '<td valign="top">';
print '<textarea name="note_public" class="quatrevingtpercent" rows="'.ROWS_3.'">';
print $langs->trans("Orders").": ".implode(', ', $listoforders);
@ -500,8 +499,8 @@ if ($action == 'create' && !$error)
{
print '<tr>';
print '<td class="border" valign="top">'.$langs->trans('NotePrivate').'</td>';
print '<td valign="top" colspan="2">';
print '<textarea name="note" wrap="soft" cols="70" rows="'.ROWS_3.'">';
print '<td valign="top">';
print '<textarea name="note" class="quatrevingtpercent" rows="'.ROWS_3.'">';
print '</textarea></td></tr>';
}
@ -622,7 +621,7 @@ if (($action != 'create' && $action != 'add') || ($action == 'create' && $error)
print '<td class="liste_titre" align="left">';
print '<input class="flat" type="text" size="10" name="sref_client" value="'.$sref_client.'">';
print '</td>';
//DATE ORDER
print '<td class="liste_titre" align="center">';
print $period;
@ -637,7 +636,7 @@ if (($action != 'create' && $action != 'add') || ($action == 'create' && $error)
print '<td align="right" class="liste_titre">';
print '<input type="image" class="liste_titre" name="button_search" src="'.img_picto($langs->trans("Search"),'search.png','','',1).'" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">';
print '</td>';
//ALL/NONE
print '<td align="center" class="liste_titre">';
if ($conf->use_javascript_ajax) print '<a href="#" id="checkall">'.$langs->trans("All").'</a> / <a href="#" id="checknone">'.$langs->trans("None").'</a>';
@ -653,7 +652,7 @@ if (($action != 'create' && $action != 'add') || ($action == 'create' && $error)
while ($i < $num)
{
$objp = $db->fetch_object($resql);
print '<tr class="oddeven">';
print '<td class="nowrap">';

View File

@ -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 '<tr><td class="fieldrequired titlefieldcreate">'.$langs->trans("Ref").'</td>';
print '<td colspan="3"><input size="8" type="text" class="flat" name="ref" value="'.(GETPOST("ref")?GETPOST("ref",'alpha'):$object->ref).'" maxlength="12"></td></tr>';
print '<td><input size="8" type="text" class="flat" name="ref" value="'.(GETPOST("ref")?GETPOST("ref",'alpha'):$object->ref).'" maxlength="12"></td></tr>';
// Label
print '<tr><td class="fieldrequired">'.$langs->trans("LabelBankCashAccount").'</td>';
print '<td colspan="3"><input size="30" type="text" class="flat" name="label" value="'.GETPOST("label", 'alpha').'"></td></tr>';
print '<td><input size="30" type="text" class="flat" name="label" value="'.GETPOST("label", 'alpha').'"></td></tr>';
// Type
print '<tr><td class="fieldrequired">'.$langs->trans("AccountType").'</td>';
print '<td colspan="3">';
print '<td>';
$formbank->selectTypeOfBankAccount(isset($_POST["type"])?$_POST["type"]: Account::TYPE_CURRENT,"type");
print '</td></tr>';
// Currency
print '<tr><td class="fieldrequired">'.$langs->trans("Currency").'</td>';
print '<td colspan="3">';
print '<td>';
$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 '<tr><td class="fieldrequired">'.$langs->trans("Status").'</td>';
print '<td colspan="3">';
print '<td>';
print $form->selectarray("clos", $object->status,(isset($_POST["clos"])?$_POST["clos"]:$object->clos));
print '</td></tr>';
@ -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 '<tr><td class="fieldrequired">'.$langs->trans("BankAccountCountry").'</td>';
print '<td colspan="3">';
print '<td>';
print $form->select_country($selectedcode,'account_country_id');
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
print '</td></tr>';
// State
print '<tr><td>'.$langs->trans('State').'</td><td colspan="3">';
print '<tr><td>'.$langs->trans('State').'</td><td>';
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 '<tr><td>'.$langs->trans("Web").'</td>';
print '<td colspan="3"><input class="minwidth300" type="text" class="flat" name="url" value="'.GETPOST("url").'"></td></tr>';
print '<td><input class="minwidth300" type="text" class="flat" name="url" value="'.GETPOST("url").'"></td></tr>';
// Tags-Categories
if ($conf->categorie->enabled)
if ($conf->categorie->enabled)
{
print '<tr><td class="tdtop">'.$langs->trans("Categories").'</td><td colspan="3">';
print '<tr><td class="tdtop">'.$langs->trans("Categories").'</td><td>';
$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 '<tr><td class="tdtop">'.$langs->trans("Comment").'</td>';
print '<td colspan="3">';
print '<td>';
// 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 '</td></tr>';
// 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 '<tr><td class="titlefieldcreate">'.$langs->trans("InitialBankBalance").'</td>';
print '<td colspan="3"><input size="12" type="text" class="flat" name="solde" value="'.(GETPOST("solde")?GETPOST("solde"):price2num($object->solde)).'"></td></tr>';
print '<td><input size="12" type="text" class="flat" name="solde" value="'.(GETPOST("solde")?GETPOST("solde"):price2num($object->solde)).'"></td></tr>';
print '<tr><td>'.$langs->trans("Date").'</td>';
print '<td colspan="3">';
print '<td>';
$form->select_date('', 're', 0, 0, 0, 'formsoc');
print '</td></tr>';
print '<tr><td>'.$langs->trans("BalanceMinimalAllowed").'</td>';
print '<td colspan="3"><input size="12" type="text" class="flat" name="account_min_allowed" value="'.(GETPOST("account_min_allowed")?GETPOST("account_min_allowed"):$object->min_allowed).'"></td></tr>';
print '<td><input size="12" type="text" class="flat" name="account_min_allowed" value="'.(GETPOST("account_min_allowed")?GETPOST("account_min_allowed"):$object->min_allowed).'"></td></tr>';
print '<tr><td>'.$langs->trans("BalanceMinimalDesired").'</td>';
print '<td colspan="3"><input size="12" type="text" class="flat" name="account_min_desired" value="'.(GETPOST("account_min_desired")?GETPOST("account_min_desired"):$object->min_desired).'"></td></tr>';
print '<td><input size="12" type="text" class="flat" name="account_min_desired" value="'.(GETPOST("account_min_desired")?GETPOST("account_min_desired"):$object->min_desired).'"></td></tr>';
print '</table>';
print '<br>';
@ -444,7 +444,7 @@ if ($action == 'create')
// If bank account
print '<tr><td class="titlefieldcreate">'.$langs->trans("BankName").'</td>';
print '<td colspan="3"><input size="30" type="text" class="flat" name="bank" value="'.(GETPOST('bank')?GETPOST('bank','alpha'):$object->bank).'"></td>';
print '<td><input size="30" type="text" class="flat" name="bank" value="'.(GETPOST('bank')?GETPOST('bank','alpha'):$object->bank).'"></td>';
print '</tr>';
// Show fields of bank account
@ -477,21 +477,21 @@ if ($action == 'create')
// IBAN
print '<tr><td>'.$langs->trans($ibankey).'</td>';
print '<td colspan="3"><input size="34" maxlength="34" type="text" class="flat" name="iban" value="'.(GETPOST('iban')?GETPOST('iban','alpha'):$object->iban).'"></td></tr>';
print '<td><input size="34" maxlength="34" type="text" class="flat" name="iban" value="'.(GETPOST('iban')?GETPOST('iban','alpha'):$object->iban).'"></td></tr>';
print '<tr><td>'.$langs->trans($bickey).'</td>';
print '<td colspan="3"><input size="11" maxlength="11" type="text" class="flat" name="bic" value="'.(GETPOST('bic')?GETPOST('bic','alpha'):$object->bic).'"></td></tr>';
print '<td><input size="11" maxlength="11" type="text" class="flat" name="bic" value="'.(GETPOST('bic')?GETPOST('bic','alpha'):$object->bic).'"></td></tr>';
print '<tr><td>'.$langs->trans("BankAccountDomiciliation").'</td><td colspan="3">';
print '<tr><td>'.$langs->trans("BankAccountDomiciliation").'</td><td>';
print "<textarea class=\"flat\" name=\"domiciliation\" rows=\"2\" cols=\"40\">";
print (GETPOST('domiciliation')?GETPOST('domiciliation'):$object->domiciliation);
print "</textarea></td></tr>";
print '<tr><td>'.$langs->trans("BankAccountOwner").'</td>';
print '<td colspan="3"><input size="30" type="text" class="flat" name="proprio" value="'.(GETPOST('proprio')?GETPOST('proprio','alpha'):$object->proprio).'">';
print '<td><input size="30" type="text" class="flat" name="proprio" value="'.(GETPOST('proprio')?GETPOST('proprio','alpha'):$object->proprio).'">';
print '</td></tr>';
print '<tr><td class="tdtop">'.$langs->trans("BankAccountOwnerAddress").'</td><td colspan="3">';
print '<tr><td class="tdtop">'.$langs->trans("BankAccountOwnerAddress").'</td><td>';
print "<textarea class=\"flat\" name=\"owner_address\" rows=\"2\" cols=\"40\">";
print (GETPOST('owner_address')?GETPOST('owner_address','alpha'):$object->owner_address);
print "</textarea></td></tr>";
@ -503,8 +503,8 @@ if ($action == 'create')
print '<table class="border" width="100%">';
// 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 '<tr><td class="'.$fieldrequired.'titlefieldcreate">'.$langs->trans("AccountancyCode").'</td>';
@ -515,7 +515,7 @@ if ($action == 'create')
else
{
print '<tr><td class="'.$fieldrequired.'titlefieldcreate">'.$langs->trans("AccountancyCode").'</td>';
print '<td colspan="3"><input type="text" name="account_number" value="'.(GETPOST("account_number")?GETPOST('account_number', 'alpha'):$object->account_number).'"></td></tr>';
print '<td><input type="text" name="account_number" value="'.(GETPOST("account_number")?GETPOST('account_number', 'alpha'):$object->account_number).'"></td></tr>';
}
// 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 = '<a href="'.DOL_URL_ROOT.'/compta/bank/index.php">'.$langs->trans("BackToList").'</a>';
$morehtmlref='';
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
print '<div class="fichecenter">';
print '<div class="fichehalfleft">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
// Ref
/*
print '<tr><td class="titlefield">'.$langs->trans("Ref").'</td>';
print '<td colspan="3">';
print '<td>';
print $form->showrefnav($object, 'ref', $linkback, 1, 'ref');
print '</td></tr>';*/
@ -662,25 +662,25 @@ else
print $object->account_number;
}
print '</td></tr>';
// Accountancy journal
if (! empty($conf->accounting->enabled))
{
print '<tr><td>'.$langs->trans("AccountancyJournal").'</td>';
print '<td>';
$accountingjournal = new AccountingJournal($db);
$accountingjournal->fetch($object->fk_accountancy_journal);
print $accountingjournal->getNomUrl(0,1,1,'',1);
print '</td></tr>';
}
// Other attributes
$cols = 2;
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
print '</table>';
print '</div>';
@ -689,7 +689,7 @@ else
print '<div class="underbanner clearboth"></div>';
print '<table class="border centpercent">';
// Categories
if ($conf->categorie->enabled) {
print '<tr><td class="titlefield">'.$langs->trans("Categories").'</td><td>';
@ -705,9 +705,9 @@ else
if ($object->type == Account::TYPE_SAVINGS || $object->type == Account::TYPE_CURRENT)
{
print '<br>';
print '<div class="underbanner clearboth"></div>';
print '<table class="border centpercent">';
print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("BankName").'</td>';
@ -726,7 +726,7 @@ else
}
print '<tr><td>'.$langs->trans($val).'</td>';
print '<td colspan="3">'.$content.'</td>';
print '<td>'.$content.'</td>';
print '</tr>';
}
@ -776,7 +776,7 @@ else
print '</div>';
print '<div class="clearboth"></div>';
dol_fiche_end();
/*
@ -839,7 +839,7 @@ else
dol_fiche_head('');
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
// Ref
@ -921,7 +921,7 @@ else
print '</td></tr>';
// Tags-Categories
if ($conf->categorie->enabled)
if ($conf->categorie->enabled)
{
print '<tr><td class="tdtop">'.$langs->trans("Categories").'</td><td>';
$cate_arbo = $form->select_all_categories(Categorie::TYPE_ACCOUNT, '', 'parent', 64, 0, 1);
@ -944,12 +944,13 @@ else
print '</td></tr>';
// 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 '</table>';
print '<br>';

View File

@ -6,7 +6,7 @@
* Copyright (C) 2005-2010 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2015-2016 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
* Copyright (C) 2015-2017 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2016 Ferran Marcet <fmarcet@2byte.es>
*
* 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).', ';
}

View File

@ -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 '<table class="border" width="100%">';
// Date payment
@ -274,7 +274,7 @@ if ($action == 'create')
print $formaccounting->select_account($accountancy_code, 'accountancy_code', 1, null, 1, 1, '');
print '</td></tr>';
}
else // For external software
else // For external software
{
print '<tr><td>'.$langs->trans("AccountAccounting").'</td>';
print '<td class="maxwidthonsmartphone"><input class="minwidth100" name="accountancy_code" value="'.$accountancy_code.'">';
@ -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 '</table>';
@ -315,7 +315,7 @@ if ($id)
print '<table class="border" width="100%">';
$linkback = '<a href="'.DOL_URL_ROOT.'/compta/bank/various_payment/index.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
print "<tr>";
print '<td class="titlefield">'.$langs->trans("Ref").'</td><td>';
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 '</table>';
dol_fiche_end();
/*
* Action buttons
*/

View File

@ -251,7 +251,7 @@ if ($action == 'create')
print '<table class="border" width="100%">';
print "<tr>";
print '<td width="25%" class="fieldrequired">'.$langs->trans("Type").'</td><td>';
print '<td class="fieldrequired">'.$langs->trans("Type").'</td><td>';
$form->select_type_fees(GETPOST('type','int'),'type',1);
print '</td></tr>';
@ -277,7 +277,7 @@ if ($action == 'create')
// Public note
print '<tr>';
print '<td class="tdtop">'.$langs->trans('NotePublic').'</td>';
print '<td valign="top" colspan="2">';
print '<td>';
$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 '<tr>';
print '<td class="tdtop">'.$langs->trans('NotePrivate').'</td>';
print '<td valign="top" colspan="2">';
print '<td>';
$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 '</table>';
@ -340,7 +340,7 @@ else if ($id)
// Ref
print "<tr>";
print '<td width="20%">'.$langs->trans("Ref").'</td><td>';
print '<td class="titlefield">'.$langs->trans("Ref").'</td><td>';
print $object->ref;
print '</td></tr>';
@ -374,7 +374,7 @@ else if ($id)
// Public note
print '<tr><td class="tdtop">'.$langs->trans("NotePublic").'</td>';
print '<td valign="top" colspan="3">';
print '<td>';
$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 '<tr><td class="tdtop">'.$langs->trans("NotePrivate").'</td>';
print '<td valign="top" colspan="3">';
print '<td>';
$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 '</table>';
@ -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 '<tr><td>'.$langs->trans("Status").'</td><td>'.$object->getLibStatut(4).'</td></tr>';
// 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 "</table><br>";

View File

@ -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 '<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">';
$tmp='<input type="radio" id="radio_deposit" name="type" value="3"' . (GETPOST('type') == 3 ? ' checked' : '') . '> ';
@ -2342,7 +2342,7 @@ if ($action == 'create')
});
});
</script>';
$desc = $form->textwithpicto($tmp.$langs->trans("InvoiceDeposit"), $langs->transnoentities("InvoiceDepositDesc"), 1, 'help', '', 0, 3);
print '<table class="nobordernopadding"><tr><td>';
print $desc;
@ -2356,7 +2356,7 @@ if ($action == 'create')
print '<td class="nowrap" style="padding-left: 5px">' . $langs->trans('Value') . ':<input type="text" id="valuedeposit" name="valuedeposit" size="3" value="' . GETPOST('valuedeposit', 'int') . '"/>';
}
print '</td></tr></table>';
print '</div></div>';
}
}
@ -2388,7 +2388,7 @@ if ($action == 'create')
}
// Replacement
if (empty($conf->global->INVOICE_DISABLE_REPLACEMENT))
if (empty($conf->global->INVOICE_DISABLE_REPLACEMENT))
{
print '<!-- replacement line -->';
print '<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">';
@ -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 '<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">';
$tmp='<input type="radio" id="radio_creditnote" name="type" value="2"' . (GETPOST('type') == 2 ? ' checked' : '');
@ -2471,12 +2471,12 @@ if ($action == 'create')
$text .= '</select>';
$desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceAvoirDesc"), 1, 'help', '', 0, 3);
print $desc;
print '<div id="credit_note_options" class="clearboth">';
print '&nbsp;&nbsp;&nbsp; <input data-role="none" type="checkbox" name="invoiceAvoirWithLines" id="invoiceAvoirWithLines" value="1" onclick="if($(this).is(\':checked\') ) { $(\'#radio_creditnote\').prop(\'checked\', true); $(\'#invoiceAvoirWithPaymentRestAmount\').removeAttr(\'checked\'); }" '.(GETPOST('invoiceAvoirWithLines','int')>0 ? 'checked':'').' /> <label for="invoiceAvoirWithLines">'.$langs->trans('invoiceAvoirWithLines')."</label>";
print '<br>&nbsp;&nbsp;&nbsp; <input data-role="none" type="checkbox" name="invoiceAvoirWithPaymentRestAmount" id="invoiceAvoirWithPaymentRestAmount" value="1" onclick="if($(this).is(\':checked\') ) { $(\'#radio_creditnote\').prop(\'checked\', true); $(\'#invoiceAvoirWithLines\').removeAttr(\'checked\'); }" '.(GETPOST('invoiceAvoirWithPaymentRestAmount','int')>0 ? 'checked':'').' /> <label for="invoiceAvoirWithPaymentRestAmount">'.$langs->trans('invoiceAvoirWithPaymentRestAmount')."</label>";
print '</div>';
print '</div></div>';
}
}
@ -2492,7 +2492,7 @@ if ($action == 'create')
print '</div></div>' . "\n";
}
}
// Template invoice
print '<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">';
$tmp='<input type="radio" name="type" id="radio_template" value="0" disabled> ';
@ -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 '<tr><td>' . $langs->trans('MulticurrencyTotalHT') . '</td><td colspan="2">' . price($objectsrc->multicurrency_total_ht) . '</td></tr>';
print '<tr><td>' . $langs->trans('MulticurrencyTotalVAT') . '</td><td colspan="2">' . price($objectsrc->multicurrency_total_tva) . "</td></tr>";
print '<tr><td>' . $langs->trans('MulticurrencyTotalTTC') . '</td><td colspan="2">' . price($objectsrc->multicurrency_total_ttc) . "</td></tr>";
print '<tr><td>' . $langs->trans('MulticurrencyTotalTTC') . '</td><td colspan="2">' . price($objectsrc->multicurrency_total_ttc) . "</td></tr>";
}
}
@ -3488,21 +3487,21 @@ else if ($id > 0 || ! empty($ref))
print '<div class="fichehalfright">';
print '<div class="ficheaddleft">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border centpercent">';
if (!empty($conf->multicurrency->enabled) && ($object->multicurrency_code != $conf->currency))
{
// Multicurrency Amount HT
print '<tr><td class="titlefieldmiddle">' . fieldLabel('MulticurrencyAmountHT','multicurrency_total_ht') . '</td>';
print '<td class="nowrap amountcard">' . price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>';
print '</tr>';
// Multicurrency Amount VAT
print '<tr><td>' . fieldLabel('MulticurrencyAmountVAT','multicurrency_total_tva') . '</td>';
print '<td class="nowrap amountcard">' . price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>';
print '</tr>';
// Multicurrency Amount TTC
print '<tr><td>' . fieldLabel('MulticurrencyAmountTTC','multicurrency_total_ttc') . '</td>';
print '<td class="nowrap amountcard">' . price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>';
@ -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 '<table class="nobordernopadding paymenttable" width="100%">';
if (count($object->tab_previous_situation_invoice) > 0) {
// List of previous invoices
print '<tr class="liste_titre">';
@ -3601,7 +3600,7 @@ else if ($id > 0 || ! empty($ref))
print '<td align="right">' . $langs->trans('AmountTTC') . '</td>';
print '<td width="18">&nbsp;</td>';
print '</tr>';
$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 '<td align="right">' . price($prev_invoice->total_ttc) . '</td>';
print '<td align="right">' . $prev_invoice->getLibStatut(3, $totalpaye) . '</td>';
print '</tr>';
}
print '<tr class="oddeven">';
print '<td colspan="2" align="right"></td>';
print '<td align="right"><b>' . price($total_prev_ht) . '</b></td>';
@ -3626,7 +3625,7 @@ else if ($id > 0 || ! empty($ref))
print '<td width="18">&nbsp;</td>';
print '</tr>';
}
if (count($object->tab_next_situation_invoice) > 0) {
// List of next invoices
print '<tr class="liste_titre">';
@ -3637,9 +3636,9 @@ else if ($id > 0 || ! empty($ref))
print '<td align="right">' . $langs->trans('AmountTTC') . '</td>';
print '<td width="18">&nbsp;</td>';
print '</tr>';
$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 '<td align="right">' . price($next_invoice->total_ttc) . '</td>';
print '<td align="right">' . $next_invoice->getLibStatut(3, $totalpaye) . '</td>';
print '</tr>';
}
print '<tr class="oddeven">';
print '<td colspan="2" align="right"></td>';
if (! empty($conf->banque->enabled)) print '<td align="right"></td>';
@ -3664,7 +3663,7 @@ else if ($id > 0 || ! empty($ref))
print '<td width="18">&nbsp;</td>';
print '</tr>';
}
if (count($object->tab_previous_situation_invoice) > 0 || count($object->tab_next_situation_invoice) > 0)
print '</table>';
}
@ -3741,7 +3740,7 @@ else if ($id > 0 || ! empty($ref))
print '</tr>';
$i ++;
}
}
}
/*else {
print '<tr class="oddeven"><td colspan="' . $nbcols . '" class="opacitymedium">' . $langs->trans("None") . '</td><td></td><td></td></tr>';
}*/
@ -3837,7 +3836,7 @@ else if ($id > 0 || ! empty($ref))
// Billed
print '<tr><td colspan="' . $nbcols . '" align="right">' . $langs->trans("Billed") . ' :</td><td align="right">' . price($object->total_ttc) . '</td><td>&nbsp;</td></tr>';
// Remainder to pay
print '<tr><td colspan="' . $nbcols . '" align="right">';
if ($resteapayeraffiche >= 0)
@ -3847,11 +3846,11 @@ else if ($id > 0 || ! empty($ref))
print ' :</td>';
print '<td align="right"'.($resteapayeraffiche?' class="amountremaintopay"':(' class="'.$cssforamountpaymentcomplete.'"')).'>' . price($resteapayeraffiche) . '</td>';
print '<td class="nowrap">&nbsp;</td></tr>';
}
}
else // Credit note
{
$cssforamountpaymentcomplete='';
// Total already paid back
print '<tr><td colspan="' . $nbcols . '" align="right">';
print $langs->trans('AlreadyPaidBack');
@ -3909,14 +3908,14 @@ else if ($id > 0 || ! empty($ref))
{
if ($object->situation_cycle_ref && $object->statut == 0) {
print '<div class="div-table-responsive">';
print '<form name="updatealllines" id="updatealllines" action="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '#updatealllines" method="POST">';
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '" />';
print '<input type="hidden" name="action" value="updatealllines" />';
print '<input type="hidden" name="id" value="' . $object->id . '" />';
print '<table id="tablelines_all_progress" class="noborder noshadow" width="100%">';
print '<tr class="liste_titre nodrag nodrop">';
if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) {
@ -3954,11 +3953,11 @@ else if ($id > 0 || ! empty($ref))
print '<td align="right" class="nowrap"><input type="text" size="1" value="" name="all_progress">%</td>';
print '<td colspan="4" align="right"><input class="button" type="submit" name="all_percent" value="Modifier" /></td>';
print '</tr>';
print '</table>';
print '</form>';
print '</div>';
}
}
@ -3969,14 +3968,14 @@ else if ($id > 0 || ! empty($ref))
<input type="hidden" name="mode" value="">
<input type="hidden" name="id" value="' . $object->id . '">
';
if (! empty($conf->use_javascript_ajax) && $object->statut == 0) {
include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php';
}
print '<div class="div-table-responsive">';
print '<table id="tablelines" class="noborder noshadow" width="100%">';
// 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 '<a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("AmountMustBePositive")).'">'.$langs->trans("MakeWithdrawRequest").'</a>';
}
}
// 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';

View File

@ -158,7 +158,7 @@ if ($id)
if ($action == 'create')
{
print load_fiche_titre($langs->transcountry($lttype==2?"newLT2Payment":"newLT1Payment",$mysoc->country_code));
print '<form name="add" action="'.$_SERVER["PHP_SELF"].'" name="formlocaltax" method="post">'."\n";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="localTaxType" value="'.$lttype.'">';
@ -193,14 +193,14 @@ if ($action == 'create')
$form->select_types_paiements(GETPOST("paiementtype"), "paiementtype");
print "</td>\n";
print "</tr>";
// Number
print '<tr><td>'.$langs->trans('Numero');
print ' <em>('.$langs->trans("ChequeOrTransferNumber").')</em>';
print '<td><input name="num_payment" type="text" value="'.GETPOST("num_payment").'"></td></tr>'."\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 '</table>';
@ -237,20 +237,20 @@ if ($id)
print '<table class="border" width="100%">';
print "<tr>";
print '<td width="25%">'.$langs->trans("Ref").'</td><td colspan="3">';
print '<td width="25%">'.$langs->trans("Ref").'</td><td>';
print $vatpayment->ref;
print '</td></tr>';
print "<tr>";
print '<td>'.$langs->trans("DatePayment").'</td><td colspan="3">';
print '<td>'.$langs->trans("DatePayment").'</td><td>';
print dol_print_date($vatpayment->datep,'day');
print '</td></tr>';
print '<tr><td>'.$langs->trans("DateValue").'</td><td colspan="3">';
print '<tr><td>'.$langs->trans("DateValue").'</td><td>';
print dol_print_date($vatpayment->datev,'day');
print '</td></tr>';
print '<tr><td>'.$langs->trans("Amount").'</td><td colspan="3">'.price($vatpayment->amount).'</td></tr>';
print '<tr><td>'.$langs->trans("Amount").'</td><td>'.price($vatpayment->amount).'</td></tr>';
if (! empty($conf->banque->enabled))
{
@ -261,7 +261,7 @@ if ($id)
print '<tr>';
print '<td>'.$langs->trans('BankTransactionLine').'</td>';
print '<td colspan="3">';
print '<td>';
print $bankline->getNomUrl(1,0,'showall');
print '</td>';
print '</tr>';
@ -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 '</table>';
dol_fiche_end();
/*
* Boutons d'actions

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2010-2012 Juanjo Menent <jmenent@2byte.es>
*
@ -107,33 +107,32 @@ if ($result)
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="page" value="'.$page.'">';
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
print_barre_liste($langs->trans("WithdrawalsReceipts"), $page, $_SERVER["PHP_SELF"], $urladd, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_generic', 0, '', '', $limit);
$moreforfilter='';
print '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
print '<tr class="liste_titre">';
print '<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_ref" value="'. $db->escape($search_ref).'"></td>';
print '<td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre" align="right">';
$searchpicto=$form->showFilterButtons();
print $searchpicto;
print '</td>';
print '</tr>';
print '<tr class="liste_titre">';
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 "</tr>\n";
print '<tr class="liste_titre">';
print '<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_ref" value="'. $db->escape($search_ref).'"></td>';
print '<td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre" align="right">';
$searchpicto=$form->showFilterAndCheckAddButtons(0);
print $searchpicto;
print '</td>';
print '</tr>';
while ($i < min($num,$limit))
{
$obj = $db->fetch_object($result);
$obj = $db->fetch_object($result);
print '<tr class="oddeven"><td>';
@ -151,9 +150,9 @@ if ($result)
}
print "</table>";
print '</div>';
print '</form>';
$db->free($result);
}
else

View File

@ -94,9 +94,7 @@ llxHeader('', $langs->trans("NewStandingOrder"));
if (prelevement_check_config() < 0)
{
$langs->load("errors");
print '<div class="error">';
print $langs->trans("ErrorModuleSetupNotComplete");
print '</div>';
setEventMessages($langs->trans("ErrorModuleSetupNotComplete"), null, 'errors');
}
/*$h=0;
@ -148,7 +146,7 @@ if ($nb)
}
else
{
print '<a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv("NoInvoiceToWithdraw")).'">'.$langs->trans("CreateAll")."</a>\n";
print '<a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv("NoInvoiceToWithdraw", $langs->transnoentitiesnoconv("StandingOrders"))).'">'.$langs->trans("CreateAll")."</a>\n";
}
print "</div>\n";
@ -194,7 +192,7 @@ if ($resql)
while ($i < $num && $i < 20)
{
$obj = $db->fetch_object($resql);
print '<tr class="oddeven">';
print '<td>';
$invoicestatic->id=$obj->rowid;
@ -268,7 +266,7 @@ if ($result)
while ($i < min($num,$limit))
{
$obj = $db->fetch_object($result);
print '<tr class="oddeven">';

View File

@ -129,7 +129,7 @@ if ($resql)
$invoicestatic->type=$obj->type;
$alreadypayed=$invoicestatic->getSommePaiement();
print '<tr class="oddeven"><td>';
print $invoicestatic->getNomUrl(1,'withdraw');
print '</td>';
@ -157,7 +157,7 @@ if ($resql)
}
else
{
print '<tr '.$bc[false].'><td colspan="2" class="opacitymedium">'.$langs->trans("NoInvoiceToWithdraw").'</td></tr>';
print '<tr class="oddeven"><td colspan="5" class="opacitymedium">'.$langs->trans("NoInvoiceToWithdraw", $langs->transnoentitiesnoconv("StandingOrders")).'</td></tr>';
}
print "</table><br>";
}
@ -197,7 +197,7 @@ if ($result)
while ($i < min($num,$limit))
{
$obj = $db->fetch_object($result);
print '<tr class="oddeven">';

View File

@ -130,10 +130,24 @@ if ($result)
print '<form action="'.$_SERVER["PHP_SELF"].'" method="GET">';
$moreforfilter='';
print '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
print '<tr class="liste_titre">';
print '<td class="liste_titre"><input type="text" class="flat" name="search_line" value="'. dol_escape_htmltag($search_line).'" size="6"></td>';
print '<td class="liste_titre"><input type="text" class="flat" name="search_bon" value="'. dol_escape_htmltag($search_bon).'" size="6"></td>';
print '<td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre"><input type="text" class="flat" name="search_company" value="'. dol_escape_htmltag($search_company).'" size="6"></td>';
print '<td class="liste_titre" align="center"><input type="text" class="flat" name="search_code" value="'. dol_escape_htmltag($search_code).'" size="6"></td>';
print '<td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre" align="right">';
$searchpicto=$form->showFilterButtons();
print $searchpicto;
print '</td>';
print '</tr>';
print '<tr class="liste_titre">';
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 "</tr>\n";
print '<tr class="liste_titre">';
print '<td class="liste_titre"><input type="text" class="flat" name="search_line" value="'. dol_escape_htmltag($search_line).'" size="6"></td>';
print '<td class="liste_titre"><input type="text" class="flat" name="search_bon" value="'. dol_escape_htmltag($search_bon).'" size="6"></td>';
print '<td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre"><input type="text" class="flat" name="search_company" value="'. dol_escape_htmltag($search_company).'" size="6"></td>';
print '<td class="liste_titre" align="center"><input type="text" class="flat" name="search_code" value="'. dol_escape_htmltag($search_code).'" size="6"></td>';
print '<td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre" align="right">';
$searchpicto=$form->showFilterAndCheckAddButtons(0);
print $searchpicto;
print '</td>';
print '</tr>';
while ($i < min($num,$limit))
{
$obj = $db->fetch_object($result);
$obj = $db->fetch_object($result);
print '<tr class="oddeven"><td>';
@ -199,9 +199,9 @@ if ($result)
}
print "</table>";
print '</div>';
print '</form>';
$db->free($result);
}
else

View File

@ -1,8 +1,8 @@
<?php
/* Copyright (C) 2011-2017 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
/* Copyright (C) 2011-2017 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2014 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2015 Charlie BENKE <charlie@patas-monkey.com>
* Copyright (C) 2015 Charlie BENKE <charlie@patas-monkey.com>
*
* 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 '<table class="border" width="100%">';
// 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 '</table>';
@ -340,35 +340,35 @@ if ($id)
$morehtmlref.=$langs->trans('Employee') . ' : ' . $userstatic->getNomUrl(1);
$morehtmlref.='</div>';
dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', '');
dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', '');
print '<div class="fichecenter">';
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
print '<table class="border" width="100%">';
// Label
print '<tr><td class="titlefield">'.$langs->trans("Label").'</td><td>'.$object->label.'</td></tr>';
print "<tr>";
print '<td>'.$langs->trans("DateStartPeriod").'</td><td colspan="3">';
print '<td>'.$langs->trans("DateStartPeriod").'</td><td>';
print dol_print_date($object->datesp,'day');
print '</td></tr>';
print '<tr><td>'.$langs->trans("DateEndPeriod").'</td><td colspan="3">';
print '<tr><td>'.$langs->trans("DateEndPeriod").'</td><td>';
print dol_print_date($object->dateep,'day');
print '</td></tr>';
print "<tr>";
print '<td>'.$langs->trans("DatePayment").'</td><td colspan="3">';
print '<td>'.$langs->trans("DatePayment").'</td><td>';
print dol_print_date($object->datep,'day');
print '</td></tr>';
print '<tr><td>'.$langs->trans("DateValue").'</td><td colspan="3">';
print '<tr><td>'.$langs->trans("DateValue").'</td><td>';
print dol_print_date($object->datev,'day');
print '</td></tr>';
print '<tr><td>'.$langs->trans("Amount").'</td><td colspan="3">'.price($object->amount,0,$outputlangs,1,-1,-1,$conf->currency).'</td></tr>';
print '<tr><td>'.$langs->trans("Amount").'</td><td>'.price($object->amount,0,$outputlangs,1,-1,-1,$conf->currency).'</td></tr>';
if (! empty($conf->banque->enabled))
{
@ -379,7 +379,7 @@ if ($id)
print '<tr>';
print '<td>'.$langs->trans('BankTransactionLine').'</td>';
print '<td colspan="3">';
print '<td>';
print $bankline->getNomUrl(1,0,'showall');
print '</td>';
print '</tr>';
@ -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 '</table>';
@ -396,7 +396,7 @@ if ($id)
dol_fiche_end();
/*
* Action buttons
*/
@ -405,7 +405,7 @@ if ($id)
{
if (! empty($user->rights->salaries->delete))
{
print '<a class="butActionDelete" href="card.php?id='.$object->id.'&action=delete">'.$langs->trans("Delete").'</a>';
print '<a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=delete">'.$langs->trans("Delete").'</a>';
}
else
{

View File

@ -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 '</script>'."\n";
@ -282,7 +282,7 @@ if ($action == 'create')
print '<td><input name="num_payment" type="text" value="'.GETPOST("num_payment").'"></td></tr>'."\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 '</table>';
@ -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 '</table>';

View File

@ -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';

View File

@ -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 "</table><br>";
print '<hr style="margin-bottom: 20px">';
// Add personnal information
print load_fiche_titre('<div class="comboperso">'.$langs->trans("PersonalInformations").'</div>','','');
@ -787,7 +787,7 @@ else
print $object->ref;
print '</td></tr>';
}
// Lastname
print '<tr><td class="titlefieldcreate fieldrequired"><label for="lastname">'.$langs->trans("Lastname").' / '.$langs->trans("Label").'</label></td>';
print '<td colspan="3"><input name="lastname" id="lastname" type="text" class="minwidth200" maxlength="80" value="'.(isset($_POST["lastname"])?GETPOST("lastname"):$object->lastname).'" autofocus="autofocus"></td>';
@ -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 = '<a href="'.DOL_URL_ROOT.'/contact/list.php">'.$langs->trans("BackToList").'</a>';
$morehtmlref='<div class="refidno">';
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.='</div>';
$morehtmlref.='</div>';
dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref);
print '<div class="fichecenter">';
print '<div class="fichehalfleft">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border tableforfield" width="100%">';
@ -1102,26 +1102,14 @@ else
print $object->LibPubPriv($object->priv);
print '</td></tr>';
// Note Public
/*
print '<tr><td class="tdtop">'.$langs->trans("NotePublic").'</td><td>';
print nl2br($object->note_public);
print '</td></tr>';
// Note Private
print '<tr><td class="tdtop">'.$langs->trans("NotePrivate").'</td><td>';
print nl2br($object->note_private);
print '</td></tr>';
*/
print '</table>';
print '</div>';
print '<div class="fichehalfright"><div class="ficheaddleft">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border tableforfield" width="100%">';
// Categories
if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire)) {
print '<tr><td class="titlefield">' . $langs->trans("Categories") . '</td>';
@ -1130,14 +1118,10 @@ else
print '</td></tr>';
}
// 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 '</td></tr>';
print "</table>";
print '</div></div></div>';
print '<div style="clear:both"></div>';
print dol_fiche_end();
// Barre d'actions

View File

@ -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 = '<a href="'.DOL_URL_ROOT.'/contrat/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
$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.='<div class="refidno">';
// 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 '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
// Ligne info remises tiers
print '<tr><td class="titlefield">'.$langs->trans('Discount').'</td><td colspan="3">';
if ($object->thirdparty->remise_percent) print $langs->trans("CompanyHasRelativeDiscount",$object->thirdparty->remise_percent);
@ -1423,7 +1423,7 @@ else
print "</table>";
print '</div>';
if (! empty($object->brouillon) && $user->rights->contrat->creer)
{
print '</form>';
@ -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 '<a href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;ligne=' . $object->lines[$cursorline - 1]->id . '&amp;action=' . $tmpaction . '">';
print img_picto($tmpactiontext, $tmpactionpicto);
@ -1962,7 +1962,7 @@ else
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
print '</td>';
print '</tr>';
print '</table>';
print '</form>';
@ -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 '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=reopen">'.$langs->trans("Modify").'</a></div>';
else print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans("Modify").'</a></div>';
}
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 '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/commande/card.php?action=create&amp;origin='.$object->element.'&amp;originid='.$object->id.'&amp;socid='.$object->thirdparty->id.'">'.$langs->trans("CreateOrder").'</a></div>';
else print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans("CreateOrder").'</a></div>';
}
// Clone
if ($user->rights->contrat->creer) {
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&amp;socid=' . $object->socid . '&amp;action=clone&amp;object=' . $object->element . '">' . $langs->trans("ToClone") . '</a></div>';
@ -2083,16 +2083,16 @@ else
print "</div>";
}
// Select mail models is same action as presend
if (GETPOST('modelselected')) {
$action = 'presend';
}
if ($action != 'presend')
{
print '<div class="fichecenter"><div class="fichehalfleft">';
/*
* 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 '</div><div class="fichehalfright"><div class="ficheaddleft">';
// 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 '</div></div></div>';
}

View File

@ -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 '<tr class="liste_titre nodrag nodrop">';
if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) print '<td class="linecolnum" align="center" width="5">&nbsp;</td>';
// Description
print '<td class="linecoldescription">'.$langs->trans('Description').'</td>';
if ($this->element == 'supplier_proposal')
{
print '<td class="linerefsupplier" align="right"><span id="title_fourn_ref">'.$langs->trans("SupplierProposalRefFourn").'</span></td>';
}
// VAT
print '<td class="linecolvat" align="right" width="80">'.$langs->trans('VAT').'</td>';
// Price HT
print '<td class="linecoluht" align="right" width="80">'.$langs->trans('PriceUHT').'</td>';
// Multicurrency
if (!empty($conf->multicurrency->enabled)) print '<td class="linecoluht_currency" align="right" width="80">'.$langs->trans('PriceUHTCurrency', $this->multicurrency_code).'</td>';
if ($inputalsopricewithtax) print '<td align="right" width="80">'.$langs->trans('PriceUTTC').'</td>';
// Qty
print '<td class="linecolqty" align="right">'.$langs->trans('Qty').'</td>';
if($conf->global->PRODUCT_USE_UNITS)
{
print '<td class="linecoluseunit" align="left">'.$langs->trans('Unit').'</td>';
}
// Reduction short
print '<td class="linecoldiscount" align="right">'.$langs->trans('ReductionShort').'</td>';
if ($this->situation_cycle_ref) {
print '<td class="linecolcycleref" align="right">' . $langs->trans('Progress') . '</td>';
}
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 '<td class="linecolmargin1 margininfos" align="right" width="80">'.$langs->trans('BuyingPrice').'</td>';
else
print '<td class="linecolmargin1 margininfos" align="right" width="80">'.$langs->trans('CostPrice').'</td>';
print '<td class="linecolmargin1 margininfos" align="right" width="80">'.$langs->trans('CostPrice').'</td>';
}
if (! empty($conf->global->DISPLAY_MARGIN_RATES) && $user->rights->margins->liretous)
print '<td class="linecolmargin2 margininfos" align="right" width="50">'.$langs->trans('MarginRate').'</td>';
if (! empty($conf->global->DISPLAY_MARK_RATES) && $user->rights->margins->liretous)
print '<td class="linecolmargin2 margininfos" align="right" width="50">'.$langs->trans('MarkRate').'</td>';
}
// Total HT
print '<td class="linecolht" align="right">'.$langs->trans('TotalHTShort').'</td>';
// Multicurrency
if (!empty($conf->multicurrency->enabled)) print '<td class="linecoltotalht_currency" align="right">'.$langs->trans('TotalHTShortCurrency', $this->multicurrency_code).'</td>';
if ($outputalsopricetotalwithtax) print '<td align="right" width="80">'.$langs->trans('TotalTTCShort').'</td>';
print '<td class="linecoledit"></td>'; // No width to allow autodim
print '<td class="linecoldelete" width="10"></td>';
print '<td class="linecolmove" width="10"></td>';
print "</tr>\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 )."'";
}
}

View File

@ -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);

View File

@ -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 '<span class="opacitymedium">'.$langs->trans("AutomaticallyCalculated").'</span>';
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.<br>';
}
@ -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='<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">'.implode(' ', $toprint).'</ul></div>';
} else {
dol_syslog(get_class($this) . '::showOutputField error ' . $this->db->lasterror(), LOG_WARNING);
}

View File

@ -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)
{

View File

@ -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.")";
}

View File

@ -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)

View File

@ -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)";

View File

@ -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 '<table class="border centpercent">';
// Import key
if (! empty($object->import_key))
{
@ -378,7 +378,7 @@ function dol_print_object_info($object, $usetable=0)
if ($usetable) print '</td></tr>';
else print '<br>';
}
// Date approve
if (! empty($object->date_approve2))
{
@ -391,7 +391,7 @@ function dol_print_object_info($object, $usetable=0)
if ($usetable) print '</td></tr>';
else print '<br>';
}
// User close
if (! empty($object->user_cloture))
{
@ -476,7 +476,7 @@ function dol_print_object_info($object, $usetable=0)
if ($usetable) print '</td></tr>';
else print '<br>';
}
if ($usetable) print '</table>';
}
@ -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."<br>\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
*/

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2006-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2010-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2010-2017 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
*
* 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 ? ' <span class="badge">'.$nbagenda.'</span>' : '');
$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.'&amp;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 '</td>';
}
// Background color THEME_ELDY_BACKBODY
if ($foruserprofile)
{
@ -508,7 +480,7 @@ function show_theme($fuser,$edit=0,$foruserprofile=false)
else print '';
}
if ($edit) print '<br>('.$langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis").')';
print '</td>';*/
print '</td>';*/
}
else
{
@ -530,7 +502,7 @@ function show_theme($fuser,$edit=0,$foruserprofile=false)
print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis"));
print '</td>';
}
// TopMenuBackgroundColor
if ($foruserprofile)
{
@ -553,13 +525,13 @@ function show_theme($fuser,$edit=0,$foruserprofile=false)
else print '';
}
if ($edit) print '<br>('.$langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis").')';
print '</td>';*/
print '</td>';*/
}
else
{
$default='5a6482';
if ($conf->theme == 'md') $default='5a3278';
print '<tr class="oddeven">';
print '<td>'.$langs->trans("TopMenuBackgroundColor").'</td>';
print '<td colspan="'.($colspan-1).'">';
@ -577,15 +549,15 @@ function show_theme($fuser,$edit=0,$foruserprofile=false)
print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis"));
print '</td>';
}
// BackgroundTableTitleColor
if ($foruserprofile)
{
}
else
{
{
print '<tr class="oddeven">';
print '<td>'.$langs->trans("BackgroundTableTitleColor").'</td>';
print '<td colspan="'.($colspan-1).'">';
@ -613,7 +585,7 @@ function show_theme($fuser,$edit=0,$foruserprofile=false)
{
$default='ffffff';
if ($conf->theme == 'md') $default='ffffff';
print '<tr class="oddeven">';
print '<td>'.$langs->trans("BackgroundTableLineOddColor").'</td>';
print '<td colspan="'.($colspan-1).'">';
@ -631,17 +603,17 @@ function show_theme($fuser,$edit=0,$foruserprofile=false)
print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis"));
print '</td>';
}
// BackgroundTableLineEvenColor
if ($foruserprofile)
{
}
else
{
$default='f8f8f8';
if ($conf->theme == 'md') $default='f8f8f8';
print '<tr class="oddeven">';
print '<td>'.$langs->trans("BackgroundTableLineEvenColor").'</td>';
print '<td colspan="'.($colspan-1).'">';
@ -659,12 +631,12 @@ function show_theme($fuser,$edit=0,$foruserprofile=false)
print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis"));
print '</td>';
}
// TextTitleColor
if ($foruserprofile)
{
}
else
{
@ -681,12 +653,12 @@ function show_theme($fuser,$edit=0,$foruserprofile=false)
}
print ' &nbsp; ('.$langs->trans("Default").': <strong><span style="color: #3c3c14">3c3c14</span></strong>) ';
print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis"));
print '</td>';
print '</tr>';
}
// 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 '<input type="text" class="colorthumb" disabled="disabled" style="padding: 1px; margin-top: 0; margin-bottom: 0; background-color: #'.$color.'" value="'.$color.'">';
else
else
{
//print '<input type="text" class="colorthumb" disabled="disabled" style="padding: 1px; margin-top: 0; margin-bottom: 0; background-color: #'.$defaultcolor.'" value="'.$langs->trans("Default").'">';
//print '<span style="color: #000078">'.$langs->trans("Default").'</span>';
@ -735,7 +707,7 @@ function show_theme($fuser,$edit=0,$foruserprofile=false)
print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis"));
print '</td>';
}
// 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 '<input type="text" class="colorthumb" disabled="disabled" style="padding: 1px; margin-top: 0; margin-bottom: 0; background-color: #'.$color.'" value="'.$color.'">';
else print $langs->trans("Default");
@ -779,7 +751,6 @@ function show_theme($fuser,$edit=0,$foruserprofile=false)
print '</td>';
print '</tr>';
}
print '</table>';
}

View File

@ -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='';

View File

@ -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='';

View File

@ -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&amp;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&amp;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&amp;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&amp;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__);

View File

@ -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));
}
}

View File

@ -17,22 +17,28 @@
*
* Need to have following variables defined:
* $object (invoice, order, ...)
* $action
* $conf
* $langs
*
* $parameters
* $cols
*/
?>
<!-- BEGIN PHP TEMPLATE admin_extrafields_view.tpl.php -->
<!-- BEGIN PHP TEMPLATE extrafields_view.tpl.php -->
<?php
//$res = $object->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 '<tr class="hideobject"><td>';
if (! empty($extrafields->attributes[$object->table_element]['ishidden'][$key])) print '<tr class="hideobject"><td>';
else print '<tr><td>';
print '<table width="100%" class="nobordernopadding">';
print '<tr>';
print '<td';
//var_dump($action);exit;
if ((! empty($action) && ($action == 'create' || $action == 'edit')) && ! empty($extrafields->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) . '</td>';
//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 '<td align="right"><a href="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=edit_extras&attribute=' . $key . '">' . img_edit().'</a></td>';
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 '<td align="right"><a href="' . $_SERVER['PHP_SELF'] . '?'.$fieldid.'=' . $object->id . '&action=edit_extras&attribute=' . $key . '">' . img_edit().'</a></td>';
}
print '</tr></table>';
$html_id = !empty($object->id) ? $object->element.'_extras_'.$key.'_'.$object->id : '';
print '<td id="'.$html_id.'" class="'.$object->element.'_extras_'.$key.'" colspan="'.$cols.'">';
// 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 '<form enctype="multipart/form-data" action="' . $_SERVER["PHP_SELF"] . '" method="post" name="formextra">';
$fieldid='id';
if ($object->table_element == 'societe') $fieldid='socid';
print '<form enctype="multipart/form-data" action="' . $_SERVER["PHP_SELF"] . '" method="post" name="formextra">';
print '<input type="hidden" name="action" value="update_extras">';
print '<input type="hidden" name="attribute" value="' . $key . '">';
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<input type="hidden" name="id" value="' . $object->id . '">';
print '<input type="hidden" name="'.$fieldid.'" value="' . $object->id . '">';
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 '</td></tr>' . "\n";
print "\n";
// Add code to manage list depending on others
if (! empty($conf->use_javascript_ajax))
print '
<script type="text/javascript">
jQuery(document).ready(function() {
function showOptions(child_list, parent_list)
{
var val = $("select[name=\"options_"+parent_list+"\"]").val();
var parentVal = parent_list + ":" + val;
if(val > 0) {
$("select[name=\""+child_list+"\"] option[parent]").hide();
$("select[name=\""+child_list+"\"] option[parent=\""+parentVal+"\"]").show();
} else {
$("select[name=\""+child_list+"\"] option").show();
}
}
function setListDependencies() {
jQuery("select option[parent]").parent().each(function() {
var child_list = $(this).attr("name");
var parent = $(this).find("option[parent]:first").attr("parent");
var infos = parent.split(":");
var parent_list = infos[0];
$("select[name=\""+parent_list+"\"]").change(function() {
showOptions(child_list, parent_list);
});
});
}
setListDependencies();
});
</script>'."\n";
}
}
}
?>
<!-- END PHP TEMPLATE admin_extrafields_view.tpl.php -->
<!-- END PHP TEMPLATE extrafields_view.tpl.php -->

View File

@ -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 '</tr>';
// Country
print '<tr><td><label for="selectcountry_id">'.$langs->trans('Country').'</label></td><td colspan="3" class="maxwidthonsmartphone">';
print '<tr><td><label for="selectcountry_id">'.$langs->trans('Country').'</label></td><td class="maxwidthonsmartphone">';
print $form->select_country(GETPOST('country_id')!=''?GETPOST('country_id'):$object->country_id);
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
print '</td></tr>';
@ -346,7 +346,7 @@ if ($action == 'create')
// Public note
print '<tr>';
print '<td class="border" valign="top">' . $langs->trans('NotePublic') . '</td>';
print '<td valign="top" colspan="2">';
print '<td>';
$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 '<tr>';
print '<td class="border" valign="top">' . $langs->trans('NotePrivate') . '</td>';
print '<td valign="top" colspan="2">';
print '<td>';
$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 '<tr><td>'.$langs->trans("Amount").'</td><td colspan="2">';
print '<tr><td>'.$langs->trans("Amount").'</td><td>';
print price($object->amount,0,$langs,0,0,-1,$conf->currency);
print '</td></tr>';
}
@ -467,7 +467,7 @@ if (! empty($id) && $action == 'edit')
print '</tr>';
// Country
print '<tr><td class="titlefieldcreate">'.$langs->trans('Country').'</td><td colspan="3">';
print '<tr><td class="titlefieldcreate">'.$langs->trans('Country').'</td><td>';
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 '</td></tr>';
@ -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 = '<a href="'.DOL_URL_ROOT.'/don/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
$morehtmlref='<div class="refidno">';
// Project
if (! empty($conf->projet->enabled))
@ -581,8 +581,8 @@ if (! empty($id) && $action != 'edit')
}
}
$morehtmlref.='</div>';
dol_banner_tab($object, 'rowid', $linkback, 1, 'rowid', 'ref', $morehtmlref);
@ -620,7 +620,7 @@ if (! empty($id) && $action != 'edit')
// Zip / Town
print '<tr><td>'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td>';
print $object->zip.($object->zip && $object->town?' / ':'').$object->town.'</td></tr>';
// Country
print '<tr><td>'.$langs->trans('Country').'</td><td>';
if (! empty($object->country_code))
@ -634,18 +634,18 @@ if (! empty($id) && $action != 'edit')
print $object->country_olddata;
}
print '</td></tr>';
// EMail
print "<tr>".'<td>'.$langs->trans("EMail").'</td><td>'.dol_print_email($object->email).'</td></tr>';
*/
// Payment mode
print "<tr><td>".$langs->trans("PaymentMode")."</td><td>";
$form->form_modes_reglement(null, $object->modepaymentid,'none');
print "</td></tr>\n";
//print "<tr>".'<td>'.$langs->trans("Status").'</td><td>'.$object->getLibStatut(4).'</td></tr>';
// Project
/*
if (! empty($conf->projet->enabled))
@ -660,7 +660,7 @@ if (! empty($id) && $action != 'edit')
print '</td>';
print '</tr>';
}*/
// 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 '<tr class="oddeven"><td>';
print '<a href="'.DOL_URL_ROOT.'/don/payment/card.php?id='.$objp->rowid.'">'.img_object($langs->trans("Payment"),"payment").' '.$objp->rowid.'</a></td>';
print '<td>'.dol_print_date($db->jdate($objp->dp),'day')."</td>\n";

View File

@ -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 '<tr><td>';
print $langs->trans("Weight");
print '</td><td><input name="weight" size="4" value="'.GETPOST('weight','int').'"> ';
print '</td><td colspan="3"><input name="weight" size="4" value="'.GETPOST('weight','int').'"> ';
$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 '<td colspan="3">';
print '<input name="tracking_number" size="20" value="'.GETPOST('tracking_number','alpha').'">';
print "</td></tr>\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 "</td></tr>\n";
}
print "</table>";
dol_fiche_end();
// Shipment lines
$numAsked = count($object->lines);
@ -833,14 +833,14 @@ if ($action == 'create')
print '<br>';
print '<table class="noborder" width="100%">';
// Load shipments already done for same order
$object->loadExpeditions();
if ($numAsked)
{
print '<tr class="liste_titre">';
@ -848,7 +848,7 @@ if ($action == 'create')
print '<td align="center">'.$langs->trans("QtyOrdered").'</td>';
print '<td align="center">'.$langs->trans("QtyShipped").'</td>';
print '<td align="center">'.$langs->trans("QtyToShip");
if (empty($conf->productbatch->enabled))
if (empty($conf->productbatch->enabled))
{
print ' <br>(<a href="#" id="autofill">'.$langs->trans("Fill").'</a>';
print ' / <a href="#" id="autoreset">'.$langs->trans("Reset").'</a>)';
@ -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 '<tr class="oddeven">'."\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)?'<br>'.dol_htmlentitiesbr($line->desc):'';
}
print '</td>';
}
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 '<td></td><td></td></tr>'; // 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 '<td colspan="3" ></td><td align="center">';
print '<input name="qtyl'.$indiceAsked.'_'.$subj.'" id="qtyl'.$indiceAsked.'_'.$subj.'" type="text" size="4" value="'.$deliverableQty.'">';
print '</td>';
print '<td align="left">';
print $staticwarehouse->getNomUrl(0).' / ';
print '<!-- Show details of lot -->';
print '<input name="batchl'.$indiceAsked.'_'.$subj.'" type="hidden" value="'.$dbatch->id.'">';
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 '<tr class="oddeven"><td colspan="3"></td><td align="center">';
print '<input name="qtyl'.$indiceAsked.'_'.$subj.'" id="qtyl'.$indiceAsked.'_'.$subj.'" type="text" size="4" value="0" disabled="disabled"> ';
print '</td>';
print '<td align="left">';
print img_warning().' '.$langs->trans("NoProductToShipFoundIntoStock", $staticwarehouse->libelle);
print '</td></tr>';
}
}
}
else
else
{
// ship from multiple locations
if (empty($conf->productbatch->enabled) || ! $product->hasbatch())
{
print '<td></td><td></td></tr>'; // end line and start a new one for each warehouse
print '<!-- Case warehouse not already known and product does not need lot -->';
print '<input name="idl'.$indiceAsked.'" type="hidden" value="'.$line->id.'">';
$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 '</td>';
// 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 '<!-- Show details of stock -->';
print '('.$stock.')';
}
else
{
@ -1193,7 +1193,7 @@ if ($action == 'create')
$subj=0;
print '<input name="idl'.$indiceAsked.'" type="hidden" value="'.$line->id.'">';
$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 '<!-- subj='.$subj.'/'.$nbofsuggested.' --><tr '.((($subj + 1) == $nbofsuggested)?$bc[$var]:'').'><td colspan="3"></td><td align="center">';
print '<input name="qtyl'.$indiceAsked.'_'.$subj.'" id="qtyl'.$indiceAsked.'_'.$subj.'" type="text" size="4" value="'.$deliverableQty.'">';
print '</td>';
print '<td align="left">';
print $tmpwarehouseObject->getNomUrl(0).' / ';
print '<!-- Show details of lot -->';
print '<input name="batchl'.$indiceAsked.'_'.$subj.'" type="hidden" value="'.$dbatch->id.'">';
//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 '</td>';
print '<td align="left">';
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 '</tr>';
}
}
//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.='</div>';
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
print '<div class="fichecenter">';
print '<div class="fichehalfleft">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
// 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 '</td></tr>';
@ -1597,7 +1597,7 @@ else if ($id || $ref)
print '<td colspan="3">';
$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 '</table>';
print '</div>';
print '<div class="fichehalfright">';
print '<div class="ficheaddleft">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border centpercent">';
// Sending method
@ -1667,7 +1667,7 @@ else if ($id || $ref)
}
print '</td>';
print '</tr>';
// Tracking Number
print '<tr><td class="titlefield">'.$form->editfieldkey("TrackingNumber",'trackingnumber',$object->tracking_number,$object,$user->rights->expedition->creer).'</td><td colspan="3">';
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 "</table>";
print '</div>';
print '</div>';
print '</div>';
print '<div class="clearboth"></div>';
/*
* Lines of products
*/
print '<br>';
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
@ -1732,7 +1732,7 @@ else if ($id || $ref)
{
print '<td align="center">'.$langs->trans("QtyInOtherShipments").'</td>';
}
print '<td align="center">'.$langs->trans("CalculatedWeight").'</td>';
print '<td align="center">'.$langs->trans("CalculatedVolume").'</td>';
//print '<td align="center">'.$langs->trans("Size").'</td>';
@ -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 '</td>';
// 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 "</tr>";
// 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 '</tr>';
}
}
// TODO Show also lines ordered but not delivered
print "</table>\n";
print '</div>';
}
@ -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 '<a class="butActionRefused" href="#" title="'.$langs->trans("NotAllowed").'">'.$langs->trans("Validate").'</a>';
}
}
// 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 '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=reopen">'.$langs->trans("ReOpen").'</a>';
}
// Send
if ($object->statut > 0)
{
@ -2040,7 +2040,7 @@ else if ($id || $ref)
}
else print '<a class="butActionRefused" href="#">'.$langs->trans('SendByMail').'</a>';
}
// Create bill and Close shipment
if (! empty($conf->facture->enabled) && $object->statut > 0)
{
@ -2049,7 +2049,7 @@ else if ($id || $ref)
print '<a class="butAction" href="'.DOL_URL_ROOT.'/compta/facture/card.php?action=create&amp;origin='.$object->element.'&amp;originid='.$object->id.'&amp;socid='.$object->socid.'">'.$langs->trans("CreateBill").'</a>';
}
}
// 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 '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action='.$paramaction.'">'.$langs->trans($label).'</a>';
}
}
if ($user->rights->expedition->supprimer)
{
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete">'.$langs->trans("Delete").'</a>';
}
}
print '</div>';
}
@ -2086,11 +2086,11 @@ else if ($id || $ref)
/*
* Documents generated
*/
if ($action != 'presend')
{
print '<div class="fichecenter"><div class="fichehalfleft">';
$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 '</div><div class="fichehalfright"><div class="ficheaddleft">';
// List of actions on element
@ -2117,11 +2117,11 @@ else if ($id || $ref)
print '</div></div></div>';
}
/*
* 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) {

View File

@ -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'])

View File

@ -133,9 +133,9 @@ if ($object->id > 0)
dol_fiche_head($head, 'supplier', $langs->trans("ThirdParty"), -1, 'company');
$linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php">'.$langs->trans("BackToList").'</a>';
dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom');
print '<div class="fichecenter"><div class="fichehalfleft">';
print '<div class="underbanner clearboth"></div>';
@ -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 '</div><div class="fichehalfright"><div class="ficheaddleft">';
$boxstat = '';
// Nbre max d'elements des petites listes
$MAXLIST=$conf->global->MAIN_SIZE_SHORTLIST_LIMIT;
// Lien recap
$boxstat.='<div class="box">';
$boxstat.='<table summary="'.dol_escape_htmltag($langs->trans("DolibarrStateBoard")).'" class="noborder boxtable boxtablenobottom" width="100%">';
$boxstat.='<tr class="impair"><td colspan="2" class="tdboxstats nohover">';
if ($conf->supplier_proposal->enabled)
{
// Box proposals
@ -304,7 +299,7 @@ if ($object->id > 0)
$boxstat.='</div>';
if ($link) $boxstat.='</a>';
}
if ($conf->fournisseur->enabled)
{
// Box proposals
@ -322,14 +317,14 @@ if ($object->id > 0)
$boxstat.='</div>';
if ($link) $boxstat.='</a>';
}
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.='<span class="boxstatsindicator">'.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).'</span>';
$boxstat.='</div>';
if ($link) $boxstat.='</a>';
// 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.='</div>';
if ($link) $boxstat.='</a>';
}
$boxstat.='</td></tr>';
$boxstat.='</table>';
$boxstat.='</div>';
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 '</table>';
}
/*
* 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 '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td colspan="3">';
print '<table class="nobordernopadding" width="100%"><tr><td>'.$langs->trans("LastSupplierProposals",($num<$MAXLIST?"":$MAXLIST)).'</td>';
@ -478,13 +473,13 @@ if ($object->id > 0)
print '</tr></table>';
print '</td></tr>';
}
$var = True;
while ($i < $num && $i <= $MAXLIST)
{
$obj = $db->fetch_object($resql);
print '<tr class="oddeven">';
print '<td class="nowrap">';
$proposalstatic->id = $obj->rowid;
@ -509,14 +504,14 @@ if ($object->id > 0)
$i++;
}
$db->free($resql);
if ($num >0) print "</table>";
}
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 '<tr class="oddeven">';
print '<td class="nowrap">';
@ -660,7 +655,7 @@ if ($object->id > 0)
while ($i < min($num,$MAXLIST))
{
$obj = $db->fetch_object($resql);
print '<tr class="oddeven">';
print '<td>';
print '<a href="facture/card.php?facid='.$obj->rowid.'">';
@ -712,7 +707,7 @@ if ($object->id > 0)
{
print '<div class="inline-block divButAction"><a class="butActionRefused" title="'.dol_escape_js($langs->trans("ThirdPartyIsClosed")).'" href="#">'.$langs->trans("ThirdPartyIsClosed").'</a></div>';
}
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 '</div>';
if (! empty($conf->global->MAIN_REPEATCONTACTONEACHTAB))
{

View File

@ -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 = '<a href="'.DOL_URL_ROOT.'/fourn/commande/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
$morehtmlref='<div class="refidno">';
// 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.='</div>';
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
print '<div class="fichecenter">';
print '<div class="fichehalfleft">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
// Date
@ -1995,16 +1995,15 @@ elseif (! empty($object->id))
}
// Other attributes
$cols = 2;
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
print '</table>';
print '</div>';
print '<div class="fichehalfright">';
print '<div class="ficheaddleft">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border centpercent">';
if (!empty($conf->multicurrency->enabled))
@ -2013,18 +2012,18 @@ elseif (! empty($object->id))
print '<tr><td class="titlefieldmiddle">' . fieldLabel('MulticurrencyAmountHT','multicurrency_total_ht') . '</td>';
print '<td class="nowrap">' . price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>';
print '</tr>';
// Multicurrency Amount VAT
print '<tr><td>' . fieldLabel('MulticurrencyAmountVAT','multicurrency_total_tva') . '</td>';
print '<td class="nowrap">' . price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>';
print '</tr>';
// Multicurrency Amount TTC
print '<tr><td>' . fieldLabel('MulticurrencyAmountTTC','multicurrency_total_ttc') . '</td>';
print '<td class="nowrap">' . price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>';
print '</tr>';
}
// Total
print '<tr><td class="titlefieldmiddle">'.$langs->trans("AmountHT").'</td>';
print '<td>'.price($object->total_ht,'',$langs,1,-1,-1,$conf->currency).'</td>';
@ -2053,19 +2052,19 @@ elseif (! empty($object->id))
print '</tr>';
print '</table>';
// Margin Infos
/*if (! empty($conf->margin->enabled)) {
$formmargin->displayMarginInfos($object);
}*/
print '</div>';
print '</div>';
print '</div>';
print '<div class="clearboth"></div><br>';
if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
{
$blocname = 'contacts';

View File

@ -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[] = '<div class="error">' . $object->error . '</div>';
$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 '<h3>' . $companystatic->getNomUrl(1, 'customer') . '</h3>';
}
print '<form name="orders2invoice" method="GET" action="orderstoinvoice.php">';
print '<input type="hidden" name="socid" value="' . $socid . '">';
print '<table class="noborder" width="100%">';
@ -517,7 +518,7 @@ if (($action != 'create' && $action != 'add') && !$error) {
print '<td class="liste_titre" align="left">';
print '<input class="flat" type="text" size="10" name="sref_client" value="' . $sref_client . '">';
print '</td>';
// DATE ORDER
print '<td class="liste_titre" align="center">';
print $period;
@ -606,9 +607,9 @@ if (($action != 'create' && $action != 'add') && !$error) {
print '<input type="submit" class="butAction" value="' . $langs->trans("GenerateBill") . '">';
print '</div>';
print '</div>';
print '</form>';
$db->free($resql);
} else {
print dol_print_error($db);

View File

@ -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 '<tr><td>' . $langs->trans('Discounts') . '</td><td colspan="2">';
print '<tr><td>' . $langs->trans('Discounts') . '</td><td>';
if ($soc->remise_percent)
print $langs->trans("CompanyHasRelativeDiscount", '<a href="' . DOL_URL_ROOT . '/comm/remise.php?id=' . $soc->id . '&backtopage=' . urlencode($_SERVER["PHP_SELF"] . '?socid=' . $soc->id . '&action=' . $action . '&origin=' . GETPOST('origin') . '&originid=' . GETPOST('originid')) . '">' . $soc->remise_percent . '</a>');
else
@ -1705,17 +1705,17 @@ if ($action == 'create')
print '</td></tr>';
// Payment term
print '<tr><td class="nowrap">'.$langs->trans('PaymentConditionsShort').'</td><td colspan="2">';
print '<tr><td class="nowrap">'.$langs->trans('PaymentConditionsShort').'</td><td>';
$form->select_conditions_paiements(isset($_POST['cond_reglement_id'])?$_POST['cond_reglement_id']:$cond_reglement_id, 'cond_reglement_id');
print '</td></tr>';
// Payment mode
print '<tr><td>'.$langs->trans('PaymentMode').'</td><td colspan="2">';
print '<tr><td>'.$langs->trans('PaymentMode').'</td><td>';
$form->select_types_paiements(isset($_POST['mode_reglement_id'])?$_POST['mode_reglement_id']:$mode_reglement_id, 'mode_reglement_id', 'DBIT');
print '</td></tr>';
// Bank Account
print '<tr><td>'.$langs->trans('BankAccount').'</td><td colspan="2">';
print '<tr><td>'.$langs->trans('BankAccount').'</td><td>';
$form->select_comptes($fk_account, 'fk_account', 0, '', 1);
print '</td></tr>';
@ -1724,7 +1724,7 @@ if ($action == 'create')
{
print '<tr>';
print '<td>'.fieldLabel('Currency','multicurrency_code').'</td>';
print '<td colspan="2" class="maxwidthonsmartphone">';
print '<td class="maxwidthonsmartphone">';
print $form->selectMultiCurrency($currency_code, 'multicurrency_code');
print '</td></tr>';
}
@ -1735,7 +1735,7 @@ if ($action == 'create')
$formproject = new FormProjets($db);
$langs->load('projects');
print '<tr><td>' . $langs->trans('Project') . '</td><td colspan="2">';
print '<tr><td>' . $langs->trans('Project') . '</td><td>';
$formproject->select_projects((empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS)?$societe->id:-1), $projectid, 'projectid', 0, 0, 1, 1);
print '</td></tr>';
}
@ -1790,7 +1790,7 @@ if ($action == 'create')
$langs->load('orders');
$txt=$langs->trans("SupplierOrder");
}
print '<tr><td>'.$txt.'</td><td colspan="2">'.$objectsrc->getNomUrl(1);
print '<tr><td>'.$txt.'</td><td>'.$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 '</td></tr>';
print '<tr><td>'.$langs->trans('TotalHT').'</td><td colspan="2">'.price($objectsrc->total_ht).'</td></tr>';
print '<tr><td>'.$langs->trans('TotalVAT').'</td><td colspan="2">'.price($objectsrc->total_tva)."</td></tr>";
print '<tr><td>'.$langs->trans('TotalHT').'</td><td>'.price($objectsrc->total_ht).'</td></tr>';
print '<tr><td>'.$langs->trans('TotalVAT').'</td><td>'.price($objectsrc->total_tva)."</td></tr>";
if ($mysoc->localtax1_assuj=="1" || $object->total_localtax1 != 0) //Localtax1
{
print '<tr><td>'.$langs->transcountry("AmountLT1",$mysoc->country_code).'</td><td colspan="2">'.price($objectsrc->total_localtax1)."</td></tr>";
print '<tr><td>'.$langs->transcountry("AmountLT1",$mysoc->country_code).'</td><td>'.price($objectsrc->total_localtax1)."</td></tr>";
}
if ($mysoc->localtax2_assuj=="1" || $object->total_localtax2 != 0) //Localtax2
{
print '<tr><td>'.$langs->transcountry("AmountLT2",$mysoc->country_code).'</td><td colspan="2">'.price($objectsrc->total_localtax2)."</td></tr>";
print '<tr><td>'.$langs->transcountry("AmountLT2",$mysoc->country_code).'</td><td>'.price($objectsrc->total_localtax2)."</td></tr>";
}
print '<tr><td>'.$langs->trans('TotalTTC').'</td><td colspan="2">'.price($objectsrc->total_ttc)."</td></tr>";
print '<tr><td>'.$langs->trans('TotalTTC').'</td><td>'.price($objectsrc->total_ttc)."</td></tr>";
if (!empty($conf->multicurrency->enabled))
{
print '<tr><td>' . $langs->trans('MulticurrencyTotalHT') . '</td><td colspan="2">' . price($objectsrc->multicurrency_total_ht) . '</td></tr>';
print '<tr><td>' . $langs->trans('MulticurrencyTotalVAT') . '</td><td colspan="2">' . price($objectsrc->multicurrency_total_tva) . "</td></tr>";
print '<tr><td>' . $langs->trans('MulticurrencyTotalTTC') . '</td><td colspan="2">' . price($objectsrc->multicurrency_total_ttc) . "</td></tr>";
print '<tr><td>' . $langs->trans('MulticurrencyTotalHT') . '</td><td>' . price($objectsrc->multicurrency_total_ht) . '</td></tr>';
print '<tr><td>' . $langs->trans('MulticurrencyTotalVAT') . '</td><td>' . price($objectsrc->multicurrency_total_tva) . "</td></tr>";
print '<tr><td>' . $langs->trans('MulticurrencyTotalTTC') . '</td><td>' . price($objectsrc->multicurrency_total_ttc) . "</td></tr>";
}
}
// 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 '<tr class="oddeven"><td>';
$paymentstatic->id=$objp->rowid;
$paymentstatic->datepaye=$db->jdate($objp->dp);

View File

@ -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 "<div id='ways'>";
$c = new Categorie($db);
@ -175,17 +211,6 @@ if ($resql)
print '<table class="liste" width="100%">';
// Lignes des titres
print "<tr class=\"liste_titre\">";
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 "</tr>\n";
// Lignes des champs de filtre
print '<tr class="liste_titre">';
print '<td class="liste_titre">';
@ -197,19 +222,34 @@ if ($resql)
print '<td class="liste_titre">';
print '<input class="flat" type="text" name="snom" value="'.$snom.'">';
print '</td>';
print '<td class="liste_titre" colspan="4" align="right">';
print '<input type="image" class="liste_titre" value="button_search" name="button_search" src="'.img_picto($langs->trans("Search"),'search.png','','',1).'" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">';
print '&nbsp; ';
print '<input type="image" class="liste_titre" value="button_removefilter" name="button_removefilter" src="'.img_picto($langs->trans("Search"),'searchclear.png','','',1).'" value="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'" title="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'">';
print '<td></td>';
print '<td></td>';
print '<td></td>';
print '<td></td>';
print '<td class="liste_titre" align="right">';
$searchpicto=$form->showFilterButtons();
print $searchpicto;
print '</td>';
print '</tr>';
// Lignes des titres
print '<tr class="liste_titre">';
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 "</tr>\n";
$oldid = '';
$var=True;
while ($i < min($num,$limit))
{
$objp = $db->fetch_object($resql);
print '<tr class="oddeven">';
print '<td>';
@ -236,6 +276,8 @@ if ($resql)
print '<td align="right">'.(isset($objp->unitprice) ? price($objp->unitprice) : '').'</td>';
print '<td align="right"></td>';
print "</tr>\n";
$i++;
}

View File

@ -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";

View File

@ -1,9 +1,9 @@
<?php
/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2015 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2011-2012 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2017 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2011-2012 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
*
* 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",

View File

@ -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;
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);

View File

@ -1,6 +1,7 @@
-- ============================================================================
-- Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
-- Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net>
-- Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
-- Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net>
-- Copyright (C) 2017 Regis Houssin <regis.houssin@capnetworks.com>
--
-- 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);

View File

@ -1,5 +1,6 @@
-- ============================================================================
-- Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
-- Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
-- Copyright (C) 2017 Regis Houssin <regis.houssin@capnetworks.com>
--
-- 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;

View File

@ -1,5 +1,6 @@
-- ============================================================================
-- Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net>
-- Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net>
-- Copyright (C) 2017 Regis Houssin <regis.houssin@capnetworks.com>
--
-- 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);

View File

@ -1,5 +1,6 @@
-- ============================================================================
-- Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net>
-- Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net>
-- Copyright (C) 2017 Regis Houssin <regis.houssin@capnetworks.com>
--
-- 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;

View File

@ -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 '<tr><td colspan="4">';
print '<b>'.$langs->trans('UpgradeExternalModule').'</b>: '.$langs->trans("None");
print '</td></tr>';
//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 '<tr><td colspan="4">';
print '<b>'.$langs->trans('UpgradeExternalModule').'</b>: '.$langs->trans("None");
print '</td></tr>';
}
}
}

View File

@ -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: <strong>$db, $conf, $langs, $mysoc, $user, $object</strong>.<br><strong>WARNING</strong>: 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.<br>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.<br><br>Example of formula:<br>$object->id < 5 ? round($object->id / 2, 2) : ($object->id + 2*$user->id) * (int) substr($mysoc->zip, 1, 2)<br><br>Example of formula to force load of object and its parent object:<br>(($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'<br><br>Other example to reload object<br>(($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: <strong>$db, $conf, $langs, $mysoc, $user, $object</strong>.<br><strong>WARNING</strong>: 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.<br>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.<br><br>Example of formula:<br>$object->id < 10 ? round($object->id / 2, 2) : ($object->id + 2 * $user->id) * (int) substr($mysoc->zip, 1, 2)<br><br>Example to reload object<br>(($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'<br><br>Other example of formula to force load of object and its parent object:<br>(($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<br><br> for example : <br>1,value1<br>2,value2<br>3,value3<br>...<br><br>In order to have the list depending on another complementary attribute list :<br>1,value1|options_<i>parent_list_code</i>:parent_key<br>2,value2|options_<i>parent_list_code</i>:parent_key <br><br>In order to have the list depending on another list :<br>1,value1|<i>parent_list_code</i>:parent_key<br>2,value2|<i>parent_list_code</i>:parent_key
ExtrafieldParamHelpcheckbox=Parameters list have to be like key,value<br><br> for example : <br>1,value1<br>2,value2<br>3,value3<br>...
ExtrafieldParamHelpradio=Parameters list have to be like key,value<br><br> for example : <br>1,value1<br>2,value2<br>3,value3<br>...

View File

@ -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.

View File

@ -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

View File

@ -1,14 +1,14 @@
<?php
/* Copyright (C) 2002-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Xavier Dutoit <doli@sydesy.com>
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2005 Simon Tosser <simon@kornog-computing.com>
* Copyright (C) 2006 Andre Cianfarani <andre.cianfarani@acdeveloppement.net>
* Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2011 Philippe Grand <philippe.grand@atoo-net.com>
/* Copyright (C) 2002-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Xavier Dutoit <doli@sydesy.com>
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* Copyright (C) 2005-2017 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2005 Simon Tosser <simon@kornog-computing.com>
* Copyright (C) 2006 Andre Cianfarani <andre.cianfarani@acdeveloppement.net>
* Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2011 Philippe Grand <philippe.grand@atoo-net.com>
* 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;

View File

@ -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.= '<b>' . $langs->trans('Ref') . ':</b> ' . $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 = '<a href="'.$url.'"';
$linkstart.=$linkclose.'>';
$linkend='</a>';

View File

@ -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

View File

@ -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 '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="action" value="update">';
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
print '<input type="hidden" name="id" value="'.$object->id.'">';
dol_fiche_head();
print '<table class="border centpercent">'."\n";
// print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td><td><input class="flat" type="text" size="36" name="label" value="'.$label.'"></td></tr>';
// LIST_OF_TD_LABEL_FIELDS_EDIT
print '</table>';
dol_fiche_end();
print '<div class="center"><input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">';
@ -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 = '<a href="' . DOL_URL_ROOT . '/mymodule/list.php' . (! empty($socid) ? '?socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
$morehtmlref='<div class="refidno">';
/*
// Ref bis
@ -382,11 +382,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
}
*/
$morehtmlref.='</div>';
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
print '<div class="fichecenter">';
print '<div class="fichehalfleft">';
print '<div class="underbanner clearboth"></div>';
@ -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 '</table>';
@ -405,16 +404,16 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '<div class="ficheaddleft">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border centpercent">';
print '</table>';
print '</div>';
print '</div>';
print '</div>';
print '<div class="clearboth"></div><br>';
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 '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=edit">'.$langs->trans("Modify").'</a></div>'."\n";
}
if ($user->rights->mymodule->delete)
{
print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete">'.$langs->trans('Delete').'</a></div>'."\n";
@ -440,12 +439,12 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '</div>'."\n";
}
// Select mail models is same action as presend
if (GETPOST('modelselected')) {
$action = 'presend';
}
if ($action != 'presend')
{
print '<div class="fichecenter"><div class="fichehalfleft">';
@ -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 '</div><div class="fichehalfright"><div class="ficheaddleft">';
// 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 '</div></div></div>';
}
/*
* Action presend

View File

@ -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 '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
// Fields title
print '<tr class="liste_titre">';
// 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 '</tr>'."\n";
// Fields title search
print '<tr class="liste_titre">';
@ -371,22 +343,22 @@ print '<tr class="liste_titre">';
// 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 '<td class="liste_titre'.($align?' '.$align:'').'">';
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 '<input class="flat'.($searchclass?' '.$searchclass:'').'" size="4" type="text" name="search_options_'.$tmpkey.'" value="'.dol_escape_htmltag($search_array_options['search_options_'.$tmpkey]).'">';
}
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 '<input class="flat'.($searchclass?' '.$searchclass:'').'" size="4" type="text" name="search_options_'.$tmpkey.'" value="'.dol_escape_htmltag($search_array_options['search_options_'.$tmpkey]).'">';
}
print '</td>';
}
}
@ -408,19 +380,48 @@ if (! empty($arrayfields['t.tms']['checked']))
print '</td>';
}
/*if (! empty($arrayfields['u.statut']['checked']))
{
// Status
print '<td class="liste_titre" align="center">';
print $form->selectarray('search_statut', array('-1'=>'','0'=>$langs->trans('Disabled'),'1'=>$langs->trans('Enabled')),$search_statut);
print '</td>';
}*/
{
// Status
print '<td class="liste_titre" align="center">';
print $form->selectarray('search_statut', array('-1'=>'','0'=>$langs->trans('Disabled'),'1'=>$langs->trans('Enabled')),$search_statut);
print '</td>';
}*/
// Action column
print '<td class="liste_titre" align="right">';
$searchpicto=$form->showFilterAndCheckAddButtons($massactionbutton?1:0, 'checkforselect', 1);
$searchpicto=$form->showFilterButtons();
print $searchpicto;
print '</td>';
print '</tr>'."\n";
// Fields title
print '<tr class="liste_titre">';
// 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 '</tr>'."\n";
// Detect if we need a fetch on each output line
$needToFetchEachLine=0;
@ -441,12 +442,12 @@ while ($i < min($num, $limit))
print '<tr class="oddeven">';
// LIST_OF_TD_FIELDS_LIST
/*
if (! empty($arrayfields['t.field1']['checked']))
if (! empty($arrayfields['t.field1']['checked']))
{
print '<td>'.$obj->field1.'</td>';
if (! $i) $totalarray['nbfield']++;
}
if (! empty($arrayfields['t.field2']['checked']))
if (! empty($arrayfields['t.field2']['checked']))
{
print '<td>'.$obj->field2.'</td>';
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 '<td';
$align=$extrafields->getAlignFlag($key);

View File

@ -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 '<table class="border centpercent">';
print '<tr>';
$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 '<tr><td class="tdtop">'.$langs->trans("NoteNotVisibleOnBill").'</td><td colspan="3">';
// 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 "</td></tr>";
//}
if($conf->categorie->enabled) {
// Categories
print '<tr><td>'.$langs->trans("Categories").'</td><td colspan="3">';
@ -1123,7 +1123,7 @@ else
print $formaccounting->select_account(GETPOST('accountancy_code_buy'), 'accountancy_code_buy', 1, null, 1, 1, '');
print '</td></tr>';
}
else // For external software
else // For external software
{
// Accountancy_code_sell
print '<tr><td class="titlefieldcreate">'.$langs->trans("ProductAccountancySellCode").'</td>';
@ -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 '<tr><td class="tdtop">'.$langs->trans("Categories").'</td><td colspan="3">';
$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 '<tr><td class="tdtop">'.$langs->trans("NoteNotVisibleOnBill").'</td><td colspan="3">';
$doleditor = new DolEditor('note_private', $object->note_private, '', 140, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_4, '90%');
$doleditor->Create();
print "</td></tr>";
}
print '</table>';
print '<br>';
@ -1416,7 +1416,7 @@ else
print $formaccounting->select_account($object->accountancy_code_buy, 'accountancy_code_buy', 1, '', 1, 1);
print '</td></tr>';
}
else // For external software
else // For external software
{
// Accountancy_code_sell
print '<tr><td class="titlefield">'.$langs->trans("ProductAccountancySellCode").'</td>';
@ -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 = '<a href="'.DOL_URL_ROOT.'/product/list.php?type='.$object->type.'">'.$langs->trans("BackToList").'</a>';
$object->next_prev_filter=" fk_product_type = ".$object->type;
dol_banner_tab($object, 'ref', $linkback, ($user->societe_id?0:1), 'ref');
print '<div class="fichecenter">';
print '<div class="fichehalfleft">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border tableforfield" width="100%">';
// Type
if (! empty($conf->produit->enabled) && ! empty($conf->service->enabled))
{
@ -1577,7 +1577,7 @@ else
}
print '</td></tr>';
*/
// Batch number management (to batch)
if (! empty($conf->productbatch->enabled)) {
print '<tr><td>'.$langs->trans("ManageLotSerial").'</td><td colspan="2">';
@ -1616,10 +1616,10 @@ else
print '</table>';
print '</div>';
print '<div class="fichehalfright"><div class="ficheaddleft">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border tableforfield" width="100%">';
// 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 '<tr><td class="tdtop">'.$langs->trans("NotePrivate").'</td><td colspan="'.(2+(($showphoto||$showbarcode)?1:0)).'">'.(dol_textishtml($object->note_private)?$object->note_private:dol_nl2br($object->note_private,1,true)).'</td></tr>'."\n";
print '<!-- End show Note --> '."\n";
}
print "</table>\n";
print '</div>';
print '</div></div>';
print '<div style="clear:both"></div>';
dol_fiche_end();
}
@ -1814,16 +1810,16 @@ if (($action == 'clone' && (empty($conf->use_javascript_ajax) || ! empty($conf->
if ($action != 'create' && $action != 'edit')
{
print "\n".'<div class="tabsAction">'."\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 '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&amp;id='.$object->id.'">'.$langs->trans("Modify").'</a></div>';
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 '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans("Delete").'</a></div>';
}
}
print "\n</div>\n";
}
@ -1957,7 +1953,7 @@ if (! empty($conf->global->PRODUCT_ADD_FORM_ADD_TO) && $object->id && ($action =
print '<input type="hidden" name="action" value="addin">';
print load_fiche_titre($langs->trans("AddToDraft"),'','');
dol_fiche_head('');
$html .= '<tr><td class="nowrap">'.$langs->trans("Quantity").' ';
@ -1969,7 +1965,7 @@ if (! empty($conf->global->PRODUCT_ADD_FORM_ADD_TO) && $object->id && ($action =
print '<table width="100%" class="border">';
print $html;
print '</table>';
print '<div class="center">';
print '<input type="submit" class="button" value="'.$langs->trans("Add").'">';
print '</div>';
@ -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 '</div><div class="fichehalfright"><div class="ficheaddleft">';
print '</div></div></div>';

View File

@ -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 = '<a href="'.DOL_URL_ROOT.'/product/list.php">'.$langs->trans("BackToList").'</a>';
$object->next_prev_filter=" fk_product_type = ".$object->type;
dol_banner_tab($object, 'ref', $linkback, ($user->societe_id?0:1), 'ref');
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border tableforfield" width="100%">';
@ -225,14 +226,14 @@ if ($object->id)
print '</div>';
print '<div style="clear:both"></div>';
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 ';
}

View File

@ -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;
}

View File

@ -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

View File

@ -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 = '<a href="'.DOL_URL_ROOT.'/product/list.php">'.$langs->trans("BackToList").'</a>';
dol_banner_tab($object, 'ref', $linkback, ($user->societe_id?0:1), 'ref');
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border tableforfield" width="100%">';
if ($conf->productbatch->enabled)
if ($conf->productbatch->enabled)
{
print '<tr><td class="titlefield">'.$langs->trans("ManageLotSerial").'</td><td>';
print $object->getLibStatut(0,2);
@ -614,11 +614,11 @@ if ($id > 0 || $ref)
print '<tr><td>'.$form->editfieldkey("StockLimit",'seuil_stock_alerte',$object->seuil_stock_alerte,$object,$user->rights->produit->creer).'</td><td colspan="2">';
print $form->editfieldval("StockLimit",'seuil_stock_alerte',$object->seuil_stock_alerte,$object,$user->rights->produit->creer,'string');
print '</td></tr>';
// 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 '<tr><td>'.$form->editfieldkey($form->textwithpicto($langs->trans("DesiredStock"), $langs->trans("DesiredStockDesc"), 1),'desiredstock',$object->desiredstock,$object,$user->rights->produit->creer);
print '</td><td colspan="2">';
@ -643,7 +643,7 @@ if ($id > 0 || $ref)
print '</tr>';
$stocktheo = price2num($object->stock_theorique, 'MS');
$found=0;
$helpondiff='<strong>'.$langs->trans("StockDiffPhysicTeoric").':</strong><br>';
// 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.='<br>'; else $found=1;
$helpondiff.=$langs->trans("ProductQtyInSuppliersShipmentAlreadyRecevied").': '.$object->stats_reception['qty'];
}
// Calculating a theorical value
print '<tr><td>';
print $form->textwithpicto($langs->trans("VirtualStock"), $langs->trans("VirtualStockDesc"));
@ -723,7 +723,7 @@ if ($id > 0 || $ref)
print '</div>';
print '<div style="clear:both"></div>';
dol_fiche_end();
}
@ -762,18 +762,18 @@ if (empty($reshook))
if (empty($action) && $object->id)
{
print "<div class=\"tabsAction\">\n";
if ($user->rights->stock->mouvement->creer)
{
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=correction">'.$langs->trans("StockCorrection").'</a>';
}
//if (($user->rights->stock->mouvement->creer) && ! $object->hasbatch())
if ($user->rights->stock->mouvement->creer)
{
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=transfert">'.$langs->trans("StockTransfer").'</a>';
}
print '</div>';
}
@ -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 '<br><br>';
print_titre($langs->trans('AddNewProductStockWarehouse'));
//print '<br />';
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="action" value="addlimitstockwarehouse">';
print '<input type="hidden" name="id" value="'.GETPOST('id').'">';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td width="40%" colspan="4">'.$formproduct->selectWarehouses('', 'fk_entrepot').'</td>';
print '<td align="right"><input name="seuil_stock_alerte" type="text" placeholder="'.$langs->trans("StockLimit").'" /></td>';
print '<td align="right"><input name="desiredstock" type="text" placeholder="'.$langs->trans("DesiredStock").'" /></td>';
print '<td align="right"><input type="submit" value="'.$langs->trans('Save').'" class="button" /></td>';
print '</tr>';
$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 '<td align="right">'.$line['desiredstock'].'</td>';
print '<td align="right"><a href="?id='.GETPOST('id').'&fk_productstockwarehouse='.$line['id'].'&action=delete_productstockwarehouse">'.img_delete().'</a></td>';
print '</tr>';
}
}
print "</table>";
print '</form>';
}

View File

@ -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),

View File

@ -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 = '<u>' . $langs->trans("ShowProject") . '</u>';
$label .= ($label?'<br>':'').'<b>' . $langs->trans('Ref') . ': </b>' . $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 = '<a href="'.$url.'"';
$linkstart.=$linkclose.'>';
$linkend='</a>';
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);
}
}

View File

@ -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 = '<u>' . $langs->trans("ShowTask") . '</u>';
if (! empty($this->ref))
@ -597,8 +601,12 @@ class Task extends CommonObject
{
$label .= "<br>".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 = '<a href="'.$url.'"';
$linkstart.=$linkclose.'>';
$linkend='</a>';
$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&amp;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)));
}
}
}

View File

@ -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 = '<a href="'.DOL_URL_ROOT.'/projet/list.php">'.$langs->trans("BackToList").'</a>';
$linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
$morehtmlref='<div class="refidno">';
// Title
$morehtmlref.=$projectstatic->title;
// Thirdparty
if ($projectstatic->thirdparty->id > 0)
if ($projectstatic->thirdparty->id > 0)
{
$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $projectstatic->thirdparty->getNomUrl(1, 'project');
}
$morehtmlref.='</div>';
// 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 '<div class="fichecenter">';
print '<div class="fichehalfleft">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
// Visibility
print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>';
if ($projectstatic->public) print $langs->trans('SharedProject');
else print $langs->trans('PrivateProject');
print '</td></tr>';
// Date start - end
print '<tr><td>'.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").'</td><td>';
print dol_print_date($projectstatic->date_start,'day');
$end=dol_print_date($projectstatic->date_end,'day');
if ($end) print ' - '.$end;
print '</td></tr>';
// Budget
print '<tr><td>'.$langs->trans("Budget").'</td><td>';
if (strcmp($projectstatic->budget_amount, '')) print price($projectstatic->budget_amount,'',$langs,1,0,0,$conf->currency);
print '</td></tr>';
// Other attributes
$cols = 2;
//include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
print '</table>';
print '</div>';
print '<div class="fichehalfright">';
print '<div class="ficheaddleft">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
// Description
print '<td class="titlefield tdtop">'.$langs->trans("Description").'</td><td>';
print nl2br($projectstatic->description);
print '</td></tr>';
// Categories
if($conf->categorie->enabled) {
print '<tr><td valign="middle">'.$langs->trans("Categories").'</td><td>';
print $form->showCategories($projectstatic->id,'project',1);
print "</td></tr>";
}
print '</table>';
print '</div>';
print '</div>';
print '</div>';
print '<div class="clearboth"></div>';
dol_fiche_end();
@ -284,16 +284,16 @@ if ($id > 0 || ! empty($ref))
$param=(GETPOST('withproject')?'&withproject=1':'');
$linkback=GETPOST('withproject')?'<a href="'.DOL_URL_ROOT.'/projet/tasks.php?id='.$projectstatic->id.'">'.$langs->trans("BackToList").'</a>':'';
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.='<br>';
// Third party
$morehtmlref.=$langs->trans("ThirdParty").': ';
$morehtmlref.=$projectstatic->thirdparty->getNomUrl(1);
$morehtmlref.='</div>';
}
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 '<input type="hidden" name="id" value="'.$object->id.'">';
if ($withproject) print '<input type="hidden" name="withproject" value="'.$withproject.'">';
print '<tr class="oddeven">';
print '<td class="nowrap">';

View File

@ -136,84 +136,84 @@ if ($object->id > 0)
// Project card
$linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php">'.$langs->trans("BackToList").'</a>';
$linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
$morehtmlref='<div class="refidno">';
// Title
$morehtmlref.=$projectstatic->title;
// Thirdparty
if ($projectstatic->thirdparty->id > 0)
if ($projectstatic->thirdparty->id > 0)
{
$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $projectstatic->thirdparty->getNomUrl(1, 'project');
}
$morehtmlref.='</div>';
// 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 '<div class="fichecenter">';
print '<div class="fichehalfleft">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
// Visibility
print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>';
if ($projectstatic->public) print $langs->trans('SharedProject');
else print $langs->trans('PrivateProject');
print '</td></tr>';
// Date start - end
print '<tr><td>'.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").'</td><td>';
print dol_print_date($projectstatic->date_start,'day');
$end=dol_print_date($projectstatic->date_end,'day');
if ($end) print ' - '.$end;
print '</td></tr>';
// Budget
print '<tr><td>'.$langs->trans("Budget").'</td><td>';
if (strcmp($projectstatic->budget_amount, '')) print price($projectstatic->budget_amount,'',$langs,1,0,0,$conf->currency);
print '</td></tr>';
// Other attributes
$cols = 2;
//include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
print '</table>';
print '</div>';
print '<div class="fichehalfright">';
print '<div class="ficheaddleft">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
// Description
print '<td class="titlefield tdtop">'.$langs->trans("Description").'</td><td>';
print nl2br($projectstatic->description);
print '</td></tr>';
// Categories
if($conf->categorie->enabled) {
print '<tr><td valign="middle">'.$langs->trans("Categories").'</td><td>';
print $form->showCategories($projectstatic->id,'project',1);
print "</td></tr>";
}
print '</table>';
print '</div>';
print '</div>';
print '</div>';
print '<div class="clearboth"></div>';
dol_fiche_end();
}
@ -227,7 +227,7 @@ if ($object->id > 0)
{
$totalsize+=$file['size'];
}
$param=(GETPOST('withproject')?'&withproject=1':'');
$linkback=GETPOST('withproject')?'<a href="'.DOL_URL_ROOT.'/projet/tasks.php?id='.$projectstatic->id.'">'.$langs->trans("BackToList").'</a>':'';
@ -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.='<br>';
// Third party
$morehtmlref.=$langs->trans("ThirdParty").': ';
$morehtmlref.=$projectstatic->thirdparty->getNomUrl(1);
$morehtmlref.='</div>';
}
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, $param);
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
@ -268,7 +268,7 @@ if ($object->id > 0)
print "</table>\n";
print '</div>';
dol_fiche_end();
print '<br>';

View File

@ -114,9 +114,9 @@ if ($object->id > 0)
$param=($mode=='mine'?'&mode=mine':'');
// Project card
$linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php">'.$langs->trans("BackToList").'</a>';
$linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
$morehtmlref='<div class="refidno">';
// Title
$morehtmlref.=$projectstatic->title;
@ -126,92 +126,92 @@ if ($object->id > 0)
$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $projectstatic->thirdparty->getNomUrl(1, 'project');
}
$morehtmlref.='</div>';
// 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 '<div class="fichecenter">';
print '<div class="fichehalfleft">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
// Visibility
print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>';
if ($projectstatic->public) print $langs->trans('SharedProject');
else print $langs->trans('PrivateProject');
print '</td></tr>';
// Date start - end
print '<tr><td>'.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").'</td><td>';
print dol_print_date($projectstatic->date_start,'day');
$end=dol_print_date($projectstatic->date_end,'day');
if ($end) print ' - '.$end;
print '</td></tr>';
// Budget
print '<tr><td>'.$langs->trans("Budget").'</td><td>';
if (strcmp($projectstatic->budget_amount, '')) print price($projectstatic->budget_amount,'',$langs,1,0,0,$conf->currency);
print '</td></tr>';
// Other attributes
$cols = 2;
//include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
print '</table>';
print '</div>';
print '<div class="fichehalfright">';
print '<div class="ficheaddleft">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
// Description
print '<td class="titlefield tdtop">'.$langs->trans("Description").'</td><td>';
print nl2br($projectstatic->description);
print '</td></tr>';
// Categories
if($conf->categorie->enabled) {
print '<tr><td valign="middle">'.$langs->trans("Categories").'</td><td>';
print $form->showCategories($projectstatic->id,'project',1);
print "</td></tr>";
}
print '</table>';
print '</div>';
print '</div>';
print '</div>';
print '<div class="clearboth"></div>';
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')?'<a href="'.DOL_URL_ROOT.'/projet/tasks.php?id='.$projectstatic->id.'">'.$langs->trans("BackToList").'</a>':'';
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.='<br>';
// Third party
$morehtmlref.=$langs->trans("ThirdParty").': ';
$morehtmlref.=$projectstatic->thirdparty->getNomUrl(1);
$morehtmlref.='</div>';
}
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, $param);
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
$cssclass='titlefield';
@ -237,7 +237,7 @@ if ($object->id > 0)
include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
print '</div>';
dol_fiche_end();
}

View File

@ -226,85 +226,85 @@ if ($id > 0 || ! empty($ref))
$param=($mode=='mine'?'&mode=mine':'');
// Project card
$linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php">'.$langs->trans("BackToList").'</a>';
$linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
$morehtmlref='<div class="refidno">';
// Title
$morehtmlref.=$projectstatic->title;
// Thirdparty
if ($projectstatic->thirdparty->id > 0)
if ($projectstatic->thirdparty->id > 0)
{
$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $projectstatic->thirdparty->getNomUrl(1, 'project');
}
$morehtmlref.='</div>';
// 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 '<div class="fichecenter">';
print '<div class="fichehalfleft">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
// Visibility
print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>';
if ($projectstatic->public) print $langs->trans('SharedProject');
else print $langs->trans('PrivateProject');
print '</td></tr>';
// Date start - end
print '<tr><td>'.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").'</td><td>';
print dol_print_date($projectstatic->date_start,'day');
$end=dol_print_date($projectstatic->date_end,'day');
if ($end) print ' - '.$end;
print '</td></tr>';
// Budget
print '<tr><td>'.$langs->trans("Budget").'</td><td>';
if (strcmp($projectstatic->budget_amount, '')) print price($projectstatic->budget_amount,'',$langs,1,0,0,$conf->currency);
print '</td></tr>';
// Other attributes
$cols = 2;
//include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
print '</table>';
print '</div>';
print '<div class="fichehalfright">';
print '<div class="ficheaddleft">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
// Description
print '<td class="titlefield tdtop">'.$langs->trans("Description").'</td><td>';
print nl2br($projectstatic->description);
print '</td></tr>';
// Categories
if($conf->categorie->enabled) {
print '<tr><td valign="middle">'.$langs->trans("Categories").'</td><td>';
print $form->showCategories($projectstatic->id,'project',1);
print "</td></tr>";
}
print '</table>';
print '</div>';
print '</div>';
print '</div>';
print '<div class="clearboth"></div>';
dol_fiche_end();
print '<br>';
@ -430,7 +430,7 @@ if ($id > 0 || ! empty($ref))
* Fiche tache en mode visu
*/
$param=($withproject?'&withproject=1':'');
$linkback=$withproject?'<a href="'.DOL_URL_ROOT.'/projet/tasks.php?id='.$projectstatic->id.'">'.$langs->trans("BackToList").'</a>':'';
$linkback=$withproject?'<a href="'.DOL_URL_ROOT.'/projet/tasks.php?id='.$projectstatic->id.'&restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>':'';
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.='<br>';
// Third party
$morehtmlref.=$langs->trans("ThirdParty").': ';
$morehtmlref.=$projectstatic->thirdparty->getNomUrl(1);
$morehtmlref.='</div>';
}
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, $param);
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
// Date start - Date end
@ -511,18 +511,15 @@ if ($id > 0 || ! empty($ref))
print nl2br($object->description);
print '</td></tr>';
// 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 '</table>';
print '</div>';
dol_fiche_end();
}
@ -532,7 +529,7 @@ if ($id > 0 || ! empty($ref))
/*
* Actions
*/
print '<div class="tabsAction">';
$parameters = array();
@ -549,7 +546,7 @@ if ($id > 0 || ! empty($ref))
{
print '<a class="butActionRefused" href="#" title="'.$langs->trans("NotAllowed").'">'.$langs->trans('Modify').'</a>';
}
// Delete
if ($user->rights->projet->supprimer)
{
@ -566,13 +563,13 @@ if ($id > 0 || ! empty($ref))
{
print '<a class="butActionRefused" href="#" title="'.$langs->trans("NotAllowed").'">'.$langs->trans('Delete').'</a>';
}
print '</div>';
}
print '<div class="fichecenter"><div class="fichehalfleft">';
print '<a name="builddoc"></a>'; // 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 '</div><div class="fichehalfright"><div class="ficheaddleft">';
print '</div></div></div>';
}
}

View File

@ -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 = '<a href="'.DOL_URL_ROOT.'/projet/list.php">'.$langs->trans("BackToList").'</a>';
$linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
$morehtmlref='<div class="refidno">';
// Title
$morehtmlref.=$projectstatic->title;
// Thirdparty
if ($projectstatic->thirdparty->id > 0)
if ($projectstatic->thirdparty->id > 0)
{
$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $projectstatic->thirdparty->getNomUrl(1, 'project');
}
$morehtmlref.='</div>';
// 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 '<div class="fichecenter">';
print '<div class="fichehalfleft">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
// Visibility
print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>';
if ($projectstatic->public) print $langs->trans('SharedProject');
else print $langs->trans('PrivateProject');
print '</td></tr>';
// Date start - end
print '<tr><td>'.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").'</td><td>';
print dol_print_date($projectstatic->date_start,'day');
$end=dol_print_date($projectstatic->date_end,'day');
if ($end) print ' - '.$end;
print '</td></tr>';
// Budget
print '<tr><td>'.$langs->trans("Budget").'</td><td>';
if (strcmp($projectstatic->budget_amount, '')) print price($projectstatic->budget_amount,'',$langs,1,0,0,$conf->currency);
print '</td></tr>';
// Other attributes
$cols = 2;
//include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
print '</table>';
print '</div>';
print '<div class="fichehalfright">';
print '<div class="ficheaddleft">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
// Description
print '<td class="titlefield tdtop">'.$langs->trans("Description").'</td><td>';
print nl2br($projectstatic->description);
print '</td></tr>';
// Categories
if($conf->categorie->enabled) {
print '<tr><td valign="middle">'.$langs->trans("Categories").'</td><td>';
print $form->showCategories($projectstatic->id,'project',1);
print "</td></tr>";
}
print '</table>';
print '</div>';
print '</div>';
print '</div>';
print '<div class="clearboth"></div>';
dol_fiche_end();
/*
* Actions
*/
@ -399,7 +399,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0)
if ((empty($id) && empty($ref)) || ! empty($projectidforalltimes))
{
print '<div class="tabsAction">';
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 '<a class="butActionRefused" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans('AddTask').'</a>';
}
print '</div>';
}
}
}
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.='<br>';
// Third party
$morehtmlref.=$langs->trans("ThirdParty").': ';
$morehtmlref.=$projectstatic->thirdparty->getNomUrl(1);
$morehtmlref.='</div>';
}
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, $param);
print '<div class="fichecenter">';
print '<div class="fichehalfleft">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
@ -482,12 +482,12 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0)
print '</table>';
print '</div>';
print '<div class="fichehalfright"><div class="ficheaddleft">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
// Progress declared
print '<tr><td>'.$langs->trans("ProgressDeclared").'</td><td>';
print $object->progress.' %';
@ -508,10 +508,10 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0)
print '</div>';
print '</div>';
print '</div>';
print '<div class="clearboth"></div>';
dol_fiche_end();
@ -583,18 +583,18 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0)
print '</td></tr>';
print '</table></form>';
print '<br>';
}
}
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.='&amp;id='.$id;
if ($projectid) $params.='&amp;projectid='.$projectid;
if ($withproject) $params.='&amp;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 '<form method="POST" action="'.$_SERVER["PHP_SELF"].'?id='.$id.'">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@ -708,31 +708,31 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0)
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="page" value="'.$page.'">';
print '<input type="hidden" name="id" value="'.$id.'">';
print '<input type="hidden" name="projectid" value="'.$projectidforalltimes.'">';
print '<input type="hidden" name="withproject" value="'.$withproject.'">';
$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 '<div class="liste_titre liste_titre_bydiv centpercent">';
print $moreforfilter;
print '</div>';
}
$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
print '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
// Fields title search
print '<tr class="liste_titre_filter">';
// Date
@ -783,14 +783,14 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0)
$searchpicto=$form->showFilterAndCheckAddButtons($massactionbutton?1:0, 'checkforselect', 1);
print $searchpicto;
print '</td>';
print '</tr>'."\n";
print '</tr>'."\n";
print '<tr class="liste_titre">';
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 "</tr>\n";
$tasktmp = new Task($db);
$i = 0;
$childids = $user->getAllChildIds();
$total = 0;
$totalvalue = 0;
$totalarray=array();
foreach ($tasks as $task_time)
{
print '<tr class="oddeven">';
$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 '</td>';
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 '<td class="nowrap">';
print $task_time->label;
print $task_time->label;
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
}
// User
if (! empty($arrayfields['author']['checked']))
if (! empty($arrayfields['author']['checked']))
{
print '<td>';
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 '<td align="left">';
if ($_GET['action'] == 'editline' && $_GET['lineid'] == $task_time->rowid)
@ -921,7 +921,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0)
print '</td>';
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 '<td align="right">';
$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 '<td class="center"">';
if ($action == 'editline' && $_GET['lineid'] == $task_time->rowid)
@ -975,7 +975,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0)
print '<a href="'.$_SERVER["PHP_SELF"].'?'.($projectidforalltimes?'projectid='.$projectidforalltimes.'&amp;':'').'id='.$task_time->fk_task.'&amp;action=editline&amp;lineid='.$task_time->rowid.($withproject?'&amp;withproject=1':'').'">';
print img_edit();
print '</a>';
print '&nbsp;';
print '<a href="'.$_SERVER["PHP_SELF"].'?'.($projectidforalltimes?'projectid='.$projectidforalltimes.'&amp;':'').'id='.$task_time->fk_task.'&amp;action=deleteline&amp;lineid='.$task_time->rowid.($withproject?'&amp;withproject=1':'').'">';
print img_delete();
@ -984,12 +984,12 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0)
}
print '</td>';
if (! $i) $totalarray['nbfield']++;
print "</tr>\n";
$i++;
}
// Show total line
if (isset($totalarray['totaldurationfield']) || isset($totalarray['totalvaluefield']))
{

View File

@ -175,7 +175,7 @@ if (! $action)
print '</tr>';
// 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))
{

View File

@ -201,7 +201,7 @@ if ( $object->fetch($id) > 0 )
print '</td></tr>';
// 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 = '<a href="' . DOL_URL_ROOT . '/resource/list.php' . (! empty($socid) ? '?id=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
$morehtmlref='<div class="refidno">';
$morehtmlref.='</div>';
dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref);
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
/*---------------------------------------
* View object
*/
@ -269,21 +269,16 @@ if ( $object->fetch($id) > 0 )
print '</td>';
// 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 '</tr>';
print '</table>';
print '</div>';
print '<div class="clearboth"></div><br>';
dol_fiche_end();
}

View File

@ -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 '<td colspan="3"><input type="text" name="email" id="email" value="'.$object->email.'"></td></tr>';
print '<tr><td>'.fieldLabel('Web','url').'</td>';
print '<td colspan="3"><input type="text" name="url" id="url" value="'.$object->url.'"></td></tr>';
// Skype
if (! empty($conf->skype->enabled))
{
@ -1215,7 +1230,7 @@ else
print '</td><td>'.$langs->transcountry("LocalTax2IsUsed",$mysoc->country_code).'</td><td>';
print $form->selectyesno('localtax2assuj_value',(isset($conf->global->THIRDPARTY_DEFAULT_USELOCALTAX2)?$conf->global->THIRDPARTY_DEFAULT_USELOCALTAX2:0),1);
print '</td></tr>';
}
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 '</td></tr>';
}
// Type - Size
print '<tr><td>'.fieldLabel('ThirdPartyType','typent_id').'</td><td class="maxwidthonsmartphone">'."\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 '<div class="fichecenter2">';
print '<div class="fichecenter2">';
print '<table class="border" width="100%">';
// Ref/ID
@ -1750,7 +1765,7 @@ else
$formcompany->select_localtax(1,$object->localtax1_value, "lt1");
print '</span>';
}
print '</td><td>'.fieldLabel($langs->transcountry("LocalTax2IsUsed",$mysoc->country_code),'localtax2assuj_value').'</td><td>';
print $form->selectyesno('localtax2assuj_value',$object->localtax2_assuj,1);
if (! isOnlyOneLocalTax(2))
@ -1760,7 +1775,7 @@ else
print '</span>';
}
print '</td></tr>';
}
elseif($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj!="1")
{
@ -1773,7 +1788,7 @@ else
print '</span>';
}
print '</td></tr>';
}
elseif($mysoc->localtax2_assuj=="1" && $mysoc->localtax1_assuj!="1")
{
@ -1787,7 +1802,7 @@ else
}
print '</td></tr>';
}
// VAT Code
print '<tr><td>'.fieldLabel('VATIntra','intra_vat').'</td>';
print '<td colspan="3">';
@ -1935,7 +1950,7 @@ else
print '</table>';
print '</div>';
dol_fiche_end();
print '<div align="center">';
@ -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 '</td></tr><tr><td>'.$langs->transcountry("LocalTax2IsUsed",$mysoc->country_code).'</td><td>';
print yn($object->localtax2_assuj);
print '</td></tr>';
if($object->localtax1_assuj=="1" && (! isOnlyOneLocalTax(1)))
{
print '<form method="post" action="'.$_SERVER['PHP_SELF'].'?socid='.$object->id.'">';
@ -2145,7 +2160,7 @@ else
print '<td>'.$object->localtax1_value.'</td>';
}
print '</tr></form>';
}
}
elseif($mysoc->localtax2_assuj=="1" && $mysoc->localtax1_assuj!="1")
@ -2155,7 +2170,7 @@ else
print '</td></tr>';
if($object->localtax2_assuj=="1" && (! isOnlyOneLocalTax(2)))
{
print '<form method="post" action="'.$_SERVER['PHP_SELF'].'?socid='.$object->id.'">';
print '<input type="hidden" name="action" value="set_localtax2">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@ -2168,7 +2183,7 @@ else
print '<td>'.$object->localtax2_value.'</td>';
}
print '</tr></form>';
}
}
/*
@ -2179,7 +2194,7 @@ else
print '</td><tr>';
}
*/
// VAT Code
print '<tr>';
print '<td class="nowrap">'.$langs->trans('VATIntra').'</td><td>';
@ -2308,14 +2323,9 @@ else
print '</td></tr>';
}
// 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))
{

View File

@ -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.= '</div><div style="clear: both;"></div>';
}
$label.= '<div class="centpercent">';
if ($option == 'customer' || $option == 'compta' || $option == 'category' || $option == 'category_supplier')
@ -1903,7 +1898,7 @@ class Societe extends CommonObject
$label.= '<u>' . $langs->trans("ShowMargin") . '</u>';
$linkstart = '<a href="'.DOL_URL_ROOT.'/margin/tabs/thirdpartyMargins.php?socid='.$this->id.'&type=1';
}
// By default
if (empty($linkstart))
{
@ -1924,13 +1919,13 @@ class Societe extends CommonObject
$label.= '<br><b>' . $langs->trans('CustomerAccountancyCode') . ':</b> '. $this->code_compta_client;
if (! empty($conf->accounting->enabled) && $this->fournisseur)
$label.= '<br><b>' . $langs->trans('SupplierAccountancyCode') . ':</b> '. $this->code_compta_fournisseur;
$label.= '</div>';
// Add type of canvas
$linkstart.=(!empty($this->canvas)?'&canvas='.$this->canvas:'');
// 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) $linkstart.='&save_lastsearch_values=1';
$linkstart.='"';
@ -1965,7 +1960,7 @@ class Societe extends CommonObject
$linkstart='';
$linkend='';
}
if ($withpicto) $result.=($linkstart.img_object(($notooltip?'':$label), 'company', ($notooltip?'':'class="classfortooltip valigntextbottom"'), 0, 0, $notooltip?0:1).$linkend);
if ($withpicto && $withpicto != 2) $result.=' ';
if ($withpicto != 2) $result.=$linkstart.($maxlen?dol_trunc($name,$maxlen):$name).$linkend;
@ -3352,7 +3347,7 @@ class Societe extends CommonObject
{
$table='propal';
if ($mode == 'supplier') $table = 'supplier_proposal';
$sql = "SELECT rowid, total_ht, total as total_ttc, fk_statut FROM ".MAIN_DB_PREFIX.$table." as f";
$sql .= " WHERE fk_soc = ". $this->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;

View File

@ -115,9 +115,9 @@ if (! empty($socid))
dol_fiche_head($head, 'salesrepresentative', $langs->trans("ThirdParty"), -1, 'company');
$linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php">'.$langs->trans("BackToList").'</a>';
dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom');
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
@ -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 '<a href="'.DOL_URL_ROOT.'/user/card.php?id='.$obj->rowid.'">';
print img_object($langs->trans("ShowUser"),"user").' ';
print dolGetFirstLastname($obj->firstname, $obj->lastname)."\n";
@ -216,7 +213,7 @@ if (! empty($socid))
print '</table>';
print "</div>\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 "<tr ".$bc[$var]."><td>";
$tmpuser->id=$obj->rowid;
$tmpuser->firstname=$obj->firstname;

View File

@ -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 '<table class="liste" width="100%">'."\n";
// Titles with sort buttons
print '<tr class="liste_titre">';
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 "</tr>\n";
// Filters
print '<tr class="liste_titre">';
print '<td class="liste_titre" align="left">';
@ -393,6 +384,18 @@ if ($sql_select)
print '</td>';
print '</tr>';
// Titles with sort buttons
print '<tr class="liste_titre">';
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 "</tr>\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 '<tr class="oddeven">';
print '<td class="nobordernopadding nowrap" width="100">';
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 "</tr>\n";
print '<tr '.$bc[0].'><td class="opacitymedium" colspan="5">'.$langs->trans("SelectElementAndClickRefresh").'</td></tr>';
print '<tr '.$bc[0].'><td class="opacitymedium" colspan="5">'.$langs->trans("SelectElementAndClick", $langs->transnoentitiesnoconv("Search")).'</td></tr>';
print "</table>";
}

View File

@ -840,6 +840,11 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab
if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum';
print '<input class="flat'.($searchclass?' '.$searchclass:'').'" size="4" type="text" name="search_options_'.$tmpkey.'" value="'.dol_escape_htmltag($search_array_options['search_options_'.$tmpkey]).'">';
}
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 '</td>';
}
}

View File

@ -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 = '<a href="' . DOL_URL_ROOT . '/supplier_proposal/list.php' . (! empty($socid) ? '?socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
$morehtmlref='<div class="refidno">';
// 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.='</div>';
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
print '<div class="fichecenter">';
print '<div class="fichehalfleft">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
// Payment term
@ -1563,14 +1547,14 @@ if ($action == 'create')
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
print '</table>';
print '</div>';
print '<div class="fichehalfright">';
print '<div class="ficheaddleft">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border centpercent">';
if (!empty($conf->multicurrency->enabled) && ($object->multicurrency_code != $conf->currency))
{
// Multicurrency Amount HT
@ -1588,7 +1572,7 @@ if ($action == 'create')
print '<td>' . price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '</td>';
print '</tr>';
}
// Amount HT
print '<tr><td class="titlefieldmiddle">' . $langs->trans('AmountHT') . '</td>';
print '<td>' . price($object->total_ht, '', $langs, 0, - 1, - 1, $conf->currency) . '</td>';
@ -1619,18 +1603,18 @@ if ($action == 'create')
print '</tr>';
print '</table>';
// Margin Infos
/*if (! empty($conf->margin->enabled)) {
$formmargin->displayMarginInfos($object);
}*/
}*/
print '</div>';
print '</div>';
print '</div>';
print '<div class="clearboth"></div><br>';
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 '</div><div class="fichehalfright"><div class="ficheaddleft">';
// List of actions on element

View File

@ -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 {

Some files were not shown because too many files have changed in this diff Show More