Merge branch 'develop' into 14a15

This commit is contained in:
Alexandre SPANGARO 2021-02-28 07:12:24 +01:00 committed by GitHub
commit ad95caac7e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
303 changed files with 20243 additions and 16622 deletions

View File

@ -21,6 +21,8 @@ Following changes may create regressions for some external modules, but were nec
* API /setup/shipment_methods has been replaced with API /setup/shipping_methods
* Field "tva" renamed into "total_tva" in llx_propal, llx_supplier_proposal, llx_commande, llx_commande_fournisseur for better field name consistency
* Field "total" renamed into "total_ttc" in llx_propal, llx_supplier_proposal for better field name consistency
* If your database is PostgreSql, you must use version 9.1.0 or more (Dolibarr need the SQL function CONCAT)
* If your database is MySql or MariaDB, you need at least version 5.1
***** ChangeLog for 13.0.1 compared to 13.0.0 *****

View File

@ -1,135 +0,0 @@
<?php
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2014 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.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
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
/**
* \file htdocs/accountancy/bookkeeping/balancebymonth.php
* \ingroup Accountancy (Double entries)
* \brief Balance by month
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
// Load translation files required by the page
$langs->loadLangs(array("bills", "compta", "accountancy", "other"));
// Filter
$year = GETPOST("year", 'int');
if ($year == 0) {
$year_current = strftime("%Y", time());
$year_start = $year_current;
} else {
$year_current = $year;
$year_start = $year;
}
/*
* View
*/
llxHeader('', $langs->trans("Bookkeeping"));
$textprevyear = '<a href="'.$_SERVER["PHP_SELF"].'?year='.($year_current - 1).'">'.img_previous().'</a>';
$textnextyear = '&nbsp;<a href="'.$_SERVER["PHP_SELF"].'?year='.($year_current + 1).'">'.img_next().'</a>';
print load_fiche_titre($langs->trans("AccountBalanceByMonth").' '.$textprevyear.' '.$langs->trans("Year").' '.$year_start.' '.$textnextyear);
$sql = "SELECT count(*) FROM ".MAIN_DB_PREFIX."facturedet as fd";
$sql .= " , ".MAIN_DB_PREFIX."facture as f";
$sql .= " WHERE fd.fk_code_ventilation = 0";
$sql .= " AND f.rowid = fd.fk_facture AND f.fk_statut = 1;";
dol_syslog('accountancy/bookkeeping/balancebymonth.php:: $sql='.$sql);
$result = $db->query($sql);
if ($result) {
$row = $db->fetch_row($result);
$nbfac = $row[0];
$db->free($result);
}
$y = $year_current;
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td width=150>'.$langs->trans("Label").'</td>';
for ($i = 1; $i <= 12; $i++) {
print '<td class="right">'.$langs->trans("MonthShort".sprintf("%02s", $i)).'</td>';
}
print '<td class="center"><strong>'.$langs->trans("Total").'</strong></td>';
print '</tr>';
$sql = "SELECT bk.numero_compte AS 'compte',";
$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=1,bk.montant,0)),2) AS 'Janvier',";
$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=2,bk.montant,0)),2) AS 'Fevrier',";
$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=3,bk.montant,0)),2) AS 'Mars',";
$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=4,bk.montant,0)),2) AS 'Avril',";
$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=5,bk.montant,0)),2) AS 'Mai',";
$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=6,bk.montant,0)),2) AS 'Juin',";
$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=7,bk.montant,0)),2) AS 'Juillet',";
$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=8,bk.montant,0)),2) AS 'Aout',";
$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=9,bk.montant,0)),2) AS 'Septembre',";
$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=10,bk.montant,0)),2) AS 'Octobre',";
$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=11,bk.montant,0)),2) AS 'Novembre',";
$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=12,bk.montant,0)),2) AS 'Decembre',";
$sql .= " ROUND(SUM(bk.montant),2) as 'Total'";
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as bk";
$sql .= " WHERE bk.doc_date >= '".$db->idate(dol_get_first_day($y, 1, false))."'";
$sql .= " AND bk.doc_date <= '".$db->idate(dol_get_last_day($y, 12, false))."'";
$sql .= " GROUP BY bk.numero_compte";
$resql = $db->query($sql);
if ($resql) {
$i = 0;
$num = $db->num_rows($resql);
while ($i < $num) {
$row = $db->fetch_row($resql);
print '<tr class="oddeven"><td width="14%">'.length_accountg($row[0]).'</td>';
print '<td class="right" width="6.5%">'.price($row[1]).'</td>';
print '<td class="right" width="6.5%">'.price($row[2]).'</td>';
print '<td class="right" width="6.5%">'.price($row[3]).'</td>';
print '<td class="right" width="6.5%">'.price($row[4]).'</td>';
print '<td class="right" width="6.5%">'.price($row[5]).'</td>';
print '<td class="right" width="6.5%">'.price($row[6]).'</td>';
print '<td class="right" width="6.5%">'.price($row[7]).'</td>';
print '<td class="right" width="6.5%">'.price($row[8]).'</td>';
print '<td class="right" width="6.5%">'.price($row[9]).'</td>';
print '<td class="right" width="6.5%">'.price($row[10]).'</td>';
print '<td class="right" width="6.5%">'.price($row[11]).'</td>';
print '<td class="right" width="6.5%">'.price($row[12]).'</td>';
print '<td class="right" width="8%"><strong>'.price($row[13]).'</strong></td>';
print '</tr>';
$i++;
}
$db->free($resql);
} else {
print $db->lasterror();
}
print "</table>\n";
// End of page
llxFooter();
$db->close();

View File

@ -145,7 +145,7 @@ print dol_get_fiche_end();
$sql = "SELECT bk.rowid, bk.doc_date, bk.doc_type, bk.doc_ref, ";
$sql .= " bk.subledger_account, bk.numero_compte , bk.label_compte, bk.debit, ";
$sql .= " bk.credit, bk.montant , bk.sens , bk.code_journal , bk.piece_num, bk.lettering_code ";
$sql .= " bk.credit, bk.montant, bk.sens, bk.code_journal, bk.piece_num, bk.lettering_code";
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as bk";
$sql .= " WHERE (bk.subledger_account = '".$db->escape($object->code_compta)."' AND bk.numero_compte = '".$db->escape($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER)."' )";

View File

@ -144,7 +144,7 @@ print dol_get_fiche_end();
$sql = "SELECT bk.rowid, bk.doc_date, bk.doc_type, bk.doc_ref, ";
$sql .= " bk.subledger_account, bk.numero_compte , bk.label_compte, bk.debit, ";
$sql .= " bk.credit, bk.montant , bk.sens , bk.code_journal , bk.piece_num, bk.lettering_code, bk.date_validated ";
$sql .= " bk.credit, bk.montant, bk.sens, bk.code_journal, bk.piece_num, bk.lettering_code, bk.date_validated ";
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as bk";
$sql .= " WHERE (bk.subledger_account = '".$db->escape($object->code_compta_fournisseur)."' AND bk.numero_compte = '".$db->escape($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER)."' )";
if (dol_strlen($search_date_start) || dol_strlen($search_date_end)) {

View File

@ -359,7 +359,7 @@ class AccountancyExport
print length_accountg($line->numero_compte).$separator;
print length_accounta($line->subledger_account).$separator;
print $line->sens.$separator;
print price2fec(abs($line->montant)).$separator;
print price2fec(abs($line->debit - $line->credit)).$separator;
print dol_string_unaccent($line->label_operation).$separator;
print dol_string_unaccent($line->doc_ref);
print $end_line;
@ -387,11 +387,11 @@ class AccountancyExport
print $line->label_operation.$separator;
print $date.$separator;
if ($line->sens == 'D') {
print price($line->montant).$separator;
print price($line->debit).$separator;
print ''.$separator;
} elseif ($line->sens == 'C') {
print ''.$separator;
print price($line->montant).$separator;
print price($line->credit).$separator;
}
print $line->doc_ref.$separator;
print $line->label_operation.$separator;
@ -493,7 +493,7 @@ class AccountancyExport
$Tab['num_piece'] = str_pad(self::trunc($data->piece_num, 12), 12);
$Tab['num_compte'] = str_pad(self::trunc($code_compta, 11), 11);
$Tab['libelle_ecriture'] = str_pad(self::trunc(dol_string_unaccent($data->doc_ref).dol_string_unaccent($data->label_operation), 25), 25);
$Tab['montant'] = str_pad(abs($data->montant), 13, ' ', STR_PAD_LEFT);
$Tab['montant'] = str_pad(abs($data->debit - $data->credit), 13, ' ', STR_PAD_LEFT);
$Tab['type_montant'] = str_pad($data->sens, 1);
$Tab['vide'] = str_repeat(' ', 18);
$Tab['intitule_compte'] = str_pad(self::trunc(dol_string_unaccent($data->label_operation), 34), 34);
@ -541,20 +541,23 @@ class AccountancyExport
$Tab['libelle_ecriture'] = str_pad(self::trunc(dol_string_unaccent($data->doc_ref).' '.dol_string_unaccent($data->label_operation), 20), 20);
// Credit invoice - invert sens
if ($data->montant < 0) {
if ($data->sens == 'C') {
$Tab['sens'] = 'D';
} else {
$Tab['sens'] = 'C';
}
$Tab['signe_montant'] = '-';
} else {
$Tab['sens'] = $data->sens; // C or D
$Tab['signe_montant'] = '+';
}
/*
if ($data->montant < 0) {
if ($data->sens == 'C') {
$Tab['sens'] = 'D';
} else {
$Tab['sens'] = 'C';
}
$Tab['signe_montant'] = '-';
} else {
$Tab['sens'] = $data->sens; // C or D
$Tab['signe_montant'] = '+';
}*/
$Tab['sens'] = $data->sens; // C or D
$Tab['signe_montant'] = '+';
// The amount must be in centimes without decimal points.
$Tab['montant'] = str_pad(abs($data->montant * 100), 12, '0', STR_PAD_LEFT);
$Tab['montant'] = str_pad(abs(($data->debit - $abs->credit) * 100), 12, '0', STR_PAD_LEFT);
$Tab['contrepartie'] = str_repeat(' ', 8);
// Force date format : %d%m%y
@ -640,13 +643,13 @@ class AccountancyExport
$Tab['num_compte'] = str_pad(self::trunc($code_compta, 6), 6, '0');
if ($data->sens == 'D') {
$Tab['montant_debit'] = str_pad(number_format(abs($data->montant), 2, ',', ''), 13, ' ', STR_PAD_LEFT);
$Tab['montant_debit'] = str_pad(number_format($data->debit, 2, ',', ''), 13, ' ', STR_PAD_LEFT);
$Tab['montant_crebit'] = str_pad(number_format(0, 2, ',', ''), 13, ' ', STR_PAD_LEFT);
} else {
$Tab['montant_debit'] = str_pad(number_format(0, 2, ',', ''), 13, ' ', STR_PAD_LEFT);
$Tab['montant_crebit'] = str_pad(number_format(abs($data->montant), 2, ',', ''), 13, ' ', STR_PAD_LEFT);
$Tab['montant_crebit'] = str_pad(number_format($data->credit, 2, ',', ''), 13, ' ', STR_PAD_LEFT);
}
$Tab['libelle_ecriture'] = str_pad(self::trunc(dol_string_unaccent($data->doc_ref).' '.dol_string_unaccent($data->label_operation), 30), 30);
@ -707,7 +710,7 @@ class AccountancyExport
//print substr(length_accountg($line->numero_compte), 0, 2) . $separator;
print '"'.dol_trunc($line->label_operation, 40, 'right', 'UTF-8', 1).'"'.$separator;
print '"'.dol_trunc($line->piece_num, 15, 'right', 'UTF-8', 1).'"'.$separator;
print price2num(abs($line->montant)).$separator;
print price2num(abs($line->debit - $line->credit)).$separator;
print $line->sens.$separator;
print $date.$separator;
//print 'EUR';
@ -747,7 +750,7 @@ class AccountancyExport
print self::toAnsi($line->doc_ref).$separator;
print price($line->debit).$separator;
print price($line->credit).$separator;
print price($line->montant).$separator;
print price(abs($line->debit - $line->credit)).$separator;
print $line->sens.$separator;
print $line->lettering_code.$separator;
print $line->code_journal;
@ -810,7 +813,7 @@ class AccountancyExport
$tab[] = length_accounta($line->subledger_account);
$tab[] = price2num($line->debit);
$tab[] = price2num($line->credit);
$tab[] = price2num($line->montant);
$tab[] = price2num($line->debit - $line->credit);
$tab[] = $line->code_journal;
print implode($separator, $tab).$this->end_line;
@ -853,8 +856,8 @@ class AccountancyExport
foreach ($objectLines as $line) {
if ($line->debit == 0 && $line->credit == 0) {
unset($array[$line]);
} else {
//unset($array[$line]);
} else {
$date_creation = dol_print_date($line->date_creation, '%Y%m%d');
$date_document = dol_print_date($line->doc_date, '%Y%m%d');
$date_lettering = dol_print_date($line->date_lettering, '%Y%m%d');
@ -959,7 +962,7 @@ class AccountancyExport
foreach ($objectLines as $line) {
if ($line->debit == 0 && $line->credit == 0) {
unset($array[$line]);
//unset($array[$line]);
} else {
$date_creation = dol_print_date($line->date_creation, '%Y%m%d');
$date_document = dol_print_date($line->doc_date, '%Y%m%d');
@ -1110,11 +1113,7 @@ class AccountancyExport
// Code
print '""'.$this->separator;
// Netto
if ($line->montant >= 0) {
print $line->montant.$this->separator;
} else {
print ($line->montant * -1).$this->separator;
}
print abs($line->debit - $line->credit).$this->separator;
// Steuer
print "0.00".$this->separator;
// FW-Betrag
@ -1190,13 +1189,13 @@ class AccountancyExport
print $date_lim_reglement.$separator;
// CNPI
if ($line->doc_type == 'supplier_invoice') {
if ($line->montant < 0) {
if (($line->debit - $line->credit) > 0) {
$nature_piece = 'AF';
} else {
$nature_piece = 'FF';
}
} elseif ($line->doc_type == 'customer_invoice') {
if ($line->montant < 0) {
if (($line->debit - $line->credit) < 0) {
$nature_piece = 'AC';
} else {
$nature_piece = 'FC';
@ -1220,7 +1219,7 @@ class AccountancyExport
print $racine_subledger_account.$separator; // deprecated CPTG & CPTA use instead
// MONT
print price(abs($line->montant), 0, '', 1, 2, 2).$separator;
print price(abs($line->debit - $line->credit), 0, '', 1, 2, 2).$separator;
// CODC
print $line->sens.$separator;
// CPTG
@ -1451,13 +1450,13 @@ class AccountancyExport
print $date_lim_reglement.$separator;
// CNPI
if ($line->doc_type == 'supplier_invoice') {
if ($line->montant < 0) {
if (($line->debit - $line->credit) > 0) {
$nature_piece = 'AF';
} else {
$nature_piece = 'FF';
}
} elseif ($line->doc_type == 'customer_invoice') {
if ($line->montant < 0) {
if (($line->debit - $line->credit) < 0) {
$nature_piece = 'AC';
} else {
$nature_piece = 'FC';
@ -1481,7 +1480,7 @@ class AccountancyExport
print $racine_subledger_account.$separator; // deprecated CPTG & CPTA use instead
// MONT
print price(abs($line->montant), 0, '', 1, 2).$separator;
print price(abs($line->debit - $line->credit), 0, '', 1, 2).$separator;
// CODC
print $line->sens.$separator;
// CPTG
@ -1602,7 +1601,7 @@ class AccountancyExport
print self::trunc($line->label_compte, 60).$separator; //Account label
print self::trunc($line->doc_ref, 20).$separator; //Piece
print self::trunc($line->label_operation, 60).$separator; //Operation label
print price(abs($line->montant)).$separator; //Amount
print price(abs($line->debit - $line->credit)).$separator; //Amount
print $line->sens.$separator; //Direction
print $separator; //Analytic
print $separator; //Analytic
@ -1631,7 +1630,7 @@ class AccountancyExport
$supplier_invoices_infos = array();
foreach ($objectLines as $line) {
if ($line->debit == 0 && $line->credit == 0) {
unset($array[$line]);
//unset($array[$line]);
} else {
$date = dol_print_date($line->doc_date, '%d/%m/%Y');
@ -1699,8 +1698,8 @@ class AccountancyExport
print dol_trunc(str_replace('"', '', $line->piece_num), 10, 'right', 'UTF-8', 1) . $this->separator;
//Devise
print 'EUR' . $this->separator;
//Montant
print price2num(abs($line->montant)) . $this->separator;
//Amount
print price2num(abs($line->debit - $line->credit)) . $this->separator;
//Sens
print $line->sens . $this->separator;
//Code lettrage
@ -1726,14 +1725,14 @@ class AccountancyExport
foreach ($objectLines as $line) {
if ($line->debit == 0 && $line->credit == 0) {
unset($array[$line]);
//unset($array[$line]);
} else {
$date = dol_print_date($line->doc_date, '%d%m%Y');
print $line->id . $this->separator;
print $date . $this->separator;
print substr($line->code_journal, 0, 4) . $this->separator;
if ((substr($line->numero_compte, 0, 3) == '411') || (substr($line->numero_compte, 0, 3) == '401')) {
if ((substr($line->numero_compte, 0, 3) == '411') || (substr($line->numero_compte, 0, 3) == '401')) { // TODO No hard code value
print length_accountg($line->subledger_account) . $this->separator;
} else {
print substr(length_accountg($line->numero_compte), 0, 15) . $this->separator;
@ -1742,7 +1741,7 @@ class AccountancyExport
//print '"'.dol_trunc(str_replace('"', '', $line->label_operation),40,'right','UTF-8',1).'"' . $this->separator;
print '"' . dol_trunc(str_replace('"', '', $line->doc_ref), 40, 'right', 'UTF-8', 1) . '"' . $this->separator;
print '"' . dol_trunc(str_replace('"', '', $line->piece_num), 10, 'right', 'UTF-8', 1) . '"' . $this->separator;
print price2num($line->montant) . $this->separator;
print price2num(abs($line->debit - $line->credit)) . $this->separator;
print $line->sens . $this->separator;
print $date . $this->separator;
print $this->separator;

View File

@ -135,6 +135,7 @@ class BookKeeping extends CommonObject
/**
* @var float FEC:Amount (Not necessary)
* @deprecated No more used
*/
public $amount;
@ -239,6 +240,9 @@ class BookKeeping extends CommonObject
if (isset($this->montant)) {
$this->montant = (float) $this->montant;
}
if (isset($this->amount)) {
$this->amount = (float) $this->amount;
}
if (isset($this->sens)) {
$this->sens = trim($this->sens);
}
@ -563,6 +567,9 @@ class BookKeeping extends CommonObject
if (isset($this->montant)) {
$this->montant = trim($this->montant);
}
if (isset($this->amount)) {
$this->amount = trim($this->amount);
}
if (isset($this->sens)) {
$this->sens = trim($this->sens);
}
@ -708,7 +715,7 @@ class BookKeeping extends CommonObject
$sql .= " t.label_operation,";
$sql .= " t.debit,";
$sql .= " t.credit,";
$sql .= " t.montant,";
$sql .= " t.montant as amount,";
$sql .= " t.sens,";
$sql .= " t.fk_user_author,";
$sql .= " t.import_key,";
@ -747,7 +754,8 @@ class BookKeeping extends CommonObject
$this->label_operation = $obj->label_operation;
$this->debit = $obj->debit;
$this->credit = $obj->credit;
$this->montant = $obj->montant;
$this->montant = $obj->amount;
$this->amount = $obj->amount;
$this->sens = $obj->sens;
$this->fk_user_author = $obj->fk_user_author;
$this->import_key = $obj->import_key;
@ -1207,8 +1215,8 @@ class BookKeeping extends CommonObject
if (isset($this->credit)) {
$this->credit = trim($this->credit);
}
if (isset($this->montant)) {
$this->montant = trim($this->montant);
if (isset($this->amount)) {
$this->amount = trim($this->amount);
}
if (isset($this->sens)) {
$this->sens = trim($this->sens);
@ -1655,7 +1663,7 @@ class BookKeeping extends CommonObject
$sql = "SELECT rowid, doc_date, doc_type,";
$sql .= " doc_ref, fk_doc, fk_docdet, thirdparty_code, subledger_account, subledger_label,";
$sql .= " numero_compte, label_compte, label_operation, debit, credit,";
$sql .= " montant, sens, fk_user_author, import_key, code_journal, journal_label, piece_num, date_creation";
$sql .= " montant as amount, sens, fk_user_author, import_key, code_journal, journal_label, piece_num, date_creation";
$sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element.$mode;
$sql .= " WHERE piece_num = ".$piecenum;
$sql .= " AND entity IN (".getEntity('accountancy').")";
@ -1681,7 +1689,8 @@ class BookKeeping extends CommonObject
$line->label_operation = $obj->label_operation;
$line->debit = $obj->debit;
$line->credit = $obj->credit;
$line->montant = $obj->montant;
$line->montant = $obj->amount;
$line->amount = $obj->amount;
$line->sens = $obj->sens;
$line->code_journal = $obj->code_journal;
$line->journal_label = $obj->journal_label;
@ -1714,7 +1723,7 @@ class BookKeeping extends CommonObject
$sql = "SELECT rowid, doc_date, doc_type,";
$sql .= " doc_ref, fk_doc, fk_docdet, thirdparty_code, subledger_account, subledger_label,";
$sql .= " numero_compte, label_compte, label_operation, debit, credit,";
$sql .= " montant, sens, fk_user_author, import_key, code_journal, piece_num";
$sql .= " montant as amount, sens, fk_user_author, import_key, code_journal, piece_num";
$sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element;
$sql .= " WHERE entity IN (".getEntity('accountancy').")";
@ -1744,7 +1753,8 @@ class BookKeeping extends CommonObject
$line->label_operation = $obj->label_operation;
$line->debit = $obj->debit;
$line->credit = $obj->credit;
$line->montant = $obj->montant;
$line->montant = $obj->amount;
$line->amount = $obj->amount;
$line->sens = $obj->sens;
$line->code_journal = $obj->code_journal;
$line->piece_num = $obj->piece_num;

View File

@ -63,7 +63,9 @@ if (GETPOST('addbox')) {
* View
*/
llxHeader('', $langs->trans("AccountancyArea"));
$help_url = '';
llxHeader('', $langs->trans("AccountancyArea"), $help_url);
if ($conf->accounting->enabled) {
$step = 0;
@ -91,7 +93,7 @@ if ($conf->accounting->enabled) {
}
print load_fiche_titre($langs->trans("AccountancyArea"), $resultboxes['selectboxlist'], 'title_accountancy', 0, '', '', $showtutorial);
print load_fiche_titre($langs->trans("AccountancyArea"), $resultboxes['selectboxlist'], 'accountancy', 0, '', '', $showtutorial);
print '<div class="'.($helpisexpanded ? '' : 'hideobject').'" id="idfaq">'; // hideobject is to start hidden
print "<br>\n";

View File

@ -180,9 +180,12 @@ if ($object->id > 0) {
// Affichage fiche action en mode visu
print '<table class="border tableforfield centpercent">';
// Type
// Type of event
if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
print '<tr><td class="titlefield">'.$langs->trans("Type").'</td><td colspan="3">'.$object->type.'</td></tr>';
print '<tr><td class="titlefield">'.$langs->trans("Type").'</td><td colspan="3">';
print $object->getTypePicto();
print $langs->trans("Action".$object->type_code);
print '</td></tr>';
}
// Full day event

View File

@ -340,7 +340,7 @@ if ($object->id > 0) {
print '<tr><td>';
print $langs->trans('CustomerCode').'</td><td>';
print $object->code_client;
print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_client));
$tmpcheck = $object->check_codeclient();
if ($tmpcheck != 0 && $tmpcheck != -5) {
print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>';
@ -388,7 +388,7 @@ if ($object->id > 0) {
// TVA Intra
print '<tr><td class="nowrap">'.$langs->trans('VATIntra').'</td><td>';
print $object->tva_intra;
print showValueWithClipboardCPButton(dol_escape_htmltag($object->tva_intra));
print '</td></tr>';
// default terms of the settlement
@ -533,7 +533,7 @@ if ($object->id > 0) {
print '</tr>';
}
// Warehouse
if (!empty($conf->stock->enabled)) {
if (!empty($conf->stock->enabled) && !empty($conf->global->SOCIETE_ASK_FOR_WAREHOUSE)) {
$langs->load('stocks');
require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
$formproduct = new FormProduct($db);

View File

@ -2047,7 +2047,7 @@ if ($action == 'create') {
print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editdate&amp;id='.$object->id.'">'.img_edit($langs->trans('SetDate'), 1).'</a></td>';
}
print '</tr></table>';
print '</td><td>';
print '</td><td class="valuefield">';
if ($object->statut == Propal::STATUS_DRAFT && $action == 'editdate' && $usercancreate) {
print '<form name="editdate" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post">';
print '<input type="hidden" name="token" value="'.newToken().'">';
@ -2074,7 +2074,7 @@ if ($action == 'create') {
print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editecheance&amp;id='.$object->id.'">'.img_edit($langs->trans('SetConditions'), 1).'</a></td>';
}
print '</tr></table>';
print '</td><td>';
print '</td><td class="valuefield">';
if ($object->statut == Propal::STATUS_DRAFT && $action == 'editecheance' && $usercancreate) {
print '<form name="editecheance" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post">';
print '<input type="hidden" name="token" value="'.newToken().'">';
@ -2104,7 +2104,7 @@ if ($action == 'create') {
print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editconditions&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetConditions'), 1).'</a></td>';
}
print '</tr></table>';
print '</td><td>';
print '</td><td class="valuefield">';
if ($object->statut == Propal::STATUS_DRAFT && $action == 'editconditions' && $usercancreate) {
$form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'cond_reglement_id');
} else {
@ -2117,7 +2117,7 @@ if ($action == 'create') {
$langs->load('deliveries');
print '<tr><td>';
print $form->editfieldkey($langs->trans('DeliveryDate'), 'date_livraison', $object->delivery_date, $object, $usercancreate, 'datepicker');
print '</td><td>';
print '</td><td class="valuefield">';
print $form->editfieldval($langs->trans('DeliveryDate'), 'date_livraison', $object->delivery_date, $object, $usercancreate, 'datepicker');
print '</td>';
print '</tr>';
@ -2134,7 +2134,7 @@ if ($action == 'create') {
print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editavailability&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetAvailability'), 1).'</a></td>';
}
print '</tr></table>';
print '</td><td>';
print '</td><td class="valuefield">';
if ($object->statut == Propal::STATUS_DRAFT && $action == 'editavailability' && $usercancreate) {
$form->form_availability($_SERVER['PHP_SELF'].'?id='.$object->id, $object->availability_id, 'availability_id', 1);
} else {
@ -2154,7 +2154,7 @@ if ($action == 'create') {
print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editshippingmethod&amp;id='.$object->id.'">'.img_edit($langs->trans('SetShippingMode'), 1).'</a></td>';
}
print '</tr></table>';
print '</td><td>';
print '</td><td class="valuefield">';
if ($action == 'editshippingmethod' && $usercancreate) {
$form->formSelectShippingMethod($_SERVER['PHP_SELF'].'?id='.$object->id, $object->shipping_method_id, 'shipping_method_id', 1);
} else {
@ -2172,7 +2172,7 @@ if ($action == 'create') {
print '<tr><td>';
$editenable = $usercancreate;
print $form->editfieldkey("Warehouse", 'warehouse', '', $object, $editenable);
print '</td><td>';
print '</td><td class="valuefieldcreate">';
if ($action == 'editwarehouse') {
$formproduct->formSelectWarehouses($_SERVER['PHP_SELF'].'?id='.$object->id, $object->warehouse_id, 'warehouse_id', 1);
} else {
@ -2191,7 +2191,7 @@ if ($action == 'create') {
print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editdemandreason&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetDemandReason'), 1).'</a></td>';
}
print '</tr></table>';
print '</td><td>';
print '</td><td class="valuefield">';
if ($object->statut == Propal::STATUS_DRAFT && $action == 'editdemandreason' && $usercancreate) {
$form->formInputReason($_SERVER['PHP_SELF'].'?id='.$object->id, $object->demand_reason_id, 'demand_reason_id', 1);
} else {
@ -2202,7 +2202,7 @@ if ($action == 'create') {
// Payment mode
print '<tr>';
print '<td>';
print '<td class="valuefield">';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('PaymentMode');
print '</td>';
@ -2210,7 +2210,7 @@ if ($action == 'create') {
print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editmode&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetMode'), 1).'</a></td>';
}
print '</tr></table>';
print '</td><td>';
print '</td><td class="valuefieldcreate">';
if ($object->statut == Propal::STATUS_DRAFT && $action == 'editmode' && $usercancreate) {
$form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'mode_reglement_id', 'CRDT', 1, 1);
} else {
@ -2230,7 +2230,7 @@ if ($action == 'create') {
print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editmulticurrencycode&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1).'</a></td>';
}
print '</tr></table>';
print '</td><td>';
print '</td><td class="valuefield">';
if ($object->statut == $object::STATUS_DRAFT && $action == 'editmulticurrencycode' && $usercancreate) {
$form->form_multicurrency_code($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_code, 'multicurrency_code');
} else {
@ -2250,7 +2250,7 @@ if ($action == 'create') {
print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editmulticurrencyrate&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1).'</a></td>';
}
print '</tr></table>';
print '</td><td>';
print '</td><td class="valuefield">';
if ($object->statut == $object::STATUS_DRAFT && ($action == 'editmulticurrencyrate' || $action == 'actualizemulticurrencyrate') && $usercancreate) {
if ($action == 'actualizemulticurrencyrate') {
list($object->fk_multicurrency, $object->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($object->db, $object->multicurrency_code);
@ -2272,7 +2272,7 @@ if ($action == 'create') {
// Outstanding Bill
print '<tr><td>';
print $langs->trans('OutstandingBill');
print '</td><td class="right">';
print '</td><td class="valuefield">';
$arrayoutstandingbills = $soc->getOutstandingBills();
print price($arrayoutstandingbills['opened']).' / ';
print price($soc->outstanding_limit, 0, $langs, 1, - 1, - 1, $conf->currency);
@ -2290,7 +2290,7 @@ if ($action == 'create') {
print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editbankaccount&amp;id='.$object->id.'">'.img_edit($langs->trans('SetBankAccount'), 1).'</a></td>';
}
print '</tr></table>';
print '</td><td>';
print '</td><td class="valuefield">';
if ($action == 'editbankaccount') {
$form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1);
} else {
@ -2305,13 +2305,13 @@ if ($action == 'create') {
$totalVolume = $tmparray['volume'];
if ($totalWeight) {
print '<tr><td>'.$langs->trans("CalculatedWeight").'</td>';
print '<td>';
print '<td class="valuefield">';
print showDimensionInBestUnit($totalWeight, 0, "weight", $langs, isset($conf->global->MAIN_WEIGHT_DEFAULT_ROUND) ? $conf->global->MAIN_WEIGHT_DEFAULT_ROUND : -1, isset($conf->global->MAIN_WEIGHT_DEFAULT_UNIT) ? $conf->global->MAIN_WEIGHT_DEFAULT_UNIT : 'no');
print '</td></tr>';
}
if ($totalVolume) {
print '<tr><td>'.$langs->trans("CalculatedVolume").'</td>';
print '<td>';
print '<td class="valuefield">';
print showDimensionInBestUnit($totalVolume, 0, "volume", $langs, isset($conf->global->MAIN_VOLUME_DEFAULT_ROUND) ? $conf->global->MAIN_VOLUME_DEFAULT_ROUND : -1, isset($conf->global->MAIN_VOLUME_DEFAULT_UNIT) ? $conf->global->MAIN_VOLUME_DEFAULT_UNIT : 'no');
print '</td></tr>';
}
@ -2329,7 +2329,7 @@ if ($action == 'create') {
}
print '</td></tr></table>';
print '</td>';
print '<td>';
print '<td class="valuefield">';
if ($action != 'editincoterm') {
print $form->textwithpicto($object->display_incoterms(), $object->label_incoterms, 1);
} else {

View File

@ -2067,7 +2067,7 @@ if ($action == 'create' && $usercancreate) {
// Outstanding Bill
print '<tr><td class="titlefield">';
print $langs->trans('OutstandingBill');
print '</td><td>';
print '</td><td class="valuefield">';
$arrayoutstandingbills = $soc->getOutstandingBills();
print price($arrayoutstandingbills['opened']).' / ';
print price($soc->outstanding_limit, 0, '', 1, - 1, - 1, $conf->currency);
@ -2088,7 +2088,7 @@ if ($action == 'create' && $usercancreate) {
$addabsolutediscount = '<a href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$soc->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"]).'?facid='.$object->id.'">'.$langs->trans("EditGlobalDiscounts").'</a>';
$addcreditnote = '<a href="'.DOL_URL_ROOT.'/compta/facture/card.php?action=create&socid='.$soc->id.'&type=2&backtopage='.urlencode($_SERVER["PHP_SELF"]).'?facid='.$object->id.'">'.$langs->trans("AddCreditNote").'</a>';
print '<tr><td class="titlefield">'.$langs->trans('Discounts').'</td><td>';
print '<tr><td class="titlefield">'.$langs->trans('Discounts').'</td><td class="valuefield">';
$absolute_discount = $soc->getAvailableDiscounts('', $filterabsolutediscount);
$absolute_creditnote = $soc->getAvailableDiscounts('', $filtercreditnote);
@ -2106,7 +2106,7 @@ if ($action == 'create' && $usercancreate) {
print '<tr><td>';
$editenable = $usercancreate && $object->statut == Commande::STATUS_DRAFT;
print $form->editfieldkey("Date", 'date', '', $object, $editenable);
print '</td><td>';
print '</td><td class="valuefield">';
if ($action == 'editdate') {
print '<form name="setdate" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post">';
print '<input type="hidden" name="token" value="'.newToken().'">';
@ -2127,7 +2127,7 @@ if ($action == 'create' && $usercancreate) {
print '<tr><td>';
$editenable = $usercancreate;
print $form->editfieldkey("DateDeliveryPlanned", 'date_livraison', '', $object, $editenable);
print '</td><td>';
print '</td><td class="valuefield">';
if ($action == 'editdate_livraison') {
print '<form name="setdate_livraison" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post">';
print '<input type="hidden" name="token" value="'.newToken().'">';
@ -2149,7 +2149,7 @@ if ($action == 'create' && $usercancreate) {
print '<tr><td>';
$editenable = $usercancreate;
print $form->editfieldkey("SendingMethod", 'shippingmethod', '', $object, $editenable);
print '</td><td>';
print '</td><td class="valuefield">';
if ($action == 'editshippingmethod') {
$form->formSelectShippingMethod($_SERVER['PHP_SELF'].'?id='.$object->id, $object->shipping_method_id, 'shipping_method_id', 1);
} else {
@ -2167,7 +2167,7 @@ if ($action == 'create' && $usercancreate) {
print '<tr><td>';
$editenable = $usercancreate;
print $form->editfieldkey("Warehouse", 'warehouse', '', $object, $editenable);
print '</td><td>';
print '</td><td class="valuefield">';
if ($action == 'editwarehouse') {
$formproduct->formSelectWarehouses($_SERVER['PHP_SELF'].'?id='.$object->id, $object->warehouse_id, 'warehouse_id', 1);
} else {
@ -2181,7 +2181,7 @@ if ($action == 'create' && $usercancreate) {
print '<tr><td>';
$editenable = $usercancreate;
print $form->editfieldkey("PaymentConditionsShort", 'conditions', '', $object, $editenable);
print '</td><td>';
print '</td><td class="valuefield">';
if ($action == 'editconditions') {
$form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->cond_reglement_id, 'cond_reglement_id', 1);
} else {
@ -2195,7 +2195,7 @@ if ($action == 'create' && $usercancreate) {
print '<tr><td>';
$editenable = $usercancreate;
print $form->editfieldkey("PaymentMode", 'mode', '', $object, $editenable);
print '</td><td>';
print '</td><td class="valuefield">';
if ($action == 'editmode') {
$form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'mode_reglement_id', 'CRDT', 1, 1);
} else {
@ -2210,7 +2210,7 @@ if ($action == 'create' && $usercancreate) {
print '<td>';
$editenable = $usercancreate && $object->statut == Commande::STATUS_DRAFT;
print $form->editfieldkey("Currency", 'multicurrencycode', '', $object, $editenable);
print '</td><td>';
print '</td><td class="valuefield">';
if ($action == 'editmulticurrencycode') {
$form->form_multicurrency_code($_SERVER['PHP_SELF'].'?id='.$object->id, $object->multicurrency_code, 'multicurrency_code');
} else {
@ -2224,7 +2224,7 @@ if ($action == 'create' && $usercancreate) {
print '<td>';
$editenable = $usercancreate && $object->multicurrency_code && $object->multicurrency_code != $conf->currency && $object->statut == $object::STATUS_DRAFT;
print $form->editfieldkey("CurrencyRate", 'multicurrencyrate', '', $object, $editenable);
print '</td><td>';
print '</td><td class="valuefield">';
if ($action == 'editmulticurrencyrate' || $action == 'actualizemulticurrencyrate') {
if ($action == 'actualizemulticurrencyrate') {
list($object->fk_multicurrency, $object->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($object->db, $object->multicurrency_code);
@ -2246,7 +2246,7 @@ if ($action == 'create' && $usercancreate) {
print '<tr class="fielddeliverydelay"><td>';
$editenable = $usercancreate;
print $form->editfieldkey("AvailabilityPeriod", 'availability', '', $object, $editenable);
print '</td><td>';
print '</td><td class="valuefield">';
if ($action == 'editavailability') {
$form->form_availability($_SERVER['PHP_SELF'].'?id='.$object->id, $object->availability_id, 'availability_id', 1);
} else {
@ -2258,7 +2258,7 @@ if ($action == 'create' && $usercancreate) {
print '<tr><td>';
$editenable = $usercancreate;
print $form->editfieldkey("Channel", 'demandreason', '', $object, $editenable);
print '</td><td>';
print '</td><td class="valuefield">';
if ($action == 'editdemandreason') {
$form->formInputReason($_SERVER['PHP_SELF'].'?id='.$object->id, $object->demand_reason_id, 'demand_reason_id', 1);
} else {
@ -2285,13 +2285,13 @@ if ($action == 'create' && $usercancreate) {
$totalVolume = $tmparray['volume'];
if ($totalWeight) {
print '<tr><td>'.$langs->trans("CalculatedWeight").'</td>';
print '<td>';
print '<td class="valuefield">';
print showDimensionInBestUnit($totalWeight, 0, "weight", $langs, isset($conf->global->MAIN_WEIGHT_DEFAULT_ROUND) ? $conf->global->MAIN_WEIGHT_DEFAULT_ROUND : -1, isset($conf->global->MAIN_WEIGHT_DEFAULT_UNIT) ? $conf->global->MAIN_WEIGHT_DEFAULT_UNIT : 'no');
print '</td></tr>';
}
if ($totalVolume) {
print '<tr><td>'.$langs->trans("CalculatedVolume").'</td>';
print '<td>';
print '<td class="valuefield">';
print showDimensionInBestUnit($totalVolume, 0, "volume", $langs, isset($conf->global->MAIN_VOLUME_DEFAULT_ROUND) ? $conf->global->MAIN_VOLUME_DEFAULT_ROUND : -1, isset($conf->global->MAIN_VOLUME_DEFAULT_UNIT) ? $conf->global->MAIN_VOLUME_DEFAULT_UNIT : 'no');
print '</td></tr>';
}
@ -2304,7 +2304,7 @@ if ($action == 'create' && $usercancreate) {
$editenable = $usercancreate;
print $form->editfieldkey("IncotermLabel", 'incoterm', '', $object, $editenable);
print '</td>';
print '<td>';
print '<td class="valuefield">';
if ($action != 'editincoterm') {
print $form->textwithpicto($object->display_incoterms(), $object->label_incoterms, 1);
} else {
@ -2318,7 +2318,7 @@ if ($action == 'create' && $usercancreate) {
print '<tr><td>';
$editenable = $usercancreate;
print $form->editfieldkey("BankAccount", 'bankaccount', '', $object, $editenable);
print '</td><td>';
print '</td><td class="valuefield">';
if ($action == 'editbankaccount') {
$form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1);
} else {
@ -2343,17 +2343,17 @@ if ($action == 'create' && $usercancreate) {
if (!empty($conf->multicurrency->enabled) && ($object->multicurrency_code != $conf->currency)) {
// Multicurrency Amount HT
print '<tr><td class="titlefieldmiddle">'.$form->editfieldkey('MulticurrencyAmountHT', 'multicurrency_total_ht', '', $object, 0).'</td>';
print '<td class="nowrap">'.price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'</td>';
print '<td class="valuefield nowrap">'.price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'</td>';
print '</tr>';
// Multicurrency Amount VAT
print '<tr><td>'.$form->editfieldkey('MulticurrencyAmountVAT', 'multicurrency_total_tva', '', $object, 0).'</td>';
print '<td class="nowrap">'.price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'</td>';
print '<td class="valuefield nowrap">'.price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'</td>';
print '</tr>';
// Multicurrency Amount TTC
print '<tr><td>'.$form->editfieldkey('MulticurrencyAmountTTC', 'multicurrency_total_ttc', '', $object, 0).'</td>';
print '<td class="nowrap">'.price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'</td>';
print '<td class="valuefield nowrap">'.price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'</td>';
print '</tr>';
}
@ -2363,23 +2363,23 @@ if ($action == 'create' && $usercancreate) {
$alert = ' '.img_warning($langs->trans('OrderMinAmount').': '.price($object->thirdparty->order_min_amount));
}
print '<tr><td class="titlefieldmiddle">'.$langs->trans('AmountHT').'</td>';
print '<td>'.price($object->total_ht, 1, '', 1, - 1, - 1, $conf->currency).$alert.'</td>';
print '<td class="valuefield">'.price($object->total_ht, 1, '', 1, - 1, - 1, $conf->currency).$alert.'</td>';
// Total VAT
print '<tr><td>'.$langs->trans('AmountVAT').'</td><td>'.price($object->total_tva, 1, '', 1, - 1, - 1, $conf->currency).'</td></tr>';
print '<tr><td>'.$langs->trans('AmountVAT').'</td><td class="valuefield">'.price($object->total_tva, 1, '', 1, - 1, - 1, $conf->currency).'</td></tr>';
// Amount Local Taxes
if ($mysoc->localtax1_assuj == "1" || $object->total_localtax1 != 0) { // Localtax1
print '<tr><td>'.$langs->transcountry("AmountLT1", $mysoc->country_code).'</td>';
print '<td>'.price($object->total_localtax1, 1, '', 1, - 1, - 1, $conf->currency).'</td></tr>';
print '<td class="valuefield">'.price($object->total_localtax1, 1, '', 1, - 1, - 1, $conf->currency).'</td></tr>';
}
if ($mysoc->localtax2_assuj == "1" || $object->total_localtax2 != 0) { // Localtax2 IRPF
print '<tr><td>'.$langs->transcountry("AmountLT2", $mysoc->country_code).'</td>';
print '<td>'.price($object->total_localtax2, 1, '', 1, - 1, - 1, $conf->currency).'</td></tr>';
print '<td class="valuefield">'.price($object->total_localtax2, 1, '', 1, - 1, - 1, $conf->currency).'</td></tr>';
}
// Total TTC
print '<tr><td>'.$langs->trans('AmountTTC').'</td><td>'.price($object->total_ttc, 1, '', 1, - 1, - 1, $conf->currency).'</td></tr>';
print '<tr><td>'.$langs->trans('AmountTTC').'</td><td class="valuefield">'.price($object->total_ttc, 1, '', 1, - 1, - 1, $conf->currency).'</td></tr>';
// Statut
//print '<tr><td>' . $langs->trans('Status') . '</td><td>' . $object->getLibStatut(4) . '</td></tr>';

View File

@ -43,7 +43,10 @@ $result = restrictedArea($user, 'banque');
$companystatic = new Societe($db);
llxHeader();
$title = $langs->trans('ListTransactionsByCategory');
$help_url = 'EN:Module_Banks_and_Cash|FR:Module_Banques_et_Caisses|ES:M&oacute;dulo_Bancos_y_Cajas';
llxHeader('', $title, $help_url);
// List movements bu category for bank transactions
print load_fiche_titre($langs->trans("BankTransactionByCategories"), '', 'bank_account');

View File

@ -79,7 +79,10 @@ if ($categid) {
* View
*/
llxHeader();
$title = $langs->trans('RubriquesTransactions');
$help_url = 'EN:Module_Banks_and_Cash|FR:Module_Banques_et_Caisses|ES:M&oacute;dulo_Bancos_y_Cajas';
llxHeader('', $title, $help_url);
print load_fiche_titre($langs->trans("RubriquesTransactions"), '', 'object_category');

View File

@ -158,7 +158,10 @@ if ($action == 'add') {
* View
*/
llxHeader();
$help_url = 'EN:Module_Banks_and_Cash|FR:Module_Banques_et_Caisses|ES:M&oacute;dulo_Bancos_y_Cajas';
$title = $langs->trans('MenuBankInternalTransfer');
llxHeader('', $title, $help_url);
print ' <script type="text/javascript">
$(document).ready(function () {

View File

@ -372,7 +372,7 @@ if ($action == "create" || $action == "start" || $action == 'close') {
//var_dump($theoricalamountforterminal); var_dump($theoricalnbofinvoiceforterminal);
if ($action != 'close') {
llxHeader();
llxHeader('', $langs->trans("NewCashFence"));
print load_fiche_titre($langs->trans("CashControl")." - ".$langs->trans("New"), '', 'cash-register');

View File

@ -48,7 +48,7 @@ $accountstatic = new Account($db);
llxHeader('', $langs->trans("ChequesArea"));
print load_fiche_titre($langs->trans("ChequesArea"), '', 'bank_account');
print load_fiche_titre($langs->trans("ChequesArea"), '', $checkdepositstatic->picto);
print '<div class="fichecenter"><div class="fichethirdleft">';

View File

@ -59,7 +59,7 @@ llxHeader('', $langs->trans("SuppliersStandingOrdersArea"));
if (prelevement_check_config('bank-transfer') < 0) {
$langs->load("errors");
setEventMessages($langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Withdraw")), null, 'errors');
setEventMessages($langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("PaymentByBankTransfer")), null, 'errors');
}
print load_fiche_titre($langs->trans("SuppliersStandingOrdersArea"));

View File

@ -165,7 +165,8 @@ if ($resql) {
$i++;
}
} else {
print '<tr class="oddeven"><td colspan="5" class="opacitymedium">'.$langs->trans("NoInvoiceToWithdraw", $langs->transnoentitiesnoconv("StandingOrders")).'</td></tr>';
$titlefortab = $langs->transnoentitiesnoconv("StandingOrders");
print '<tr class="oddeven"><td colspan="5" class="opacitymedium">'.$langs->trans("NoInvoiceToWithdraw", $titlefortab, $titlefortab).'</td></tr>';
}
print "</table></div><br>";
} else {

View File

@ -601,7 +601,6 @@ if ($refresh === true) {
/*
* Paid
*/
print load_fiche_titre($langs->trans("VATPaid"), '', '');
$sql = '';

View File

@ -131,19 +131,19 @@ $companystatic = new Societe($db);
$arrayfields = array(
'c.ref'=>array('label'=>$langs->trans("Contract"), 'checked'=>1, 'position'=>80),
'p.description'=>array('label'=>$langs->trans("Service"), 'checked'=>1, 'position'=>80),
'cd.qty'=>array('label'=>$langs->trans("Qty"), 'checked'=>0, 'position'=>100),
'cd.total_ht'=>array('label'=>$langs->trans("TotalHT"), 'checked'=>0, 'position'=>100),
'cd.total_tva'=>array('label'=>$langs->trans("TotalVAT"), 'checked'=>0, 'position'=>100),
's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1, 'position'=>90),
'cd.tva_tx'=>array('label'=>$langs->trans("VAT"), 'checked'=>0, 'position'=>100),
'cd.subprice'=>array('label'=>$langs->trans("PriceUHT"), 'checked'=>0, 'position'=>100),
's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1, 'position'=>100),
'cd.date_ouverture_prevue'=>array('label'=>$langs->trans("DateStartPlannedShort"), 'checked'=>(($mode == "" || $mode == -1) || $mode == "0")),
'cd.date_ouverture'=>array('label'=>$langs->trans("DateStartRealShort"), 'checked'=>(($mode == "" || $mode == -1) || $mode > 0)),
'cd.date_fin_validite'=>array('label'=>$langs->trans("DateEndPlannedShort"), 'checked'=>(($mode == "" || $mode == -1) || $mode < 5)),
'cd.date_cloture'=>array('label'=>$langs->trans("DateEndRealShort"), 'checked'=>(($mode == "" || $mode == -1) || $mode >= 5)),
'status'=>array('label'=>$langs->trans("Status"), 'checked'=>1),
'cd.subprice'=>array('label'=>$langs->trans("PriceUHT"), 'checked'=>0, 'position'=>105),
'cd.qty'=>array('label'=>$langs->trans("Qty"), 'checked'=>0, 'position'=>108),
'cd.total_ht'=>array('label'=>$langs->trans("TotalHT"), 'checked'=>0, 'position'=>109),
'cd.total_tva'=>array('label'=>$langs->trans("TotalVAT"), 'checked'=>0, 'position'=>110),
'cd.date_ouverture_prevue'=>array('label'=>$langs->trans("DateStartPlannedShort"), 'checked'=>(($mode == "" || $mode == -1) || $mode == "0"), 'position'=>150),
'cd.date_ouverture'=>array('label'=>$langs->trans("DateStartRealShort"), 'checked'=>(($mode == "" || $mode == -1) || $mode > 0), 'position'=>160),
'cd.date_fin_validite'=>array('label'=>$langs->trans("DateEndPlannedShort"), 'checked'=>(($mode == "" || $mode == -1) || $mode < 5), 'position'=>170),
'cd.date_cloture'=>array('label'=>$langs->trans("DateEndRealShort"), 'checked'=>(($mode == "" || $mode == -1) || $mode >= 5), 'position'=>180),
//'cd.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500),
'cd.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500)
'cd.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500),
'status'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000)
);
// Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';

View File

@ -128,7 +128,7 @@ class box_graph_invoices_permonth extends ModeleBoxes
if (empty($endyear)) {
$endyear = $nowarray['year'];
}
$startyear = $endyear - (empty($conf->global->MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH) ? 1 : $conf->global->MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH);
$startyear = $endyear - (empty($conf->global->MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH) ? 2 : ($conf->global->MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH - 1));
$mode = 'customer';
$WIDTH = (($shownb && $showtot) || !empty($conf->dol_optimize_smallscreen)) ? '256' : '320';

View File

@ -128,7 +128,7 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes
if (empty($endyear)) {
$endyear = $nowarray['year'];
}
$startyear = $endyear - (empty($conf->global->MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH) ? 1 : $conf->global->MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH);
$startyear = $endyear - (empty($conf->global->MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH) ? 2 : ($conf->global->MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH - 1));
$mode = 'supplier';
$WIDTH = (($shownb && $showtot) || !empty($conf->dol_optimize_smallscreen)) ? '256' : '320';

View File

@ -128,7 +128,7 @@ class box_graph_orders_permonth extends ModeleBoxes
if (empty($endyear)) {
$endyear = $nowarray['year'];
}
$startyear = $endyear - (empty($conf->global->MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH) ? 1 : $conf->global->MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH);
$startyear = $endyear - (empty($conf->global->MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH) ? 2 : ($conf->global->MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH - 1));
$mode = 'customer';
$WIDTH = (($shownb && $showtot) || !empty($conf->dol_optimize_smallscreen)) ? '256' : '320';

View File

@ -127,7 +127,7 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes
if (empty($endyear)) {
$endyear = $nowarray['year'];
}
$startyear = $endyear - (empty($conf->global->MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH) ? 1 : $conf->global->MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH);
$startyear = $endyear - (empty($conf->global->MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH) ? 2 : ($conf->global->MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH - 1));
$mode = 'supplier';
$WIDTH = (($shownb && $showtot) || !empty($conf->dol_optimize_smallscreen)) ? '256' : '320';

View File

@ -128,7 +128,7 @@ class box_graph_propales_permonth extends ModeleBoxes
if (empty($endyear)) {
$endyear = $nowarray['year'];
}
$startyear = $endyear - (empty($conf->global->MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH) ? 1 : $conf->global->MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH);
$startyear = $endyear - (empty($conf->global->MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH) ? 2 : ($conf->global->MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH - 1));
$WIDTH = (($shownb && $showtot) || !empty($conf->dol_optimize_smallscreen)) ? '256' : '320';
$HEIGHT = '192';

View File

@ -7395,10 +7395,10 @@ abstract class CommonObject
$helptoshow = $langs->trans($extrafields->attributes[$this->table_element]['help'][$key]);
if ($display_type == 'card') {
$out .= '<tr '.($html_id ? 'id="'.$html_id.'" ' : '').$csstyle.' class="'.$class.$this->element.'_extras_'.$key.' trextrafields_collapse'.$extrafields_collapse_num.(!empty($this->id)?'_'.$this->id:'').'" '.$domData.' >';
$out .= '<tr '.($html_id ? 'id="'.$html_id.'" ' : '').$csstyle.' class="valuefieldcreate '.$class.$this->element.'_extras_'.$key.' trextrafields_collapse'.$extrafields_collapse_num.(!empty($this->id)?'_'.$this->id:'').'" '.$domData.' >';
$out .= '<td class="wordbreak';
} elseif ($display_type == 'line') {
$out .= '<div '.($html_id ? 'id="'.$html_id.'" ' : '').$csstyle.' class="'.$class.$this->element.'_extras_'.$key.' trextrafields_collapse'.$extrafields_collapse_num.(!empty($this->id)?'_'.$this->id:'').'" '.$domData.' >';
$out .= '<div '.($html_id ? 'id="'.$html_id.'" ' : '').$csstyle.' class="valuefieldlinecreate '.$class.$this->element.'_extras_'.$key.' trextrafields_collapse'.$extrafields_collapse_num.(!empty($this->id)?'_'.$this->id:'').'" '.$domData.' >';
$out .= '<div style="display: inline-block; padding-right:4px" class="wordbreak';
}
//$out .= "titlefield";

View File

@ -1040,10 +1040,10 @@ class Form
}
$out .= '</select>';
$out .= '<input id="location_incoterms" class="maxwidth100onsmartphone" name="location_incoterms" value="'.$location_incoterms.'">';
$out .= '<input id="location_incoterms" class="maxwidth100onsmartphone nomargintop nomarginbottom" name="location_incoterms" value="'.$location_incoterms.'">';
if (!empty($page)) {
$out .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'"></form>';
$out .= '<input type="submit" class="button valignmiddle smallpaddingimp nomargintop nomarginbottom" value="'.$langs->trans("Modify").'"></form>';
}
} else {
dol_print_error($this->db);

View File

@ -547,6 +547,7 @@ function hideMessage(fieldId,message) {
* @param string token Token
*/
function setConstant(url, code, input, entity, strict, forcereload, userid, token) {
var saved_url = url; /* avoid undefined url */
$.post( url, {
action: "set",
name: code,
@ -591,7 +592,7 @@ function setConstant(url, code, input, entity, strict, forcereload, userid, toke
$.each(data, function(key, value) {
$("#set_" + key).hide();
$("#del_" + key).show();
$.post( url, {
$.post( saved_url, {
action: "set",
name: key,
value: value,
@ -621,6 +622,7 @@ function setConstant(url, code, input, entity, strict, forcereload, userid, toke
* @param string token Token
*/
function delConstant(url, code, input, entity, strict, forcereload, userid, token) {
var saved_url = url; /* avoid undefined url */
$.post( url, {
action: "del",
name: code,
@ -662,7 +664,7 @@ function delConstant(url, code, input, entity, strict, forcereload, userid, toke
$.each(data, function(key, value) {
$("#del_" + value).hide();
$("#set_" + value).show();
$.post( url, {
$.post( saved_url, {
action: "del",
name: value,
entity: entity,

View File

@ -457,22 +457,24 @@ function run_sql($sqlfile, $silent = 1, $entity = '', $usesavepoint = 1, $handle
} else {
print '<span class="error">'.$langs->trans("Error").'</span>';
}
//if (! empty($conf->use_javascript_ajax)) {
print '<script type="text/javascript" language="javascript">
jQuery(document).ready(function() {
function init_trrunsql()
{
console.log("toggle .trforrunsql");
jQuery(".trforrunsql").toggle();
}
//if (!empty($conf->use_javascript_ajax)) { // use_javascript_ajax is not defined
print '<script type="text/javascript" language="javascript">
jQuery(document).ready(function() {
function init_trrunsql()
{
console.log("toggle .trforrunsql");
jQuery(".trforrunsql").toggle();
}
init_trrunsql();
jQuery(".trforrunsqlshowhide").click(function() {
init_trrunsql();
jQuery(".trforrunsqlshowhide").click(function() {
init_trrunsql();
});
});
</script>';
print ' - <a class="trforrunsqlshowhide" href="#">'.$langs->trans("ShowHideDetails").'</a>';
});
</script>';
print ' - <a class="trforrunsqlshowhide" href="#">'.$langs->trans("ShowHideDetails").'</a>';
//}
print '</td></tr>'."\n";
}

View File

@ -252,7 +252,7 @@ function convertSecondToTime($iSecond, $format = 'all', $lengthOfDay = 86400, $l
if ($sDay > 1) {
$dayTranslate = $langs->trans("Days");
}
$sTime .= $sDay.' '.$dayTranslate.' ';
$sTime .= $sDay.' '.strtolower(dol_substr($dayTranslate, 0, 1)).'. ';
}
if ($format == 'all') {

View File

@ -3415,12 +3415,12 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $
if (empty($srconly) && in_array($pictowithouttext, array(
'1downarrow', '1uparrow', '1leftarrow', '1rightarrow', '1uparrow_selected', '1downarrow_selected', '1leftarrow_selected', '1rightarrow_selected',
'accountancy', 'account', 'accountline', 'action', 'add', 'address', 'angle-double-down', 'angle-double-up', 'bank_account', 'barcode', 'bank', 'bill', 'billa', 'billr', 'billd', 'bookmark', 'bom', 'building',
'cash-register', 'category', 'check', 'clock', 'close_title', 'cog', 'company', 'contact', 'contract', 'cron', 'cubes',
'cash-register', 'category', 'chart', 'check', 'clock', 'close_title', 'cog', 'company', 'contact', 'contract', 'cron', 'cubes',
'delete', 'dolly', 'dollyrevert', 'donation', 'download', 'edit', 'ellipsis-h', 'email', 'eraser', 'external-link-alt', 'external-link-square-alt',
'filter', 'file-code', 'file-export', 'file-import', 'file-upload', 'folder', 'folder-open', 'globe', 'globe-americas', 'grip', 'grip_title', 'group',
'help', 'holiday',
'intervention', 'label', 'language', 'link', 'list', 'listlight', 'loan', 'lot',
'margin', 'map-marker-alt', 'member', 'meeting', 'money-bill-alt', 'mrp', 'note', 'next',
'intervention', 'label', 'language', 'link', 'list', 'listlight', 'loan', 'lot', 'long-arrow-alt-right',
'margin', 'map-marker-alt', 'member', 'meeting', 'money-bill-alt', 'movement', 'mrp', 'note', 'next',
'object_accounting', 'object_account', 'object_accountline', 'object_action', 'object_barcode', 'object_bill', 'object_billa', 'object_billd', 'object_bom',
'object_category', 'object_conversation', 'object_bookmark', 'object_bug', 'object_clock', 'object_dolly', 'object_dollyrevert',
'object_folder', 'object_folder-open','object_generic',
@ -3436,16 +3436,17 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $
'object_technic', 'object_ticket', 'object_trip', 'object_user', 'object_group', 'object_member',
'object_phoning', 'object_phoning_mobile', 'object_phoning_fax', 'object_email', 'object_website', 'object_movement',
'off', 'on', 'order',
'paiment', 'play', 'pdf', 'playdisabled', 'previous', 'poll', 'printer', 'product', 'propal', 'projecttask', 'stock', 'resize', 'service', 'stats', 'trip',
'setup', 'share-alt', 'sign-out', 'split', 'stripe-s', 'switch_off', 'switch_on', 'tools', 'unlink', 'uparrow', 'user', 'vcard', 'wrench',
'jabber', 'skype', 'twitter', 'facebook', 'linkedin', 'instagram', 'snapchat', 'youtube', 'google-plus-g', 'whatsapp',
'paiment', 'play', 'pdf', 'playdisabled', 'previous', 'poll', 'pos', 'printer', 'product', 'propal', 'projecttask', 'stock', 'resize', 'service', 'stats', 'trip',
'setup', 'share-alt', 'sign-out', 'split', 'stripe', 'stripe-s', 'switch_off', 'switch_on', 'tools', 'unlink', 'uparrow', 'user', 'vcard', 'wrench',
'github', 'jabber', 'skype', 'twitter', 'facebook', 'linkedin', 'instagram', 'snapchat', 'youtube', 'google-plus-g', 'whatsapp',
'chevron-left', 'chevron-right', 'chevron-down', 'chevron-top', 'commercial', 'companies',
'generic', 'home', 'hrm', 'members', 'products', 'invoicing',
'payment', 'pencil-ruler', 'preview', 'project', 'projectpub', 'refresh', 'salary', 'shipment', 'supplier_invoice', 'technic', 'ticket',
'error', 'warning',
'recruitmentcandidature', 'recruitmentjobposition', 'resource',
'shapes', 'supplier_proposal', 'supplier_order', 'supplier_invoice', 'user-cog',
'title_setup', 'title_accountancy', 'title_bank', 'title_hrm', 'title_agenda',
'shapes', 'supplier_proposal', 'supplier_order', 'supplier_invoice',
'timespent', 'title_setup', 'title_accountancy', 'title_bank', 'title_hrm', 'title_agenda',
'user-cog',
'eventorganization', 'object_eventorganization'
))) {
$pictowithouttext = str_replace('object_', '', $pictowithouttext);
@ -3453,18 +3454,18 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $
$fakey = $pictowithouttext;
$facolor = ''; $fasize = '';
$fa = 'fas';
if (in_array($pictowithouttext, array('clock', 'generic', 'minus-square', 'object_generic', 'pdf', 'plus-square', 'note', 'off', 'on', 'object_bookmark', 'bookmark', 'vcard'))) {
if (in_array($pictowithouttext, array('clock', 'generic', 'minus-square', 'object_generic', 'pdf', 'plus-square', 'timespent', 'note', 'off', 'on', 'object_bookmark', 'bookmark', 'vcard'))) {
$fa = 'far';
}
if (in_array($pictowithouttext, array('black-tie', 'skype', 'twitter', 'facebook', 'linkedin', 'instagram', 'snapchat', 'stripe-s', 'youtube', 'google-plus-g', 'whatsapp'))) {
if (in_array($pictowithouttext, array('black-tie', 'github', 'skype', 'twitter', 'facebook', 'linkedin', 'instagram', 'snapchat', 'stripe', 'stripe-s', 'youtube', 'google-plus-g', 'whatsapp'))) {
$fa = 'fab';
}
$arrayconvpictotofa = array(
'account'=>'university', 'accountline'=>'receipt', 'accountancy'=>'money-check-alt', 'action'=>'calendar-alt', 'add'=>'plus-circle', 'address'=> 'address-book',
'account'=>'university', 'accountline'=>'receipt', 'accountancy'=>'search-dollar', 'action'=>'calendar-alt', 'add'=>'plus-circle', 'address'=> 'address-book',
'bank_account'=>'university', 'bill'=>'file-invoice-dollar', 'billa'=>'file-excel', 'supplier_invoicea'=>'file-excel', 'billd'=>'file-medical', 'supplier_invoiced'=>'file-medical',
'bom'=>'shapes',
'company'=>'building', 'contact'=>'address-book', 'contract'=>'suitcase', 'conversation'=>'comments', 'donation'=>'file-alt', 'dynamicprice'=>'hand-holding-usd',
'chart'=>'chart-line', 'company'=>'building', 'contact'=>'address-book', 'contract'=>'suitcase', 'conversation'=>'comments', 'donation'=>'file-alt', 'dynamicprice'=>'hand-holding-usd',
'setup'=>'cog', 'companies'=>'building', 'products'=>'cube', 'commercial'=>'suitcase', 'invoicing'=>'coins',
'accounting'=>'chart-line', 'category'=>'tag', 'dollyrevert'=>'dolly',
'hrm'=>'user-tie', 'margin'=>'calculator', 'members'=>'user-friends', 'ticket'=>'ticket-alt', 'globe'=>'external-link-alt', 'lot'=>'barcode',
@ -3480,13 +3481,13 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $
'intervention'=>'ambulance', 'invoice'=>'file-invoice-dollar', 'multicurrency'=>'dollar-sign', 'order'=>'file-invoice',
'error'=>'exclamation-triangle', 'warning'=>'exclamation-triangle',
'other'=>'square',
'playdisabled'=>'play', 'pdf'=>'file-pdf', 'poll'=>'check-double', 'preview'=>'binoculars', 'project'=>'sitemap', 'projectpub'=>'sitemap', 'projecttask'=>'tasks', 'propal'=>'file-signature',
'playdisabled'=>'play', 'pdf'=>'file-pdf', 'poll'=>'check-double', 'pos'=>'cash-register', 'preview'=>'binoculars', 'project'=>'sitemap', 'projectpub'=>'sitemap', 'projecttask'=>'tasks', 'propal'=>'file-signature',
'payment'=>'money-check-alt', 'phoning'=>'phone', 'phoning_mobile'=>'mobile-alt', 'phoning_fax'=>'fax', 'previous'=>'arrow-alt-circle-left', 'printer'=>'print', 'product'=>'cube', 'service'=>'concierge-bell',
'recruitmentjobposition'=>'id-card-alt', 'recruitmentcandidature'=>'id-badge',
'resize'=>'crop', 'supplier_order'=>'dol-order_supplier', 'supplier_proposal'=>'file-signature',
'refresh'=>'redo', 'resource'=>'laptop-house',
'salary'=>'wallet', 'shipment'=>'dolly', 'stock'=>'box-open', 'stats' => 'chart-bar', 'split'=>'code-branch', 'supplier_invoice'=>'file-invoice-dollar', 'technic'=>'cogs', 'ticket'=>'ticket-alt',
'title_setup'=>'tools', 'title_accountancy'=>'money-check-alt', 'title_bank'=>'university', 'title_hrm'=>'umbrella-beach',
'salary'=>'wallet', 'shipment'=>'dolly', 'stock'=>'box-open', 'stats' => 'chart-bar', 'split'=>'code-branch', 'stripe'=>'stripe-s', 'supplier_invoice'=>'file-invoice-dollar', 'technic'=>'cogs', 'ticket'=>'ticket-alt',
'timespent'=>'clock', 'title_setup'=>'tools', 'title_accountancy'=>'money-check-alt', 'title_bank'=>'university', 'title_hrm'=>'umbrella-beach',
'title_agenda'=>'calendar-alt',
'uparrow'=>'mail-forward', 'vcard'=>'address-card',
'jabber'=>'comment-o',
@ -3524,7 +3525,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $
if (in_array($pictowithouttext, array('holiday', 'dollyrevert', 'member', 'members', 'contract', 'group', 'resource', 'shipment'))) {
$morecss = 'em092';
}
if (in_array($pictowithouttext, array('holiday'))) {
if (in_array($pictowithouttext, array('holiday', 'project'))) {
$morecss = 'em088';
}
if (in_array($pictowithouttext, array('intervention', 'payment', 'loan', 'stock', 'technic'))) {
@ -3555,7 +3556,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $
'user'=>'infobox-adherent', 'users'=>'infobox-adherent',
'error'=>'pictoerror', 'warning'=>'pictowarning', 'switch_on'=>'font-status4',
'holiday'=>'infobox-holiday', 'invoice'=>'infobox-commande', 'loan'=>'infobox-bank_account',
'payment'=>'infobox-bank_account', 'poll'=>'infobox-adherent', 'project'=>'infobox-project', 'projecttask'=>'infobox-project', 'propal'=>'infobox-propal',
'payment'=>'infobox-bank_account', 'poll'=>'infobox-adherent', 'pos'=>'infobox-bank_account', 'project'=>'infobox-project', 'projecttask'=>'infobox-project', 'propal'=>'infobox-propal',
'recruitmentjobposition'=>'infobox-adherent', 'recruitmentcandidature'=>'infobox-adherent',
'resource'=>'infobox-action',
'salary'=>'infobox-bank_account', 'supplier_invoice'=>'infobox-order_supplier', 'supplier_invoicea'=>'infobox-order_supplier', 'supplier_invoiced'=>'infobox-order_supplier',
@ -3572,12 +3573,12 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $
$arrayconvpictotocolor = array(
'address'=>'#6c6aa8', 'building'=>'#6c6aa8', 'bom'=>'#a69944',
'cog'=>'#999', 'companies'=>'#6c6aa8', 'company'=>'#6c6aa8', 'contact'=>'#6c6aa8', 'dynamicprice'=>'#a69944',
'edit'=>'#444', 'note'=>'#999', 'error'=>'', 'help'=>'#bbb', 'listlight'=>'#999',
'edit'=>'#444', 'note'=>'#999', 'error'=>'', 'help'=>'#bbb', 'listlight'=>'#999', 'language'=>'#555',
'dolly'=>'#a69944', 'dollyrevert'=>'#a69944', 'lot'=>'#a69944',
'map-marker-alt'=>'#aaa', 'mrp'=>'#a69944', 'product'=>'#a69944', 'service'=>'#a69944', 'stock'=>'#a69944', 'movement'=>'#a69944',
'other'=>'#ddd',
'playdisabled'=>'#ccc', 'printer'=>'#444', 'projectpub'=>'#986c6a', 'resize'=>'#444', 'rss'=>'#cba',
'shipment'=>'#a69944', 'stats'=>'#444', 'switch_off'=>'#999', 'technic'=>'#999', 'uparrow'=>'#555', 'user-cog'=>'#999', 'globe-americas'=>'#aaa',
'shipment'=>'#a69944', 'stats'=>'#444', 'switch_off'=>'#999', 'technic'=>'#999', 'timespent'=>'#555', 'uparrow'=>'#555', 'user-cog'=>'#999', 'globe-americas'=>'#aaa',
'website'=>'#304'
);
if (isset($arrayconvpictotocolor[$pictowithouttext])) {

View File

@ -2413,18 +2413,18 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks
print_liste_field_titre("ThirdParty", $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder);
if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
if (!in_array('prospectionstatus', $hiddenfields)) {
print_liste_field_titre("OpportunityStatus", "", "", "", "", '', $sortfield, $sortorder, 'right ');
print_liste_field_titre("OpportunityStatus", "", "", "", "", 'style="max-width: 100px"', $sortfield, $sortorder, 'right ');
}
print_liste_field_titre("OpportunityAmount", "", "", "", "", 'align="right"', $sortfield, $sortorder);
print_liste_field_titre("OpportunityAmount", "", "", "", "", 'style="max-width: 100px"', $sortfield, $sortorder, 'right ');
//print_liste_field_titre('OpportunityWeightedAmount', '', '', '', '', 'align="right"', $sortfield, $sortorder);
}
if (empty($conf->global->PROJECT_HIDE_TASKS)) {
print_liste_field_titre("Tasks", "", "", "", "", 'align="right"', $sortfield, $sortorder);
if (!in_array('plannedworkload', $hiddenfields)) {
print_liste_field_titre("PlannedWorkload", "", "", "", "", '', $sortfield, $sortorder, 'right ');
print_liste_field_titre("PlannedWorkload", "", "", "", "", 'style="max-width: 100px"', $sortfield, $sortorder, 'right ');
}
if (!in_array('declaredprogress', $hiddenfields)) {
print_liste_field_titre("ProgressDeclared", "", "", "", "", '', $sortfield, $sortorder, 'right ');
print_liste_field_titre("%", "", "", "", "", '', $sortfield, $sortorder, 'right ', $langs->trans("ProgressDeclared"));
}
}
if (!in_array('projectstatus', $hiddenfields)) {

View File

@ -1185,7 +1185,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM
//$newmenu->add("/accountancy/index.php?leftmenu=accountancy", $langs->trans("MenuAccountancy"), 0, $permtoshowmenu, '', $mainmenu, 'accountancy');
// Configuration
$newmenu->add("/accountancy/index.php?leftmenu=accountancy_admin", $langs->trans("Setup"), 0, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin', 1);
$newmenu->add("/accountancy/index.php?leftmenu=accountancy_admin", $langs->trans("Setup"), 0, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin', 1, '', '', '', img_picto('', 'setup', 'class="paddingright pictofixedwidth"'));
if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_admin/', $leftmenu)) {
$newmenu->add("/accountancy/admin/index.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("General"), 1, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_general', 10);
@ -1220,7 +1220,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM
}
// Transfer in accounting
$newmenu->add("/accountancy/index.php?leftmenu=accountancy_transfer", $langs->trans("TransferInAccounting"), 0, $user->rights->accounting->bind->write, '', $mainmenu, 'transfer', 1);
$newmenu->add("/accountancy/index.php?leftmenu=accountancy_transfer", $langs->trans("TransferInAccounting"), 0, $user->rights->accounting->bind->write, '', $mainmenu, 'transfer', 1, '', '', '', img_picto('', 'long-arrow-alt-right', 'class="paddingright pictofixedwidth"'));
// Binding
// $newmenu->add("", $langs->trans("Binding"), 0, $user->rights->accounting->bind->write, '', $mainmenu, 'dispatch');
@ -1318,7 +1318,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM
}
// Accounting
$newmenu->add("/accountancy/index.php?leftmenu=accountancy_accountancy", $langs->trans("MenuAccountancy"), 0, $user->rights->accounting->mouvements->lire, '', $mainmenu, 'accountancy', 1);
$newmenu->add("/accountancy/index.php?leftmenu=accountancy_accountancy", $langs->trans("MenuAccountancy"), 0, $user->rights->accounting->mouvements->lire, '', $mainmenu, 'accountancy', 1, '', '', '', img_picto('', 'accountancy', 'class="paddingright pictofixedwidth"'));
// Balance
$newmenu->add("/accountancy/bookkeeping/balance.php?mainmenu=accountancy&amp;leftmenu=accountancy_accountancy", $langs->trans("AccountBalance"), 1, $user->rights->accounting->mouvements->lire);
@ -1447,7 +1447,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM
// Assets
if (!empty($conf->asset->enabled)) {
$newmenu->add("/asset/list.php?leftmenu=asset&amp;mainmenu=accountancy", $langs->trans("MenuAssets"), 0, $user->rights->asset->read, '', $mainmenu, 'asset');
$newmenu->add("/asset/list.php?leftmenu=asset&amp;mainmenu=accountancy", $langs->trans("MenuAssets"), 0, $user->rights->asset->read, '', $mainmenu, 'asset', 100, '', '', '', img_picto('', 'payment', 'class="paddingright pictofixedwidth"'));
$newmenu->add("/asset/card.php?leftmenu=asset&amp;action=create", $langs->trans("MenuNewAsset"), 1, $user->rights->asset->write);
$newmenu->add("/asset/list.php?leftmenu=asset&amp;mainmenu=accountancy", $langs->trans("MenuListAssets"), 1, $user->rights->asset->read);
$newmenu->add("/asset/type.php?leftmenu=asset_type", $langs->trans("MenuTypeAssets"), 1, $user->rights->asset->read, '', $mainmenu, 'asset_type');
@ -1468,7 +1468,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM
// Bank-Cash account
if (!empty($conf->banque->enabled)) {
$newmenu->add("/compta/bank/list.php?leftmenu=bank&amp;mainmenu=bank", $langs->trans("MenuBankCash"), 0, $user->rights->banque->lire, '', $mainmenu, 'bank');
$newmenu->add("/compta/bank/list.php?leftmenu=bank&amp;mainmenu=bank", $langs->trans("MenuBankCash"), 0, $user->rights->banque->lire, '', $mainmenu, 'bank', 0, '', '', '', img_picto('', 'bank_account', 'class="paddingright pictofixedwidth"'));
$newmenu->add("/compta/bank/card.php?action=create", $langs->trans("MenuNewFinancialAccount"), 1, $user->rights->banque->configurer);
$newmenu->add("/compta/bank/list.php?leftmenu=bank&amp;mainmenu=bank", $langs->trans("List"), 1, $user->rights->banque->lire, '', $mainmenu, 'bank');
@ -1486,7 +1486,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM
// Direct debit order
if (!empty($conf->prelevement->enabled)) {
$newmenu->add("/compta/prelevement/index.php?leftmenu=withdraw&amp;mainmenu=bank", $langs->trans("PaymentByDirectDebit"), 0, $user->rights->prelevement->bons->lire, '', $mainmenu, 'withdraw');
$newmenu->add("/compta/prelevement/index.php?leftmenu=withdraw&amp;mainmenu=bank", $langs->trans("PaymentByDirectDebit"), 0, $user->rights->prelevement->bons->lire, '', $mainmenu, 'withdraw', 0, '', '', '', img_picto('', 'payment', 'class="paddingright pictofixedwidth"'));
if ($usemenuhider || empty($leftmenu) || $leftmenu == "withdraw") {
$newmenu->add("/compta/prelevement/create.php?mainmenu=bank", $langs->trans("NewStandingOrder"), 1, $user->rights->prelevement->bons->creer);
@ -1500,7 +1500,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM
// Bank transfer order
if (!empty($conf->paymentbybanktransfer->enabled)) {
$newmenu->add("/compta/paymentbybanktransfer/index.php?leftmenu=banktransfer&amp;mainmenu=bank", $langs->trans("PaymentByBankTransfer"), 0, $user->rights->paymentbybanktransfer->read, '', $mainmenu, 'banktransfer');
$newmenu->add("/compta/paymentbybanktransfer/index.php?leftmenu=banktransfer&amp;mainmenu=bank", $langs->trans("PaymentByBankTransfer"), 0, $user->rights->paymentbybanktransfer->read, '', $mainmenu, 'banktransfer', 0, '', '', '', img_picto('', 'payment', 'class="paddingright pictofixedwidth"'));
if ($usemenuhider || empty($leftmenu) || $leftmenu == "banktransfer") {
$newmenu->add("/compta/prelevement/create.php?type=bank-transfer&mainmenu=bank", $langs->trans("NewPaymentByBankTransfer"), 1, $user->rights->paymentbybanktransfer->create);
@ -1514,7 +1514,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM
// Management of checks
if (empty($conf->global->BANK_DISABLE_CHECK_DEPOSIT) && !empty($conf->banque->enabled) && (!empty($conf->facture->enabled) || !empty($conf->global->MAIN_MENU_CHEQUE_DEPOSIT_ON))) {
$newmenu->add("/compta/paiement/cheque/index.php?leftmenu=checks&amp;mainmenu=bank", $langs->trans("MenuChequeDeposits"), 0, $user->rights->banque->cheque, '', $mainmenu, 'checks');
$newmenu->add("/compta/paiement/cheque/index.php?leftmenu=checks&amp;mainmenu=bank", $langs->trans("MenuChequeDeposits"), 0, $user->rights->banque->cheque, '', $mainmenu, 'checks', 0, '', '', '', img_picto('', 'payment', 'class="paddingright pictofixedwidth"'));
if (preg_match('/checks/', $leftmenu)) {
$newmenu->add("/compta/paiement/cheque/card.php?leftmenu=checks_bis&amp;action=new&amp;mainmenu=bank", $langs->trans("NewChequeDeposit"), 1, $user->rights->banque->cheque);
$newmenu->add("/compta/paiement/cheque/list.php?leftmenu=checks_bis&amp;mainmenu=bank", $langs->trans("List"), 1, $user->rights->banque->cheque);
@ -1524,7 +1524,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM
// Cash Control
if (!empty($conf->takepos->enabled) || !empty($conf->cashdesk->enabled)) {
$permtomakecashfence = ($user->rights->cashdesk->run || $user->rights->takepos->run);
$newmenu->add("/compta/cashcontrol/cashcontrol_list.php?action=list", $langs->trans("POS"), 0, $permtomakecashfence, '', $mainmenu, 'cashcontrol');
$newmenu->add("/compta/cashcontrol/cashcontrol_list.php?action=list", $langs->trans("POS"), 0, $permtomakecashfence, '', $mainmenu, 'cashcontrol', 0, '', '', '', img_picto('', 'pos', 'class="pictofixedwidth"'));
$newmenu->add("/compta/cashcontrol/cashcontrol_card.php?action=create", $langs->trans("NewCashFence"), 1, $permtomakecashfence);
$newmenu->add("/compta/cashcontrol/cashcontrol_list.php?action=list", $langs->trans("List"), 1, $permtomakecashfence);
}
@ -1724,12 +1724,12 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM
if (empty($conf->global->PROJECT_HIDE_TASKS)) {
// Project affected to user
$newmenu->add("/projet/activity/index.php?leftmenu=tasks".($search_project_user ? '&search_project_user='.$search_project_user : ''), $langs->trans("Activities"), 0, $user->rights->projet->lire, '', 'project', 'tasks', 0, '', '', '', img_picto('', 'task', 'class="pictofixedwidth"'));
$newmenu->add("/projet/activity/index.php?leftmenu=tasks".($search_project_user ? '&search_project_user='.$search_project_user : ''), $langs->trans("Activities"), 0, $user->rights->projet->lire, '', 'project', 'tasks', 0, '', '', '', img_picto('', 'projecttask', 'class="pictofixedwidth"'));
$newmenu->add("/projet/tasks.php?leftmenu=tasks&action=create", $langs->trans("NewTask"), 1, $user->rights->projet->creer);
$newmenu->add("/projet/tasks/list.php?leftmenu=tasks".($search_project_user ? '&search_project_user='.$search_project_user : ''), $langs->trans("List"), 1, $user->rights->projet->lire);
$newmenu->add("/projet/tasks/stats/index.php?leftmenu=projects", $langs->trans("Statistics"), 1, $user->rights->projet->lire);
$newmenu->add("/projet/activity/perweek.php?leftmenu=tasks".($search_project_user ? '&search_project_user='.$search_project_user : ''), $langs->trans("NewTimeSpent"), 0, $user->rights->projet->lire);
$newmenu->add("/projet/activity/perweek.php?leftmenu=tasks".($search_project_user ? '&search_project_user='.$search_project_user : ''), $langs->trans("NewTimeSpent"), 0, $user->rights->projet->lire, '', 'project', 'timespent', 0, '', '', '', img_picto('', 'timespent', 'class="pictofixedwidth"'));
}
}
}
@ -1770,7 +1770,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM
// Trips and expenses (old module)
if (!empty($conf->deplacement->enabled)) {
$langs->load("trips");
$newmenu->add("/compta/deplacement/index.php?leftmenu=tripsandexpenses&amp;mainmenu=hrm", $langs->trans("TripsAndExpenses"), 0, $user->rights->deplacement->lire, '', $mainmenu, 'tripsandexpenses');
$newmenu->add("/compta/deplacement/index.php?leftmenu=tripsandexpenses&amp;mainmenu=hrm", $langs->trans("TripsAndExpenses"), 0, $user->rights->deplacement->lire, '', $mainmenu, 'tripsandexpenses', 0, '', '', '', img_picto('', 'trip', 'class="pictofixedwidth"'));
$newmenu->add("/compta/deplacement/card.php?action=create&amp;leftmenu=tripsandexpenses&amp;mainmenu=hrm", $langs->trans("New"), 1, $user->rights->deplacement->creer);
$newmenu->add("/compta/deplacement/list.php?leftmenu=tripsandexpenses&amp;mainmenu=hrm", $langs->trans("List"), 1, $user->rights->deplacement->lire);
$newmenu->add("/compta/deplacement/stats/index.php?leftmenu=tripsandexpenses&amp;mainmenu=hrm", $langs->trans("Statistics"), 1, $user->rights->deplacement->lire);
@ -1779,7 +1779,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM
// Expense report
if (!empty($conf->expensereport->enabled)) {
$langs->load("trips");
$newmenu->add("/expensereport/index.php?leftmenu=expensereport&amp;mainmenu=hrm", $langs->trans("TripsAndExpenses"), 0, $user->rights->expensereport->lire, '', $mainmenu, 'expensereport');
$newmenu->add("/expensereport/index.php?leftmenu=expensereport&amp;mainmenu=hrm", $langs->trans("TripsAndExpenses"), 0, $user->rights->expensereport->lire, '', $mainmenu, 'expensereport', 0, '', '', '', img_picto('', 'trip', 'class="pictofixedwidth"'));
$newmenu->add("/expensereport/card.php?action=create&amp;leftmenu=expensereport&amp;mainmenu=hrm", $langs->trans("New"), 1, $user->rights->expensereport->creer);
$newmenu->add("/expensereport/list.php?leftmenu=expensereport&amp;mainmenu=hrm", $langs->trans("List"), 1, $user->rights->expensereport->lire);
if ($usemenuhider || empty($leftmenu) || $leftmenu == "expensereport") {
@ -1799,7 +1799,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM
$search_project_user = GETPOST('search_project_user', 'int');
$newmenu->add("/projet/activity/perweek.php?leftmenu=tasks".($search_project_user ? '&search_project_user='.$search_project_user : ''), $langs->trans("NewTimeSpent"), 0, $user->rights->projet->lire);
$newmenu->add("/projet/activity/perweek.php?leftmenu=tasks".($search_project_user ? '&search_project_user='.$search_project_user : ''), $langs->trans("NewTimeSpent"), 0, $user->rights->projet->lire, '', $mainmenu, 'timespent', 0, '', '', '', img_picto('', 'timespent', 'class="pictofixedwidth"'));
}
}
}

View File

@ -1433,7 +1433,8 @@ class pdf_einstein extends ModelePDFCommandes
$carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
$carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, 'target', $object);
$mode = 'target';
$carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, $mode, $object);
// Show recipient
$widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;

View File

@ -1618,7 +1618,8 @@ class pdf_eratosthene extends ModelePDFCommandes
$carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
$carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, 'target', $object);
$mode = 'target';
$carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, $mode, $object);
// Show recipient
$widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;

View File

@ -1053,10 +1053,9 @@ class pdf_crabe extends ModelePDFFactures
&& empty($conf->global->FACTURE_CHQ_NUMBER)
&& empty($conf->global->FACTURE_RIB_NUMBER)) {
$this->error = $outputlangs->transnoentities("ErrorNoPaiementModeConfigured");
}
// Avoid having any valid PDF with setup that is not complete
elseif (($object->mode_reglement_code == 'CHQ' && empty($conf->global->FACTURE_CHQ_NUMBER) && empty($object->fk_account) && empty($object->fk_bank))
} elseif (($object->mode_reglement_code == 'CHQ' && empty($conf->global->FACTURE_CHQ_NUMBER) && empty($object->fk_account) && empty($object->fk_bank))
|| ($object->mode_reglement_code == 'VIR' && empty($conf->global->FACTURE_RIB_NUMBER) && empty($object->fk_account) && empty($object->fk_bank))) {
// Avoid having any valid PDF with setup that is not complete
$outputlangs->load("errors");
$pdf->SetXY($this->marge_gauche, $posy);
@ -1850,7 +1849,8 @@ class pdf_crabe extends ModelePDFFactures
$carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
$carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, 'target', $object);
$mode = 'target';
$carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, $mode, $object);
// Show recipient
$widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;

View File

@ -1142,10 +1142,9 @@ class pdf_sponge extends ModelePDFFactures
&& empty($conf->global->FACTURE_CHQ_NUMBER)
&& empty($conf->global->FACTURE_RIB_NUMBER)) {
$this->error = $outputlangs->transnoentities("ErrorNoPaiementModeConfigured");
}
// Avoid having any valid PDF with setup that is not complete
elseif (($object->mode_reglement_code == 'CHQ' && empty($conf->global->FACTURE_CHQ_NUMBER) && empty($object->fk_account) && empty($object->fk_bank))
} elseif (($object->mode_reglement_code == 'CHQ' && empty($conf->global->FACTURE_CHQ_NUMBER) && empty($object->fk_account) && empty($object->fk_bank))
|| ($object->mode_reglement_code == 'VIR' && empty($conf->global->FACTURE_RIB_NUMBER) && empty($object->fk_account) && empty($object->fk_bank))) {
// Avoid having any valid PDF with setup that is not complete
$outputlangs->load("errors");
$pdf->SetXY($this->marge_gauche, $posy);
@ -2116,7 +2115,8 @@ class pdf_sponge extends ModelePDFFactures
$carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
$carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, 'target', $object);
$mode = 'target';
$carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, $mode, $object);
// Show recipient
$widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;

View File

@ -292,7 +292,8 @@ class modAccounting extends DolibarrModules
'b.subledger_label'=>'SubledgerAccountLabel',
'b.label_operation'=>'LabelOperation',
'b.debit'=>"Debit",
'b.credit'=>"Credit"
'b.credit'=>"Credit",
'b.sens'=>'Direction' // This field is still used by accounting export. We can remove it once it has been replace into accountancyexport.class.php by a detection using ->debit and ->credit
);
$this->import_fieldshidden_array[$r] = array('b.doc_type'=>'const-import_from_external', 'b.fk_doc'=>'const-0', 'b.fk_docdet'=>'const-0', 'b.fk_user_author'=>'user->id', 'b.date_creation'=>'const-'.dol_print_date(dol_now(), 'standard')); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent)
$this->import_regex_array[$r] = array('b.doc_date'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$');
@ -309,7 +310,8 @@ class modAccounting extends DolibarrModules
'b.subledger_label'=>'',
'b.label_operation'=>"Sale of ABC",
'b.debit'=>"0",
'b.credit'=>"100"
'b.credit'=>"100",
'b.sens'=>'C' // This field is still used by accounting export. We can remove it once it has been replace into accountancyexport.class.php by a detection using ->debit and ->credit
);
// Chart of accounts

View File

@ -216,6 +216,7 @@ class modTakePos extends DolibarrModules
'titre'=>'PointOfSaleShort',
'mainmenu'=>'takepos',
'leftmenu'=>'',
'prefix' => img_picto('', $this->picto, 'class="paddingright pictofixedwidth"'),
'url'=>'/takepos/index.php',
'langs'=>'cashdesk', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'position'=>1000 + $r,

View File

@ -1602,7 +1602,8 @@ class pdf_azur extends ModelePDFPropales
$carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
$carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, 'target', $object);
$mode = 'target';
$carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, $mode, $object);
// Show recipient
$widthrecbox = 100;

View File

@ -1718,7 +1718,8 @@ class pdf_cyan extends ModelePDFPropales
$carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
$carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, 'target', $object);
$mode = 'target';
$carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, $mode, $object);
// Show recipient
$widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;

View File

@ -44,7 +44,7 @@ foreach ($object->fields as $key => $val) {
continue; // We don't want this field
}
print '<tr id="field_'.$key.'">';
print '<tr class="field_'.$key.'">';
print '<td';
print ' class="titlefieldcreate';
if ($val['notnull'] > 0) {
@ -61,7 +61,7 @@ foreach ($object->fields as $key => $val) {
print $langs->trans($val['label']);
}
print '</td>';
print '<td>';
print '<td class="valuefieldcreate">';
if (!empty($val['picto'])) {
print img_picto('', $val['picto']);
}

View File

@ -46,7 +46,7 @@ foreach ($object->fields as $key => $val) {
continue; // We don't want this field
}
print '<tr><td';
print '<tr class="field_'.$key.'"><td';
print ' class="titlefieldcreate';
if ($val['notnull'] > 0) {
print ' fieldrequired';
@ -61,7 +61,7 @@ foreach ($object->fields as $key => $val) {
print $langs->trans($val['label']);
}
print '</td>';
print '<td>';
print '<td class="valuefieldcreate">';
if (!empty($val['picto'])) {
print img_picto('', $val['picto']);
}

View File

@ -57,7 +57,7 @@ foreach ($object->fields as $key => $val) {
$value = $object->$key;
print '<tr><td';
print '<tr class="field_'.$key.'"><td';
print ' class="titlefield fieldname_'.$key;
//if ($val['notnull'] > 0) print ' fieldrequired'; // No fieldrequired on the view output
if ($val['type'] == 'text' || $val['type'] == 'html') {
@ -70,7 +70,7 @@ foreach ($object->fields as $key => $val) {
print $langs->trans($val['label']);
}
print '</td>';
print '<td class="valuefield fieldname_'.$key;
print '<td class="valuefield';
if ($val['type'] == 'text') {
print ' wordbreak';
}

View File

@ -198,7 +198,7 @@ if (empty($reshook) && is_array($extrafields->attributes[$object->table_element]
$html_id = !empty($object->id) ? $object->element.'_extras_'.$tmpkeyextra.'_'.$object->id : '';
print '<td id="'.$html_id.'" class="'.$object->element.'_extras_'.$tmpkeyextra.' wordbreak"'.(!empty($cols) ? ' colspan="'.$cols.'"' : '').'>';
print '<td id="'.$html_id.'" class="valuefield '.$object->element.'_extras_'.$tmpkeyextra.' wordbreak"'.(!empty($cols) ? ' colspan="'.$cols.'"' : '').'>';
// Convert date into timestamp format
if (in_array($extrafields->attributes[$object->table_element]['type'][$tmpkeyextra], array('date', 'datetime'))) {

File diff suppressed because it is too large Load Diff

View File

@ -99,7 +99,7 @@ if (empty($reshook)) {
if ($action == 'setsupplieraccountancycode') {
$result = $object->fetch($id);
$object->code_compta_fournisseur = $_POST["supplieraccountancycode"];
$object->code_compta_fournisseur = GETPOST("supplieraccountancycode");
$result = $object->update($object->id, $user, 1, 0, 1);
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
@ -195,7 +195,7 @@ if ($object->id > 0) {
print '<div class="fichecenter"><div class="fichehalfleft">';
print '<div class="underbanner clearboth"></div>';
print '<table width="100%" class="border">';
print '<table class="border centpercent tableforfield">';
// Type Prospect/Customer/Supplier
print '<tr><td class="titlefield">'.$langs->trans('NatureOfThirdParty').'</td><td>';
@ -209,7 +209,7 @@ if ($object->id > 0) {
if ($object->fournisseur) {
print '<tr>';
print '<td class="titlefield">'.$langs->trans("SupplierCode").'</td><td>';
print $object->code_fournisseur;
print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_fournisseur));
$tmpcheck = $object->check_codefournisseur();
if ($tmpcheck != 0 && $tmpcheck != -5) {
print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>';
@ -250,7 +250,7 @@ if ($object->id > 0) {
// TVA Intra
print '<tr><td class="nowrap">'.$langs->trans('VATIntra').'</td><td>';
print $object->tva_intra;
print showValueWithClipboardCPButton(dol_escape_htmltag($object->tva_intra));
print '</td></tr>';
// Default terms of the settlement

View File

@ -952,7 +952,7 @@ class ProductFournisseur extends Product
}
$out .= '</table>';
} else {
$out = ($showunitprice ?price($this->fourn_unitprice * (1 - $this->fourn_remise_percent / 100) + $this->fourn_remise).' '.$langs->trans("HT").' &nbsp; (' : '').($showsuptitle ? $langs->trans("Supplier").': ' : '').$this->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).' / '.$langs->trans("SupplierRef").': '.$this->fourn_ref.($showunitprice ? ')' : '');
$out = ($showunitprice ?price($this->fourn_unitprice * (1 - $this->fourn_remise_percent / 100) + $this->fourn_remise).' '.$langs->trans("HT").' &nbsp; <span class="opacitymedium">(</span>' : '').($showsuptitle ? '<span class="opacitymedium">'.$langs->trans("Supplier").'</span>: ' : '').$this->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).' / <span class="opacitymedium">'.$langs->trans("SupplierRef").'</span>: '.$this->fourn_ref.($showunitprice ? '<span class="opacitymedium">)</span>' : '');
}
return $out;
}

View File

@ -93,9 +93,7 @@ function addDispatchLine(index, type, mode)
if (qtyOrdered <= 1) {
window.alert("Quantity can't be split");
}
if (qtyDispatched < qtyOrdered)
{
} else if (qtyDispatched < qtyOrdered) {
//replace tr suffix nbr
$row.html($row.html().replace(/_0_/g,"_"+nbrTrs+"_"));
//create new select2 to avoid duplicate id of cloned one

View File

@ -28,7 +28,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
$langs->loadLangs(array("admin", "ftp"));
// Security check
if (!$user->admin) accessforbidden();
if (!$user->admin) {
accessforbidden();
}
$def = array();
$lastftpentry = 0;
@ -45,36 +47,33 @@ $entry = GETPOST('numero_entry', 'alpha');
$sql = "select MAX(name) as name from ".MAIN_DB_PREFIX."const";
$sql .= " WHERE name like 'FTP_SERVER_%'";
$result = $db->query($sql);
if ($result)
{
if ($result) {
$obj = $db->fetch_object($result);
preg_match('/([0-9]+)$/i', $obj->name, $reg);
if ($reg[1]) $lastftpentry = $reg[1];
if ($reg[1]) {
$lastftpentry = $reg[1];
}
} else {
dol_print_error($db);
}
if ($action == 'add' || GETPOST('modify', 'alpha'))
{
if ($action == 'add' || GETPOST('modify', 'alpha')) {
$ftp_name = "FTP_NAME_".$entry; // $_POST["numero_entry"];
$ftp_server = "FTP_SERVER_".$entry; //$_POST["numero_entry"];
$error = 0;
if (!GETPOST("$ftp_name", 'alpha'))
{
if (!GETPOST("$ftp_name", 'alpha')) {
$error = 1;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors');
}
if (!GETPOST("$ftp_server", 'alpha'))
{
if (!GETPOST("$ftp_server", 'alpha')) {
$error = 1;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Server")), null, 'errors');
}
if (!$error)
{
if (!$error) {
$ftp_port = "FTP_PORT_".$entry;
$ftp_user = "FTP_USER_".$entry;
$ftp_password = "FTP_PASSWORD_".$entry;
@ -83,14 +82,23 @@ if ($action == 'add' || GETPOST('modify', 'alpha'))
$db->begin();
$result1 = dolibarr_set_const($db, "FTP_PORT_".$entry, GETPOST($ftp_port, 'alpha'), 'chaine', 0, '', $conf->entity);
if ($result1) $result2 = dolibarr_set_const($db, "FTP_SERVER_".$entry, GETPOST($ftp_server, 'alpha'), 'chaine', 0, '', $conf->entity);
if ($result2) $result3 = dolibarr_set_const($db, "FTP_USER_".$entry, GETPOST($ftp_user, 'alpha'), 'chaine', 0, '', $conf->entity);
if ($result3) $result4 = dolibarr_set_const($db, "FTP_PASSWORD_".$entry, GETPOST($ftp_password, 'alpha'), 'chaine', 0, '', $conf->entity);
if ($result4) $result5 = dolibarr_set_const($db, "FTP_NAME_".$entry, GETPOST($ftp_name, 'alpha'), 'chaine', 0, '', $conf->entity);
if ($result5) $result6 = dolibarr_set_const($db, "FTP_PASSIVE_".$entry, GETPOST($ftp_passive, 'alpha'), 'chaine', 0, '', $conf->entity);
if ($result1) {
$result2 = dolibarr_set_const($db, "FTP_SERVER_".$entry, GETPOST($ftp_server, 'alpha'), 'chaine', 0, '', $conf->entity);
}
if ($result2) {
$result3 = dolibarr_set_const($db, "FTP_USER_".$entry, GETPOST($ftp_user, 'alpha'), 'chaine', 0, '', $conf->entity);
}
if ($result3) {
$result4 = dolibarr_set_const($db, "FTP_PASSWORD_".$entry, GETPOST($ftp_password, 'alpha'), 'chaine', 0, '', $conf->entity);
}
if ($result4) {
$result5 = dolibarr_set_const($db, "FTP_NAME_".$entry, GETPOST($ftp_name, 'alpha'), 'chaine', 0, '', $conf->entity);
}
if ($result5) {
$result6 = dolibarr_set_const($db, "FTP_PASSIVE_".$entry, GETPOST($ftp_passive, 'alpha'), 'chaine', 0, '', $conf->entity);
}
if ($result1 && $result2 && $result3 && $result4 && $result5 && $result6)
{
if ($result1 && $result2 && $result3 && $result4 && $result5 && $result6) {
$db->commit();
header("Location: ".$_SERVER["PHP_SELF"]);
exit;
@ -101,21 +109,28 @@ if ($action == 'add' || GETPOST('modify', 'alpha'))
}
}
if (GETPOST('delete', 'alpha'))
{
if ($entry)
{
if (GETPOST('delete', 'alpha')) {
if ($entry) {
$db->begin();
$result1 = dolibarr_del_const($db, "FTP_PORT_".$entry, $conf->entity);
if ($result1) $result2 = dolibarr_del_const($db, "FTP_SERVER_".$entry, $conf->entity);
if ($result2) $result3 = dolibarr_del_const($db, "FTP_USER_".$entry, $conf->entity);
if ($result3) $result4 = dolibarr_del_const($db, "FTP_PASSWORD_".$entry, $conf->entity);
if ($result4) $result5 = dolibarr_del_const($db, "FTP_NAME_".$entry, $conf->entity);
if ($result4) $result6 = dolibarr_del_const($db, "FTP_PASSIVE_".$entry, $conf->entity);
if ($result1) {
$result2 = dolibarr_del_const($db, "FTP_SERVER_".$entry, $conf->entity);
}
if ($result2) {
$result3 = dolibarr_del_const($db, "FTP_USER_".$entry, $conf->entity);
}
if ($result3) {
$result4 = dolibarr_del_const($db, "FTP_PASSWORD_".$entry, $conf->entity);
}
if ($result4) {
$result5 = dolibarr_del_const($db, "FTP_NAME_".$entry, $conf->entity);
}
if ($result4) {
$result6 = dolibarr_del_const($db, "FTP_PASSIVE_".$entry, $conf->entity);
}
if ($result1 && $result2 && $result3 && $result4 && $result5 && $result6)
{
if ($result1 && $result2 && $result3 && $result4 && $result5 && $result6) {
$db->commit();
header("Location: ".$_SERVER["PHP_SELF"]);
exit;
@ -139,8 +154,7 @@ $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_valu
print load_fiche_titre($langs->trans("FTPClientSetup"), $linkback, 'title_setup');
print '<br>';
if (!function_exists('ftp_connect'))
{
if (!function_exists('ftp_connect')) {
print $langs->trans("FTPFeatureNotSupportedByYourPHP");
} else {
// Formulaire ajout
@ -186,7 +200,9 @@ if (!function_exists('ftp_connect'))
print '<tr class="impair">';
print '<td>'.$langs->trans("FTPPassiveMode").'</td>';
$defaultpassive = GETPOST("FTP_PASSIVE_".($lastftpentry + 1));
if (!isset($_POST["FTP_PASSIVE_".($lastftpentry + 1)])) $defaultpassive = empty($conf->global->FTP_SUGGEST_PASSIVE_BYDEFAULT) ? 0 : 1;
if (!isset($_POST["FTP_PASSIVE_".($lastftpentry + 1)])) {
$defaultpassive = empty($conf->global->FTP_SUGGEST_PASSIVE_BYDEFAULT) ? 0 : 1;
}
print '<td>'.$form->selectyesno('FTP_PASSIVE_'.($lastftpentry + 1), $defaultpassive, 2).'</td>';
print '<td>'.$langs->trans("No").'</td>';
print '</tr>';
@ -211,13 +227,11 @@ if (!function_exists('ftp_connect'))
dol_syslog("ftpclient select ftp setup", LOG_DEBUG);
$resql = $db->query($sql);
if ($resql)
{
if ($resql) {
$num = $db->num_rows($resql);
$i = 0;
while ($i < $num)
{
while ($i < $num) {
$obj = $db->fetch_object($resql);
preg_match('/([0-9]+)$/i', $obj->name, $reg);

View File

@ -32,13 +32,17 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php';
$langs->loadLangs(array('ftp', 'companies', 'other'));
// Security check
if ($user->socid) $socid = $user->socid;
if ($user->socid) {
$socid = $user->socid;
}
$result = restrictedArea($user, 'ftp', '');
// Get parameters
$action = GETPOST('action', 'aZ09');
$section = GETPOST('section');
if (!$section) $section = '/';
if (!$section) {
$section = '/';
}
$numero_ftp = GETPOST("numero_ftp");
/* if (! $numero_ftp) $numero_ftp=1; */
$file = GETPOST("file");
@ -51,12 +55,18 @@ $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
if (empty($page) || $page == -1) {
$page = 0;
} // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (!$sortorder) $sortorder = "ASC";
if (!$sortfield) $sortfield = "label";
if (!$sortorder) {
$sortorder = "ASC";
}
if (!$sortfield) {
$sortfield = "label";
}
$s_ftp_name = 'FTP_NAME_'.$numero_ftp;
$s_ftp_server = 'FTP_SERVER_'.$numero_ftp;
@ -66,7 +76,9 @@ $s_ftp_password = 'FTP_PASSWORD_'.$numero_ftp;
$s_ftp_passive = 'FTP_PASSIVE_'.$numero_ftp;
$ftp_name = $conf->global->$s_ftp_name;
$ftp_server = $conf->global->$s_ftp_server;
$ftp_port = $conf->global->$s_ftp_port; if (empty($ftp_port)) $ftp_port = 21;
$ftp_port = $conf->global->$s_ftp_port; if (empty($ftp_port)) {
$ftp_port = 21;
}
$ftp_user = $conf->global->$s_ftp_user;
$ftp_password = $conf->global->$s_ftp_password;
$ftp_passive = $conf->global->$s_ftp_passive;
@ -83,29 +95,24 @@ $mesg = '';
*/
// Submit file
if (GETPOST("sendit") && !empty($conf->global->MAIN_UPLOAD_DOC))
{
if (GETPOST("sendit") && !empty($conf->global->MAIN_UPLOAD_DOC)) {
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
$result = $ecmdir->fetch(GETPOST("section", 'int'));
if (!$result > 0)
{
if (!$result > 0) {
dol_print_error($db, $ecmdir->error);
exit;
}
$relativepath = $ecmdir->getRelativePath();
$upload_dir = $conf->ecm->dir_output.'/'.$relativepath;
if (dol_mkdir($upload_dir) >= 0)
{
if (dol_mkdir($upload_dir) >= 0) {
$resupload = dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir."/".dol_unescapefile($_FILES['userfile']['name']), 0);
if (is_numeric($resupload) && $resupload > 0)
{
if (is_numeric($resupload) && $resupload > 0) {
$result = $ecmdir->changeNbOfFiles('+');
} else {
$langs->load("errors");
if ($resupload < 0) // Unknown error
{
if ($resupload < 0) { // Unknown error
setEventMessages($langs->trans("ErrorFileNotUploaded"), null, 'errors');
} elseif (preg_match('/ErrorFileIsInfectedWithAVirus/', $resupload)) {
// Files infected by a virus
@ -123,15 +130,13 @@ if (GETPOST("sendit") && !empty($conf->global->MAIN_UPLOAD_DOC))
}
// Action ajout d'un rep
if ($action == 'add' && $user->rights->ftp->setup)
{
if ($action == 'add' && $user->rights->ftp->setup) {
$ecmdir->ref = GETPOST("ref");
$ecmdir->label = GETPOST("label");
$ecmdir->description = GETPOST("desc");
$id = $ecmdir->create($user);
if ($id > 0)
{
if ($id > 0) {
header("Location: ".$_SERVER["PHP_SELF"]);
exit;
} else {
@ -141,11 +146,9 @@ if ($action == 'add' && $user->rights->ftp->setup)
}
// Remove 1 file
if ($action == 'confirm_deletefile' && GETPOST('confirm') == 'yes')
{
if ($action == 'confirm_deletefile' && GETPOST('confirm') == 'yes') {
// set up a connection or die
if (!$conn_id)
{
if (!$conn_id) {
$newsectioniso = utf8_decode($section);
$resultarray = dol_ftp_connect($ftp_server, $ftp_port, $ftp_user, $ftp_password, $newsectioniso, $ftp_passive);
$conn_id = $resultarray['conn_id'];
@ -153,11 +156,9 @@ if ($action == 'confirm_deletefile' && GETPOST('confirm') == 'yes')
$mesg = $resultarray['mesg'];
}
if ($conn_id && $ok && !$mesg)
{
if ($conn_id && $ok && !$mesg) {
$newsection = $section;
if (!empty($conf->global->FTP_CONNECT_WITH_SFTP))
{
if (!empty($conf->global->FTP_CONNECT_WITH_SFTP)) {
$newsection = ssh2_sftp_realpath($conn_id, ".").'/./'; // workaround for bug https://bugs.php.net/bug.php?id=64169
}
@ -175,8 +176,7 @@ if ($action == 'confirm_deletefile' && GETPOST('confirm') == 'yes')
} else {
$result = @ftp_delete($conn_id, $newremotefileiso);
}
if ($result)
{
if ($result) {
setEventMessages($langs->trans("FileWasRemoved", $file), null, 'mesgs');
} else {
dol_syslog("ftp/index.php ftp_delete", LOG_ERR);
@ -192,11 +192,9 @@ if ($action == 'confirm_deletefile' && GETPOST('confirm') == 'yes')
}
// Delete several lines at once
if (GETPOST("const", 'array') && GETPOST("delete") && GETPOST("delete") == $langs->trans("Delete"))
{
if (GETPOST("const", 'array') && GETPOST("delete") && GETPOST("delete") == $langs->trans("Delete")) {
// set up a connection or die
if (!$conn_id)
{
if (!$conn_id) {
$newsectioniso = utf8_decode($section);
$resultarray = dol_ftp_connect($ftp_server, $ftp_port, $ftp_user, $ftp_password, $newsectioniso, $ftp_passive);
$conn_id = $resultarray['conn_id'];
@ -204,19 +202,15 @@ if (GETPOST("const", 'array') && GETPOST("delete") && GETPOST("delete") == $lang
$mesg = $resultarray['mesg'];
}
if ($conn_id && $ok && !$mesg)
{
foreach (GETPOST('const', 'array') as $const)
{
if ($const["check"]) // Is checkbox checked
{
if ($conn_id && $ok && !$mesg) {
foreach (GETPOST('const', 'array') as $const) {
if ($const["check"]) { // Is checkbox checked
$langs->load("other");
// Remote file
$file = $const["file"];
$newsection = $const["section"];
if (!empty($conf->global->FTP_CONNECT_WITH_SFTP))
{
if (!empty($conf->global->FTP_CONNECT_WITH_SFTP)) {
$newsection = ssh2_sftp_realpath($conn_id, ".").'/./'; // workaround for bug https://bugs.php.net/bug.php?id=64169
}
$remotefile = $newsection.(preg_match('@[\\\/]$@', $newsection) ? '' : '/').$file;
@ -229,8 +223,7 @@ if (GETPOST("const", 'array') && GETPOST("delete") && GETPOST("delete") == $lang
} else {
$result = @ftp_delete($conn_id, $newremotefileiso);
}
if ($result)
{
if ($result) {
setEventMessages($langs->trans("FileWasRemoved", $file), null, 'mesgs');
} else {
dol_syslog("ftp/index.php ftp_delete n files", LOG_ERR);
@ -248,11 +241,9 @@ if (GETPOST("const", 'array') && GETPOST("delete") && GETPOST("delete") == $lang
}
// Remove directory
if ($action == 'confirm_deletesection' && $confirm == 'yes')
{
if ($action == 'confirm_deletesection' && $confirm == 'yes') {
// set up a connection or die
if (!$conn_id)
{
if (!$conn_id) {
$newsectioniso = utf8_decode($section);
$resultarray = dol_ftp_connect($ftp_server, $ftp_port, $ftp_user, $ftp_password, $newsectioniso, $ftp_passive);
$conn_id = $resultarray['conn_id'];
@ -260,11 +251,9 @@ if ($action == 'confirm_deletesection' && $confirm == 'yes')
$mesg = $resultarray['mesg'];
}
if ($conn_id && $ok && !$mesg)
{
if ($conn_id && $ok && !$mesg) {
$newsection = $section;
if (!empty($conf->global->FTP_CONNECT_WITH_SFTP))
{
if (!empty($conf->global->FTP_CONNECT_WITH_SFTP)) {
$newsection = ssh2_sftp_realpath($conn_id, ".").'/./'; // workaround for bug https://bugs.php.net/bug.php?id=64169
}
@ -278,8 +267,7 @@ if ($action == 'confirm_deletesection' && $confirm == 'yes')
} else {
$result = @ftp_rmdir($conn_id, $newremotefileiso);
}
if ($result)
{
if ($result) {
setEventMessages($langs->trans("DirWasRemoved", $file), null, 'mesgs');
} else {
setEventMessages($langs->trans("FTPFailedToRemoveDir", $file), null, 'errors');
@ -294,11 +282,9 @@ if ($action == 'confirm_deletesection' && $confirm == 'yes')
}
// Download directory
if ($action == 'download')
{
if ($action == 'download') {
// set up a connection or die
if (!$conn_id)
{
if (!$conn_id) {
$newsectioniso = utf8_decode($section);
$resultarray = dol_ftp_connect($ftp_server, $ftp_port, $ftp_user, $ftp_password, $newsectioniso, $ftp_passive);
$conn_id = $resultarray['conn_id'];
@ -306,14 +292,12 @@ if ($action == 'download')
$mesg = $resultarray['mesg'];
}
if ($conn_id && $ok && !$mesg)
{
if ($conn_id && $ok && !$mesg) {
// Local file
$localfile = tempnam($download_dir, 'dol_');
$newsection = $section;
if (!empty($conf->global->FTP_CONNECT_WITH_SFTP))
{
if (!empty($conf->global->FTP_CONNECT_WITH_SFTP)) {
$newsection = ssh2_sftp_realpath($conn_id, ".").'/./'; // workaround for bug https://bugs.php.net/bug.php?id=64169
}
@ -327,23 +311,31 @@ if ($action == 'download')
} else {
$result = ftp_get($conn_id, $localfile, $newremotefileiso, FTP_BINARY);
}
if ($result)
{
if (!empty($conf->global->MAIN_UMASK))
@chmod($localfile, octdec($conf->global->MAIN_UMASK));
if ($result) {
if (!empty($conf->global->MAIN_UMASK)) {
@chmod($localfile, octdec($conf->global->MAIN_UMASK));
}
// Define mime type
$type = 'application/octet-stream';
if (GETPOSTISSET("type")) $type = GETPOST("type");
else $type = dol_mimetype($file);
if (GETPOSTISSET("type")) {
$type = GETPOST("type");
} else {
$type = dol_mimetype($file);
}
// Define attachment (attachment=true to force choice popup 'open'/'save as')
$attachment = true;
//if ($encoding) header('Content-Encoding: '.$encoding);
if ($type) header('Content-Type: '.$type);
if ($attachment) header('Content-Disposition: attachment; filename="'.$filename.'"');
else header('Content-Disposition: inline; filename="'.$filename.'"');
if ($type) {
header('Content-Type: '.$type);
}
if ($attachment) {
header('Content-Disposition: attachment; filename="'.$filename.'"');
} else {
header('Content-Disposition: inline; filename="'.$filename.'"');
}
// Ajout directives pour resoudre bug IE
header('Cache-Control: Public, must-revalidate');
@ -374,8 +366,7 @@ if ($action == 'download')
llxHeader();
// Add logic to shoow/hide buttons
if ($conf->use_javascript_ajax)
{
if ($conf->use_javascript_ajax) {
?>
<script type="text/javascript">
jQuery(document).ready(function() {
@ -411,21 +402,17 @@ print load_fiche_titre($langs->trans("FTPArea"));
print $langs->trans("FTPAreaDesc")."<br>";
if (!function_exists('ftp_connect'))
{
if (!function_exists('ftp_connect')) {
print $langs->trans("FTPFeatureNotSupportedByYourPHP");
} else {
if (!empty($ftp_server))
{
if (!empty($ftp_server)) {
// Confirm remove file
if ($action == 'delete')
{
if ($action == 'delete') {
print $form->formconfirm($_SERVER["PHP_SELF"].'?numero_ftp='.$numero_ftp.'&section='.urlencode(GETPOST('section')).'&file='.urlencode(GETPOST('file')), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', '', 1);
}
// Confirmation de la suppression d'une ligne categorie
if ($action == 'delete_section')
{
if ($action == 'delete_section') {
print $form->formconfirm($_SERVER["PHP_SELF"].'?numero_ftp='.$numero_ftp.'&section='.urlencode(GETPOST('section')).'&file='.urlencode(GETPOST('file')), $langs->trans('DeleteSection'), $langs->trans('ConfirmDeleteSection', $ecmdir->label), 'confirm_deletesection', '', '', 1);
}
@ -443,11 +430,11 @@ if (!function_exists('ftp_connect'))
print '</a> ';
// For other directories
$i = 0;
foreach ($sectionarray as $val)
{
if (empty($val)) continue; // Discard first and last entry that should be empty as section start/end with /
if ($i > 0)
{
foreach ($sectionarray as $val) {
if (empty($val)) {
continue; // Discard first and last entry that should be empty as section start/end with /
}
if ($i > 0) {
print ' / ';
$newsection .= '/';
}
@ -476,14 +463,15 @@ if (!function_exists('ftp_connect'))
print '<td class="liste_titre center">'.$langs->trans("Group").'</td>'."\n";
print '<td class="liste_titre center">'.$langs->trans("Permissions").'</td>'."\n";
print '<td class="liste_titre nowrap right">';
if ($conf->use_javascript_ajax) print '<a href="#" id="checkall">'.$langs->trans("All").'</a> / <a href="#" id="checknone">'.$langs->trans("None").'</a> ';
if ($conf->use_javascript_ajax) {
print '<a href="#" id="checkall">'.$langs->trans("All").'</a> / <a href="#" id="checknone">'.$langs->trans("None").'</a> ';
}
print '<a href="'.$_SERVER["PHP_SELF"].'?action=refreshmanual&numero_ftp='.$numero_ftp.($section ? '&section='.urlencode($section) : '').'">'.img_picto($langs->trans("Refresh"), 'refresh').'</a>&nbsp;';
print '</td>'."\n";
print '</tr>'."\n";
// set up a connection or die
if (empty($conn_id))
{
if (empty($conn_id)) {
$resultarray = dol_ftp_connect($ftp_server, $ftp_port, $ftp_user, $ftp_password, $section, $ftp_passive);
$conn_id = $resultarray['conn_id'];
@ -491,8 +479,7 @@ if (!function_exists('ftp_connect'))
$mesg = $resultarray['mesg'];
}
if ($ok)
{
if ($ok) {
//$type = ftp_systype($conn_id);
$newsection = $section;
@ -500,8 +487,7 @@ if (!function_exists('ftp_connect'))
//$newsection='/home';
// List content of directory ($newsection = '/', '/home', ...)
if (!empty($conf->global->FTP_CONNECT_WITH_SFTP))
{
if (!empty($conf->global->FTP_CONNECT_WITH_SFTP)) {
if ($newsection == '/') {
//$newsection = '/./';
$newsection = ssh2_sftp_realpath($conn_id, ".").'/./'; // workaround for bug https://bugs.php.net/bug.php?id=64169
@ -511,8 +497,7 @@ if (!function_exists('ftp_connect'))
//$dirHandle = opendir("ssh2.sftp://".intval($conn_id).ssh2_sftp_realpath($conn_id, ".").'/./');
$contents = scandir('ssh2.sftp://'.intval($conn_id).$newsection);
$buff = array();
foreach ($contents as $i => $key)
{
foreach ($contents as $i => $key) {
$buff[$i] = "---------- - root root 1234 Aug 01 2000 ".$key;
}
} else {
@ -525,31 +510,32 @@ if (!function_exists('ftp_connect'))
$nboflines = count($contents);
$rawlisthasfailed = false;
$i = 0;
while ($i < $nboflines && $i < 1000)
{
while ($i < $nboflines && $i < 1000) {
$vals = preg_split('@ +@', utf8_encode($buff[$i]), 9);
//$vals=preg_split('@ +@','drwxr-xr-x 2 root root 4096 Aug 30 2008 backup_apollon1',9);
//var_dump($vals);
$file = $vals[8];
if (empty($file))
{
if (empty($file)) {
$rawlisthasfailed = true;
$file = utf8_encode($contents[$i]);
}
if ($file == '.' || ($file == '..' && $section == '/'))
{
if ($file == '.' || ($file == '..' && $section == '/')) {
$i++;
continue;
}
// Is it a directory ?
$is_directory = 0;
if ($file == '..') $is_directory = 1;
elseif (!$rawlisthasfailed)
{
if (preg_match('/^d/', $vals[0])) $is_directory = 1;
if (preg_match('/^l/', $vals[0])) $is_link = 1;
if ($file == '..') {
$is_directory = 1;
} elseif (!$rawlisthasfailed) {
if (preg_match('/^d/', $vals[0])) {
$is_directory = 1;
}
if (preg_match('/^l/', $vals[0])) {
$is_link = 1;
}
} else {
// Remote file
$filename = $file;
@ -569,14 +555,21 @@ if (!function_exists('ftp_connect'))
print '<td>';
$newsection = $section.(preg_match('@[\\\/]$@', $section) ? '' : '/').$file;
$newsection = preg_replace('@[\\\/][^\\\/]+[\\\/]\.\.$@', '/', $newsection); // Change aaa/xxx/.. to new aaa
if ($is_directory) print '<a href="'.$_SERVER["PHP_SELF"].'?section='.urlencode($newsection).'&numero_ftp='.$numero_ftp.'">';
if ($is_directory) {
print '<a href="'.$_SERVER["PHP_SELF"].'?section='.urlencode($newsection).'&numero_ftp='.$numero_ftp.'">';
}
print dol_escape_htmltag($file);
if ($is_directory) print '</a>';
if ($is_directory) {
print '</a>';
}
print '</td>';
// Size
print '<td class="center nowrap">';
if (!$is_directory && !$is_link) print $vals[4];
else print '&nbsp;';
if (!$is_directory && !$is_link) {
print $vals[4];
} else {
print '&nbsp;';
}
print '</td>';
// Date
print '<td class="center nowrap">';
@ -596,12 +589,13 @@ if (!function_exists('ftp_connect'))
print '</td>';
// Action
print '<td class="right nowrap" width="64">';
if ($is_directory)
{
if ($file != '..') print '<a href="'.$_SERVER["PHP_SELF"].'?action=delete_section&token='.newToken().'&numero_ftp='.$numero_ftp.'&section='.urlencode($section).'&file='.urlencode($file).'">'.img_delete().'</a>';
else print '&nbsp;';
} elseif ($is_link)
{
if ($is_directory) {
if ($file != '..') {
print '<a href="'.$_SERVER["PHP_SELF"].'?action=delete_section&token='.newToken().'&numero_ftp='.$numero_ftp.'&section='.urlencode($section).'&file='.urlencode($file).'">'.img_delete().'</a>';
} else {
print '&nbsp;';
}
} elseif ($is_link) {
$newfile = $file;
$newfile = preg_replace('/ ->.*/', '', $newfile);
print '<a href="'.$_SERVER["PHP_SELF"].'?action=delete&token='.newToken().'&numero_ftp='.$numero_ftp.'&section='.urlencode($section).'&file='.urlencode($newfile).'">'.img_delete().'</a>';
@ -624,8 +618,7 @@ if (!function_exists('ftp_connect'))
print "</table>";
if (!$ok)
{
if (!$ok) {
print $mesg.'<br>'."\n";
setEventMessages($mesg, null, 'errors');
}
@ -650,19 +643,16 @@ if (!function_exists('ftp_connect'))
$foundsetup = false;
$MAXFTP = 20;
$i = 1;
while ($i <= $MAXFTP)
{
while ($i <= $MAXFTP) {
$paramkey = 'FTP_NAME_'.$i;
//print $paramkey;
if (!empty($conf->global->$paramkey))
{
if (!empty($conf->global->$paramkey)) {
$foundsetup = true;
break;
}
$i++;
}
if (!$foundsetup)
{
if (!$foundsetup) {
print $langs->trans("SetupOfFTPClientModuleNotComplete");
} else {
print $langs->trans("ChooseAFTPEntryIntoMenu");
@ -673,12 +663,9 @@ if (!function_exists('ftp_connect'))
print '<br>';
// Close FTP connection
if ($conn_id)
{
if (!empty($conf->global->FTP_CONNECT_WITH_SFTP))
{
} elseif (!empty($conf->global->FTP_CONNECT_WITH_SSL))
{
if ($conn_id) {
if (!empty($conf->global->FTP_CONNECT_WITH_SFTP)) {
} elseif (!empty($conf->global->FTP_CONNECT_WITH_SSL)) {
ftp_close($conn_id);
} else {
ftp_close($conn_id);
@ -709,14 +696,12 @@ function dol_ftp_connect($ftp_server, $ftp_port, $ftp_user, $ftp_password, $sect
$ok = 1;
$conn_id = null;
if (!is_numeric($ftp_port))
{
if (!is_numeric($ftp_port)) {
$mesg = $langs->transnoentitiesnoconv("FailedToConnectToFTPServer", $ftp_server, $ftp_port);
$ok = 0;
}
if ($ok)
{
if ($ok) {
$connecttimeout = (empty($conf->global->FTP_CONNECT_TIMEOUT) ? 40 : $conf->global->FTP_CONNECT_TIMEOUT);
if (!empty($conf->global->FTP_CONNECT_WITH_SFTP)) {
dol_syslog('Try to connect with ssh2_ftp');
@ -728,15 +713,11 @@ function dol_ftp_connect($ftp_server, $ftp_port, $ftp_user, $ftp_password, $sect
dol_syslog('Try to connect with ftp_connect');
$conn_id = ftp_connect($ftp_server, $ftp_port, $connecttimeout);
}
if ($conn_id || $tmp_conn_id)
{
if ($ftp_user)
{
if (!empty($conf->global->FTP_CONNECT_WITH_SFTP))
{
if ($conn_id || $tmp_conn_id) {
if ($ftp_user) {
if (!empty($conf->global->FTP_CONNECT_WITH_SFTP)) {
dol_syslog('Try to authenticate with ssh2_auth_password');
if (ssh2_auth_password($tmp_conn_id, $ftp_user, $ftp_password))
{
if (ssh2_auth_password($tmp_conn_id, $ftp_user, $ftp_password)) {
// Turn on passive mode transfers (must be after a successful login
//if ($ftp_passive) ftp_pasv($conn_id, true);
@ -744,31 +725,31 @@ function dol_ftp_connect($ftp_server, $ftp_port, $ftp_user, $ftp_password, $sect
$newsectioniso = utf8_decode($section);
//ftp_chdir($conn_id, $newsectioniso);
$conn_id = ssh2_sftp($tmp_conn_id);
if (!$conn_id)
{
if (!$conn_id) {
dol_syslog('Failed to connect to SFTP after sssh authentication', LOG_DEBUG);
$mesg = $langs->transnoentitiesnoconv("FailedToConnectToSFTPAfterSSHAuthentication");
$ok = 0;
$ok = 0;
$error++;
}
} else {
dol_syslog('Failed to connect to FTP with login '.$ftp_user, LOG_DEBUG);
$mesg = $langs->transnoentitiesnoconv("FailedToConnectToFTPServerWithCredentials");
$ok = 0;
$ok = 0;
$error++;
}
} else {
if (ftp_login($conn_id, $ftp_user, $ftp_password))
{
if (ftp_login($conn_id, $ftp_user, $ftp_password)) {
// Turn on passive mode transfers (must be after a successful login
if ($ftp_passive) ftp_pasv($conn_id, true);
if ($ftp_passive) {
ftp_pasv($conn_id, true);
}
// Change the dir
$newsectioniso = utf8_decode($section);
ftp_chdir($conn_id, $newsectioniso);
} else {
$mesg = $langs->transnoentitiesnoconv("FailedToConnectToFTPServerWithCredentials");
$ok = 0;
$ok = 0;
$error++;
}
}
@ -794,8 +775,7 @@ function dol_ftp_connect($ftp_server, $ftp_port, $ftp_user, $ftp_password, $sect
*/
function ftp_isdir($connect_id, $dir)
{
if (@ftp_chdir($connect_id, $dir))
{
if (@ftp_chdir($connect_id, $dir)) {
ftp_cdup($connect_id);
return 1;
} else {

File diff suppressed because it is too large Load Diff

View File

@ -170,13 +170,11 @@ class Holiday extends CommonObject
global $langs, $conf;
$langs->load("order");
if (empty($conf->global->HOLIDAY_ADDON))
{
if (empty($conf->global->HOLIDAY_ADDON)) {
$conf->global->HOLIDAY_ADDON = 'mod_holiday_madonna';
}
if (!empty($conf->global->HOLIDAY_ADDON))
{
if (!empty($conf->global->HOLIDAY_ADDON)) {
$mybool = false;
$file = $conf->global->HOLIDAY_ADDON.".php";
@ -184,16 +182,14 @@ class Holiday extends CommonObject
// Include file with class
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
foreach ($dirmodels as $reldir)
{
foreach ($dirmodels as $reldir) {
$dir = dol_buildpath($reldir."core/modules/holiday/");
// Load file with numbering class (if found)
$mybool |= @include_once $dir.$file;
}
if ($mybool === false)
{
if ($mybool === false) {
dol_print_error('', "Failed to include file ".$file);
return '';
}
@ -201,8 +197,7 @@ class Holiday extends CommonObject
$obj = new $classname();
$numref = $obj->getNextValue($objsoc, $this);
if ($numref != "")
{
if ($numref != "") {
return $numref;
} else {
$this->error = $obj->error;
@ -230,8 +225,7 @@ class Holiday extends CommonObject
// Check nb of users into table llx_holiday_users and update with empty lines
//if ($result > 0) $result = $this->verifNbUsers($this->countActiveUsersWithoutCP(), $this->getConfCP('nbUser'));
if ($result >= 0)
{
if ($result >= 0) {
$this->db->commit();
return 1;
} else {
@ -255,9 +249,15 @@ class Holiday extends CommonObject
$now = dol_now();
// Check parameters
if (empty($this->fk_user) || !is_numeric($this->fk_user) || $this->fk_user < 0) { $this->error = "ErrorBadParameterFkUser"; return -1; }
if (empty($this->fk_validator) || !is_numeric($this->fk_validator) || $this->fk_validator < 0) { $this->error = "ErrorBadParameterFkValidator"; return -1; }
if (empty($this->fk_type) || !is_numeric($this->fk_type) || $this->fk_type < 0) { $this->error = "ErrorBadParameterFkType"; return -1; }
if (empty($this->fk_user) || !is_numeric($this->fk_user) || $this->fk_user < 0) {
$this->error = "ErrorBadParameterFkUser"; return -1;
}
if (empty($this->fk_validator) || !is_numeric($this->fk_validator) || $this->fk_validator < 0) {
$this->error = "ErrorBadParameterFkValidator"; return -1;
}
if (empty($this->fk_type) || !is_numeric($this->fk_type) || $this->fk_type < 0) {
$this->error = "ErrorBadParameterFkType"; return -1;
}
// Insert request
$sql = "INSERT INTO ".MAIN_DB_PREFIX."holiday(";
@ -296,32 +296,33 @@ class Holiday extends CommonObject
$error++; $this->errors[] = "Error ".$this->db->lasterror();
}
if (!$error)
{
if (!$error) {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."holiday");
if ($this->id)
{
if ($this->id) {
// update ref
$initialref = '(PROV'.$this->id.')';
if (!empty($this->ref)) $initialref = $this->ref;
if (!empty($this->ref)) {
$initialref = $this->ref;
}
$sql = 'UPDATE '.MAIN_DB_PREFIX."holiday SET ref='".$this->db->escape($initialref)."' WHERE rowid=".$this->id;
if ($this->db->query($sql))
{
if ($this->db->query($sql)) {
$this->ref = $initialref;
if (!$error)
{
if (!$error) {
$result = $this->insertExtraFields();
if ($result < 0) $error++;
if ($result < 0) {
$error++;
}
}
if (!$error && !$notrigger)
{
if (!$error && !$notrigger) {
// Call trigger
$result = $this->call_trigger('HOLIDAY_CREATE', $user);
if ($result < 0) { $error++; }
if ($result < 0) {
$error++;
}
// End call triggers
}
}
@ -329,10 +330,8 @@ class Holiday extends CommonObject
}
// Commit or rollback
if ($error)
{
foreach ($this->errors as $errmsg)
{
if ($error) {
foreach ($this->errors as $errmsg) {
dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR);
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
}
@ -380,15 +379,16 @@ class Holiday extends CommonObject
$sql .= " cp.fk_type,";
$sql .= " cp.entity";
$sql .= " FROM ".MAIN_DB_PREFIX."holiday as cp";
if ($id > 0) $sql .= " WHERE cp.rowid = ".$id;
else $sql .= " WHERE cp.ref = '".$this->db->escape($ref)."'";
if ($id > 0) {
$sql .= " WHERE cp.rowid = ".$id;
} else {
$sql .= " WHERE cp.ref = '".$this->db->escape($ref)."'";
}
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
if ($this->db->num_rows($resql))
{
if ($resql) {
if ($this->db->num_rows($resql)) {
$obj = $this->db->fetch_object($resql);
$this->id = $obj->rowid;
@ -693,8 +693,7 @@ class Holiday extends CommonObject
$error = 0;
// Define new ref
if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref) || $this->ref == $this->id))
{
if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref) || $this->ref == $this->id)) {
$num = $this->getNextNumRef(null);
} else {
$num = $this->ref;
@ -719,22 +718,20 @@ class Holiday extends CommonObject
$error++; $this->errors[] = "Error ".$this->db->lasterror();
}
if (!$error)
{
if (!$notrigger)
{
if (!$error) {
if (!$notrigger) {
// Call trigger
$result = $this->call_trigger('HOLIDAY_VALIDATE', $user);
if ($result < 0) { $error++; }
if ($result < 0) {
$error++;
}
// End call triggers
}
}
// Commit or rollback
if ($error)
{
foreach ($this->errors as $errmsg)
{
if ($error) {
foreach ($this->errors as $errmsg) {
dol_syslog(get_class($this)."::validate ".$errmsg, LOG_ERR);
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
}
@ -831,22 +828,20 @@ class Holiday extends CommonObject
$error++; $this->errors[] = "Error ".$this->db->lasterror();
}
if (!$error)
{
if (!$notrigger)
{
if (!$error) {
if (!$notrigger) {
// Call trigger
$result = $this->call_trigger('HOLIDAY_APPROVE', $user);
if ($result < 0) { $error++; }
if ($result < 0) {
$error++;
}
// End call triggers
}
}
// Commit or rollback
if ($error)
{
foreach ($this->errors as $errmsg)
{
if ($error) {
foreach ($this->errors as $errmsg) {
dol_syslog(get_class($this)."::approve ".$errmsg, LOG_ERR);
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
}
@ -942,22 +937,20 @@ class Holiday extends CommonObject
$error++; $this->errors[] = "Error ".$this->db->lasterror();
}
if (!$error)
{
if (!$notrigger)
{
if (!$error) {
if (!$notrigger) {
// Call trigger
$result = $this->call_trigger('HOLIDAY_MODIFY', $user);
if ($result < 0) { $error++; }
if ($result < 0) {
$error++;
}
// End call triggers
}
}
// Commit or rollback
if ($error)
{
foreach ($this->errors as $errmsg)
{
if ($error) {
foreach ($this->errors as $errmsg) {
dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
}
@ -993,22 +986,20 @@ class Holiday extends CommonObject
$error++; $this->errors[] = "Error ".$this->db->lasterror();
}
if (!$error)
{
if (!$notrigger)
{
if (!$error) {
if (!$notrigger) {
// Call trigger
$result = $this->call_trigger('HOLIDAY_DELETE', $user);
if ($result < 0) { $error++; }
if ($result < 0) {
$error++;
}
// End call triggers
}
}
// Commit or rollback
if ($error)
{
foreach ($this->errors as $errmsg)
{
if ($error) {
foreach ($this->errors as $errmsg) {
dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
}
@ -1037,60 +1028,67 @@ class Holiday extends CommonObject
{
$this->fetchByUser($fk_user, '', '');
foreach ($this->holiday as $infos_CP)
{
if ($infos_CP['statut'] == 4) continue; // ignore not validated holidays
if ($infos_CP['statut'] == 5) continue; // ignore not validated holidays
foreach ($this->holiday as $infos_CP) {
if ($infos_CP['statut'] == 4) {
continue; // ignore not validated holidays
}
if ($infos_CP['statut'] == 5) {
continue; // ignore not validated holidays
}
/*
var_dump("--");
var_dump("old: ".dol_print_date($infos_CP['date_debut'],'dayhour').' '.dol_print_date($infos_CP['date_fin'],'dayhour').' '.$infos_CP['halfday']);
var_dump("new: ".dol_print_date($dateStart,'dayhour').' '.dol_print_date($dateEnd,'dayhour').' '.$halfday);
*/
if ($halfday == 0)
{
if ($dateStart >= $infos_CP['date_debut'] && $dateStart <= $infos_CP['date_fin'])
{
if ($halfday == 0) {
if ($dateStart >= $infos_CP['date_debut'] && $dateStart <= $infos_CP['date_fin']) {
return false;
}
if ($dateEnd <= $infos_CP['date_fin'] && $dateEnd >= $infos_CP['date_debut'])
{
if ($dateEnd <= $infos_CP['date_fin'] && $dateEnd >= $infos_CP['date_debut']) {
return false;
}
} elseif ($halfday == -1)
{
} elseif ($halfday == -1) {
// new start afternoon, new end afternoon
if ($dateStart >= $infos_CP['date_debut'] && $dateStart <= $infos_CP['date_fin'])
{
if ($dateStart < $infos_CP['date_fin'] || in_array($infos_CP['halfday'], array(0, -1))) return false;
if ($dateStart >= $infos_CP['date_debut'] && $dateStart <= $infos_CP['date_fin']) {
if ($dateStart < $infos_CP['date_fin'] || in_array($infos_CP['halfday'], array(0, -1))) {
return false;
}
}
if ($dateEnd <= $infos_CP['date_fin'] && $dateEnd >= $infos_CP['date_debut'])
{
if ($dateStart < $dateEnd) return false;
if ($dateEnd < $infos_CP['date_fin'] || in_array($infos_CP['halfday'], array(0, -1))) return false;
if ($dateEnd <= $infos_CP['date_fin'] && $dateEnd >= $infos_CP['date_debut']) {
if ($dateStart < $dateEnd) {
return false;
}
if ($dateEnd < $infos_CP['date_fin'] || in_array($infos_CP['halfday'], array(0, -1))) {
return false;
}
}
} elseif ($halfday == 1)
{
} elseif ($halfday == 1) {
// new start morning, new end morning
if ($dateStart >= $infos_CP['date_debut'] && $dateStart <= $infos_CP['date_fin'])
{
if ($dateStart < $dateEnd) return false;
if ($dateStart > $infos_CP['date_debut'] || in_array($infos_CP['halfday'], array(0, 1))) return false;
if ($dateStart >= $infos_CP['date_debut'] && $dateStart <= $infos_CP['date_fin']) {
if ($dateStart < $dateEnd) {
return false;
}
if ($dateStart > $infos_CP['date_debut'] || in_array($infos_CP['halfday'], array(0, 1))) {
return false;
}
}
if ($dateEnd <= $infos_CP['date_fin'] && $dateEnd >= $infos_CP['date_debut'])
{
if ($dateEnd > $infos_CP['date_debut'] || in_array($infos_CP['halfday'], array(0, 1))) return false;
if ($dateEnd <= $infos_CP['date_fin'] && $dateEnd >= $infos_CP['date_debut']) {
if ($dateEnd > $infos_CP['date_debut'] || in_array($infos_CP['halfday'], array(0, 1))) {
return false;
}
}
} elseif ($halfday == 2)
{
} elseif ($halfday == 2) {
// new start afternoon, new end morning
if ($dateStart >= $infos_CP['date_debut'] && $dateStart <= $infos_CP['date_fin'])
{
if ($dateStart < $infos_CP['date_fin'] || in_array($infos_CP['halfday'], array(0, -1))) return false;
if ($dateStart >= $infos_CP['date_debut'] && $dateStart <= $infos_CP['date_fin']) {
if ($dateStart < $infos_CP['date_fin'] || in_array($infos_CP['halfday'], array(0, -1))) {
return false;
}
}
if ($dateEnd <= $infos_CP['date_fin'] && $dateEnd >= $infos_CP['date_debut'])
{
if ($dateEnd > $infos_CP['date_debut'] || in_array($infos_CP['halfday'], array(0, 1))) return false;
if ($dateEnd <= $infos_CP['date_fin'] && $dateEnd >= $infos_CP['date_debut']) {
if ($dateEnd > $infos_CP['date_debut'] || in_array($infos_CP['halfday'], array(0, 1))) {
return false;
}
}
} else {
dol_print_error('', 'Bad value of parameter halfday when calling function verifDateHolidayCP');
@ -1123,18 +1121,17 @@ class Holiday extends CommonObject
$sql .= " WHERE cp.entity IN (".getEntity('holiday').")";
$sql .= " AND cp.fk_user = ".(int) $fk_user;
$sql .= " AND cp.date_debut <= '".$this->db->idate($timestamp)."' AND cp.date_fin >= '".$this->db->idate($timestamp)."'";
if ($status != '-1') $sql .= " AND cp.statut IN (".$this->db->sanitize($this->db->escape($status)).")";
if ($status != '-1') {
$sql .= " AND cp.statut IN (".$this->db->sanitize($this->db->escape($status)).")";
}
$resql = $this->db->query($sql);
if ($resql)
{
if ($resql) {
$num_rows = $this->db->num_rows($resql); // Note, we can have 2 records if on is morning and the other one is afternoon
if ($num_rows > 0)
{
if ($num_rows > 0) {
$arrayofrecord = array();
$i = 0;
while ($i < $num_rows)
{
while ($i < $num_rows) {
$obj = $this->db->fetch_object($resql);
// Note: $obj->halfday is 0:Full days, 2:Sart afternoon end morning, -1:Start afternoon, 1:End morning
@ -1144,27 +1141,39 @@ class Holiday extends CommonObject
// We found a record, user is on holiday by default, so is not available is true.
$isavailablemorning = true;
foreach ($arrayofrecord as $record)
{
if ($timestamp == $record['date_start'] && $record['halfday'] == 2) continue;
if ($timestamp == $record['date_start'] && $record['halfday'] == -1) continue;
foreach ($arrayofrecord as $record) {
if ($timestamp == $record['date_start'] && $record['halfday'] == 2) {
continue;
}
if ($timestamp == $record['date_start'] && $record['halfday'] == -1) {
continue;
}
$isavailablemorning = false;
break;
}
$isavailableafternoon = true;
foreach ($arrayofrecord as $record)
{
if ($timestamp == $record['date_end'] && $record['halfday'] == 2) continue;
if ($timestamp == $record['date_end'] && $record['halfday'] == 1) continue;
foreach ($arrayofrecord as $record) {
if ($timestamp == $record['date_end'] && $record['halfday'] == 2) {
continue;
}
if ($timestamp == $record['date_end'] && $record['halfday'] == 1) {
continue;
}
$isavailableafternoon = false;
break;
}
}
} else dol_print_error($this->db);
} else {
dol_print_error($this->db);
}
$result = array('morning'=>$isavailablemorning, 'afternoon'=>$isavailableafternoon);
if (!$isavailablemorning) $result['morning_reason'] = 'leave_request';
if (!$isavailableafternoon) $result['afternoon_reason'] = 'leave_request';
if (!$isavailablemorning) {
$result['morning_reason'] = 'leave_request';
}
if (!$isavailableafternoon) {
$result['afternoon_reason'] = 'leave_request';
}
return $result;
}
@ -1194,16 +1203,24 @@ class Holiday extends CommonObject
//{
// Add param to save lastsearch_values or not
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1;
if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1';
if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
$add_save_lastsearch_values = 1;
}
if ($add_save_lastsearch_values) {
$url .= '&save_lastsearch_values=1';
}
//}
$linkstart = '<a href="'.$url.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
$linkend = '</a>';
$result .= $linkstart;
if ($withpicto) $result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
if ($withpicto != 2) $result .= $this->ref;
if ($withpicto) {
$result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
}
if ($withpicto != 2) {
$result .= $this->ref;
}
$result .= $linkend;
return $result;
@ -1233,8 +1250,7 @@ class Holiday extends CommonObject
public function LibStatut($status, $mode = 0, $startdate = '')
{
// phpcs:enable
if (empty($this->labelStatus) || empty($this->labelStatusShort))
{
if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
global $langs;
//$langs->load("mymodule");
$this->labelStatus[self::STATUS_DRAFT] = $langs->trans('DraftCP');
@ -1250,11 +1266,21 @@ class Holiday extends CommonObject
}
$statusType = 'status6';
if (!empty($startdate) && $startdate > dol_now()) $statusType = 'status4';
if ($status == self::STATUS_DRAFT) $statusType = 'status0';
if ($status == self::STATUS_VALIDATED) $statusType = 'status1';
if ($status == self::STATUS_CANCELED) $statusType = 'status5';
if ($status == self::STATUS_REFUSED) $statusType = 'status5';
if (!empty($startdate) && $startdate > dol_now()) {
$statusType = 'status4';
}
if ($status == self::STATUS_DRAFT) {
$statusType = 'status0';
}
if ($status == self::STATUS_VALIDATED) {
$statusType = 'status1';
}
if ($status == self::STATUS_CANCELED) {
$statusType = 'status5';
}
if ($status == self::STATUS_REFUSED) {
$statusType = 'status5';
}
return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
}
@ -1338,15 +1364,12 @@ class Holiday extends CommonObject
if ($result) {
$obj = $this->db->fetch_object($result);
// Return value
if (empty($obj))
{
if ($createifnotfound)
{
if (empty($obj)) {
if ($createifnotfound) {
$sql = "INSERT INTO ".MAIN_DB_PREFIX."holiday_config(name, value)";
$sql .= " VALUES('".$this->db->escape($name)."', '".$this->db->escape($createifnotfound)."')";
$result = $this->db->query($sql);
if ($result)
{
if ($result) {
return $createifnotfound;
} else {
$this->error = $this->db->lasterror();
@ -1379,8 +1402,7 @@ class Holiday extends CommonObject
$error = 0;
if (empty($userID) && empty($nbHoliday) && empty($fk_type))
{
if (empty($userID) && empty($nbHoliday) && empty($fk_type)) {
$langs->load("holiday");
// Si mise à jour pour tout le monde en début de mois
@ -1395,8 +1417,7 @@ class Holiday extends CommonObject
//print 'month: '.$month.' lastUpdate:'.$lastUpdate.' monthLastUpdate:'.$monthLastUpdate;exit;
// Si la date du mois n'est pas la même que celle sauvegardée, on met à jour le timestamp
if ($month != $monthLastUpdate)
{
if ($month != $monthLastUpdate) {
$this->db->begin();
$users = $this->fetchUsers(false, false);
@ -1412,7 +1433,9 @@ class Holiday extends CommonObject
// Update each user counter
foreach ($users as $userCounter) {
$nbDaysToAdd = (isset($typeleaves[$userCounter['type']]['newByMonth']) ? $typeleaves[$userCounter['type']]['newByMonth'] : 0);
if (empty($nbDaysToAdd)) continue;
if (empty($nbDaysToAdd)) {
continue;
}
dol_syslog("We update leave type id ".$userCounter['type']." for user id ".$userCounter['rowid'], LOG_DEBUG);
@ -1424,15 +1447,13 @@ class Holiday extends CommonObject
$result = $this->updateSoldeCP($userCounter['rowid'], $newSolde, $userCounter['type'], $langs->trans('HolidaysMonthlyUpdate'));
if ($result < 0)
{
if ($result < 0) {
$error++;
break;
}
}
if (!$error)
{
if (!$error) {
$this->db->commit();
return 1;
} else {
@ -1449,19 +1470,16 @@ class Holiday extends CommonObject
$sql = "SELECT nb_holiday FROM ".MAIN_DB_PREFIX."holiday_users";
$sql .= " WHERE fk_user = ".(int) $userID." AND fk_type = ".(int) $fk_type;
$resql = $this->db->query($sql);
if ($resql)
{
if ($resql) {
$num = $this->db->num_rows($resql);
if ($num > 0)
{
if ($num > 0) {
// Update for user
$sql = "UPDATE ".MAIN_DB_PREFIX."holiday_users SET";
$sql .= " nb_holiday = ".$nbHoliday;
$sql .= " WHERE fk_user = ".(int) $userID." AND fk_type = ".(int) $fk_type;
$result = $this->db->query($sql);
if (!$result)
{
if (!$result) {
$error++;
$this->errors[] = $this->db->lasterror();
}
@ -1471,8 +1489,7 @@ class Holiday extends CommonObject
$sql .= $nbHoliday;
$sql .= ", ".(int) $userID.", ".(int) $fk_type.")";
$result = $this->db->query($sql);
if (!$result)
{
if (!$result) {
$error++;
$this->errors[] = $this->db->lasterror();
}
@ -1482,8 +1499,7 @@ class Holiday extends CommonObject
$error++;
}
if (!$error)
{
if (!$error) {
return 1;
} else {
return -1;
@ -1527,19 +1543,19 @@ class Holiday extends CommonObject
public function createCPusers($single = false, $userid = '')
{
// do we have to add balance for all users ?
if (!$single)
{
if (!$single) {
dol_syslog(get_class($this).'::createCPusers');
$arrayofusers = $this->fetchUsers(false, true);
foreach ($arrayofusers as $users)
{
foreach ($arrayofusers as $users) {
$sql = "INSERT INTO ".MAIN_DB_PREFIX."holiday_users";
$sql .= " (fk_user, nb_holiday)";
$sql .= " VALUES (".((int) $users['rowid'])."', '0')";
$resql = $this->db->query($sql);
if (!$resql) dol_print_error($this->db);
if (!$resql) {
dol_print_error($this->db);
}
}
} else {
$sql = "INSERT INTO ".MAIN_DB_PREFIX."holiday_users";
@ -1547,7 +1563,9 @@ class Holiday extends CommonObject
$sql .= " VALUES (".((int) $userid)."', '0')";
$resql = $this->db->query($sql);
if (!$resql) dol_print_error($this->db);
if (!$resql) {
dol_print_error($this->db);
}
}
}
@ -1579,16 +1597,20 @@ class Holiday extends CommonObject
$sql = "SELECT nb_holiday";
$sql .= " FROM ".MAIN_DB_PREFIX."holiday_users";
$sql .= " WHERE fk_user = ".(int) $user_id;
if ($fk_type > 0) $sql .= " AND fk_type = ".(int) $fk_type;
if ($fk_type > 0) {
$sql .= " AND fk_type = ".(int) $fk_type;
}
dol_syslog(get_class($this).'::getCPforUser user_id='.$user_id.' type_id='.$fk_type, LOG_DEBUG);
$result = $this->db->query($sql);
if ($result)
{
if ($result) {
$obj = $this->db->fetch_object($result);
//return number_format($obj->nb_holiday,2);
if ($obj) return $obj->nb_holiday;
else return null;
if ($obj) {
return $obj->nb_holiday;
} else {
return null;
}
} else {
return null;
}
@ -1608,10 +1630,8 @@ class Holiday extends CommonObject
dol_syslog(get_class($this)."::fetchUsers", LOG_DEBUG);
if ($stringlist)
{
if ($type)
{
if ($stringlist) {
if ($type) {
// If user of Dolibarr
$sql = "SELECT";
if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
@ -1620,8 +1640,7 @@ class Holiday extends CommonObject
$sql .= " u.rowid";
$sql .= " FROM ".MAIN_DB_PREFIX."user as u";
if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))
{
if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
$sql .= ", ".MAIN_DB_PREFIX."usergroup_user as ug";
$sql .= " WHERE ((ug.fk_user = u.rowid";
$sql .= " AND ug.entity IN (".getEntity('usergroup')."))";
@ -1630,7 +1649,9 @@ class Holiday extends CommonObject
$sql .= " WHERE u.entity IN (".getEntity('user').")";
}
$sql .= " AND u.statut > 0";
if ($filters) $sql .= $filters;
if ($filters) {
$sql .= $filters;
}
$resql = $this->db->query($sql);
@ -1641,8 +1662,7 @@ class Holiday extends CommonObject
$stringlist = '';
// Boucles du listage des utilisateurs
while ($i < $num)
{
while ($i < $num) {
$obj = $this->db->fetch_object($resql);
if ($i == 0) {
@ -1665,7 +1685,9 @@ class Holiday extends CommonObject
$sql = "SELECT DISTINCT cpu.fk_user";
$sql .= " FROM ".MAIN_DB_PREFIX."holiday_users as cpu, ".MAIN_DB_PREFIX."user as u";
$sql .= " WHERE cpu.fk_user = u.rowid";
if ($filters) $sql .= $filters;
if ($filters) {
$sql .= $filters;
}
$resql = $this->db->query($sql);
@ -1676,8 +1698,7 @@ class Holiday extends CommonObject
$stringlist = '';
// Boucles du listage des utilisateurs
while ($i < $num)
{
while ($i < $num) {
$obj = $this->db->fetch_object($resql);
if ($i == 0) {
@ -1699,8 +1720,7 @@ class Holiday extends CommonObject
} else {
// Si faux donc return array
// List for Dolibarr users
if ($type)
{
if ($type) {
// If user of Dolibarr
$sql = "SELECT";
if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
@ -1709,8 +1729,7 @@ class Holiday extends CommonObject
$sql .= " u.rowid, u.lastname, u.firstname, u.gender, u.photo, u.employee, u.statut, u.fk_user";
$sql .= " FROM ".MAIN_DB_PREFIX."user as u";
if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))
{
if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
$sql .= ", ".MAIN_DB_PREFIX."usergroup_user as ug";
$sql .= " WHERE ((ug.fk_user = u.rowid";
$sql .= " AND ug.entity IN (".getEntity('usergroup')."))";
@ -1720,13 +1739,14 @@ class Holiday extends CommonObject
}
$sql .= " AND u.statut > 0";
if ($filters) $sql .= $filters;
if ($filters) {
$sql .= $filters;
}
$resql = $this->db->query($sql);
// Si pas d'erreur SQL
if ($resql)
{
if ($resql) {
$i = 0;
$tab_result = $this->holiday;
$num = $this->db->num_rows($resql);
@ -1761,20 +1781,20 @@ class Holiday extends CommonObject
$sql = "SELECT cpu.fk_type, cpu.nb_holiday, u.rowid, u.lastname, u.firstname, u.gender, u.photo, u.employee, u.statut, u.fk_user";
$sql .= " FROM ".MAIN_DB_PREFIX."holiday_users as cpu, ".MAIN_DB_PREFIX."user as u";
$sql .= " WHERE cpu.fk_user = u.rowid";
if ($filters) $sql .= $filters;
if ($filters) {
$sql .= $filters;
}
$resql = $this->db->query($sql);
// Si pas d'erreur SQL
if ($resql)
{
if ($resql) {
$i = 0;
$tab_result = $this->holiday;
$num = $this->db->num_rows($resql);
// Boucles du listage des utilisateurs
while ($i < $num)
{
while ($i < $num) {
$obj = $this->db->fetch_object($resql);
$tab_result[$i]['rowid'] = $obj->rowid; // rowid of user
@ -1827,11 +1847,9 @@ class Holiday extends CommonObject
dol_syslog(get_class($this)."::fetch_users_approver_holiday sql=".$sql);
$result = $this->db->query($sql);
if ($result)
{
if ($result) {
$num_rows = $this->db->num_rows($result); $i = 0;
while ($i < $num_rows)
{
while ($i < $num_rows) {
$objp = $this->db->fetch_object($result);
array_push($users_validator, $objp->fk_user);
$i++;
@ -1888,7 +1906,9 @@ class Holiday extends CommonObject
*/
public function verifNbUsers($userDolibarrWithoutCP, $userCP)
{
if (empty($userCP)) $userCP = 0;
if (empty($userCP)) {
$userCP = 0;
}
dol_syslog(get_class($this).'::verifNbUsers userDolibarr='.$userDolibarrWithoutCP.' userCP='.$userCP);
return 1;
}
@ -1914,7 +1934,9 @@ class Holiday extends CommonObject
$new_solde = price2num($new_solde, 5);
//print "$prev_solde == $new_solde";
if ($prev_solde == $new_solde) return 0;
if ($prev_solde == $new_solde) {
return 0;
}
$this->db->begin();
@ -1938,21 +1960,17 @@ class Holiday extends CommonObject
$sql .= ")";
$resql = $this->db->query($sql);
if (!$resql)
{
if (!$resql) {
$error++; $this->errors[] = "Error ".$this->db->lasterror();
}
if (!$error)
{
if (!$error) {
$this->optRowid = $this->db->last_insert_id(MAIN_DB_PREFIX."holiday_logs");
}
// Commit or rollback
if ($error)
{
foreach ($this->errors as $errmsg)
{
if ($error) {
foreach ($this->errors as $errmsg) {
dol_syslog(get_class($this)."::addLogCP ".$errmsg, LOG_ERR);
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
}
@ -2051,23 +2069,26 @@ class Holiday extends CommonObject
$sql = "SELECT rowid, code, label, affect, delay, newByMonth";
$sql .= " FROM ".MAIN_DB_PREFIX."c_holiday_types";
$sql .= " WHERE (fk_country IS NULL OR fk_country = ".$mysoc->country_id.')';
if ($active >= 0) $sql .= " AND active = ".((int) $active);
if ($affect >= 0) $sql .= " AND affect = ".((int) $affect);
if ($active >= 0) {
$sql .= " AND active = ".((int) $active);
}
if ($affect >= 0) {
$sql .= " AND affect = ".((int) $affect);
}
$result = $this->db->query($sql);
if ($result)
{
if ($result) {
$num = $this->db->num_rows($result);
if ($num)
{
while ($obj = $this->db->fetch_object($result))
{
if ($num) {
while ($obj = $this->db->fetch_object($result)) {
$types[$obj->rowid] = array('rowid'=> $obj->rowid, 'code'=> $obj->code, 'label'=>$obj->label, 'affect'=>$obj->affect, 'delay'=>$obj->delay, 'newByMonth'=>$obj->newByMonth);
}
return $types;
}
} else dol_print_error($this->db);
} else {
dol_print_error($this->db);
}
return array();
}
@ -2099,10 +2120,8 @@ class Holiday extends CommonObject
$sql .= " AND f.entity = ".$conf->entity;
$resql = $this->db->query($sql);
if ($resql)
{
if ($this->db->num_rows($resql))
{
if ($resql) {
if ($this->db->num_rows($resql)) {
$obj = $this->db->fetch_object($resql);
$this->id = $obj->rowid;
@ -2116,26 +2135,22 @@ class Holiday extends CommonObject
$cuser->fetch($obj->fk_user_author);
$this->user_creation = $cuser;
if ($obj->fk_user_creation)
{
if ($obj->fk_user_creation) {
$cuser = new User($this->db);
$cuser->fetch($obj->fk_user_creation);
$this->user_creation = $cuser;
}
if ($obj->fk_user_valid)
{
if ($obj->fk_user_valid) {
$vuser = new User($this->db);
$vuser->fetch($obj->fk_user_valid);
$this->user_validation = $vuser;
}
if ($obj->fk_user_modification)
{
if ($obj->fk_user_modification) {
$muser = new User($this->db);
$muser->fetch($obj->fk_user_modification);
$this->user_modification = $muser;
}
if ($obj->fk_user_approve)
{
if ($obj->fk_user_approve) {
$auser = new User($this->db);
$auser->fetch($obj->fk_user_approve);
$this->user_approve = $auser;
@ -2191,8 +2206,7 @@ class Holiday extends CommonObject
$sql .= " FROM ".MAIN_DB_PREFIX."holiday as h";
$sql .= " WHERE h.statut > 1";
$sql .= " AND h.entity IN (".getEntity('holiday').")";
if (empty($user->rights->expensereport->readall))
{
if (empty($user->rights->expensereport->readall)) {
$userchildids = $user->getAllChildIds(1);
$sql .= " AND (h.fk_user IN (".join(',', $userchildids).")";
$sql .= " OR h.fk_validator IN (".join(',', $userchildids)."))";
@ -2224,7 +2238,9 @@ class Holiday extends CommonObject
// phpcs:enable
global $conf, $langs;
if ($user->socid) return -1; // protection pour eviter appel par utilisateur externe
if ($user->socid) {
return -1; // protection pour eviter appel par utilisateur externe
}
$now = dol_now();
@ -2232,16 +2248,14 @@ class Holiday extends CommonObject
$sql .= " FROM ".MAIN_DB_PREFIX."holiday as h";
$sql .= " WHERE h.statut = 2";
$sql .= " AND h.entity IN (".getEntity('holiday').")";
if (empty($user->rights->expensereport->read_all))
{
if (empty($user->rights->expensereport->read_all)) {
$userchildids = $user->getAllChildIds(1);
$sql .= " AND (h.fk_user IN (".join(',', $userchildids).")";
$sql .= " OR h.fk_validator IN (".join(',', $userchildids)."))";
}
$resql = $this->db->query($sql);
if ($resql)
{
if ($resql) {
$langs->load("members");
$response = new WorkboardResponse();
@ -2251,8 +2265,7 @@ class Holiday extends CommonObject
$response->url = DOL_URL_ROOT.'/holiday/list.php?search_statut=2&amp;mainmenu=hrm&amp;leftmenu=holiday';
$response->img = img_object('', "holiday");
while ($obj = $this->db->fetch_object($resql))
{
while ($obj = $this->db->fetch_object($resql)) {
$response->nbtodo++;
if ($this->db->jdate($obj->date_debut) < ($now - $conf->holiday->approve->warning_delay)) {

View File

@ -44,19 +44,29 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
if (empty($page) || $page == -1) {
$page = 0;
} // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (!$sortfield) $sortfield = "t.rowid"; // Set here default search field
if (!$sortorder) $sortorder = "ASC";
if (!$sortfield) {
$sortfield = "t.rowid"; // Set here default search field
}
if (!$sortorder) {
$sortorder = "ASC";
}
// Protection if external user
if ($user->socid > 0) accessforbidden();
if ($user->socid > 0) {
accessforbidden();
}
// If the user does not have perm to read the page
if (empty($user->rights->holiday->read)) accessforbidden();
if (empty($user->rights->holiday->read)) {
accessforbidden();
}
// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array
@ -65,8 +75,7 @@ $extrafields = new ExtraFields($db);
$holiday = new Holiday($db);
if (empty($conf->holiday->enabled))
{
if (empty($conf->holiday->enabled)) {
llxHeader('', $langs->trans('CPTitreMenu'));
print '<div class="tabBar">';
print '<span style="color: #FF0000;">'.$langs->trans('NotActiveModCP').'</span>';
@ -81,21 +90,25 @@ if (empty($conf->holiday->enabled))
* Actions
*/
if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; }
if (GETPOST('cancel', 'alpha')) {
$action = 'list'; $massaction = '';
}
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
$massaction = '';
}
$parameters = array();
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if (empty($reshook))
{
if (empty($reshook)) {
// Selection of new fields
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
// Purge search criteria
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers
{
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
$search_name = '';
$search_supervisor = '';
$toselect = '';
@ -104,17 +117,16 @@ if (empty($reshook))
// Mass actions
/*
$objectclass='Skeleton';
$objectlabel='Skeleton';
$permissiontoread = $user->rights->skeleton->read;
$permissiontodelete = $user->rights->skeleton->delete;
$uploaddir = $conf->skeleton->dir_output;
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
*/
$objectclass='Skeleton';
$objectlabel='Skeleton';
$permissiontoread = $user->rights->skeleton->read;
$permissiontodelete = $user->rights->skeleton->delete;
$uploaddir = $conf->skeleton->dir_output;
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
*/
// Si il y a une action de mise à jour
if ($action == 'update' && isset($_POST['update_cp']))
{
if ($action == 'update' && isset($_POST['update_cp'])) {
$error = 0;
$typeleaves = $holiday->getTypes(1, 1);
@ -122,13 +134,11 @@ if (empty($reshook))
$userID = array_keys($_POST['update_cp']);
$userID = $userID[0];
foreach ($typeleaves as $key => $val)
{
foreach ($typeleaves as $key => $val) {
$userValue = $_POST['nb_holiday_'.$val['rowid']];
$userValue = $userValue[$userID];
if (!empty($userValue) || (string) $userValue == '0')
{
if (!empty($userValue) || (string) $userValue == '0') {
$userValue = price2num($userValue, 5);
} else {
$userValue = '';
@ -138,37 +148,36 @@ if (empty($reshook))
$comment = ((isset($_POST['note_holiday'][$userID]) && !empty($_POST['note_holiday'][$userID])) ? ' ('.$_POST['note_holiday'][$userID].')' : '');
//print 'holiday: '.$val['rowid'].'-'.$userValue;
if ($userValue != '')
{
if ($userValue != '') {
// We add the modification to the log (must be before update of sold because we read current value of sold)
$result = $holiday->addLogCP($user->id, $userID, $langs->transnoentitiesnoconv('ManualUpdate').$comment, $userValue, $val['rowid']);
if ($result < 0)
{
if ($result < 0) {
setEventMessages($holiday->error, $holiday->errors, 'errors');
$error++;
}
// Update of the days of the employee
$result = $holiday->updateSoldeCP($userID, $userValue, $val['rowid']);
if ($result < 0)
{
if ($result < 0) {
setEventMessages($holiday->error, $holiday->errors, 'errors');
$error++;
}
// If it first update of balance, we set date to avoid to have sold incremented by new month
/*
$now=dol_now();
$sql = "UPDATE ".MAIN_DB_PREFIX."holiday_config SET";
$sql.= " value = '".dol_print_date($now,'%Y%m%d%H%M%S')."'";
$sql.= " WHERE name = 'lastUpdate' and value IS NULL"; // Add value IS NULL to be sure to update only at init.
dol_syslog('define_holiday update lastUpdate entry', LOG_DEBUG);
$result = $db->query($sql);
*/
$now=dol_now();
$sql = "UPDATE ".MAIN_DB_PREFIX."holiday_config SET";
$sql.= " value = '".dol_print_date($now,'%Y%m%d%H%M%S')."'";
$sql.= " WHERE name = 'lastUpdate' and value IS NULL"; // Add value IS NULL to be sure to update only at init.
dol_syslog('define_holiday update lastUpdate entry', LOG_DEBUG);
$result = $db->query($sql);
*/
}
}
if (!$error) setEventMessages('UpdateConfCPOK', '', 'mesgs');
if (!$error) {
setEventMessages('UpdateConfCPOK', '', 'mesgs');
}
}
}
@ -191,7 +200,9 @@ if ($result < 0) {
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
if ($optioncss != '') {
print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
}
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="action" value="update">';
@ -217,35 +228,36 @@ $filters = '';
// Filter on array of ids of all childs
$userchilds = array();
if (empty($user->rights->holiday->readall))
{
if (empty($user->rights->holiday->readall)) {
$userchilds = $user->getAllChildIds(1);
$filters .= ' AND u.rowid IN ('.join(', ', $userchilds).')';
}
if (!empty($search_name)) {
$filters .= natural_search(array('u.firstname', 'u.lastname'), $search_name);
}
if ($search_supervisor > 0) $filters .= natural_search(array('u.fk_user'), $search_supervisor, 2);
if ($search_supervisor > 0) {
$filters .= natural_search(array('u.fk_user'), $search_supervisor, 2);
}
$filters .= ' AND employee = 1'; // Only employee users are visible
$listUsers = $holiday->fetchUsers(false, true, $filters);
if (is_numeric($listUsers) && $listUsers < 0)
{
if (is_numeric($listUsers) && $listUsers < 0) {
setEventMessages($holiday->error, $holiday->errors, 'errors');
}
$i = 0;
if (count($typeleaves) == 0)
{
if (count($typeleaves) == 0) {
//print '<div class="info">';
print $langs->trans("NoLeaveWithCounterDefined")."<br>\n";
print $langs->trans("GoIntoDictionaryHolidayTypes");
//print '</div>';
} else {
$canedit = 0;
if (!empty($user->rights->holiday->define_holiday)) $canedit = 1;
if (!empty($user->rights->holiday->define_holiday)) {
$canedit = 1;
}
$moreforfilter = '';
@ -263,10 +275,8 @@ if (count($typeleaves) == 0)
print '</td>';
// Type of leave request
if (count($typeleaves))
{
foreach ($typeleaves as $key => $val)
{
if (count($typeleaves)) {
foreach ($typeleaves as $key => $val) {
print '<td class="liste_titre" style="text-align:center"></td>';
}
} else {
@ -285,10 +295,8 @@ if (count($typeleaves) == 0)
print '<tr class="liste_titre">';
print_liste_field_titre('Employee', $_SERVER["PHP_SELF"]);
print_liste_field_titre('Supervisor', $_SERVER["PHP_SELF"]);
if (count($typeleaves))
{
foreach ($typeleaves as $key => $val)
{
if (count($typeleaves)) {
foreach ($typeleaves as $key => $val) {
$labeltype = ($langs->trans($val['code']) != $val['code']) ? $langs->trans($val['code']) : $langs->trans($val['label']);
print_liste_field_titre($labeltype, $_SERVER["PHP_SELF"], '', '', '', '', '', '', 'center ');
}
@ -301,12 +309,12 @@ if (count($typeleaves) == 0)
$usersupervisor = new User($db);
foreach ($listUsers as $users)
{
foreach ($listUsers as $users) {
// If user has not permission to edit/read all, we must see only subordinates
if (empty($user->rights->holiday->readall))
{
if (($users['rowid'] != $user->id) && (!in_array($users['rowid'], $userchilds))) continue; // This user is not into hierarchy of current user, we hide it.
if (empty($user->rights->holiday->readall)) {
if (($users['rowid'] != $user->id) && (!in_array($users['rowid'], $userchilds))) {
continue; // This user is not into hierarchy of current user, we hide it.
}
}
$userstatic->id = $users['rowid'];
@ -318,7 +326,9 @@ if (count($typeleaves) == 0)
$userstatic->employee = $users['employee'];
$userstatic->fk_user = $users['fk_user'];
if ($userstatic->fk_user > 0) $usersupervisor->fetch($userstatic->fk_user);
if ($userstatic->fk_user > 0) {
$usersupervisor->fetch($userstatic->fk_user);
}
print '<tr class="oddeven">';
@ -329,21 +339,26 @@ if (count($typeleaves) == 0)
// Supervisor
print '<td>';
if ($userstatic->fk_user > 0) print $usersupervisor->getNomUrl(-1);
if ($userstatic->fk_user > 0) {
print $usersupervisor->getNomUrl(-1);
}
print '</td>';
// Amount for each type
if (count($typeleaves))
{
foreach ($typeleaves as $key => $val)
{
if (count($typeleaves)) {
foreach ($typeleaves as $key => $val) {
$nbtoshow = '';
if ($holiday->getCPforUser($users['rowid'], $val['rowid']) != '') $nbtoshow = price2num($holiday->getCPforUser($users['rowid'], $val['rowid']), 5);
if ($holiday->getCPforUser($users['rowid'], $val['rowid']) != '') {
$nbtoshow = price2num($holiday->getCPforUser($users['rowid'], $val['rowid']), 5);
}
//var_dump($users['rowid'].' - '.$val['rowid']);
print '<td style="text-align:center">';
if ($canedit) print '<input type="text"'.($canedit ? '' : ' disabled="disabled"').' value="'.$nbtoshow.'" name="nb_holiday_'.$val['rowid'].'['.$users['rowid'].']" size="5" style="text-align: center;"/>';
else print $nbtoshow;
if ($canedit) {
print '<input type="text"'.($canedit ? '' : ' disabled="disabled"').' value="'.$nbtoshow.'" name="nb_holiday_'.$val['rowid'].'['.$users['rowid'].']" size="5" style="text-align: center;"/>';
} else {
print $nbtoshow;
}
//print ' '.$langs->trans('days');
print '</td>'."\n";
}
@ -353,13 +368,14 @@ if (count($typeleaves) == 0)
// Note
print '<td>';
if ($canedit) print '<input type="text"'.($canedit ? '' : ' disabled="disabled"').' class="maxwidthonsmartphone" value="" name="note_holiday['.$users['rowid'].']" size="30"/>';
if ($canedit) {
print '<input type="text"'.($canedit ? '' : ' disabled="disabled"').' class="maxwidthonsmartphone" value="" name="note_holiday['.$users['rowid'].']" size="30"/>';
}
print '</td>';
// Button modify
print '<td>';
if (!empty($user->rights->holiday->define_holiday)) // Allowed to set the balance of any user
{
if (!empty($user->rights->holiday->define_holiday)) { // Allowed to set the balance of any user
print '<input type="submit" name="update_cp['.$users['rowid'].']" value="'.dol_escape_htmltag($langs->trans("Save")).'" class="button smallpaddingimp"/>';
}
print '</td>'."\n";

View File

@ -45,7 +45,9 @@ $action = GETPOST('action', 'aZ09');
$confirm = GETPOST('confirm', 'alpha');
// Security check
if ($user->socid) $socid = $user->socid;
if ($user->socid) {
$socid = $user->socid;
}
$result = restrictedArea($user, 'holiday', $id, 'holiday');
// Get parameters
@ -53,12 +55,18 @@ $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
if (empty($page) || $page == -1) {
$page = 0;
} // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (!$sortorder) $sortorder = "ASC";
if (!$sortfield) $sortfield = "position_name";
if (!$sortorder) {
$sortorder = "ASC";
}
if (!$sortfield) {
$sortfield = "position_name";
}
$object = new Holiday($db);
@ -86,8 +94,7 @@ $listhalfday = array('morning'=>$langs->trans("Morning"), "afternoon"=>$langs->t
llxHeader("", "", $langs->trans("InterventionCard"));
if ($object->id)
{
if ($object->id) {
$valideur = new User($db);
$valideur->fetch($object->fk_validator);
@ -102,8 +109,7 @@ if ($object->id)
// Build file list
$filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1);
$totalsize = 0;
foreach ($filearray as $key => $file)
{
foreach ($filearray as $key => $file) {
$totalsize += $file['size'];
}
@ -138,8 +144,7 @@ if ($object->id)
$starthalfday = ($object->halfday == -1 || $object->halfday == 2) ? 'afternoon' : 'morning';
$endhalfday = ($object->halfday == 1 || $object->halfday == 2) ? 'morning' : 'afternoon';
if (!$edit)
{
if (!$edit) {
print '<tr>';
print '<td>';
print $form->textwithpicto($langs->trans('DateDebCP'), $langs->trans("FirstDayOfHoliday"));
@ -162,8 +167,7 @@ if ($object->id)
print '</tr>';
}
if (!$edit)
{
if (!$edit) {
print '<tr>';
print '<td>';
print $form->textwithpicto($langs->trans('DateFinCP'), $langs->trans("LastDayOfHoliday"));
@ -192,15 +196,18 @@ if ($object->id)
$htmlhelp = $langs->trans('NbUseDaysCPHelp');
$includesaturday = (isset($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY) ? $conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY : 1);
$includesunday = (isset($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY) ? $conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY : 1);
if ($includesaturday) $htmlhelp .= '<br>'.$langs->trans("DayIsANonWorkingDay", $langs->trans("Saturday"));
if ($includesunday) $htmlhelp .= '<br>'.$langs->trans("DayIsANonWorkingDay", $langs->trans("Sunday"));
if ($includesaturday) {
$htmlhelp .= '<br>'.$langs->trans("DayIsANonWorkingDay", $langs->trans("Saturday"));
}
if ($includesunday) {
$htmlhelp .= '<br>'.$langs->trans("DayIsANonWorkingDay", $langs->trans("Sunday"));
}
print $form->textwithpicto($langs->trans('NbUseDaysCP'), $htmlhelp);
print '</td>';
print '<td>'.num_open_day($object->date_debut_gmt, $object->date_fin_gmt, 0, 1, $object->halfday).'</td>';
print '</tr>';
if ($object->statut == 5)
{
if ($object->statut == 5) {
print '<tr>';
print '<td>'.$langs->trans('DetailRefusCP').'</td>';
print '<td>'.$object->detail_refuse.'</td>';
@ -208,8 +215,7 @@ if ($object->id)
}
// Description
if (!$edit)
{
if (!$edit) {
print '<tr>';
print '<td>'.$langs->trans('DescCP').'</td>';
print '<td>'.nl2br($object->description).'</td>';
@ -227,67 +233,67 @@ if ($object->id)
print '</tbody>';
print '</table>'."\n";
/*
print '</div>';
print '<div class="fichehalfright">';
print '<div class="ficheaddleft">';
print '</div>';
print '<div class="fichehalfright">';
print '<div class="ficheaddleft">';
print '<div class="underbanner clearboth"></div>';
print '<div class="underbanner clearboth"></div>';
// Info workflow
print '<table class="border tableforfield centpercent">'."\n";
print '<tbody>';
print '<table class="border tableforfield centpercent">'."\n";
print '<tbody>';
if (! empty($object->fk_user_create))
{
$userCreate=new User($db);
$userCreate->fetch($object->fk_user_create);
print '<tr>';
print '<td class="titlefield">'.$langs->trans('RequestByCP').'</td>';
print '<td>'.$userCreate->getNomUrl(-1).'</td>';
print '</tr>';
}
if (! empty($object->fk_user_create))
{
$userCreate=new User($db);
$userCreate->fetch($object->fk_user_create);
print '<tr>';
print '<td class="titlefield">'.$langs->trans('RequestByCP').'</td>';
print '<td>'.$userCreate->getNomUrl(-1).'</td>';
print '</tr>';
}
if (!$edit) {
print '<tr>';
print '<td class="titlefield">'.$langs->trans('ReviewedByCP').'</td>';
print '<td>'.$valideur->getNomUrl(-1).'</td>';
print '</tr>';
} else {
print '<tr>';
print '<td class="titlefield">'.$langs->trans('ReviewedByCP').'</td>';
print '<td>';
if (!$edit) {
print '<tr>';
print '<td class="titlefield">'.$langs->trans('ReviewedByCP').'</td>';
print '<td>'.$valideur->getNomUrl(-1).'</td>';
print '</tr>';
} else {
print '<tr>';
print '<td class="titlefield">'.$langs->trans('ReviewedByCP').'</td>';
print '<td>';
print $form->select_dolusers($object->fk_user, "valideur", 1, ($user->admin ? '' : array($user->id))); // By default, hierarchical parent
print '</td>';
print '</tr>';
}
print '</td>';
print '</tr>';
}
print '<tr>';
print '<td>'.$langs->trans('DateCreation').'</td>';
print '<td>'.dol_print_date($object->date_create,'dayhour').'</td>';
print '</tr>';
if ($object->statut == 3) {
print '<tr>';
print '<td>'.$langs->trans('DateValidCP').'</td>';
print '<td>'.dol_print_date($object->date_valid,'dayhour').'</td>';
print '</tr>';
}
if ($object->statut == 4) {
print '<tr>';
print '<td>'.$langs->trans('DateCancelCP').'</td>';
print '<td>'.dol_print_date($object->date_cancel,'dayhour').'</td>';
print '</tr>';
}
if ($object->statut == 5) {
print '<tr>';
print '<td>'.$langs->trans('DateRefusCP').'</td>';
print '<td>'.dol_print_date($object->date_refuse,'dayhour').'</td>';
print '</tr>';
}
print '</tbody>';
print '</table>';
print '<tr>';
print '<td>'.$langs->trans('DateCreation').'</td>';
print '<td>'.dol_print_date($object->date_create,'dayhour').'</td>';
print '</tr>';
if ($object->statut == 3) {
print '<tr>';
print '<td>'.$langs->trans('DateValidCP').'</td>';
print '<td>'.dol_print_date($object->date_valid,'dayhour').'</td>';
print '</tr>';
}
if ($object->statut == 4) {
print '<tr>';
print '<td>'.$langs->trans('DateCancelCP').'</td>';
print '<td>'.dol_print_date($object->date_cancel,'dayhour').'</td>';
print '</tr>';
}
if ($object->statut == 5) {
print '<tr>';
print '<td>'.$langs->trans('DateRefusCP').'</td>';
print '<td>'.dol_print_date($object->date_refuse,'dayhour').'</td>';
print '</tr>';
}
print '</tbody>';
print '</table>';
print '</div>';
print '</div>'; */
print '</div>';
print '</div>'; */
print '</div>';
print '<div class="clearboth"></div>';

View File

@ -37,23 +37,26 @@ $ref = GETPOST('ref', 'alpha');
$childids = $user->getAllChildIds(1);
// Security check
if ($user->socid) $socid = $user->socid;
if ($user->socid) {
$socid = $user->socid;
}
$result = restrictedArea($user, 'holiday', $id, 'holiday');
$object = new Holiday($db);
if (!$object->fetch($id, $ref) > 0)
{
if (!$object->fetch($id, $ref) > 0) {
dol_print_error($db);
}
if ($object->id > 0)
{
if ($object->id > 0) {
// Check current user can read this expense report
$canread = 0;
if (!empty($user->rights->holiday->readall)) $canread = 1;
if (!empty($user->rights->holiday->lire) && in_array($object->fk_user_author, $childids)) $canread = 1;
if (!$canread)
{
if (!empty($user->rights->holiday->readall)) {
$canread = 1;
}
if (!empty($user->rights->holiday->lire) && in_array($object->fk_user_author, $childids)) {
$canread = 1;
}
if (!$canread) {
accessforbidden();
}
}
@ -69,8 +72,7 @@ $title = $langs->trans("Holiday")." - ".$langs->trans("Info");
$helpurl = "";
llxHeader("", $title, $helpurl);
if ($id > 0 || !empty($ref))
{
if ($id > 0 || !empty($ref)) {
$object = new Holiday($db);
$object->fetch($id, $ref);
$object->info($object->id);

View File

@ -40,7 +40,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php';
$langs->loadLangs(array('users', 'other', 'holiday', 'hrm'));
// Protection if external user
if ($user->socid > 0) accessforbidden();
if ($user->socid > 0) {
accessforbidden();
}
$action = GETPOST('action', 'aZ09'); // The action 'add', 'create', 'edit', 'update', 'view', ...
$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
@ -59,21 +61,24 @@ $childids = $user->getAllChildIds(1);
// Security check
$socid = 0;
if ($user->socid > 0) // Protection if external user
{
if ($user->socid > 0) { // Protection if external user
//$socid = $user->socid;
accessforbidden();
}
$result = restrictedArea($user, 'holiday', '', '');
// If we are on the view of a specific user
if ($id > 0)
{
if ($id > 0) {
$canread = 0;
if ($id == $user->id) $canread = 1;
if (!empty($user->rights->holiday->readall)) $canread = 1;
if (!empty($user->rights->holiday->read) && in_array($id, $childids)) $canread = 1;
if (!$canread)
{
if ($id == $user->id) {
$canread = 1;
}
if (!empty($user->rights->holiday->readall)) {
$canread = 1;
}
if (!empty($user->rights->holiday->read) && in_array($id, $childids)) {
$canread = 1;
}
if (!$canread) {
accessforbidden();
}
}
@ -86,12 +91,18 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
if (empty($page) || $page == -1) {
$page = 0;
} // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (!$sortorder) $sortorder = "DESC";
if (!$sortfield) $sortfield = "cp.rowid";
if (!$sortorder) {
$sortorder = "DESC";
}
if (!$sortfield) {
$sortfield = "cp.rowid";
}
$sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'));
$search_ref = GETPOST('search_ref', 'alphanohtml');
@ -145,8 +156,7 @@ $arrayfields = array(
// Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
if (empty($conf->holiday->enabled))
{
if (empty($conf->holiday->enabled)) {
llxHeader('', $langs->trans('CPTitreMenu'));
print '<div class="tabBar">';
print '<span style="color: #FF0000;">'.$langs->trans('NotActiveModCP').'</span>';
@ -160,21 +170,25 @@ if (empty($conf->holiday->enabled))
* Actions
*/
if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; }
if (GETPOST('cancel', 'alpha')) {
$action = 'list'; $massaction = '';
}
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
$massaction = '';
}
$parameters = array('socid'=>$socid);
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if (empty($reshook))
{
if (empty($reshook)) {
// Selection of new fields
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
// Purge search criteria
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers
{
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
$search_ref = "";
$search_month_create = "";
$search_year_create = "";
@ -190,8 +204,7 @@ if (empty($reshook))
$search_array_options = array();
}
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
|| GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha'))
{
|| GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) {
$massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
}
@ -230,8 +243,7 @@ $min_year = 10;
// Get current user id
$user_id = $user->id;
if ($id > 0)
{
if ($id > 0) {
// Charge utilisateur edite
$fuser->fetch($id, '', '', 1);
$fuser->getrights();
@ -282,21 +294,29 @@ $sql .= " ua.statut as validator_status,";
$sql .= " ua.photo as validator_photo";
// Add fields from extrafields
if (!empty($extrafields->attributes[$object->table_element]['label'])) {
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : '');
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
$sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : '');
}
}
// Add fields from hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager->resPrint;
$sql .= " FROM ".MAIN_DB_PREFIX."holiday as cp";
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (cp.rowid = ef.fk_object)";
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (cp.rowid = ef.fk_object)";
}
$sql .= ", ".MAIN_DB_PREFIX."user as uu, ".MAIN_DB_PREFIX."user as ua";
$sql .= " WHERE cp.entity IN (".getEntity('holiday').")";
$sql .= " AND cp.fk_user = uu.rowid AND cp.fk_validator = ua.rowid "; // Hack pour la recherche sur le tableau
// Search all
if (!empty($sall)) $sql .= natural_search(array_keys($fieldstosearchall), $sall);
if (!empty($sall)) {
$sql .= natural_search(array_keys($fieldstosearchall), $sall);
}
// Ref
if (!empty($search_ref)) $sql .= natural_search("cp.ref", $search_ref);
if (!empty($search_ref)) {
$sql .= natural_search("cp.ref", $search_ref);
}
// Start date
$sql .= dolSqlDateFilter("cp.date_debut", $search_day_start, $search_month_start, $search_year_start);
// End date
@ -320,8 +340,12 @@ if (!empty($search_status) && $search_status != -1) {
$sql .= " AND cp.statut = '".$db->escape($search_status)."'\n";
}
if (empty($user->rights->holiday->readall)) $sql .= ' AND cp.fk_user IN ('.join(',', $childids).')';
if ($id > 0) $sql .= " AND cp.fk_user IN (".$id.")";
if (empty($user->rights->holiday->readall)) {
$sql .= ' AND cp.fk_user IN ('.join(',', $childids).')';
}
if ($id > 0) {
$sql .= " AND cp.fk_user IN (".$id.")";
}
// Add where from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
@ -334,12 +358,10 @@ $sql .= $db->order($sortfield, $sortorder);
// Count total nb of records
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
$result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result);
if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
{
if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
$page = 0;
$offset = 0;
}
@ -350,30 +372,63 @@ $sql .= $db->plimit($limit + 1, $offset);
//print $sql;
$resql = $db->query($sql);
if ($resql)
{
if ($resql) {
$num = $db->num_rows($resql);
$arrayofselected = is_array($toselect) ? $toselect : array();
$param = '';
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
if ($search_ref) $param .= '&search_ref='.urlencode($search_ref);
if ($search_day_create) $param .= '&search_day_create='.urlencode($search_day_create);
if ($search_month_create) $param .= '&search_month_create='.urlencode($search_month_create);
if ($search_year_create) $param .= '&search_year_create='.urlencode($search_year_create);
if ($search_day_start) $param .= '&search_day_start='.urlencode($search_day_start);
if ($search_month_start) $param .= '&search_month_start='.urlencode($search_month_start);
if ($search_year_start) $param .= '&search_year_start='.urlencode($search_year_start);
if ($search_day_end) $param .= '&search_day_end='.urlencode($search_day_end);
if ($search_month_end) $param .= '&search_month_end='.urlencode($search_month_end);
if ($search_year_end) $param .= '&search_year_end='.urlencode($search_year_end);
if ($search_employee > 0) $param .= '&search_employee='.urlencode($search_employee);
if ($search_valideur > 0) $param .= '&search_valideur='.urlencode($search_valideur);
if ($search_type > 0) $param .= '&search_type='.urlencode($search_type);
if ($search_status > 0) $param .= '&search_status='.urlencode($search_status);
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
$param .= '&contextpage='.urlencode($contextpage);
}
if ($limit > 0 && $limit != $conf->liste_limit) {
$param .= '&limit='.urlencode($limit);
}
if ($optioncss != '') {
$param .= '&optioncss='.urlencode($optioncss);
}
if ($search_ref) {
$param .= '&search_ref='.urlencode($search_ref);
}
if ($search_day_create) {
$param .= '&search_day_create='.urlencode($search_day_create);
}
if ($search_month_create) {
$param .= '&search_month_create='.urlencode($search_month_create);
}
if ($search_year_create) {
$param .= '&search_year_create='.urlencode($search_year_create);
}
if ($search_day_start) {
$param .= '&search_day_start='.urlencode($search_day_start);
}
if ($search_month_start) {
$param .= '&search_month_start='.urlencode($search_month_start);
}
if ($search_year_start) {
$param .= '&search_year_start='.urlencode($search_year_start);
}
if ($search_day_end) {
$param .= '&search_day_end='.urlencode($search_day_end);
}
if ($search_month_end) {
$param .= '&search_month_end='.urlencode($search_month_end);
}
if ($search_year_end) {
$param .= '&search_year_end='.urlencode($search_year_end);
}
if ($search_employee > 0) {
$param .= '&search_employee='.urlencode($search_employee);
}
if ($search_valideur > 0) {
$param .= '&search_valideur='.urlencode($search_valideur);
}
if ($search_type > 0) {
$param .= '&search_type='.urlencode($search_type);
}
if ($search_status > 0) {
$param .= '&search_status='.urlencode($search_status);
}
// Add $param from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
@ -383,23 +438,30 @@ if ($resql)
//'builddoc'=>$langs->trans("PDFMerge"),
//'presend'=>$langs->trans("SendByMail"),
);
if ($user->rights->holiday->supprimer) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array();
if ($user->rights->holiday->supprimer) {
$arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
}
if (in_array($massaction, array('presend', 'predelete'))) {
$arrayofmassactions = array();
}
$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
// Lines of title fields
print '<form id="searchFormList" action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n";
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
if ($optioncss != '') {
print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
}
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="action" value="'.($action == 'edit' ? 'update' : 'list').'">';
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
if ($id > 0) print '<input type="hidden" name="id" value="'.$id.'">';
if ($id > 0) {
print '<input type="hidden" name="id" value="'.$id.'">';
}
if ($id > 0) // For user tab
{
if ($id > 0) { // For user tab
$title = $langs->trans("User");
$linkback = '<a href="'.DOL_URL_ROOT.'/user/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
$head = user_prepare_head($fuser);
@ -408,8 +470,7 @@ if ($resql)
dol_banner_tab($fuser, 'id', $linkback, $user->rights->user->user->lire || $user->admin);
if (empty($conf->global->HOLIDAY_HIDE_BALANCE))
{
if (empty($conf->global->HOLIDAY_HIDE_BALANCE)) {
print '<div class="underbanner clearboth"></div>';
print '<br>';
@ -425,8 +486,7 @@ if ($resql)
$canedit = (($user->id == $user_id && $user->rights->holiday->write) || ($user->id != $user_id && (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->holiday->writeall_advance))));
if ($canedit)
{
if ($canedit) {
print '<a href="'.DOL_URL_ROOT.'/holiday/card.php?action=create&fuserid='.$user_id.'" class="butAction">'.$langs->trans("AddCP").'</a>';
}
@ -445,9 +505,10 @@ if ($resql)
$trackid = 'leav'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
if ($sall)
{
foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val);
if ($sall) {
foreach ($fieldstosearchall as $key => $val) {
$fieldstosearchall[$key] = $langs->trans($val);
}
print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'</div>';
}
@ -455,11 +516,13 @@ if ($resql)
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint;
else $moreforfilter = $hookmanager->resPrint;
if (empty($reshook)) {
$moreforfilter .= $hookmanager->resPrint;
} else {
$moreforfilter = $hookmanager->resPrint;
}
if (!empty($moreforfilter))
{
if (!empty($moreforfilter)) {
print '<div class="liste_titre liste_titre_bydiv centpercent">';
print $moreforfilter;
print '</div>';
@ -471,7 +534,9 @@ if ($resql)
$include = '';
if (empty($user->rights->holiday->readall)) $include = 'hierarchyme'; // Can see only its hierarchyl
if (empty($user->rights->holiday->readall)) {
$include = 'hierarchyme'; // Can see only its hierarchyl
}
print '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
@ -480,23 +545,22 @@ if ($resql)
// Filters
print '<tr class="liste_titre_filter">';
if (!empty($arrayfields['cp.ref']['checked']))
{
if (!empty($arrayfields['cp.ref']['checked'])) {
print '<td class="liste_titre">';
print '<input class="flat maxwidth50" type="text" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
print '</td>';
}
if (!empty($arrayfields['cp.fk_user']['checked']))
{
if (!empty($arrayfields['cp.fk_user']['checked'])) {
$morefilter = '';
if (!empty($conf->global->HOLIDAY_HIDE_FOR_NON_SALARIES)) $morefilter = 'AND employee = 1';
if (!empty($conf->global->HOLIDAY_HIDE_FOR_NON_SALARIES)) {
$morefilter = 'AND employee = 1';
}
// User
$disabled = 0;
// If into the tab holiday of a user ($id is set in such a case)
if ($id && !GETPOSTISSET('search_employee'))
{
if ($id && !GETPOSTISSET('search_employee')) {
$search_employee = $id;
$disabled = 1;
}
@ -507,16 +571,16 @@ if ($resql)
}
// Approver
if (!empty($arrayfields['cp.fk_validator']['checked']))
{
if ($user->rights->holiday->readall)
{
if (!empty($arrayfields['cp.fk_validator']['checked'])) {
if ($user->rights->holiday->readall) {
print '<td class="liste_titre maxwidthonsmartphone left">';
$validator = new UserGroup($db);
$excludefilter = $user->admin ? '' : 'u.rowid <> '.$user->id;
$valideurobjects = $validator->listUsersForGroup($excludefilter);
$valideurarray = array();
foreach ($valideurobjects as $val) $valideurarray[$val->id] = $val->id;
foreach ($valideurobjects as $val) {
$valideurarray[$val->id] = $val->id;
}
print $form->select_dolusers($search_valideur, "search_valideur", 1, "", 0, $valideurarray, '', 0, 0, 0, $morefilter, 0, '', 'maxwidth150');
print '</td>';
} else {
@ -525,16 +589,14 @@ if ($resql)
}
// Type
if (!empty($arrayfields['cp.fk_type']['checked']))
{
if (!empty($arrayfields['cp.fk_type']['checked'])) {
print '<td class="liste_titre">';
if (empty($mysoc->country_id)) {
setEventMessages(null, array($langs->trans("ErrorSetACountryFirst"), $langs->trans("CompanyFoundation")), 'errors');
} else {
$typeleaves = $holidaystatic->getTypes(1, -1);
$arraytypeleaves = array();
foreach ($typeleaves as $key => $val)
{
foreach ($typeleaves as $key => $val) {
$labeltoshow = ($langs->trans($val['code']) != $val['code'] ? $langs->trans($val['code']) : $val['label']);
//$labeltoshow .= ($val['delay'] > 0 ? ' ('.$langs->trans("NoticePeriod").': '.$val['delay'].' '.$langs->trans("days").')':'');
$arraytypeleaves[$val['rowid']] = $labeltoshow;
@ -545,14 +607,12 @@ if ($resql)
}
// Duration
if (!empty($arrayfields['duration']['checked']))
{
if (!empty($arrayfields['duration']['checked'])) {
print '<td class="liste_titre">&nbsp;</td>';
}
// Start date
if (!empty($arrayfields['cp.date_debut']['checked']))
{
if (!empty($arrayfields['cp.date_debut']['checked'])) {
print '<td class="liste_titre center nowraponall">';
print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_month_start" value="'.dol_escape_htmltag($search_month_start).'">';
$formother->select_year($search_year_start, 'search_year_start', 1, $min_year, $max_year);
@ -560,8 +620,7 @@ if ($resql)
}
// End date
if (!empty($arrayfields['cp.date_fin']['checked']))
{
if (!empty($arrayfields['cp.date_fin']['checked'])) {
print '<td class="liste_titre center nowraponall">';
print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_month_end" value="'.dol_escape_htmltag($search_month_end).'">';
$formother->select_year($search_year_end, 'search_year_end', 1, $min_year, $max_year);
@ -576,8 +635,7 @@ if ($resql)
print $hookmanager->resPrint;
// Create date
if (!empty($arrayfields['cp.date_create']['checked']))
{
if (!empty($arrayfields['cp.date_create']['checked'])) {
print '<td class="liste_titre center nowraponall">';
print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_month_create" value="'.dol_escape_htmltag($search_month_create).'">';
$formother->select_year($search_year_create, 'search_year_create', 1, $min_year, 0);
@ -585,8 +643,7 @@ if ($resql)
}
// Create date
if (!empty($arrayfields['cp.tms']['checked']))
{
if (!empty($arrayfields['cp.tms']['checked'])) {
print '<td class="liste_titre center nowraponall">';
print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_month_update" value="'.dol_escape_htmltag($search_month_update).'">';
$formother->select_year($search_year_update, 'search_year_update', 1, $min_year, 0);
@ -594,8 +651,7 @@ if ($resql)
}
// Status
if (!empty($arrayfields['cp.statut']['checked']))
{
if (!empty($arrayfields['cp.statut']['checked'])) {
print '<td class="liste_titre maxwidthonsmartphone maxwidth200 right">';
$object->selectStatutCP($search_status, 'search_status');
print '</td>';
@ -610,22 +666,42 @@ if ($resql)
print "</tr>\n";
print '<tr class="liste_titre">';
if (!empty($arrayfields['cp.ref']['checked'])) print_liste_field_titre($arrayfields['cp.ref']['label'], $_SERVER["PHP_SELF"], "cp.ref", "", $param, '', $sortfield, $sortorder);
if (!empty($arrayfields['cp.fk_user']['checked'])) print_liste_field_titre($arrayfields['cp.fk_user']['label'], $_SERVER["PHP_SELF"], "cp.fk_user", "", $param, '', $sortfield, $sortorder);
if (!empty($arrayfields['cp.fk_validator']['checked'])) print_liste_field_titre($arrayfields['cp.fk_validator']['label'], $_SERVER["PHP_SELF"], "cp.fk_validator", "", $param, '', $sortfield, $sortorder);
if (!empty($arrayfields['cp.fk_type']['checked'])) print_liste_field_titre($arrayfields['cp.fk_type']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder);
if (!empty($arrayfields['duration']['checked'])) print_liste_field_titre($arrayfields['duration']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right maxwidth100');
if (!empty($arrayfields['cp.date_debut']['checked'])) print_liste_field_titre($arrayfields['cp.date_debut']['label'], $_SERVER["PHP_SELF"], "cp.date_debut", "", $param, '', $sortfield, $sortorder, 'center ');
if (!empty($arrayfields['cp.date_fin']['checked'])) print_liste_field_titre($arrayfields['cp.date_fin']['label'], $_SERVER["PHP_SELF"], "cp.date_fin", "", $param, '', $sortfield, $sortorder, 'center ');
if (!empty($arrayfields['cp.ref']['checked'])) {
print_liste_field_titre($arrayfields['cp.ref']['label'], $_SERVER["PHP_SELF"], "cp.ref", "", $param, '', $sortfield, $sortorder);
}
if (!empty($arrayfields['cp.fk_user']['checked'])) {
print_liste_field_titre($arrayfields['cp.fk_user']['label'], $_SERVER["PHP_SELF"], "cp.fk_user", "", $param, '', $sortfield, $sortorder);
}
if (!empty($arrayfields['cp.fk_validator']['checked'])) {
print_liste_field_titre($arrayfields['cp.fk_validator']['label'], $_SERVER["PHP_SELF"], "cp.fk_validator", "", $param, '', $sortfield, $sortorder);
}
if (!empty($arrayfields['cp.fk_type']['checked'])) {
print_liste_field_titre($arrayfields['cp.fk_type']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder);
}
if (!empty($arrayfields['duration']['checked'])) {
print_liste_field_titre($arrayfields['duration']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right maxwidth100');
}
if (!empty($arrayfields['cp.date_debut']['checked'])) {
print_liste_field_titre($arrayfields['cp.date_debut']['label'], $_SERVER["PHP_SELF"], "cp.date_debut", "", $param, '', $sortfield, $sortorder, 'center ');
}
if (!empty($arrayfields['cp.date_fin']['checked'])) {
print_liste_field_titre($arrayfields['cp.date_fin']['label'], $_SERVER["PHP_SELF"], "cp.date_fin", "", $param, '', $sortfield, $sortorder, 'center ');
}
// Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
// Hook fields
$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
if (!empty($arrayfields['cp.date_create']['checked'])) print_liste_field_titre($arrayfields['cp.date_create']['label'], $_SERVER["PHP_SELF"], "cp.date_create", "", $param, '', $sortfield, $sortorder, 'center ');
if (!empty($arrayfields['cp.tms']['checked'])) print_liste_field_titre($arrayfields['cp.tms']['label'], $_SERVER["PHP_SELF"], "cp.tms", "", $param, '', $sortfield, $sortorder, 'center ');
if (!empty($arrayfields['cp.statut']['checked'])) print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "cp.statut", "", $param, '', $sortfield, $sortorder, 'right ');
if (!empty($arrayfields['cp.date_create']['checked'])) {
print_liste_field_titre($arrayfields['cp.date_create']['label'], $_SERVER["PHP_SELF"], "cp.date_create", "", $param, '', $sortfield, $sortorder, 'center ');
}
if (!empty($arrayfields['cp.tms']['checked'])) {
print_liste_field_titre($arrayfields['cp.tms']['label'], $_SERVER["PHP_SELF"], "cp.tms", "", $param, '', $sortfield, $sortorder, 'center ');
}
if (!empty($arrayfields['cp.statut']['checked'])) {
print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "cp.statut", "", $param, '', $sortfield, $sortorder, 'right ');
}
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
print "</tr>\n";
@ -637,8 +713,7 @@ if ($resql)
$langs->load("errors");
print '<tr class="oddeven opacitymediuem"><td colspan="10">'.$langs->trans("NotEnoughPermissions").'</td></tr>';
$result = 0;
} elseif ($num > 0 && !empty($mysoc->country_id))
{
} elseif ($num > 0 && !empty($mysoc->country_id)) {
// Lines
$userstatic = new User($db);
$approbatorstatic = new User($db);
@ -647,8 +722,7 @@ if ($resql)
$i = 0;
$totalarray = array();
while ($i < min($num, $limit))
{
while ($i < min($num, $limit)) {
$obj = $db->fetch_object($resql);
// Leave request
@ -684,54 +758,61 @@ if ($resql)
print '<tr class="oddeven">';
if (!empty($arrayfields['cp.ref']['checked']))
{
if (!empty($arrayfields['cp.ref']['checked'])) {
print '<td class="nowraponall">';
print $holidaystatic->getNomUrl(1, 1);
print '</td>';
if (!$i) $totalarray['nbfield']++;
if (!$i) {
$totalarray['nbfield']++;
}
}
if (!empty($arrayfields['cp.fk_user']['checked']))
{
if (!empty($arrayfields['cp.fk_user']['checked'])) {
print '<td class="tdoverflowmax150">'.$userstatic->getNomUrl(-1, 'leave').'</td>';
if (!$i) $totalarray['nbfield']++;
if (!$i) {
$totalarray['nbfield']++;
}
}
if (!empty($arrayfields['cp.fk_validator']['checked']))
{
if (!empty($arrayfields['cp.fk_validator']['checked'])) {
print '<td class="tdoverflowmax150">'.$approbatorstatic->getNomUrl(-1).'</td>';
if (!$i) $totalarray['nbfield']++;
if (!$i) {
$totalarray['nbfield']++;
}
}
if (!empty($arrayfields['cp.fk_type']['checked']))
{
if (!empty($arrayfields['cp.fk_type']['checked'])) {
print '<td>';
$labeltypeleavetoshow = ($langs->trans($typeleaves[$obj->fk_type]['code']) != $typeleaves[$obj->fk_type]['code'] ? $langs->trans($typeleaves[$obj->fk_type]['code']) : $typeleaves[$obj->fk_type]['label']);
print empty($typeleaves[$obj->fk_type]['label']) ? $langs->trans("TypeWasDisabledOrRemoved", $obj->fk_type) : $labeltypeleavetoshow;
print '</td>';
if (!$i) $totalarray['nbfield']++;
if (!$i) {
$totalarray['nbfield']++;
}
}
if (!empty($arrayfields['duration']['checked']))
{
if (!empty($arrayfields['duration']['checked'])) {
print '<td class="right">';
$nbopenedday = num_open_day($db->jdate($obj->date_debut, 1), $db->jdate($obj->date_fin, 1), 0, 1, $obj->halfday);
print $nbopenedday.' '.$langs->trans('DurationDays');
print '</td>';
if (!$i) $totalarray['nbfield']++;
if (!$i) {
$totalarray['nbfield']++;
}
}
if (!empty($arrayfields['cp.date_debut']['checked']))
{
if (!empty($arrayfields['cp.date_debut']['checked'])) {
print '<td class="center">';
print dol_print_date($db->jdate($obj->date_debut), 'day');
print ' <span class="opacitymedium nowraponall">('.$langs->trans($listhalfday[$starthalfday]).')</span>';
print '</td>';
if (!$i) $totalarray['nbfield']++;
if (!$i) {
$totalarray['nbfield']++;
}
}
if (!empty($arrayfields['cp.date_fin']['checked']))
{
if (!empty($arrayfields['cp.date_fin']['checked'])) {
print '<td class="center">';
print dol_print_date($db->jdate($obj->date_fin), 'day');
print ' <span class="opacitymedium nowraponall">('.$langs->trans($listhalfday[$endhalfday]).')</span>';
print '</td>';
if (!$i) $totalarray['nbfield']++;
if (!$i) {
$totalarray['nbfield']++;
}
}
// Extra fields
@ -742,32 +823,38 @@ if ($resql)
print $hookmanager->resPrint;
// Date creation
if (!empty($arrayfields['cp.date_create']['checked']))
{
if (!empty($arrayfields['cp.date_create']['checked'])) {
print '<td style="text-align: center;">'.dol_print_date($date, 'dayhour').'</td>';
if (!$i) $totalarray['nbfield']++;
if (!$i) {
$totalarray['nbfield']++;
}
}
if (!empty($arrayfields['cp.tms']['checked']))
{
if (!empty($arrayfields['cp.tms']['checked'])) {
print '<td style="text-align: center;">'.dol_print_date($date_modif, 'dayhour').'</td>';
if (!$i) $totalarray['nbfield']++;
if (!$i) {
$totalarray['nbfield']++;
}
}
if (!empty($arrayfields['cp.statut']['checked']))
{
if (!empty($arrayfields['cp.statut']['checked'])) {
print '<td class="right nowrap">'.$holidaystatic->getLibStatut(5).'</td>';
if (!$i) $totalarray['nbfield']++;
if (!$i) {
$totalarray['nbfield']++;
}
}
// Action column
print '<td class="nowrap center">';
if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
{
if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
$selected = 0;
if (in_array($obj->rowid, $arrayofselected)) $selected = 1;
if (in_array($obj->rowid, $arrayofselected)) {
$selected = 1;
}
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']++;
if (!$i) {
$totalarray['nbfield']++;
}
print '</tr>'."\n";
@ -776,10 +863,13 @@ if ($resql)
}
// Si il n'y a pas d'enregistrement suite à une recherche
if ($num == 0)
{
if ($num == 0) {
$colspan = 1;
foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; }
foreach ($arrayfields as $key => $val) {
if (!empty($val['checked'])) {
$colspan++;
}
}
print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
}
@ -815,8 +905,7 @@ function showMyBalance($holiday, $user_id)
$out = '';
$nb_holiday = 0;
$typeleaves = $holiday->getTypes(1, 1);
foreach ($typeleaves as $key => $val)
{
foreach ($typeleaves as $key => $val) {
$nb_type = $holiday->getCPforUser($user_id, $val['rowid']);
$nb_holiday += $nb_type;
$out .= ' - '.$val['label'].': <strong>'.($nb_type ?price2num($nb_type) : 0).'</strong><br>';

View File

@ -36,8 +36,7 @@ $langs->loadLangs(array("holiday"));
// Security check
$socid = 0;
if ($user->socid > 0) // Protection if external user
{
if ($user->socid > 0) { // Protection if external user
//$socid = $user->socid;
accessforbidden();
}
@ -57,8 +56,12 @@ $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_
$sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'alpha');
if (!$sortfield) $sortfield = "cp.rowid";
if (!$sortorder) $sortorder = "ASC";
if (!$sortfield) {
$sortfield = "cp.rowid";
}
if (!$sortorder) {
$sortorder = "ASC";
}
$hookmanager->initHooks(array('leavemovementlist'));
@ -69,21 +72,25 @@ $arrayofmassactions = array();
* Actions
*/
if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; }
if (GETPOST('cancel', 'alpha')) {
$action = 'list'; $massaction = '';
}
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
$massaction = '';
}
$parameters = array();
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if (empty($reshook))
{
if (empty($reshook)) {
// Selection of new fields
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
// Purge search criteria
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers
{
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
$search_ref = '';
$search_employee = '';
$search_type = '';
@ -97,8 +104,7 @@ if (empty($reshook))
|| GETPOST('button_removefilter', 'alpha')
|| GETPOST('button_search_x', 'alpha')
|| GETPOST('button_search.x', 'alpha')
|| GETPOST('button_search', 'alpha'))
{
|| GETPOST('button_search', 'alpha')) {
$massaction = '';
}
}
@ -141,16 +147,23 @@ $sql .= " WHERE cp.rowid > 0";
$sql .= " AND cp.statut = 3"; // 3 = Approved
$sql .= " AND (date_format(cp.date_debut, '%Y-%m') = '".$db->escape($year_month)."' OR date_format(cp.date_fin, '%Y-%m') = '".$db->escape($year_month)."')";
if (!empty($search_ref)) $sql .= natural_search('cp.ref', $search_ref);
if (!empty($search_employee)) $sql .= " AND cp.fk_user = '".$db->escape($search_employee)."'";
if (!empty($search_type)) $sql .= ' AND cp.fk_type IN ('.$db->escape($search_type).')';
if (!empty($search_description)) $sql .= natural_search('cp.description', $search_description);
if (!empty($search_ref)) {
$sql .= natural_search('cp.ref', $search_ref);
}
if (!empty($search_employee)) {
$sql .= " AND cp.fk_user = '".$db->escape($search_employee)."'";
}
if (!empty($search_type)) {
$sql .= ' AND cp.fk_type IN ('.$db->escape($search_type).')';
}
if (!empty($search_description)) {
$sql .= natural_search('cp.description', $search_description);
}
$sql .= $db->order($sortfield, $sortorder);
$resql = $db->query($sql);
if (empty($resql))
{
if (empty($resql)) {
dol_print_error($db);
exit;
}
@ -158,15 +171,29 @@ if (empty($resql))
$num = $db->num_rows($resql);
$param = '';
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
if (!empty($search_ref)) $param .= '&search_ref='.urlencode($search_ref);
if (!empty($search_employee)) $param .= '&search_employee='.urlencode($search_employee);
if (!empty($search_type)) $param .= '&search_type='.urlencode($search_type);
if (!empty($search_description)) $param .= '&search_description='.urlencode($search_description);
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
$param .= '&contextpage='.urlencode($contextpage);
}
if ($limit > 0 && $limit != $conf->liste_limit) {
$param .= '&limit='.urlencode($limit);
}
if (!empty($search_ref)) {
$param .= '&search_ref='.urlencode($search_ref);
}
if (!empty($search_employee)) {
$param .= '&search_employee='.urlencode($search_employee);
}
if (!empty($search_type)) {
$param .= '&search_type='.urlencode($search_type);
}
if (!empty($search_description)) {
$param .= '&search_description='.urlencode($search_description);
}
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
if ($optioncss != '') {
print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
}
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="action" value="list">';
@ -215,8 +242,7 @@ if (!empty($arrayfields['cp.fk_user']['checked'])) {
if (!empty($arrayfields['ct.label']['checked'])) {
$typeleaves = $holidaystatic->getTypes(1, -1);
$arraytypeleaves = array();
foreach ($typeleaves as $key => $val)
{
foreach ($typeleaves as $key => $val) {
$labeltoshow = ($langs->trans($val['code']) != $val['code'] ? $langs->trans($val['code']) : $val['label']);
$arraytypeleaves[$val['rowid']] = $labeltoshow;
}
@ -226,12 +252,24 @@ if (!empty($arrayfields['ct.label']['checked'])) {
print '</td>';
}
if (!empty($arrayfields['cp.date_debut']['checked'])) print '<td class="liste_titre"></td>';
if (!empty($arrayfields['cp.date_fin']['checked'])) print '<td class="liste_titre"></td>';
if (!empty($arrayfields['used_days']['checked'])) print '<td class="liste_titre"></td>';
if (!empty($arrayfields['date_start_month']['checked'])) print '<td class="liste_titre"></td>';
if (!empty($arrayfields['date_end_month']['checked'])) print '<td class="liste_titre"></td>';
if (!empty($arrayfields['used_days_month']['checked'])) print '<td class="liste_titre"></td>';
if (!empty($arrayfields['cp.date_debut']['checked'])) {
print '<td class="liste_titre"></td>';
}
if (!empty($arrayfields['cp.date_fin']['checked'])) {
print '<td class="liste_titre"></td>';
}
if (!empty($arrayfields['used_days']['checked'])) {
print '<td class="liste_titre"></td>';
}
if (!empty($arrayfields['date_start_month']['checked'])) {
print '<td class="liste_titre"></td>';
}
if (!empty($arrayfields['date_end_month']['checked'])) {
print '<td class="liste_titre"></td>';
}
if (!empty($arrayfields['used_days_month']['checked'])) {
print '<td class="liste_titre"></td>';
}
// Filter: Description
if (!empty($arrayfields['cp.description']['checked'])) {
@ -248,26 +286,43 @@ print '</td>';
print '</tr>';
print '<tr class="liste_titre">';
if (!empty($arrayfields['cp.ref']['checked'])) print_liste_field_titre($arrayfields['cp.ref']['label'], $_SERVER["PHP_SELF"], 'cp.ref', '', '', '', $sortfield, $sortorder);
if (!empty($arrayfields['cp.fk_user']['checked'])) print_liste_field_titre($arrayfields['cp.fk_user']['label'], $_SERVER["PHP_SELF"], 'cp.fk_user', '', '', '', $sortfield, $sortorder);
if (!empty($arrayfields['ct.label']['checked'])) print_liste_field_titre($arrayfields['ct.label']['label'], $_SERVER["PHP_SELF"], 'ct.label', '', '', '', $sortfield, $sortorder);
if (!empty($arrayfields['cp.date_debut']['checked'])) print_liste_field_titre($arrayfields['cp.date_debut']['label'], $_SERVER["PHP_SELF"], 'cp.date_debut', '', '', '', $sortfield, $sortorder);
if (!empty($arrayfields['cp.date_fin']['checked'])) print_liste_field_titre($arrayfields['cp.date_fin']['label'], $_SERVER["PHP_SELF"], 'cp.date_fin', '', '', '', $sortfield, $sortorder);
if (!empty($arrayfields['used_days']['checked'])) print_liste_field_titre($arrayfields['used_days']['label'], $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder);
if (!empty($arrayfields['date_start_month']['checked'])) print_liste_field_titre($arrayfields['date_start_month']['label'], $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder);
if (!empty($arrayfields['date_end_month']['checked'])) print_liste_field_titre($arrayfields['date_end_month']['label'], $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder);
if (!empty($arrayfields['used_days_month']['checked'])) print_liste_field_titre($arrayfields['used_days_month']['label'], $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder);
if (!empty($arrayfields['cp.description']['checked'])) print_liste_field_titre($arrayfields['cp.description']['label'], $_SERVER["PHP_SELF"], 'cp.description', '', '', '', $sortfield, $sortorder);
if (!empty($arrayfields['cp.ref']['checked'])) {
print_liste_field_titre($arrayfields['cp.ref']['label'], $_SERVER["PHP_SELF"], 'cp.ref', '', '', '', $sortfield, $sortorder);
}
if (!empty($arrayfields['cp.fk_user']['checked'])) {
print_liste_field_titre($arrayfields['cp.fk_user']['label'], $_SERVER["PHP_SELF"], 'cp.fk_user', '', '', '', $sortfield, $sortorder);
}
if (!empty($arrayfields['ct.label']['checked'])) {
print_liste_field_titre($arrayfields['ct.label']['label'], $_SERVER["PHP_SELF"], 'ct.label', '', '', '', $sortfield, $sortorder);
}
if (!empty($arrayfields['cp.date_debut']['checked'])) {
print_liste_field_titre($arrayfields['cp.date_debut']['label'], $_SERVER["PHP_SELF"], 'cp.date_debut', '', '', '', $sortfield, $sortorder);
}
if (!empty($arrayfields['cp.date_fin']['checked'])) {
print_liste_field_titre($arrayfields['cp.date_fin']['label'], $_SERVER["PHP_SELF"], 'cp.date_fin', '', '', '', $sortfield, $sortorder);
}
if (!empty($arrayfields['used_days']['checked'])) {
print_liste_field_titre($arrayfields['used_days']['label'], $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder);
}
if (!empty($arrayfields['date_start_month']['checked'])) {
print_liste_field_titre($arrayfields['date_start_month']['label'], $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder);
}
if (!empty($arrayfields['date_end_month']['checked'])) {
print_liste_field_titre($arrayfields['date_end_month']['label'], $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder);
}
if (!empty($arrayfields['used_days_month']['checked'])) {
print_liste_field_titre($arrayfields['used_days_month']['label'], $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder);
}
if (!empty($arrayfields['cp.description']['checked'])) {
print_liste_field_titre($arrayfields['cp.description']['label'], $_SERVER["PHP_SELF"], 'cp.description', '', '', '', $sortfield, $sortorder);
}
print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
print '</tr>';
if ($num == 0)
{
if ($num == 0) {
print '<tr><td colspan="10" class="opacitymedium">'.$langs->trans('None').'</td></tr>';
}
else {
while ($obj = $db->fetch_object($resql))
{
} else {
while ($obj = $db->fetch_object($resql)) {
$user = new User($db);
$user->fetch($obj->fk_user);
@ -289,19 +344,25 @@ else {
// Set date_start_gmt and date_end_gmt that are date to show for the selected month
$date_start_inmonth = $db->jdate($obj->date_debut, true);
$date_end_inmonth = $db->jdate($obj->date_fin, true);
if ($tmpstart['year'] < $search_year || $tmpstart['mon'] < $search_month)
{
if ($tmpstart['year'] < $search_year || $tmpstart['mon'] < $search_month) {
$date_start_inmonth = dol_get_first_day($search_year, $search_month, true);
$starthalfdayinmonth = 'morning';
if ($halfdayinmonth == 2) $halfdayinmonth = 1;
if ($halfdayinmonth == -1) $halfdayinmonth = 0;
if ($halfdayinmonth == 2) {
$halfdayinmonth = 1;
}
if ($halfdayinmonth == -1) {
$halfdayinmonth = 0;
}
}
if ($tmpend['year'] > $search_year || $tmpend['mon'] > $search_month)
{
if ($tmpend['year'] > $search_year || $tmpend['mon'] > $search_month) {
$date_end_inmonth = dol_get_last_day($search_year, $search_month, true) - ((24 * 3600) - 1);
$endhalfdayinmonth = 'afternoon';
if ($halfdayinmonth == 2) $halfdayinmonth = -1;
if ($halfdayinmonth == 1) $halfdayinmonth = 0;
if ($halfdayinmonth == 2) {
$halfdayinmonth = -1;
}
if ($halfdayinmonth == 1) {
$halfdayinmonth = 0;
}
}
// Leave request
@ -310,42 +371,50 @@ else {
print '<tr class="oddeven">';
if (!empty($arrayfields['cp.ref']['checked'])) print '<td>'.$holidaystatic->getNomUrl(1, 1).'</td>';
if (!empty($arrayfields['cp.fk_user']['checked'])) print '<td>'.$user->getFullName($langs).'</td>';
if (!empty($arrayfields['ct.label']['checked'])) print '<td>'.$obj->label.'</td>';
if (!empty($arrayfields['cp.ref']['checked'])) {
print '<td>'.$holidaystatic->getNomUrl(1, 1).'</td>';
}
if (!empty($arrayfields['cp.fk_user']['checked'])) {
print '<td>'.$user->getFullName($langs).'</td>';
}
if (!empty($arrayfields['ct.label']['checked'])) {
print '<td>'.$obj->label.'</td>';
}
if (!empty($arrayfields['cp.date_debut']['checked']))
{
if (!empty($arrayfields['cp.date_debut']['checked'])) {
print '<td class="center">'.dol_print_date($db->jdate($obj->date_debut), 'day');
print ' <span class="opacitymedium">('.$langs->trans($listhalfday[$starthalfday]).')</span>';
print '</td>';
}
if (!empty($arrayfields['cp.date_fin']['checked']))
{
if (!empty($arrayfields['cp.date_fin']['checked'])) {
print '<td class="center">'.dol_print_date($db->jdate($obj->date_fin), 'day');
print ' <span class="opacitymedium">('.$langs->trans($listhalfday[$endhalfday]).')</span>';
print '</td>';
}
if (!empty($arrayfields['used_days']['checked'])) print '<td class="right">'.num_open_day($date_start, $date_end, 0, 1, $obj->halfday).'</td>';
if (!empty($arrayfields['used_days']['checked'])) {
print '<td class="right">'.num_open_day($date_start, $date_end, 0, 1, $obj->halfday).'</td>';
}
if (!empty($arrayfields['date_start_month']['checked']))
{
if (!empty($arrayfields['date_start_month']['checked'])) {
print '<td class="center">'.dol_print_date($date_start_inmonth, 'day');
print ' <span class="opacitymedium">('.$langs->trans($listhalfday[$starthalfdayinmonth]).')</span>';
print '</td>';
}
if (!empty($arrayfields['date_end_month']['checked']))
{
if (!empty($arrayfields['date_end_month']['checked'])) {
print '<td class="center">'.dol_print_date($date_end_inmonth, 'day');
print ' <span class="opacitymedium">('.$langs->trans($listhalfday[$endhalfdayinmonth]).')</span>';
print '</td>';
}
if (!empty($arrayfields['used_days_month']['checked'])) print '<td class="right">'.num_open_day($date_start_inmonth, $date_end_inmonth, 0, 1, $halfdayinmonth).'</td>';
if (!empty($arrayfields['cp.description']['checked'])) print '<td class="maxwidth300">'.dol_escape_htmltag(dolGetFirstLineOfText($obj->description)).'</td>';
if (!empty($arrayfields['used_days_month']['checked'])) {
print '<td class="right">'.num_open_day($date_start_inmonth, $date_end_inmonth, 0, 1, $halfdayinmonth).'</td>';
}
if (!empty($arrayfields['cp.description']['checked'])) {
print '<td class="maxwidth300">'.dol_escape_htmltag(dolGetFirstLineOfText($obj->description)).'</td>';
}
print '<td></td>';
print '</tr>';

View File

@ -61,15 +61,23 @@ $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) {
$page = 0;
} // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (!$sortfield) $sortfield = "cpl.rowid";
if (!$sortorder) $sortorder = "DESC";
if (!$sortfield) {
$sortfield = "cpl.rowid";
}
if (!$sortorder) {
$sortorder = "DESC";
}
// Si l'utilisateur n'a pas le droit de lire cette page
if (!$user->rights->holiday->readall) accessforbidden();
if (!$user->rights->holiday->readall) {
accessforbidden();
}
// Load translation files required by the page
$langs->loadLangs(array('users', 'other', 'holiday'));
@ -83,8 +91,7 @@ $hookmanager->initHooks(array('leavemovementlist')); // Note that conf->hooks_mo
$arrayfields = array();
$arrayofmassactions = array();
if (empty($conf->holiday->enabled))
{
if (empty($conf->holiday->enabled)) {
llxHeader('', $langs->trans('CPTitreMenu'));
print '<div class="tabBar">';
print '<span style="color: #FF0000;">'.$langs->trans('NotActiveModCP').'</span>';
@ -98,12 +105,18 @@ if (empty($conf->holiday->enabled))
* Actions
*/
if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; }
if (GETPOST('cancel', 'alpha')) {
$action = 'list'; $massaction = '';
}
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
$massaction = '';
}
$parameters = array();
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if (empty($reshook)) {
// Selection of new fields
@ -129,8 +142,7 @@ if (empty($reshook)) {
|| GETPOST('button_removefilter', 'alpha')
|| GETPOST('button_search_x', 'alpha')
|| GETPOST('button_search.x', 'alpha')
|| GETPOST('button_search', 'alpha'))
{
|| GETPOST('button_search', 'alpha')) {
$massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
}
@ -184,13 +196,27 @@ if (!empty($search_year) && $search_year > 0) {
$sqlwhere .= "AND date_action BETWEEN '".$db->idate($from_date)."' AND '".$db->idate($to_date)."'";
}
if (!empty($search_id) && $search_id > 0) $sqlwhere .= natural_search('rowid', $search_id, 1);
if (!empty($search_validator) && $search_validator > 0) $sqlwhere .= natural_search('fk_user_action', $search_validator, 1);
if (!empty($search_employee) && $search_employee > 0) $sqlwhere .= natural_search('fk_user_update', $search_employee, 1);
if (!empty($search_description)) $sqlwhere .= natural_search('type_action', $search_description);
if (!empty($search_type) && $search_type > 0) $sqlwhere .= natural_search('fk_type', $search_type, 1);
if (!empty($search_prev_solde)) $sqlwhere .= natural_search('prev_solde', $search_prev_solde, 1);
if (!empty($search_new_solde)) $sqlwhere .= natural_search('new_solde', $search_new_solde, 1);
if (!empty($search_id) && $search_id > 0) {
$sqlwhere .= natural_search('rowid', $search_id, 1);
}
if (!empty($search_validator) && $search_validator > 0) {
$sqlwhere .= natural_search('fk_user_action', $search_validator, 1);
}
if (!empty($search_employee) && $search_employee > 0) {
$sqlwhere .= natural_search('fk_user_update', $search_employee, 1);
}
if (!empty($search_description)) {
$sqlwhere .= natural_search('type_action', $search_description);
}
if (!empty($search_type) && $search_type > 0) {
$sqlwhere .= natural_search('fk_type', $search_type, 1);
}
if (!empty($search_prev_solde)) {
$sqlwhere .= natural_search('prev_solde', $search_prev_solde, 1);
}
if (!empty($search_new_solde)) {
$sqlwhere .= natural_search('new_solde', $search_new_solde, 1);
}
$sqlorder = $db->order($sortfield, $sortorder);
@ -214,20 +240,44 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
$num = is_array($object->logs) ? count($object->logs) : 0;
$param = '';
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
if (!empty($search_id)) $param .= '&search_statut='.urlencode($search_statut);
if (!empty($search_month) && $search_month > 0) $param .= '&search_month='.urlencode($search_month);
if (!empty($search_year) && $search_year > 0) $param .= '&search_year='.urlencode($search_year);
if (!empty($search_validator) && $search_validator > 0) $param .= '&search_validator='.urlencode($search_validator);
if (!empty($search_employee) && $search_employee > 0) $param .= '&search_employee='.urlencode($search_employee);
if (!empty($search_description)) $param .= '&search_description='.urlencode($search_description);
if (!empty($search_type) && $search_type > 0) $param .= '&search_type='.urlencode($search_type);
if (!empty($search_prev_solde)) $param .= '&search_prev_solde='.urlencode($search_prev_solde);
if (!empty($search_new_solde)) $param .= '&search_new_solde='.urlencode($search_new_solde);
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
$param .= '&contextpage='.urlencode($contextpage);
}
if ($limit > 0 && $limit != $conf->liste_limit) {
$param .= '&limit='.urlencode($limit);
}
if (!empty($search_id)) {
$param .= '&search_statut='.urlencode($search_statut);
}
if (!empty($search_month) && $search_month > 0) {
$param .= '&search_month='.urlencode($search_month);
}
if (!empty($search_year) && $search_year > 0) {
$param .= '&search_year='.urlencode($search_year);
}
if (!empty($search_validator) && $search_validator > 0) {
$param .= '&search_validator='.urlencode($search_validator);
}
if (!empty($search_employee) && $search_employee > 0) {
$param .= '&search_employee='.urlencode($search_employee);
}
if (!empty($search_description)) {
$param .= '&search_description='.urlencode($search_description);
}
if (!empty($search_type) && $search_type > 0) {
$param .= '&search_type='.urlencode($search_type);
}
if (!empty($search_prev_solde)) {
$param .= '&search_prev_solde='.urlencode($search_prev_solde);
}
if (!empty($search_new_solde)) {
$param .= '&search_new_solde='.urlencode($search_new_solde);
}
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
if ($optioncss != '') {
print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
}
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="action" value="list">';
@ -348,23 +398,40 @@ print '</td>';
print '</tr>';
print '<tr class="liste_titre">';
if (!empty($arrayfields['cpl.rowid']['checked'])) print_liste_field_titre($arrayfields['cpl.rowid']['label'], $_SERVER["PHP_SELF"], 'rowid', '', '', '', $sortfield, $sortorder);
if (!empty($arrayfields['cpl.date_action']['checked'])) print_liste_field_titre($arrayfields['cpl.date_action']['label'], $_SERVER["PHP_SELF"], 'date_action', '', '', '', $sortfield, $sortorder, 'center ');
if (!empty($arrayfields['cpl.fk_user_action']['checked'])) print_liste_field_titre($arrayfields['cpl.fk_user_action']['label'], $_SERVER["PHP_SELF"], 'fk_user_action', '', '', '', $sortfield, $sortorder);
if (!empty($arrayfields['cpl.fk_user_update']['checked'])) print_liste_field_titre($arrayfields['cpl.fk_user_update']['label'], $_SERVER["PHP_SELF"], 'fk_user_update', '', '', '', $sortfield, $sortorder);
if (!empty($arrayfields['cpl.type_action']['checked'])) print_liste_field_titre($arrayfields['cpl.type_action']['label'], $_SERVER["PHP_SELF"], 'type_action', '', '', '', $sortfield, $sortorder);
if (!empty($arrayfields['cpl.fk_type']['checked'])) print_liste_field_titre($arrayfields['cpl.fk_type']['label'], $_SERVER["PHP_SELF"], 'fk_type', '', '', '', $sortfield, $sortorder);
if (!empty($arrayfields['cpl.prev_solde']['checked'])) print_liste_field_titre($arrayfields['cpl.prev_solde']['label'], $_SERVER["PHP_SELF"], 'prev_solde', '', '', '', $sortfield, $sortorder, 'right ');
if (!empty($arrayfields['variation']['checked'])) print_liste_field_titre($arrayfields['variation']['label'], $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'right ');
if (!empty($arrayfields['cpl.new_solde']['checked'])) print_liste_field_titre($arrayfields['cpl.new_solde']['label'], $_SERVER["PHP_SELF"], 'new_solde', '', '', '', $sortfield, $sortorder, 'right ');
if (!empty($arrayfields['cpl.rowid']['checked'])) {
print_liste_field_titre($arrayfields['cpl.rowid']['label'], $_SERVER["PHP_SELF"], 'rowid', '', '', '', $sortfield, $sortorder);
}
if (!empty($arrayfields['cpl.date_action']['checked'])) {
print_liste_field_titre($arrayfields['cpl.date_action']['label'], $_SERVER["PHP_SELF"], 'date_action', '', '', '', $sortfield, $sortorder, 'center ');
}
if (!empty($arrayfields['cpl.fk_user_action']['checked'])) {
print_liste_field_titre($arrayfields['cpl.fk_user_action']['label'], $_SERVER["PHP_SELF"], 'fk_user_action', '', '', '', $sortfield, $sortorder);
}
if (!empty($arrayfields['cpl.fk_user_update']['checked'])) {
print_liste_field_titre($arrayfields['cpl.fk_user_update']['label'], $_SERVER["PHP_SELF"], 'fk_user_update', '', '', '', $sortfield, $sortorder);
}
if (!empty($arrayfields['cpl.type_action']['checked'])) {
print_liste_field_titre($arrayfields['cpl.type_action']['label'], $_SERVER["PHP_SELF"], 'type_action', '', '', '', $sortfield, $sortorder);
}
if (!empty($arrayfields['cpl.fk_type']['checked'])) {
print_liste_field_titre($arrayfields['cpl.fk_type']['label'], $_SERVER["PHP_SELF"], 'fk_type', '', '', '', $sortfield, $sortorder);
}
if (!empty($arrayfields['cpl.prev_solde']['checked'])) {
print_liste_field_titre($arrayfields['cpl.prev_solde']['label'], $_SERVER["PHP_SELF"], 'prev_solde', '', '', '', $sortfield, $sortorder, 'right ');
}
if (!empty($arrayfields['variation']['checked'])) {
print_liste_field_titre($arrayfields['variation']['label'], $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'right ');
}
if (!empty($arrayfields['cpl.new_solde']['checked'])) {
print_liste_field_titre($arrayfields['cpl.new_solde']['label'], $_SERVER["PHP_SELF"], 'new_solde', '', '', '', $sortfield, $sortorder, 'right ');
}
print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
print '</tr>';
// TODO: $i = 0;
$i = 1;
while ($i < min($num, $limit))
{
while ($i < min($num, $limit)) {
//TODO: $obj = $db->fetch_object($resql);
$obj = next($object->logs);

View File

@ -27,8 +27,9 @@ require_once DOL_DOCUMENT_ROOT.'/hrm/class/establishment.class.php';
// Load translation files required by the page
$langs->loadLangs(array('admin', 'hrm'));
if (!$user->admin)
if (!$user->admin) {
accessforbidden();
}
$error = 0;
@ -52,8 +53,12 @@ llxHeader('', $langs->trans("Establishments"));
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
$sortorder = GETPOST("sortorder", 'alpha');
$sortfield = GETPOST("sortfield", 'alpha');
if (!$sortorder) $sortorder = "DESC";
if (!$sortfield) $sortfield = "e.rowid";
if (!$sortorder) {
$sortorder = "DESC";
}
if (!$sortfield) {
$sortfield = "e.rowid";
}
if (empty($page) || $page == -1) {
$page = 0;
@ -79,8 +84,7 @@ $sql .= $db->order($sortfield, $sortorder);
$sql .= $db->plimit($limit + 1, $offset);
$result = $db->query($sql);
if ($result)
{
if ($result) {
$num = $db->num_rows($result);
$i = 0;
@ -95,12 +99,10 @@ if ($result)
print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "e.status", "", "", '', $sortfield, $sortorder, 'right ');
print "</tr>\n";
if ($num > 0)
{
if ($num > 0) {
$establishmentstatic = new Establishment($db);
while ($i < min($num, $limit))
{
while ($i < min($num, $limit)) {
$obj = $db->fetch_object($result);
$establishmentstatic->id = $obj->rowid;

View File

@ -27,8 +27,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
// Load translation files required by the page
$langs->loadLangs(array('admin', 'hrm'));
if (!$user->admin)
if (!$user->admin) {
accessforbidden();
}
$action = GETPOST('action', 'aZ09');

View File

@ -180,7 +180,9 @@ class Establishment extends CommonObject
$this->zip = trim($this->zip);
$this->town = trim($this->town);
if (empty($this->ref)) $this->ref = '(PROV)';
if (empty($this->ref)) {
$this->ref = '(PROV)';
}
$this->db->begin();
@ -248,8 +250,7 @@ class Establishment extends CommonObject
global $langs;
// Check parameters
if (empty($this->label))
{
if (empty($this->label)) {
$this->error = 'ErrorBadParameter';
return -1;
}
@ -296,8 +297,7 @@ class Establishment extends CommonObject
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
$result = $this->db->query($sql);
if ($result)
{
if ($result) {
$obj = $this->db->fetch_object($result);
$this->id = $obj->rowid;
@ -334,8 +334,7 @@ class Establishment extends CommonObject
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$result = $this->db->query($sql);
if ($result)
{
if ($result) {
$this->db->commit();
return 1;
} else {
@ -367,8 +366,7 @@ class Establishment extends CommonObject
public function LibStatut($status, $mode = 0)
{
// phpcs:enable
if (empty($this->labelStatus) || empty($this->labelStatusShort))
{
if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
global $langs;
//$langs->load("mymodule");
$this->labelStatus[self::STATUS_OPEN] = $langs->trans('Open');
@ -378,8 +376,12 @@ class Establishment extends CommonObject
}
$statusType = 'status'.$status;
if ($status == self::STATUS_OPEN) $statusType = 'status4';
if ($status == self::STATUS_CLOSED) $statusType = 'status6';
if ($status == self::STATUS_OPEN) {
$statusType = 'status4';
}
if ($status == self::STATUS_CLOSED) {
$statusType = 'status6';
}
return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
}
@ -400,22 +402,18 @@ class Establishment extends CommonObject
dol_syslog(get_class($this)."::fetch info", LOG_DEBUG);
$result = $this->db->query($sql);
if ($result)
{
if ($this->db->num_rows($result))
{
if ($result) {
if ($this->db->num_rows($result)) {
$obj = $this->db->fetch_object($result);
$this->id = $obj->rowid;
$this->date_creation = $this->db->jdate($obj->datec);
if ($obj->fk_user_author)
{
if ($obj->fk_user_author) {
$cuser = new User($this->db);
$cuser->fetch($obj->fk_user_author);
$this->user_creation = $cuser;
}
if ($obj->fk_user_mod)
{
if ($obj->fk_user_mod) {
$muser = new User($this->db);
$muser->fetch($obj->fk_user_mod);
$this->user_modification = $muser;
@ -449,9 +447,15 @@ class Establishment extends CommonObject
$label = '<u>'.$langs->trans("Establishment").'</u>';
$label .= '<br>'.$langs->trans("Label").': '.$this->label;
if ($withpicto) $result .= ($link.img_object($label, $picto).$linkend);
if ($withpicto && $withpicto != 2) $result .= ' ';
if ($withpicto != 2) $result .= $link.$this->label.$linkend;
if ($withpicto) {
$result .= ($link.img_object($label, $picto).$linkend);
}
if ($withpicto && $withpicto != 2) {
$result .= ' ';
}
if ($withpicto != 2) {
$result .= $link.$this->label.$linkend;
}
return $result;
}
@ -465,10 +469,14 @@ class Establishment extends CommonObject
global $mysoc;
// We return country code of bank account
if (!empty($this->country_code)) return $this->country_code;
if (!empty($this->country_code)) {
return $this->country_code;
}
// We return country code of managed company
if (!empty($mysoc->country_code)) return $mysoc->country_code;
if (!empty($mysoc->country_code)) {
return $mysoc->country_code;
}
return '';
}

View File

@ -29,7 +29,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
$langs->loadLangs(array('admin', 'hrm'));
// Security check
if (!$user->admin) accessforbidden();
if (!$user->admin) {
accessforbidden();
}
$error = 0;
@ -44,7 +46,9 @@ static $tmpstatus2label = array(
'1'=>'OpenEtablishment'
);
$status2label = array('');
foreach ($tmpstatus2label as $key => $val) $status2label[$key] = $langs->trans($val);
foreach ($tmpstatus2label as $key => $val) {
$status2label[$key] = $langs->trans($val);
}
$object = new Establishment($db);
@ -56,31 +60,25 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be includ
* Actions
*/
if ($action == 'confirm_delete' && $confirm == "yes")
{
if ($action == 'confirm_delete' && $confirm == "yes") {
$result = $object->delete($id);
if ($result >= 0)
{
if ($result >= 0) {
header("Location: ../admin/admin_establishment.php");
exit;
} else {
setEventMessages($object->error, $object->errors, 'errors');
}
} elseif ($action == 'add')
{
if (!$cancel)
{
} elseif ($action == 'add') {
if (!$cancel) {
$error = 0;
$object->label = GETPOST('label', 'alpha');
if (empty($object->label))
{
if (empty($object->label)) {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors');
$error++;
}
if (empty($error))
{
if (empty($error)) {
$object->address = GETPOST('address', 'alpha');
$object->zip = GETPOST('zipcode', 'alpha');
$object->town = GETPOST('town', 'alpha');
@ -92,8 +90,7 @@ if ($action == 'confirm_delete' && $confirm == "yes")
$id = $object->create($user);
if ($id > 0)
{
if ($id > 0) {
header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
exit;
} else {
@ -106,11 +103,8 @@ if ($action == 'confirm_delete' && $confirm == "yes")
header("Location: ../admin/admin_establishment.php");
exit;
}
}
// Update record
elseif ($action == 'update')
{
} elseif ($action == 'update') {
// Update record
$error = 0;
if (!$cancel) {
@ -120,8 +114,7 @@ elseif ($action == 'update')
$error++;
}
if (empty($error))
{
if (empty($error)) {
$object->label = GETPOST('label', 'alphanohtml');
$object->address = GETPOST('address', 'alpha');
$object->zip = GETPOST('zipcode', 'alpha');
@ -133,8 +126,7 @@ elseif ($action == 'update')
$result = $object->update($user);
if ($result > 0)
{
if ($result > 0) {
header("Location: ".$_SERVER["PHP_SELF"]."?id=".$_POST['id']);
exit;
} else {
@ -159,8 +151,7 @@ $formcompany = new FormCompany($db);
/*
* Action create
*/
if ($action == 'create')
{
if ($action == 'create') {
print load_fiche_titre($langs->trans("NewEstablishment"));
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
@ -228,7 +219,9 @@ if ($action == 'create')
print '<td>'.$form->editfieldkey('Country', 'selectcountry_id', '', $object, 0).'</td>';
print '<td class="maxwidthonsmartphone">';
print $form->select_country(GETPOSTISSET('country_id') ? GETPOST('country_id', 'int') : ($object->country_id ? $object->country_id : $mysoc->country_id), 'country_id');
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
if ($user->admin) {
print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
}
print '</td>';
print '</tr>';
@ -253,15 +246,12 @@ if ($action == 'create')
}
// Part to edit record
if (($id || $ref) && $action == 'edit')
{
if (($id || $ref) && $action == 'edit') {
$result = $object->fetch($id);
if ($result > 0)
{
if ($result > 0) {
$head = establishment_prepare_head($object);
if ($action == 'edit')
{
if ($action == 'edit') {
print dol_get_fiche_head($head, 'card', $langs->trans("Establishment"), 0, 'building');
print '<form name="update" action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n";
@ -284,12 +274,12 @@ if (($id || $ref) && $action == 'edit')
// Entity
/*
if (! empty($conf->multicompany->enabled)) {
print '<tr><td>'.$form->editfieldkey('Parent', 'entity', '', $object, 0, 'string', '', 1).'</td>';
if (! empty($conf->multicompany->enabled)) {
print '<tr><td>'.$form->editfieldkey('Parent', 'entity', '', $object, 0, 'string', '', 1).'</td>';
print '<td class="maxwidthonsmartphone">';
print $object->entity > 0 ? $object->entity : $conf->entity;
print '</td></tr>';
}*/
print '</td></tr>';
}*/
// Address
print '<tr><td>'.$form->editfieldkey('Address', 'address', '', $object, 0).'</td>';
@ -313,7 +303,9 @@ if (($id || $ref) && $action == 'edit')
print '<tr><td>'.$form->editfieldkey('Country', 'selectcountry_id', '', $object, 0).'</td>';
print '<td class="maxwidthonsmartphone">';
print $form->select_country($object->country_id, 'country_id');
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
if ($user->admin) {
print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
}
print '</td>';
print '</tr>';
@ -334,19 +326,19 @@ if (($id || $ref) && $action == 'edit')
print '</form>';
}
} else dol_print_error($db);
} else {
dol_print_error($db);
}
}
if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create')))
{
if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) {
$res = $object->fetch_optionals();
$head = establishment_prepare_head($object);
print dol_get_fiche_head($head, 'card', $langs->trans("Establishment"), -1, 'building');
// Confirmation to delete
if ($action == 'delete')
{
if ($action == 'delete') {
print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id, $langs->trans("DeleteEstablishment"), $langs->trans("ConfirmDeleteEstablishment"), "confirm_delete");
}
@ -404,8 +396,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '<tr>';
print '<td>'.$langs->trans("Country").'</td>';
print '<td>';
if ($object->country_id > 0)
{
if ($object->country_id > 0) {
$img = picto_from_langcode($object->country_code);
print $img ? $img.' ' : '';
print getCountry($object->getCountryCode(), 0, $db);
@ -421,8 +412,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print dol_get_fiche_end();
/*
* Barre d'actions
*/
* Barre d'actions
*/
print '<div class="tabsAction">';
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&id='.$id.'">'.$langs->trans('Modify').'</a>';

View File

@ -37,7 +37,9 @@ $backtopage = GETPOST('backtopage', 'alpha');
if (GETPOST('actioncode', 'array')) {
$actioncode = GETPOST('actioncode', 'array', 3);
if (!count($actioncode)) $actioncode = '0';
if (!count($actioncode)) {
$actioncode = '0';
}
} else {
$actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT));
}
@ -47,12 +49,18 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
if (empty($page) || $page == -1) {
$page = 0;
} // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (!$sortfield) $sortfield = 'a.datep,a.id';
if (!$sortorder) $sortorder = 'DESC,DESC';
if (!$sortfield) {
$sortfield = 'a.datep,a.id';
}
if (!$sortorder) {
$sortorder = 'DESC,DESC';
}
// Initialize technical objects
$object = new Establishment($db);
@ -64,7 +72,9 @@ $extrafields->fetch_name_optionals_label($object->table_element);
// Load object
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
if ($id > 0 || !empty($ref)) $upload_dir = $conf->hrm->multidir_output[$object->entity]."/".$object->id;
if ($id > 0 || !empty($ref)) {
$upload_dir = $conf->hrm->multidir_output[$object->entity]."/".$object->id;
}
// Security check - Protection if external user
//if ($user->socid > 0) accessforbidden();
@ -80,20 +90,19 @@ $permissiontoadd = $user->rights->hrm->write; // Used by the include of actions_
$parameters = array('id'=>$id);
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if (empty($reshook))
{
if (empty($reshook)) {
// Cancel
if (GETPOST('cancel', 'alpha') && !empty($backtopage))
{
if (GETPOST('cancel', 'alpha') && !empty($backtopage)) {
header("Location: ".$backtopage);
exit;
}
// Purge search criteria
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers
{
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
$actioncode = '';
$search_agenda_label = '';
}
@ -107,14 +116,15 @@ if (empty($reshook))
$form = new Form($db);
if ($object->id > 0)
{
if ($object->id > 0) {
$title = $langs->trans("Agenda");
//if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name." - ".$title;
$help_url = '';
llxHeader('', $title, $help_url);
if (!empty($conf->notification->enabled)) $langs->load("mails");
if (!empty($conf->notification->enabled)) {
$langs->load("mails");
}
$head = establishment_prepare_head($object);

View File

@ -33,8 +33,12 @@ require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php';
if ($conf->deplacement->enabled) require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php';
if ($conf->expensereport->enabled) require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
if ($conf->deplacement->enabled) {
require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php';
}
if ($conf->expensereport->enabled) {
require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
}
require_once DOL_DOCUMENT_ROOT.'/recruitment/class/recruitmentcandidature.class.php';
require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php';
@ -47,9 +51,13 @@ $langs->loadLangs(array('users', 'holidays', 'trips', 'boxes'));
$socid = GETPOST("socid", "int");
// Protection if external user
if ($user->socid > 0) accessforbidden();
if ($user->socid > 0) {
accessforbidden();
}
if (empty($conf->global->MAIN_INFO_SOCIETE_NOM) || empty($conf->global->MAIN_INFO_SOCIETE_COUNTRY)) $setupcompanynotcomplete = 1;
if (empty($conf->global->MAIN_INFO_SOCIETE_NOM) || empty($conf->global->MAIN_INFO_SOCIETE_COUNTRY)) {
$setupcompanynotcomplete = 1;
}
$holiday = new Holiday($db);
$holidaystatic = new Holiday($db);
@ -63,8 +71,7 @@ $max = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT;
*/
// Update sold
if (!empty($conf->holiday->enabled) && !empty($setupcompanynotcomplete))
{
if (!empty($conf->holiday->enabled) && !empty($setupcompanynotcomplete)) {
$result = $holiday->updateBalance();
}
@ -81,8 +88,7 @@ llxHeader('', $langs->trans('HRMArea'));
print load_fiche_titre($langs->trans("HRMArea"), '', 'hrm');
if (!empty($setupcompanynotcomplete))
{
if (!empty($setupcompanynotcomplete)) {
$langs->load("errors");
$warnpicto = img_warning($langs->trans("WarningMandatorySetupNotComplete"));
print '<br><div class="warning"><a href="'.DOL_URL_ROOT.'/admin/company.php?mainmenu=home'.(empty($setupcompanynotcomplete) ? '' : '&action=edit').'">'.$warnpicto.' '.$langs->trans("WarningMandatorySetupNotComplete").'</a></div>';
@ -94,36 +100,34 @@ if (!empty($setupcompanynotcomplete))
print '<div class="fichecenter"><div class="fichethirdleft">';
if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo
{
if (!empty($conf->holiday->enabled) && $user->rights->holiday->read)
{
if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) { // This is useless due to the global search combo
if (!empty($conf->holiday->enabled) && $user->rights->holiday->read) {
$langs->load("holiday");
$listofsearchfields['search_holiday'] = array('text'=>'TitreRequestCP');
}
if (!empty($conf->deplacement->enabled) && $user->rights->deplacement->lire)
{
if (!empty($conf->deplacement->enabled) && $user->rights->deplacement->lire) {
$langs->load("trips");
$listofsearchfields['search_deplacement'] = array('text'=>'ExpenseReport');
}
if (!empty($conf->expensereport->enabled) && $user->rights->expensereport->lire)
{
if (!empty($conf->expensereport->enabled) && $user->rights->expensereport->lire) {
$langs->load("trips");
$listofsearchfields['search_expensereport'] = array('text'=>'ExpenseReport');
}
if (count($listofsearchfields))
{
if (count($listofsearchfields)) {
print '<form method="post" action="'.DOL_URL_ROOT.'/core/search.php">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder nohover centpercent">';
$i = 0;
foreach ($listofsearchfields as $key => $value)
{
if ($i == 0) print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Search").'</td></tr>';
foreach ($listofsearchfields as $key => $value) {
if ($i == 0) {
print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Search").'</td></tr>';
}
print '<tr '.$bc[false].'>';
print '<td class="nowrap"><label for="'.$key.'">'.$langs->trans($value["text"]).'</label></td><td><input type="text" class="flat inputsearch" name="'.$key.'" id="'.$key.'" size="18"></td>';
if ($i == 0) print '<td rowspan="'.count($listofsearchfields).'"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td>';
if ($i == 0) {
print '<td rowspan="'.count($listofsearchfields).'"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td>';
}
print '</tr>';
$i++;
}
@ -135,10 +139,8 @@ if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useles
}
if (!empty($conf->holiday->enabled))
{
if (empty($conf->global->HOLIDAY_HIDE_BALANCE))
{
if (!empty($conf->holiday->enabled)) {
if (empty($conf->global->HOLIDAY_HIDE_BALANCE)) {
$user_id = $user->id;
print '<div class="div-table-responsive-no-min">';
@ -149,8 +151,7 @@ if (!empty($conf->holiday->enabled))
$out = '';
$typeleaves = $holiday->getTypes(1, 1);
foreach ($typeleaves as $key => $val)
{
foreach ($typeleaves as $key => $val) {
$nb_type = $holiday->getCPforUser($user->id, $val['rowid']);
$nb_holiday += $nb_type;
$out .= ' - '.($langs->trans($val['code']) != $val['code'] ? $langs->trans($val['code']) : $val['label']).': <strong>'.($nb_type ? price2num($nb_type) : 0).'</strong><br>';
@ -161,8 +162,7 @@ if (!empty($conf->holiday->enabled))
print '</td>';
print '</tr>';
print '</table></div><br>';
} elseif (!is_numeric($conf->global->HOLIDAY_HIDE_BALANCE))
{
} elseif (!is_numeric($conf->global->HOLIDAY_HIDE_BALANCE)) {
print $langs->trans($conf->global->HOLIDAY_HIDE_BALANCE).'<br>';
}
}
@ -173,22 +173,22 @@ print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
// Latest leave requests
if (!empty($conf->holiday->enabled) && $user->rights->holiday->read)
{
if (!empty($conf->holiday->enabled) && $user->rights->holiday->read) {
$sql = "SELECT u.rowid as uid, u.lastname, u.firstname, u.login, u.email, u.photo, u.statut as user_status,";
$sql .= " x.rowid, x.rowid as ref, x.fk_type, x.date_debut as date_start, x.date_fin as date_end, x.halfday, x.tms as dm, x.statut as status";
$sql .= " FROM ".MAIN_DB_PREFIX."holiday as x, ".MAIN_DB_PREFIX."user as u";
$sql .= " WHERE u.rowid = x.fk_user";
$sql .= " AND x.entity = ".$conf->entity;
if (empty($user->rights->holiday->readall)) $sql .= ' AND x.fk_user IN ('.join(',', $childids).')';
if (empty($user->rights->holiday->readall)) {
$sql .= ' AND x.fk_user IN ('.join(',', $childids).')';
}
//if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND x.fk_soc = s. rowid AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
//if (!empty($socid)) $sql.= " AND x.fk_soc = ".$socid;
$sql .= $db->order("x.tms", "DESC");
$sql .= $db->plimit($max, 0);
$result = $db->query($sql);
if ($result)
{
if ($result) {
$var = false;
$num = $db->num_rows($result);
@ -208,10 +208,8 @@ if (!empty($conf->holiday->enabled) && $user->rights->holiday->read)
print '<th>'.$langs->trans("to").'</th>';
print '<th class="right" colspan="2"><a href="'.DOL_URL_ROOT.'/holiday/list.php?sortfield=cp.tms&sortorder=DESC">'.$langs->trans("FullList").'</th>';
print '</tr>';
if ($num)
{
while ($i < $num && $i < $max)
{
if ($num) {
while ($i < $num && $i < $max) {
$obj = $db->fetch_object($result);
$holidaystatic->id = $obj->rowid;
@ -248,28 +246,30 @@ if (!empty($conf->holiday->enabled) && $user->rights->holiday->read)
print '</table>';
print '</div>';
print '<br>';
} else dol_print_error($db);
} else {
dol_print_error($db);
}
}
// Latest expense report
if (!empty($conf->expensereport->enabled) && $user->rights->expensereport->lire)
{
if (!empty($conf->expensereport->enabled) && $user->rights->expensereport->lire) {
$sql = "SELECT u.rowid as uid, u.lastname, u.firstname, u.login, u.email, u.statut as user_status, u.photo,";
$sql .= " x.rowid, x.ref, x.date_debut as date, x.tms as dm, x.total_ttc, x.fk_statut as status";
$sql .= " FROM ".MAIN_DB_PREFIX."expensereport as x, ".MAIN_DB_PREFIX."user as u";
//if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql .= " WHERE u.rowid = x.fk_user_author";
$sql .= " AND x.entity = ".$conf->entity;
if (empty($user->rights->expensereport->readall) && empty($user->rights->expensereport->lire_tous)) $sql .= ' AND x.fk_user_author IN ('.join(',', $childids).')';
if (empty($user->rights->expensereport->readall) && empty($user->rights->expensereport->lire_tous)) {
$sql .= ' AND x.fk_user_author IN ('.join(',', $childids).')';
}
//if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND x.fk_soc = s. rowid AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
//if (!empty($socid)) $sql.= " AND x.fk_soc = ".$socid;
$sql .= $db->order("x.tms", "DESC");
$sql .= $db->plimit($max, 0);
$result = $db->query($sql);
if ($result)
{
if ($result) {
$num = $db->num_rows($result);
$i = 0;
@ -281,14 +281,12 @@ if (!empty($conf->expensereport->enabled) && $user->rights->expensereport->lire)
print '<th class="right">'.$langs->trans("TotalTTC").'</th>';
print '<th class="right" colspan="2"><a href="'.DOL_URL_ROOT.'/expensereport/list.php?sortfield=d.tms&sortorder=DESC">'.$langs->trans("FullList").'</th>';
print '</tr>';
if ($num)
{
if ($num) {
$total_ttc = $totalam = $total = 0;
$expensereportstatic = new ExpenseReport($db);
$userstatic = new User($db);
while ($i < $num && $i < $max)
{
while ($i < $num && $i < $max) {
$obj = $db->fetch_object($result);
$expensereportstatic->id = $obj->rowid;
@ -320,26 +318,32 @@ if (!empty($conf->expensereport->enabled) && $user->rights->expensereport->lire)
print '</table>';
print '</div>';
print '<br>';
} else dol_print_error($db);
} else {
dol_print_error($db);
}
}
// Last modified job position
if (!empty($conf->recruitment->enabled) && $user->rights->recruitment->recruitmentjobposition->read)
{
if (!empty($conf->recruitment->enabled) && $user->rights->recruitment->recruitmentjobposition->read) {
$sql = "SELECT rc.rowid, rc.ref, rc.email, rc.lastname, rc.firstname, rc.date_creation, rc.tms, rc.status";
$sql .= " FROM ".MAIN_DB_PREFIX."recruitment_recruitmentcandidature as rc";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."recruitment_recruitmentjobposition as s ON rc.fk_recruitmentjobposition = s.rowid";
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
if (!$user->rights->societe->client->voir && !$socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE rc.entity IN (".getEntity($staticrecruitmentjobposition->element).")";
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id;
if ($socid) $sql .= " AND s.fk_soc = $socid";
if (!$user->rights->societe->client->voir && !$socid) {
$sql .= " AND s.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id;
}
if ($socid) {
$sql .= " AND s.fk_soc = $socid";
}
$sql .= " ORDER BY rc.tms DESC";
$sql .= $db->plimit($max, 0);
$resql = $db->query($sql);
if ($resql)
{
if ($resql) {
$num = $db->num_rows($resql);
$i = 0;
@ -351,10 +355,8 @@ if (!empty($conf->recruitment->enabled) && $user->rights->recruitment->recruitme
print '</th>';
print '<th class="right" colspan="2"><a href="'.DOL_URL_ROOT.'/recruitment/recruitmentcandidature_list.php?sortfield=t.tms&sortorder=DESC">'.$langs->trans("FullList").'</th>';
print '</tr>';
if ($num)
{
while ($i < $num)
{
if ($num) {
while ($i < $num) {
$objp = $db->fetch_object($resql);
$staticrecruitmentcandidature->id = $objp->rowid;
$staticrecruitmentcandidature->ref = $objp->ref;

View File

@ -87,15 +87,17 @@ class Import
$modulesdir = dolGetModulesDirs();
// Load list of modules
foreach ($modulesdir as $dir)
{
foreach ($modulesdir as $dir) {
$handle = @opendir(dol_osencode($dir));
if (!is_resource($handle)) continue;
if (!is_resource($handle)) {
continue;
}
// Search module files
while (($file = readdir($handle)) !== false)
{
if (!preg_match("/^(mod.*)\.class\.php/i", $file, $reg)) continue;
while (($file = readdir($handle)) !== false) {
if (!preg_match("/^(mod.*)\.class\.php/i", $file, $reg)) {
continue;
}
$modulename = $reg[1];
@ -103,10 +105,16 @@ class Import
$enabled = true;
$part = strtolower(preg_replace('/^mod/i', '', $modulename));
// Adds condition for propal module
if ($part === 'propale') $part = 'propal';
if (empty($conf->$part->enabled)) $enabled = false;
if ($part === 'propale') {
$part = 'propal';
}
if (empty($conf->$part->enabled)) {
$enabled = false;
}
if (empty($enabled)) continue;
if (empty($enabled)) {
continue;
}
// Init load class
$file = $dir."/".$modulename.".class.php";
@ -114,11 +122,11 @@ class Import
require_once $file;
$module = new $classname($this->db);
if (isset($module->import_code) && is_array($module->import_code))
{
foreach ($module->import_code as $r => $value)
{
if ($filter && ($filter != $module->import_code[$r])) continue;
if (isset($module->import_code) && is_array($module->import_code)) {
foreach ($module->import_code as $r => $value) {
if ($filter && ($filter != $module->import_code[$r])) {
continue;
}
// Test if permissions are ok
/*$perm=$module->import_permission[$r][0];
@ -137,10 +145,8 @@ class Import
// Load lang file
$langtoload = $module->getLangFilesArray();
if (is_array($langtoload))
{
foreach ($langtoload as $key)
{
if (is_array($langtoload)) {
foreach ($langtoload as $key) {
$langs->load($key);
}
}
@ -246,9 +252,15 @@ class Import
dol_syslog("Import.class.php::create");
// Check parameters
if (empty($this->model_name)) { $this->error = 'ErrorWrongParameters'; return -1; }
if (empty($this->datatoimport)) { $this->error = 'ErrorWrongParameters'; return -1; }
if (empty($this->hexa)) { $this->error = 'ErrorWrongParameters'; return -1; }
if (empty($this->model_name)) {
$this->error = 'ErrorWrongParameters'; return -1;
}
if (empty($this->datatoimport)) {
$this->error = 'ErrorWrongParameters'; return -1;
}
if (empty($this->hexa)) {
$this->error = 'ErrorWrongParameters'; return -1;
}
$this->db->begin();
@ -259,8 +271,7 @@ class Import
dol_syslog(get_class($this)."::create", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
if ($resql) {
$this->db->commit();
return 1;
} else {
@ -285,11 +296,9 @@ class Import
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
$result = $this->db->query($sql);
if ($result)
{
if ($result) {
$obj = $this->db->fetch_object($result);
if ($obj)
{
if ($obj) {
$this->id = $obj->rowid;
$this->hexa = $obj->field;
$this->model_name = $obj->label;
@ -325,26 +334,24 @@ class Import
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
if (!$resql) {
$error++; $this->errors[] = "Error ".$this->db->lasterror();
}
if (!$error)
{
if (!$notrigger)
{
if (!$error) {
if (!$notrigger) {
/* Not used. This is not a business object. To convert it we must herit from CommonObject
// Call trigger
$result=$this->call_trigger('IMPORT_DELETE',$user);
if ($result < 0) $error++;
// End call triggers
*/
// Call trigger
$result=$this->call_trigger('IMPORT_DELETE',$user);
if ($result < 0) $error++;
// End call triggers
*/
}
}
// Commit or rollback
if ($error)
{
foreach ($this->errors as $errmsg)
{
if ($error) {
foreach ($this->errors as $errmsg) {
dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
}

View File

@ -21,7 +21,9 @@
* \brief Show example of import file
*/
if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on)
if (!defined('NOTOKENRENEWAL')) {
define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on)
}
/**
@ -58,8 +60,7 @@ $format = GETPOST('format');
$langs->load("exports");
// Check exportkey
if (empty($datatoimport))
{
if (empty($datatoimport)) {
$user->getrights();
llxHeader();
@ -81,23 +82,30 @@ $fieldstarget = $objimport->array_import_fields[0];
$valuestarget = $objimport->array_import_examplevalues[0];
$attachment = true;
if (isset($_GET["attachment"])) $attachment = $_GET["attachment"];
if (isset($_GET["attachment"])) {
$attachment = $_GET["attachment"];
}
//$attachment = false;
$contenttype = dol_mimetype($format);
if (isset($_GET["contenttype"])) $contenttype = $_GET["contenttype"];
if (isset($_GET["contenttype"])) {
$contenttype = $_GET["contenttype"];
}
//$contenttype='text/plain';
$outputencoding = 'UTF-8';
if ($contenttype) header('Content-Type: '.$contenttype.($outputencoding ? '; charset='.$outputencoding : ''));
if ($attachment) header('Content-Disposition: attachment; filename="'.$filename.'"');
if ($contenttype) {
header('Content-Type: '.$contenttype.($outputencoding ? '; charset='.$outputencoding : ''));
}
if ($attachment) {
header('Content-Disposition: attachment; filename="'.$filename.'"');
}
// List of targets fields
$headerlinefields = array();
$contentlinevalues = array();
$i = 0;
foreach ($fieldstarget as $code=>$label)
{
foreach ($fieldstarget as $code => $label) {
$withoutstar = preg_replace('/\*/', '', $fieldstarget[$code]);
$headerlinefields[] = $langs->transnoentities($withoutstar).($withoutstar != $fieldstarget[$code] ? '*' : '').' ('.$code.')';
$contentlinevalues[] = $valuestarget[$code];

File diff suppressed because it is too large Load Diff

View File

@ -27,8 +27,9 @@ require_once DOL_DOCUMENT_ROOT.'/imports/class/import.class.php';
// Load translation files required by the page
$langs->load("exports");
if (!$user->socid == 0)
accessforbidden();
if (!$user->socid == 0) {
accessforbidden();
}
$import = new Import($db);
$import->load_arrays($user);
@ -49,8 +50,7 @@ print '<br>';
print '<div class="center">';
if (count($import->array_import_code))
{
if (count($import->array_import_code)) {
print dolGetButtonTitle($langs->trans('NewImport'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/imports/import.php?leftmenu=import');
}
print '</div>';
@ -70,8 +70,7 @@ include_once DOL_DOCUMENT_ROOT.'/core/modules/import/modules_import.php';
$model = new ModeleImports();
$list = $model->liste_modeles($db);
foreach ($list as $key)
{
foreach ($list as $key) {
print '<tr class="oddeven">';
print '<td width="16">'.img_picto_common($model->getDriverLabelForKey($key), $model->getPictoForKey($key)).'</td>';
$text = $model->getDriverDescForKey($key);

View File

@ -64,7 +64,8 @@ pHeader('', ''); // No next step for navigation buttons. Next step is defined by
//print "<br>\n";
//print $langs->trans("InstallEasy")."<br><br>\n";
print '<h3><img class="valigntextbottom" src="../theme/common/octicons/build/svg/gear.svg" width="20" alt="Database"> '.$langs->trans("MiscellaneousChecks").":</h3>\n";
print '<h3><img class="valigntextbottom inline-block" src="../theme/common/octicons/build/svg/gear.svg" width="20" alt="Database"> ';
print '<span class="inline-block">'.$langs->trans("MiscellaneousChecks")."</span></h3>\n";
// Check browser
$useragent = $_SERVER['HTTP_USER_AGENT'];

View File

@ -20,6 +20,10 @@
opacity: 0.5;
}
.inline-block {
display: inline-block;
}
body {
font-size:14px;
font-family: roboto,arial,tahoma,verdana,helvetica;
@ -353,15 +357,16 @@ tr.choiceselected td.listofchoicesdesc {
}
tr.choiceselected td .button {
background: rgb(0,113,121);
background: rgba(150, 110, 162, 0.95);
color: #fff;
}
a.button:link,a.button:visited,a.button:active {
color: #888;
}
.button {
background: #ddd;
background: rgb(234,228,225);
color: #fff;
/* border: 1px solid #e0e0e0; */
padding: 0.5em 0.7em;

View File

@ -483,9 +483,10 @@ function pHeader($subtitle, $next, $action = 'set', $param = '', $forcejqueryurl
* @param string $setuplang Language code
* @param string $jscheckfunction Add a javascript check function
* @param integer $withpleasewait Add also please wait tags
* @param string $morehtml Add more HTML content
* @return void
*/
function pFooter($nonext = 0, $setuplang = '', $jscheckfunction = '', $withpleasewait = 0)
function pFooter($nonext = 0, $setuplang = '', $jscheckfunction = '', $withpleasewait = 0, $morehtml = '')
{
global $conf, $langs;
@ -494,6 +495,10 @@ function pFooter($nonext = 0, $setuplang = '', $jscheckfunction = '', $withpleas
print '</td></tr></table>'."\n";
print '</td></tr></table>'."\n";
print '<!-- pFooter -->'."\n";
print $morehtml;
if (!$nonext || ($nonext == '2')) {
print '<div class="nextbutton" id="nextbutton">';
if ($nonext == '2') {

View File

@ -583,3 +583,8 @@ insert into llx_c_action_trigger (code,label,description,elementtype,rang) value
insert into llx_c_actioncomm (id, code, type, libelle, module, active, position) values ( 6,'AC_EMAIL_IN','system','reception Email',NULL, 1, 4);
-- VMYSQL4.3 ALTER TABLE llx_accounting_bookkeeping MODIFY COLUMN montant double(24,8) NULL;
-- VPGSQL8.2 ALTER TABLE llx_accounting_bookkeeping ALTER COLUMN montant DROP NOT NULL;

View File

@ -40,6 +40,9 @@ ALTER TABLE llx_asset_extrafields ADD INDEX idx_asset_extrafields (fk_object);
insert into llx_c_actioncomm (id, code, type, libelle, module, active, position) values ( 6,'AC_EMAIL_IN','system','reception Email',NULL, 1, 4);
-- VMYSQL4.3 ALTER TABLE llx_accounting_bookkeeping MODIFY COLUMN montant double(24,8) NULL;
-- VPGSQL8.2 ALTER TABLE llx_accounting_bookkeeping ALTER COLUMN montant DROP NOT NULL;
-- For v14
ALTER TABLE llx_c_availability ADD COLUMN position integer NOT NULL DEFAULT 0;
@ -135,6 +138,9 @@ ALTER TABLE llx_menu ADD COLUMN prefix varchar(255) NULL AFTER titre;
ALTER TABLE llx_chargesociales ADD COLUMN fk_user integer DEFAULT NULL;
ALTER TABLE llx_mrp_production ADD COLUMN origin_id integer AFTER fk_mo;
ALTER TABLE llx_mrp_production ADD COLUMN origin_type varchar(10) AFTER origin_id;
ALTER TABLE llx_fichinter ADD COLUMN last_main_doc varchar(255) AFTER model_pdf;
ALTER TABLE llx_projet ADD COLUMN last_main_doc varchar(255) AFTER model_pdf;

View File

@ -35,7 +35,7 @@ CREATE TABLE llx_accounting_bookkeeping
label_operation varchar(255), -- FEC:EcritureLib | label of the operation
debit double(24,8) NOT NULL, -- FEC:Debit
credit double(24,8) NOT NULL, -- FEC:Credit
montant double(24,8) NOT NULL, -- FEC:Montant (Not necessary)
montant double(24,8) NULL, -- FEC:Montant (Not necessary)
sens varchar(1) DEFAULT NULL, -- FEC:Sens (Not necessary)
multicurrency_amount double(24,8), -- FEC:Montantdevise
multicurrency_code varchar(255), -- FEC:Idevise

View File

@ -17,6 +17,8 @@
CREATE TABLE llx_mrp_production(
rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL,
fk_mo integer NOT NULL,
origin_id integer,
origin_type varchar(10), -- 'bom' bom production line or 'free' free production line added after Mo creation from bom
position integer NOT NULL DEFAULT 0,
fk_product integer NOT NULL,
fk_warehouse integer,
@ -24,7 +26,7 @@ CREATE TABLE llx_mrp_production(
qty_frozen smallint DEFAULT 0,
disable_stock_change smallint DEFAULT 0,
batch varchar(128),
role varchar(10), -- 'toconsume' or 'toproduce' (initialized at MO creation), 'consumed' or 'produced' (added after MO validation)
role varchar(10), -- 'toconsume' or 'toproduce' (initialized at MO creation), 'consumed' or 'produced' (added after MO validation)
fk_mrp_production integer, -- if role = 'consumed', id of line with role 'toconsume', if role = 'produced' id of line with role 'toproduce'
fk_stock_movement integer, -- id of stock movement when movements are validated
date_creation datetime NOT NULL,

File diff suppressed because it is too large Load Diff

View File

@ -112,6 +112,8 @@ if ($action == "set") {
* View
*/
$morehtml = '';
pHeader($langs->trans("SetupEnd"), "step5");
print '<br>';
@ -424,11 +426,11 @@ if ($action == "set" && $success) {
print '<br><div class="warning">'.$langs->trans("WarningRemoveInstallDir")."</div>";
}
print "<br><br>";
print "<br>";
print '<div class="center"><a href="../index.php?mainmenu=home'.(isset($login) ? '&username='.urlencode($login) : '').'">';
print '<span class="fas fa-link-alt"></span> '.$langs->trans("GoToDolibarr").'...';
print '</a></div><br>';
$morehtml = '<br><div class="center"><a href="../index.php?mainmenu=home'.(isset($login) ? '&username='.urlencode($login) : '').'">';
$morehtml .= '<span class="fas fa-link-alt"></span> '.$langs->trans("GoToDolibarr").'...';
$morehtml .= '</a></div><br>';
} else {
// If here MAIN_VERSION_LAST_UPGRADE is not empty
print $langs->trans("VersionLastUpgrade").': <b><span class="ok">'.$conf->global->MAIN_VERSION_LAST_UPGRADE.'</span></b><br>';
@ -436,9 +438,9 @@ if ($action == "set" && $success) {
print "<br>";
print '<div class="center"><a href="../install/index.php">';
print '<span class="fas fa-link-alt"></span> '.$langs->trans("GoToUpgradePage");
print '</a></div>';
$morehtml = '<br><div class="center"><a href="../install/index.php">';
$morehtml .= '<span class="fas fa-link-alt"></span> '.$langs->trans("GoToUpgradePage");
$morehtml .= '</a></div>';
}
} else {
dol_print_error('', 'step5.php: unknown choice of action');
@ -455,7 +457,7 @@ dolibarr_install_syslog("Exit ".$ret);
dolibarr_install_syslog("- step5: Dolibarr setup finished");
pFooter(1, $setuplang);
pFooter(1, $setuplang, '', 0, $morehtml);
// Return code if ran from command line
if ($ret) {

View File

@ -110,7 +110,8 @@ $actiondone = 0;
if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ09'))) {
$actiondone = 1;
print '<h3><img class="valigntextbottom" src="../theme/common/octicons/build/svg/database.svg" width="20" alt="Database"> '.$langs->trans("DatabaseMigration").'</h3>';
print '<h3><img class="valigntextbottom inline-block" src="../theme/common/octicons/build/svg/database.svg" width="20" alt="Database"> ';
print '<span class="inline-block">'.$langs->trans("DatabaseMigration").'</span></h3>';
print '<table cellspacing="0" cellpadding="1" border="0" width="100%">';
$error = 0;

View File

@ -117,7 +117,8 @@ pHeader('', 'step5', GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'upg
if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ09'))) {
print '<h3><img class="valigntextbottom" src="../theme/common/octicons/build/svg/database.svg" width="20" alt="Database"> '.$langs->trans('DataMigration').'</h3>';
print '<h3><img class="valigntextbottom inline-block" src="../theme/common/octicons/build/svg/database.svg" width="20" alt="Database"> ';
print '<span class="inline-block">'.$langs->trans('DataMigration').'</span></h3>';
print '<table cellspacing="0" cellpadding="1" border="0" width="100%">';
@ -455,6 +456,7 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
$listofmodule = array(
'MAIN_MODULE_ACCOUNTING'=>'newboxdefonly',
'MAIN_MODULE_AGENDA'=>'newboxdefonly',
'MAIN_MODULE_BANQUE'=>'menuonly',
'MAIN_MODULE_BARCODE'=>'newboxdefonly',
'MAIN_MODULE_CRON'=>'newboxdefonly',
'MAIN_MODULE_COMMANDE'=>'newboxdefonly',
@ -472,11 +474,13 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
'MAIN_MODULE_PAYBOX'=>'newboxdefonly',
'MAIN_MODULE_PRINTING'=>'newboxdefonly',
'MAIN_MODULE_PRODUIT'=>'newboxdefonly',
'MAIN_MODULE_RECRUITMENT'=>'menuonly',
'MAIN_MODULE_RESOURCE'=>'noboxes',
'MAIN_MODULE_SALARIES'=>'newboxdefonly',
'MAIN_MODULE_SERVICE'=>'newboxdefonly',
'MAIN_MODULE_SYSLOG'=>'newboxdefonly',
'MAIN_MODULE_SOCIETE'=>'newboxdefonly',
'MAIN_MODULE_SERVICE'=>'newboxdefonly',
'MAIN_MODULE_STRIPE'=>'menuonly',
'MAIN_MODULE_TICKET'=>'newboxdefonly',
'MAIN_MODULE_TAKEPOS'=>'newboxdefonly',
'MAIN_MODULE_USER'=>'newboxdefonly', //This one must be always done and only into last targeted version)
@ -521,7 +525,7 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
print "<!-- (".$reshook.") -->";
print '</td></tr>';
} else {
print '<tr><td colspan="4">';
print '<tr class="trforrunsql"><td colspan="4">';
print '<b>'.$langs->trans('UpgradeExternalModule').'</b>: <span class="ok">OK</span>';
print "<!-- (".$reshook.") -->";
print '</td></tr>';
@ -529,7 +533,7 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
} else {
//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 '<tr class="trforrunsql"><td colspan="4">';
print '<b>'.$langs->trans('UpgradeExternalModule').'</b>: '.$langs->trans("None");
print '</td></tr>';
}
@ -539,6 +543,7 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
print '</table>';
// Set constant to ask to remake a new ping to inform about upgrade (if first ping was done and OK)
$sql = 'UPDATE '.MAIN_DB_PREFIX."const SET VALUE = 'torefresh' WHERE name = 'MAIN_FIRST_PING_OK_ID'";
$db->query($sql, 1);
@ -563,7 +568,39 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
// Actions for all versions (no database change but rename some directories)
migrate_rename_directories($db, $langs, $conf, '/banque/bordereau', '/bank/checkdeposits');
print '<div><br>'.$langs->trans("MigrationFinished").'</div>';
$silent = 0;
if (!$silent) {
print '<table width="100%">';
print '<tr><td style="width: 30%">'.$langs->trans("MigrationFinished").'</td>';
print '<td class="right">';
if ($error == 0) {
//print '<span class="ok">'.$langs->trans("OK").'</span> - '; // $error = 0 does not mean there is no error (error are not always trapped)
} else {
print '<span class="error">'.$langs->trans("Error").'</span> - ';
}
//if (!empty($conf->use_javascript_ajax)) { // use_javascript_ajax is not defined
print '<script type="text/javascript" language="javascript">
jQuery(document).ready(function() {
function init_trrunsql()
{
console.log("toggle .trforrunsql");
jQuery(".trforrunsql").toggle();
}
init_trrunsql();
jQuery(".trforrunsqlshowhide").click(function() {
init_trrunsql();
});
});
</script>';
print '<a class="trforrunsqlshowhide" href="#">'.$langs->trans("ShowHideDetails").'</a>';
//}
print '</td></tr>'."\n";
print '</table>';
}
//print '<div><br>'.$langs->trans("MigrationFinished").'</div>';
} else {
print '<div class="error">'.$langs->trans('ErrorWrongParameters').'</div>';
$error++;
@ -4296,7 +4333,7 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo
$mod = new $classname($db);
//$mod->remove('noboxes');
$mod->delete_menus(); // We must delete to be sure it is insert with new values
$mod->delete_menus(); // We must delete to be sure it is inserted with new values
$mod->init($reloadmode);
} else {
dolibarr_install_syslog('Failed to include '.DOL_DOCUMENT_ROOT.'/core/modules/mod'.$moduletoreloadshort.'.class.php');
@ -4320,7 +4357,7 @@ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $fo
}
if (!empty($mod) && is_object($mod)) {
print '<tr><td colspan="4">';
print '<tr class="trforrunsql"><td colspan="4">';
print '<b>'.$langs->trans('Upgrade').'</b>: ';
print $langs->trans('MigrationReloadModule').' '.$mod->getName(); // We keep getName outside of trans because getName is already encoded/translated
print "<!-- (".$reloadmode.") -->";
@ -4355,7 +4392,7 @@ function migrate_reload_menu($db, $langs, $conf)
}
foreach ($listofmenuhandler as $key => $val) {
print '<tr><td colspan="4">';
print '<tr class="trforrunsql"><td colspan="4">';
//print "x".$key;
print '<br>';

View File

@ -30,7 +30,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
// Load translation files required by the page
$langs->loadLangs(array("admin", "intracommreport"));
if (!$user->admin) accessforbidden();
if (!$user->admin) {
accessforbidden();
}
$action = GETPOST('action', 'aZ09');
@ -46,10 +48,8 @@ $list_DES = array(
if ($action == 'update') {
$error = 0;
if (!$error)
{
foreach ($list_DEB as $constname)
{
if (!$error) {
foreach ($list_DEB as $constname) {
$constvalue = GETPOST($constname, 'alpha');
if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
@ -57,8 +57,7 @@ if ($action == 'update') {
}
}
foreach ($list_DES as $constname)
{
foreach ($list_DES as $constname) {
$constvalue = GETPOST($constname, 'alpha');
if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
@ -110,8 +109,7 @@ print '<td>'.$langs->trans("Description").'</td>';
print '<td>'.$langs->trans("Value").'</td>';
print '</tr>';
foreach ($list_DEB as $key)
{
foreach ($list_DEB as $key) {
print '<tr class="oddeven value">';
// Param
@ -175,8 +173,7 @@ print '<td>'.$langs->trans("Description").'</td>';
print '<td>'.$langs->trans("Value").'</td>';
print '</tr>';
foreach ($list_DES as $key)
{
foreach ($list_DES as $key) {
print '<tr class="oddeven value">';
// Param

View File

@ -172,13 +172,13 @@ ProfId1ES=Prof Id 1 (CIF/NIF)
ProfId2ES=Prof Id 2 (Social security number)
ProfId3ES=Prof Id 3 (CNAE)
ProfId4ES=Prof Id 4 (Collegiate number)
ProfId5ES=EORI number
ProfId5ES=Prof Id 5 (EORI number)
ProfId6ES=-
ProfId1FR=Prof Id 1 (SIREN)
ProfId2FR=Prof Id 2 (SIRET)
ProfId3FR=Prof Id 3 (NAF, old APE)
ProfId4FR=Prof Id 4 (RCS/RM)
ProfId5FR=EORI number
ProfId5FR=Prof Id 5 (numéro EORI)
ProfId6FR=-
ProfId1GB=Registration Number
ProfId2GB=-
@ -232,7 +232,7 @@ ProfId1PT=Prof Id 1 (NIPC)
ProfId2PT=Prof Id 2 (Social security number)
ProfId3PT=Prof Id 3 (Commercial Record number)
ProfId4PT=Prof Id 4 (Conservatory)
ProfId5PT=EORI number
ProfId5PT=Prof Id 5 (EORI number)
ProfId6PT=-
ProfId1SN=RC
ProfId2SN=NINEA
@ -256,7 +256,7 @@ ProfId1RO=Prof Id 1 (CUI)
ProfId2RO=Prof Id 2 (Nr. Înmatriculare)
ProfId3RO=Prof Id 3 (CAEN)
ProfId4RO=Prof Id 5 (EUID)
ProfId5RO=EORI number
ProfId5RO=Prof Id 5 (EORI number)
ProfId6RO=-
ProfId1RU=Prof Id 1 (OGRN)
ProfId2RU=Prof Id 2 (INN)

View File

@ -89,7 +89,7 @@ ConfirmEnableWorkstation=Are you sure you want to enable workstation <b>%s</b> ?
EnableAWorkstation=Enable a workstation
ConfirmDisableWorkstation=Are you sure you want to disable workstation <b>%s</b> ?
DisableAWorkstation=Disable a workstation
DeleteWorkstation=Supprimer
DeleteWorkstation=Delete
NbOperatorsRequired=Number of operators required
THMOperatorEstimated=Estimated operator THM
THMMachineEstimated=Estimated machine THM

View File

@ -1,8 +1,10 @@
# ProductBATCH language file - en_US - ProductBATCH
ManageLotSerial=Use lot/serial number
ProductStatusOnBatch=Yes (lot/serial required)
ProductStatusOnBatch=Yes (lot required)
ProductStatusOnSerial=Yes (unique serial number required)
ProductStatusNotOnBatch=No (lot/serial not used)
ProductStatusOnBatchShort=Yes
ProductStatusOnBatchShort=Lot
ProductStatusOnSerialShort=Serial
ProductStatusNotOnBatchShort=No
Batch=Lot/Serial
atleast1batchfield=Eat-by date or Sell-by date or Lot/Serial number

View File

@ -1,8 +1,10 @@
# ProductBATCH language file - en_US - ProductBATCH
ManageLotSerial=Utiliser les numéros de lots/série
ProductStatusOnBatch=Oui (Lot/Série requis)
ProductStatusOnBatch=Lot (requis)
ProductStatusOnSerial=Numéro de série (doit être unique pour chaque équipement)
ProductStatusNotOnBatch=Non (Lot/Série non utilisé)
ProductStatusOnBatchShort=Oui
ProductStatusOnBatchShort=Lot
ProductStatusOnSerialShort=N°série
ProductStatusNotOnBatchShort=Non
Batch=Lot/Série
atleast1batchfield=Date limite utilisation optimale, de consommation ou numéro de lot/série

View File

@ -24,9 +24,15 @@
* \brief File to calculate loan monthly payments
*/
if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal
if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1');
if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1');
if (!defined('NOTOKENRENEWAL')) {
define('NOTOKENRENEWAL', '1'); // Disables token renewal
}
if (!defined('NOREQUIREMENU')) {
define('NOREQUIREMENU', '1');
}
if (!defined('NOREQUIREAJAX')) {
define('NOREQUIREAJAX', '1');
}
require '../main.inc.php';
require DOL_DOCUMENT_ROOT.'/core/lib/loan.lib.php';

View File

@ -28,8 +28,12 @@ require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/loan.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
if (!empty($conf->accounting->enabled)) {
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
}
if (!empty($conf->accounting->enabled)) {
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
}
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
@ -45,7 +49,9 @@ $projectid = GETPOST('projectid', 'int');
// Security check
$socid = GETPOST('socid', 'int');
if ($user->socid) $socid = $user->socid;
if ($user->socid) {
$socid = $user->socid;
}
$result = restrictedArea($user, 'loan', $id, '', '');
$object = new Loan($db);
@ -60,16 +66,15 @@ $error = 0;
*/
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if (empty($reshook))
{
if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if (empty($reshook)) {
// Classify paid
if ($action == 'confirm_paid' && $confirm == 'yes' && $user->rights->loan->write)
{
if ($action == 'confirm_paid' && $confirm == 'yes' && $user->rights->loan->write) {
$object->fetch($id);
$result = $object->setPaid($user);
if ($result > 0)
{
if ($result > 0) {
setEventMessages($langs->trans('LoanPaid'), null, 'mesgs');
} else {
setEventMessages($loan->error, null, 'errors');
@ -77,12 +82,10 @@ if (empty($reshook))
}
// Delete loan
if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->loan->write)
{
if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->loan->write) {
$object->fetch($id);
$result = $object->delete($user);
if ($result > 0)
{
if ($result > 0) {
setEventMessages($langs->trans('LoanDeleted'), null, 'mesgs');
header("Location: list.php");
exit;
@ -92,44 +95,37 @@ if (empty($reshook))
}
// Add loan
if ($action == 'add' && $user->rights->loan->write)
{
if (!$cancel)
{
if ($action == 'add' && $user->rights->loan->write) {
if (!$cancel) {
$datestart = dol_mktime(12, 0, 0, GETPOST('startmonth', 'int'), GETPOST('startday', 'int'), GETPOST('startyear', 'int'));
$dateend = dol_mktime(12, 0, 0, GETPOST('endmonth', 'int'), GETPOST('endday', 'int'), GETPOST('endyear', 'int'));
$capital = price2num(GETPOST('capital'));
$rate = GETPOST('rate');
if (!$capital)
{
if (!$capital) {
$error++; $action = 'create';
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("LoanCapital")), null, 'errors');
}
if (!$datestart)
{
if (!$datestart) {
$error++; $action = 'create';
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("DateStart")), null, 'errors');
}
if (!$dateend)
{
if (!$dateend) {
$error++; $action = 'create';
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("DateEnd")), null, 'errors');
}
if ($rate == '')
{
if ($rate == '') {
$error++; $action = 'create';
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Rate")), null, 'errors');
}
if (!$error)
{
if (!$error) {
$object->label = GETPOST('label');
$object->fk_bank = GETPOST('accountid');
$object->capital = $capital;
$object->fk_bank = GETPOST('accountid');
$object->capital = $capital;
$object->datestart = $datestart;
$object->dateend = $dateend;
$object->nbterm = GETPOST('nbterm');
$object->dateend = $dateend;
$object->nbterm = GETPOST('nbterm');
$object->rate = $rate;
$object->note_private = GETPOST('note_private', 'restricthtml');
$object->note_public = GETPOST('note_public', 'restricthtml');
@ -140,13 +136,24 @@ if (empty($reshook))
$accountancy_account_insurance = GETPOST('accountancy_account_insurance');
$accountancy_account_interest = GETPOST('accountancy_account_interest');
if ($accountancy_account_capital <= 0) { $object->account_capital = ''; } else { $object->account_capital = $accountancy_account_capital; }
if ($accountancy_account_insurance <= 0) { $object->account_insurance = ''; } else { $object->account_insurance = $accountancy_account_insurance; }
if ($accountancy_account_interest <= 0) { $object->account_interest = ''; } else { $object->account_interest = $accountancy_account_interest; }
if ($accountancy_account_capital <= 0) {
$object->account_capital = '';
} else {
$object->account_capital = $accountancy_account_capital;
}
if ($accountancy_account_insurance <= 0) {
$object->account_insurance = '';
} else {
$object->account_insurance = $accountancy_account_insurance;
}
if ($accountancy_account_interest <= 0) {
$object->account_interest = '';
} else {
$object->account_interest = $accountancy_account_interest;
}
$id = $object->create($user);
if ($id <= 0)
{
if ($id <= 0) {
$error++;
setEventMessages($object->error, $object->errors, 'errors');
$action = 'create';
@ -156,21 +163,16 @@ if (empty($reshook))
header("Location: list.php");
exit();
}
}
// Update record
elseif ($action == 'update' && $user->rights->loan->write)
{
if (!$cancel)
{
} elseif ($action == 'update' && $user->rights->loan->write) {
// Update record
if (!$cancel) {
$result = $object->fetch($id);
$datestart = dol_mktime(12, 0, 0, GETPOST('startmonth', 'int'), GETPOST('startday', 'int'), GETPOST('startyear', 'int'));
$dateend = dol_mktime(12, 0, 0, GETPOST('endmonth', 'int'), GETPOST('endday', 'int'), GETPOST('endyear', 'int'));
$capital = price2num(GETPOST('capital'));
if (!$capital)
{
if (!$capital) {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("LoanCapital")), null, 'errors');
$action = 'edit';
} else {
@ -185,15 +187,26 @@ if (empty($reshook))
$accountancy_account_insurance = GETPOST('accountancy_account_insurance');
$accountancy_account_interest = GETPOST('accountancy_account_interest');
if ($accountancy_account_capital <= 0) { $object->account_capital = ''; } else { $object->account_capital = $accountancy_account_capital; }
if ($accountancy_account_insurance <= 0) { $object->account_insurance = ''; } else { $object->account_insurance = $accountancy_account_insurance; }
if ($accountancy_account_interest <= 0) { $object->account_interest = ''; } else { $object->account_interest = $accountancy_account_interest; }
if ($accountancy_account_capital <= 0) {
$object->account_capital = '';
} else {
$object->account_capital = $accountancy_account_capital;
}
if ($accountancy_account_insurance <= 0) {
$object->account_insurance = '';
} else {
$object->account_insurance = $accountancy_account_insurance;
}
if ($accountancy_account_interest <= 0) {
$object->account_interest = '';
} else {
$object->account_interest = $accountancy_account_interest;
}
}
$result = $object->update($user);
if ($result > 0)
{
if ($result > 0) {
header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
exit;
} else {
@ -207,20 +220,20 @@ if (empty($reshook))
}
// Link to a project
if ($action == 'classin' && $user->rights->loan->write)
{
if ($action == 'classin' && $user->rights->loan->write) {
$object->fetch($id);
$result = $object->setProject($projectid);
if ($result < 0)
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
}
}
if ($action == 'setlabel' && $user->rights->loan->write)
{
if ($action == 'setlabel' && $user->rights->loan->write) {
$object->fetch($id);
$result = $object->setValueFrom('label', GETPOST('label'), '', '', 'text', '', $user, 'LOAN_MODIFY');
if ($result < 0)
setEventMessages($object->error, $object->errors, 'errors');
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
}
}
}
@ -231,7 +244,9 @@ if (empty($reshook))
$form = new Form($db);
$formproject = new FormProjets($db);
if (!empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db);
if (!empty($conf->accounting->enabled)) {
$formaccounting = new FormAccounting($db);
}
$title = $langs->trans("Loan").' - '.$langs->trans("Card");
$help_url = 'EN:Module_Loan|FR:Module_Emprunt';
@ -239,8 +254,7 @@ llxHeader("", $title, $help_url);
// Create mode
if ($action == 'create')
{
if ($action == 'create') {
//WYSIWYG Editor
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
@ -260,8 +274,7 @@ if ($action == 'create')
print '<tr><td class="fieldrequired titlefieldcreate">'.$langs->trans("Label").'</td><td><input name="label" class="minwidth300" maxlength="255" value="'.dol_escape_htmltag(GETPOST('label')).'" autofocus="autofocus"></td></tr>';
// Bank account
if (!empty($conf->banque->enabled))
{
if (!empty($conf->banque->enabled)) {
print '<tr><td class="fieldrequired">'.$langs->trans("Account").'</td><td>';
$form->select_comptes(GETPOST("accountid"), "accountid", 0, "courant=1", 1); // Show list of bank account with courant
print '</td></tr>';
@ -296,8 +309,7 @@ if ($action == 'create')
print '<tr><td>'.$langs->trans("Insurance").'</td><td><input name="insurance_amount" size="10" value="'.dol_escape_htmltag(GETPOST("insurance_amount")).'" placeholder="'.$langs->trans('Amount').'"></td></tr>';
// Project
if (!empty($conf->projet->enabled))
{
if (!empty($conf->projet->enabled)) {
$formproject = new FormProjets($db);
// Projet associe
@ -329,8 +341,7 @@ if ($action == 'create')
print '</td></tr>';
// Accountancy
if (!empty($conf->accounting->enabled))
{
if (!empty($conf->accounting->enabled)) {
// Accountancy_account_capital
print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("LoanAccountancyCapitalCode").'</td>';
print '<td>';
@ -379,32 +390,27 @@ if ($action == 'create')
}
// View
if ($id > 0)
{
if ($id > 0) {
$object = new Loan($db);
$result = $object->fetch($id);
if ($result > 0)
{
if ($result > 0) {
$head = loan_prepare_head($object);
$totalpaid = $object->getSumPayment();
// Confirm for loan
if ($action == 'paid')
{
if ($action == 'paid') {
$text = $langs->trans('ConfirmPayLoan');
print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans('PayLoan'), $text, "confirm_paid", '', '', 2);
}
if ($action == 'delete')
{
if ($action == 'delete') {
$text = $langs->trans('ConfirmDeleteLoan');
print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans('DeleteLoan'), $text, 'confirm_delete', '', '', 2);
}
if ($action == 'edit')
{
if ($action == 'edit') {
print '<form name="update" action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n";
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="update">';
@ -422,14 +428,13 @@ if ($id > 0)
$morehtmlref .= $form->editfieldkey("Label", 'label', $object->label, $object, $user->rights->loan->write, 'string', '', 0, 1);
$morehtmlref .= $form->editfieldval("Label", 'label', $object->label, $object, $user->rights->loan->write, 'string', '', null, null, '', 1);
// Project
if (!empty($conf->projet->enabled))
{
if (!empty($conf->projet->enabled)) {
$langs->loadLangs(array("projects"));
$morehtmlref .= '<br>'.$langs->trans('Project').' ';
if ($user->rights->loan->write)
{
if ($action != 'classify')
if ($user->rights->loan->write) {
if ($action != 'classify') {
$morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : ';
}
if ($action == 'classify') {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
@ -466,8 +471,7 @@ if ($id > 0)
print '<table class="border centpercent tableforfield">';
// Capital
if ($action == 'edit')
{
if ($action == 'edit') {
print '<tr><td class="fieldrequired titlefield">'.$langs->trans("LoanCapital").'</td><td>';
print '<input name="capital" size="10" value="'.$object->capital.'"></td></tr>';
print '</td></tr>';
@ -476,8 +480,7 @@ if ($id > 0)
}
// Insurance
if ($action == 'edit')
{
if ($action == 'edit') {
print '<tr><td class="titlefield">'.$langs->trans("Insurance").'</td><td>';
print '<input name="insurance_amount" size="10" value="'.$object->insurance_amount.'"></td></tr>';
print '</td></tr>';
@ -488,8 +491,7 @@ if ($id > 0)
// Date start
print '<tr><td>'.$langs->trans("DateStart")."</td>";
print "<td>";
if ($action == 'edit')
{
if ($action == 'edit') {
print $form->selectDate($object->datestart, 'start', 0, 0, 0, 'update', 1, 0);
} else {
print dol_print_date($object->datestart, "day");
@ -499,8 +501,7 @@ if ($id > 0)
// Date end
print '<tr><td>'.$langs->trans("DateEnd")."</td>";
print "<td>";
if ($action == 'edit')
{
if ($action == 'edit') {
print $form->selectDate($object->dateend, 'end', 0, 0, 0, 'update', 1, 0);
} else {
print dol_print_date($object->dateend, "day");
@ -510,8 +511,7 @@ if ($id > 0)
// Nbterms
print '<tr><td>'.$langs->trans("Nbterms").'</td>';
print '<td>';
if ($action == 'edit')
{
if ($action == 'edit') {
print '<input name="nbterm" size="4" value="'.$object->nbterm.'">';
} else {
print $object->nbterm;
@ -521,8 +521,7 @@ if ($id > 0)
// Rate
print '<tr><td>'.$langs->trans("Rate").'</td>';
print '<td>';
if ($action == 'edit')
{
if ($action == 'edit') {
print '<input name="rate" size="4" value="'.$object->rate.'">%';
} else {
print price($object->rate).'%';
@ -531,14 +530,12 @@ if ($id > 0)
// Accountancy account capital
print '<tr>';
if ($action == 'edit')
{
if ($action == 'edit') {
print '<td class="nowrap fieldrequired">';
print $langs->trans("LoanAccountancyCapitalCode");
print '</td><td>';
if (!empty($conf->accounting->enabled))
{
if (!empty($conf->accounting->enabled)) {
print $formaccounting->select_account($object->account_capital, 'accountancy_account_capital', 1, '', 1, 1);
} else {
print '<input name="accountancy_account_capital" size="16" value="'.$object->account_capital.'">';
@ -549,8 +546,7 @@ if ($id > 0)
print $langs->trans("LoanAccountancyCapitalCode");
print '</td><td>';
if (!empty($conf->accounting->enabled))
{
if (!empty($conf->accounting->enabled)) {
$accountingaccount = new AccountingAccount($db);
$accountingaccount->fetch('', $object->account_capital, 1);
@ -565,14 +561,12 @@ if ($id > 0)
// Accountancy account insurance
print '<tr>';
if ($action == 'edit')
{
if ($action == 'edit') {
print '<td class="nowrap fieldrequired">';
print $langs->trans("LoanAccountancyInsuranceCode");
print '</td><td>';
if (!empty($conf->accounting->enabled))
{
if (!empty($conf->accounting->enabled)) {
print $formaccounting->select_account($object->account_insurance, 'accountancy_account_insurance', 1, '', 1, 1);
} else {
print '<input name="accountancy_account_insurance" size="16" value="'.$object->account_insurance.'">';
@ -583,8 +577,7 @@ if ($id > 0)
print $langs->trans("LoanAccountancyInsuranceCode");
print '</td><td>';
if (!empty($conf->accounting->enabled))
{
if (!empty($conf->accounting->enabled)) {
$accountingaccount = new AccountingAccount($db);
$accountingaccount->fetch('', $object->account_insurance, 1);
@ -599,14 +592,12 @@ if ($id > 0)
// Accountancy account interest
print '<tr>';
if ($action == 'edit')
{
if ($action == 'edit') {
print '<td class="nowrap fieldrequired">';
print $langs->trans("LoanAccountancyInterestCode");
print '</td><td>';
if (!empty($conf->accounting->enabled))
{
if (!empty($conf->accounting->enabled)) {
print $formaccounting->select_account($object->account_interest, 'accountancy_account_interest', 1, '', 1, 1);
} else {
print '<input name="accountancy_account_interest" size="16" value="'.$object->account_interest.'">';
@ -617,8 +608,7 @@ if ($id > 0)
print $langs->trans("LoanAccountancyInterestCode");
print '</td><td>';
if (!empty($conf->accounting->enabled))
{
if (!empty($conf->accounting->enabled)) {
$accountingaccount = new AccountingAccount($db);
$accountingaccount->fetch('', $object->account_interest, 1);
@ -653,8 +643,7 @@ if ($id > 0)
//print $sql;
$resql = $db->query($sql);
if ($resql)
{
if ($resql) {
$num = $db->num_rows($resql);
$i = 0;
$total_insurance = 0;
@ -672,8 +661,7 @@ if ($id > 0)
print '<td class="right">'.$langs->trans("LoanCapital").'</td>';
print '</tr>';
while ($i < $num)
{
while ($i < $num) {
$objp = $db->fetch_object($resql);
print '<tr class="oddeven">';
@ -690,8 +678,7 @@ if ($id > 0)
$totalpaid = $total_capital;
if ($object->paid == 0 || $object->paid == 2)
{
if ($object->paid == 0 || $object->paid == 2) {
print '<tr><td colspan="5" class="right">'.$langs->trans("AlreadyPaid").' :</td><td class="nowrap right">'.price($totalpaid, 0, $langs, 0, -1, -1, $conf->currency).'</td></tr>';
print '<tr><td colspan="5" class="right">'.$langs->trans("AmountExpected").' :</td><td class="nowrap right">'.price($object->capital, 0, $outputlangs, 1, -1, -1, $conf->currency).'</td></tr>';
@ -718,8 +705,7 @@ if ($id > 0)
print dol_get_fiche_end();
if ($action == 'edit')
{
if ($action == 'edit') {
print '<div class="center">';
print '<input type="submit" class="button button-save" name="save" value="'.$langs->trans("Save").'">';
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
@ -732,34 +718,28 @@ if ($id > 0)
/*
* Buttons actions
*/
if ($action != 'edit')
{
if ($action != 'edit') {
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
if (empty($reshook))
{
if (empty($reshook)) {
print '<div class="tabsAction">';
// Edit
if (($object->paid == 0 || $object->paid == 2) && $user->rights->loan->write)
{
if (($object->paid == 0 || $object->paid == 2) && $user->rights->loan->write) {
print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/loan/card.php?id='.$object->id.'&amp;action=edit">'.$langs->trans("Modify").'</a></div>';
}
// Emit payment
if (($object->paid == 0 || $object->paid == 2) && ((price2num($object->capital) > 0 && round($staytopay) < 0) || (price2num($object->capital) > 0 && round($staytopay) > 0)) && $user->rights->loan->write)
{
if (($object->paid == 0 || $object->paid == 2) && ((price2num($object->capital) > 0 && round($staytopay) < 0) || (price2num($object->capital) > 0 && round($staytopay) > 0)) && $user->rights->loan->write) {
print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/loan/payment/payment.php?id='.$object->id.'&amp;action=create">'.$langs->trans("DoPayment").'</a></div>';
}
// Classify 'paid'
if (($object->paid == 0 || $object->paid == 2) && round($staytopay) <= 0 && $user->rights->loan->write)
{
if (($object->paid == 0 || $object->paid == 2) && round($staytopay) <= 0 && $user->rights->loan->write) {
print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/loan/card.php?id='.$object->id.'&amp;action=paid&amp;token='.newToken().'">'.$langs->trans("ClassifyPaid").'</a></div>';
}
// Delete
if (($object->paid == 0 || $object->paid == 2) && $user->rights->loan->delete)
{
if (($object->paid == 0 || $object->paid == 2) && $user->rights->loan->delete) {
print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.DOL_URL_ROOT.'/loan/card.php?id='.$object->id.'&amp;action=delete&amp;token='.newToken().'">'.$langs->trans("Delete").'</a></div>';
}

View File

@ -135,10 +135,8 @@ class Loan extends CommonObject
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
if ($this->db->num_rows($resql))
{
if ($resql) {
if ($this->db->num_rows($resql)) {
$obj = $this->db->fetch_object($resql);
$this->id = $obj->rowid;
@ -188,36 +186,52 @@ class Loan extends CommonObject
// clean parameters
$newcapital = price2num($this->capital, 'MT');
if (empty($this->insurance_amount)) $this->insurance_amount = 0;
if (empty($this->insurance_amount)) {
$this->insurance_amount = 0;
}
$newinsuranceamount = price2num($this->insurance_amount, 'MT');
if (isset($this->note_private)) $this->note_private = trim($this->note_private);
if (isset($this->note_public)) $this->note_public = trim($this->note_public);
if (isset($this->account_capital)) $this->account_capital = trim($this->account_capital);
if (isset($this->account_insurance)) $this->account_insurance = trim($this->account_insurance);
if (isset($this->account_interest)) $this->account_interest = trim($this->account_interest);
if (isset($this->fk_bank)) $this->fk_bank = (int) $this->fk_bank;
if (isset($this->fk_user_creat)) $this->fk_user_creat = (int) $this->fk_user_creat;
if (isset($this->fk_user_modif)) $this->fk_user_modif = (int) $this->fk_user_modif;
if (isset($this->fk_project)) $this->fk_project = (int) $this->fk_project;
if (isset($this->note_private)) {
$this->note_private = trim($this->note_private);
}
if (isset($this->note_public)) {
$this->note_public = trim($this->note_public);
}
if (isset($this->account_capital)) {
$this->account_capital = trim($this->account_capital);
}
if (isset($this->account_insurance)) {
$this->account_insurance = trim($this->account_insurance);
}
if (isset($this->account_interest)) {
$this->account_interest = trim($this->account_interest);
}
if (isset($this->fk_bank)) {
$this->fk_bank = (int) $this->fk_bank;
}
if (isset($this->fk_user_creat)) {
$this->fk_user_creat = (int) $this->fk_user_creat;
}
if (isset($this->fk_user_modif)) {
$this->fk_user_modif = (int) $this->fk_user_modif;
}
if (isset($this->fk_project)) {
$this->fk_project = (int) $this->fk_project;
}
// Check parameters
if (!$newcapital > 0 || empty($this->datestart) || empty($this->dateend))
{
if (!$newcapital > 0 || empty($this->datestart) || empty($this->dateend)) {
$this->error = "ErrorBadParameter";
return -2;
}
if (($conf->accounting->enabled) && empty($this->account_capital))
{
if (($conf->accounting->enabled) && empty($this->account_capital)) {
$this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("LoanAccountancyCapitalCode"));
return -2;
}
if (($conf->accounting->enabled) && empty($this->account_insurance))
{
if (($conf->accounting->enabled) && empty($this->account_insurance)) {
$this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("LoanAccountancyInsuranceCode"));
return -2;
}
if (($conf->accounting->enabled) && empty($this->account_interest))
{
if (($conf->accounting->enabled) && empty($this->account_interest)) {
$this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("LoanAccountancyInterestCode"));
return -2;
}
@ -248,8 +262,7 @@ class Loan extends CommonObject
dol_syslog(get_class($this)."::create", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
if ($resql) {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."loan");
//dol_syslog("Loans::create this->id=".$this->id);
@ -281,47 +294,39 @@ class Loan extends CommonObject
$lines_url = $account->get_url('', $this->id, 'loan');
// Delete bank urls
foreach ($lines_url as $line_url)
{
if (!$error)
{
foreach ($lines_url as $line_url) {
if (!$error) {
$accountline = new AccountLine($this->db);
$accountline->fetch($line_url['fk_bank']);
$result = $accountline->delete_urls($user);
if ($result < 0)
{
if ($result < 0) {
$error++;
}
}
}
// Delete payments
if (!$error)
{
if (!$error) {
$sql = "DELETE FROM ".MAIN_DB_PREFIX."payment_loan where fk_loan=".$this->id;
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql)
{
if (!$resql) {
$error++;
$this->error = $this->db->lasterror();
}
}
if (!$error)
{
if (!$error) {
$sql = "DELETE FROM ".MAIN_DB_PREFIX."loan where rowid=".$this->id;
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql)
{
if (!$resql) {
$error++;
$this->error = $this->db->lasterror();
}
}
if (!$error)
{
if (!$error) {
$this->db->commit();
return 1;
} else {
@ -341,8 +346,7 @@ class Loan extends CommonObject
{
$this->db->begin();
if (!is_numeric($this->nbterm))
{
if (!is_numeric($this->nbterm)) {
$this->error = 'BadValueForParameterForNbTerm';
return -1;
}
@ -364,8 +368,7 @@ class Loan extends CommonObject
dol_syslog(get_class($this)."::update", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
if ($resql) {
$this->db->commit();
return 1;
} else {
@ -512,22 +515,29 @@ class Loan extends CommonObject
$langs->loadLangs(array("customers", "bills"));
unset($this->labelStatus); // Force to reset the array of status label, because label can change depending on parameters
if (empty($this->labelStatus) || empty($this->labelStatusShort))
{
if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
global $langs;
$this->labelStatus[self::STATUS_UNPAID] = $langs->trans('Unpaid');
$this->labelStatus[self::STATUS_PAID] = $langs->trans('Paid');
$this->labelStatus[self::STATUS_STARTED] = $langs->trans("BillStatusStarted");
if ($status == 0 && $alreadypaid > 0) $this->labelStatus[self::STATUS_UNPAID] = $langs->trans("BillStatusStarted");
if ($status == 0 && $alreadypaid > 0) {
$this->labelStatus[self::STATUS_UNPAID] = $langs->trans("BillStatusStarted");
}
$this->labelStatusShort[self::STATUS_UNPAID] = $langs->trans('Unpaid');
$this->labelStatusShort[self::STATUS_PAID] = $langs->trans('Enabled');
$this->labelStatusShort[self::STATUS_STARTED] = $langs->trans("BillStatusStarted");
if ($status == 0 && $alreadypaid > 0) $this->labelStatusShort[self::STATUS_UNPAID] = $langs->trans("BillStatusStarted");
if ($status == 0 && $alreadypaid > 0) {
$this->labelStatusShort[self::STATUS_UNPAID] = $langs->trans("BillStatusStarted");
}
}
$statusType = 'status1';
if (($status == 0 && $alreadypaid > 0) || $status == self::STATUS_STARTED) $statusType = 'status3';
if ($status == 1) $statusType = 'status6';
if (($status == 0 && $alreadypaid > 0) || $status == self::STATUS_STARTED) {
$statusType = 'status3';
}
if ($status == 1) {
$statusType = 'status6';
}
return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
}
@ -560,33 +570,40 @@ class Loan extends CommonObject
$url = DOL_URL_ROOT.'/loan/card.php?id='.$this->id;
if ($option != 'nolink')
{
if ($option != 'nolink') {
// Add param to save lastsearch_values or not
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1;
if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1';
if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
$add_save_lastsearch_values = 1;
}
if ($add_save_lastsearch_values) {
$url .= '&save_lastsearch_values=1';
}
}
$linkclose = '';
if (empty($notooltip))
{
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
{
if (empty($notooltip)) {
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
$label = $langs->trans("ShowMyObject");
$linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
}
$linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
$linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
} else $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
} else {
$linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
}
$linkstart = '<a href="'.$url.'"';
$linkstart .= $linkclose.'>';
$linkend = '</a>';
$result .= $linkstart;
if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
if ($withpicto != 2) $result .= ($maxlen ?dol_trunc($this->ref, $maxlen) : $this->ref);
if ($withpicto) {
$result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
}
if ($withpicto != 2) {
$result .= ($maxlen ?dol_trunc($this->ref, $maxlen) : $this->ref);
}
$result .= $linkend;
return $result;
@ -638,12 +655,13 @@ class Loan extends CommonObject
dol_syslog(get_class($this)."::getSumPayment", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
if ($resql) {
$amount = 0;
$obj = $this->db->fetch_object($resql);
if ($obj) $amount = $obj->amount ? $obj->amount : 0;
if ($obj) {
$amount = $obj->amount ? $obj->amount : 0;
}
$this->db->free($resql);
return $amount;
@ -668,26 +686,24 @@ class Loan extends CommonObject
dol_syslog(get_class($this).'::info', LOG_DEBUG);
$result = $this->db->query($sql);
if ($result)
{
if ($this->db->num_rows($result))
{
if ($result) {
if ($this->db->num_rows($result)) {
$obj = $this->db->fetch_object($result);
$this->id = $obj->rowid;
if ($obj->fk_user_author)
{
if ($obj->fk_user_author) {
$cuser = new User($this->db);
$cuser->fetch($obj->fk_user_author);
$this->user_creation = $cuser;
}
if ($obj->fk_user_modif)
{
if ($obj->fk_user_modif) {
$muser = new User($this->db);
$muser->fetch($obj->fk_user_modif);
$this->user_modification = $muser;
}
$this->date_creation = $this->db->jdate($obj->datec);
if (empty($obj->fk_user_modif)) $obj->tms = "";
if (empty($obj->fk_user_modif)) {
$obj->tms = "";
}
$this->date_modification = $this->db->jdate($obj->tms);
$this->db->free($result);

View File

@ -129,21 +129,36 @@ class LoanSchedule extends CommonObject
$now = dol_now();
// Validate parameters
if (!$this->datep)
{
if (!$this->datep) {
$this->error = 'ErrorBadValueForParameter';
return -1;
}
// Clean parameters
if (isset($this->fk_loan)) $this->fk_loan = (int) $this->fk_loan;
if (isset($this->amount_capital)) $this->amount_capital = trim($this->amount_capital ? $this->amount_capital : 0);
if (isset($this->amount_insurance)) $this->amount_insurance = trim($this->amount_insurance ? $this->amount_insurance : 0);
if (isset($this->amount_interest)) $this->amount_interest = trim($this->amount_interest ? $this->amount_interest : 0);
if (isset($this->fk_typepayment)) $this->fk_typepayment = (int) $this->fk_typepayment;
if (isset($this->fk_bank)) $this->fk_bank = (int) $this->fk_bank;
if (isset($this->fk_user_creat)) $this->fk_user_creat = (int) $this->fk_user_creat;
if (isset($this->fk_user_modif)) $this->fk_user_modif = (int) $this->fk_user_modif;
if (isset($this->fk_loan)) {
$this->fk_loan = (int) $this->fk_loan;
}
if (isset($this->amount_capital)) {
$this->amount_capital = trim($this->amount_capital ? $this->amount_capital : 0);
}
if (isset($this->amount_insurance)) {
$this->amount_insurance = trim($this->amount_insurance ? $this->amount_insurance : 0);
}
if (isset($this->amount_interest)) {
$this->amount_interest = trim($this->amount_interest ? $this->amount_interest : 0);
}
if (isset($this->fk_typepayment)) {
$this->fk_typepayment = (int) $this->fk_typepayment;
}
if (isset($this->fk_bank)) {
$this->fk_bank = (int) $this->fk_bank;
}
if (isset($this->fk_user_creat)) {
$this->fk_user_creat = (int) $this->fk_user_creat;
}
if (isset($this->fk_user_modif)) {
$this->fk_user_modif = (int) $this->fk_user_modif;
}
$totalamount = $this->amount_capital + $this->amount_insurance + $this->amount_interest;
$totalamount = price2num($totalamount);
@ -157,8 +172,7 @@ class LoanSchedule extends CommonObject
$this->db->begin();
if ($totalamount != 0)
{
if ($totalamount != 0) {
$sql = "INSERT INTO ".MAIN_DB_PREFIX.$this->table_element." (fk_loan, datec, datep, amount_capital, amount_insurance, amount_interest,";
$sql .= " fk_typepayment, fk_user_creat, fk_bank)";
$sql .= " VALUES (".$this->fk_loan.", '".$this->db->idate($now)."',";
@ -172,8 +186,7 @@ class LoanSchedule extends CommonObject
dol_syslog(get_class($this)."::create", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
if ($resql) {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."payment_loan");
} else {
$this->error = $this->db->lasterror();
@ -181,8 +194,7 @@ class LoanSchedule extends CommonObject
}
}
if ($totalamount != 0 && !$error)
{
if ($totalamount != 0 && !$error) {
$this->amount_capital = $totalamount;
$this->db->commit();
return $this->id;
@ -280,14 +292,30 @@ class LoanSchedule extends CommonObject
$error = 0;
// Clean parameters
if (isset($this->amount_capital)) $this->amount_capital = trim($this->amount_capital);
if (isset($this->amount_insurance)) $this->amount_insurance = trim($this->amount_insurance);
if (isset($this->amount_interest)) $this->amount_interest = trim($this->amount_interest);
if (isset($this->num_payment)) $this->num_payment = trim($this->num_payment);
if (isset($this->note_private)) $this->note_private = trim($this->note_private);
if (isset($this->note_public)) $this->note_public = trim($this->note_public);
if (isset($this->fk_bank)) $this->fk_bank = trim($this->fk_bank);
if (isset($this->fk_payment_loan)) $this->fk_payment_loan = (int) $this->fk_payment_loan;
if (isset($this->amount_capital)) {
$this->amount_capital = trim($this->amount_capital);
}
if (isset($this->amount_insurance)) {
$this->amount_insurance = trim($this->amount_insurance);
}
if (isset($this->amount_interest)) {
$this->amount_interest = trim($this->amount_interest);
}
if (isset($this->num_payment)) {
$this->num_payment = trim($this->num_payment);
}
if (isset($this->note_private)) {
$this->note_private = trim($this->note_private);
}
if (isset($this->note_public)) {
$this->note_public = trim($this->note_public);
}
if (isset($this->fk_bank)) {
$this->fk_bank = trim($this->fk_bank);
}
if (isset($this->fk_payment_loan)) {
$this->fk_payment_loan = (int) $this->fk_payment_loan;
}
// Check parameters
// Put here code to add control on parameters values
@ -317,11 +345,12 @@ class LoanSchedule extends CommonObject
dol_syslog(get_class($this)."::update", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
if (!$resql) {
$error++; $this->errors[] = "Error ".$this->db->lasterror();
}
// Commit or rollback
if ($error)
{
if ($error) {
$this->db->rollback();
return -1 * $error;
} else {
@ -351,14 +380,14 @@ class LoanSchedule extends CommonObject
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
if (!$resql) {
$error++; $this->errors[] = "Error ".$this->db->lasterror();
}
}
// Commit or rollback
if ($error)
{
foreach ($this->errors as $errmsg)
{
if ($error) {
foreach ($this->errors as $errmsg) {
dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
}
@ -423,10 +452,8 @@ class LoanSchedule extends CommonObject
dol_syslog(get_class($this)."::fetchAll", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
while ($obj = $this->db->fetch_object($resql))
{
if ($resql) {
while ($obj = $this->db->fetch_object($resql)) {
$line = new LoanSchedule($this->db);
$line->id = $obj->rowid;
$line->ref = $obj->rowid;
@ -537,14 +564,15 @@ class LoanSchedule extends CommonObject
$sql = "SELECT p.rowid";
$sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as p ";
$sql .= " WHERE p.fk_loan = ".$loanid;
if (!empty($datemax)) { $sql .= " AND p.datep > '".$this->db->idate($datemax)."'"; }
if (!empty($datemax)) {
$sql .= " AND p.datep > '".$this->db->idate($datemax)."'";
}
$sql .= " AND p.datep <= '".$this->db->idate(dol_now())."'";
$resql = $this->db->query($sql);
if ($resql) {
while ($obj = $this->db->fetch_object($resql))
{
while ($obj = $this->db->fetch_object($resql)) {
$result[] = $obj->rowid;
}
}

View File

@ -126,36 +126,58 @@ class PaymentLoan extends CommonObject
$now = dol_now();
// Validate parameters
if (!$this->datep)
{
if (!$this->datep) {
$this->error = 'ErrorBadValueForParameter';
return -1;
}
// Clean parameters
if (isset($this->fk_loan)) $this->fk_loan = (int) $this->fk_loan;
if (isset($this->amount_capital)) $this->amount_capital = price2num($this->amount_capital ? $this->amount_capital : 0);
if (isset($this->amount_insurance)) $this->amount_insurance = price2num($this->amount_insurance ? $this->amount_insurance : 0);
if (isset($this->amount_interest)) $this->amount_interest = price2num($this->amount_interest ? $this->amount_interest : 0);
if (isset($this->fk_typepayment)) $this->fk_typepayment = (int) $this->fk_typepayment;
if (isset($this->num_payment)) $this->num_payment = (int) $this->num_payment;
if (isset($this->note_private)) $this->note_private = trim($this->note_private);
if (isset($this->note_public)) $this->note_public = trim($this->note_public);
if (isset($this->fk_bank)) $this->fk_bank = (int) $this->fk_bank;
if (isset($this->fk_user_creat)) $this->fk_user_creat = (int) $this->fk_user_creat;
if (isset($this->fk_user_modif)) $this->fk_user_modif = (int) $this->fk_user_modif;
if (isset($this->fk_loan)) {
$this->fk_loan = (int) $this->fk_loan;
}
if (isset($this->amount_capital)) {
$this->amount_capital = price2num($this->amount_capital ? $this->amount_capital : 0);
}
if (isset($this->amount_insurance)) {
$this->amount_insurance = price2num($this->amount_insurance ? $this->amount_insurance : 0);
}
if (isset($this->amount_interest)) {
$this->amount_interest = price2num($this->amount_interest ? $this->amount_interest : 0);
}
if (isset($this->fk_typepayment)) {
$this->fk_typepayment = (int) $this->fk_typepayment;
}
if (isset($this->num_payment)) {
$this->num_payment = (int) $this->num_payment;
}
if (isset($this->note_private)) {
$this->note_private = trim($this->note_private);
}
if (isset($this->note_public)) {
$this->note_public = trim($this->note_public);
}
if (isset($this->fk_bank)) {
$this->fk_bank = (int) $this->fk_bank;
}
if (isset($this->fk_user_creat)) {
$this->fk_user_creat = (int) $this->fk_user_creat;
}
if (isset($this->fk_user_modif)) {
$this->fk_user_modif = (int) $this->fk_user_modif;
}
$totalamount = $this->amount_capital + $this->amount_insurance + $this->amount_interest;
$totalamount = price2num($totalamount);
// Check parameters
if ($totalamount == 0) return -1; // Negative amounts are accepted for reject prelevement but not null
if ($totalamount == 0) {
return -1; // Negative amounts are accepted for reject prelevement but not null
}
$this->db->begin();
if ($totalamount != 0)
{
if ($totalamount != 0) {
$sql = "INSERT INTO ".MAIN_DB_PREFIX."payment_loan (fk_loan, datec, datep, amount_capital, amount_insurance, amount_interest,";
$sql .= " fk_typepayment, num_payment, note_private, note_public, fk_user_creat, fk_bank)";
$sql .= " VALUES (".$this->chid.", '".$this->db->idate($now)."',";
@ -168,8 +190,7 @@ class PaymentLoan extends CommonObject
dol_syslog(get_class($this)."::create", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
if ($resql) {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."payment_loan");
} else {
$this->error = $this->db->lasterror();
@ -177,8 +198,7 @@ class PaymentLoan extends CommonObject
}
}
if ($totalamount != 0 && !$error)
{
if ($totalamount != 0 && !$error) {
$this->amount_capital = $totalamount;
$this->db->commit();
return $this->id;
@ -223,10 +243,8 @@ class PaymentLoan extends CommonObject
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
if ($this->db->num_rows($resql))
{
if ($resql) {
if ($this->db->num_rows($resql)) {
$obj = $this->db->fetch_object($resql);
$this->id = $obj->rowid;
@ -276,17 +294,39 @@ class PaymentLoan extends CommonObject
$error = 0;
// Clean parameters
if (isset($this->fk_loan)) $this->fk_loan = (int) $this->fk_loan;
if (isset($this->amount_capital)) $this->amount_capital = trim($this->amount_capital);
if (isset($this->amount_insurance)) $this->amount_insurance = trim($this->amount_insurance);
if (isset($this->amount_interest)) $this->amount_interest = trim($this->amount_interest);
if (isset($this->fk_typepayment)) $this->fk_typepayment = (int) $this->fk_typepayment;
if (isset($this->num_payment)) $this->num_payment = (int) $this->num_payment;
if (isset($this->note_private)) $this->note = trim($this->note_private);
if (isset($this->note_public)) $this->note = trim($this->note_public);
if (isset($this->fk_bank)) $this->fk_bank = (int) $this->fk_bank;
if (isset($this->fk_user_creat)) $this->fk_user_creat = (int) $this->fk_user_creat;
if (isset($this->fk_user_modif)) $this->fk_user_modif = (int) $this->fk_user_modif;
if (isset($this->fk_loan)) {
$this->fk_loan = (int) $this->fk_loan;
}
if (isset($this->amount_capital)) {
$this->amount_capital = trim($this->amount_capital);
}
if (isset($this->amount_insurance)) {
$this->amount_insurance = trim($this->amount_insurance);
}
if (isset($this->amount_interest)) {
$this->amount_interest = trim($this->amount_interest);
}
if (isset($this->fk_typepayment)) {
$this->fk_typepayment = (int) $this->fk_typepayment;
}
if (isset($this->num_payment)) {
$this->num_payment = (int) $this->num_payment;
}
if (isset($this->note_private)) {
$this->note = trim($this->note_private);
}
if (isset($this->note_public)) {
$this->note = trim($this->note_public);
}
if (isset($this->fk_bank)) {
$this->fk_bank = (int) $this->fk_bank;
}
if (isset($this->fk_user_creat)) {
$this->fk_user_creat = (int) $this->fk_user_creat;
}
if (isset($this->fk_user_modif)) {
$this->fk_user_modif = (int) $this->fk_user_modif;
}
// Check parameters
@ -314,13 +354,13 @@ class PaymentLoan extends CommonObject
dol_syslog(get_class($this)."::update", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
if (!$resql) {
$error++; $this->errors[] = "Error ".$this->db->lasterror();
}
// Commit or rollback
if ($error)
{
foreach ($this->errors as $errmsg)
{
if ($error) {
foreach ($this->errors as $errmsg) {
dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
}
@ -347,35 +387,35 @@ class PaymentLoan extends CommonObject
$this->db->begin();
if (!$error)
{
if (!$error) {
$sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_url";
$sql .= " WHERE type='payment_loan' AND url_id=".$this->id;
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
if (!$resql) {
$error++; $this->errors[] = "Error ".$this->db->lasterror();
}
}
if (!$error)
{
if (!$error) {
$sql = "DELETE FROM ".MAIN_DB_PREFIX."payment_loan";
$sql .= " WHERE rowid=".$this->id;
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
if (!$resql) {
$error++; $this->errors[] = "Error ".$this->db->lasterror();
}
}
// Set loan unpaid if loan has no other payment
if (!$error)
{
if (!$error) {
require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php';
$loan = new Loan($this->db);
$loan->fetch($this->fk_loan);
$sum_payment = $loan->getSumPayment();
if ($sum_payment == 0)
{
if ($sum_payment == 0) {
dol_syslog(get_class($this)."::delete : set loan to unpaid", LOG_DEBUG);
if ($loan->setUnpaid($user) < 1) {
$error++;
@ -401,10 +441,8 @@ class PaymentLoan extends CommonObject
//}
// Commit or rollback
if ($error)
{
foreach ($this->errors as $errmsg)
{
if ($error) {
foreach ($this->errors as $errmsg) {
dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
}
@ -461,15 +499,16 @@ class PaymentLoan extends CommonObject
$error = 0;
$this->db->begin();
if (!empty($conf->banque->enabled))
{
if (!empty($conf->banque->enabled)) {
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
$acc = new Account($this->db);
$acc->fetch($accountid);
$total = $this->amount_capital;
if ($mode == 'payment_loan') $total = -$total;
if ($mode == 'payment_loan') {
$total = -$total;
}
// Insert payment into llx_bank
$bank_line_id = $acc->addline(
@ -486,23 +525,21 @@ class PaymentLoan extends CommonObject
// Update fk_bank into llx_paiement.
// We know the payment who generated the account write
if ($bank_line_id > 0)
{
if ($bank_line_id > 0) {
$result = $this->update_fk_bank($bank_line_id);
if ($result <= 0)
{
if ($result <= 0) {
$error++;
dol_print_error($this->db);
}
// Add link 'payment_loan' in bank_url between payment and bank transaction
$url = '';
if ($mode == 'payment_loan') $url = DOL_URL_ROOT.'/loan/payment/card.php?id=';
if ($url)
{
if ($mode == 'payment_loan') {
$url = DOL_URL_ROOT.'/loan/payment/card.php?id=';
}
if ($url) {
$result = $acc->add_url_line($bank_line_id, $this->id, $url, '(payment)', $mode);
if ($result <= 0)
{
if ($result <= 0) {
$error++;
dol_print_error($this->db);
}
@ -510,10 +547,11 @@ class PaymentLoan extends CommonObject
// Add link 'loan' in bank_url between invoice and bank transaction (for each invoice concerned by payment)
if ($mode == 'payment_loan')
{
if ($mode == 'payment_loan') {
$result = $acc->add_url_line($bank_line_id, $fk_loan, DOL_URL_ROOT.'/loan/card.php?id=', ($this->label ? $this->label : ''), 'loan');
if ($result <= 0) dol_print_error($this->db);
if ($result <= 0) {
dol_print_error($this->db);
}
}
} else {
$this->error = $acc->error;
@ -523,28 +561,23 @@ class PaymentLoan extends CommonObject
// Set loan payment started if no set
if (!$error)
{
if (!$error) {
require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php';
$loan = new Loan($this->db);
$loan->fetch($fk_loan);
if ($loan->paid == $loan::STATUS_UNPAID)
{
if ($loan->paid == $loan::STATUS_UNPAID) {
dol_syslog(get_class($this)."::addPaymentToBank : set loan payment to started", LOG_DEBUG);
if ($loan->setStarted($user) < 1)
{
if ($loan->setStarted($user) < 1) {
$error++;
dol_print_error($this->db);
}
}
}
if (!$error)
{
if (!$error) {
$this->db->commit();
return 1;
}
else {
} else {
$this->db->rollback();
return -1;
}
@ -565,8 +598,7 @@ class PaymentLoan extends CommonObject
dol_syslog(get_class($this)."::update_fk_bank", LOG_DEBUG);
$result = $this->db->query($sql);
if ($result)
{
if ($result) {
$this->fk_bank = $id_bank;
return 1;
} else {
@ -589,27 +621,39 @@ class PaymentLoan extends CommonObject
{
global $langs, $conf;
if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips
if (!empty($conf->dol_no_mouse_hover)) {
$notooltip = 1; // Force disable tooltips
}
$result = '';
$label = '<u>'.$langs->trans("Loan").'</u>';
if (!empty($this->id)) {
$label .= '<br><b>'.$langs->trans('Ref').':</b> '.$this->id;
}
if ($moretitle) $label .= ' - '.$moretitle;
if ($moretitle) {
$label .= ' - '.$moretitle;
}
$url = DOL_URL_ROOT.'/loan/payment/card.php?id='.$this->id;
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1;
if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1';
if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
$add_save_lastsearch_values = 1;
}
if ($add_save_lastsearch_values) {
$url .= '&save_lastsearch_values=1';
}
$linkstart = '<a href="'.$url.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
$linkend = '</a>';
$result .= $linkstart;
if ($withpicto) $result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
if ($withpicto != 2) $result .= $this->ref;
if ($withpicto) {
$result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
}
if ($withpicto != 2) {
$result .= $this->ref;
}
$result .= $linkend;
return $result;

View File

@ -40,7 +40,9 @@ $action = GETPOST('action', 'aZ09');
$confirm = GETPOST('confirm', 'alpha');
// Security check
if ($user->socid) $socid = $user->socid;
if ($user->socid) {
$socid = $user->socid;
}
$result = restrictedArea($user, 'loan', $id, '', '');
// Get parameters
@ -54,11 +56,17 @@ if (empty($page) || $page == -1) {
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (!$sortorder) $sortorder = "ASC";
if (!$sortfield) $sortfield = "name";
if (!$sortorder) {
$sortorder = "ASC";
}
if (!$sortfield) {
$sortfield = "name";
}
$object = new Loan($db);
if ($id > 0) $object->fetch($id);
if ($id > 0) {
$object->fetch($id);
}
$upload_dir = $conf->loan->dir_output.'/'.dol_sanitizeFileName($object->ref);
$modulepart = 'loan';
@ -81,8 +89,7 @@ $title = $langs->trans("Loan").' - '.$langs->trans("Documents");
$help_url = 'EN:Module_Loan|FR:Module_Emprunt';
llxHeader("", $title, $help_url);
if ($object->id)
{
if ($object->id) {
$totalpaid = $object->getSumPayment();
$head = loan_prepare_head($object);
@ -138,8 +145,7 @@ if ($object->id)
// Build file list
$filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1);
$totalsize = 0;
foreach ($filearray as $key => $file)
{
foreach ($filearray as $key => $file) {
$totalsize += $file['size'];
}

View File

@ -38,7 +38,9 @@ $action = GETPOST('action', 'aZ09');
// Security check
$socid = GETPOST('socid', 'int');
if ($user->socid) $socid = $user->socid;
if ($user->socid) {
$socid = $user->socid;
}
$result = restrictedArea($user, 'loan', $id, '', '');

View File

@ -32,14 +32,18 @@ $langs->loadLangs(array("loan", "compta", "banks", "bills"));
// Security check
$socid = GETPOST('socid', 'int');
if ($user->socid) $socid = $user->socid;
if ($user->socid) {
$socid = $user->socid;
}
$result = restrictedArea($user, 'loan', '', '', '');
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) {
$page = 0;
} // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
@ -48,8 +52,12 @@ $pagenext = $page + 1;
$loan_static = new Loan($db);
$extrafields = new ExtraFields($db);
if (!$sortfield) $sortfield = "l.rowid";
if (!$sortorder) $sortorder = "DESC";
if (!$sortfield) {
$sortfield = "l.rowid";
}
if (!$sortorder) {
$sortorder = "DESC";
}
$search_ref = GETPOST('search_ref', 'int');
$search_label = GETPOST('search_label', 'alpha');
@ -63,18 +71,22 @@ $optioncss = GETPOST('optioncss', 'alpha');
* Actions
*/
if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; }
if (GETPOST('cancel', 'alpha')) {
$action = 'list'; $massaction = '';
}
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
$massaction = '';
}
$parameters = array();
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if (empty($reshook))
{
if (empty($reshook)) {
// Purge search criteria
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers
{
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
$search_ref = "";
$search_label = "";
$search_amount = "";
@ -97,35 +109,39 @@ $sql .= " SUM(pl.amount_capital) as alreadypaid";
$sql .= " FROM ".MAIN_DB_PREFIX."loan as l LEFT JOIN ".MAIN_DB_PREFIX."payment_loan AS pl";
$sql .= " ON l.rowid = pl.fk_loan";
$sql .= " WHERE l.entity = ".$conf->entity;
if ($search_amount) $sql .= natural_search("l.capital", $search_amount, 1);
if ($search_ref) $sql .= " AND l.rowid = ".$db->escape($search_ref);
if ($search_label) $sql .= natural_search("l.label", $search_label);
if ($search_amount) {
$sql .= natural_search("l.capital", $search_amount, 1);
}
if ($search_ref) {
$sql .= " AND l.rowid = ".$db->escape($search_ref);
}
if ($search_label) {
$sql .= natural_search("l.label", $search_label);
}
$sql .= " GROUP BY l.rowid, l.label, l.capital, l.paid, l.datestart, l.dateend";
$sql .= $db->order($sortfield, $sortorder);
// Count total nb of records
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
$resql = $db->query($sql);
$nbtotalofrecords = $db->num_rows($resql);
if (($page * $limit) > $nbtotalofrecords) // if total of record found is smaller than page * limit, goto and load page 0
{
if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0
$page = 0;
$offset = 0;
}
}
// if total of record found is smaller than limit, no need to do paging and to restart another select with limits set.
if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit)))
{
if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) {
$num = $nbtotalofrecords;
} else {
if ($limit) $sql .= $db->plimit($limit + 1, $offset);
if ($limit) {
$sql .= $db->plimit($limit + 1, $offset);
}
$resql = $db->query($sql);
if (!$resql)
{
if (!$resql) {
dol_print_error($db);
exit;
}
@ -138,24 +154,39 @@ if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit
llxHeader('', $title, $help_url);
if ($resql)
{
if ($resql) {
$i = 0;
$param = '';
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
if ($search_ref) $param .= "&search_ref=".urlencode($search_ref);
if ($search_label) $param .= "&search_label=".urlencode($search_label);
if ($search_amount) $param .= "&search_amount=".urlencode($search_amount);
if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
$param .= '&contextpage='.urlencode($contextpage);
}
if ($limit > 0 && $limit != $conf->liste_limit) {
$param .= '&limit='.urlencode($limit);
}
if ($search_ref) {
$param .= "&search_ref=".urlencode($search_ref);
}
if ($search_label) {
$param .= "&search_label=".urlencode($search_label);
}
if ($search_amount) {
$param .= "&search_amount=".urlencode($search_amount);
}
if ($optioncss != '') {
$param .= '&optioncss='.urlencode($optioncss);
}
$url = DOL_URL_ROOT.'/loan/card.php?action=create';
if (!empty($socid)) $url .= '&socid='.$socid;
if (!empty($socid)) {
$url .= '&socid='.$socid;
}
$newcardbutton = dolGetButtonTitle($langs->trans('NewLoan'), '', 'fa fa-plus-circle', $url, '', $user->rights->loan->write);
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
if ($optioncss != '') {
print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
}
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="action" value="list">';
@ -201,10 +232,11 @@ if ($resql)
// --------------------------------------------------------------------
$i = 0;
$totalarray = array();
while ($i < ($limit ? min($num, $limit) : $num))
{
while ($i < ($limit ? min($num, $limit) : $num)) {
$obj = $db->fetch_object($resql);
if (empty($obj)) break; // Should not happen
if (empty($obj)) {
break; // Should not happen
}
$loan_static->id = $obj->rowid;
$loan_static->ref = $obj->rowid;
@ -240,8 +272,7 @@ if ($resql)
}
// If no record found
if ($num == 0)
{
if ($num == 0) {
$colspan = 7;
//foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; }
print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';

View File

@ -44,7 +44,9 @@ $id = GETPOST('id', 'int');
$result = restrictedArea($user, 'loan', $id, '&loan');
$object = new Loan($db);
if ($id > 0) $object->fetch($id);
if ($id > 0) {
$object->fetch($id);
}
$permissionnote = $user->rights->loan->write; // Used by the include of actions_setnotes.inc.php
@ -66,11 +68,10 @@ $title = $langs->trans("Loan").' - '.$langs->trans("Notes");
$help_url = 'EN:Module_Loan|FR:Module_Emprunt';
llxHeader("", $title, $help_url);
if ($id > 0)
{
if ($id > 0) {
/*
* Affichage onglets
*/
* Affichage onglets
*/
$totalpaid = $object->getSumPayment();
$head = loan_prepare_head($object);

View File

@ -24,7 +24,9 @@
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php';
require_once DOL_DOCUMENT_ROOT.'/loan/class/paymentloan.class.php';
if (!empty($conf->banque->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
if (!empty($conf->banque->enabled)) {
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
}
// Load translation files required by the page
$langs->loadLangs(array("bills", "banks", "companies", "loan"));
@ -33,15 +35,18 @@ $langs->loadLangs(array("bills", "banks", "companies", "loan"));
$id = GETPOST("id", 'int');
$action = GETPOST('action', 'aZ09');
$confirm = GETPOST('confirm');
if ($user->socid) $socid = $user->socid;
if ($user->socid) {
$socid = $user->socid;
}
// TODO ajouter regle pour restreindre acces paiement
//$result = restrictedArea($user, 'facture', $id,'');
$payment = new PaymentLoan($db);
if ($id > 0)
{
if ($id > 0) {
$result = $payment->fetch($id);
if (!$result) dol_print_error($db, 'Failed to get payment id '.$id);
if (!$result) {
dol_print_error($db, 'Failed to get payment id '.$id);
}
}
@ -50,8 +55,7 @@ if ($id > 0)
*/
// Delete payment
if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->loan->delete)
{
if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->loan->delete) {
$db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."loan_schedule SET fk_bank = 0 WHERE fk_bank = ".$payment->fk_bank;
@ -60,8 +64,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->loan->del
$fk_loan = $payment->fk_loan;
$result = $payment->delete($user);
if ($result > 0)
{
if ($result > 0) {
$db->commit();
header("Location: ".DOL_URL_ROOT."/loan/card.php?id=".$fk_loan);
exit;
@ -93,8 +96,7 @@ print dol_get_fiche_head($head, $hselected, $langs->trans("PaymentLoan"), -1, 'p
/*
* Confirm deletion of the payment
*/
if ($action == 'delete')
{
if ($action == 'delete') {
print $form->formconfirm('card.php?id='.$payment->id, $langs->trans("DeletePayment"), $langs->trans("ConfirmDeletePayment"), 'confirm_delete', '', 0, 2);
}
@ -127,10 +129,8 @@ print '<tr><td>'.$langs->trans('NotePrivate').'</td><td>'.nl2br($payment->note_p
print '<tr><td>'.$langs->trans('NotePublic').'</td><td>'.nl2br($payment->note_public).'</td></tr>';
// Bank account
if (!empty($conf->banque->enabled))
{
if ($payment->bank_account)
{
if (!empty($conf->banque->enabled)) {
if ($payment->bank_account) {
$bankline = new AccountLine($db);
$bankline->fetch($payment->bank_line);
@ -161,8 +161,7 @@ $sql .= ' AND pl.rowid = '.$payment->id;
dol_syslog("loan/payment/card.php", LOG_DEBUG);
$resql = $db->query($sql);
if ($resql)
{
if ($resql) {
$num = $db->num_rows($resql);
$i = 0;
@ -176,10 +175,8 @@ if ($resql)
print '<td class="right">'.$langs->trans('PayedByThisPayment').'</td>';
print "</tr>\n";
if ($num > 0)
{
while ($i < $num)
{
if ($num > 0) {
while ($i < $num) {
$objp = $db->fetch_object($resql);
print '<tr class="oddeven">';
@ -199,8 +196,7 @@ if ($resql)
print '<td class="right">'.price($amount_payed).'</td>';
print "</tr>\n";
if ($objp->paid == 1) // If at least one invoice is paid, disable delete
{
if ($objp->paid == 1) { // If at least one invoice is paid, disable delete
$disable_delete = 1;
}
$total = $total + $objp->amount_capital;
@ -224,10 +220,8 @@ print '</div>';
print '<div class="tabsAction">';
if (empty($action) && !empty($user->rights->loan->delete))
{
if (!$disable_delete)
{
if (empty($action) && !empty($user->rights->loan->delete)) {
if (!$disable_delete) {
print '<a class="butActionDelete" href="card.php?id='.$id.'&amp;action=delete&amp;token='.newToken().'">'.$langs->trans('Delete').'</a>';
} else {
print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("CantRemovePaymentWithOneInvoicePaid")).'">'.$langs->trans('Delete').'</a>';

View File

@ -39,10 +39,14 @@ $datepaid = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'in
// Security check
$socid = 0;
if ($user->socid > 0)
if ($user->socid > 0) {
$socid = $user->socid;
elseif (GETPOSTISSET('socid')) $socid = GETPOST('socid', 'int');
if (empty($user->rights->loan->write)) accessforbidden();
} elseif (GETPOSTISSET('socid')) {
$socid = GETPOST('socid', 'int');
}
if (empty($user->rights->loan->write)) {
accessforbidden();
}
$loan = new Loan($db);
$loan->fetch($chid);
@ -51,35 +55,31 @@ $echance = 0;
$ls = new LoanSchedule($db);
// grab all loanschedule
$res = $ls->fetchAll($chid);
if ($res > 0)
{
foreach ($ls->lines as $l)
{
if ($res > 0) {
foreach ($ls->lines as $l) {
$echance++; // Count term pos
// last unpaid term
if (empty($l->fk_bank))
{
if (empty($l->fk_bank)) {
$line_id = $l->id;
break;
}
// If line_id provided, only count temp pos
elseif ($line_id == $l->id)
{
} elseif ($line_id == $l->id) {
// If line_id provided, only count temp pos
break;
}
}
}
// Set current line with last unpaid line (only if shedule is used)
if (!empty($line_id))
{
if (!empty($line_id)) {
$line = new LoanSchedule($db);
$res = $line->fetch($line_id);
if ($res > 0) {
$amount_capital = price($line->amount_capital);
$amount_insurance = price($line->amount_insurance);
$amount_interest = price($line->amount_interest);
if (empty($datepaid)) $ts_temppaid = $line->datep;
if (empty($datepaid)) {
$ts_temppaid = $line->datep;
}
}
}
@ -88,66 +88,59 @@ if (!empty($line_id))
* Actions
*/
if ($action == 'add_payment')
{
if ($action == 'add_payment') {
$error = 0;
if ($cancel)
{
if ($cancel) {
$loc = DOL_URL_ROOT.'/loan/card.php?id='.$chid;
header("Location: ".$loc);
exit;
}
if (!GETPOST('paymenttype', 'int') > 0)
{
if (!GETPOST('paymenttype', 'int') > 0) {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode")), null, 'errors');
$error++;
}
if ($datepaid == '')
{
if ($datepaid == '') {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Date")), null, 'errors');
$error++;
}
if (!empty($conf->banque->enabled) && !GETPOST('accountid', 'int') > 0)
{
if (!empty($conf->banque->enabled) && !GETPOST('accountid', 'int') > 0) {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("AccountToCredit")), null, 'errors');
$error++;
}
if (!$error)
{
if (!$error) {
$paymentid = 0;
$pay_amount_capital = price2num(GETPOST('amount_capital'));
$pay_amount_insurance = price2num(GETPOST('amount_insurance'));
// User can't set interest him self if schedule is set (else value in schedule can be incoherent)
if (!empty($line)) $pay_amount_interest = $line->amount_interest;
else $pay_amount_interest = price2num(GETPOST('amount_interest'));
if (!empty($line)) {
$pay_amount_interest = $line->amount_interest;
} else {
$pay_amount_interest = price2num(GETPOST('amount_interest'));
}
$remaindertopay = price2num(GETPOST('remaindertopay'));
$amount = $pay_amount_capital + $pay_amount_insurance + $pay_amount_interest;
// This term is allready paid
if (!empty($line) && !empty($line->fk_bank))
{
if (!empty($line) && !empty($line->fk_bank)) {
setEventMessages($langs->trans('TermPaidAllreadyPaid'), null, 'errors');
$error++;
}
if (empty($remaindertopay))
{
if (empty($remaindertopay)) {
setEventMessages('Empty sumpaid', null, 'errors');
$error++;
}
if ($amount == 0)
{
if ($amount == 0) {
setEventMessages($langs->trans('ErrorNoPaymentDefined'), null, 'errors');
$error++;
}
if (!$error)
{
if (!$error) {
$db->begin();
// Create a line of payments
@ -164,38 +157,30 @@ if ($action == 'add_payment')
$payment->note_private = GETPOST('note_private', 'restricthtml');
$payment->note_public = GETPOST('note_public', 'restricthtml');
if (!$error)
{
if (!$error) {
$paymentid = $payment->create($user);
if ($paymentid < 0)
{
if ($paymentid < 0) {
setEventMessages($payment->error, $payment->errors, 'errors');
$error++;
}
}
if (!$error)
{
if (!$error) {
$result = $payment->addPaymentToBank($user, $chid, 'payment_loan', '(LoanPayment)', $payment->fk_bank, '', '');
if (!$result > 0)
{
if (!$result > 0) {
setEventMessages($payment->error, $payment->errors, 'errors');
$error++;
}
}
// Update loan schedule with payment value
if (!$error && !empty($line))
{
if (!$error && !empty($line)) {
// If payment values are modified, recalculate schedule
if (($line->amount_capital <> $pay_amount_capital) || ($line->amount_insurance <> $pay_amount_insurance) || ($line->amount_interest <> $pay_amount_interest))
{
if (($line->amount_capital <> $pay_amount_capital) || ($line->amount_insurance <> $pay_amount_insurance) || ($line->amount_interest <> $pay_amount_interest)) {
$arr_term = loanCalcMonthlyPayment(($pay_amount_capital + $pay_amount_interest), $remaindertopay, ($loan->rate / 100), $echance, $loan->nbterm);
foreach ($arr_term as $k=>$v)
{
foreach ($arr_term as $k => $v) {
// Update fk_bank for current line
if ($k == $echance)
{
if ($k == $echance) {
$ls->lines[$k - 1]->fk_bank = $payment->fk_bank;
$ls->lines[$k - 1]->fk_payment_loan = $payment->id;
}
@ -204,29 +189,25 @@ if ($action == 'add_payment')
$ls->lines[$k - 1]->tms = dol_now();
$ls->lines[$k - 1]->fk_user_modif = $user->id;
$result = $ls->lines[$k - 1]->update($user, 0);
if ($result < 1)
{
if ($result < 1) {
setEventMessages(null, $ls->errors, 'errors');
$error++;
break;
}
}
}
else // Only add fk_bank bank to schedule line (mark as paid)
} else // Only add fk_bank bank to schedule line (mark as paid)
{
$line->fk_bank = $payment->fk_bank;
$line->fk_payment_loan = $payment->id;
$result = $line->update($user, 0);
if ($result < 1)
{
if ($result < 1) {
setEventMessages(null, $line->errors, 'errors');
$error++;
}
}
}
if (!$error)
{
if (!$error) {
$db->commit();
$loc = DOL_URL_ROOT.'/loan/card.php?id='.$chid;
header('Location: '.$loc);
@ -251,8 +232,7 @@ $form = new Form($db);
// Form to create loan's payment
if ($action == 'create')
{
if ($action == 'create') {
$total = $loan->capital;
print load_fiche_titre($langs->trans("DoPayment"));
@ -261,8 +241,7 @@ if ($action == 'create')
$sql .= " FROM ".MAIN_DB_PREFIX."payment_loan";
$sql .= " WHERE fk_loan = ".$chid;
$resql = $db->query($sql);
if ($resql)
{
if ($resql) {
$obj = $db->fetch_object($resql);
$sumpaid = $obj->total;
$db->free();
@ -282,10 +261,10 @@ if ($action == 'create')
print '<table class="border centpercent">';
print '<tr><td class="titlefield">'.$langs->trans("Ref").'</td><td colspan="2"><a href="'.DOL_URL_ROOT.'/loan/card.php?id='.$chid.'">'.$chid.'</a></td></tr>';
if ($echance > 0)
{
print '<tr><td>'.$langs->trans("Term").'</td><td colspan="2"><a href="'.DOL_URL_ROOT.'/loan/schedule.php?loanid='.$chid.'#n'.$echance.'">'.$echance.'</a></td></tr>'."\n";
}
if ($echance > 0)
{
print '<tr><td>'.$langs->trans("Term").'</td><td colspan="2"><a href="'.DOL_URL_ROOT.'/loan/schedule.php?loanid='.$chid.'#n'.$echance.'">'.$echance.'</a></td></tr>'."\n";
}
print '<tr><td>'.$langs->trans("DateStart").'</td><td colspan="2">'.dol_print_date($loan->datestart, 'day')."</td></tr>\n";
print '<tr><td>'.$langs->trans("Label").'</td><td colspan="2">'.$loan->label."</td></tr>\n";
print '<tr><td>'.$langs->trans("Amount").'</td><td colspan="2">'.price($loan->capital, 0, $outputlangs, 1, -1, -1, $conf->currency).'</td></tr>';
@ -300,108 +279,106 @@ if ($action == 'create')
print '<table class="border centpercent">';
print '<tr><td class="titlefield fieldrequired">'.$langs->trans("Date").'</td><td colspan="2">';
if (empty($datepaid))
if (empty($ts_temppaid)) $datepayment = empty($conf->global->MAIN_AUTOFILL_DATE) ?-1 : dol_now();
else $datepayment = $ts_temppaid;
else $datepayment = $datepaid;
print $form->selectDate($datepayment, '', '', '', '', "add_payment", 1, 1);
print "</td>";
print '</tr>';
if (empty($datepaid)) {
if (empty($ts_temppaid)) {
$datepayment = empty($conf->global->MAIN_AUTOFILL_DATE) ?-1 : dol_now();
} else {
$datepayment = $ts_temppaid;
}
} else {
$datepayment = $datepaid;
}
print $form->selectDate($datepayment, '', '', '', '', "add_payment", 1, 1);
print "</td>";
print '</tr>';
print '<tr><td class="fieldrequired">'.$langs->trans("PaymentMode").'</td><td colspan="2">';
$form->select_types_paiements(GETPOSTISSET("paymenttype") ? GETPOST("paymenttype", 'alphanohtml') : $loan->fk_typepayment, "paymenttype");
print "</td>\n";
print '</tr>';
print '<tr><td class="fieldrequired">'.$langs->trans("PaymentMode").'</td><td colspan="2">';
$form->select_types_paiements(GETPOSTISSET("paymenttype") ? GETPOST("paymenttype", 'alphanohtml') : $loan->fk_typepayment, "paymenttype");
print "</td>\n";
print '</tr>';
print '<tr>';
print '<td class="fieldrequired">'.$langs->trans('AccountToDebit').'</td>';
print '<td colspan="2">';
$form->select_comptes(GETPOSTISSET("accountid") ? GETPOST("accountid", 'int') : $loan->accountid, "accountid", 0, 'courant = '.Account::TYPE_CURRENT, 1); // Show opend bank account list
print '</td></tr>';
print '<tr>';
print '<td class="fieldrequired">'.$langs->trans('AccountToDebit').'</td>';
print '<td colspan="2">';
$form->select_comptes(GETPOSTISSET("accountid") ? GETPOST("accountid", 'int') : $loan->accountid, "accountid", 0, 'courant = '.Account::TYPE_CURRENT, 1); // Show opend bank account list
print '</td></tr>';
// Number
print '<tr><td>'.$langs->trans('Numero');
print ' <em>('.$langs->trans("ChequeOrTransferNumber").')</em>';
print '</td>';
print '<td colspan="2"><input name="num_payment" type="text" value="'.GETPOST('num_payment', 'alphanohtml').'"></td>'."\n";
print "</tr>";
print '<tr><td>'.$langs->trans('Numero');
print ' <em>('.$langs->trans("ChequeOrTransferNumber").')</em>';
print '</td>';
print '<td colspan="2"><input name="num_payment" type="text" value="'.GETPOST('num_payment', 'alphanohtml').'"></td>'."\n";
print "</tr>";
print '<tr>';
print '<td class="tdtop">'.$langs->trans("NotePrivate").'</td>';
print '<td valign="top" colspan="2"><textarea name="note_private" wrap="soft" cols="60" rows="'.ROWS_3.'"></textarea></td>';
print '</tr>';
print '<tr>';
print '<td class="tdtop">'.$langs->trans("NotePrivate").'</td>';
print '<td valign="top" colspan="2"><textarea name="note_private" wrap="soft" cols="60" rows="'.ROWS_3.'"></textarea></td>';
print '</tr>';
print '<tr>';
print '<td class="tdtop">'.$langs->trans("NotePublic").'</td>';
print '<td valign="top" colspan="2"><textarea name="note_public" wrap="soft" cols="60" rows="'.ROWS_3.'"></textarea></td>';
print '</tr>';
print '<tr>';
print '<td class="tdtop">'.$langs->trans("NotePublic").'</td>';
print '<td valign="top" colspan="2"><textarea name="note_public" wrap="soft" cols="60" rows="'.ROWS_3.'"></textarea></td>';
print '</tr>';
print '</table>';
print '</table>';
print dol_get_fiche_end();
print dol_get_fiche_end();
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td class="left">'.$langs->trans("DateDue").'</td>';
print '<td class="right">'.$langs->trans("LoanCapital").'</td>';
print '<td class="right">'.$langs->trans("AlreadyPaid").'</td>';
print '<td class="right">'.$langs->trans("RemainderToPay").'</td>';
print '<td class="right">'.$langs->trans("Amount").'</td>';
print "</tr>\n";
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td class="left">'.$langs->trans("DateDue").'</td>';
print '<td class="right">'.$langs->trans("LoanCapital").'</td>';
print '<td class="right">'.$langs->trans("AlreadyPaid").'</td>';
print '<td class="right">'.$langs->trans("RemainderToPay").'</td>';
print '<td class="right">'.$langs->trans("Amount").'</td>';
print "</tr>\n";
print '<tr class="oddeven">';
print '<tr class="oddeven">';
if ($loan->datestart > 0)
{
if ($loan->datestart > 0) {
print '<td class="left" valign="center">'.dol_print_date($loan->datestart, 'day').'</td>';
} else {
print '<td class="center" valign="center"><b>!!!</b></td>';
}
print '<td class="right" valign="center">'.price($loan->capital)."</td>";
print '<td class="right" valign="center">'.price($loan->capital)."</td>";
print '<td class="right" valign="center">'.price($sumpaid)."</td>";
print '<td class="right" valign="center">'.price($sumpaid)."</td>";
print '<td class="right" valign="center">'.price($loan->capital - $sumpaid)."</td>";
print '<td class="right" valign="center">'.price($loan->capital - $sumpaid)."</td>";
print '<td class="right">';
if ($sumpaid < $loan->capital)
{
print '<td class="right">';
if ($sumpaid < $loan->capital) {
print $langs->trans("LoanCapital").': <input type="text" size="8" name="amount_capital" value="'.(GETPOSTISSET('amount_capital') ?GETPOST('amount_capital') : $amount_capital).'">';
}
else {
} else {
print '-';
}
print '<br>';
if ($sumpaid < $loan->capital)
{
print '<br>';
if ($sumpaid < $loan->capital) {
print $langs->trans("Insurance").': <input type="text" size="8" name="amount_insurance" value="'.(GETPOSTISSET('amount_insurance') ?GETPOST('amount_insurance') : $amount_insurance).'">';
}
else {
} else {
print '-';
}
print '<br>';
if ($sumpaid < $loan->capital)
{
print '<br>';
if ($sumpaid < $loan->capital) {
print $langs->trans("Interest").': <input type="text" size="8" name="amount_interest" value="'.(GETPOSTISSET('amount_interest') ?GETPOST('amount_interest') : $amount_interest).'" '.(!empty($line) ? 'disabled title="'.$langs->trans('CantModifyInterestIfScheduleIsUsed').'"' : '').'>';
}
else {
} else {
print '-';
}
print "</td>";
print "</td>";
print "</tr>\n";
print "</tr>\n";
print '</table>';
print '</table>';
print '<br><div class="center">';
print '<input type="submit" class="button button-save" name="save" value="'.$langs->trans("Save").'">';
print '&nbsp; &nbsp;';
print '<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans("Cancel").'">';
print '</div>';
print '<br><div class="center">';
print '<input type="submit" class="button button-save" name="save" value="'.$langs->trans("Save").'">';
print '&nbsp; &nbsp;';
print '<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans("Cancel").'">';
print '</div>';
print "</form>\n";
print "</form>\n";
}
llxFooter();

View File

@ -35,9 +35,15 @@ $action = GETPOST('action', 'aZ09');
// Security check
$socid = 0;
if (GETPOSTISSET('socid')) $socid = GETPOST('socid', 'int');
if ($user->socid) $socid = $user->socid;
if (empty($user->rights->loan->calc)) accessforbidden();
if (GETPOSTISSET('socid')) {
$socid = GETPOST('socid', 'int');
}
if ($user->socid) {
$socid = $user->socid;
}
if (empty($user->rights->loan->calc)) {
accessforbidden();
}
// Load translation files required by the page
$langs->loadLangs(array("compta", "bills", "loan"));
@ -120,7 +126,9 @@ if ($action == 'updateecheancier' && empty($pay_without_schedule)) {
$echeances->lines[$i - 1] = $new_echeance;
$i++;
}
if ($result > 0) $db->commit();
if ($result > 0) {
$db->commit();
}
}
/*
@ -141,24 +149,23 @@ $morehtmlref = '<div class="refidno">';
$morehtmlref .= $form->editfieldkey("Label", 'label', $object->label, $object, 0, 'string', '', 0, 1);
$morehtmlref .= $form->editfieldval("Label", 'label', $object->label, $object, 0, 'string', '', null, null, '', 1);
// Project
if (!empty($conf->projet->enabled))
{
if (!empty($conf->projet->enabled)) {
$langs->loadLangs(array("projects"));
$morehtmlref .= '<br>'.$langs->trans('Project').' : ';
if ($user->rights->loan->write)
{
if ($action != 'classify')
if ($user->rights->loan->write) {
if ($action != 'classify') {
//$morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : ';
if ($action == 'classify') {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
$morehtmlref .= '<input type="hidden" name="action" value="classin">';
$morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
$morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
$morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref .= '</form>';
} else {
$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
if ($action == 'classify') {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
$morehtmlref .= '<input type="hidden" name="action" value="classin">';
$morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
$morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
$morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref .= '</form>';
} else {
$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
}
}
} else {
if (!empty($object->fk_project)) {
@ -212,14 +219,14 @@ $(document).ready(function() {
</script>
<?php
if ($pay_without_schedule == 1)
if ($pay_without_schedule == 1) {
print '<div class="warning">'.$langs->trans('CantUseScheduleWithLoanStartedToPaid').'</div>'."\n";
}
print '<form name="createecheancier" action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="loanid" value="'.$loanid.'">';
if (count($echeances->lines) > 0)
{
if (count($echeances->lines) > 0) {
print '<input type="hidden" name="action" value="updateecheancier">';
} else {
print '<input type="hidden" name="action" value="createecheancier">';
@ -229,7 +236,9 @@ print '<div class="div-table-responsive-no-min">';
print '<table class="border centpercent">';
print '<tr class="liste_titre">';
$colspan = 6;
if (count($echeances->lines) > 0) $colspan++;
if (count($echeances->lines) > 0) {
$colspan++;
}
print '<th class="center" colspan="'.$colspan.'">';
print $langs->trans("FinancialCommitment");
print '</th>';
@ -245,18 +254,18 @@ print '<th class="center">'.$langs->trans("CapitalRemain");
print '<br>('.price($object->capital, 0, '', 1, -1, -1, $conf->currency).')';
print '<input type="hidden" name="hi_capital0" id ="hi_capital0" value="'.$object->capital.'">';
print '</th>';
if (count($echeances->lines) > 0) print '<th class="center">'.$langs->trans('DoPayment').'</th>';
if (count($echeances->lines) > 0) {
print '<th class="center">'.$langs->trans('DoPayment').'</th>';
}
print '</tr>'."\n";
if ($object->nbterm > 0 && count($echeances->lines) == 0)
{
if ($object->nbterm > 0 && count($echeances->lines) == 0) {
$i = 1;
$capital = $object->capital;
$insurance = $object->insurance_amount / $object->nbterm;
$insurance = price2num($insurance, 'MT');
$regulInsurance = price2num($object->insurance_amount - ($insurance * $object->nbterm));
while ($i < $object->nbterm + 1)
{
while ($i < $object->nbterm + 1) {
$mens = price2num($echeances->calcMonthlyPayments($capital, $object->rate / 100, $object->nbterm - $i + 1), 'MT');
$int = ($capital * ($object->rate / 12)) / 100;
$int = price2num($int, 'MT');
@ -273,8 +282,7 @@ if ($object->nbterm > 0 && count($echeances->lines) == 0)
$i++;
$capital = $cap_rest;
}
} elseif (count($echeances->lines) > 0)
{
} elseif (count($echeances->lines) > 0) {
$i = 1;
$capital = $object->capital;
$insurance = $object->insurance_amount / $object->nbterm;
@ -300,14 +308,12 @@ if ($object->nbterm > 0 && count($echeances->lines) == 0)
print '<td class="center" id="capital'.$i.'">'.price($cap_rest, 0, '', 1, -1, -1, $conf->currency).'</td><input type="hidden" name="hi_capital'.$i.'" id ="hi_capital'.$i.'" value="'.$cap_rest.'">';
print '<td class="center">';
if (!empty($line->fk_bank))
{
if (!empty($line->fk_bank)) {
print $langs->trans('Paid');
if (!empty($line->fk_payment_loan))
if (!empty($line->fk_payment_loan)) {
print '&nbsp;<a href="'.DOL_URL_ROOT.'/loan/payment/card.php?id='.$line->fk_payment_loan.'">('.img_object($langs->trans("Payment"), "payment").' '.$line->fk_payment_loan.')</a>';
}
elseif (!$printed)
{
}
} elseif (!$printed) {
print '<a class="butAction" href="'.DOL_URL_ROOT.'/loan/payment/payment.php?id='.$object->id.'&amp;action=create">'.$langs->trans('DoPayment').'</a>';
$printed = true;
}
@ -323,8 +329,11 @@ print '</div>';
print '</br>';
if (count($echeances->lines) == 0) $label = $langs->trans("Create");
else $label = $langs->trans("Save");
if (count($echeances->lines) == 0) {
$label = $langs->trans("Create");
} else {
$label = $langs->trans("Save");
}
print '<div class="center"><input class="button" type="submit" value="'.$label.'" '.(($pay_without_schedule == 1) ? 'disabled title="'.$langs->trans('CantUseScheduleWithLoanStartedToPaid').'"' : '').'title=""></div>';
print '</form>';

View File

@ -77,8 +77,7 @@ class MailmanSpip
*/
public function isSpipEnabled()
{
if (defined("ADHERENT_USE_SPIP") && (ADHERENT_USE_SPIP == 1))
{
if (defined("ADHERENT_USE_SPIP") && (ADHERENT_USE_SPIP == 1)) {
return true;
}
@ -92,10 +91,8 @@ class MailmanSpip
*/
public function checkSpipConfig()
{
if (defined('ADHERENT_SPIP_SERVEUR') && defined('ADHERENT_SPIP_USER') && defined('ADHERENT_SPIP_PASS') && defined('ADHERENT_SPIP_DB'))
{
if (ADHERENT_SPIP_SERVEUR != '' && ADHERENT_SPIP_USER != '' && ADHERENT_SPIP_PASS != '' && ADHERENT_SPIP_DB != '')
{
if (defined('ADHERENT_SPIP_SERVEUR') && defined('ADHERENT_SPIP_USER') && defined('ADHERENT_SPIP_PASS') && defined('ADHERENT_SPIP_DB')) {
if (ADHERENT_SPIP_SERVEUR != '' && ADHERENT_SPIP_USER != '' && ADHERENT_SPIP_PASS != '' && ADHERENT_SPIP_DB != '') {
return true;
}
}
@ -112,8 +109,7 @@ class MailmanSpip
{
$resource = getDoliDBInstance('mysql', ADHERENT_SPIP_SERVEUR, ADHERENT_SPIP_USER, ADHERENT_SPIP_PASS, ADHERENT_SPIP_DB, ADHERENT_SPIP_PORT);
if ($resource->ok)
{
if ($resource->ok) {
return $resource;
}
@ -165,8 +161,7 @@ class MailmanSpip
dol_syslog('result curl_exec='.$result);
//An error was found, we store it in $this->error for later
if ($result === false || curl_errno($ch) > 0)
{
if ($result === false || curl_errno($ch) > 0) {
$this->error = curl_errno($ch).' '.curl_error($ch);
dol_syslog('Error using curl '.$this->error, LOG_ERR);
}
@ -188,14 +183,11 @@ class MailmanSpip
// phpcs:enable
dol_syslog(get_class($this)."::add_to_spip");
if ($this->isSpipEnabled())
{
if ($this->checkSpipConfig())
{
if ($this->isSpipEnabled()) {
if ($this->checkSpipConfig()) {
$mydb = $this->connectSpip();
if ($mydb)
{
if ($mydb) {
require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
$mdpass = dol_hash($object->pass);
$htpass = crypt($object->pass, makesalt());
@ -205,13 +197,20 @@ class MailmanSpip
$mydb->close();
if ($result)
{
if ($result) {
return 1;
} else $this->error = $mydb->lasterror();
} else $this->error = 'Failed to connect to SPIP';
} else $this->error = 'BadSPIPConfiguration';
} else $this->error = 'SPIPNotEnabled';
} else {
$this->error = $mydb->lasterror();
}
} else {
$this->error = 'Failed to connect to SPIP';
}
} else {
$this->error = 'BadSPIPConfiguration';
}
} else {
$this->error = 'SPIPNotEnabled';
}
return 0;
}
@ -228,27 +227,31 @@ class MailmanSpip
// phpcs:enable
dol_syslog(get_class($this)."::del_to_spip");
if ($this->isSpipEnabled())
{
if ($this->checkSpipConfig())
{
if ($this->isSpipEnabled()) {
if ($this->checkSpipConfig()) {
$mydb = $this->connectSpip();
if ($mydb)
{
if ($mydb) {
$query = "DELETE FROM spip_auteurs WHERE login='".$object->login."'";
$result = $mydb->query($query);
$mydb->close();
if ($result)
{
if ($result) {
return 1;
} else $this->error = $mydb->lasterror();
} else $this->error = 'Failed to connect to SPIP';
} else $this->error = 'BadSPIPConfiguration';
} else $this->error = 'SPIPNotEnabled';
} else {
$this->error = $mydb->lasterror();
}
} else {
$this->error = 'Failed to connect to SPIP';
}
} else {
$this->error = 'BadSPIPConfiguration';
}
} else {
$this->error = 'SPIPNotEnabled';
}
return 0;
}
@ -263,22 +266,17 @@ class MailmanSpip
public function is_in_spip($object)
{
// phpcs:enable
if ($this->isSpipEnabled())
{
if ($this->checkSpipConfig())
{
if ($this->isSpipEnabled()) {
if ($this->checkSpipConfig()) {
$mydb = $this->connectSpip();
if ($mydb)
{
if ($mydb) {
$query = "SELECT login FROM spip_auteurs WHERE login='".$object->login."'";
$result = $mydb->query($query);
if ($result)
{
if ($mydb->num_rows($result))
{
if ($result) {
if ($mydb->num_rows($result)) {
// nous avons au moins une reponse
$mydb->close($result);
return 1;
@ -291,9 +289,15 @@ class MailmanSpip
$this->error = $mydb->lasterror();
$mydb->close();
}
} else $this->error = 'Failed to connect to SPIP';
} else $this->error = 'BadSPIPConfiguration';
} else $this->error = 'SPIPNotEnabled';
} else {
$this->error = 'Failed to connect to SPIP';
}
} else {
$this->error = 'BadSPIPConfiguration';
}
} else {
$this->error = 'SPIPNotEnabled';
}
return -1;
}
@ -316,36 +320,32 @@ class MailmanSpip
$this->mladded_ok = array();
$this->mladded_ko = array();
if (!function_exists("curl_init"))
{
if (!function_exists("curl_init")) {
$langs->load("errors");
$this->error = $langs->trans("ErrorFunctionNotAvailableInPHP", "curl_init");
return -1;
}
if ($conf->adherent->enabled) // Synchro for members
{
if (!empty($conf->global->ADHERENT_MAILMAN_URL))
{
if ($listes == '' && !empty($conf->global->ADHERENT_MAILMAN_LISTS)) $lists = explode(',', $conf->global->ADHERENT_MAILMAN_LISTS);
else $lists = explode(',', $listes);
if ($conf->adherent->enabled) { // Synchro for members
if (!empty($conf->global->ADHERENT_MAILMAN_URL)) {
if ($listes == '' && !empty($conf->global->ADHERENT_MAILMAN_LISTS)) {
$lists = explode(',', $conf->global->ADHERENT_MAILMAN_LISTS);
} else {
$lists = explode(',', $listes);
}
$categstatic = new Categorie($this->db);
foreach ($lists as $list)
{
foreach ($lists as $list) {
// Filter on type something (ADHERENT_MAILMAN_LISTS = "mailinglist0,TYPE:typevalue:mailinglist1,CATEG:categvalue:mailinglist2")
$tmp = explode(':', $list);
if (!empty($tmp[2]))
{
if (!empty($tmp[2])) {
$list = $tmp[2];
if ($object->element == 'member' && $tmp[0] == 'TYPE' && $object->type != $tmp[1]) // Filter on member type label
{
if ($object->element == 'member' && $tmp[0] == 'TYPE' && $object->type != $tmp[1]) { // Filter on member type label
dol_syslog("We ignore list ".$list." because object member type ".$object->type." does not match ".$tmp[1], LOG_DEBUG);
continue;
}
if ($object->element == 'member' && $tmp[0] == 'CATEG' && !in_array($tmp[1], $categstatic->containing($object->id, 'member', 'label'))) // Filter on member category
{
if ($object->element == 'member' && $tmp[0] == 'CATEG' && !in_array($tmp[1], $categstatic->containing($object->id, 'member', 'label'))) { // Filter on member category
dol_syslog("We ignore list ".$list." because object member is not into category ".$tmp[1], LOG_DEBUG);
continue;
}
@ -354,11 +354,12 @@ class MailmanSpip
//We call Mailman to subscribe the user
$result = $this->callMailman($object, $conf->global->ADHERENT_MAILMAN_URL, $list);
if ($result === false)
{
if ($result === false) {
$this->mladded_ko[$list] = $object->email;
return -2;
} else $this->mladded_ok[$list] = $object->email;
} else {
$this->mladded_ok[$list] = $object->email;
}
}
return count($lists);
} else {
@ -387,36 +388,32 @@ class MailmanSpip
$this->mlremoved_ok = array();
$this->mlremoved_ko = array();
if (!function_exists("curl_init"))
{
if (!function_exists("curl_init")) {
$langs->load("errors");
$this->error = $langs->trans("ErrorFunctionNotAvailableInPHP", "curl_init");
return -1;
}
if ($conf->adherent->enabled) // Synchro for members
{
if (!empty($conf->global->ADHERENT_MAILMAN_UNSUB_URL))
{
if ($listes == '' && !empty($conf->global->ADHERENT_MAILMAN_LISTS)) $lists = explode(',', $conf->global->ADHERENT_MAILMAN_LISTS);
else $lists = explode(',', $listes);
if ($conf->adherent->enabled) { // Synchro for members
if (!empty($conf->global->ADHERENT_MAILMAN_UNSUB_URL)) {
if ($listes == '' && !empty($conf->global->ADHERENT_MAILMAN_LISTS)) {
$lists = explode(',', $conf->global->ADHERENT_MAILMAN_LISTS);
} else {
$lists = explode(',', $listes);
}
$categstatic = new Categorie($this->db);
foreach ($lists as $list)
{
foreach ($lists as $list) {
// Filter on type something (ADHERENT_MAILMAN_LISTS = "mailinglist0,TYPE:typevalue:mailinglist1,CATEG:categvalue:mailinglist2")
$tmp = explode(':', $list);
if (!empty($tmp[2]))
{
if (!empty($tmp[2])) {
$list = $tmp[2];
if ($object->element == 'member' && $tmp[0] == 'TYPE' && $object->type != $tmp[1]) // Filter on member type label
{
if ($object->element == 'member' && $tmp[0] == 'TYPE' && $object->type != $tmp[1]) { // Filter on member type label
dol_syslog("We ignore list ".$list." because object member type ".$object->type." does not match ".$tmp[1], LOG_DEBUG);
continue;
}
if ($object->element == 'member' && $tmp[0] == 'CATEG' && !in_array($tmp[1], $categstatic->containing($object->id, 'member', 'label'))) // Filter on member category
{
if ($object->element == 'member' && $tmp[0] == 'CATEG' && !in_array($tmp[1], $categstatic->containing($object->id, 'member', 'label'))) { // Filter on member category
dol_syslog("We ignore list ".$list." because object member is not into category ".$tmp[1], LOG_DEBUG);
continue;
}
@ -425,11 +422,12 @@ class MailmanSpip
//We call Mailman to unsubscribe the user
$result = $this->callMailman($object, $conf->global->ADHERENT_MAILMAN_UNSUB_URL, $list);
if ($result === false)
{
if ($result === false) {
$this->mlremoved_ko[$list] = $object->email;
return -2;
} else $this->mlremoved_ok[$list] = $object->email;
} else {
$this->mlremoved_ok[$list] = $object->email;
}
}
return count($lists);
} else {

View File

@ -31,7 +31,9 @@ require_once DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php";
$langs->loadLangs(array("admin", "bills", "margins", "stocks"));
if (!$user->admin) accessforbidden();
if (!$user->admin) {
accessforbidden();
}
$action = GETPOST('action', 'aZ09');
@ -40,11 +42,9 @@ $action = GETPOST('action', 'aZ09');
* Action
*/
if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg))
{
if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) {
$code = $reg[1];
if (dolibarr_set_const($db, $code, 1, 'yesno', 0, '', $conf->entity) > 0)
{
if (dolibarr_set_const($db, $code, 1, 'yesno', 0, '', $conf->entity) > 0) {
header("Location: ".$_SERVER["PHP_SELF"]);
exit;
} else {
@ -52,11 +52,9 @@ if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg))
}
}
if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg))
{
if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) {
$code = $reg[1];
if (dolibarr_del_const($db, $code, $conf->entity) > 0)
{
if (dolibarr_del_const($db, $code, $conf->entity) > 0) {
header("Location: ".$_SERVER["PHP_SELF"]);
exit;
} else {
@ -64,30 +62,24 @@ if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg))
}
}
if ($action == 'remises')
{
if (dolibarr_set_const($db, 'MARGIN_METHODE_FOR_DISCOUNT', $_POST['MARGIN_METHODE_FOR_DISCOUNT'], 'chaine', 0, '', $conf->entity) > 0)
{
if ($action == 'remises') {
if (dolibarr_set_const($db, 'MARGIN_METHODE_FOR_DISCOUNT', $_POST['MARGIN_METHODE_FOR_DISCOUNT'], 'chaine', 0, '', $conf->entity) > 0) {
setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs');
} else {
dol_print_error($db);
}
}
if ($action == 'typemarges')
{
if (dolibarr_set_const($db, 'MARGIN_TYPE', $_POST['MARGIN_TYPE'], 'chaine', 0, '', $conf->entity) > 0)
{
if ($action == 'typemarges') {
if (dolibarr_set_const($db, 'MARGIN_TYPE', $_POST['MARGIN_TYPE'], 'chaine', 0, '', $conf->entity) > 0) {
setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs');
} else {
dol_print_error($db);
}
}
if ($action == 'contact')
{
if (dolibarr_set_const($db, 'AGENT_CONTACT_TYPE', $_POST['AGENT_CONTACT_TYPE'], 'chaine', 0, '', $conf->entity) > 0)
{
if ($action == 'contact') {
if (dolibarr_set_const($db, 'AGENT_CONTACT_TYPE', $_POST['AGENT_CONTACT_TYPE'], 'chaine', 0, '', $conf->entity) > 0) {
setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs');
} else {
dol_print_error($db);
@ -126,18 +118,23 @@ print '<tr class="oddeven">';
print '<td>'.$langs->trans("MARGIN_TYPE").'</td>';
print '<td>';
print ' <input type="radio" name="MARGIN_TYPE" value="1" ';
if (isset($conf->global->MARGIN_TYPE) && $conf->global->MARGIN_TYPE == '1')
if (isset($conf->global->MARGIN_TYPE) && $conf->global->MARGIN_TYPE == '1') {
print 'checked ';
}
print '/> ';
print $langs->trans('MargeType1');
print '<br>';
print ' <input type="radio" name="MARGIN_TYPE" value="pmp" ';
if (isset($conf->global->MARGIN_TYPE) && $conf->global->MARGIN_TYPE == 'pmp') print 'checked ';
if (isset($conf->global->MARGIN_TYPE) && $conf->global->MARGIN_TYPE == 'pmp') {
print 'checked ';
}
print '/> ';
print $langs->trans('MargeType2');
print '<br>';
print ' <input type="radio" name="MARGIN_TYPE" value="costprice" ';
if (isset($conf->global->MARGIN_TYPE) && $conf->global->MARGIN_TYPE == 'costprice') print 'checked ';
if (isset($conf->global->MARGIN_TYPE) && $conf->global->MARGIN_TYPE == 'costprice') {
print 'checked ';
}
print '/> ';
print $langs->trans('MargeType3');
print '</td>';
@ -153,12 +150,10 @@ print '</form>';
print '<tr class="oddeven">';
print '<td>'.$langs->trans("DisplayMarginRates").'</td>';
print '<td colspan="2">';
if (!empty($conf->use_javascript_ajax))
{
if (!empty($conf->use_javascript_ajax)) {
print ajax_constantonoff('DISPLAY_MARGIN_RATES');
} else {
if (empty($conf->global->DISPLAY_MARGIN_RATES))
{
if (empty($conf->global->DISPLAY_MARGIN_RATES)) {
print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_DISPLAY_MARGIN_RATES&amp;token='.newToken().'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
} else {
print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_DISPLAY_MARGIN_RATES&amp;token='.newToken().'">'.img_picto($langs->trans("Enabled"), 'on').'</a>';
@ -172,12 +167,10 @@ print '</tr>';
print '<tr class="oddeven">';
print '<td>'.$langs->trans("DisplayMarkRates").'</td>';
print '<td colspan="2">';
if (!empty($conf->use_javascript_ajax))
{
if (!empty($conf->use_javascript_ajax)) {
print ajax_constantonoff('DISPLAY_MARK_RATES');
} else {
if (empty($conf->global->DISPLAY_MARK_RATES))
{
if (empty($conf->global->DISPLAY_MARK_RATES)) {
print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_DISPLAY_MARK_RATES">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
} else {
print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_DISPLAY_MARK_RATES">'.img_picto($langs->trans("Enabled"), 'on').'</a>';
@ -191,12 +184,10 @@ print '</tr>';
print '<tr class="oddeven">';
print '<td>'.$langs->trans("ForceBuyingPriceIfNull").'</td>';
print '<td colspan="2">';
if (!empty($conf->use_javascript_ajax))
{
if (!empty($conf->use_javascript_ajax)) {
print ajax_constantonoff('ForceBuyingPriceIfNull');
} else {
if (empty($conf->global->ForceBuyingPriceIfNull))
{
if (empty($conf->global->ForceBuyingPriceIfNull)) {
print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_ForceBuyingPriceIfNull&amp;token='.newToken().'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
} else {
print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_ForceBuyingPriceIfNull&amp;token='.newToken().'">'.img_picto($langs->trans("Enabled"), 'on').'</a>';

View File

@ -39,16 +39,21 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
if (empty($page) || $page == -1) {
$page = 0;
} // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (!$sortorder) $sortorder = "ASC";
if (!$sortfield)
{
if ($agentid > 0)
if (!$sortorder) {
$sortorder = "ASC";
}
if (!$sortfield) {
if ($agentid > 0) {
$sortfield = "s.nom";
else $sortfield = "u.lastname";
} else {
$sortfield = "u.lastname";
}
}
$startdate = $enddate = '';
@ -60,10 +65,12 @@ $enddateday = GETPOST('enddateday', 'int');
$enddatemonth = GETPOST('enddatemonth', 'int');
$enddateyear = GETPOST('enddateyear', 'int');
if (!empty($startdatemonth))
if (!empty($startdatemonth)) {
$startdate = dol_mktime(0, 0, 0, $startdatemonth, $startdateday, $startdateyear);
if (!empty($enddatemonth))
}
if (!empty($enddatemonth)) {
$enddate = dol_mktime(23, 59, 59, $enddatemonth, $enddateday, $enddateyear);
}
// Security check
if ($user->rights->margins->read->all) {
@ -154,23 +161,31 @@ $sql .= " WHERE f.fk_soc = s.rowid";
$sql .= ' AND f.entity IN ('.getEntity('invoice').')';
$sql .= " AND sc.fk_soc = f.fk_soc";
$sql .= " AND (d.product_type = 0 OR d.product_type = 1)";
if (!empty($conf->global->AGENT_CONTACT_TYPE))
if (!empty($conf->global->AGENT_CONTACT_TYPE)) {
$sql .= " AND ((e.fk_socpeople IS NULL AND sc.fk_user = u.rowid) OR (e.fk_socpeople IS NOT NULL AND e.fk_socpeople = u.rowid))";
else $sql .= " AND sc.fk_user = u.rowid";
} else {
$sql .= " AND sc.fk_user = u.rowid";
}
$sql .= " AND f.fk_statut NOT IN (".implode(', ', $invoice_status_except_list).")";
$sql .= ' AND s.entity IN ('.getEntity('societe').')';
$sql .= " AND d.fk_facture = f.rowid";
if ($agentid > 0) {
if (!empty($conf->global->AGENT_CONTACT_TYPE))
$sql .= " AND ((e.fk_socpeople IS NULL AND sc.fk_user = ".$agentid.") OR (e.fk_socpeople IS NOT NULL AND e.fk_socpeople = ".$agentid."))";
else $sql .= " AND sc.fk_user = ".$agentid;
if (!empty($conf->global->AGENT_CONTACT_TYPE)) {
$sql .= " AND ((e.fk_socpeople IS NULL AND sc.fk_user = ".$agentid.") OR (e.fk_socpeople IS NOT NULL AND e.fk_socpeople = ".$agentid."))";
} else {
$sql .= " AND sc.fk_user = ".$agentid;
}
}
if (!empty($startdate)) {
$sql .= " AND f.datef >= '".$db->idate($startdate)."'";
}
if (!empty($enddate)) {
$sql .= " AND f.datef <= '".$db->idate($enddate)."'";
}
if (!empty($startdate))
$sql .= " AND f.datef >= '".$db->idate($startdate)."'";
if (!empty($enddate))
$sql .= " AND f.datef <= '".$db->idate($enddate)."'";
$sql .= " AND d.buy_price_ht IS NOT NULL";
if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1) $sql .= " AND d.buy_price_ht <> 0";
if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1) {
$sql .= " AND d.buy_price_ht <> 0";
}
//if ($agentid > 0) $sql.= " GROUP BY s.rowid, s.nom, s.code_client, s.client, u.rowid, u.login, u.lastname, u.firstname";
//else $sql.= " GROUP BY u.rowid, u.login, u.lastname, u.firstname";
$sql .= " GROUP BY s.rowid, s.nom, s.code_client, s.client, u.rowid, u.login, u.lastname, u.firstname";
@ -183,28 +198,42 @@ print '<br>';
print img_info('').' '.$langs->trans("MarginPerSaleRepresentativeWarning").'<br>';
$param = '';
if (!empty($agentid)) $param .= "&amp;agentid=".urlencode($agentid);
if (!empty($startdateday)) $param .= "&amp;startdateday=".urlencode($startdateday);
if (!empty($startdatemonth)) $param .= "&amp;startdatemonth=".urlencode($startdatemonth);
if (!empty($startdateyear)) $param .= "&amp;startdateyear=".urlencode($startdateyear);
if (!empty($enddateday)) $param .= "&amp;enddateday=".urlencode($enddateday);
if (!empty($enddatemonth)) $param .= "&amp;enddatemonth=".urlencode($enddatemonth);
if (!empty($enddateyear)) $param .= "&amp;enddateyear=".urlencode($enddateyear);
if (!empty($agentid)) {
$param .= "&amp;agentid=".urlencode($agentid);
}
if (!empty($startdateday)) {
$param .= "&amp;startdateday=".urlencode($startdateday);
}
if (!empty($startdatemonth)) {
$param .= "&amp;startdatemonth=".urlencode($startdatemonth);
}
if (!empty($startdateyear)) {
$param .= "&amp;startdateyear=".urlencode($startdateyear);
}
if (!empty($enddateday)) {
$param .= "&amp;enddateday=".urlencode($enddateday);
}
if (!empty($enddatemonth)) {
$param .= "&amp;enddatemonth=".urlencode($enddatemonth);
}
if (!empty($enddateyear)) {
$param .= "&amp;enddateyear=".urlencode($enddateyear);
}
dol_syslog('margin::agentMargins.php', LOG_DEBUG);
$result = $db->query($sql);
if ($result)
{
if ($result) {
$num = $db->num_rows($result);
print '<br>';
print_barre_liste($langs->trans("MarginDetails"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num, $num, '', 0, '', '', 0, 1);
if ($conf->global->MARGIN_TYPE == "1")
if ($conf->global->MARGIN_TYPE == "1") {
$labelcostprice = 'BuyingPrice';
else // value is 'costprice' or 'pmp'
} else { // value is 'costprice' or 'pmp'
$labelcostprice = 'CostPrice';
}
$moreforfilter = '';
@ -213,21 +242,24 @@ if ($result)
print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
print '<tr class="liste_titre">';
if ($agentid > 0)
if ($agentid > 0) {
print_liste_field_titre("Customer", $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder);
else print_liste_field_titre("SalesRepresentative", $_SERVER["PHP_SELF"], "u.lastname", "", $param, '', $sortfield, $sortorder);
} else {
print_liste_field_titre("SalesRepresentative", $_SERVER["PHP_SELF"], "u.lastname", "", $param, '', $sortfield, $sortorder);
}
print_liste_field_titre("SellingPrice", $_SERVER["PHP_SELF"], "selling_price", "", $param, '', $sortfield, $sortorder, 'right ');
print_liste_field_titre($labelcostprice, $_SERVER["PHP_SELF"], "buying_price", "", $param, '', $sortfield, $sortorder, 'right ');
print_liste_field_titre("Margin", $_SERVER["PHP_SELF"], "marge", "", $param, '', $sortfield, $sortorder, 'right ');
if (!empty($conf->global->DISPLAY_MARGIN_RATES))
if (!empty($conf->global->DISPLAY_MARGIN_RATES)) {
print_liste_field_titre("MarginRate", $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'right ');
if (!empty($conf->global->DISPLAY_MARK_RATES))
}
if (!empty($conf->global->DISPLAY_MARK_RATES)) {
print_liste_field_titre("MarkRate", $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'right ');
}
print "</tr>\n";
if ($num > 0)
{
if ($num > 0) {
$group_list = array();
while ($objp = $db->fetch_object($result)) {
if ($agentid > 0) {
@ -295,10 +327,12 @@ if ($result)
print '<td class="nowrap right">'.price(price2num($pv, 'MT')).'</td>';
print '<td class="nowrap right">'.price(price2num($pa, 'MT')).'</td>';
print '<td class="nowrap right">'.price(price2num($marge, 'MT')).'</td>';
if (!empty($conf->global->DISPLAY_MARGIN_RATES))
if (!empty($conf->global->DISPLAY_MARGIN_RATES)) {
print '<td class="nowrap right">'.(($marginRate === '') ? 'n/a' : price(price2num($marginRate, 'MT'))."%").'</td>';
if (!empty($conf->global->DISPLAY_MARK_RATES))
}
if (!empty($conf->global->DISPLAY_MARK_RATES)) {
print '<td class="nowrap right">'.(($markRate === '') ? 'n/a' : price(price2num($markRate, 'MT'))."%").'</td>';
}
print "</tr>\n";
$i++;
@ -319,10 +353,12 @@ if ($result)
print '<td class="nowrap right">'.price(price2num($cumul_vente, 'MT')).'</td>';
print '<td class="nowrap right">'.price(price2num($cumul_achat, 'MT')).'</td>';
print '<td class="nowrap right">'.price(price2num($totalMargin, 'MT')).'</td>';
if (!empty($conf->global->DISPLAY_MARGIN_RATES))
if (!empty($conf->global->DISPLAY_MARGIN_RATES)) {
print '<td class="nowrap right">'.(($marginRate === '') ? 'n/a' : price(price2num($marginRate, 'MT'))."%").'</td>';
if (!empty($conf->global->DISPLAY_MARK_RATES))
}
if (!empty($conf->global->DISPLAY_MARK_RATES)) {
print '<td class="nowrap right">'.(($markRate === '') ? 'n/a' : price(price2num($markRate, 'MT'))."%").'</td>';
}
print '</tr>';
print '</table>';

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