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

This commit is contained in:
Regis Houssin 2017-06-08 15:05:45 +02:00
commit 4b98a1aefd
77 changed files with 1232 additions and 1074 deletions

View File

@ -52,7 +52,7 @@ if ($user->societe_id > 0) accessforbidden();
if (! $user->rights->accounting->chartofaccount) accessforbidden();
// Load variable for pagination
$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit;
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'sortorder');
$page = GETPOST("page", 'int');

View File

@ -28,7 +28,7 @@ require_once DOL_DOCUMENT_ROOT . '/core/class/fiscalyear.class.php';
$action = GETPOST('action','aZ09');
// Load variable for pagination
$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit;
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST('sortfield','alpha');
$sortorder = GETPOST('sortorder','alpha');
$page = GETPOST('page','int');

View File

@ -39,7 +39,7 @@ $langs->load("accountancy");
if (! $user->admin)
accessforbidden();
$limit = GETPOST("limit")?GETPOST("limit","int"):(empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
$limit = GETPOST('limit','int')?GETPOST('limit','int'):(empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');

View File

@ -70,7 +70,7 @@ $accounting_product_mode = GETPOST('accounting_product_mode', 'alpha');
$btn_changeaccount = GETPOST('changeaccount');
$btn_changetype = GETPOST('changetype');
$limit = GETPOST("limit")?GETPOST("limit","int"):(empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
$limit = GETPOST('limit','int')?GETPOST('limit','int'):(empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');

View File

@ -55,7 +55,7 @@ if (GETPOST("button_export_csv_x") || GETPOST("button_export_csv")) {
$action = 'export_csv';
}
$limit = GETPOST('limit') ? GETPOST('limit', 'int') : $conf->liste_limit;
$limit = GETPOST('limit','int')?GETPOST('limit', 'int'):$conf->liste_limit;
$offset = $limit * $page;

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
@ -80,7 +80,7 @@ $search_direction = GETPOST('search_direction', 'alpha');
$search_ledger_code = GETPOST('search_ledger_code', 'alpha');
// Load variable for pagination
$limit = GETPOST('limit') ? GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
$limit = GETPOST('limit','int')?GETPOST('limit', 'int'):(empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
$page = GETPOST('page','int');
@ -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

@ -59,7 +59,7 @@ $search_direction = GETPOST('search_direction', 'alpha');
$search_ledger_code = GETPOST('search_ledger_code', 'alpha');
// Load variable for pagination
$limit = GETPOST('limit') ? GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
$limit = GETPOST('limit','int')?GETPOST('limit', 'int'):(empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
$page = GETPOST('page','int');

View File

@ -37,7 +37,7 @@ $langs->load("accountancy");
$page = GETPOST("page");
$sortorder = GETPOST("sortorder");
$sortfield = GETPOST("sortfield");
$limit = GETPOST('limit') ? GETPOST('limit', 'int') : $conf->liste_limit;
$limit = GETPOST('limit','int')?GETPOST('limit', 'int'):$conf->liste_limit;
$search_date_start = dol_mktime(0, 0, 0, GETPOST('date_startmonth', 'int'), GETPOST('date_startday', 'int'), GETPOST('date_startyear', 'int'));
$search_date_end = dol_mktime(0, 0, 0, GETPOST('date_endmonth', 'int'), GETPOST('date_endday', 'int'), GETPOST('date_endyear', 'int'));
$search_doc_type = GETPOST('search_doc_type', 'alpha');

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

@ -55,7 +55,7 @@ $search_country = GETPOST('search_country', 'alpha');
$search_tvaintra = GETPOST('search_tvaintra', 'alpha');
// Load variable for pagination
$limit = GETPOST('limit') ? GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
$limit = GETPOST('limit','int')?GETPOST('limit', 'int'):(empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
$page = GETPOST('page', 'int');

View File

@ -63,7 +63,7 @@ $search_vat = GETPOST('search_vat', 'alpha');
$btn_ventil = GETPOST('ventil', 'alpha');
// Load variable for pagination
$limit = GETPOST('limit') ? GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
$limit = GETPOST('limit','int')?GETPOST('limit', 'int'):(empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
$page = GETPOST('page','int');

View File

@ -52,7 +52,7 @@ $search_account = GETPOST('search_account', 'alpha');
$search_vat = GETPOST('search_vat', 'alpha');
// Load variable for pagination
$limit = GETPOST('limit') ? GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
$limit = GETPOST('limit','int')?GETPOST('limit', 'int'):(empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
$page = GETPOST('page', 'int');

View File

@ -61,7 +61,7 @@ $search_vat = GETPOST('search_vat', 'alpha');
$btn_ventil = GETPOST('ventil', 'alpha');
// Load variable for pagination
$limit = GETPOST('limit') ? GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
$limit = GETPOST('limit','int')?GETPOST('limit', 'int'):(empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
$page = GETPOST('page','int');

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

@ -54,7 +54,7 @@ $search_account = GETPOST('search_account', 'alpha');
$search_vat = GETPOST('search_vat', 'alpha');
// Load variable for pagination
$limit = GETPOST('limit') ? GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
$limit = GETPOST('limit','int')?GETPOST('limit', 'int'):(empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
$page = GETPOST('page', 'int');

View File

@ -63,7 +63,7 @@ $search_vat = GETPOST('search_vat', 'alpha');
$btn_ventil = GETPOST('ventil', 'alpha');
// Load variable for pagination
$limit = GETPOST('limit') ? GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
$limit = GETPOST('limit','int')?GETPOST('limit', 'int'):(empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION)?$conf->liste_limit:$conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
$page = GETPOST('page','int');

View File

@ -62,7 +62,7 @@ $optioncss = GETPOST('optioncss','alpha');
if ($statut < -1) $statut = '';
$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit;
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');

View File

@ -42,7 +42,7 @@ $optioncss = GETPOST('optioncss','alpha');
$date_select=isset($_GET["date_select"])?$_GET["date_select"]:$_POST["date_select"];
$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit;
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');

View File

@ -44,7 +44,7 @@ $search_email = GETPOST('search_email','alpha');
$type = GETPOST('type','alpha');
$status = GETPOST('status','alpha');
$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit;
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');

View File

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

View File

@ -39,7 +39,7 @@ $action=GETPOST('action','alpha');
$mode = GETPOST('mode')?GETPOST('mode'):'createform'; // 'createform', 'filters', 'sortorder', 'focus'
$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit;
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');

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

@ -45,7 +45,7 @@ $transvalue=GETPOST('transvalue','alpha');
$mode = GETPOST('mode')?GETPOST('mode'):'overwrite';
$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit;
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');

View File

@ -39,7 +39,7 @@ if (! $user->rights->bookmark->lire) {
}
$optioncss = GETPOST('optioncss','alpha');
$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit;
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');

View File

@ -76,7 +76,7 @@ if (empty($filtert) && empty($conf->global->AGENDA_ALL_CALENDARS))
$filtert=$user->id;
}
$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit;
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');

View File

@ -39,7 +39,7 @@ if (! $user->rights->mailing->lire || $user->societe_id > 0) accessforbidden();
// Load variable for pagination
$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit;
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST('sortfield','alpha');
$sortorder = GETPOST('sortorder','alpha');
$page = GETPOST('page','int');

View File

@ -45,7 +45,7 @@ accessforbidden();
$langs->load("companies");
$langs->load("orders");
$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit;
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');

View File

@ -82,7 +82,7 @@ $result = restrictedArea($user, 'commande', $id,'');
$diroutputmassaction=$conf->commande->dir_output . '/temp/massgeneration/'.$user->id;
$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit;
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');

View File

@ -55,7 +55,7 @@ $result=restrictedArea($user,'banque');
$diroutputmassaction=$conf->bank->dir_output . '/temp/massgeneration/'.$user->id;
$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit;
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');

View File

@ -48,7 +48,7 @@ $id = GETPOST('id','int');
$socid = GETPOST('socid','int');
$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit;
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');

View File

@ -45,7 +45,7 @@ $page = GETPOST('page','int');
$sortorder = GETPOST('sortorder','alpha');
$sortfield = GETPOST('sortfield','alpha');
$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit;
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');

View File

@ -44,7 +44,7 @@ if ($user->societe_id > 0) accessforbidden();
$prev_id = GETPOST('id','int');
$socid = GETPOST('socid','int');
$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit;
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');

View File

@ -40,7 +40,7 @@ $object = new Societe($db);
if ($id > 0) $object->fetch($id);
// Load variable for pagination
$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit;
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST('sortfield','alpha');
$sortorder = GETPOST('sortorder','alpha');
$page = GETPOST('page','int');

View File

@ -52,7 +52,7 @@ if ($user->societe_id > 0) $socid = $user->societe_id;
if (! empty($conf->comptabilite->enabled)) $result=restrictedArea($user,'compta','','','resultat');
if (! empty($conf->accounting->enabled)) $result=restrictedArea($user,'accounting','','','comptarapport');
$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit;
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');

View File

@ -89,7 +89,7 @@ $search_agenda_label=GETPOST('search_agenda_label');
if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'contact', $id, 'socpeople&societe', '', '', 'rowid', $objcanvas); // If we create a contact with no company (shared contacts), no check on write permission
$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit;
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');

View File

@ -74,7 +74,7 @@ $optioncss = GETPOST('optioncss','alpha');
$type=GETPOST("type");
$view=GETPOST("view");
$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit;
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
$page = GETPOST('page', 'int');
@ -682,6 +682,7 @@ print "</tr>\n";
$i = 0;
$totalarray=array();
while ($i < min($num,$limit))
{
$obj = $db->fetch_object($result);
@ -706,56 +707,67 @@ while ($i < min($num,$limit))
print '<td valign="middle">';
print $contactstatic->getNomUrl(1,'',0);
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
// Firstname
if (! empty($arrayfields['p.firstname']['checked']))
{
print '<td>'.$obj->firstname.'</td>';
if (! $i) $totalarray['nbfield']++;
}
// Zip
if (! empty($arrayfields['p.zip']['checked']))
{
print '<td>'.$obj->zip.'</td>';
if (! $i) $totalarray['nbfield']++;
}
// Town
if (! empty($arrayfields['p.town']['checked']))
{
print '<td>'.$obj->town.'</td>';
if (! $i) $totalarray['nbfield']++;
}
// Function
if (! empty($arrayfields['p.poste']['checked']))
{
print '<td>'.dol_trunc($obj->poste,20).'</td>';
if (! $i) $totalarray['nbfield']++;
}
// Phone
if (! empty($arrayfields['p.phone']['checked']))
{
print '<td>'.dol_print_phone($obj->phone_pro,$obj->country_code,$obj->rowid,$obj->socid,'AC_TEL').'</td>';
if (! $i) $totalarray['nbfield']++;
}
// Phone perso
if (! empty($arrayfields['p.phone_perso']['checked']))
{
print '<td>'.dol_print_phone($obj->phone_perso,$obj->country_code,$obj->rowid,$obj->socid,'AC_TEL').'</td>';
if (! $i) $totalarray['nbfield']++;
}
// Phone mobile
if (! empty($arrayfields['p.phone_mobile']['checked']))
{
print '<td>'.dol_print_phone($obj->phone_mobile,$obj->country_code,$obj->rowid,$obj->socid,'AC_TEL').'</td>';
if (! $i) $totalarray['nbfield']++;
}
// Fax
if (! empty($arrayfields['p.fax']['checked']))
{
print '<td>'.dol_print_phone($obj->fax,$obj->country_code,$obj->rowid,$obj->socid,'AC_TEL').'</td>';
if (! $i) $totalarray['nbfield']++;
}
// EMail
if (! empty($arrayfields['p.email']['checked']))
{
print '<td>'.dol_print_email($obj->email,$obj->rowid,$obj->socid,'AC_EMAIL',18).'</td>';
if (! $i) $totalarray['nbfield']++;
}
// Skype
if (! empty($arrayfields['p.skype']['checked']))
{
if (! empty($conf->skype->enabled)) { print '<td>'.dol_print_skype($obj->skype,$obj->rowid,$obj->socid,'AC_SKYPE',18).'</td>'; }
if (! $i) $totalarray['nbfield']++;
}
// Company
if (! empty($arrayfields['p.thirdparty']['checked']))
@ -770,12 +782,14 @@ while ($i < min($num,$limit))
else
print '&nbsp;';
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
// Private/Public
if (! empty($arrayfields['p.priv']['checked']))
{
print '<td align="center">'.$contactstatic->LibPubPriv($obj->priv).'</td>';
if (! $i) $totalarray['nbfield']++;
}
// Extra fields
@ -792,6 +806,7 @@ while ($i < min($num,$limit))
$tmpkey='options_'.$key;
print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1);
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
}
}
@ -805,6 +820,7 @@ while ($i < min($num,$limit))
print '<td align="center">';
print dol_print_date($db->jdate($obj->date_creation), 'dayhour');
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
// Date modification
if (! empty($arrayfields['p.tms']['checked']))
@ -812,11 +828,13 @@ while ($i < min($num,$limit))
print '<td align="center">';
print dol_print_date($db->jdate($obj->date_update), 'dayhour');
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
// Status
if (! empty($arrayfields['p.statut']['checked']))
{
print '<td align="center">'.$contactstatic->getLibStatut(3).'</td>';
if (! $i) $totalarray['nbfield']++;
}
// Action column
@ -829,7 +847,7 @@ while ($i < min($num,$limit))
}
print '</td>';
if (! $i) $totalarray['nbfield']++;
print "</tr>\n";
$i++;
}

View File

@ -65,7 +65,7 @@ $month=GETPOST("month","int");
$optioncss = GETPOST('optioncss','alpha');
$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit;
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');

View File

@ -33,7 +33,7 @@ $langs->load("products");
$langs->load("contracts");
$langs->load("companies");
$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit;
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');

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';
@ -5759,7 +5760,7 @@ class Form
$disabled = ($disabled ? ' disabled' : '');
$resultyesno = '<select class="flat" id="'.$htmlname.'" name="'.$htmlname.'"'.$disabled.'>'."\n";
if ($useempty) $resultyesno .= '<option value="-1"'.(($value < 0)?' selected':'').'></option>'."\n";
if ($useempty) $resultyesno .= '<option value="-1"'.(($value < 0)?' selected':'').'>&nbsp;</option>'."\n";
if (("$value" == 'yes') || ($value == 1))
{
$resultyesno .= '<option value="'.$yes.'" selected>'.$langs->trans("Yes").'</option>'."\n";

View File

@ -3704,7 +3704,7 @@ function vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0)
* @param float $amount Amount to format
* @param integer $form Type of format, HTML or not (not by default)
* @param Translate $outlangs Object langs for output
* @param int $trunc 1=Truncate if there is too much decimals (default), 0=Does not truncate. Deprecated because amount are rounded (to unit or total amount accurancy) before inserted into database or after a computation, so this parameter should be useless.
* @param int $trunc 1=Truncate if there is more decimals than MAIN_MAX_DECIMALS_SHOWN (default), 0=Does not truncate. Deprecated because amount are rounded (to unit or total amount accurancy) before inserted into database or after a computation, so this parameter should be useless.
* @param int $rounding Minimum number of decimal to show. If 0, no change, if -1, we use min($conf->global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOTAL)
* @param int $forcerounding Force the number of decimal to forcerounding decimal (-1=do not force)
* @param string $currency_code To add currency symbol (''=add nothing, 'auto'=Use default currency, 'XXX'=add currency symbols for XXX currency)

View File

@ -109,7 +109,7 @@ class Cronjob extends CommonObject
if (isset($this->nbrun)) $this->nbrun=trim($this->nbrun);
if (isset($this->libname)) $this->libname = trim($this->libname);
if (isset($this->test)) $this->test = trim($this->test);
// Check parameters
// Put here code to add a control on parameters values
if (dol_strlen($this->datestart)==0) {
@ -361,15 +361,15 @@ class Cronjob extends CommonObject
* @param int $offset page
* @param int $status display active or not
* @param array $filter filter output
* @param int $processing Processing or not
* @param int $processing Processing or not
* @return int <0 if KO, >0 if OK
*/
function fetch_all($sortorder='DESC', $sortfield='t.rowid', $limit=0, $offset=0, $status=1, $filter='', $processing=-1)
{
global $langs;
$this->lines=array();
$sql = "SELECT";
$sql.= " t.rowid,";
$sql.= " t.entity,";
@ -409,7 +409,7 @@ class Cronjob extends CommonObject
if ($status == 2) $sql.= " AND t.status = 2";
//Manage filter
if (is_array($filter) && count($filter)>0) {
foreach($filter as $key => $value)
foreach($filter as $key => $value)
{
if ($key == 't.rowid') $sql.= ' AND '.$key.' = '.$this->db->escape($value);
else $sql.= ' AND '.$key.' LIKE \'%'.$this->db->escape($value).'%\'';
@ -532,7 +532,7 @@ class Cronjob extends CommonObject
if (empty($this->maxrun)) $this->maxrun=0;
if (empty($this->processing)) $this->processing=0;
// Check parameters
// Put here code to add a control on parameters values
if (dol_strlen($this->datestart)==0) {
@ -845,8 +845,8 @@ class Cronjob extends CommonObject
/**
* Run a job.
* Once job is finished, status and nb of run is updated.
* This function does not plan the next run. This is done by function ->reprogram_jobs
* Once job is finished, status and nb of run is updated.
* This function does not plan the next run. This is done by function ->reprogram_jobs
*
* @param string $userlogin User login
* @return int <0 if KO, >0 if OK
@ -861,7 +861,7 @@ class Cronjob extends CommonObject
$langs->load('cron');
if (empty($userlogin))
if (empty($userlogin))
{
$this->error="User login is mandatory";
dol_syslog(get_class($this)."::run_jobs ".$this->error, LOG_ERR);
@ -948,7 +948,7 @@ class Cronjob extends CommonObject
$error++;
}
}
// Load langs
if (! $error)
{
@ -963,14 +963,14 @@ class Cronjob extends CommonObject
$error++;
}
}
if (! $error)
{
dol_syslog(get_class($this)."::run_jobs START ".$this->objectname."->".$this->methodename."(".$this->params.");", LOG_DEBUG);
// Create Object for the call module
$object = new $this->objectname($this->db);
$params_arr = array_map('trim', explode(",",$this->params));
if (!is_array($params_arr))
{
@ -980,7 +980,7 @@ class Cronjob extends CommonObject
{
$result = call_user_func_array(array($object, $this->methodename), $params_arr);
}
if ($result===false || $result != 0)
{
$langs->load("errors");
@ -998,7 +998,7 @@ class Cronjob extends CommonObject
$this->lastresult=var_export($result,true);
$retval = $this->lastresult;
}
}
}
}
if($this->jobtype == 'function')
@ -1071,7 +1071,7 @@ class Cronjob extends CommonObject
$this->lastoutput = ''; // Will be filled later
$this->lastresult = $retval;
$retval = $this->lastresult;
$error++;
$error++;
}
}
if ($execmethod == 2)
@ -1102,14 +1102,14 @@ class Cronjob extends CommonObject
$this->lastoutput.=$val."\n";
}
}
$this->lastresult=$retval;
dol_syslog(get_class($this)."::run_jobs output_arr:".var_export($output_arr,true)." lastoutput=".$this->lastoutput." lastresult=".$this->lastresult, LOG_DEBUG);
}
dol_syslog(get_class($this)."::run_jobs now we update job to track it is finished (with success or error)");
$this->datelastresult=dol_now();
$this->processing=0;
$result = $this->update($user); // This include begin/commit
@ -1135,19 +1135,19 @@ class Cronjob extends CommonObject
function reprogram_jobs($userlogin, $now)
{
dol_syslog(get_class($this)."::reprogram_jobs userlogin:$userlogin", LOG_DEBUG);
require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
$user=new User($this->db);
$result=$user->fetch('',$userlogin);
if ($result<0)
if ($result<0)
{
$this->error="User Error:".$user->error;
dol_syslog(get_class($this)."::reprogram_jobs ".$this->error, LOG_ERR);
return -1;
}
else
else
{
if (empty($user->id))
if (empty($user->id))
{
$this->error=" User user login:".$userlogin." do not exists";
dol_syslog(get_class($this)."::reprogram_jobs ".$this->error, LOG_ERR);
@ -1155,28 +1155,28 @@ class Cronjob extends CommonObject
}
}
dol_syslog(get_class($this)."::reprogram_jobs ", LOG_DEBUG);
dol_syslog(get_class($this)."::reprogram_jobs datenextrun=".$this->datenextrun." ".dol_print_date($this->datenextrun, 'dayhourrfc')." frequency=".$this->frequency." unitfrequency=".$this->unitfrequency, LOG_DEBUG);
if (empty($this->datenextrun))
if (empty($this->datenextrun))
{
if (empty($this->datestart)) $this->datenextrun = $now + ($this->frequency * $this->unitfrequency);
else $this->datenextrun = $this->datestart + ($this->frequency * $this->unitfrequency);
}
if ($this->datenextrun < $now && $this->frequency > 0 && $this->unitfrequency > 0)
if ($this->datenextrun < $now && $this->frequency > 0 && $this->unitfrequency > 0)
{
// Loop until date is after future
while ($this->datenextrun < $now)
{
$this->datenextrun += ($this->frequency * $this->unitfrequency);
// TODO For exact frequency (every month, every year, ...), use instead a dol_time_plus_duree($time, $duration_value, $duration_unit)
}
}
else
else
{
//$this->datenextrun=$this->datenextrun + ($this->frequency * $this->unitfrequency);
dol_syslog(get_class($this)."::reprogram_jobs datenextrun is already in future, we do not change it");
}
@ -1190,9 +1190,9 @@ class Cronjob extends CommonObject
dol_syslog(get_class($this)."::reprogram_jobs Job will be set to archived", LOG_ERR);
}
}
$result = $this->update($user);
if ($result<0)
if ($result<0)
{
dol_syslog(get_class($this)."::reprogram_jobs ".$this->error, LOG_ERR);
return -1;
@ -1200,7 +1200,7 @@ class Cronjob extends CommonObject
return 1;
}
/**
* Return label of status of user (active, inactive)
*
@ -1211,7 +1211,7 @@ class Cronjob extends CommonObject
{
return $this->LibStatut($this->status,$mode);
}
/**
* Renvoi le libelle d'un statut donne
*
@ -1223,7 +1223,7 @@ class Cronjob extends CommonObject
{
global $langs;
$langs->load('users');
if ($mode == 0)
{
$prefix='';
@ -1255,7 +1255,7 @@ class Cronjob extends CommonObject
if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4','class="pictostatus"');
if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5','class="pictostatus"');
}
}
}
}

View File

@ -48,7 +48,7 @@ $object->info($id);
$head = cron_prepare_head($object);
dol_fiche_head($head, 'info', $langs->trans("CronTask"), 0, 'cron');
dol_fiche_head($head, 'info', $langs->trans("CronTask"), -1, 'cron');
print '<table width="100%"><tr><td>';
dol_print_object_info($object);

View File

@ -39,7 +39,7 @@ $action=GETPOST('action','alpha');
$confirm=GETPOST('confirm','alpha');
$id=GETPOST('id','int');
$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit;
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');

View File

@ -53,7 +53,7 @@ $search_type_thirdparty=GETPOST("search_type_thirdparty",'int');
$sall = GETPOST('sall', 'alphanohtml');
$optioncss = GETPOST('optioncss','alpha');
$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit;
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST('sortfield','alpha');
$sortorder = GETPOST('sortorder','alpha');
$page = GETPOST('page','int');

View File

@ -51,7 +51,7 @@ $diroutputmassaction=$conf->expensereport->dir_output . '/temp/massgeneration/'.
// Load variable for pagination
$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit;
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST('sortfield','alpha');
$sortorder = GETPOST('sortorder','alpha');
$page = GETPOST('page','int');

View File

@ -101,7 +101,7 @@ $result = restrictedArea($user, 'fournisseur', $orderid, '', 'commande');
$diroutputmassaction=$conf->fournisseur->commande->dir_output . '/temp/massgeneration/'.$user->id;
$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit;
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');

View File

@ -42,7 +42,7 @@ $type = GETPOST('type');
$optioncss = GETPOST('optioncss','alpha');
// Load variable for pagination
$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit;
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST('sortfield','alpha');
$sortorder = GETPOST('sortorder','alpha');
$page = GETPOST('page','int');

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)
{
@ -491,9 +492,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

@ -50,7 +50,7 @@ class modMyModule extends DolibarrModules
// Id for module (must be unique).
// Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id).
$this->numero = 500000; // TODO Go on page http://wiki.dolibarr.org/index.php/List_of_modules_id to reserve id number for your module
$this->numero = 500000; // TODO Go on page https://wiki.dolibarr.org/index.php/List_of_modules_id to reserve id number for your module
// Key text used to identify module (for permissions, menus, etc...)
$this->rights_class = 'mymodule';
@ -62,11 +62,13 @@ class modMyModule extends DolibarrModules
// Gives the possibility to the module, to provide his own family info and position of this family (Overwrite $this->family and $this->module_position. Avoid this)
//$this->familyinfo = array('myownfamily' => array('position' => '001', 'label' => $langs->trans("MyOwnFamily")));
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
// Module label (no space allowed), used if translation string 'ModuleMyModuleName' not found (MyModue is name of module).
$this->name = preg_replace('/^mod/i','',get_class($this));
// Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)
// Module description, used if translation string 'ModuleMyModuleDesc' not found (MyModue is name of module).
$this->description = "MyModuleDescription";
// Used only if file README.md and README-LL.md not found.
$this->descriptionlong = "MyModuleDescription (Long)";
$this->editor_name = 'Editor name';
$this->editor_url = 'https://www.example.com';

View File

@ -17,11 +17,9 @@
*/
/**
* \file css/mycss.css.php
* \file htdocs/modulebuilder/template/css/mycss.css.php
* \ingroup mymodule
* \brief Example CSS.
*
* Put detailed description here.
* \brief CSS file for module MyModule.
*/
header('Content-Type: text/css');

View File

@ -19,9 +19,7 @@
/**
* \file htdocs/modulebuilder/template/js/mymodule.js.php
* \ingroup mymodule
* \brief Example JavaScript.
*
* Put detailed description here.
* \brief JavaScript file for module MyModule.
*/
header('Content-Type: application/javascript');

View File

@ -68,7 +68,7 @@ $search_myfield=GETPOST('search_myfield');
$optioncss = GETPOST('optioncss','alpha');
// Load variable for pagination
$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit;
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST('sortfield','alpha');
$sortorder = GETPOST('sortorder','alpha');
$page = GETPOST('page','int');

View File

@ -36,7 +36,7 @@ require_once DOL_DOCUMENT_ROOT.'/product/inventory/lib/inventory.lib.php';
$langs->load("stock");
$langs->load("inventory");
$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit;
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = (GETPOST("page",'int')?GETPOST("page", 'int'):0);

View File

@ -77,7 +77,7 @@ if (!$_POST) {
$diroutputmassaction=$conf->product->dir_output . '/temp/massgeneration/'.$user->id;
$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit;
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = (GETPOST("page",'int')?GETPOST("page", 'int'):0);

View File

@ -77,7 +77,7 @@ if (!$_POST) {
$diroutputmassaction=$conf->product->dir_output . '/temp/massgeneration/'.$user->id;
$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit;
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = (GETPOST("page",'int')?GETPOST("page", 'int'):0);
@ -179,7 +179,7 @@ $arrayfields=array(
// 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)
{
$arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key]);
}
@ -219,16 +219,16 @@ if (empty($reshook))
$search_accountancy_code_buy='';
$search_array_options=array();
}
// Mass actions
$objectclass='Product';
if ((string) $search_type == '1') { $objectlabel='Services'; }
if ((string) $search_type == '0') { $objectlabel='Products'; }
$permtoread = $user->rights->produit->lire;
$permtodelete = $user->rights->produit->supprimer;
$uploaddir = $conf->product->dir_output;
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
}
@ -324,7 +324,7 @@ else
$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);
}
@ -361,7 +361,7 @@ else
$num = $db->num_rows($resql);
$arrayofselected=is_array($toselect)?$toselect:array();
if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall)
{
$obj = $db->fetch_object($resql);
@ -415,8 +415,8 @@ else
$crit=$val;
$tmpkey=preg_replace('/search_options_/','',$key);
if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val);
}
}
// List of mass actions available
$arrayofmassactions = array(
//'presend'=>$langs->trans("SendByMail"),
@ -425,7 +425,7 @@ else
if ($user->rights->produit->supprimer) $arrayofmassactions['delete']=$langs->trans("Delete");
if ($massaction == 'presend' || $massaction == 'createbills') $arrayofmassactions=array();
$massactionbutton=$form->selectMassAction('', $arrayofmassactions);
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post" name="formulaire">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@ -473,7 +473,7 @@ else
foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val);
print $langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall);
}
// Filter on categories
$moreforfilter='';
if (! empty($conf->categorie->enabled))
@ -505,10 +505,10 @@ else
$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";
// Lines with input filters
print '<tr class="liste_titre_filter">';
if (! empty($arrayfields['p.ref']['checked']))
@ -591,7 +591,7 @@ else
// 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'])) print '<td class="liste_titre"></td>';
}
@ -668,12 +668,13 @@ else
if (! empty($arrayfields['p.tobuy']['checked'])) print_liste_field_titre($langs->trans("Status").' ('.$langs->trans("Buy").')',$_SERVER["PHP_SELF"],"p.tobuy","",$param,'align="right"',$sortfield,$sortorder);
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ');
print "</tr>\n";
$product_static=new Product($db);
$product_fourn =new ProductFournisseur($db);
$i = 0;
$totalarray=array();
while ($i < min($num,$limit))
{
$obj = $db->fetch_object($resql);
@ -721,6 +722,7 @@ else
print '<td class="nowrap">';
print $product_static->getNomUrl(1,'',24);
print "</td>\n";
if (! $i) $totalarray['nbfield']++;
}
// Ref supplier
if (! empty($arrayfields['pfp.ref_fourn']['checked']))
@ -728,24 +730,28 @@ else
print '<td class="nowrap">';
print $product_static->getNomUrl(1,'',24);
print "</td>\n";
if (! $i) $totalarray['nbfield']++;
}
// Label
if (! empty($arrayfields['p.label']['checked']))
{
print '<td>'.dol_trunc($obj->label,40).'</td>';
if (! $i) $totalarray['nbfield']++;
}
// Type
if (! empty($arrayfields['p.fk_product_type']['checked']))
{
print '<td>'.$obj->fk_product_type.'</td>';
if (! $i) $totalarray['nbfield']++;
}
// Barcode
if (! empty($arrayfields['p.barcode']['checked']))
{
print '<td>'.$obj->barcode.'</td>';
}
if (! $i) $totalarray['nbfield']++;
}
// Duration
if (! empty($arrayfields['p.duration']['checked']))
@ -761,6 +767,7 @@ else
else print $obj->duration;
}
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
// Sell price
@ -773,6 +780,7 @@ else
else print price($obj->price).' '.$langs->trans("HT");
}
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
// Better buy price
@ -796,6 +804,7 @@ else
}
}
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
// Limit alert
@ -807,6 +816,7 @@ else
print $obj->seuil_stock_alerte;
}
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
// Desired stock
if (! empty($arrayfields['p.desiredstock']['checked']))
@ -817,6 +827,7 @@ else
print $obj->desiredstock;
}
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
// Stock
if (! empty($arrayfields['p.stock']['checked']))
@ -828,7 +839,8 @@ else
print $product_static->stock_reel;
}
print '</td>';
}
if (! $i) $totalarray['nbfield']++;
}
// Stock
if (! empty($arrayfields['stock_virtual']['checked']))
{
@ -839,24 +851,34 @@ else
print $product_static->stock_theorique;
}
print '</td>';
}
if (! $i) $totalarray['nbfield']++;
}
// Lot/Serial
if (! empty($arrayfields['p.tobatch']['checked']))
{
print '<td align="center">';
print yn($obj->tobatch);
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
// Accountancy code sell
if (! empty($arrayfields['p.accountancy_code_sell']['checked'])) print '<td>'.$obj->accountancy_code_sell.'</td>';
if (! empty($arrayfields['p.accountancy_code_sell']['checked']))
{
print '<td>'.$obj->accountancy_code_sell.'</td>';
if (! $i) $totalarray['nbfield']++;
}
// Accountancy code sell
if (! empty($arrayfields['p.accountancy_code_buy']['checked'])) print '<td>'.$obj->accountancy_code_buy.'</td>';
if (! empty($arrayfields['p.accountancy_code_buy']['checked']))
{
print '<td>'.$obj->accountancy_code_buy.'</td>';
if (! $i) $totalarray['nbfield']++;
}
// 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);
@ -865,6 +887,7 @@ else
$tmpkey='options_'.$key;
print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1);
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
}
}
@ -878,6 +901,7 @@ else
print '<td align="center">';
print dol_print_date($obj->date_creation, 'dayhour');
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
// Date modification
if (! empty($arrayfields['p.tms']['checked']))
@ -885,8 +909,9 @@ else
print '<td align="center">';
print dol_print_date($obj->date_update, 'dayhour');
print '</td>';
}
if (! $i) $totalarray['nbfield']++;
}
// Status (to sell)
if (! empty($arrayfields['p.tosell']['checked']))
{
@ -897,6 +922,7 @@ else
print $product_static->LibStatut($obj->tosell,5,0);
}
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
// Status (to buy)
if (! empty($arrayfields['p.tobuy']['checked']))
@ -908,6 +934,7 @@ else
print $product_static->LibStatut($obj->tobuy,5,1);
}
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
// Action
print '<td class="nowrap" align="center">';
@ -918,11 +945,12 @@ else
print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected?' checked="checked"':'').'>';
}
print '</td>';
if (! $i) $totalarray['nbfield']++;
print "</tr>\n";
$i++;
}
$db->free($resql);
print "</table>";

View File

@ -38,7 +38,7 @@ $type=GETPOST("type","int");
if (! empty($user->societe_id)) $socid=$user->societe_id;
$result=restrictedArea($user,'produit|service');
$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit;
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');

View File

@ -61,7 +61,7 @@ $search_myfield=GETPOST('search_myfield');
$optioncss = GETPOST('optioncss','alpha');
// Load variable for pagination
$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit;
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST('sortfield','alpha');
$sortorder = GETPOST('sortorder','alpha');
$page = GETPOST('page','int');

View File

@ -41,6 +41,7 @@ $ref=GETPOST('ref','alpha');
$action=GETPOST('action','alpha');
$backtopage=GETPOST('backtopage','alpha');
$cancel=GETPOST('cancel','alpha');
$confirm=GETPOST('confirm','aZ09');
$status=GETPOST('status','int');
$opp_status=GETPOST('opp_status','int');
$opp_percent=price2num(GETPOST('opp_percent','alpha'));
@ -68,7 +69,7 @@ if ($id > 0 || ! empty($ref))
}
// Security check
$socid=GETPOST('socid');
$socid=GETPOST('socid','int');
//if ($user->societe_id > 0) $socid = $user->societe_id; // For external user, no check is done on company because readability is managed by public status of project and assignement.
$result = restrictedArea($user, 'projet', $object->id,'projet&project');
@ -135,6 +136,12 @@ if (empty($reshook))
setEventMessages($langs->trans("ErrorOppStatusRequiredIfAmount"), null, 'errors');
}
// Create with status validated immediatly
if (! empty($conf->global->PROJECT_CREATE_NO_DRAFT))
{
$status=Project::STATUS_VALIDATED;
}
if (! $error)
{
$error=0;
@ -148,10 +155,10 @@ if (empty($reshook))
$object->public = GETPOST('public','alpha');
$object->opp_amount = price2num(GETPOST('opp_amount'));
$object->budget_amount = price2num(GETPOST('budget_amount'));
$object->datec=dol_now();
$object->date_start=$date_start;
$object->date_end=$date_end;
$object->statuts = $status;
$object->datec = dol_now();
$object->date_start = $date_start;
$object->date_end = $date_end;
$object->statut = $status;
$object->opp_status = $opp_status;
$object->opp_percent = $opp_percent;
@ -365,7 +372,7 @@ if (empty($reshook))
}
if ($action == 'confirm_validate' && GETPOST('confirm') == 'yes')
if ($action == 'confirm_validate' && $confirm == 'yes')
{
$result = $object->setValid($user);
if ($result <= 0)
@ -374,7 +381,7 @@ if (empty($reshook))
}
}
if ($action == 'confirm_close' && GETPOST('confirm') == 'yes')
if ($action == 'confirm_close' && $confirm == 'yes')
{
$result = $object->setClose($user);
if ($result <= 0)
@ -383,7 +390,7 @@ if (empty($reshook))
}
}
if ($action == 'confirm_reopen' && GETPOST('confirm') == 'yes')
if ($action == 'confirm_reopen' && $confirm == 'yes')
{
$result = $object->setValid($user);
if ($result <= 0)
@ -409,7 +416,7 @@ if (empty($reshook))
}
}
if ($action == 'confirm_clone' && $user->rights->projet->creer && GETPOST('confirm') == 'yes')
if ($action == 'confirm_clone' && $user->rights->projet->creer && $confirm == 'yes')
{
$clone_contacts=GETPOST('clone_contacts')?1:0;
$clone_tasks=GETPOST('clone_tasks')?1:0;
@ -885,12 +892,16 @@ elseif ($object->id > 0)
// Opportunity percent
print '<tr><td>'.$langs->trans("OpportunityProbability").'</td><td>';
if (strcmp($object->opp_percent,'')) print price($object->opp_percent,0,$langs,1,0).' %';
if (strcmp($object->opp_percent,'')) print price($object->opp_percent, 0, $langs, 1, 0).' %';
print '</td></tr>';
// Opportunity Amount
print '<tr><td>'.$langs->trans("OpportunityAmount").'</td><td>';
if (strcmp($object->opp_amount,'')) print price($object->opp_amount,0,$langs,1,0,0,$conf->currency);
/*if ($object->opp_status)
{
print price($obj->opp_amount, 1, $langs, 1, 0, -1, $conf->currency);
}*/
if (strcmp($object->opp_amount,'')) print price($object->opp_amount, 0, $langs, 1, 0, -1, $conf->currency);
print '</td></tr>';
}

View File

@ -103,6 +103,20 @@ class Project extends CommonObject
*/
public $lines;
/**
* Draft status
*/
const STATUS_DRAFT = 0;
/**
* Open/Validated status
*/
const STATUS_VALIDATED = 1;
/**
* Closed status
*/
const STATUS_CLOSED = 2;
/**
* Constructor

View File

@ -35,7 +35,7 @@ $ref = GETPOST('ref','alpha');
$socid = GETPOST('socid','int');
$action = GETPOST('action','alpha');
$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit;
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield","alpha");
$sortorder = GETPOST("sortorder");
$page = GETPOST("page");

View File

@ -55,7 +55,7 @@ if (!$user->rights->projet->lire) accessforbidden();
$diroutputmassaction=$conf->projet->dir_output . '/temp/massgeneration/'.$user->id;
$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit;
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield","alpha");
$sortorder = GETPOST("sortorder");
$page = GETPOST("page");
@ -135,7 +135,7 @@ $arrayfields=array(
// 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)
{
$arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]);
}
@ -186,7 +186,7 @@ if (empty($reshook))
$toselect='';
$search_array_options=array();
}
// Mass actions
$objectclass='Project';
@ -297,12 +297,12 @@ else if ($search_eyear > 0)
$sql.= " AND p.datee BETWEEN '".$db->idate(dol_get_first_day($search_eyear,1,false))."' AND '".$db->idate(dol_get_last_day($search_eyear,12,false))."'";
}
if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
if ($search_status >= 0)
if ($search_status >= 0)
{
if ($search_status == 99) $sql .= " AND p.fk_statut <> 2";
else $sql .= " AND p.fk_statut = ".$db->escape($search_status);
}
if ($search_opp_status)
if ($search_opp_status)
{
if (is_numeric($search_opp_status) && $search_opp_status > 0) $sql .= " AND p.fk_opp_status = ".$db->escape($search_opp_status);
if ($search_opp_status == 'all') $sql .= " AND p.fk_opp_status IS NOT NULL";
@ -313,7 +313,7 @@ if ($search_public!='') $sql .= " AND p.public = ".$db->escape($search_public);
if ($search_sale > 0) $sql.= " AND sc.fk_user = " .$search_sale;
// For external user, no check is done on company permission because readability is managed by public status of project and assignement.
//if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND ((s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id.") OR (s.rowid IS NULL))";
if ($search_project_user > 0) $sql.= " AND ecp.fk_c_type_contact IN (".join(',',array_keys($listofprojectcontacttype)).") AND ecp.element_id = p.rowid AND ecp.fk_socpeople = ".$search_project_user;
if ($search_project_user > 0) $sql.= " AND ecp.fk_c_type_contact IN (".join(',',array_keys($listofprojectcontacttype)).") AND ecp.element_id = p.rowid AND ecp.fk_socpeople = ".$search_project_user;
if ($search_opp_amount != '') $sql .= natural_search('p.opp_amount', $search_opp_amount, 1);
if ($search_budget_amount != '') $sql .= natural_search('p.budget_amount', $search_budget_amount, 1);
// Add where from extra fields
@ -324,7 +324,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);
}
@ -383,8 +383,8 @@ if ($search_ref != '') $param.='&search_ref='.$search_ref;
if ($search_label != '') $param.='&search_label='.$search_label;
if ($search_societe != '') $param.='&search_societe='.$search_societe;
if ($search_status >= 0) $param.='&search_status='.$search_status;
if ((is_numeric($search_opp_status) && $search_opp_status >= 0) || in_array($search_opp_status, array('all','openedopp','none'))) $param.='&search_opp_status='.urlencode($search_opp_status);
if ((is_numeric($search_opp_percent) && $search_opp_percent >= 0) || in_array($search_opp_percent, array('all','openedopp','none'))) $param.='&search_opp_percent='.urlencode($search_opp_percent);
if ((is_numeric($search_opp_status) && $search_opp_status >= 0) || in_array($search_opp_status, array('all','openedopp','none'))) $param.='&search_opp_status='.urlencode($search_opp_status);
if ($search_opp_percent != '') $param.='&search_opp_percent='.urlencode($search_opp_percent);
if ($search_public != '') $param.='&search_public='.$search_public;
if ($search_project_user != '') $param.='&search_project_user='.$search_project_user;
if ($search_sale > 0) $param.='&search_sale='.$search_sale;
@ -532,18 +532,18 @@ if (! empty($arrayfields['p.public']['checked']))
print $form->selectarray('search_public',$array,$search_public);
print '</td>';
}
if (! empty($arrayfields['p.opp_amount']['checked']))
{
print '<td class="liste_titre nowrap right">';
print '<input type="text" class="flat" name="search_opp_amount" size="3" value="'.$search_opp_amount.'">';
print '</td>';
}
if (! empty($arrayfields['p.fk_opp_status']['checked']))
{
print '<td class="liste_titre nowrap center">';
print $formproject->selectOpportunityStatus('search_opp_status', $search_opp_status, 1, 1, 1, 0, 'maxwidth100');
print '</td>';
}
if (! empty($arrayfields['p.opp_amount']['checked']))
{
print '<td class="liste_titre nowrap right">';
print '<input type="text" class="flat" name="search_opp_amount" size="3" value="'.$search_opp_amount.'">';
print '</td>';
}
if (! empty($arrayfields['p.opp_percent']['checked']))
{
print '<td class="liste_titre nowrap right">';
@ -620,8 +620,8 @@ if (! empty($arrayfields['commercial']['checked'])) print_liste_field_titre
if (! empty($arrayfields['p.dateo']['checked'])) print_liste_field_titre($arrayfields['p.dateo']['label'],$_SERVER["PHP_SELF"],"p.dateo","",$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['p.datee']['checked'])) print_liste_field_titre($arrayfields['p.datee']['label'],$_SERVER["PHP_SELF"],"p.datee","",$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['p.public']['checked'])) print_liste_field_titre($arrayfields['p.public']['label'],$_SERVER["PHP_SELF"],"p.public","",$param,"",$sortfield,$sortorder);
if (! empty($arrayfields['p.opp_amount']['checked'])) print_liste_field_titre($arrayfields['p.opp_amount']['label'],$_SERVER["PHP_SELF"],'p.opp_amount',"",$param,'align="right"',$sortfield,$sortorder);
if (! empty($arrayfields['p.fk_opp_status']['checked'])) print_liste_field_titre($arrayfields['p.fk_opp_status']['label'],$_SERVER["PHP_SELF"],'p.fk_opp_status',"",$param,'align="center"',$sortfield,$sortorder);
if (! empty($arrayfields['p.opp_amount']['checked'])) print_liste_field_titre($arrayfields['p.opp_amount']['label'],$_SERVER["PHP_SELF"],'p.opp_amount',"",$param,'align="right"',$sortfield,$sortorder);
if (! empty($arrayfields['p.opp_percent']['checked'])) print_liste_field_titre($arrayfields['p.opp_percent']['label'],$_SERVER["PHP_SELF"],'p.opp_percent',"",$param,'align="right"',$sortfield,$sortorder);
if (! empty($arrayfields['p.budget_amount']['checked'])) print_liste_field_titre($arrayfields['p.budget_amount']['label'],$_SERVER["PHP_SELF"],'p.budget_amount',"",$param,'align="right"',$sortfield,$sortorder);
// Extra fields
@ -661,7 +661,7 @@ while ($i < min($num,$limit))
$object->datee = $db->jdate($obj->date_end);
$object->statut = $obj->fk_statut;
$object->opp_status = $obj->fk_opp_status;
$userAccess = $object->restrictedProjectArea($user); // why this ?
if ($userAccess >= 0)
{
@ -770,20 +770,7 @@ while ($i < min($num,$limit))
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
// Opp Amount
if (! empty($arrayfields['p.opp_amount']['checked']))
{
print '<td align="right">';
if ($obj->opp_status_code)
{
print price($obj->opp_amount, 1, '', 1, -1, -1, '');
$totalarray['totalopp'] += $obj->opp_amount;
}
print '</td>';
if (! $i) $totalarray['nbfield']++;
if (! $i) $totalarray['totaloppfield']=$totalarray['nbfield'];
}
// Opp Status
// Opp Status
if (! empty($arrayfields['p.fk_opp_status']['checked']))
{
print '<td class="center">';
@ -791,11 +778,25 @@ while ($i < min($num,$limit))
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
// Opp Amount
if (! empty($arrayfields['p.opp_amount']['checked']))
{
print '<td align="right">';
//if ($obj->opp_status_code)
if (strcmp($obj->opp_amount,''))
{
print price($obj->opp_amount, 1, $langs, 1, -1, -1, '');
$totalarray['totalopp'] += $obj->opp_amount;
}
print '</td>';
if (! $i) $totalarray['nbfield']++;
if (! $i) $totalarray['totaloppfield']=$totalarray['nbfield'];
}
// Opp percent
if (! empty($arrayfields['p.opp_percent']['checked']))
{
print '<td align="right">';
if ($obj->opp_percent) print price($obj->opp_percent, 1, '', 1, 0).'%';
if ($obj->opp_percent) print price($obj->opp_percent, 1, $langs, 1, 0).'%';
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
@ -803,9 +804,9 @@ while ($i < min($num,$limit))
if (! empty($arrayfields['p.budget_amount']['checked']))
{
print '<td align="right">';
if ($obj->budget_amount != '')
if ($obj->budget_amount != '')
{
print price($obj->budget_amount, 1, '', 1, -1, -1);
print price($obj->budget_amount, 1, $langs, 1, -1, -1);
$totalarray['totalbudget'] += $obj->budget_amount;
}
print '</td>';
@ -826,9 +827,9 @@ while ($i < min($num,$limit))
$tmpkey='options_'.$key;
print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1);
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
}
if (! $i) $totalarray['nbfield']++;
}
// Fields from hook
$parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj);
@ -866,7 +867,7 @@ while ($i < min($num,$limit))
}
print '</td>';
if (! $i) $totalarray['nbfield']++;
print "</tr>\n";
}
@ -887,8 +888,8 @@ if (isset($totalarray['totaloppfield']) || isset($totalarray['totalbudgetfield']
if ($num < $limit && empty($offset)) print '<td align="left">'.$langs->trans("Total").'</td>';
else print '<td align="left">'.$langs->trans("Totalforthispage").'</td>';
}
elseif ($totalarray['totaloppfield'] == $i) print '<td align="right">'.price($totalarray['totalopp']).'</td>';
elseif ($totalarray['totalbudgetfield'] == $i) print '<td align="right">'.price($totalarray['totalbudget']).'</td>';
elseif ($totalarray['totaloppfield'] == $i) print '<td align="right">'.price($totalarray['totalopp'], 1, $langs, 1, -1, -1).'</td>';
elseif ($totalarray['totalbudgetfield'] == $i) print '<td align="right">'.price($totalarray['totalbudget'], 1, $langs, 1, -1, -1).'</td>';
else print '<td></td>';
}
print '</tr>';

View File

@ -85,7 +85,7 @@ if (!$user->rights->projet->lire) accessforbidden();
$diroutputmassaction=$conf->projet->dir_output . '/tasks/temp/massgeneration/'.$user->id;
$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit;
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');

View File

@ -58,7 +58,7 @@ $socid=0;
//if ($user->societe_id > 0) $socid = $user->societe_id; // For external user, no check is done on company because readability is managed by public status of project and assignement.
if (!$user->rights->projet->lire) accessforbidden();
$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit;
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');

View File

@ -91,7 +91,7 @@ if (empty($sortorder)) $sortorder="ASC";
if (empty($sortfield)) $sortfield="t.rowid";
if (empty($arch)) $arch = 0;
$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit;
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$page = GETPOST("page");
$page = is_numeric($page) ? $page : 0;
$page = $page == -1 ? 0 : $page;
@ -257,66 +257,63 @@ if ($ret)
{
foreach ($object->lines as $resource)
{
print '<tr class="oddeven">';
$style='';
if ($resource->id == GETPOST('lineid')) $style='style="background: orange;"';
if (! empty($arrayfields['t.ref']['checked']))
{
print '<td>';
print $resource->getNomUrl(5);
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
print '<tr '.$bc[$var].' '.$style.'>';
if (! empty($arrayfields['ty.label']['checked']))
{
print '<td>';
print $resource->type_label;
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
// 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']))
{
print '<td';
$align=$extrafields->getAlignFlag($key);
if ($align) print ' align="'.$align.'"';
print '>';
$tmpkey='options_'.$key;
print $extrafields->showOutputField($key, $resource->array_options[$tmpkey], '', 1);
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
}
}
if (! empty($arrayfields['t.ref']['checked']))
{
print '<td>';
print $resource->getNomUrl(5);
print '</td>';
}
print '<td align="center">';
print '<a href="./card.php?action=edit&id='.$resource->id.'">';
print img_edit();
print '</a>';
print '&nbsp;';
print '<a href="./card.php?action=delete&id='.$resource->id.'">';
print img_delete();
print '</a>';
print '</td>';
if (! $i) $totalarray['nbfield']++;
if (! empty($arrayfields['ty.label']['checked']))
{
print '<td>';
print $resource->type_label;
print '</td>';
}
// 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']))
{
print '<td';
$align=$extrafields->getAlignFlag($key);
if ($align) print ' align="'.$align.'"';
print '>';
$tmpkey='options_'.$key;
print $extrafields->showOutputField($key, $resource->array_options[$tmpkey], '', 1);
print '</td>';
}
}
if (! $i) $totalarray['nbfield']++;
}
print '<td align="center">';
print '<a href="./card.php?action=edit&id='.$resource->id.'">';
print img_edit();
print '</a>';
print '&nbsp;';
print '<a href="./card.php?action=delete&id='.$resource->id.'">';
print img_delete();
print '</a>';
print '</td>';
print '</tr>';
print '</tr>';
}
print '</table>';
print "</form>\n";
}
else
{
print '<tr><td class="opacitymedium">'.$langs->trans('NoResourceInDatabase').'</td></tr>';
}
llxFooter();
print '</table>';
print "</form>\n";
llxFooter();
$db->close();

View File

@ -50,7 +50,7 @@ $socid = GETPOST('socid','int');
if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'societe', $socid, '&societe');
$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit;
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');

View File

@ -582,6 +582,7 @@ if (empty($reshook))
if (! empty($backtopage))
{
if (preg_match('/\?/', $backtopage)) $backtopage.='&socid='.$object->id;
header("Location: ".$backtopage);
exit;
}
@ -1065,7 +1066,7 @@ else
print '<td class="maxwidthonsmartphone">';
$selected=isset($_POST['client'])?GETPOST('client'):$object->client;
print '<select class="flat" name="client" id="customerprospect">';
if (GETPOST("type") == '') print '<option value="-1"></option>';
if (GETPOST("type") == '') print '<option value="-1">&nbsp;</option>';
if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) print '<option value="2"'.($selected==2?' selected':'').'>'.$langs->trans('Prospect').'</option>';
if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTSCUSTOMERS)) print '<option value="3"'.($selected==3?' selected':'').'>'.$langs->trans('ProspectCustomer').'</option>';
if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) print '<option value="1"'.($selected==1?' selected':'').'>'.$langs->trans('Customer').'</option>';

View File

@ -84,7 +84,7 @@ $mode=GETPOST("mode");
$diroutputmassaction=$conf->societe->dir_output . '/temp/massgeneration/'.$user->id;
$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit;
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield=GETPOST("sortfield",'alpha');
$sortorder=GETPOST("sortorder",'alpha');
$page=GETPOST("page",'int');
@ -247,7 +247,7 @@ if (empty($reshook))
$permtodelete = $user->rights->societe->supprimer;
$uploaddir = $conf->societe->dir_output;
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
if ($action == 'setstcomm')
{
$object = new Client($db);
@ -930,6 +930,7 @@ print "</tr>\n";
$i = 0;
$totalarray=array();
while ($i < min($num, $limit))
{
$obj = $db->fetch_object($resql);
@ -955,46 +956,55 @@ while ($i < min($num, $limit))
print '<td class="tdoverflowmax200">';
print $companystatic->getNomUrl(1,'',100);
print "</td>\n";
if (! $i) $totalarray['nbfield']++;
}
// Barcode
if (! empty($arrayfields['s.barcode']['checked']))
{
print '<td>'.$obj->barcode.'</td>';
if (! $i) $totalarray['nbfield']++;
}
// Customer code
if (! empty($arrayfields['s.code_client']['checked']))
{
print '<td>'.$obj->code_client.'</td>';
if (! $i) $totalarray['nbfield']++;
}
// Supplier code
if (! empty($arrayfields['s.code_fournisseur']['checked']))
{
print '<td>'.$obj->code_fournisseur.'</td>';
if (! $i) $totalarray['nbfield']++;
}
// Account customer code
if (! empty($arrayfields['s.code_compta']['checked']))
{
print '<td>'.$obj->code_compta.'</td>';
if (! $i) $totalarray['nbfield']++;
}
// Account supplier code
if (! empty($arrayfields['s.code_compta_fournisseur']['checked']))
{
print '<td>'.$obj->code_compta_fournisseur.'</td>';
if (! $i) $totalarray['nbfield']++;
}
// Town
if (! empty($arrayfields['s.town']['checked']))
{
print "<td>".$obj->town."</td>\n";
if (! $i) $totalarray['nbfield']++;
}
// Zip
if (! empty($arrayfields['s.zip']['checked']))
{
print "<td>".$obj->zip."</td>\n";
if (! $i) $totalarray['nbfield']++;
}
// State
if (! empty($arrayfields['state.nom']['checked']))
{
print "<td>".$obj->state_name."</td>\n";
if (! $i) $totalarray['nbfield']++;
}
// Country
if (! empty($arrayfields['country.code_iso']['checked']))
@ -1003,6 +1013,7 @@ while ($i < min($num, $limit))
$tmparray=getCountry($obj->fk_pays,'all');
print $tmparray['label'];
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
// Type ent
if (! empty($arrayfields['typent.code']['checked']))
@ -1011,42 +1022,52 @@ while ($i < min($num, $limit))
if (count($typenArray)==0) $typenArray = $formcompany->typent_array(1);
print $typenArray[$obj->typent_code];
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
if (! empty($arrayfields['s.email']['checked']))
{
print "<td>".$obj->email."</td>\n";
if (! $i) $totalarray['nbfield']++;
}
if (! empty($arrayfields['s.phone']['checked']))
{
print "<td>".$obj->phone."</td>\n";
if (! $i) $totalarray['nbfield']++;
}
if (! empty($arrayfields['s.url']['checked']))
{
print "<td>".$obj->url."</td>\n";
if (! $i) $totalarray['nbfield']++;
}
if (! empty($arrayfields['s.siren']['checked']))
{
print "<td>".$obj->idprof1."</td>\n";
if (! $i) $totalarray['nbfield']++;
}
if (! empty($arrayfields['s.siret']['checked']))
{
print "<td>".$obj->idprof2."</td>\n";
if (! $i) $totalarray['nbfield']++;
}
if (! empty($arrayfields['s.ape']['checked']))
{
print "<td>".$obj->idprof3."</td>\n";
if (! $i) $totalarray['nbfield']++;
}
if (! empty($arrayfields['s.idprof4']['checked']))
{
print "<td>".$obj->idprof4."</td>\n";
if (! $i) $totalarray['nbfield']++;
}
if (! empty($arrayfields['s.idprof5']['checked']))
{
print "<td>".$obj->idprof5."</td>\n";
if (! $i) $totalarray['nbfield']++;
}
if (! empty($arrayfields['s.idprof6']['checked']))
{
print "<td>".$obj->idprof6."</td>\n";
if (! $i) $totalarray['nbfield']++;
}
// Type
if (! empty($arrayfields['customerorsupplier']['checked']))
@ -1075,6 +1096,7 @@ while ($i < min($num, $limit))
}
print $s;
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
if (! empty($arrayfields['s.fk_prospectlevel']['checked']))
@ -1083,6 +1105,7 @@ while ($i < min($num, $limit))
print '<td align="center">';
print $companystatic->getLibProspLevel();
print "</td>";
if (! $i) $totalarray['nbfield']++;
}
if (! empty($arrayfields['s.fk_stcomm']['checked']))
@ -1098,6 +1121,7 @@ while ($i < min($num, $limit))
if ($obj->stcomm_id != $val['id']) print '<a class="pictosubstatus" href="'.$_SERVER["PHP_SELF"].'?stcommsocid='.$obj->rowid.'&stcomm='.$val['code'].'&action=setstcomm'.$param.($page?'&page='.urlencode($page):'').'">'.img_action($titlealt,$val['code']).'</a>';
}
print '</div></div></td>';
if (! $i) $totalarray['nbfield']++;
}
// Extra fields
if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
@ -1113,6 +1137,7 @@ while ($i < min($num, $limit))
$tmpkey='options_'.$key;
print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1);
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
}
}
@ -1126,6 +1151,7 @@ while ($i < min($num, $limit))
print '<td align="center" class="nowrap">';
print dol_print_date($db->jdate($obj->date_creation), 'dayhour');
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
// Date modification
if (! empty($arrayfields['s.tms']['checked']))
@ -1133,11 +1159,13 @@ while ($i < min($num, $limit))
print '<td align="center" class="nowrap">';
print dol_print_date($db->jdate($obj->date_update), 'dayhour');
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
// Status
if (! empty($arrayfields['s.status']['checked']))
{
print '<td align="center" class="nowrap">'.$companystatic->getLibStatut(3).'</td>';
if (! $i) $totalarray['nbfield']++;
}
// Action column
@ -1150,7 +1178,7 @@ while ($i < min($num, $limit))
}
print '</td>';
if (! $i) $totalarray['nbfield']++;
print '</tr>'."\n";
$i++;
}

View File

@ -44,7 +44,7 @@ $actionid=GETPOST('actionid');
if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'societe','','');
$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit;
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield=GETPOST("sortfield",'alpha');
$sortorder=GETPOST("sortorder",'alpha');
$page=GETPOST("page",'int');

View File

@ -4179,7 +4179,7 @@ dl.dropdown {
position:absolute;
top:2px;
list-style:none;
max-height: 300px;
max-height: 280px;
overflow: auto;
}
.dropdown span.value {

View File

@ -4266,7 +4266,7 @@ dl.dropdown {
position:absolute;
top:2px;
list-style:none;
max-height: 300px;
max-height: 280px;
overflow: auto;
}
.dropdown span.value {

View File

@ -45,7 +45,7 @@ $search_group=GETPOST('search_group');
$optioncss = GETPOST('optioncss','alpha');
// Load variable for pagination
$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit;
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST('sortfield','alpha');
$sortorder = GETPOST('sortorder','alpha');
$page = GETPOST('page','int');

View File

@ -46,7 +46,7 @@ if ($user->societe_id > 0)
$mode = GETPOST("mode", 'alpha');
// Load variable for pagination
$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit;
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST('sortfield','alpha');
$sortorder = GETPOST('sortorder','alpha');
$page = GETPOST('page','int');
@ -465,6 +465,7 @@ print "</tr>\n";
$i = 0;
$totalarray=array();
while ($i < min($num,$limit))
{
$obj = $db->fetch_object($result);
@ -497,32 +498,39 @@ while ($i < min($num,$limit))
print img_picto($langs->trans("Administrator"), 'star', 'class="valignmiddle paddingleft"');
}
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
if (! empty($arrayfields['u.lastname']['checked']))
{
print '<td>'.$obj->lastname.'</td>';
if (! $i) $totalarray['nbfield']++;
}
if (! empty($arrayfields['u.firstname']['checked']))
{
print '<td>'.$obj->firstname.'</td>';
if (! $i) $totalarray['nbfield']++;
}
if (! empty($arrayfields['u.gender']['checked']))
{
print '<td>';
if ($obj->gender) print $langs->trans("Gender".$obj->gender);
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
if (! empty($arrayfields['u.employee']['checked']))
{
print '<td>'.yn($obj->employee).'</td>';
if (! $i) $totalarray['nbfield']++;
}
if (! empty($arrayfields['u.accountancy_code']['checked']))
{
print '<td>'.$obj->accountancy_code.'</td>';
if (! $i) $totalarray['nbfield']++;
}
if (! empty($arrayfields['u.email']['checked']))
{
print '<td>'.$obj->email.'</td>';
if (! $i) $totalarray['nbfield']++;
}
if (! empty($arrayfields['u.fk_soc']['checked']))
{
@ -543,6 +551,7 @@ while ($i < min($num,$limit))
print $langs->trans("InternalUser");
}
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
// Multicompany enabled
if (! empty($conf->multicompany->enabled) && is_object($mc) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))
@ -560,6 +569,7 @@ while ($i < min($num,$limit))
print $mc->label;
}
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
}
// Supervisor
@ -589,17 +599,20 @@ while ($i < min($num,$limit))
}
}
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
// Date last login
if (! empty($arrayfields['u.datelastlogin']['checked']))
{
print '<td class="nowrap" align="center">'.dol_print_date($db->jdate($obj->datelastlogin),"dayhour").'</td>';
if (! $i) $totalarray['nbfield']++;
}
// Date previous login
if (! empty($arrayfields['u.datepreviouslogin']['checked']))
{
print '<td class="nowrap" align="center">'.dol_print_date($db->jdate($obj->datepreviouslogin),"dayhour").'</td>';
if (! $i) $totalarray['nbfield']++;
}
// Extra fields
@ -616,6 +629,7 @@ while ($i < min($num,$limit))
$tmpkey='options_'.$key;
print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1);
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
}
}
@ -629,6 +643,7 @@ while ($i < min($num,$limit))
print '<td align="center">';
print dol_print_date($db->jdate($obj->date_creation), 'dayhour');
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
// Date modification
if (! empty($arrayfields['u.tms']['checked']))
@ -636,15 +651,18 @@ while ($i < min($num,$limit))
print '<td align="center">';
print dol_print_date($db->jdate($obj->date_update), 'dayhour');
print '</td>';
if (! $i) $totalarray['nbfield']++;
}
// Status
if (! empty($arrayfields['u.statut']['checked']))
{
$userstatic->statut=$obj->statut;
print '<td align="center">'.$userstatic->getLibStatut(3).'</td>';
$userstatic->statut=$obj->statut;
print '<td align="center">'.$userstatic->getLibStatut(3).'</td>';
if (! $i) $totalarray['nbfield']++;
}
// Action column
print '<td></td>';
if (! $i) $totalarray['nbfield']++;
print "</tr>\n";
$i++;

View File

@ -44,7 +44,7 @@ $actionid=GETPOST('actionid');
if ($user->societe_id) $id=$user->societe_id;
$result = restrictedArea($user, 'societe','','');
$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit;
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield=GETPOST("sortfield",'alpha');
$sortorder=GETPOST("sortorder",'alpha');
$page=GETPOST("page",'int');