Merge pull request #5 from Dolibarr/develop

Merge changes since last PR
This commit is contained in:
Tim Otte 2020-07-28 11:07:22 +02:00 committed by GitHub
commit 08fc988d3a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1487 changed files with 27177 additions and 16766 deletions

View File

@ -326,6 +326,12 @@ source_file = htdocs/langs/en_US/receptions.lang
source_lang = en_US
type = MOZILLAPROPERTIES
[dolibarr.recruitment]
file_filter = htdocs/langs/<lang>/recruitment.lang
source_file = htdocs/langs/en_US/recruitment.lang
source_lang = en_US
type = MOZILLAPROPERTIES
[dolibarr.resource]
file_filter = htdocs/langs/<lang>/resource.lang
source_file = htdocs/langs/en_US/resource.lang

View File

@ -39,7 +39,7 @@ TCPDI 1.0.0 LGPL-3+ / Apache 2.0 Yes
JS libraries:
Ace 1.4.8 BSD Yes JS library to get code syntaxique coloration in a textarea.
ChartJS 2.9.3 MIT License Yes JS library for graph
jQuery 3.4.1 MIT License Yes JS library
jQuery 3.5.1 MIT License Yes JS library
jQuery UI 1.12.1 GPL and MIT License Yes JS library plugin UI
jQuery select2 4.0.13 GPL and Apache License Yes JS library plugin for sexier multiselect. Warning: 4.0.6+ create troubles without patching css
jQuery blockUI 2.70.0 GPL and MIT License Yes JS library plugin blockUI (to use ajax popups)

View File

@ -14,6 +14,42 @@ Following changes may create regressions for some external modules, but were nec
***** ChangeLog for 12.0.1 compared to 12.0.0 *****
FIX: reposition was broken if url end with #anchor
FIX: $_POST must be GETPOST
FIX: 10.0 - fatal with postgreSQL
FIX: #14109
FIX: #14112
FIX: #14142
FIX: all extrafields cleared after update of one of them
FIX: Avoid warning when creating a module with already existing files
FIX: change selected fields on company card
FIX: Correct ModuleBuilder left menu
FIX: create a deposit with amount using comma didn't work
FIX: CSS
FIX: Entry from stripe intent were reported into SEPA payments
FIX: Filter on status, closing opening status
FIX: html lost on html extrafield
FIX: Label of popup on thirdparty
FIX: missing possibility to change entity when propal cloning
FIX: missing setup of extrafields for MO
FIX: Missing the tooltip when creating bank account
FIX: Missing token
FIX: non numeric value on comm/card.php
FIX: SQL Problem in customer invoice list
FIX: SQL Problem in social contribution list
FIX: SQL Problem in supplier invoice list
FIX: SQL syntax error when editing extrafields
FIX: Sql type
FIX: takepos 12 hook
FIX: Update form erased extrafields that were hidden
FIX: Update of extrafields date
FIX: Update of extrafiels on draft object
FIX: upload documents into manual ECM was reported a permission error
FIX: Use of office365 TLS with SMTPs method.
FIX: wrong origin
FIX: Permission error during import
***** ChangeLog for 12.0.0 compared to 11.0.0 *****
For users:
@ -115,8 +151,8 @@ NEW: class tool for converting units
NEW: Close #13011 Add button create thirdparty when creating intervention
NEW: Colorful theme for TakePOS
NEW: columns units in product list
NEW: compatibility of translabel with more dict
NEW: Confirm file delete on fracture card
NEW: compatibility of translabel with more dictionaries
NEW: Confirm file delete on invoice card
NEW: "contact_civility" for ODT templates
NEW: CUPS printing compatibility for TakePOS
NEW: Customer command list - Add date start & date end
@ -124,16 +160,11 @@ NEW: display weight in shipment list
NEW: Documentation about PHP support in Dolibarr
NEW: Donation - Update FR CERFA to 11580*04
NEW: Easier way to setup the different types of tax. Better visibility.
NEW: enable put for agendaevents api
NEW: Expedition list - Add date start & date end
NEW: Experiment supplier packaging with option PRODUCT_USE_SUPPLIER_PACKAGING: Using price according to the minimum quantity
NEW: Export module, add extrafields for Contract and Contract line
NEW: Extend retained warranty to be available for all invoices
NEW: filter by product on supplier order API
NEW: French new regions
NEW: get documents for categories with RESP API
NEW: get proposal by ref with API
NEW: Hidden option MAIN_TEMP_DIR
NEW: hook and data id
NEW: hook on ics generation to add more events in eventarray
NEW: hook on product load stats
@ -206,7 +237,6 @@ NEW: API filter bankaccounts by category
NEW: API filter contacts by category
NEW: API filter members by category
NEW: API filter projects by category
NEW: API filter thirdpartie by category
NEW: API filter thirdparty by category
NEW: API filter user by category
NEW: API filter warehouses by categorie
@ -220,6 +250,11 @@ NEW: Bookkeeping by account - Add selectfields & hook
NEW: Can force position of legend of graph on right (instead of top)
NEW: Can change destination of "Back to list" using a "backtolist" parameter
NEW: add more category types from hook
NEW: enable put for agendaevents api
NEW: filter by product on supplier order API
NEW: get documents for categories with RESP API
NEW: get proposal by ref with API
NEW: Hidden option MAIN_TEMP_DIR
WARNING:

View File

@ -167,6 +167,7 @@ In htdocs/includes/tecnickcom/tcpdf/tcpdf.php
TCPDI:
------
Add fpdf_tpl.php 1.2
Add tcpdi.php
Add tcpdi_parser.php and replace:
@ -205,8 +206,6 @@ with
JCROP:
------
* Remove analytics tag into file index.html

View File

@ -0,0 +1,172 @@
<?xml version="1.0" encoding="UTF-8"?>
<Document xmlns="urn:iso:std:iso:20022:tech:xsd:pain.001.001.03">
<CstmrCdtTrfInitn>
<GrpHdr>
<MsgId>message-id-001</MsgId>
<CreDtTm>2010-09-28T14:07:00</CreDtTm>
<NbOfTxs>1</NbOfTxs>
<CtrlSum>10.1</CtrlSum>
<InitgPty>
<Nm>Bedrijfsnaam</Nm>
<Id>
<OrgId>
<Othr>
<Id>123456789123456</Id>
</Othr>
</OrgId>
</Id>
</InitgPty>
</GrpHdr>
<PmtInf>
<PmtInfId>minimaal gevuld</PmtInfId>
<PmtMtd>TRF</PmtMtd>
<NbOfTxs>1</NbOfTxs>
<CtrlSum>10.1</CtrlSum>
<ReqdExctnDt>2009-11-01</ReqdExctnDt>
<Dbtr>
<Nm>Naam</Nm>
</Dbtr>
<DbtrAcct>
<Id>
<IBAN>NL44RABO0123456789</IBAN>
</Id>
</DbtrAcct>
<DbtrAgt>
<FinInstnId>
<BIC>RABONL2U</BIC>
</FinInstnId>
</DbtrAgt>
<CdtTrfTxInf>
<PmtId>
<EndToEndId>non ref</EndToEndId>
</PmtId>
<Amt>
<InstdAmt Ccy="EUR">10.1</InstdAmt>
</Amt>
<ChrgBr>SLEV</ChrgBr>
<CdtrAgt>
<FinInstnId>
<BIC>ABNANL2A</BIC>
</FinInstnId>
</CdtrAgt>
<Cdtr>
<Nm>Naam creditor</Nm>
</Cdtr>
<CdtrAcct>
<Id>
<IBAN>NL90ABNA0111111111</IBAN>
</Id>
</CdtrAcct>
<RmtInf>
<Ustrd>vrije tekst</Ustrd>
</RmtInf>
</CdtTrfTxInf>
</PmtInf>
<PmtInf>
<PmtInfId>maximaal gevuld</PmtInfId>
<PmtMtd>TRF</PmtMtd>
<BtchBookg>true</BtchBookg>
<NbOfTxs>1</NbOfTxs>
<CtrlSum>20.2</CtrlSum>
<PmtTpInf>
<InstrPrty>NORM</InstrPrty>
<SvcLvl>
<Cd>SEPA</Cd>
</SvcLvl>
<LclInstrm>
<Cd>IDEAL</Cd>
</LclInstrm>
<CtgyPurp>
<Cd>SECU</Cd>
</CtgyPurp>
</PmtTpInf>
<ReqdExctnDt>2009-11-01</ReqdExctnDt>
<Dbtr>
<Nm>Naam</Nm>
<PstlAdr>
<Ctry>NL</Ctry>
<AdrLine>Debtor straat 1</AdrLine>
<AdrLine>9999 XX Plaats debtor</AdrLine>
</PstlAdr>
</Dbtr>
<DbtrAcct>
<Id>
<IBAN>NL44RABO0123456789</IBAN>
</Id>
</DbtrAcct>
<DbtrAgt>
<FinInstnId>
<BIC>RABONL2U</BIC>
</FinInstnId>
</DbtrAgt>
<UltmtDbtr>
<Id>
<OrgId>
<Othr>
<Id>12345678</Id>
<SchmeNm>
<Prtry>klantnummer</Prtry>
</SchmeNm>
<Issr>klantnummer uitgifte instantie</Issr>
</Othr>
</OrgId>
</Id>
</UltmtDbtr>
<ChrgBr>SLEV</ChrgBr>
<CdtTrfTxInf>
<PmtId>
<InstrId>debtor-to-debtor-bank-01</InstrId>
<EndToEndId>End-to-end-id-debtor-to-creditor-01</EndToEndId>
</PmtId>
<Amt>
<InstdAmt Ccy="EUR">20.2</InstdAmt>
</Amt>
<CdtrAgt>
<FinInstnId>
<BIC>ABNANL2A</BIC>
</FinInstnId>
</CdtrAgt>
<Cdtr>
<Nm>Naam creditor</Nm>
<PstlAdr>
<Ctry>NL</Ctry>
<AdrLine>Straat creditor 1</AdrLine>
<AdrLine>9999 XX Plaats creditor</AdrLine>
</PstlAdr>
</Cdtr>
<CdtrAcct>
<Id>
<IBAN>NL90ABNA0111111111</IBAN>
</Id>
</CdtrAcct>
<UltmtCdtr>
<Id>
<PrvtId>
<DtAndPlcOfBirth>
<BirthDt>1969-07-03</BirthDt>
<CityOfBirth>PLAATS</CityOfBirth>
<CtryOfBirth>NL</CtryOfBirth>
</DtAndPlcOfBirth>
</PrvtId>
</Id>
</UltmtCdtr>
<Purp>
<Cd>CHAR</Cd>
</Purp>
<RmtInf>
<Strd>
<CdtrRefInf>
<Tp>
<CdOrPrtry>
<Cd>SCOR</Cd>
</CdOrPrtry>
<Issr>CUR</Issr>
</Tp>
<Ref>1234567</Ref>
</CdtrRefInf>
</Strd>
</RmtInf>
</CdtTrfTxInf>
</PmtInf>
</CstmrCdtTrfInitn>
</Document>

View File

@ -254,6 +254,8 @@ if ($result) {
} else {
$tabpay[$obj->rowid]["lib"] = dol_trunc($obj->label, 60);
}
// Load of url links to the line into llx_bank
$links = $object->get_url($obj->rowid); // Get an array('url'=>, 'url_id'=>, 'label'=>, 'type'=> 'fk_bank'=> )
//var_dump($i);
@ -319,6 +321,7 @@ if ($result) {
$chargestatic->ref = $links[$key]['url_id'];
$tabpay[$obj->rowid]["lib"] .= ' '.$chargestatic->getNomUrl(2);
$reg = array();
if (preg_match('/^\((.*)\)$/i', $links[$key]['label'], $reg)) {
if ($reg[1] == 'socialcontribution')
$reg[1] = 'SocialContribution';
@ -330,11 +333,13 @@ if ($result) {
$tabpay[$obj->rowid]["soclib"] = $chargestatic->getNomUrl(1, 30);
$tabpay[$obj->rowid]["paymentscid"] = $chargestatic->id;
// Retreive the accounting code of the social contribution of the payment from link of payment.
// Note: We have the social contribution id, it can be faster to get accounting code from social contribution id.
$sqlmid = 'SELECT cchgsoc.accountancy_code';
$sqlmid .= " FROM ".MAIN_DB_PREFIX."c_chargesociales cchgsoc ";
$sqlmid .= " FROM ".MAIN_DB_PREFIX."c_chargesociales cchgsoc";
$sqlmid .= " INNER JOIN ".MAIN_DB_PREFIX."chargesociales as chgsoc ON chgsoc.fk_type=cchgsoc.id";
$sqlmid .= " INNER JOIN ".MAIN_DB_PREFIX."paiementcharge as paycharg ON paycharg.fk_charge=chgsoc.rowid";
$sqlmid .= " INNER JOIN ".MAIN_DB_PREFIX."bank_url as bkurl ON bkurl.url_id=paycharg.rowid";
$sqlmid .= " INNER JOIN ".MAIN_DB_PREFIX."bank_url as bkurl ON bkurl.url_id=paycharg.rowid AND bkurl.type = 'payment_sc'";
$sqlmid .= " WHERE bkurl.fk_bank=".$obj->rowid;
dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=".$sqlmid, LOG_DEBUG);

View File

@ -263,7 +263,7 @@ if ($action == 'writebookkeeping') {
$bookkeeping->montant = $mt;
$bookkeeping->sens = ($mt < 0) ? 'C' : 'D';
$bookkeeping->debit = ($mt > 0) ? $mt : 0;
$bookkeeping->credit = ($mt <= 0) ? $mt : 0;
$bookkeeping->credit = ($mt <= 0) ? -$mt : 0;
$bookkeeping->code_journal = $journal;
$bookkeeping->journal_label = $journal_label;
$bookkeeping->fk_user_author = $user->id;
@ -321,7 +321,7 @@ if ($action == 'writebookkeeping') {
$bookkeeping->montant = $mt;
$bookkeeping->sens = ($mt < 0) ? 'C' : 'D';
$bookkeeping->debit = ($mt > 0) ? $mt : 0;
$bookkeeping->credit = ($mt <= 0) ? $mt : 0;
$bookkeeping->credit = ($mt <= 0) ? -$mt : 0;
$bookkeeping->code_journal = $journal;
$bookkeeping->journal_label = $journal_label;
$bookkeeping->fk_user_author = $user->id;
@ -610,7 +610,7 @@ if (empty($action) || $action == 'view') {
} else print $accountoshow;
print '</td>';
print "<td>".$userstatic->getNomUrl(0, 'user', 16).' - '.$langs->trans("SubledgerAccount")."</td>";
print '<td class="right nowraponall">'.($mt < 0 ? -price(-$mt) : '')."</td>";
print '<td class="right nowraponall">'.($mt < 0 ? price(-$mt) : '')."</td>";
print '<td class="right nowraponall">'.($mt >= 0 ? price($mt) : '')."</td>";
print "</tr>";
}

View File

@ -401,8 +401,8 @@ if ($result) {
// Ref product
print '<td class="tdoverflowmax100">';
if ($product_static->id > 0) print $product_static->getNomUrl(1);
if ($product_static->id > 0 && $objp->product_label) print '<br>';
if ($productstatic->id > 0) print $productstatic->getNomUrl(1);
if ($productstatic->id > 0 && $objp->product_label) print '<br>';
if ($objp->product_label) print '<span class="opacitymedium">'.$objp->product_label.'</span>';
print '</td>';

View File

@ -285,6 +285,7 @@ if ($search_gender != '' && $search_gender != '-1') $sql .= " AND d.gender = '".
if ($search_login) $sql .= natural_search("d.login", $search_login);
if ($search_company) $sql .= natural_search("s.nom", $search_company);
if ($search_email) $sql .= natural_search("d.email", $search_email);
if ($search_address) $sql .= natural_search("d.address", $search_address);
if ($search_town) $sql .= natural_search("d.town", $search_town);
if ($search_zip) $sql .= natural_search("d.zip", $search_zip);
if ($search_state) $sql .= natural_search("state.nom", $search_state);

View File

@ -0,0 +1,113 @@
<?php
/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2012 Regis Houssin <regis.houssin@inodbox.com>
* 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/admin/bom_extrafields.php
* \ingroup bom
* \brief Page to setup extra fields of BOM
*/
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/bom/lib/bom.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
// Load translation files required by the page
$langs->loadLangs(array('mrp', 'admin'));
$extrafields = new ExtraFields($db);
$form = new Form($db);
// List of supported format
$tmptype2label = ExtraFields::$type2label;
$type2label = array('');
foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val);
$action = GETPOST('action', 'alpha');
$attrname = GETPOST('attrname', 'alpha');
$elementtype = 'bom_bom';
if (!$user->admin) accessforbidden();
/*
* Actions
*/
require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php';
/*
* View
*/
llxHeader('', $langs->trans("BOMsSetup"), $help_url);
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans("BOMsSetup"), $linkback, 'title_setup');
$head = bomAdminPrepareHead();
dol_fiche_head($head, 'bom_extrafields', $langs->trans("ExtraFields"), -1, 'account');
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php';
dol_fiche_end();
// Buttons
if ($action != 'create' && $action != 'edit')
{
print '<div class="tabsAction">';
print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>";
print "</div>";
}
/*
* Creation of an optional field
*/
if ($action == 'create')
{
print '<br><div id="newattrib"></div>';
print load_fiche_titre($langs->trans('NewAttribute'));
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php';
}
/*
* Edition of an optional field
*/
if ($action == 'edit' && !empty($attrname))
{
print "<br>";
print load_fiche_titre($langs->trans("FieldEdition", $attrname));
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php';
}
// End of page
llxFooter();
$db->close();

View File

@ -314,7 +314,7 @@ $boxactivated = InfoBox::listBoxes($db, 'activated', -1, null);
print "<br>\n";
print "\n\n".'<!-- Boxes Available -->'."\n";
print load_fiche_titre($langs->trans("BoxesAvailable"));
print load_fiche_titre($langs->trans("BoxesAvailable"), '', '');
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n";
print '<input type="hidden" name="token" value="'.newToken().'">'."\n";
@ -377,7 +377,7 @@ print "\n".'<!-- End Boxes Available -->'."\n";
//var_dump($boxactivated);
print "<br>\n\n";
print load_fiche_titre($langs->trans("BoxesActivated"));
print load_fiche_titre($langs->trans("BoxesActivated"), '', '');
print '<div class="div-table-responsive-no-min">';
print '<table class="tagtable liste">'."\n";
@ -436,7 +436,7 @@ print '<br>';
// Other parameters
print "\n\n".'<!-- Other Const -->'."\n";
print load_fiche_titre($langs->trans("Other"));
print load_fiche_titre($langs->trans("Other"), '', '');
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="addconst">';

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005-2011 Laurent Destailleur <eldy@users.sourceforge.org>
* Copyright (C) 2005-2020 Laurent Destailleur <eldy@users.sourceforge.org>
* Copyright (C) 2011-2013 Juanjo Menent <jmenent@2byte.es>
*
* This program is free software; you can redistribute it and/or modify
@ -33,6 +33,10 @@ if (!$user->admin) accessforbidden();
$action = GETPOST('action', 'aZ09');
if (! in_array('clicktodial', $conf->modules)) {
accessforbidden($langs->trans("WarningModuleNotActive", $langs->transnoentitiesnoconv("Module58Name")));
}
/*
* Actions
@ -56,6 +60,8 @@ if ($action == 'setvalue' && $user->admin)
* View
*/
$form = new Form($db);
$user->fetch_clicktodial();
$wikihelp = 'EN:Module_ClickToDial_En|FR:Module_ClickToDial|ES:Módulo_ClickTodial_Es';
@ -71,6 +77,7 @@ print '<form method="post" action="clicktodial.php">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="setvalue">';
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Name").'</td>';
@ -103,6 +110,7 @@ print $langs->trans("Example").':<br>http://myphoneserver/mypage?login=__LOGIN__
print '</td></tr>';
print '</table>';
print '</div>';
print '<div class="center"><br><input type="submit" class="button" value="'.$langs->trans("Modify").'"></div>';

View File

@ -92,7 +92,7 @@ print load_fiche_titre($langs->trans("SendingsSetup"), $linkback, 'title_setup')
print '<br>';
$head = expedition_admin_prepare_head();
dol_fiche_head($head, 'general', $langs->trans("Sendings"), -1, 'sending');
dol_fiche_head($head, 'general', $langs->trans("Sendings"), -1, 'shipment');
// Miscellaneous parameters

View File

@ -209,7 +209,7 @@ $sql .= $hookmanager->resPrint;
/* If a group by is required
$sql.= " GROUP BY "
foreach($object->fields as $key => $val)
foreach ($object->fields as $key => $val)
{
$sql.='t.'.$key.', ';
}

View File

@ -102,7 +102,7 @@ print '<input type="hidden" name="action" value="save">';
$head = security_prepare_head();
dol_fiche_head($head, 'audit', $langs->trans("Security"), -1);
dol_fiche_head($head, 'audit', '', -1);
print '<table class="noborder" width="100%">';
print "<tr class=\"liste_titre\">";

View File

@ -184,7 +184,7 @@ print load_fiche_titre($langs->trans("SendingsSetup"), $linkback, 'title_setup')
print '<br>';
$head = expedition_admin_prepare_head();
dol_fiche_head($head, 'shipment', $langs->trans("Sendings"), -1, 'sending');
dol_fiche_head($head, 'shipment', $langs->trans("Sendings"), -1, 'shipment');
// Shipment numbering model

View File

@ -76,7 +76,7 @@ print "<br>\n";
$head = expedition_admin_prepare_head();
dol_fiche_head($head, 'attributes_shipment', $langs->trans("Sendings"), -1, 'sending');
dol_fiche_head($head, 'attributes_shipment', $langs->trans("Sendings"), -1, 'shipment');
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php';

View File

@ -77,7 +77,7 @@ print "<br>\n";
$head = expedition_admin_prepare_head();
dol_fiche_head($head, 'attributeslines_shipment', $langs->trans("Sendings"), -1, 'sending');
dol_fiche_head($head, 'attributeslines_shipment', $langs->trans("Sendings"), -1, 'shipment');
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php';

View File

@ -1,5 +1,5 @@
<?php
/* Copyright (C) 2007-2012 Laurent Destailleur <eldy@users.sourceforge.net>
/* Copyright (C) 2007-2020 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2009-2018 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
*
@ -34,11 +34,21 @@ if (!$user->admin) accessforbidden();
$action = GETPOST('action', 'alpha');
$currencycode = GETPOST('currencycode', 'alpha');
if (!empty($conf->multicurrency->enabled) && !empty($conf->global->MULTICURRENCY_USE_LIMIT_BY_CURRENCY)) {
// When MULTICURRENCY_USE_LIMIT_BY_CURRENCY is on, we use always a defined currency code instead of '' even for default.
$currencycode = (!empty($currencycode) ? $currencycode : $conf->currency);
}
$mainmaxdecimalsunit = 'MAIN_MAX_DECIMALS_UNIT'.(!empty($currencycode) ? '_'.$currencycode : '');
$mainmaxdecimalstot = 'MAIN_MAX_DECIMALS_TOT'.(!empty($currencycode) ? '_'.$currencycode : '');
$mainmaxdecimalsshown = 'MAIN_MAX_DECIMALS_SHOWN'.(!empty($currencycode) ? '_'.$currencycode : '');
$mainroundingruletot = 'MAIN_ROUNDING_RULE_TOT'.(!empty($currencycode) ? '_'.$currencycode : '');
$valmainmaxdecimalsunit = GETPOST($mainmaxdecimalsunit, 'int');
$valmainmaxdecimalstot = GETPOST($mainmaxdecimalstot, 'int');
$valmainmaxdecimalsshown = GETPOST($mainmaxdecimalsshown, 'int');
$valmainroundingruletot = price2num(GETPOST($mainroundingruletot, 'alpha'));
if ($action == 'update')
{
$error = 0;
@ -60,9 +70,9 @@ if ($action == 'update')
setEventMessages($langs->trans("ErrorNegativeValueNotAllowed"), null, 'errors');
}
if ($_POST[$mainroundingruletot])
if ($valmainroundingruletot)
{
if ($_POST[$mainroundingruletot] * pow(10, $_POST[$mainmaxdecimalstot]) < 1)
if ($valmainroundingruletot * pow(10, $valmainmaxdecimalstot) < 1)
{
$langs->load("errors");
$error++;
@ -72,11 +82,11 @@ if ($action == 'update')
if (!$error)
{
dolibarr_set_const($db, $mainmaxdecimalsunit, $_POST[$mainmaxdecimalsunit], 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, $mainmaxdecimalstot, $_POST[$mainmaxdecimalstot], 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, $mainmaxdecimalsshown, $_POST[$mainmaxdecimalsshown], 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, $mainmaxdecimalsunit, $valmainmaxdecimalsunit, 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, $mainmaxdecimalstot, $valmainmaxdecimalstot, 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, $mainmaxdecimalsshown, $valmainmaxdecimalsshown, 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, $mainroundingruletot, $_POST[$mainroundingruletot], 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, $mainroundingruletot, $valmainroundingruletot, 'chaine', 0, '', $conf->entity);
header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup".(!empty($currencycode) ? '&currencycode='.$currencycode : ''));
exit;
@ -94,7 +104,6 @@ llxHeader();
print load_fiche_titre($langs->trans("LimitsSetup"), '', 'title_setup');
$currencycode = (!empty($currencycode) ? $currencycode : $conf->currency);
$aCurrencies = array($conf->currency); // Default currency always first position
if (!empty($conf->multicurrency->enabled) && !empty($conf->global->MULTICURRENCY_USE_LIMIT_BY_CURRENCY))
@ -232,9 +241,9 @@ if (empty($mysoc->country_code))
// Add vat rates examples specific to country
$vat_rates = array();
$sql = "SELECT taux as vat_rate";
$sql = "SELECT taux as vat_rate, t.code as vat_code, t.localtax1 as localtax_rate1, t.localtax2 as localtax_rate2";
$sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c";
$sql .= " WHERE t.active=1 AND t.fk_pays = c.rowid AND c.code='".$mysoc->country_code."' AND t.taux <> 0";
$sql .= " WHERE t.active=1 AND t.fk_pays = c.rowid AND c.code='".$mysoc->country_code."' AND (t.taux <> 0 OR t.localtax1 <>0 OR t.localtax2 <>0)";
$sql .= " ORDER BY t.taux ASC";
$resql = $db->query($sql);
if ($resql)
@ -245,23 +254,31 @@ if (empty($mysoc->country_code))
for ($i = 0; $i < $num; $i++)
{
$obj = $db->fetch_object($resql);
$vat_rates[$i] = $obj->vat_rate;
$vat_rates[] = array('vat_rate'=>$obj->vat_rate, 'code'=>$obj->vat_code, 'localtax_rate1'=>$obj->localtax_rate1, 'locltax_rate2'=>$obj->localtax_rate2);
}
}
} else dol_print_error($db);
if (count($vat_rates))
{
foreach ($vat_rates as $vat)
foreach ($vat_rates as $vatarray)
{
$vat = $vatarray['vat_rate'];
for ($qty = 1; $qty <= 2; $qty++)
{
$vattxt = $vat.($vatarray['code'] ? ' ('.$vatarray['code'].')' : '');
$localtax_array = getLocalTaxesFromRate($vattxt, 0, $mysoc, $mysoc);
$s = 10 / 3;
$tmparray = calcul_price_total(1, $qty * price2num($s, 'MU'), 0, $vat, 0, 0, 0, 'HT', 0, 0, $mysoc);
$tmparray = calcul_price_total($qty, price2num($s, 'MU'), 0, $vat, -1, -1, 0, 'HT', 0, 0, $mysoc, $localtax_array);
print '<span class="opacitymedium">'.$langs->trans("UnitPriceOfProduct").":</span> ".price2num($s, 'MU');
print " x ".$langs->trans("Quantity").": ".$qty;
print " - ".$langs->trans("VAT").": ".$vat.'%';
print ' &nbsp; -> &nbsp; <span class="opacitymedium">'.$langs->trans("TotalPriceAfterRounding").":</span> ".$tmparray[0].' / '.$tmparray[1].' / '.$tmparray[2]."<br>\n";
print ($vatarray['code'] ? ' ('.$vatarray['code'].')' : '');
print ' &nbsp; -> &nbsp; <span class="opacitymedium">'.$langs->trans("TotalPriceAfterRounding").":</span> ";
print $tmparray[0].' / '.$tmparray[1].($tmparray[9] ? '+'.$tmparray[9] : '').($tmparray[10] ? '+'.$tmparray[10] : '').' / '.$tmparray[2];
print "<br>\n";
}
}
} else {
@ -269,69 +286,22 @@ if (empty($mysoc->country_code))
// This example must be kept for test purpose with current value because value used (2/7, 10/3, and vat 0, 10)
// were calculated to show all possible cases of rounding. If we change this, examples becomes useless or show the same rounding rule.
$localtax_array = array();
$s = 10 / 3; $qty = 1; $vat = 10;
$tmparray = calcul_price_total(1, $qty * price2num($s, 'MU'), 0, $vat, 0, 0, 0, 'HT', 0, 0, $mysoc);
$tmparray = calcul_price_total($qty, price2num($s, 'MU'), 0, $vat, -1, -1, 0, 'HT', 0, 0, $mysoc, $localtax_array);
print '<span class="opacitymedium">'.$langs->trans("UnitPriceOfProduct").":</span> ".price2num($s, 'MU');
print " x ".$langs->trans("Quantity").": ".$qty;
print " - ".$langs->trans("VAT").": ".$vat.'%';
print ' &nbsp; -> &nbsp; <span class="opacitymedium">'.$langs->trans("TotalPriceAfterRounding").": ".$tmparray[0].' / '.$tmparray[1].' / '.$tmparray[2]."<br>\n";
$s = 10 / 3; $qty = 2; $vat = 10;
$tmparray = calcul_price_total(1, $qty * price2num($s, 'MU'), 0, $vat, 0, 0, 0, 'HT', 0, 0, $mysoc);
$tmparray = calcul_price_total($qty, price2num($s, 'MU'), 0, $vat, -1, -1, 0, 'HT', 0, 0, $mysoc, $localtax_array);
print '<span class="opacitymedium">'.$langs->trans("UnitPriceOfProduct").":</span> ".price2num($s, 'MU');
print " x ".$langs->trans("Quantity").": ".$qty;
print " - ".$langs->trans("VAT").": ".$vat.'%';
print ' &nbsp; -> &nbsp; <span class="opacitymedium">'.$langs->trans("TotalPriceAfterRounding").":</span> ".$tmparray[0].' / '.$tmparray[1].' / '.$tmparray[2]."<br>\n";
}
// Important: can debug rounding, to simulate the rounded total
/*
print '<br><b>'.$langs->trans("VATRoundedByLine").' ('.$langs->trans("DolibarrDefault").')</b><br>';
foreach($vat_rates as $vat)
{
for ($qty=1; $qty<=2; $qty++)
{
$s1=10/3;
$s2=2/7;
// Round by line
$tmparray1=calcul_price_total(1,$qty*price2num($s1,'MU'),0,$vat,0,0,0,'HT',0, 0,$mysoc);
$tmparray2=calcul_price_total(1,$qty*price2num($s2,'MU'),0,$vat,0,0,0,'HT',0, 0,$mysoc);
$total_ht = $tmparray1[0] + $tmparray2[0];
$total_tva = $tmparray1[1] + $tmparray2[1];
$total_ttc = $tmparray1[2] + $tmparray2[2];
print $langs->trans("UnitPriceOfProduct").": ".(price2num($s1,'MU') + price2num($s2,'MU'));
print " x ".$langs->trans("Quantity").": ".$qty;
print " - ".$langs->trans("VAT").": ".$vat.'%';
print " &nbsp; -> &nbsp; ".$langs->trans("TotalPriceAfterRounding").": ".$total_ht.' / '.$total_tva.' / '.$total_ttc."<br>\n";
}
}
print '<br><b>'.$langs->trans("VATRoundedOnTotal").'</b><br>';
foreach($vat_rates as $vat)
{
for ($qty=1; $qty<=2; $qty++)
{
$s1=10/3;
$s2=2/7;
// Global round
$subtotal_ht = (($qty*price2num($s1,'MU')) + ($qty*price2num($s2,'MU')));
$tmparray3=calcul_price_total(1,$subtotal_ht,0,$vat,0,0,0,'HT',0, 0,$mysoc);
$total_ht = $tmparray3[0];
$total_tva = $tmparray3[1];
$total_ttc = $tmparray3[2];
print $langs->trans("UnitPriceOfProduct").": ".price2num($s1+$s2,'MU');
print " x ".$langs->trans("Quantity").": ".$qty;
print " - ".$langs->trans("VAT").": ".$vat.'%';
print " &nbsp; -> &nbsp; ".$langs->trans("TotalPriceAfterRounding").": ".$total_ht.' / '.$total_tva.' / '.$total_ttc."<br>\n";
}
}
*/
}
// End of page

View File

@ -179,7 +179,7 @@ print load_fiche_titre($langs->trans("SendingsSetup"), $linkback, 'title_setup')
print '<br>';
$head = expedition_admin_prepare_head();
dol_fiche_head($head, 'receivings', $langs->trans("Receivings"), -1, 'sending');
dol_fiche_head($head, 'receivings', $langs->trans("Receivings"), -1, 'shipment');
// Delivery numbering model

View File

@ -76,7 +76,7 @@ print "<br>\n";
$head = expedition_admin_prepare_head();
dol_fiche_head($head, 'attributes_receivings', $langs->trans("Receivings"), -1, 'sending');
dol_fiche_head($head, 'attributes_receivings', $langs->trans("Receivings"), -1, 'shipment');
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php';

View File

@ -77,7 +77,7 @@ print "<br>\n";
$head = expedition_admin_prepare_head();
dol_fiche_head($head, 'attributeslines_receivings', $langs->trans("Receivings"), -1, 'sending');
dol_fiche_head($head, 'attributeslines_receivings', $langs->trans("Receivings"), -1, 'shipment');
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php';

View File

@ -151,7 +151,7 @@ print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="update">';
dol_fiche_head($head, 'handler', $langs->trans("Menus"), -1);
dol_fiche_head($head, 'handler', '', -1);
print '<span class="opacitymedium">'.$langs->trans("MenusDesc")."</span><br>\n";
print "<br>\n";

View File

@ -229,7 +229,7 @@ $head[$h][1] = $langs->trans("Miscellaneous");
$head[$h][2] = 'misc';
$h++;
dol_fiche_head($head, 'editor', $langs->trans("Menus"), -1);
dol_fiche_head($head, 'editor', '', -1);
print '<span class="opacitymedium">'.$langs->trans("MenusEditorDesc")."</span><br>\n";
print "<br>\n";

View File

@ -75,7 +75,7 @@ $head[$h][1] = $langs->trans("Miscellaneous");
$head[$h][2] = 'misc';
$h++;
dol_fiche_head($head, 'misc', $langs->trans("Menus"), -1);
dol_fiche_head($head, 'misc', '', -1);
// Other Options

View File

@ -341,7 +341,7 @@ if ($mode == 'feature')
$text .= '<br><br>';
$text .= '<br><strong>'.$langs->trans("AddDataTables").':</strong> ';
$sqlfiles = dol_dir_list(dol_buildpath($moduledir.'/sql/'), 'files', 0, 'llx.*\.sql', array('\.key\.sql'));
$sqlfiles = dol_dir_list(dol_buildpath($moduledir.'/sql/'), 'files', 0, 'llx.*\.sql', array('\.key\.sql', '\.sql\.back'));
if (count($sqlfiles) > 0)
{
$text .= $langs->trans("Yes").' (';

View File

@ -460,8 +460,9 @@ asort($orders);
//var_dump($modules);
$nbofactivatedmodules = count($conf->modules);
$moreinfo = $langs->trans("TotalNumberOfActivatedModules", ($nbofactivatedmodules - 1), count($modules));
if ($nbofactivatedmodules <= 1) $moreinfo .= ' '.img_warning($langs->trans("YouMustEnableOneModule"));
$moreinfo = $langs->trans("TitleNumberOfActivatedModules");
$moreinfo2 = ($nbofactivatedmodules - 1)." / ".count($modules);
if ($nbofactivatedmodules <= 1) $moreinfo2 .= ' '.img_warning($langs->trans("YouMustEnableOneModule"));
print load_fiche_titre($langs->trans("ModulesSetup"), '', 'title_setup');
@ -496,6 +497,14 @@ if ($mode == 'common' || $mode == 'commonkanban')
dol_fiche_head($head, $newmode, '', -1);
$moreforfilter = '<div class="valignmiddle">';
$moreforfilter .= '<div class="floatright right pagination"><ul><li>';
$moreforfilter .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=commonkanban'.$param, '', 1, array('morecss'=>'reposition'.($mode == 'common' ? '' : ' btnTitleSelected')));
$moreforfilter .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-list-alt imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.$param, '', 1, array('morecss'=>'reposition'.($mode == 'commonkanban' ? '' : ' btnTitleSelected')));
$moreforfilter .= '</li></ul></div>';
$moreforfilter .= '<div class="floatright center marginrightonly hideonsmartphone" style="padding-top: 3px"><span class="">'.$moreinfo.'</span><br><b class="largenumber">'.$moreinfo2.'</b></div>';
$moreforfilter .= '<div class="colorbacktimesheet float valignmiddle">';
$moreforfilter .= '<div class="divsearchfield">';
$moreforfilter .= $langs->trans('Keyword').': <input type="text" id="search_keyword" name="search_keyword" class="maxwidth100" value="'.dol_escape_htmltag($search_keyword).'">';
@ -524,13 +533,6 @@ if ($mode == 'common' || $mode == 'commonkanban')
$moreforfilter .= '</div>';
$moreforfilter .= '</div>';
$moreforfilter .= '<div class="floatright right">';
$moreforfilter .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list paddingleft imgforviewmode', $_SERVER["PHP_SELF"].'?mode=commonkanban'.$param, '', 1, array('morecss'=>'reposition'.($mode == 'common' ? '' : ' btnTitleSelected')));
$moreforfilter .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-list-alt paddingleft imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.$param, '', 1, array('morecss'=>'reposition'.($mode == 'commonkanban' ? '' : ' btnTitleSelected')));
$moreforfilter .= '</div>';
$moreforfilter .= '<div class="floatright right margintoponly marginrightonly" style="padding-top: 3px">'.$moreinfo.'</div>';
$moreforfilter .= '</div>';
if (!empty($moreforfilter))

View File

@ -0,0 +1,113 @@
<?php
/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2012 Regis Houssin <regis.houssin@inodbox.com>
* 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/admin/mrp_extrafields.php
* \ingroup mrp
* \brief Page to setup extra fields of MOs
*/
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/mrp/lib/mrp.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
// Load translation files required by the page
$langs->loadLangs(array('mrp', 'admin'));
$extrafields = new ExtraFields($db);
$form = new Form($db);
// List of supported format
$tmptype2label = ExtraFields::$type2label;
$type2label = array('');
foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val);
$action = GETPOST('action', 'alpha');
$attrname = GETPOST('attrname', 'alpha');
$elementtype = 'mrp_mo';
if (!$user->admin) accessforbidden();
/*
* Actions
*/
require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php';
/*
* View
*/
llxHeader('', $langs->trans("MrpSetupPage"), $help_url);
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans("MrpSetupPage"), $linkback, 'title_setup');
$head = mrpAdminPrepareHead();
dol_fiche_head($head, 'mrp_extrafields', $langs->trans("ExtraFields"), -1, 'account');
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php';
dol_fiche_end();
// Buttons
if ($action != 'create' && $action != 'edit')
{
print '<div class="tabsAction">';
print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>";
print "</div>";
}
/*
* Creation of an optional field
*/
if ($action == 'create')
{
print '<br><div id="newattrib"></div>';
print load_fiche_titre($langs->trans('NewAttribute'));
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php';
}
/*
* Edition of an optional field
*/
if ($action == 'edit' && !empty($attrname))
{
print "<br>";
print load_fiche_titre($langs->trans("FieldEdition", $attrname));
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php';
}
// End of page
llxFooter();
$db->close();

View File

@ -72,6 +72,7 @@ if ($action == 'update')
dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_HIDE_DESC", $_POST["MAIN_GENERATE_DOCUMENTS_HIDE_DESC"], 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_HIDE_REF", $_POST["MAIN_GENERATE_DOCUMENTS_HIDE_REF"], 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_DOCUMENTS_LOGO_HEIGHT", GETPOST("MAIN_DOCUMENTS_LOGO_HEIGHT", 'int'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_INVERT_SENDER_RECIPIENT", $_POST["MAIN_INVERT_SENDER_RECIPIENT"], 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_PDF_USE_ISO_LOCATION", $_POST["MAIN_PDF_USE_ISO_LOCATION"], 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS", $_POST["MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS"], 'chaine', 0, '', $conf->entity);
@ -82,6 +83,7 @@ if ($action == 'update')
dolibarr_set_const($db, "PDF_USE_ALSO_LANGUAGE_CODE", GETPOST('PDF_USE_ALSO_LANGUAGE_CODE', 'alpha'), 'chaine', 0, '', $conf->entity);
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup");
exit;
@ -119,9 +121,41 @@ $arraydetailsforpdffoot = array(
3 => $langs->transnoentitiesnoconv('DisplayCompanyInfoAndManagers')
);
$s = $langs->trans("LibraryToBuildPDF")."<br>";
$i = 0;
$pdf = pdf_getInstance('A4');
if (class_exists('FPDF') && !class_exists('TCPDF'))
{
if ($i) $s .= ' + ';
$s .= 'FPDF';
$s .= ' ('.@constant('FPDF_PATH').')';
$i++;
}
if (class_exists('TCPDF'))
{
if ($i) $s .= ' + ';
$s .= 'TCPDF';
$s .= ' ('.@constant('TCPDF_PATH').')';
$i++;
}
if (class_exists('FPDI'))
{
if ($i) $s .= ' + ';
$s .= 'FPDI';
$s .= ' ('.@constant('FPDI_PATH').')';
$i++;
}
if (class_exists('TCPDI'))
{
if ($i) $s .= ' + ';
$s .= 'TCPDI';
$s .= ' ('.@constant('TCPDI_PATH').')';
$i++;
}
print load_fiche_titre($langs->trans("PDF"), '', 'title_setup');
print '<span class="opacitymedium">'.$langs->trans("PDFDesc")."</span><br>\n";
print '<span class="opacitymedium">'.$form->textwithpicto($langs->trans("PDFDesc"), $s)."</span><br>\n";
print "<br>\n";
$noCountryCode = (empty($mysoc->country_code) ? true : false);
@ -261,6 +295,12 @@ print '<div class="div-table-responsive-no-min">';
print '<table summary="more" class="noborder centpercent">';
print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td width="200px">'.$langs->trans("Value").'</td></tr>';
// Height of logo
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_DOCUMENTS_LOGO_HEIGHT").'</td><td>';
print '<input type="text" class="maxwidth50" name="MAIN_DOCUMENTS_LOGO_HEIGHT" value="'.(!empty($conf->global->MAIN_DOCUMENTS_LOGO_HEIGHT) ? $conf->global->MAIN_DOCUMENTS_LOGO_HEIGHT : 20).'">';
print '</td></tr>';
//Desc
print '<tr class="oddeven"><td>'.$langs->trans("HideDescOnPDF").'</td><td>';
@ -309,62 +349,6 @@ print '</td></tr>';
print '</table>';
print '</div>';
/*
* Library
*/
print '<br>';
print load_fiche_titre($langs->trans("Library"), '', '');
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">'."\n";
print '<tr class="liste_titre">'."\n";
print '<td>'.$langs->trans("Name").'</td>'."\n";
print '<td>'.$langs->trans("Value").'</td>'."\n";
print "</tr>\n";
print '<tr class="oddeven">'."\n";
print '<td>'.$langs->trans("LibraryToBuildPDF").'</td>'."\n";
print '<td>';
$i = 0;
$pdf = pdf_getInstance('A4');
if (class_exists('FPDF') && !class_exists('TCPDF'))
{
if ($i) print ' + ';
print 'FPDF';
print ' ('.@constant('FPDF_PATH').')';
$i++;
}
if (class_exists('TCPDF'))
{
if ($i) print ' + ';
print 'TCPDF';
print ' ('.@constant('TCPDF_PATH').')';
$i++;
}
if (class_exists('FPDI'))
{
if ($i) print ' + ';
print 'FPDI';
print ' ('.@constant('FPDI_PATH').')';
$i++;
}
if (class_exists('TCPDI'))
{
if ($i) print ' + ';
print 'TCPDI';
print ' ('.@constant('TCPDI_PATH').')';
$i++;
}
print '</td>'."\n";
print '</tr>'."\n";
print "</table>\n";
print '</div>';
print '<br><div class="center">';
print '<input class="button" type="submit" name="save" value="'.$langs->trans("Save").'">';
print '</div>';

View File

@ -116,7 +116,7 @@ $db->commit();
$head = security_prepare_head();
dol_fiche_head($head, 'default', $langs->trans("Security"), -1);
dol_fiche_head($head, 'default', '', -1);
// Show warning about external users

View File

@ -94,7 +94,7 @@ print '<input type="hidden" name="action" value="set_proxy">';
$head = security_prepare_head();
dol_fiche_head($head, 'proxy', $langs->trans("Security"), -1);
dol_fiche_head($head, 'proxy', '', -1);
if ($conf->use_javascript_ajax)

View File

@ -28,7 +28,7 @@ require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/resource.lib.php';
if (!empty($conf->resouce->enabled)) require_once DOL_DOCUMENT_ROOT.'/resource/class/html.formresource.class.php';
require_once DOL_DOCUMENT_ROOT.'/resource/class/html.formresource.class.php';
// Load translation files required by the page
$langs->loadLangs(array("admin", "resource"));

View File

@ -197,7 +197,7 @@ print "<br>\n";
$head = security_prepare_head();
dol_fiche_head($head, 'passwords', $langs->trans("Security"), -1);
dol_fiche_head($head, 'passwords', '', -1);
// Choix du gestionnaire du generateur de mot de passe

View File

@ -100,7 +100,7 @@ print '<input type="hidden" name="action" value="updateform">';
$head = security_prepare_head();
dol_fiche_head($head, 'file', $langs->trans("Security"), -1);
dol_fiche_head($head, 'file', '', -1);
// Upload options

View File

@ -93,7 +93,7 @@ print '<input type="hidden" name="action" value="updateform">';
$head = security_prepare_head();
dol_fiche_head($head, 'misc', $langs->trans("Security"), -1);
dol_fiche_head($head, 'misc', '', -1);
// Other Options

View File

@ -84,7 +84,6 @@ $configfileparameters = array(
'?dolibarr_js_CKEDITOR',
'?dolibarr_js_JQUERY',
'?dolibarr_js_JQUERY_UI',
'?dolibarr_js_JQUERY_FLOT',
'?dolibarr_font_DOL_DEFAULT_TTF',
'?dolibarr_font_DOL_DEFAULT_TTF_BOLD',
'separator',
@ -132,7 +131,6 @@ $configfilelib = array(
'dolibarr_js_CKEDITOR',
'dolibarr_js_JQUERY',
'dolibarr_js_JQUERY_UI',
'dolibarr_js_JQUERY_FLOT',
'dolibarr_font_DOL_DEFAULT_TTF',
'dolibarr_font_DOL_DEFAULT_TTF_BOLD',
'separator',

View File

@ -114,7 +114,7 @@ if (!$base)
print '<td>'.$obj->Engine.'</td>';
if (isset($obj->Engine) && $obj->Engine == "MyISAM")
{
print '<td><a class="reposition" href="database-tables.php?action=convert&amp;table='.$obj->Name.'">'.$langs->trans("Convert").' InnoDB</a></td>';
print '<td><a class="reposition" href="database-tables.php?action=convert&amp;table='.$obj->Name.'">'.$langs->trans("Convert").' InnoDb</a></td>';
} else {
print '<td>&nbsp;</td>';
}

View File

@ -317,7 +317,6 @@ $configfileparameters = array(
'?dolibarr_js_CKEDITOR' => 'dolibarr_js_CKEDITOR',
'?dolibarr_js_JQUERY' => 'dolibarr_js_JQUERY',
'?dolibarr_js_JQUERY_UI' => 'dolibarr_js_JQUERY_UI',
'?dolibarr_js_JQUERY_FLOT' => 'dolibarr_js_JQUERY_FLOT',
'?dolibarr_font_DOL_DEFAULT_TTF' => 'dolibarr_font_DOL_DEFAULT_TTF',
'?dolibarr_font_DOL_DEFAULT_TTF_BOLD' => 'dolibarr_font_DOL_DEFAULT_TTF_BOLD',
'separator4' => '',

View File

@ -237,7 +237,8 @@ if (in_array($type, array('mysql', 'mysqli'))) {
print '<input type="checkbox" name="sql_structure" value="structure" id="checkbox_sql_structure" checked />';
print '<label for="checkbox_sql_structure">'.$langs->trans('ExportStructure').'</label>';
print '</legend>';
print '<input type="checkbox" name="drop"'.(((!isset($_GET["drop"]) && !isset($_POST["drop"])) || GETPOST('drop')) ? ' checked' : '').' id="checkbox_dump_drop" />';
print '<input type="checkbox" name="drop"'.((! GETPOSTISSET("drop") || GETPOST('drop')) ? ' checked' : '').' id="checkbox_dump_drop" />';
print '<label for="checkbox_dump_drop">'.$langs->trans("AddDropTable").'</label>';
print '<br>';
print '</fieldset>';

View File

@ -40,7 +40,7 @@ $transkey = GETPOST('transkey', 'alphanohtml');
$transvalue = GETPOST('transvalue', 'none');
$mode = GETPOST('mode', 'aZ09') ?GETPOST('mode', 'aZ09') : 'overwrite';
$mode = GETPOST('mode', 'aZ09') ?GETPOST('mode', 'aZ09') : 'searchkey';
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha');
@ -496,7 +496,7 @@ if ($mode == 'searchkey')
if ($i > ($offset + $limit)) break;
print '<tr class="oddeven"><td>'.$langcode.'</td><td>'.$key.'</td><td>';
print dol_escape_htmltag($val);
print '</td><td class="right">';
print '</td><td class="right nowraponall">';
if (!empty($newlangfileonly->tab_translate[$key]))
{
if ($val != $newlangfileonly->tab_translate[$key])
@ -516,7 +516,7 @@ if ($mode == 'searchkey')
print ' ';
print '<a href="'.$_SERVER['PHP_SELF'].'?rowid='.$obj->rowid.'&entity='.$conf->entity.'&action=delete">'.img_delete().'</a>';
print '&nbsp;&nbsp;';
$htmltext = $langs->trans("OriginalValueWas", $newlangfileonly->tab_translate[$key]);
$htmltext = $langs->trans("OriginalValueWas", '<i>'.$newlangfileonly->tab_translate[$key].'</i>');
print $form->textwithpicto('', $htmltext, 1, 'info');
} elseif (!empty($conf->global->MAIN_ENABLE_OVERWRITE_TRANSLATION))
{
@ -530,7 +530,7 @@ if ($mode == 'searchkey')
//$transifexurl = 'https://www.transifex.com/dolibarr-association/dolibarr/translate/#'.$langcode.'/'.$transifexlangfile.'?key='.$key;
$transifexurl = 'https://www.transifex.com/dolibarr-association/dolibarr/translate/#'.$langcode.'/'.$transifexlangfile.'?q=key%3A'.$key;
print ' &nbsp; <a href="'.$transifexurl.'" target="transifex">'.img_picto('FixOnTransifex', 'globe').'</a>';
print ' &nbsp; <a href="'.$transifexurl.'" target="transifex">'.img_picto($langs->trans('FixOnTransifex'), 'globe').'</a>';
}
} else {
$htmltext = $langs->trans("TransKeyWithoutOriginalValue", $key);

View File

@ -251,7 +251,7 @@ class BOM extends CommonObject
if ($result > 0 && !empty($object->table_element_line)) $object->fetchLines();
// Get lines so they will be clone
//foreach($object->lines as $line)
//foreach ($object->lines as $line)
// $line->fetch_optionals();
// Reset some properties
@ -333,8 +333,10 @@ class BOM extends CommonObject
public function fetch($id, $ref = null)
{
$result = $this->fetchCommon($id, $ref);
if ($result > 0 && !empty($this->table_element_line)) $this->fetchLines();
$this->calculateCosts();
return $result;
}

View File

@ -41,6 +41,11 @@ function bomAdminPrepareHead()
$head[$h][2] = 'settings';
$h++;
$head[$h][0] = dol_buildpath("/admin/bom_extrafields.php", 1);
$head[$h][1] = $langs->trans("ExtraFields");
$head[$h][2] = 'bom_extrafields';
$h++;
/*$head[$h][0] = DOL_URL_ROOT."/bom/admin/about.php";
$head[$h][1] = $langs->trans("About");
$head[$h][2] = 'about';

View File

@ -58,7 +58,6 @@ if ($nolinesbefore) {
}
print '<td class="linecoldescription minwidth500imp">';
print '<div id="add"></div><span class="hideonsmartphone">'.$langs->trans('AddNewLine').'</span>';
// echo $langs->trans("FreeZone");
print '</td>';
print '<td class="linecolqty right">'.$langs->trans('Qty').'</td>';
if ($conf->global->PRODUCT_USE_UNITS)

View File

@ -69,7 +69,7 @@ print '<td class="linecoldisablestockchange right">'.$form->textwithpicto($langs
print '<td class="linecolefficiency right">'.$form->textwithpicto($langs->trans('ManufacturingEfficiency'), $langs->trans('ValueOfMeansLoss')).'</td>';
// Cost
print '<td class="linecolcost right">'.$langs->trans('CostPrice').'</td>';
print '<td class="linecolcost right">'.$form->textwithpicto($langs->trans("TotalCost"), $langs->trans("BOMTotalCost")).'</td>';
print '<td class="linecoledit"></td>'; // No width to allow autodim

View File

@ -113,7 +113,7 @@ if ($this->status == 0 && ($object_rights->write) && $action != 'selectlines') {
$coldisplay++;
if (($line->info_bits & 2) == 2 || !empty($disableedit)) {
} else {
print '<a class="editfielda reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$this->id.'&amp;action=editline&amp;lineid='.$line->id.'#line_'.$line->id.'">'.img_edit().'</a>';
print '<a class="editfielda reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$this->id.'&amp;action=editline&amp;lineid='.$line->id.'">'.img_edit().'</a>';
}
print '</td>';

View File

@ -6,8 +6,8 @@
* Copyright (C) 2010-2013 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2014 Cedric GROSS <c.gross@kreiz-it.fr>
* Copyright (C) 2015 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2018-2019 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2015 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2018-2019 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2019 Ferran Marcet <fmarcet@2byte.es>
*
* This program is free software; you can redistribute it and/or modify
@ -111,6 +111,7 @@ $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');
/*
* Actions
*/
@ -310,7 +311,7 @@ if (empty($reshook) && $action == 'add')
if (GETPOST("doneby") > 0) $object->userdoneid = GETPOST("doneby", "int");
}
$object->note_private = trim(GETPOST("note"));
$object->note_private = trim(GETPOST("note", "none"));
if (isset($_POST["contactid"])) $object->contact = $contact;
@ -451,7 +452,7 @@ if (empty($reshook) && $action == 'update')
$object->contact_id = key($object->socpeopleassigned);
}
$object->fk_project = GETPOST("projectid", 'int');
$object->note_private = GETPOST("note", "none");
$object->note_private = trim(GETPOST("note", "none"));
$object->fk_element = GETPOST("fk_element", "int");
$object->elementtype = GETPOST("elementtype", "alphanohtml");
@ -1028,14 +1029,13 @@ if ($action == 'create')
// Project
if (!empty($conf->projet->enabled))
{
// Projet associe
$langs->load("projects");
$projectid = GETPOST('projectid', 'int');
print '<tr><td class="titlefieldcreate">'.$langs->trans("Project").'</td><td id="project-input-container" >';
$numproject = $formproject->select_projects((!empty($societe->id) ? $societe->id : -1), $projectid, 'projectid', 0, 0, 1, 1);
$numproject = $formproject->select_projects((!empty($societe->id) ? $societe->id : -1), $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 0, 0, 'maxwidth500');
print ' <a href="'.DOL_URL_ROOT.'/projet/card.php?socid='.$societe->id.'&action=create"><span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans("AddProject").'"></span></a>';
$urloption = '?action=create&donotclearsession=1';
@ -1077,6 +1077,7 @@ if ($action == 'create')
print '<input type="hidden" name="origin" size="10" value="'.GETPOST('origin').'">';
}
$reg = array();
if (GETPOST("datep") && preg_match('/^([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])$/', GETPOST("datep"), $reg))
{
$object->datep = dol_mktime(0, 0, 0, $reg[2], $reg[3], $reg[1]);
@ -1090,7 +1091,7 @@ if ($action == 'create')
// Description
print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td>';
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor = new DolEditor('note', (GETPOST('note', 'none') ?GETPOST('note', 'none') : $object->note_private), '', 180, 'dolibarr_notes', 'In', true, true, $conf->fckeditor->enabled, ROWS_4, '90%');
$doleditor = new DolEditor('note', (GETPOST('note', 'none') ? GETPOST('note', 'none') : $object->note_private), '', 180, 'dolibarr_notes', 'In', true, true, $conf->fckeditor->enabled, ROWS_4, '90%');
$doleditor->Create();
print '</td></tr>';
@ -1541,7 +1542,7 @@ if ($id > 0)
$linkback = '';
// Link to other agenda views
$linkback .= img_picto($langs->trans("BackToList"), 'object_list-alt', 'class="hideonsmartphone pictoactionview"');
$linkback .= '<a href="'.DOL_URL_ROOT.'/comm/action/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
$linkback .= '<a href="'.DOL_URL_ROOT.'/comm/action/list.php?action=show_list&restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
$linkback .= '</li>';
$linkback .= '<li class="noborder litext">';
$linkback .= img_picto($langs->trans("ViewCal"), 'object_calendar', 'class="hideonsmartphone pictoactionview"');

View File

@ -1207,8 +1207,8 @@ class ActionComm extends CommonObject
$response->warning_delay = $conf->agenda->warning_delay / 60 / 60 / 24;
$response->label = $langs->trans("ActionsToDo");
$response->labelShort = $langs->trans("ActionsToDoShort");
$response->url = DOL_URL_ROOT.'/comm/action/list.php?actioncode=0&amp;status=todo&amp;mainmenu=agenda';
if ($user->rights->agenda->allactions->read) $response->url .= '&amp;filtert=-1';
$response->url = DOL_URL_ROOT.'/comm/action/list.php?action=show_list&actioncode=0&status=todo&mainmenu=agenda';
if ($user->rights->agenda->allactions->read) $response->url .= '&filtert=-1';
$response->img = img_object('', "action", 'class="inline-block valigntextmiddle"');
}
// This assignment in condition is not a bug. It allows walking the results.

View File

@ -123,7 +123,7 @@ if ($object->id > 0)
dol_fiche_head($head, 'documents', $langs->trans("Action"), -1, 'action');
$linkback = img_picto($langs->trans("BackToList"), 'object_list', 'class="hideonsmartphone pictoactionview"');
$linkback .= '<a href="'.DOL_URL_ROOT.'/comm/action/list.php">'.$langs->trans("BackToList").'</a>';
$linkback .= '<a href="'.DOL_URL_ROOT.'/comm/action/list.php?action=show_list">'.$langs->trans("BackToList").'</a>';
// Link to other agenda views
$out = '';

View File

@ -150,6 +150,7 @@ if (GETPOST("viewlist", 'alpha') || $action == 'show_list')
$param .= '&'.$key.'='.urlencode($val);
}
}
if (! preg_match('/action=/', $param)) $param .= ($param ? '&' : '').'action=show_list';
//print $param;
header("Location: ".DOL_URL_ROOT.'/comm/action/list.php?'.$param);
exit;
@ -329,9 +330,10 @@ if ($action == 'show_day')
//print dol_print_date($firstdaytoshow,'day');
//print dol_print_date($lastdaytoshow,'day');
$title = $langs->trans("DoneAndToDoActions");
/*$title = $langs->trans("DoneAndToDoActions");
if ($status == 'done') $title = $langs->trans("DoneActions");
if ($status == 'todo') $title = $langs->trans("ToDoActions");
*/
$param = '';
if ($actioncode || isset($_GET['search_actioncode']) || isset($_POST['search_actioncode'])) {
@ -340,7 +342,7 @@ if ($actioncode || isset($_GET['search_actioncode']) || isset($_POST['search_act
} else $param .= "&search_actioncode=".urlencode($actioncode);
}
if ($resourceid > 0) $param .= "&search_resourceid=".urlencode($resourceid);
if ($status || isset($_GET['status']) || isset($_POST['status'])) $param .= "&search_status=".urlencode($status);
if ($status || GETPOSTISSET('status')) $param .= "&search_status=".urlencode($status);
if ($filter) $param .= "&search_filter=".urlencode($filter);
if ($filtert) $param .= "&search_filtert=".urlencode($filtert);
if ($usergroup) $param .= "&search_usergroup=".urlencode($usergroup);
@ -358,7 +360,7 @@ if (empty($action) || $action == 'show_month')
$nav .= " <span id=\"month_name\">".dol_print_date(dol_mktime(0, 0, 0, $month, 1, $year), "%b %Y");
$nav .= " </span>\n";
$nav .= " &nbsp; <a href=\"?year=".$next_year."&amp;month=".$next_month.$param."\"><i class=\"fa fa-chevron-right\"></i></a>\n";
$nav .= " &nbsp; (<a href=\"?year=".$nowyear."&amp;month=".$nowmonth.$param."\">".$langs->trans("Today")."</a>)";
$nav .= " &nbsp; <a href=\"?year=".$nowyear."&amp;month=".$nowmonth.$param."\">".$langs->trans("Today")."</a> ";
$picto = 'calendar';
}
if ($action == 'show_week')
@ -367,7 +369,7 @@ if ($action == 'show_week')
$nav .= " <span id=\"month_name\">".dol_print_date(dol_mktime(0, 0, 0, $first_month, $first_day, $first_year), "%Y").", ".$langs->trans("Week")." ".$week;
$nav .= " </span>\n";
$nav .= " &nbsp; <a href=\"?year=".$next_year."&amp;month=".$next_month."&amp;day=".$next_day.$param."\"><i class=\"fa fa-chevron-right\" title=\"".dol_escape_htmltag($langs->trans("Next"))."\"></i></a>\n";
$nav .= " &nbsp; (<a href=\"?year=".$nowyear."&amp;month=".$nowmonth."&amp;day=".$nowday.$param."\">".$langs->trans("Today")."</a>)";
$nav .= " &nbsp; <a href=\"?year=".$nowyear."&amp;month=".$nowmonth."&amp;day=".$nowday.$param."\">".$langs->trans("Today")."</a> ";
$picto = 'calendarweek';
}
if ($action == 'show_day')
@ -376,12 +378,13 @@ if ($action == 'show_day')
$nav .= " <span id=\"month_name\">".dol_print_date(dol_mktime(0, 0, 0, $month, $day, $year), "daytextshort");
$nav .= " </span>\n";
$nav .= " &nbsp; <a href=\"?year=".$next_year."&amp;month=".$next_month."&amp;day=".$next_day.$param."\"><i class=\"fa fa-chevron-right\"></i></a>\n";
$nav .= " &nbsp; (<a href=\"?year=".$nowyear."&amp;month=".$nowmonth."&amp;day=".$nowday.$param."\">".$langs->trans("Today")."</a>)";
$nav .= " &nbsp; <a href=\"?year=".$nowyear."&amp;month=".$nowmonth."&amp;day=".$nowday.$param."\">".$langs->trans("Today")."</a> ";
$picto = 'calendarday';
}
$nav .= $form->selectDate($dateselect, 'dateselect', 0, 0, 1, '', 1, 0);
$nav .= ' <input type="submit" name="submitdateselect" class="button" value="'.$langs->trans("Refresh").'">';
//$nav .= ' <input type="submit" name="submitdateselect" class="button" value="'.$langs->trans("Refresh").'">';
$nav .= '<button type="submit" class="liste_titre button_search" name="button_search_x" value="x"><span class="fa fa-search"></span></button>';
// Must be after the nav definition
$param .= '&year='.$year.'&month='.$month.($day ? '&day='.$day : '');
@ -404,10 +407,55 @@ print '<form method="POST" id="searchFormList" class="listactionsfilter" action=
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.newToken().'">';
dol_fiche_head($head, $tabactive, $langs->trans('Agenda'), 0, 'action');
print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, $listofextcals, $actioncode, $usergroup, '', $resourceid);
dol_fiche_end();
//dol_fiche_head($head, $tabactive, $langs->trans('Agenda'), 0, 'action');
//print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, $listofextcals, $actioncode, $usergroup, '', $resourceid);
//dol_fiche_end();
$viewmode = '';
$viewmode .= '<a class="btnTitle reposition" href="'.DOL_URL_ROOT.'/comm/action/list.php?action=show_list&restore_lastsearch_values=1">';
//$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
$viewmode .= img_picto($langs->trans("List"), 'object_list-alt', 'class="pictoactionview block"');
//$viewmode .= '</span>';
$viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans("ViewList").'</span></a>';
$viewmode .= '<a class="btnTitle'.($action == 'show_month' ? ' btnTitleSelected' : '').' reposition" href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_month&year='.dol_print_date($object->datep, '%Y').'&month='.dol_print_date($object->datep, '%m').'&day='.dol_print_date($object->datep, '%d').'">';
//$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
$viewmode .= img_picto($langs->trans("ViewCal"), 'object_calendar', 'class="pictoactionview block"');
//$viewmode .= '</span>';
$viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans("ViewCal").'</span></a>';
$viewmode .= '<a class="btnTitle'.($action == 'show_week' ? ' btnTitleSelected' : '').' reposition" href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_week&year='.dol_print_date($object->datep, '%Y').'&month='.dol_print_date($object->datep, '%m').'&day='.dol_print_date($object->datep, '%d').'">';
//$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
$viewmode .= img_picto($langs->trans("ViewWeek"), 'object_calendarweek', 'class="pictoactionview block"');
//$viewmode .= '</span>';
$viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans("ViewWeek").'</span></a>';
$viewmode .= '<a class="btnTitle'.($action == 'show_day' ? ' btnTitleSelected' : '').' reposition" href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_day&year='.dol_print_date($object->datep, '%Y').'&month='.dol_print_date($object->datep, '%m').'&day='.dol_print_date($object->datep, '%d').'">';
//$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
$viewmode .= img_picto($langs->trans("ViewDay"), 'object_calendarday', 'class="pictoactionview block"');
//$viewmode .= '</span>';
$viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans("ViewDay").'</span></a>';
$viewmode .= '<a class="btnTitle reposition marginrightonly" href="'.DOL_URL_ROOT.'/comm/action/peruser.php?action=show_peruser&year='.dol_print_date($object->datep, '%Y').'&month='.dol_print_date($object->datep, '%m').'&day='.dol_print_date($object->datep, '%d').'">';
//$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
$viewmode .= img_picto($langs->trans("ViewPerUser"), 'object_calendarperuser', 'class="pictoactionview block"');
//$viewmode .= '</span>';
$viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans("ViewPerUser").'</span></a>';
$viewmode .= '<span class="marginrightonly"></span>';
$newcardbutton = '';
if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create)
{
$tmpforcreatebutton = dol_getdate(dol_now(), true);
$newparam .= '&month='.str_pad($month, 2, "0", STR_PAD_LEFT).'&year='.$tmpforcreatebutton['year'];
//$param='month='.$monthshown.'&year='.$year;
$hourminsec = '100000';
$newcardbutton .= dolGetButtonTitle($langs->trans("AddAction"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.sprintf("%04d%02d%02d", $tmpforcreatebutton['year'], $tmpforcreatebutton['mon'], $tmpforcreatebutton['mday']).$hourminsec.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($newparam ? '?'.$newparam : '')));
}
// Define the legend/list of calendard to show
$s = ''; $link = '';
@ -440,7 +488,7 @@ if (!empty($conf->use_javascript_ajax)) // If javascript on
$s .= '</script>'."\n";
// Local calendar
$s .= '<div class="nowrap inline-block minheight20"><input type="checkbox" id="check_mytasks" name="check_mytasks" checked disabled> '.$langs->trans("LocalAgenda").' &nbsp; </div>';
$s .= '<div class="nowrap inline-block minheight30"><input type="checkbox" id="check_mytasks" name="check_mytasks" checked disabled> '.$langs->trans("LocalAgenda").' &nbsp; </div>';
// External calendars
if (is_array($showextcals) && count($showextcals) > 0)
@ -487,9 +535,6 @@ if (!empty($conf->use_javascript_ajax)) // If javascript on
$link .= '</a>';
}
print load_fiche_titre($s, $link.' &nbsp; &nbsp; '.$nav, '', 0, 0, 'tablelistofcalendars');
// Load events from database into $eventarray
$eventarray = array();
@ -1109,6 +1154,11 @@ if (is_readable($color_file))
if (!is_array($theme_datacolor)) $theme_datacolor = array(array(120, 130, 150), array(200, 160, 180), array(190, 190, 220));
print_barre_liste($langs->trans("Agenda"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, -1, 'object_action', 0, $nav.'<span class="marginleftonly"></span>'.$newcardbutton, '', $limit, 1, 0, 1, $viewmode);
print $s;
if (empty($action) || $action == 'show_month') // View by month
{
$newparam = $param; // newparam is for birthday links
@ -1122,6 +1172,9 @@ if (empty($action) || $action == 'show_month') // View by month
$newparam = preg_replace('/showbirthday_=/i', 'showbirthday=', $newparam); // Restore correct parameter
$newparam .= '&viewcal=1';
print '<div class="liste_titre liste_titre_bydiv centpercent">';
print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid);
print '</div>';
print '<div class="div-table-responsive-no-min">';
print '<table width="100%" class="noborder nocellnopadd cal_pannel cal_month">';
@ -1200,6 +1253,10 @@ if (empty($action) || $action == 'show_month') // View by month
$newparam = preg_replace('/showbirthday_=/i', 'showbirthday=', $newparam); // Restore correct parameter
$newparam .= '&viewweek=1';
print '<div class="liste_titre liste_titre_bydiv centpercent"><div class="divsearchfield">';
print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid);
print '</div></div>';
print '<div class="div-table-responsive-no-min">';
print '<table width="100%" class="noborder nocellnopadd cal_pannel cal_month">';
print ' <tr class="liste_titre">';
@ -1256,7 +1313,11 @@ if (empty($action) || $action == 'show_month') // View by month
$timestamp = dol_mktime(12, 0, 0, $month, $day, $year);
$arraytimestamp = dol_getdate($timestamp);
//echo '<table class="tagtable centpercent noborder nocellnopadd cal_pannel cal_month">';
print '<div class="liste_titre liste_titre_bydiv centpercent"><div class="divsearchfield">';
print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid);
print '</div></div>';
print '<div class="div-table-responsive-no-min">';
echo '<table class="tagtable centpercent noborder nocellnopadd cal_pannel cal_month noborderbottom" style="margin-bottom: 5px !important;">';
echo ' <tr class="tagtr liste_titre">';
@ -1274,6 +1335,7 @@ if (empty($action) || $action == 'show_month') // View by month
*/
echo '</table>';
print '</div>';
/* WIP View per hour */
$useviewhour = 0;
@ -1301,9 +1363,8 @@ if (empty($action) || $action == 'show_month') // View by month
{
echo ' <div class="tagtr calendarviewcontainertr">'."\n";
echo ' <div class="tagtd width100 tdtop">'.dol_print_date($i * 3600, 'hour', 'gmt').'</div>';
echo ' <div class="tagtd '.$style.' tdtop">';
echo " </div>\n";
echo " </div>\n";
echo ' <div class="tagtd '.$style.' tdtop"></div>'."\n";
echo ' </div>'."\n";
$i++;
$j++;
}

View File

@ -152,6 +152,7 @@ if (is_array($extrafields->attributes[$object->table_element]['label']) && count
$object->fields = dol_sort_array($object->fields, 'position');
$arrayfields = dol_sort_array($arrayfields, 'position');
//var_dump($_POST);exit;
/*
* Actions
@ -301,7 +302,7 @@ if ($user->rights->agenda->allactions->delete)
{
$arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
}
if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array();
$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
$sql = "SELECT";
@ -428,7 +429,9 @@ if ($resql)
$arrayofselected = is_array($toselect) ? $toselect : array();
// Local calendar
$newtitle = '<div class="nowrap clear inline-block minheight20"><input type="checkbox" id="check_mytasks" name="check_mytasks" checked disabled> '.$langs->trans("LocalAgenda").' &nbsp; </div>';
$newtitle = '<div class="nowrap clear inline-block minheight30">';
$newtitle .= '<input type="checkbox" id="check_mytasks" name="check_mytasks" checked disabled> '.$langs->trans("LocalAgenda").' &nbsp; ';
$newtitle .= '</div>';
//$newtitle=$langs->trans($title);
$tabactive = 'cardlist';
@ -439,7 +442,6 @@ if ($resql)
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="list">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
@ -450,9 +452,9 @@ if ($resql)
if ($showbirthday) $nav .= '<input type="hidden" name="search_showbirthday" value="1">';
print $nav;
dol_fiche_head($head, $tabactive, $langs->trans('Agenda'), 0, 'action');
print_actions_filter($form, $canedit, $search_status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid);
dol_fiche_end();
//dol_fiche_head($head, $tabactive, $langs->trans('Agenda'), 0, 'action');
//print_actions_filter($form, $canedit, $search_status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid);
//dol_fiche_end();
// Add link to show birthdays
$link = '';
@ -484,6 +486,39 @@ if ($resql)
$s = $hookmanager->resPrint;
}
$viewmode = '';
$viewmode .= '<a class="btnTitle btnTitleSelected reposition" href="'.DOL_URL_ROOT.'/comm/action/list.php?action=show_list&restore_lastsearch_values=1">';
//$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
$viewmode .= img_picto($langs->trans("List"), 'object_list-alt', 'class="pictoactionview block"');
//$viewmode .= '</span>';
$viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans("ViewList").'</span></a>';
$viewmode .= '<a class="btnTitle reposition" href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_month&year='.dol_print_date($object->datep, '%Y').'&month='.dol_print_date($object->datep, '%m').'&day='.dol_print_date($object->datep, '%d').'">';
//$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
$viewmode .= img_picto($langs->trans("ViewCal"), 'object_calendar', 'class="pictoactionview block"');
//$viewmode .= '</span>';
$viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans("ViewCal").'</span></a>';
$viewmode .= '<a class="btnTitle reposition" href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_week&year='.dol_print_date($object->datep, '%Y').'&month='.dol_print_date($object->datep, '%m').'&day='.dol_print_date($object->datep, '%d').'">';
//$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
$viewmode .= img_picto($langs->trans("ViewWeek"), 'object_calendarweek', 'class="pictoactionview block"');
//$viewmode .= '</span>';
$viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans("ViewWeek").'</span></a>';
$viewmode .= '<a class="btnTitle reposition" href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_day&year='.dol_print_date($object->datep, '%Y').'&month='.dol_print_date($object->datep, '%m').'&day='.dol_print_date($object->datep, '%d').'">';
//$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
$viewmode .= img_picto($langs->trans("ViewDay"), 'object_calendarday', 'class="pictoactionview block"');
//$viewmode .= '</span>';
$viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans("ViewDay").'</span></a>';
$viewmode .= '<a class="btnTitle reposition marginrightonly" href="'.DOL_URL_ROOT.'/comm/action/peruser.php?action=show_peruser&year='.dol_print_date($object->datep, '%Y').'&month='.dol_print_date($object->datep, '%m').'&day='.dol_print_date($object->datep, '%d').'">';
//$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
$viewmode .= img_picto($langs->trans("ViewPerUser"), 'object_calendarperuser', 'class="pictoactionview block"');
//$viewmode .= '</span>';
$viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans("ViewPerUser").'</span></a>';
$viewmode .= '<span class="marginrightonly"></span>';
$newcardbutton = '';
if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create)
{
@ -495,8 +530,12 @@ if ($resql)
$hourminsec = '100000';
$newcardbutton .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.sprintf("%04d%02d%02d", $tmpforcreatebutton['year'], $tmpforcreatebutton['mon'], $tmpforcreatebutton['mday']).$hourminsec.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($newparam ? '?'.$newparam : '')));
}
$param .= '&action='.$action;
print_barre_liste($s, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, -1 * $nbtotalofrecords, '', 0, $nav.$newcardbutton, '', $limit, 0, 0, 1);
print_barre_liste($langs->trans("Agenda"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, -1 * $nbtotalofrecords, 'object_action', 0, $nav.$newcardbutton, '', $limit, 0, 0, 1, $viewmode);
print $s;
include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
@ -506,6 +545,11 @@ if ($resql)
$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
if ($massactionbutton) $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
$i = 0;
print '<div class="liste_titre liste_titre_bydiv centpercent">';
print_actions_filter($form, $canedit, $search_status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid);
print '</div>';
print '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";

View File

@ -700,7 +700,7 @@ jQuery(document).ready(function() {
else if (ids.indexOf(",") > -1) /* There is several events */
{
/* alert(\'several events\'); */
url = "'.DOL_URL_ROOT.'/comm/action/list.php?filtert="+userid+"&dateselectyear="+year+"&dateselectmonth="+month+"&dateselectday="+day;
url = "'.DOL_URL_ROOT.'/comm/action/list.php?action=show_list&filtert="+userid+"&dateselectyear="+year+"&dateselectmonth="+month+"&dateselectday="+day;
window.location.href = url;
}
else /* One event */

View File

@ -284,7 +284,7 @@ $nav = "<a href=\"?year=".$prev_year."&amp;month=".$prev_month."&amp;day=".$prev
$nav .= " <span id=\"month_name\">".dol_print_date(dol_mktime(0, 0, 0, $first_month, $first_day, $first_year), "%Y").", ".$langs->trans("Week")." ".$week;
$nav .= " </span>\n";
$nav .= " &nbsp; <a href=\"?year=".$next_year."&amp;month=".$next_month."&amp;day=".$next_day.$param."\"><i class=\"fa fa-chevron-right\" title=\"".dol_escape_htmltag($langs->trans("Next"))."\"></i></a>\n";
$nav .= " &nbsp; (<a href=\"?year=".$nowyear."&amp;month=".$nowmonth."&amp;day=".$nowday.$param."\">".$langs->trans("Today")."</a>)";
$nav .= " &nbsp; <a href=\"?year=".$nowyear."&amp;month=".$nowmonth."&amp;day=".$nowday.$param."\">".$langs->trans("Today")."</a> ";
/*$nav.=' &nbsp; <form name="dateselect" action="'.$_SERVER["PHP_SELF"].'?action=show_peruser'.$param.'">';
$nav.='<input type="hidden" name="token" value="' . newToken() . '">';
@ -303,7 +303,8 @@ $nav.='<input type="hidden" name="end_d" value="' . $end_d . '">';
$nav.='<input type="hidden" name="showbirthday" value="' . $showbirthday . '">';
*/
$nav .= $form->selectDate($dateselect, 'dateselect', 0, 0, 1, '', 1, 0);
$nav .= ' <input type="submit" name="submitdateselect" class="button" value="'.$langs->trans("Refresh").'">';
//$nav .= ' <input type="submit" name="submitdateselect" class="button" value="'.$langs->trans("Refresh").'">';
$nav .= ' <button type="submit" class="liste_titre button_search" name="button_search_x" value="x"><span class="fa fa-search"></span></button>';
//$nav.='</form>';
// Must be after the nav definition
@ -325,10 +326,6 @@ $head = calendars_prepare_head($paramnoaction);
print '<form method="POST" id="searchFormList" class="listactionsfilter" action="'.$_SERVER["PHP_SELF"].'">'."\n";
dol_fiche_head($head, $tabactive, $langs->trans('Agenda'), 0, 'action');
print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, $listofextcals, $actioncode, $usergroup, '', $resourceid);
dol_fiche_end();
$showextcals = $listofextcals;
// Legend
if ($conf->use_javascript_ajax)
@ -381,6 +378,41 @@ if ($conf->use_javascript_ajax)
}
}
$massactionbutton = '';
$viewmode = '';
$viewmode .= '<a class="btnTitle reposition" href="'.DOL_URL_ROOT.'/comm/action/list.php?action=show_list&restore_lastsearch_values=1">';
//$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
$viewmode .= img_picto($langs->trans("List"), 'object_list-alt', 'class="pictoactionview block"');
//$viewmode .= '</span>';
$viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans("ViewList").'</span></a>';
$viewmode .= '<a class="btnTitle reposition" href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_month&year='.dol_print_date($object->datep, '%Y').'&month='.dol_print_date($object->datep, '%m').'&day='.dol_print_date($object->datep, '%d').'">';
//$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
$viewmode .= img_picto($langs->trans("ViewCal"), 'object_calendar', 'class="pictoactionview block"');
//$viewmode .= '</span>';
$viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans("ViewCal").'</span></a>';
$viewmode .= '<a class="btnTitle reposition" href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_week&year='.dol_print_date($object->datep, '%Y').'&month='.dol_print_date($object->datep, '%m').'&day='.dol_print_date($object->datep, '%d').'">';
//$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
$viewmode .= img_picto($langs->trans("ViewWeek"), 'object_calendarweek', 'class="pictoactionview block"');
//$viewmode .= '</span>';
$viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans("ViewWeek").'</span></a>';
$viewmode .= '<a class="btnTitle reposition" href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_day&year='.dol_print_date($object->datep, '%Y').'&month='.dol_print_date($object->datep, '%m').'&day='.dol_print_date($object->datep, '%d').'">';
//$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
$viewmode .= img_picto($langs->trans("ViewDay"), 'object_calendarday', 'class="pictoactionview block"');
//$viewmode .= '</span>';
$viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans("ViewDay").'</span></a>';
$viewmode .= '<a class="btnTitle btnTitleSelected reposition marginrightonly" href="'.DOL_URL_ROOT.'/comm/action/peruser.php?action=show_peruser&year='.dol_print_date($object->datep, '%Y').'&month='.dol_print_date($object->datep, '%m').'&day='.dol_print_date($object->datep, '%d').'">';
//$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
$viewmode .= img_picto($langs->trans("ViewPerUser"), 'object_calendarperuser', 'class="pictoactionview block"');
//$viewmode .= '</span>';
$viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans("ViewPerUser").'</span></a>';
$viewmode .= '<span class="marginrightonly"></span>';
$newcardbutton = '';
if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create)
@ -394,8 +426,24 @@ if ($user->rights->agenda->myactions->create || $user->rights->agenda->allaction
$newcardbutton .= dolGetButtonTitle($langs->trans("AddAction"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.sprintf("%04d%02d%02d", $tmpforcreatebutton['year'], $tmpforcreatebutton['mon'], $tmpforcreatebutton['mday']).$hourminsec.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($newparam ? '?'.$newparam : '')));
}
print_barre_liste($langs->trans("Agenda"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, -1, 'object_action', 0, $nav.'<span class="marginleftonly"></span>'.$newcardbutton, '', $limit, 1, 0, 1, $viewmode);
$link = '';
print load_fiche_titre($s, $link.' &nbsp; &nbsp; '.$nav.' '.$newcardbutton, '');
//print load_fiche_titre('', $link.' &nbsp; &nbsp; '.$nav.' '.$newcardbutton, '');
// Local calendar
$newtitle = '<div class="nowrap clear inline-block minheight30">';
$newtitle .= '<input type="checkbox" id="check_mytasks" name="check_mytasks" checked disabled> '.$langs->trans("LocalAgenda").' &nbsp; ';
$newtitle .= '</div>';
//$newtitle=$langs->trans($title);
$s = $newtitle;
print $s;
print '<div class="liste_titre liste_titre_bydiv centpercent">';
print_actions_filter($form, $canedit, $search_status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid);
print '</div>';
@ -650,7 +698,7 @@ while ($currentdaytoshow < $lastdaytoshow) {
continue;
}
echo '<td align="center" colspan="'.($end_h - $begin_h).'">';
echo $langs->trans("Day".(($i + (isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1)) % 7));
echo '<span class="opacitymedium spandayofweek">'.$langs->trans("Day".(($i + (isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1)) % 7)).'</span>';
print "<br>";
if ($i) print dol_print_date(dol_time_plus_duree($currentdaytoshow, $i, 'd'), 'day');
else print dol_print_date($currentdaytoshow, 'day');
@ -864,7 +912,7 @@ jQuery(document).ready(function() {
else if (ids.indexOf(",") > -1) /* There is several events */
{
/* alert(\'several events\'); */
url = "'.DOL_URL_ROOT.'/comm/action/list.php?filtert="+userid+"&dateselectyear="+year+"&dateselectmonth="+month+"&dateselectday="+day;
url = "'.DOL_URL_ROOT.'/comm/action/list.php?action=show_list&filtert="+userid+"&dateselectyear="+year+"&dateselectmonth="+month+"&dateselectday="+day;
window.location.href = url;
}
else /* One event */

View File

@ -35,8 +35,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/modules/action/rapport.pdf.php';
$langs->loadLangs(array("agenda", "commercial"));
$action = GETPOST('action', 'alpha');
$month = GETPOST('month');
$year = GETPOST('year');
$month = GETPOST('month', 'int');
$year = GETPOST('year', 'int');
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha');
@ -119,9 +119,8 @@ if ($resql)
print '<input type="hidden" name="action" value="list">';
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="page" value="'.$page.'">';
print_barre_liste($langs->trans("EventReports"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_agenda', 0, '', '', $limit);
print_barre_liste($langs->trans("EventReports"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_agenda', 0, '', '', $limit, 0, 0, 1);
$moreforfilter = '';
@ -154,7 +153,7 @@ if ($resql)
// Button to build doc
print '<td class="center">';
print '<a href="'.$_SERVER["PHP_SELF"].'?action=builddoc&amp;page='.$page.'&amp;month='.$obj->month.'&amp;year='.$obj->year.'">'.img_picto($langs->trans('BuildDoc'), 'filenew').'</a>';
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=builddoc&amp;page='.$page.'&amp;month='.$obj->month.'&amp;year='.$obj->year.'">'.img_picto($langs->trans('BuildDoc'), 'filenew').'</a>';
print '</td>';
$name = "actions-".$obj->month."-".$obj->year.".pdf";

View File

@ -934,7 +934,7 @@ if ($object->id > 0)
$late = '';
foreach ($contrat->lines as $line) {
if ($contrat->statut == Contrat::STATUS_VALIDATED && $line->statut == ContratLigne::STATUS_OPEN) {
if (($line->date_fin_validite + $conf->contrat->services->expires->warning_delay) < $now) $late = img_warning($langs->trans("Late"));
if (((!empty($line->date_fin_validite)?$line->date_fin_validite:0) + $conf->contrat->services->expires->warning_delay) < $now) $late = img_warning($langs->trans("Late"));
}
}

View File

@ -192,7 +192,7 @@ if (empty($reshook))
}
}
$result = $object->createFromClone($user, $socid);
$result = $object->createFromClone($user, $socid, (GETPOSTISSET('entity') ? GETPOST('entity', 'int') : null));
if ($result > 0) {
header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result);
exit();
@ -778,11 +778,19 @@ if (empty($reshook))
}
}
}
} // Add line
elseif ($action == 'addline' && $usercancreate) {
} elseif ($action == 'addline' && GETPOST('submitforalllines', 'aZ09') && GETPOST('vatforalllines', 'alpha')) {
// Define vat_rate
$vat_rate = (GETPOST('vatforalllines') ? GETPOST('vatforalllines') : 0);
$vat_rate = str_replace('*', '', $vat_rate);
$localtax1_rate = get_localtax($vat_rate, 1, $object->thirdparty, $mysoc);
$localtax2_rate = get_localtax($vat_rate, 2, $object->thirdparty, $mysoc);
foreach ($object->lines as $line) {
$result = $object->updateline($line->id, $line->subprice, $line->qty, $line->remise_percent, $vat_rate, $localtax1_rate, $localtax2_rate, $line->desc, 'HT', $line->info_bits, $line->special_code, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->product_type, $line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $line->multicurrency_subprice);
}
} elseif ($action == 'addline' && $usercancreate) { // Add line
// Set if we used free entry or predefined product
$predef = '';
$product_desc = (GETPOST('dp_desc') ?GETPOST('dp_desc') : '');
$product_desc = (GETPOST('dp_desc', 'none') ?GETPOST('dp_desc', 'none') : '');
$price_ht = GETPOST('price_ht');
$price_ht_devise = GETPOST('multicurrency_price_ht');
$prod_entry_mode = GETPOST('prod_entry_mode');
@ -1753,10 +1761,9 @@ if ($action == 'create')
print '<tr><td class="tdtop"><input type="radio" name="createmode" value="empty" checked></td>';
print '<td valign="top" colspan="2">'.$langs->trans("CreateEmptyPropal").'</td></tr>';
print '</table>';
}
if (!empty($conf->global->PROPAL_CLONE_ON_CREATE_PAGE)) print '</table>';
dol_fiche_end();
$langs->load("bills");
@ -1799,11 +1806,11 @@ if ($action == 'create')
if ($action == 'clone') {
// Create an array for form
$formquestion = array(
// 'text' => $langs->trans("ConfirmClone"),
// array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1),
// array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' =>
// 1),
array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company(GETPOST('socid', 'int'), 'socid', '(s.client=1 OR s.client=2 OR s.client=3)')));
// 'text' => $langs->trans("ConfirmClone"),
// array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1),
// array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1),
array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company(GETPOST('socid', 'int'), 'socid', '(s.client=1 OR s.client=2 OR s.client=3)'))
);
if (!empty($conf->global->PROPAL_CLONE_DATE_DELIVERY) && !empty($object->date_livraison)) {
$formquestion[] = array('type' => 'date', 'name' => 'date_delivery', 'label' => $langs->trans("DeliveryDate"), 'value' => $object->date_livraison);
}

View File

@ -725,15 +725,15 @@ class Propal extends CommonObject
/**
* Update a proposal line
*
* @param int $rowid Id de la ligne
* @param float $pu Prix unitaire (HT ou TTC selon price_base_type)
* @param int $rowid Id of line
* @param float $pu Unit price (HT or TTC depending on price_base_type)
* @param float $qty Quantity
* @param float $remise_percent Remise effectuee sur le produit
* @param float $txtva Taux de TVA
* @param float $remise_percent Discount on line
* @param float $txtva VAT Rate (Can be '1.23' or '1.23 (ABC)')
* @param float $txlocaltax1 Local tax 1 rate
* @param float $txlocaltax2 Local tax 2 rate
* @param string $desc Description
* @param string $price_base_type HT ou TTC
* @param string $price_base_type HT or TTC
* @param int $info_bits Miscellaneous informations
* @param int $special_code Special code (also used by externals modules!)
* @param int $fk_parent_line Id of parent line (0 in most cases, used by modules adding sublevels into lines).
@ -1289,9 +1289,10 @@ class Propal extends CommonObject
*
* @param User $user User making the clone
* @param int $socid Id of thirdparty
* @param int $forceentity Entity id to force
* @return int New id of clone
*/
public function createFromClone(User $user, $socid = 0)
public function createFromClone(User $user, $socid = 0, $forceentity = null)
{
global $conf, $hookmanager;
@ -1345,6 +1346,7 @@ class Propal extends CommonObject
$object->id = 0;
$object->ref = '';
$object->entity = (! empty($forceentity) ? $forceentity : $object->entity);
$object->statut = self::STATUS_DRAFT;
// Clear fields
@ -4119,6 +4121,8 @@ class PropaleLigne extends CommonObjectLine
$pa_ht_isemptystring = (empty($this->pa_ht) && $this->pa_ht == ''); // If true, we can use a default value. If this->pa_ht = '0', we must use '0'.
if (empty($this->id) && ! empty($this->rowid)) $this->id = $this->rowid;
// Clean parameters
if (empty($this->tva_tx)) $this->tva_tx = 0;
if (empty($this->localtax1_tx)) $this->localtax1_tx = 0;
@ -4192,7 +4196,7 @@ class PropaleLigne extends CommonObjectLine
$sql .= ", multicurrency_total_tva=".price2num($this->multicurrency_total_tva)."";
$sql .= ", multicurrency_total_ttc=".price2num($this->multicurrency_total_ttc)."";
$sql .= " WHERE rowid = ".$this->rowid;
$sql .= " WHERE rowid = ".$this->id;
dol_syslog(get_class($this)."::update", LOG_DEBUG);
$resql = $this->db->query($sql);
@ -4200,7 +4204,6 @@ class PropaleLigne extends CommonObjectLine
{
if (!$error)
{
$this->id = $this->rowid;
$result = $this->insertExtraFields();
if ($result < 0)
{

View File

@ -59,9 +59,9 @@ if (GETPOST('action', 'aZ09') == 'setremise')
$discount_type = GETPOST('discount_type', 'int');
if (!empty($discount_type)) {
$result = $object->set_remise_supplier(price2num(GETPOST("remise")), GETPOST("note"), $user);
$result = $object->set_remise_supplier(price2num(GETPOST("remise")), GETPOST("note", "alphanohtml"), $user);
} else {
$result = $object->set_remise_client(price2num(GETPOST("remise")), GETPOST("note"), $user);
$result = $object->set_remise_client(price2num(GETPOST("remise")), GETPOST("note", "alphanohtml"), $user);
}
if ($result > 0)
@ -183,7 +183,7 @@ if ($socid > 0)
// Motif/Note
print '<tr><td class="fieldrequired">';
print $langs->trans("NoteReason").'</td><td><input type="text" size="60" name="note" value="'.dol_escape_htmltag(GETPOST("note")).'"></td></tr>';
print $langs->trans("NoteReason").'</td><td><input type="text" size="60" name="note" value="'.dol_escape_htmltag(GETPOST("note", "alphanohtml")).'"></td></tr>';
print "</table>";

View File

@ -624,10 +624,16 @@ if (empty($reshook))
$result = $object->set_remise($user, GETPOST('remise_percent'));
} elseif ($action == 'setremiseabsolue' && $usercancreate) {
$result = $object->set_remise_absolue($user, GETPOST('remise_absolue'));
}
// Add a new line
elseif ($action == 'addline' && $usercancreate)
} elseif ($action == 'addline' && GETPOST('submitforalllines', 'aZ09') && GETPOST('vatforalllines', 'alpha')) {
// Define vat_rate
$vat_rate = (GETPOST('vatforalllines') ? GETPOST('vatforalllines') : 0);
$vat_rate = str_replace('*', '', $vat_rate);
$localtax1_rate = get_localtax($vat_rate, 1, $object->thirdparty, $mysoc);
$localtax2_rate = get_localtax($vat_rate, 2, $object->thirdparty, $mysoc);
foreach ($object->lines as $line) {
$result = $object->updateline($line->id, $line->desc, $line->subprice, $line->qty, $line->remise_percent, $vat_rate, $localtax1_rate, $localtax2_rate, 'HT', $line->info_bits, $line->date_start, $line->date_end, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->fk_unit, $line->multicurrency_subprice);
}
} elseif ($action == 'addline' && $usercancreate) // Add a new line
{
$langs->load('errors');
$error = 0;
@ -1574,7 +1580,7 @@ if ($action == 'create' && $usercancreate)
print '</td>';
} else {
print '<td>';
print $form->select_company('', 'socid', '(s.client = 1 OR s.client = 3)', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300');
print $form->select_company('', 'socid', '(s.client = 1 OR s.client = 2 OR s.client = 3)', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300');
// reload page to retrieve customer informations
if (!empty($conf->global->RELOAD_PAGE_ON_CUSTOMER_CHANGE))
{
@ -1997,7 +2003,7 @@ if ($action == 'create' && $usercancreate)
if ($action == 'clone') {
// Create an array for form
$formquestion = array(
array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company(GETPOST('socid', 'int'), 'socid', '(s.client=1 OR s.client=3)'))
array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company(GETPOST('socid', 'int'), 'socid', '(s.client=1 OR s.client = 2 OR s.client=3)'))
);
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneOrder', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
}

View File

@ -40,13 +40,7 @@ $id = (GETPOST('id', 'int') ? GETPOST('id', 'int') : GETPOST('account', 'int'));
$ref = GETPOST('ref', 'alpha');
$action = GETPOST('action', 'alpha');
$confirm = GETPOST('confirm', 'alpha');
$num = (GETPOST('num', 'alpha') ? GETPOST('num', 'alpha') : GETPOST('sectionid', 'alpha'));
$mesg = '';
if (isset($_SESSION['DolMessage'])) {
$mesg = $_SESSION['DolMessage'];
unset($_SESSION['DolMessage']);
}
$numref = (GETPOST('num', 'alpha') ? GETPOST('num', 'alpha') : GETPOST('sectionid', 'alpha'));
// Security check
if ($user->socid) {
@ -71,21 +65,74 @@ if (!$sortfield)
$sortfield = "name";
$object = new Account($db);
if ($id > 0 || !empty($ref)) $object->fetch($id, $ref);
if ($id > 0 || !empty($ref))
{
$result = $object->fetch($id, $ref);
$account = $object->id; // Force the search field on id of account
}
$result = restrictedArea($user, 'banque', $object->id, 'bank_account', '', '');
// Define number of receipt to show (current, previous or next one ?)
$found = false;
if ($_GET["rel"] == 'prev')
{
// Recherche valeur pour num = numero releve precedent
$sql = "SELECT DISTINCT(b.num_releve) as num";
$sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
$sql .= " WHERE b.num_releve < '".$db->escape($numref)."'";
$sql .= " AND b.fk_account = ".$id;
$sql .= " ORDER BY b.num_releve DESC";
dol_syslog("htdocs/compta/bank/releve.php", LOG_DEBUG);
$resql = $db->query($sql);
if ($resql)
{
$numrows = $db->num_rows($resql);
if ($numrows > 0)
{
$obj = $db->fetch_object($resql);
$numref = $obj->num;
$found = true;
}
}
} elseif ($_GET["rel"] == 'next')
{
// Recherche valeur pour num = numero releve precedent
$sql = "SELECT DISTINCT(b.num_releve) as num";
$sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
$sql .= " WHERE b.num_releve > '".$db->escape($numref)."'";
$sql .= " AND b.fk_account = ".$id;
$sql .= " ORDER BY b.num_releve ASC";
dol_syslog("htdocs/compta/bank/releve.php", LOG_DEBUG);
$resql = $db->query($sql);
if ($resql)
{
$numrows = $db->num_rows($resql);
if ($numrows > 0)
{
$obj = $db->fetch_object($resql);
$numref = $obj->num;
$found = true;
}
}
} else {
// On veut le releve num
$found = true;
}
/*
* Actions
*/
if (!empty($num))
if (!empty($numref))
{
$object->fetch_thirdparty();
$upload_dir = $conf->bank->dir_output."/".$id."/statement/".dol_sanitizeFileName($num);
$upload_dir = $conf->bank->dir_output."/".$id."/statement/".dol_sanitizeFileName($numref);
}
$backtopage = $_SERVER['PHP_SELF']."?account=".$id."&num=".$num;
$backtopage = $_SERVER['PHP_SELF']."?account=".$id."&num=".$numref;
include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
@ -101,10 +148,10 @@ llxHeader('', $title, $helpurl);
if ($id > 0 || !empty($ref)) {
if ($object->fetch($id, $ref)) {
$upload_dir = $conf->bank->dir_output."/".$id."/statement/".dol_sanitizeFileName($num);
$upload_dir = $conf->bank->dir_output."/".$id."/statement/".dol_sanitizeFileName($numref);
// Onglets
$head = account_statement_prepare_head($object, $num);
$head = account_statement_prepare_head($object, $numref);
dol_fiche_head($head, 'document', $langs->trans("AccountStatement"), -1, 'account');
@ -115,8 +162,15 @@ if ($id > 0 || !empty($ref)) {
$totalsize += $file['size'];
}
$title = $langs->trans("AccountStatement").' '.$num.' - '.$langs->trans("BankAccount").' '.$object->getNomUrl(1, 'receipts');
print load_fiche_titre($title, '', '');
$morehtmlright = '';
$morehtmlright .= '<div class="pagination"><ul>';
$morehtmlright .= '<li class="pagination"><a class="paginationnext" href="'.$_SERVER["PHP_SELF"].'?rel=prev&amp;num='.$numref.'&amp;ve='.$ve.'&amp;account='.$object->id.'"><i class="fa fa-chevron-left" title="'.dol_escape_htmltag($langs->trans("Previous")).'"></i></a></li>';
$morehtmlright .= '<li class="pagination"><span class="active">'.$langs->trans("AccountStatement")." ".$numref.'</span></li>';
$morehtmlright .= '<li class="pagination"><a class="paginationnext" href="'.$_SERVER["PHP_SELF"].'?rel=next&amp;num='.$numref.'&amp;ve='.$ve.'&amp;account='.$object->id.'"><i class="fa fa-chevron-right" title="'.dol_escape_htmltag($langs->trans("Next")).'"></i></a></li>';
$morehtmlright .= '</ul></div>';
$title = $langs->trans("AccountStatement").' '.$numref.' - '.$langs->trans("BankAccount").' '.$object->getNomUrl(1, 'receipts');
print load_fiche_titre($title, $morehtmlright, '');
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
@ -134,9 +188,9 @@ if ($id > 0 || !empty($ref)) {
$modulepart = 'bank';
$permission = $user->rights->banque->modifier;
$permtoedit = $user->rights->banque->modifier;
$param = '&id='.$object->id.'&num='.urlencode($num);
$moreparam = '&num='.urlencode($num); ;
$relativepathwithnofile = $id."/statement/".dol_sanitizeFileName($num)."/";
$param = '&id='.$object->id.'&num='.urlencode($numref);
$moreparam = '&num='.urlencode($numref); ;
$relativepathwithnofile = $id."/statement/".dol_sanitizeFileName($numref)."/";
include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php';
} else {
dol_print_error($db);

View File

@ -39,12 +39,6 @@ $ref = GETPOST('ref', 'alpha');
$action = GETPOST('action', 'alpha');
$confirm = GETPOST('confirm', 'alpha');
$mesg = '';
if (isset($_SESSION['DolMessage'])) {
$mesg = $_SESSION['DolMessage'];
unset($_SESSION['DolMessage']);
}
// Security check
if ($user->socid) {
$action = '';

View File

@ -247,6 +247,8 @@ if (empty($numref))
$linkback = '<a href="'.DOL_URL_ROOT.'/compta/bank/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
$morehtmlref = '';
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', '', 1);
dol_fiche_end();
@ -362,17 +364,15 @@ if (empty($numref))
dol_fiche_head($head, 'statement', $langs->trans("AccountStatement"), -1, 'account');
$mesprevnext = '';
$mesprevnext .= '<div class="pagination"><ul>';
$mesprevnext .= '<li class="pagination"><a class="paginationnext" href="'.$_SERVER["PHP_SELF"].'?rel=prev&amp;num='.$numref.'&amp;ve='.$ve.'&amp;account='.$object->id.'"><i class="fa fa-chevron-left" title="'.dol_escape_htmltag($langs->trans("Previous")).'"></i></a></li>';
//$mesprevnext.=' &nbsp; ';
$mesprevnext .= '<li class="pagination"><span class="active">'.$langs->trans("AccountStatement")." ".$numref.'</span></li>';
//$mesprevnext.=' &nbsp; ';
$mesprevnext .= '<li class="pagination"><a class="paginationnext" href="'.$_SERVER["PHP_SELF"].'?rel=next&amp;num='.$numref.'&amp;ve='.$ve.'&amp;account='.$object->id.'"><i class="fa fa-chevron-right" title="'.dol_escape_htmltag($langs->trans("Next")).'"></i></a></li>';
$mesprevnext .= '</ul></div>';
$morehtmlright = '';
$morehtmlright .= '<div class="pagination"><ul>';
$morehtmlright .= '<li class="pagination"><a class="paginationnext" href="'.$_SERVER["PHP_SELF"].'?rel=prev&amp;num='.$numref.'&amp;ve='.$ve.'&amp;account='.$object->id.'"><i class="fa fa-chevron-left" title="'.dol_escape_htmltag($langs->trans("Previous")).'"></i></a></li>';
$morehtmlright .= '<li class="pagination"><span class="active">'.$langs->trans("AccountStatement")." ".$numref.'</span></li>';
$morehtmlright .= '<li class="pagination"><a class="paginationnext" href="'.$_SERVER["PHP_SELF"].'?rel=next&amp;num='.$numref.'&amp;ve='.$ve.'&amp;account='.$object->id.'"><i class="fa fa-chevron-right" title="'.dol_escape_htmltag($langs->trans("Next")).'"></i></a></li>';
$morehtmlright .= '</ul></div>';
$title = $langs->trans("AccountStatement").' '.$numref.' - '.$langs->trans("BankAccount").' '.$object->getNomUrl(1, 'receipts');
print load_fiche_titre($title, $mesprevnext, '');
print load_fiche_titre($title, $morehtmlright, '');
//print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, 0, $nbtotalofrecords, 'bank_account', 0, '', '', 0, 1);
print "<form method=\"post\" action=\"releve.php\">";
@ -620,7 +620,7 @@ if (empty($numref))
if ($user->rights->banque->modifier || $user->rights->banque->consolidate)
{
print '<td class="center"><a href="'.DOL_URL_ROOT.'/compta/bank/line.php?rowid='.$objp->rowid.'&account='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?account='.$object->id.'&num='.$numref).'">';
print '<td class="center"><a class="editfielda reposition" href="'.DOL_URL_ROOT.'/compta/bank/line.php?rowid='.$objp->rowid.'&account='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?account='.$object->id.'&num='.$numref).'">';
print img_edit();
print "</a></td>";
} else {

View File

@ -178,7 +178,7 @@ if ($result)
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print_barre_liste($langs->trans("VariousPayments"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines, 'object_payment', 0, $newcardbutton, '', $limit, 0, 0, 1);
print_barre_liste($langs->trans("MenuVariousPayment"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines, 'object_payment', 0, $newcardbutton, '', $limit, 0, 0, 1);
print '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";

View File

@ -451,6 +451,7 @@ while ($j < $numlt)
// Payment Salary
/*
if (!empty($conf->salaries->enabled) && !empty($user->rights->salaries->read))
{
if (!$mode || $mode != 'sconly')
@ -558,6 +559,7 @@ if (!empty($conf->salaries->enabled) && !empty($user->rights->salaries->read))
}
}
}
*/
print '</form>';

View File

@ -1417,7 +1417,7 @@ if (empty($reshook))
$result = $srcobject->fetch($object->origin_id);
$typeamount = GETPOST('typedeposit', 'aZ09');
$valuedeposit = GETPOST('valuedeposit', 'int');
$valuedeposit = price2num(GETPOST('valuedeposit', 'alpha'), 'MU');
// If deposit invoice
if ($_POST['type'] == Facture::TYPE_DEPOSIT && in_array($typeamount, array('amount', 'variable')))
@ -1867,8 +1867,16 @@ if (empty($reshook))
$_GET["originid"] = $_POST["originid"];
setEventMessages($object->error, $object->errors, 'errors');
}
} // Add a new line
elseif ($action == 'addline' && $usercancreate)
} elseif ($action == 'addline' && GETPOST('submitforalllines', 'aZ09') && GETPOST('vatforalllines', 'alpha')) {
// Define vat_rate
$vat_rate = (GETPOST('vatforalllines') ? GETPOST('vatforalllines') : 0);
$vat_rate = str_replace('*', '', $vat_rate);
$localtax1_rate = get_localtax($vat_rate, 1, $object->thirdparty, $mysoc);
$localtax2_rate = get_localtax($vat_rate, 2, $object->thirdparty, $mysoc);
foreach ($object->lines as $line) {
$result = $object->updateline($line->id, $line->desc, $line->subprice, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $vat_rate, $localtax1_rate, $localtax2_rate, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit, $line->multicurrency_subprice);
}
} elseif ($action == 'addline' && $usercancreate) // Add a new line
{
$langs->load('errors');
$error = 0;

View File

@ -1333,7 +1333,7 @@ class FactureRec extends CommonInvoice
$result = '';
$label = '<u>'.$langs->trans("ShowInvoice").'</u>';
$label = '<u>'.$langs->trans("RepeatableInvoice").'</u>';
if (!empty($this->ref)) {
$label .= '<br><b>'.$langs->trans('Ref').':</b> '.$this->ref;
}

View File

@ -423,7 +423,7 @@ class Facture extends CommonInvoice
$this->brouillon = 1;
// Multicurrency (test on $this->multicurrency_tx because we should take the default rate only if not using origin rate)
if (!empty($this->multicurrency_code) && empty($this->multicurrency_tx)) list($this->fk_multicurrency, $this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code);
if (!empty($this->multicurrency_code) && empty($this->multicurrency_tx)) list($this->fk_multicurrency, $this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code, $this->date);
else $this->fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $this->multicurrency_code);
if (empty($this->fk_multicurrency))
{
@ -2415,7 +2415,7 @@ class Facture extends CommonInvoice
* @param string $force_number Reference to force on invoice
* @param int $idwarehouse Id of warehouse to use for stock decrease if option to decreasenon stock is on (0=no decrease)
* @param int $notrigger 1=Does not execute triggers, 0= execute triggers
* @param int $batch_rule [=0] 0 not decrement batch, else batch rule to use
* @param int $batch_rule 0=do not decrement batch, else batch rule to use
* 1=take in batches ordered by sellby and eatby dates
* @return int <0 if KO, 0=Nothing done because invoice is not a draft, >0 if OK
*/

View File

@ -53,6 +53,8 @@ $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'inv
$socid = GETPOST('socid', 'int');
$socid = GETPOST('socid', 'int');
// Security check
$id = (GETPOST('facid', 'int') ?GETPOST('facid', 'int') : GETPOST('id', 'int'));
$lineid = GETPOST('lineid', 'int');
@ -151,6 +153,11 @@ if ($socid > 0) {
}
if ($socid > 0) {
$tmpthirdparty = new Societe($db);
$res = $tmpthirdparty->fetch($socid);
if ($res > 0) $search_societe = $tmpthirdparty->name;
}
/*
* Actions

View File

@ -48,13 +48,12 @@ $ref = GETPOST('ref', 'alpha');
$socid = GETPOST('socid', 'int');
$action = GETPOST('action', 'alpha');
$type = GETPOST('type', 'aZ09');
$mode = GETPOST('mode', 'aZ09');
$fieldid = (!empty($ref) ? 'ref' : 'rowid');
if ($user->socid) $socid = $user->socid;
$result = restrictedArea($user, 'facture', $id, '', '', 'fk_soc', $fieldid);
if ($mode == 'bank-transfer') {
if ($type == 'bank-transfer') {
$object = new FactureFournisseur($db);
} else {
$object = new Facture($db);
@ -94,6 +93,7 @@ if (empty($reshook))
$sourcetype = 'facture';
if ($type == 'bank-transfer') {
$sourcetype = 'supplier_invoice';
$newtype = 'bank-transfer';
}
$result = $object->demande_prelevement($user, price2num(GETPOST('withdraw_request_amount', 'alpha')), $newtype, $sourcetype);
@ -117,7 +117,7 @@ if (empty($reshook))
$result = $object->demande_prelevement_delete($user, GETPOST('did', 'int'));
if ($result == 0)
{
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id.'&mode='.$mode);
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id.'&type='.$type);
exit;
}
}
@ -133,7 +133,7 @@ $form = new Form($db);
$now = dol_now();
if ($mode == 'bank-transfer') {
if ($type == 'bank-transfer') {
$title = $langs->trans('InvoiceSupplier')." - ".$langs->trans('CreditTransfer');
$helpurl = "";
} else {
@ -168,7 +168,7 @@ if ($object->id > 0)
if ($object->paye) $resteapayer = 0;
$resteapayeraffiche = $resteapayer;
if ($mode == 'bank-transfer') {
if ($type == 'bank-transfer') {
if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { // Never use this
$filterabsolutediscount = "fk_invoice_supplier_source IS NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice
$filtercreditnote = "fk_invoice_supplier_source IS NOT NULL"; // If we want deposit to be substracted to payments only and not to total of final invoice
@ -202,7 +202,7 @@ if ($object->id > 0)
$author->fetch($object->user_author);
}
if ($mode == 'bank-transfer') {
if ($type == 'bank-transfer') {
$head = facturefourn_prepare_head($object);
} else {
$head = facture_prepare_head($object);
@ -211,7 +211,7 @@ if ($object->id > 0)
dol_fiche_head($head, 'standingorders', $title, -1, 'bill');
// Invoice content
if ($mode == 'bank-transfer') {
if ($type == 'bank-transfer') {
$linkback = '<a href="'.DOL_URL_ROOT.'/fourn/facture/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
} else {
$linkback = '<a href="'.DOL_URL_ROOT.'/compta/facture/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
@ -219,7 +219,7 @@ if ($object->id > 0)
$morehtmlref = '<div class="refidno">';
// Ref customer
if ($mode == 'bank-transfer') {
if ($type == 'bank-transfer') {
$morehtmlref .= $form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', 0, 1);
$morehtmlref .= $form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', null, null, '', 1);
} else {
@ -228,7 +228,7 @@ if ($object->id > 0)
}
// Thirdparty
$morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1);
if ($mode == 'bank-transfer') {
if ($type == 'bank-transfer') {
if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref .= ' (<a href="'.DOL_URL_ROOT.'/fourn/facture/list.php?socid='.$object->thirdparty->id.'&search_company='.urlencode($object->thirdparty->name).'">'.$langs->trans("OtherBills").'</a>)';
} else {
if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref .= ' (<a href="'.DOL_URL_ROOT.'/compta/facture/list.php?socid='.$object->thirdparty->id.'&search_company='.urlencode($object->thirdparty->name).'">'.$langs->trans("OtherBills").'</a>)';
@ -288,7 +288,7 @@ if ($object->id > 0)
}
if ($object->type == $object::TYPE_REPLACEMENT)
{
if ($mode == 'bank-transfer') {
if ($type == 'bank-transfer') {
$facreplaced = new FactureFournisseur($db);
} else {
$facreplaced = new Facture($db);
@ -298,7 +298,7 @@ if ($object->id > 0)
}
if ($object->type == $object::TYPE_CREDIT_NOTE)
{
if ($mode == 'bank-transfer') {
if ($type == 'bank-transfer') {
$facusing = new FactureFournisseur($db);
} else {
$facusing = new Facture($db);
@ -316,7 +316,7 @@ if ($object->id > 0)
{
if ($i == 0) print ' ';
else print ',';
if ($mode == 'bank-transfer') {
if ($type == 'bank-transfer') {
$facavoir = new FactureFournisseur($db);
} else {
$facavoir = new Facture($db);
@ -339,7 +339,7 @@ if ($object->id > 0)
// Discounts
print '<tr><td>'.$langs->trans('Discounts').'</td><td colspan="3">';
if ($mode == 'bank-transfer') {
if ($type == 'bank-transfer') {
//$societe = new Fournisseur($db);
//$result = $societe->fetch($object->socid);
$thirdparty = $object->thirdparty;
@ -355,7 +355,7 @@ if ($object->id > 0)
print '</td></tr>';
// Label
if ($mode == 'bank-transfer') {
if ($type == 'bank-transfer') {
print '<tr>';
print '<td>'.$form->editfieldkey("Label", 'label', $object->label, $object, 0).'</td>';
print '<td>'.$form->editfieldval("Label", 'label', $object->label, $object, 0).'</td>';
@ -417,7 +417,7 @@ if ($object->id > 0)
if ($object->type != $object::TYPE_CREDIT_NOTE)
{
$duedate = $object->date_lim_reglement;
if ($mode == 'bank-transfer') {
if ($type == 'bank-transfer') {
$duedate = $object->date_echeance;
}
@ -470,7 +470,7 @@ if ($object->id > 0)
print '</tr>';
$title = 'CustomerIBAN';
if ($mode == 'bank-transfer') {
if ($type == 'bank-transfer') {
$title = 'SupplierIBAN';
}
print '<tr><td>'.$langs->trans($title).'</td><td colspan="3">';
@ -627,7 +627,7 @@ if ($object->id > 0)
print "\n<div class=\"tabsAction\">\n";
$buttonlabel = $langs->trans("MakeWithdrawRequest");
if ($mode == 'bank-transfer') {
if ($type == 'bank-transfer') {
$buttonlabel = $langs->trans("MakeBankTransferOrder");
}
@ -643,6 +643,7 @@ if ($object->id > 0)
print '<form method="POST" action="">';
print '<input type="hidden" name="token" value="'.newToken().'" />';
print '<input type="hidden" name="id" value="'.$object->id.'" />';
print '<input type="hidden" name="type" value="'.$type.'" />';
print '<input type="hidden" name="action" value="new" />';
print '<label for="withdraw_request_amount">'.$langs->trans('BankTransferAmount').' </label>';
print '<input type="text" id="withdraw_request_amount" name="withdraw_request_amount" value="'.$remaintopaylesspendingdebit.'" size="9" />';
@ -667,7 +668,7 @@ if ($object->id > 0)
print "</div><br>\n";
if ($mode == 'bank-transfer') {
if ($type == 'bank-transfer') {
print '<div class="opacitymedium">'.$langs->trans("DoCreditTransferBeforePayments").'</div><br>';
} else {
print '<div class="opacitymedium">'.$langs->trans("DoStandingOrdersBeforePayments").'</div><br>';
@ -684,7 +685,7 @@ if ($object->id > 0)
print '<td class="left">'.$langs->trans("DateRequest").'</td>';
print '<td class="center">'.$langs->trans("User").'</td>';
print '<td class="center">'.$langs->trans("Amount").'</td>';
if ($mode == 'bank-transfer') {
if ($type == 'bank-transfer') {
print '<td class="center">'.$langs->trans("BankTransferReceipt").'</td>';
} else {
print '<td class="center">'.$langs->trans("WithdrawalReceipt").'</td>';
@ -696,7 +697,7 @@ if ($object->id > 0)
$sql = "SELECT pfd.rowid, pfd.traite, pfd.date_demande as date_demande,";
$sql .= " pfd.date_traite as date_traite, pfd.amount,";
$sql .= " u.rowid as user_id, u.lastname, u.firstname, u.login";
$sql .= " u.rowid as user_id, u.email, u.lastname, u.firstname, u.login, u.statut as user_status";
$sql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on pfd.fk_user_demande = u.rowid";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."prelevement_bons as pb ON pb.rowid = pfd.fk_prelevement_bons";
@ -716,14 +717,29 @@ if ($object->id > 0)
{
$i = 0;
$tmpuser = new User($db);
$num = $db->num_rows($result);
while ($i < $num)
{
$obj = $db->fetch_object($result_sql);
$tmpuser->id = $obj->user_id;
$tmpuser->login = $obj->login;
$tmpuser->ref = $obj->login;
$tmpuser->email = $obj->email;
$tmpuser->lastname = $obj->lastname;
$tmpuser->firstname = $obj->firstname;
$tmpuser->statut = $obj->user_status;
print '<tr class="oddeven">';
print '<td class="left">'.dol_print_date($db->jdate($obj->date_demande), 'dayhour')."</td>\n";
print '<td align="center"><a href="'.DOL_URL_ROOT.'/user/card.php?id='.$obj->user_id.'">'.img_object($langs->trans("ShowUser"), 'user').' '.$obj->login.'</a></td>';
print '<td align="center">';
print $tmpuser->getNomUrl(1, '', 0, 0, 0, 0, 'login');
print '</td>';
print '<td class="center">'.price($obj->amount).'</td>';
print '<td align="center">-</td>';
print '<td>&nbsp;</td>';
@ -731,7 +747,7 @@ if ($object->id > 0)
print '<td class="center">'.$langs->trans("OrderWaiting").'</td>';
print '<td class="right">';
print '<a href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=delete&did='.$obj->rowid.'&mode='.$mode.'">';
print '<a href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=delete&did='.$obj->rowid.'&type='.$type.'">';
print img_delete();
print '</a></td>';
@ -749,7 +765,7 @@ if ($object->id > 0)
$sql = "SELECT pfd.rowid, pfd.traite, pfd.date_demande, pfd.date_traite, pfd.fk_prelevement_bons, pfd.amount,";
$sql .= " pb.ref,";
$sql .= " u.rowid as user_id, u.lastname, u.firstname, u.login";
$sql .= " u.rowid as user_id, u.email, u.lastname, u.firstname, u.login, u.statut as user_status";
$sql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on pfd.fk_user_demande = u.rowid";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."prelevement_bons as pb ON pb.rowid = pfd.fk_prelevement_bons";
@ -769,15 +785,27 @@ if ($object->id > 0)
$numclosed = $num;
$i = 0;
$tmpuser = new User($db);
while ($i < $num)
{
$obj = $db->fetch_object($result);
$tmpuser->id = $obj->user_id;
$tmpuser->login = $obj->login;
$tmpuser->ref = $obj->login;
$tmpuser->email = $obj->email;
$tmpuser->lastname = $obj->lastname;
$tmpuser->firstname = $obj->firstname;
$tmpuser->statut = $obj->user_status;
print '<tr class="oddeven">';
print '<td class="left">'.dol_print_date($db->jdate($obj->date_demande), 'day')."</td>\n";
print '<td align="center"><a href="'.DOL_URL_ROOT.'/user/card.php?id='.$obj->user_id.'">'.img_object($langs->trans("ShowUser"), 'user').' '.$obj->login.'</a></td>';
print '<td align="center">';
print $tmpuser->getNomUrl(1, '', 0, 0, 0, 0, 'login');
print '</td>';
print '<td class="center">'.price($obj->amount).'</td>';

View File

@ -351,9 +351,10 @@ if ($action == 'new')
$now = dol_now();
print $langs->trans("SelectChequeTransactionAndGenerate").'<br><br>'."\n";
print '<span class="opacitymedium">'.$langs->trans("SelectChequeTransactionAndGenerate").'</span><br><br>'."\n";
print '<form class="nocellnopadd" action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="new">';
dol_fiche_head();

View File

@ -1154,7 +1154,7 @@ class Paiement extends CommonObject
if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips
$result = '';
$label = '<u>'.$langs->trans("ShowPayment").'</u><br>';
$label = '<u>'.$langs->trans("Payment").'</u><br>';
$label .= '<strong>'.$langs->trans("Ref").':</strong> '.$this->ref;
if ($this->datepaye ? $this->datepaye : $this->date) $label .= '<br><strong>'.$langs->trans("Date").':</strong> '.dol_print_date($this->datepaye ? $this->datepaye : $this->date, 'dayhour');
if ($mode == 'withlistofinvoices')

View File

@ -41,6 +41,8 @@ if ($user->socid > 0)
$socid = $user->socid;
}
$charge = new ChargeSociales($db);
/*
* Actions
@ -161,7 +163,6 @@ $form = new Form($db);
// Formulaire de creation d'un paiement de charge
if ($action == 'create')
{
$charge = new ChargeSociales($db);
$charge->fetch($chid);
$charge->accountid = $charge->fk_account ? $charge->fk_account : $charge->accountid;
$charge->paiementtype = $charge->mode_reglement_id ? $charge->mode_reglement_id : $charge->paiementtype;
@ -223,7 +224,7 @@ if ($action == 'create')
print '<tr><td class="fieldrequired">'.$langs->trans("Date").'</td><td>';
$datepaye = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]);
$datepayment = empty($conf->global->MAIN_AUTOFILL_DATE) ? (empty($_POST["remonth"]) ?-1 : $datepaye) : 0;
print $form->selectDate($datepayment, '', '', '', '', "add_payment", 1, 1);
print $form->selectDate($datepayment, '', '', '', 0, "add_payment", 1, 1, 0, '', '', $charge->date_ech, '', 1, $langs->trans("DateOfSocialContribution"));
print "</td>";
print '</tr>';

View File

@ -94,11 +94,11 @@ print '</td></tr></table></div><br>';
*/
$sql = "SELECT f.ref, f.rowid, f.total_ttc, f.fk_statut, f.paye, f.type,";
$sql .= " pfd.date_demande, pfd.amount,";
$sql .= " s.nom as name, s.rowid as socid";
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f,";
$sql .= " s.nom as name, s.email, s.rowid as socid, s.tva_intra";
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f,";
$sql .= " ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql .= " , ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd";
$sql .= ", ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd";
$sql .= " WHERE s.rowid = f.fk_soc";
$sql .= " AND f.entity IN (".getEntity('supplier_invoice').")";
$sql .= " AND f.total_ttc > 0";
@ -106,7 +106,9 @@ if (empty($conf->global->WITHDRAWAL_ALLOW_ANY_INVOICE_STATUS))
{
$sql .= " AND f.fk_statut = ".FactureFournisseur::STATUS_VALIDATED;
}
$sql .= " AND pfd.traite = 0 AND pfd.fk_facture_fourn = f.rowid";
$sql .= " AND pfd.traite = 0";
$sql .= " AND pfd.ext_payment_id IS NULL";
$sql .= " AND pfd.fk_facture_fourn = f.rowid";
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
if ($socid) $sql .= " AND f.fk_soc = ".$socid;
@ -133,15 +135,17 @@ if ($resql)
$invoicestatic->type = $obj->type;
$alreadypayed = $invoicestatic->getSommePaiement();
$thirdpartystatic->id = $obj->socid;
$thirdpartystatic->name = $obj->name;
$thirdpartystatic->email = $obj->email;
$thirdpartystatic->tva_intra = $obj->tva_intra;
print '<tr class="oddeven"><td>';
print $invoicestatic->getNomUrl(1, 'withdraw');
print '</td>';
print '<td>';
$thirdpartystatic->id = $obj->socid;
$thirdpartystatic->name = $obj->name;
print $thirdpartystatic->getNomUrl(1, 'customer');
print $thirdpartystatic->getNomUrl(1, 'supplier');
print '</td>';
print '<td class="right">';
@ -190,7 +194,8 @@ if ($result)
print"\n<!-- debut table -->\n";
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><th>'.$langs->trans("LatestBankTransferReceipts", $limit).'</th>';
print '<tr class="liste_titre">';
print '<th>'.$langs->trans("LatestBankTransferReceipts", $limit).'</th>';
print '<th>'.$langs->trans("Date").'</th>';
print '<th class="right">'.$langs->trans("Amount").'</th>';
print '<th class="right">'.$langs->trans("Status").'</th>';
@ -217,7 +222,7 @@ if ($result)
$i++;
}
} else {
print '<tr><td class="opacitymedium">'.$langs->trans("None").'</td></tr>';
print '<tr><td class="opacitymedium" colspan="4">'.$langs->trans("None").'</td></tr>';
}
print "</table></div><br>";

View File

@ -31,10 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.p
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
// Load translation files required by the page
$langs->loadLangs(array('banks', 'categories', 'bills', 'withdrawals'));
if (!$user->rights->prelevement->bons->lire)
accessforbidden();
$langs->loadLangs(array('banks', 'categories', 'bills', 'companies', 'withdrawals'));
// Security check
if ($user->socid > 0) accessforbidden();
@ -44,7 +41,6 @@ $action = GETPOST('action', 'alpha');
$id = GETPOST('id', 'int');
$ref = GETPOST('ref', 'alpha');
$socid = GETPOST('socid', 'int');
$type = GETPOST('type', 'aZ09');
// Load variable for pagination
@ -67,6 +63,13 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be includ
$hookmanager->initHooks(array('directdebitprevcard', 'globalcard', 'directdebitprevlist'));
if (!$user->rights->prelevement->bons->lire && $object->type != 'bank-transfer') {
accessforbidden();
}
if (!$user->rights->paymentbybanktransfer->read && $object->type == 'bank-transfer') {
accessforbidden();
}
/*
* Actions
@ -174,7 +177,7 @@ if ($id > 0 || $ref)
}*/
$linkback = '<a href="'.DOL_URL_ROOT.'/compta/prelevement/bons.php">'.$langs->trans("BackToList").'</a>';
$linkback = '<a href="'.DOL_URL_ROOT.'/compta/prelevement/bons.php'.($object->type != 'bank-transfer' ? '' : '?type=bank-transfer').'">'.$langs->trans("BackToList").'</a>';
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref');
@ -200,7 +203,7 @@ if ($id > 0 || $ref)
print '<tr><td>'.$langs->trans("TransData").'</td><td>';
print dol_print_date($object->date_trans, 'day');
print ' '.$langs->trans("By").' '.$muser->getFullName($langs).'</td></tr>';
print ' <span class="opacitymedium">'.$langs->trans("By").'</span> '.$muser->getFullName($langs).'</td></tr>';
print '<tr><td>'.$langs->trans("TransMetod").'</td><td>';
print $object->methodes_trans[$object->method_trans];
print '</td></tr>';
@ -223,7 +226,9 @@ if ($id > 0 || $ref)
$result = $acc->fetch($conf->global->PRELEVEMENT_ID_BANKACCOUNT);
print '<tr><td class="titlefield">';
print $langs->trans("BankToReceiveWithdraw");
$labelofbankfield = "BankToReceiveWithdraw";
if ($object->type == 'bank-transfer') $labelofbankfield = 'BankToPayCreditTransfer';
print $langs->trans($labelofbankfield);
print '</td>';
print '<td>';
if ($acc->id > 0)
@ -232,9 +237,13 @@ if ($id > 0 || $ref)
print '</tr>';
print '<tr><td class="titlefield">';
print $langs->trans("WithdrawalFile").'</td><td>';
$labelfororderfield = 'WithdrawalFile';
if ($object->type == 'bank-transfer') $labelfororderfield = 'CreditTransferFile';
print $langs->trans($labelfororderfield).'</td><td>';
$relativepath = 'receipts/'.$object->ref.'.xml';
print '<a data-ajax="false" href="'.DOL_URL_ROOT.'/document.php?type=text/plain&amp;modulepart=prelevement&amp;file='.urlencode($relativepath).'">'.$relativepath.'</a>';
$modulepart = 'prelevement';
if ($object->type == 'bank-transfer') $modulepart = 'paymentbybanktransfer';
print '<a data-ajax="false" href="'.DOL_URL_ROOT.'/document.php?type=text/plain&amp;modulepart='.$modulepart.'&amp;file='.urlencode($relativepath).'">'.$relativepath.'</a>';
print '</td></tr></table>';
print '</div>';

View File

@ -28,6 +28,7 @@
require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
@ -118,7 +119,7 @@ class BonPrelevement extends CommonObject
/**
* Add invoice to withdrawal
*
* @param int $facture_id id invoice to add
* @param int $invoice_id id invoice to add
* @param int $client_id id invoice customer
* @param string $client_nom customer name
* @param int $amount amount of invoice
@ -126,14 +127,16 @@ class BonPrelevement extends CommonObject
* @param string $code_guichet code of bank's office
* @param string $number bank account number
* @param string $number_key number key of account number
* @param string $type 'debit-order' or 'bank-transfer'
* @return int >0 if OK, <0 if KO
*/
public function AddFacture($facture_id, $client_id, $client_nom, $amount, $code_banque, $code_guichet, $number, $number_key)
public function AddFacture($invoice_id, $client_id, $client_nom, $amount, $code_banque, $code_guichet, $number, $number_key, $type = 'debit-order')
{
// phpcs:enable
$result = 0;
$line_id = 0;
// Add lines
$result = $this->addline($line_id, $client_id, $client_nom, $amount, $code_banque, $code_guichet, $number, $number_key);
if ($result == 0)
@ -141,10 +144,14 @@ class BonPrelevement extends CommonObject
if ($line_id > 0)
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."prelevement_facture (";
$sql .= "fk_facture";
if ($type != 'bank-transfer') {
$sql .= "fk_facture";
} else {
$sql .= "fk_facture_fourn";
}
$sql .= ",fk_prelevement_lignes";
$sql .= ") VALUES (";
$sql .= $facture_id;
$sql .= $invoice_id;
$sql .= ", ".$line_id;
$sql .= ")";
@ -153,15 +160,15 @@ class BonPrelevement extends CommonObject
$result = 0;
} else {
$result = -1;
dol_syslog(get_class($this)."::AddFacture Erreur $result");
dol_syslog(get_class($this)."::AddFacture Error $result");
}
} else {
$result = -2;
dol_syslog(get_class($this)."::AddFacture Erreur $result");
dol_syslog(get_class($this)."::AddFacture Error $result");
}
} else {
$result = -3;
dol_syslog(get_class($this)."::AddFacture Erreur $result");
dol_syslog(get_class($this)."::AddFacture Error $result");
}
return $result;
@ -276,6 +283,7 @@ class BonPrelevement extends CommonObject
$sql .= ", p.method_trans, p.fk_user_trans";
$sql .= ", p.date_credit as date_credit";
$sql .= ", p.fk_user_credit";
$sql .= ", p.type";
$sql .= ", p.statut as status";
$sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p";
$sql .= " WHERE p.entity IN (".getEntity('invoice').")";
@ -303,6 +311,8 @@ class BonPrelevement extends CommonObject
$this->date_credit = $this->db->jdate($obj->date_credit);
$this->user_credit = $obj->fk_user_credit;
$this->type = $obj->type;
$this->status = $obj->status;
$this->statut = $obj->status; // For backward compatibility
@ -645,7 +655,7 @@ class BonPrelevement extends CommonObject
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Returns amount of withdrawal
* Returns amount waiting for direct debit payment or credit transfer payment
*
* @param string $mode 'direct-debit' or 'bank-transfer'
* @return double <O if KO, Total amount
@ -662,11 +672,19 @@ class BonPrelevement extends CommonObject
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f,";
}
$sql .= " ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd";
$sql .= " WHERE f.fk_statut = 1";
$sql .= " AND f.entity IN (".getEntity('invoice').")";
$sql .= " AND f.rowid = pfd.fk_facture";
$sql .= " WHERE f.entity IN (".getEntity('invoice').")";
if (empty($conf->global->WITHDRAWAL_ALLOW_ANY_INVOICE_STATUS))
{
$sql .= " AND f.fk_statut = ".Facture::STATUS_VALIDATED;
}
if ($mode != 'bank-transfer') {
$sql .= " AND f.rowid = pfd.fk_facture";
} else {
$sql .= " AND f.rowid = pfd.fk_facture_fourn";
}
$sql .= " AND f.paye = 0";
$sql .= " AND pfd.traite = 0";
$sql .= " AND pfd.ext_payment_id IS NULL";
$sql .= " AND f.total_ttc > 0";
$resql = $this->db->query($sql);
@ -699,18 +717,18 @@ class BonPrelevement extends CommonObject
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Get number of invoices to withdrawal
* Get number of invoices to pay
*
* @param string $mode 'direct-debit' or 'bank-transfer'
* @param string $type 'direct-debit' or 'bank-transfer'
* @return int <O if KO, number of invoices if OK
*/
public function NbFactureAPrelever($mode = 'direct-debit')
public function NbFactureAPrelever($type = 'direct-debit')
{
// phpcs:enable
global $conf;
$sql = "SELECT count(f.rowid) as nb";
if ($mode == 'bank-transfer') {
if ($type == 'bank-transfer') {
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f";
} else {
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f";
@ -721,12 +739,13 @@ class BonPrelevement extends CommonObject
{
$sql .= " AND f.fk_statut = ".Facture::STATUS_VALIDATED;
}
if ($mode == 'bank-transfer') {
if ($type == 'bank-transfer') {
$sql .= " AND f.rowid = pfd.fk_facture_fourn";
} else {
$sql .= " AND f.rowid = pfd.fk_facture";
}
$sql .= " AND pfd.traite = 0";
$sql .= " AND pfd.ext_payment_id IS NULL";
$sql .= " AND f.total_ttc > 0";
dol_syslog(get_class($this)."::NbFactureAPrelever");
@ -748,18 +767,19 @@ class BonPrelevement extends CommonObject
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Create a withdraw
* TODO delete params banque and agence when not necesary
* Create a direct debit order or a credit transfer order
* TODO delete params banque and agence when not necessary
*
* @param int $banque dolibarr mysoc bank
* @param int $agence dolibarr mysoc bank office (guichet)
* @param string $mode real=do action, simu=test only
* @param string $format FRST, RCUR or ALL
* @param int $banque dolibarr mysoc bank
* @param int $agence dolibarr mysoc bank office (guichet)
* @param string $mode real=do action, simu=test only
* @param string $format FRST, RCUR or ALL
* @param string $executiondate Date to execute the transfer
* @param int $notrigger Disable triggers
* @return int <0 if KO, nbre of invoice withdrawed if OK
* @param string $type 'direct-debit' or 'bank-transfer'
* @return int <0 if KO, No of invoice included into file if OK
*/
public function Create($banque = 0, $agence = 0, $mode = 'real', $format = 'ALL', $executiondate = '', $notrigger = 0)
public function create($banque = 0, $agence = 0, $mode = 'real', $format = 'ALL', $executiondate = '', $notrigger = 0, $type = 'direct-debit')
{
// phpcs:enable
global $conf, $langs, $user;
@ -769,7 +789,12 @@ class BonPrelevement extends CommonObject
require_once DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php";
require_once DOL_DOCUMENT_ROOT."/societe/class/societe.class.php";
if (empty($format)) return 'ErrorBadParametersForDirectDebitFileCreate';
if ($type != 'bank-transfer') {
if (empty($format)) {
$this->error = 'ErrorBadParametersForDirectDebitFileCreate';
return -1;
}
}
$error = 0;
@ -796,17 +821,26 @@ class BonPrelevement extends CommonObject
$sql .= ", pfd.code_banque, pfd.code_guichet, pfd.number, pfd.cle_rib";
$sql .= ", pfd.amount";
$sql .= ", s.nom as name";
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f";
if ($type != 'bank-transfer') {
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f";
} else {
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f";
}
$sql .= ", ".MAIN_DB_PREFIX."societe as s";
$sql .= ", ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd";
$sql .= " WHERE f.rowid = pfd.fk_facture";
$sql .= " AND f.entity IN (".getEntity('invoice').')';
$sql .= " WHERE f.entity IN (".getEntity('invoice').')';
if ($type != 'bank-transfer') {
$sql .= " AND f.rowid = pfd.fk_facture";
} else {
$sql .= " AND f.rowid = pfd.fk_facture_fourn";
}
$sql .= " AND s.rowid = f.fk_soc";
//if ($banque || $agence) $sql.= " AND s.rowid = sr.fk_soc";
$sql .= " AND f.fk_statut = 1";
$sql .= " AND f.paye = 0";
$sql .= " AND pfd.traite = 0";
$sql .= " AND f.total_ttc > 0";
$sql .= " AND pfd.ext_payment_id IS NULL";
//if ($banque) $sql.= " AND sr.code_banque = '".$conf->global->PRELEVEMENT_CODE_BANQUE."'";
//if ($agence) $sql.= " AND sr.code_guichet = '".$conf->global->PRELEVEMENT_CODE_GUICHET."'";
@ -822,6 +856,12 @@ class BonPrelevement extends CommonObject
{
$row = $this->db->fetch_row($resql);
$factures[$i] = $row; // All fields
if ($row[7] == 0) {
$error++;
dol_syslog(__METHOD__."::Read invoices error Found a null invoice", LOG_ERR);
$this->invoice_in_error[$row[0]] = "Error for invoice id ".$row[0].", found a null amount";
break;
}
$i++;
}
$this->db->free($resql);
@ -837,30 +877,36 @@ class BonPrelevement extends CommonObject
require_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php';
$soc = new Societe($this->db);
// Check RIB
// Check BAN
$i = 0;
dol_syslog(__METHOD__."::Check RIB", LOG_DEBUG);
dol_syslog(__METHOD__."::Check BAN", LOG_DEBUG);
if (count($factures) > 0)
{
foreach ($factures as $key => $fac)
{
$fact = new Facture($this->db);
$resfetch = $fact->fetch($fac[0]);
if ($type != 'bank-transfer') {
$tmpinvoice = new Facture($this->db);
} else {
$tmpinvoice = new FactureFournisseur($this->db);
}
$resfetch = $tmpinvoice->fetch($fac[0]);
if ($resfetch >= 0) // Field 0 of $fac is rowid of invoice
{
if ($soc->fetch($fact->socid) >= 0)
if ($soc->fetch($tmpinvoice->socid) >= 0)
{
$bac = new CompanyBankAccount($this->db);
$bac->fetch(0, $soc->id);
if ($format == 'FRST' && $bac->frstrecur != 'FRST')
{
continue;
}
if ($format == 'RCUR' && ($bac->frstrecur != 'RCUR' && $bac->frstrecur != 'RECUR'))
{
continue;
if ($type != 'bank-transfer') {
if ($format == 'FRST' && $bac->frstrecur != 'FRST')
{
continue;
}
if ($format == 'RCUR' && ($bac->frstrecur != 'RCUR' && $bac->frstrecur != 'RECUR'))
{
continue;
}
}
if ($bac->verif() >= 1)
@ -871,26 +917,26 @@ class BonPrelevement extends CommonObject
$i++;
//dol_syslog(__METHOD__."::RIB is ok", LOG_DEBUG);
} else {
dol_syslog(__METHOD__."::Check RIB Error on default bank number IBAN/BIC for thirdparty reported by verif() ".$fact->socid." ".$soc->name, LOG_WARNING);
$this->invoice_in_error[$fac[0]] = "Error on default bank number IBAN/BIC for invoice ".$fact->getNomUrl(0)." for thirdparty ".$soc->getNomUrl(0);
$this->thirdparty_in_error[$soc->id] = "Error on default bank number IBAN/BIC for invoice ".$fact->getNomUrl(0)." for thirdparty ".$soc->getNomUrl(0);
dol_syslog(__METHOD__."::Check BAN Error on default bank number IBAN/BIC for thirdparty reported by verif() ".$tmpinvoice->socid." ".$soc->name, LOG_WARNING);
$this->invoice_in_error[$fac[0]] = "Error on default bank number IBAN/BIC for invoice ".$tmpinvoice->getNomUrl(0)." for thirdparty ".$soc->getNomUrl(0);
$this->thirdparty_in_error[$soc->id] = "Error on default bank number IBAN/BIC for invoice ".$tmpinvoice->getNomUrl(0)." for thirdparty ".$soc->getNomUrl(0);
}
} else {
dol_syslog(__METHOD__."::Check RIB Failed to read company", LOG_WARNING);
dol_syslog(__METHOD__."::Check BAN Failed to read company", LOG_WARNING);
}
} else {
dol_syslog(__METHOD__."::Check RIB Failed to read invoice", LOG_WARNING);
dol_syslog(__METHOD__."::Check BAN Failed to read invoice", LOG_WARNING);
}
}
} else {
dol_syslog(__METHOD__."::Check RIB No invoice to process", LOG_WARNING);
dol_syslog(__METHOD__."::Check BAN No invoice to process", LOG_WARNING);
}
}
$ok = 0;
// Withdraw invoices in factures_prev array
$out = count($factures_prev)." invoices will be withdrawn.";
$out = count($factures_prev)." invoices will be included.";
//print $out."\n";
dol_syslog($out);
@ -918,14 +964,14 @@ class BonPrelevement extends CommonObject
{
/*
* We are in real mode.
* We create withdraw receipt and build withdraw into disk
* We create order and build file into disk
*/
$this->db->begin();
$now = dol_now();
/*
* Traitements
* Process order generation
*/
if (!$error)
{
@ -937,7 +983,7 @@ class BonPrelevement extends CommonObject
$sql .= " AND entity = ".$conf->entity;
$sql .= " ORDER BY ref DESC LIMIT 1";
dol_syslog(get_class($this)."::Create sql=".$sql, LOG_DEBUG);
dol_syslog(get_class($this)."::create sql=".$sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
@ -945,18 +991,23 @@ class BonPrelevement extends CommonObject
$row = $this->db->fetch_row($resql);
$ref = "T".$ref.str_pad(dol_substr("00".intval($row[0]) + 1, 0, 2), 2, "0", STR_PAD_LEFT);
$dir = $conf->prelevement->dir_output.'/receipts';
if ($type != 'bank-transfer') {
$dir = $conf->prelevement->dir_output.'/receipts';
} else {
$dir = $conf->paymentbybanktransfer->dir_output.'/receipts';
}
if (!is_dir($dir)) dol_mkdir($dir);
$this->filename = $dir.'/'.$ref.'.xml';
// Create withdraw receipt in database
$sql = "INSERT INTO ".MAIN_DB_PREFIX."prelevement_bons (";
$sql .= " ref, entity, datec";
$sql .= " ref, entity, datec, type";
$sql .= ") VALUES (";
$sql .= "'".$this->db->escape($ref)."'";
$sql .= ", ".$conf->entity;
$sql .= ", '".$this->db->idate($now)."'";
$sql .= ", '".($type == 'bank-transfer' ? 'bank-transfer' : 'debit-order')."'";
$sql .= ")";
$resql = $this->db->query($sql);
@ -987,10 +1038,13 @@ class BonPrelevement extends CommonObject
// Fetch invoice
$fact = new Facture($this->db);
$fact->fetch($fac[0]);
/*
* Add standing order
*
*
* $fac[0] : invoice_id
* $fac[1] : ???
* $fac[2] : third party id
* $fac[3] : banque
* $fac[4] : guichet
* $fac[5] : number
@ -999,7 +1053,8 @@ class BonPrelevement extends CommonObject
* $fac[8] : client nom
* $fac[2] : client id
*/
$ri = $this->AddFacture($fac[0], $fac[2], $fac[8], $fac[7], $fac[3], $fac[4], $fac[5], $fac[6]);
$ri = $this->AddFacture($fac[0], $fac[2], $fac[8], $fac[7], $fac[3], $fac[4], $fac[5], $fac[6], $type);
if ($ri <> 0)
{
$error++;
@ -1012,13 +1067,12 @@ class BonPrelevement extends CommonObject
$sql .= ", fk_prelevement_bons = ".$this->id;
$sql .= " WHERE rowid = ".$fac[1];
dol_syslog(__METHOD__."::Update Orders::Sql=".$sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql)
{
$error++;
dol_syslog(__METHOD__."::Update Orders::Error=".$this->db->error(), LOG_ERR);
dol_syslog(__METHOD__."::Update Error=".$this->db->error(), LOG_ERR);
}
}
}
@ -1027,11 +1081,10 @@ class BonPrelevement extends CommonObject
if (!$error)
{
/*
* Create direct debit order in a XML file
* Create file of direct debit order or credit transfer into a XML file
*/
dol_syslog(__METHOD__."::Init withdraw receipt for ".count($factures_prev)." invoices", LOG_DEBUG);
dol_syslog(__METHOD__."::Init direct debit or credit transfer file for ".count($factures_prev)." invoices", LOG_DEBUG);
if (count($factures_prev) > 0)
{
@ -1057,15 +1110,16 @@ class BonPrelevement extends CommonObject
$this->factures = $factures_prev_id;
$this->context['factures_prev'] = $factures_prev;
// Generation of SEPA file $this->filename
$this->generate($format, $executiondate);
// Generation of direct debit or credti transfer file $this->filename (May be a SEPA file for european countries)
// This also set the property $this->total with amount that is included into file
$result = $this->generate($format, $executiondate, $type);
}
dol_syslog(__METHOD__."::End withdraw receipt, file ".$this->filename, LOG_DEBUG);
}
//var_dump($factures_prev);exit;
/*
* Update total
* Update total defined after generation of file
*/
$sql = "UPDATE ".MAIN_DB_PREFIX."prelevement_bons";
$sql .= " SET amount = ".price2num($this->total);
@ -1081,8 +1135,13 @@ class BonPrelevement extends CommonObject
if (!$error && !$notrigger)
{
$triggername = 'DIRECT_DEBIT_ORDER_CREATE';
if ($type != 'bank-transfer') {
$triggername = 'CREDIT_TRANSFER_ORDER_CREATE';
}
// Call trigger
$result = $this->call_trigger('DIRECT_DEBIT_ORDER_CREATE', $user);
$result = $this->call_trigger($triggername, $user);
if ($result < 0) $error++;
// End call triggers
}
@ -1332,17 +1391,18 @@ class BonPrelevement extends CommonObject
/**
* Generate a withdrawal file.
* Generate a direct debit or credit transfer file.
* Generation Formats:
* - Europe: SEPA (France: CFONB no more supported, Spain: AEB19 if external module EsAEB is enabled)
* - Others countries: Warning message
* File is generated with name this->filename
*
* @param string $format FRST, RCUR or ALL
* @param string $executiondate Date to execute transfer
* @return int 0 if OK, <0 if KO
* @param string $format FRST, RCUR or ALL
* @param string $executiondate Date to execute transfer
* @param string $type 'direct-debit' or 'credit-transfer'
* @return int >=0 if OK, <0 if KO
*/
public function generate($format = 'ALL', $executiondate = '')
public function generate($format = 'ALL', $executiondate = '', $type = 'direct-debit')
{
global $conf, $langs, $mysoc;
@ -1350,7 +1410,7 @@ class BonPrelevement extends CommonObject
$result = 0;
dol_syslog(get_class($this)."::generate build file ".$this->filename);
dol_syslog(get_class($this)."::generate build file=".$this->filename." type=".$type);
$this->file = fopen($this->filename, "w");
if (empty($this->file))
@ -1360,159 +1420,295 @@ class BonPrelevement extends CommonObject
}
$found = 0;
$this->total = 0;
// Build file for European countries
if ($mysoc->isInEEC())
{
$found++;
/**
* SECTION CREATION FICHIER SEPA
*/
// SEPA Initialisation
$CrLf = "\n";
if ($type == 'bank-transfer') {
/**
* SECTION CREATION FICHIER SEPA - CREDIT TRANSFER
*/
// SEPA Initialisation
$CrLf = "\n";
$now = dol_now();
$now = dol_now();
$dateTime_ECMA = dol_print_date($now, '%Y-%m-%dT%H:%M:%S');
$dateTime_ECMA = dol_print_date($now, '%Y-%m-%dT%H:%M:%S');
$date_actu = $now;
if (!empty($executiondate)) $date_actu = $executiondate;
$date_actu = $now;
if (!empty($executiondate)) $date_actu = $executiondate;
$dateTime_YMD = dol_print_date($date_actu, '%Y%m%d');
$dateTime_YMDHMS = dol_print_date($date_actu, '%Y%m%d%H%M%S');
$fileDebiteurSection = '';
$fileEmetteurSection = '';
$i = 0;
$this->total = 0;
$dateTime_YMD = dol_print_date($date_actu, '%Y%m%d');
$dateTime_YMDHMS = dol_print_date($date_actu, '%Y%m%d%H%M%S');
$fileCrediteurSection = '';
$fileEmetteurSection = '';
$i = 0;
/*
* section Debiteur (sepa Debiteurs bloc lines)
*/
/*
* Section Creditor (sepa Crediteurs bloc lines)
*/
$sql = "SELECT soc.code_client as code, soc.address, soc.zip, soc.town, c.code as country_code,";
$sql .= " pl.client_nom as nom, pl.code_banque as cb, pl.code_guichet as cg, pl.number as cc, pl.amount as somme,";
$sql .= " f.ref as fac, pf.fk_facture as idfac, rib.datec, rib.iban_prefix as iban, rib.bic as bic, rib.rowid as drum, rib.rum, rib.date_rum";
$sql .= " FROM";
$sql .= " ".MAIN_DB_PREFIX."prelevement_lignes as pl,";
$sql .= " ".MAIN_DB_PREFIX."facture as f,";
$sql .= " ".MAIN_DB_PREFIX."prelevement_facture as pf,";
$sql .= " ".MAIN_DB_PREFIX."societe as soc,";
$sql .= " ".MAIN_DB_PREFIX."c_country as c,";
$sql .= " ".MAIN_DB_PREFIX."societe_rib as rib";
$sql .= " WHERE pl.fk_prelevement_bons = ".$this->id;
$sql .= " AND pl.rowid = pf.fk_prelevement_lignes";
$sql .= " AND pf.fk_facture = f.rowid";
$sql .= " AND soc.fk_pays = c.rowid";
$sql .= " AND soc.rowid = f.fk_soc";
$sql .= " AND rib.fk_soc = f.fk_soc";
$sql .= " AND rib.default_rib = 1";
$sql .= " AND rib.type = 'ban'";
//print $sql;
$sql = "SELECT soc.code_client as code, soc.address, soc.zip, soc.town, c.code as country_code,";
$sql .= " pl.client_nom as nom, pl.code_banque as cb, pl.code_guichet as cg, pl.number as cc, pl.amount as somme,";
$sql .= " f.ref as fac, pf.fk_facture as idfac, rib.datec, rib.iban_prefix as iban, rib.bic as bic, rib.rowid as drum, rib.rum, rib.date_rum";
$sql .= " FROM";
$sql .= " ".MAIN_DB_PREFIX."prelevement_lignes as pl,";
$sql .= " ".MAIN_DB_PREFIX."facture_fourn as f,";
$sql .= " ".MAIN_DB_PREFIX."prelevement_facture as pf,";
$sql .= " ".MAIN_DB_PREFIX."societe as soc,";
$sql .= " ".MAIN_DB_PREFIX."c_country as c,";
$sql .= " ".MAIN_DB_PREFIX."societe_rib as rib";
$sql .= " WHERE pl.fk_prelevement_bons = ".$this->id;
$sql .= " AND pl.rowid = pf.fk_prelevement_lignes";
$sql .= " AND pf.fk_facture_fourn = f.rowid";
$sql .= " AND soc.fk_pays = c.rowid";
$sql .= " AND soc.rowid = f.fk_soc";
$sql .= " AND rib.fk_soc = f.fk_soc";
$sql .= " AND rib.default_rib = 1";
$sql .= " AND rib.type = 'ban'";
//print $sql;
// Define $fileDebiteurSection. One section DrctDbtTxInf per invoice.
$resql = $this->db->query($sql);
if ($resql)
{
$num = $this->db->num_rows($resql);
while ($i < $num)
// Define $fileCrediteurSection. One section DrctDbtTxInf per invoice.
$resql = $this->db->query($sql);
if ($resql)
{
$obj = $this->db->fetch_object($resql);
$daterum = (!empty($obj->date_rum)) ? $this->db->jdate($obj->date_rum) : $this->db->jdate($obj->datec);
$fileDebiteurSection .= $this->EnregDestinataireSEPA($obj->code, $obj->nom, $obj->address, $obj->zip, $obj->town, $obj->country_code, $obj->cb, $obj->cg, $obj->cc, $obj->somme, $obj->fac, $obj->idfac, $obj->iban, $obj->bic, $daterum, $obj->drum, $obj->rum);
$this->total = $this->total + $obj->somme;
$i++;
$num = $this->db->num_rows($resql);
while ($i < $num)
{
$obj = $this->db->fetch_object($resql);
$daterum = (!empty($obj->date_rum)) ? $this->db->jdate($obj->date_rum) : $this->db->jdate($obj->datec);
$fileCrediteurSection .= $this->EnregDestinataireSEPA($obj->code, $obj->nom, $obj->address, $obj->zip, $obj->town, $obj->country_code, $obj->cb, $obj->cg, $obj->cc, $obj->somme, $obj->fac, $obj->idfac, $obj->iban, $obj->bic, $daterum, $obj->drum, $obj->rum);
$this->total = $this->total + $obj->somme;
$i++;
}
$nbtotalDrctDbtTxInf = $i;
} else {
fputs($this->file, 'ERROR CREDITOR '.$sql.$CrLf); // CREDITORS = Suppliers
$result = -2;
}
$nbtotalDrctDbtTxInf = $i;
} else {
fputs($this->file, 'ERROR DEBITOR '.$sql.$CrLf); // DEBITOR = Customers
$result = -2;
}
// Define $fileEmetteurSection. Start of bloc PmtInf. Will contains all DrctDbtTxInf
if ($result != -2)
{
$fileEmetteurSection .= $this->EnregEmetteurSEPA($conf, $date_actu, $nbtotalDrctDbtTxInf, $this->total, $CrLf, $format);
} else {
fputs($this->file, 'ERROR CREDITOR'.$CrLf); // CREDITOR = My company
}
// Define $fileEmetteurSection. Start of bloc PmtInf. Will contains all $nbtotalDrctDbtTxInf
if ($result != -2)
{
$fileEmetteurSection .= $this->EnregEmetteurSEPA($conf, $date_actu, $nbtotalDrctDbtTxInf, $this->total, $CrLf, $format);
}
/**
* SECTION CREATION SEPA FILE
*/
// SEPA File Header
fputs($this->file, '<'.'?xml version="1.0" encoding="UTF-8" standalone="yes"?'.'>'.$CrLf);
fputs($this->file, '<Document xmlns="urn:iso:std:iso:20022:tech:xsd:pain.008.001.02" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">'.$CrLf);
fputs($this->file, ' <CstmrDrctDbtInitn>'.$CrLf);
// SEPA Group header
fputs($this->file, ' <GrpHdr>'.$CrLf);
fputs($this->file, ' <MsgId>'.('PREL'.$dateTime_YMD.'/REF'.$this->id).'</MsgId>'.$CrLf);
fputs($this->file, ' <CreDtTm>'.$dateTime_ECMA.'</CreDtTm>'.$CrLf);
fputs($this->file, ' <NbOfTxs>'.$i.'</NbOfTxs>'.$CrLf);
fputs($this->file, ' <CtrlSum>'.$this->total.'</CtrlSum>'.$CrLf);
fputs($this->file, ' <InitgPty>'.$CrLf);
fputs($this->file, ' <Nm>'.strtoupper(dol_string_unaccent($this->raison_sociale)).'</Nm>'.$CrLf);
fputs($this->file, ' <Id>'.$CrLf);
fputs($this->file, ' <PrvtId>'.$CrLf);
fputs($this->file, ' <Othr>'.$CrLf);
fputs($this->file, ' <Id>'.$conf->global->PRELEVEMENT_ICS.'</Id>'.$CrLf);
fputs($this->file, ' </Othr>'.$CrLf);
fputs($this->file, ' </PrvtId>'.$CrLf);
fputs($this->file, ' </Id>'.$CrLf);
fputs($this->file, ' </InitgPty>'.$CrLf);
fputs($this->file, ' </GrpHdr>'.$CrLf);
// SEPA File Emetteur
if ($result != -2)
{ fputs($this-> file, $fileEmetteurSection); }
// SEPA File Debiteurs
if ($result != -2)
{ fputs($this-> file, $fileDebiteurSection); }
// SEPA FILE FOOTER
fputs($this->file, ' </PmtInf>'.$CrLf);
fputs($this->file, ' </CstmrDrctDbtInitn>'.$CrLf);
fputs($this->file, '</Document>'.$CrLf);
/**
* SECTION CREATION SEPA FILE - CREDTI TRANSFER - ISO200022
*/
// SEPA File Header
fputs($this->file, '<'.'?xml version="1.0" encoding="UTF-8" standalone="yes"?'.'>'.$CrLf);
fputs($this->file, '<Document xmlns="urn:iso:std:iso:20022:tech:xsd:pain.001.001.03" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">'.$CrLf);
fputs($this->file, ' <CstmrCdtTrfInitn>'.$CrLf);
// SEPA Group header
fputs($this->file, ' <GrpHdr>'.$CrLf);
fputs($this->file, ' <MsgId>'.('CREDTRANS'.$dateTime_YMD.'/REF'.$this->id).'</MsgId>'.$CrLf);
fputs($this->file, ' <CreDtTm>'.$dateTime_ECMA.'</CreDtTm>'.$CrLf);
fputs($this->file, ' <NbOfTxs>'.$i.'</NbOfTxs>'.$CrLf);
fputs($this->file, ' <CtrlSum>'.$this->total.'</CtrlSum>'.$CrLf);
fputs($this->file, ' <InitgPty>'.$CrLf);
fputs($this->file, ' <Nm>'.strtoupper(dol_string_unaccent($this->raison_sociale)).'</Nm>'.$CrLf);
fputs($this->file, ' <Id>'.$CrLf);
fputs($this->file, ' <PrvtId>'.$CrLf);
fputs($this->file, ' <Othr>'.$CrLf);
fputs($this->file, ' <Id>'.$conf->global->PRELEVEMENT_ICS.'</Id>'.$CrLf);
fputs($this->file, ' </Othr>'.$CrLf);
fputs($this->file, ' </PrvtId>'.$CrLf);
fputs($this->file, ' </Id>'.$CrLf);
fputs($this->file, ' </InitgPty>'.$CrLf);
fputs($this->file, ' </GrpHdr>'.$CrLf);
// SEPA File Emetteur (mycompany)
if ($result != -2)
{ fputs($this-> file, $fileEmetteurSection); }
// SEPA File Creditors
if ($result != -2)
{ fputs($this-> file, $fileCrediteurSection); }
// SEPA FILE FOOTER
fputs($this->file, ' </PmtInf>'.$CrLf);
fputs($this->file, ' </CstmrCdtTrfInitn>'.$CrLf);
fputs($this->file, '</Document>'.$CrLf);
} else {
/**
* SECTION CREATION FICHIER SEPA
*/
// SEPA Initialisation
$CrLf = "\n";
$now = dol_now();
$dateTime_ECMA = dol_print_date($now, '%Y-%m-%dT%H:%M:%S');
$date_actu = $now;
if (!empty($executiondate)) $date_actu = $executiondate;
$dateTime_YMD = dol_print_date($date_actu, '%Y%m%d');
$dateTime_YMDHMS = dol_print_date($date_actu, '%Y%m%d%H%M%S');
$fileDebiteurSection = '';
$fileEmetteurSection = '';
$i = 0;
/*
* Section Debitor (sepa Debiteurs bloc lines)
*/
$sql = "SELECT soc.code_client as code, soc.address, soc.zip, soc.town, c.code as country_code,";
$sql .= " pl.client_nom as nom, pl.code_banque as cb, pl.code_guichet as cg, pl.number as cc, pl.amount as somme,";
$sql .= " f.ref as fac, pf.fk_facture as idfac, rib.datec, rib.iban_prefix as iban, rib.bic as bic, rib.rowid as drum, rib.rum, rib.date_rum";
$sql .= " FROM";
$sql .= " ".MAIN_DB_PREFIX."prelevement_lignes as pl,";
$sql .= " ".MAIN_DB_PREFIX."facture as f,";
$sql .= " ".MAIN_DB_PREFIX."prelevement_facture as pf,";
$sql .= " ".MAIN_DB_PREFIX."societe as soc,";
$sql .= " ".MAIN_DB_PREFIX."c_country as c,";
$sql .= " ".MAIN_DB_PREFIX."societe_rib as rib";
$sql .= " WHERE pl.fk_prelevement_bons = ".$this->id;
$sql .= " AND pl.rowid = pf.fk_prelevement_lignes";
$sql .= " AND pf.fk_facture = f.rowid";
$sql .= " AND soc.fk_pays = c.rowid";
$sql .= " AND soc.rowid = f.fk_soc";
$sql .= " AND rib.fk_soc = f.fk_soc";
$sql .= " AND rib.default_rib = 1";
$sql .= " AND rib.type = 'ban'";
//print $sql;
// Define $fileDebiteurSection. One section DrctDbtTxInf per invoice.
$resql = $this->db->query($sql);
if ($resql)
{
$num = $this->db->num_rows($resql);
while ($i < $num)
{
$obj = $this->db->fetch_object($resql);
$daterum = (!empty($obj->date_rum)) ? $this->db->jdate($obj->date_rum) : $this->db->jdate($obj->datec);
$fileDebiteurSection .= $this->EnregDestinataireSEPA($obj->code, $obj->nom, $obj->address, $obj->zip, $obj->town, $obj->country_code, $obj->cb, $obj->cg, $obj->cc, $obj->somme, $obj->fac, $obj->idfac, $obj->iban, $obj->bic, $daterum, $obj->drum, $obj->rum);
$this->total = $this->total + $obj->somme;
$i++;
}
$nbtotalDrctDbtTxInf = $i;
} else {
fputs($this->file, 'ERROR DEBITOR '.$sql.$CrLf); // DEBITOR = Customers
$result = -2;
}
// Define $fileEmetteurSection. Start of bloc PmtInf. Will contains all $nbtotalDrctDbtTxInf
if ($result != -2)
{
$fileEmetteurSection .= $this->EnregEmetteurSEPA($conf, $date_actu, $nbtotalDrctDbtTxInf, $this->total, $CrLf, $format);
}
/**
* SECTION CREATION SEPA FILE - ISO200022
*/
// SEPA File Header
fputs($this->file, '<'.'?xml version="1.0" encoding="UTF-8" standalone="yes"?'.'>'.$CrLf);
fputs($this->file, '<Document xmlns="urn:iso:std:iso:20022:tech:xsd:pain.008.001.02" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">'.$CrLf);
fputs($this->file, ' <CstmrDrctDbtInitn>'.$CrLf);
// SEPA Group header
fputs($this->file, ' <GrpHdr>'.$CrLf);
fputs($this->file, ' <MsgId>'.('PREL'.$dateTime_YMD.'/REF'.$this->id).'</MsgId>'.$CrLf);
fputs($this->file, ' <CreDtTm>'.$dateTime_ECMA.'</CreDtTm>'.$CrLf);
fputs($this->file, ' <NbOfTxs>'.$i.'</NbOfTxs>'.$CrLf);
fputs($this->file, ' <CtrlSum>'.$this->total.'</CtrlSum>'.$CrLf);
fputs($this->file, ' <InitgPty>'.$CrLf);
fputs($this->file, ' <Nm>'.strtoupper(dol_string_unaccent($this->raison_sociale)).'</Nm>'.$CrLf);
fputs($this->file, ' <Id>'.$CrLf);
fputs($this->file, ' <PrvtId>'.$CrLf);
fputs($this->file, ' <Othr>'.$CrLf);
fputs($this->file, ' <Id>'.$conf->global->PRELEVEMENT_ICS.'</Id>'.$CrLf);
fputs($this->file, ' </Othr>'.$CrLf);
fputs($this->file, ' </PrvtId>'.$CrLf);
fputs($this->file, ' </Id>'.$CrLf);
fputs($this->file, ' </InitgPty>'.$CrLf);
fputs($this->file, ' </GrpHdr>'.$CrLf);
// SEPA File Emetteur
if ($result != -2)
{ fputs($this-> file, $fileEmetteurSection); }
// SEPA File Debiteurs
if ($result != -2)
{ fputs($this-> file, $fileDebiteurSection); }
// SEPA FILE FOOTER
fputs($this->file, ' </PmtInf>'.$CrLf);
fputs($this->file, ' </CstmrDrctDbtInitn>'.$CrLf);
fputs($this->file, '</Document>'.$CrLf);
}
}
// Build file for Other Countries with unknow format
if (!$found)
{
$this->total = 0;
$sql = "SELECT pl.amount";
$sql .= " FROM";
$sql .= " ".MAIN_DB_PREFIX."prelevement_lignes as pl,";
$sql .= " ".MAIN_DB_PREFIX."facture as f,";
$sql .= " ".MAIN_DB_PREFIX."prelevement_facture as pf";
$sql .= " WHERE pl.fk_prelevement_bons = ".$this->id;
$sql .= " AND pl.rowid = pf.fk_prelevement_lignes";
$sql .= " AND pf.fk_facture = f.rowid";
if ($type == 'bank-transfer') {
$sql = "SELECT pl.amount";
$sql .= " FROM";
$sql .= " ".MAIN_DB_PREFIX."prelevement_lignes as pl,";
$sql .= " ".MAIN_DB_PREFIX."facture_fourn as f,";
$sql .= " ".MAIN_DB_PREFIX."prelevement_facture as pf";
$sql .= " WHERE pl.fk_prelevement_bons = ".$this->id;
$sql .= " AND pl.rowid = pf.fk_prelevement_lignes";
$sql .= " AND pf.fk_facture_fourn = f.rowid";
//Lines
$i = 0;
$resql = $this->db->query($sql);
if ($resql)
{
$num = $this->db->num_rows($resql);
while ($i < $num)
// Lines
$i = 0;
$resql = $this->db->query($sql);
if ($resql)
{
$obj = $this->db->fetch_object($resql);
$this->total = $this->total + $obj->amount;
$i++;
$num = $this->db->num_rows($resql);
while ($i < $num)
{
$obj = $this->db->fetch_object($resql);
$this->total = $this->total + $obj->amount;
// TODO Write record into file
$i++;
}
} else {
$result = -2;
}
} else {
$result = -2;
$sql = "SELECT pl.amount";
$sql .= " FROM";
$sql .= " ".MAIN_DB_PREFIX."prelevement_lignes as pl,";
$sql .= " ".MAIN_DB_PREFIX."facture as f,";
$sql .= " ".MAIN_DB_PREFIX."prelevement_facture as pf";
$sql .= " WHERE pl.fk_prelevement_bons = ".$this->id;
$sql .= " AND pl.rowid = pf.fk_prelevement_lignes";
$sql .= " AND pf.fk_facture = f.rowid";
// Lines
$i = 0;
$resql = $this->db->query($sql);
if ($resql)
{
$num = $this->db->num_rows($resql);
while ($i < $num)
{
$obj = $this->db->fetch_object($resql);
$this->total = $this->total + $obj->amount;
// TODO Write record into file
$i++;
}
} else {
$result = -2;
}
}
$langs->load('withdrawals');
// TODO Add here code to generate a generic file
fputs($this->file, $langs->trans('WithdrawalFileNotCapable', $mysoc->country_code));
fputs($this->file, $langs->transnoentitiesnoconv('WithdrawalFileNotCapable', $mysoc->country_code));
}
fclose($this->file);
if (!empty($conf->global->MAIN_UMASK))
if (!empty($conf->global->MAIN_UMASK)) {
@chmod($this->file, octdec($conf->global->MAIN_UMASK));
return $result;
}
return $result;
}

View File

@ -1,11 +1,11 @@
<?php
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2010-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2010-2020 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2010-2012 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2019 Markus Welters <markus@welters.de>
* Copyright (C) 2019 Markus Welters <markus@welters.de>
*
* 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
@ -24,7 +24,7 @@
/**
* \file htdocs/compta/prelevement/create.php
* \ingroup prelevement
* \brief Prelevement creation page
* \brief Page to create a direct debit order or a credit transfer order
*/
require '../../main.inc.php';
@ -77,11 +77,17 @@ if (empty($reshook))
}
if ($action == 'create')
{
// $conf->global->PRELEVEMENT_CODE_BANQUE and $conf->global->PRELEVEMENT_CODE_GUICHET should be empty
$delayindays = 0;
if ($type != 'bank-transfer') {
$conf->global->PRELEVEMENT_ADDDAYS;
} else {
$conf->global->PAYMENTBYBANKTRANSFER_ADDDAYS;
}
$bprev = new BonPrelevement($db);
$executiondate = dol_mktime(0, 0, 0, GETPOST('remonth'), (GETPOST('reday') + $conf->global->PRELEVEMENT_ADDDAYS), GETPOST('reyear'));
$executiondate = dol_mktime(0, 0, 0, GETPOST('remonth', 'int'), (GETPOST('reday', 'int') + $delayindays), GETPOST('reyear', 'int'));
$result = $bprev->create($conf->global->PRELEVEMENT_CODE_BANQUE, $conf->global->PRELEVEMENT_CODE_GUICHET, $mode, $format, $executiondate);
// $conf->global->PRELEVEMENT_CODE_BANQUE and $conf->global->PRELEVEMENT_CODE_GUICHET should be empty (we don't use them anymore)
$result = $bprev->create($conf->global->PRELEVEMENT_CODE_BANQUE, $conf->global->PRELEVEMENT_CODE_GUICHET, $mode, $format, $executiondate, 0, $type);
if ($result < 0)
{
setEventMessages($bprev->error, $bprev->errors, 'errors');
@ -95,7 +101,11 @@ if (empty($reshook))
$mesg .= '<span class="warning">'.$val."</span><br>\n";
}
} else {
setEventMessages($langs->trans("DirectDebitOrderCreated", $bprev->getNomUrl(1)), null);
if ($type != 'bank-transfer') {
setEventMessages($langs->trans("DirectDebitOrderCreated", $bprev->getNomUrl(1)), null);
} else {
setEventMessages($langs->trans("CreditTransferOrderCreated", $bprev->getNomUrl(1)), null);
}
header("Location: ".DOL_URL_ROOT.'/compta/prelevement/card.php?id='.$bprev->id);
exit;
@ -111,7 +121,11 @@ if (empty($reshook))
$form = new Form($db);
$thirdpartystatic = new Societe($db);
$invoicestatic = new Facture($db);
if ($type != 'bank-transfer') {
$invoicestatic = new Facture($db);
} else {
$invoicestatic = new FactureFournisseur($db);
}
$bprev = new BonPrelevement($db);
llxHeader('', $langs->trans("NewStandingOrder"));
@ -174,15 +188,25 @@ print '<div class="tabsAction">'."\n";
print '<form action="'.$_SERVER['PHP_SELF'].'?action=create" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="type" value="'.$type.'">';
if ($nb) {
if ($pricetowithdraw) {
print $langs->trans('ExecutionDate').' ';
print $form->selectDate();
$datere = dol_mktime(0, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
print $form->selectDate($datere, 're');
if ($mysoc->isInEEC()) {
$title = $langs->trans("CreateForSepa");
if ($type == 'bank-transfer') {
$title = $langs->trans("CreateSepaFileForPaymentByBankTransfer");
}
print '<select name="format"><option value="FRST">'.$langs->trans('SEPAFRST').'</option><option value="RCUR">'.$langs->trans('SEPARCUR').'</option></select>';
if ($type != 'bank-transfer') {
print '<select name="format">';
print '<option value="FRST"'.(GETPOST('format', 'aZ09') == 'FRST' ? ' selected="selected"' : '').'>'.$langs->trans('SEPAFRST').'</option>';
print '<option value="RCUR"'.(GETPOST('format', 'aZ09') == 'RCUR' ? ' selected="selected"' : '').'>'.$langs->trans('SEPARCUR').'</option>';
print '</select>';
}
print '<input class="butAction" type="submit" value="'.$title.'"/>';
} else {
$title = $langs->trans("CreateAll");
@ -248,8 +272,10 @@ if (empty($conf->global->WITHDRAWAL_ALLOW_ANY_INVOICE_STATUS))
{
$sql .= " AND f.fk_statut = ".Facture::STATUS_VALIDATED;
}
$sql .= " AND f.total_ttc > 0";
//$sql .= " AND pfd.amount > 0";
$sql .= " AND f.total_ttc > 0"; // Avoid credit notes
$sql .= " AND pfd.traite = 0";
$sql .= " AND pfd.ext_payment_id IS NULL";
if ($type == 'bank-transfer') {
$sql .= " AND pfd.fk_facture_fourn = f.rowid";
} else {
@ -295,9 +321,14 @@ if ($resql)
}
print_barre_liste($title, $page, $_SERVER['PHP_SELF'], $param, '', '', '', $num, $nbtotalofrecords, 'bill', 0, '', '', $limit);
$tradinvoice = "Invoice";
if ($type == 'bank-transfer') {
$tradinvoice = "SupplierInvoice";
}
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Invoice").'</td>';
print '<td>'.$langs->trans($tradinvoice).'</td>';
print '<td>'.$langs->trans("ThirdParty").'</td>';
print '<td>'.$langs->trans("RIB").'</td>';
print '<td>'.$langs->trans("RUM").'</td>';
@ -341,7 +372,9 @@ if ($resql)
print '<td>';
print $thirdpartystatic->display_rib('rum');
$format = $thirdpartystatic->display_rib('format');
if ($format) print ' ('.$format.')';
if ($type != 'bank-transfer') {
if ($format) print ' ('.$format.')';
}
print '</td>';
// Amount
print '<td class="right">';

View File

@ -190,6 +190,14 @@ print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
$param = '';
$label = 'NewStandingOrder';
$typefilter = '';
if ($type == 'bank-transfer') {
$label = 'NewPaymentByBankTransfer';
$typefilter = 'type='.$type;
}
$newcardbutton .= dolGetButtonTitle($langs->trans($label), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/compta/prelevement/create.php'.($typefilter ? '?'.$typefilter : ''));
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'generic', 0, $newcardbutton, '', $limit);
print '<table class="liste centpercent">';

View File

@ -32,21 +32,21 @@ require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
// Load translation files required by the page
$langs->loadLangs(array('banks', 'categories', 'companies', 'withdrawals', 'bills'));
$langs->loadLangs(array('banks', 'categories', 'bills', 'companies', 'withdrawals'));
// Securite acces client
if ($user->socid > 0) accessforbidden();
// Get supervariables
$id = GETPOST('id', 'int');
$socid = GETPOST('socid', 'int');
$ref = GETPOST('ref', 'alpha');
$socid = GETPOST('socid', 'int');
$type = GETPOST('type', 'aZ09');
// Load variable for pagination
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
$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
$offset = $limit * $page;
@ -57,6 +57,17 @@ if (!$sortorder) $sortorder = 'DESC';
$object = new BonPrelevement($db);
// 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
$hookmanager->initHooks(array('directdebitprevcard', 'globalcard', 'directdebitprevlist'));
if (!$user->rights->prelevement->bons->lire && $object->type != 'bank-transfer') {
accessforbidden();
}
if (!$user->rights->paymentbybanktransfer->read && $object->type == 'bank-transfer') {
accessforbidden();
}
/*
@ -75,19 +86,17 @@ if ($id > 0 || $ref)
$head = prelevement_prepare_head($object);
dol_fiche_head($head, 'invoices', $langs->trans("WithdrawalsReceipts"), -1, 'payment');
$linkback = '<a href="'.DOL_URL_ROOT.'/compta/prelevement/bons.php">'.$langs->trans("BackToList").'</a>';
$linkback = '<a href="'.DOL_URL_ROOT.'/compta/prelevement/bons.php'.($object->type != 'bank-transfer' ? '' : '?type=bank-transfer').'">'.$langs->trans("BackToList").'</a>';
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref');
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border centpercent tableforfield">';
print '<table class="border centpercent tableforfield">'."\n";
//print '<tr><td class="titlefield">'.$langs->trans("Ref").'</td><td>'.$object->getNomUrl(1).'</td></tr>';
print '<tr><td class="titlefield">'.$langs->trans("Date").'</td><td>'.dol_print_date($object->datec, 'day').'</td></tr>';
print '<tr><td>'.$langs->trans("Amount").'</td><td>'.price($object->amount).'</td></tr>';
// Status
//print '<tr><td>'.$langs->trans('Status').'</td><td>'.$object->getLibStatut(1).'</td></tr>';
if ($object->date_trans <> 0)
{
@ -119,7 +128,9 @@ if ($id > 0 || $ref)
$result = $acc->fetch($conf->global->PRELEVEMENT_ID_BANKACCOUNT);
print '<tr><td class="titlefield">';
print $langs->trans("BankToReceiveWithdraw");
$labelofbankfield = "BankToReceiveWithdraw";
if ($object->type == 'bank-transfer') $labelofbankfield = 'BankToPayCreditTransfer';
print $langs->trans($labelofbankfield);
print '</td>';
print '<td>';
if ($acc->id > 0)
@ -128,9 +139,13 @@ if ($id > 0 || $ref)
print '</tr>';
print '<tr><td class="titlefield">';
print $langs->trans("WithdrawalFile").'</td><td>';
$labelfororderfield = 'WithdrawalFile';
if ($object->type == 'bank-transfer') $labelfororderfield = 'CreditTransferFile';
print $langs->trans($labelfororderfield).'</td><td>';
$relativepath = 'receipts/'.$object->ref.'.xml';
print '<a data-ajax="false" href="'.DOL_URL_ROOT.'/document.php?type=text/plain&amp;modulepart=prelevement&amp;file='.urlencode($relativepath).'">'.$relativepath.'</a>';
$modulepart = 'prelevement';
if ($object->type == 'bank-transfer') $modulepart = 'paymentbybanktransfer';
print '<a data-ajax="false" href="'.DOL_URL_ROOT.'/document.php?type=text/plain&amp;modulepart='.$modulepart.'&amp;file='.urlencode($relativepath).'">'.$relativepath.'</a>';
print '</td></tr></table>';
print '</div>';
@ -149,13 +164,25 @@ $sql .= " s.rowid as socid, s.nom as name, pl.statut, pl.amount as amount_reques
$sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p";
$sql .= ", ".MAIN_DB_PREFIX."prelevement_lignes as pl";
$sql .= ", ".MAIN_DB_PREFIX."prelevement_facture as pf";
$sql .= ", ".MAIN_DB_PREFIX."facture as f";
if ($object->type != 'bank-transfer') {
$sql .= ", ".MAIN_DB_PREFIX."facture as f";
} else {
$sql .= ", ".MAIN_DB_PREFIX."facture_fourn as f";
}
$sql .= ", ".MAIN_DB_PREFIX."societe as s";
$sql .= " WHERE pf.fk_prelevement_lignes = pl.rowid";
$sql .= " AND pl.fk_prelevement_bons = p.rowid";
$sql .= " AND f.fk_soc = s.rowid";
$sql .= " AND pf.fk_facture = f.rowid";
$sql .= " AND f.entity IN (".getEntity('invoice').")";
if ($object->type != 'bank-transfer') {
$sql .= " AND pf.fk_facture = f.rowid";
} else {
$sql .= " AND pf.fk_facture_fourn = f.rowid";
}
if ($object->type != 'bank-transfer') {
$sql .= " AND f.entity IN (".getEntity('invoice').")";
} else {
$sql .= " AND f.entity IN (".getEntity('supplier_invoice').")";
}
if ($object->id > 0) $sql .= " AND p.rowid=".$object->id;
if ($socid) $sql .= " AND s.rowid = ".$socid;
$sql .= $db->order($sortfield, $sortorder);

View File

@ -21,7 +21,7 @@
/**
* \file htdocs/compta/prelevement/fiche-rejet.php
* \ingroup prelevement
* \brief Withdraw reject
* \brief Debit order or credit transfer reject
*/
require '../../main.inc.php';
@ -34,7 +34,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
// Load translation files required by the page
$langs->loadLangs(array("banks", "categories", 'withdrawals', 'bills'));
// Securite acces client
// Security check
if ($user->socid > 0) accessforbidden();
// Get supervariables
@ -55,6 +55,15 @@ $pagenext = $page + 1;
$object = new BonPrelevement($db);
// 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 (!$user->rights->prelevement->bons->lire && $object->type != 'bank-transfer') {
accessforbidden();
}
if (!$user->rights->paymentbybanktransfer->read && $object->type == 'bank-transfer') {
accessforbidden();
}
@ -71,7 +80,7 @@ if ($prev_id > 0 || $ref)
$head = prelevement_prepare_head($object);
dol_fiche_head($head, 'rejects', $langs->trans("WithdrawalsReceipts"), -1, 'payment');
$linkback = '<a href="'.DOL_URL_ROOT.'/compta/prelevement/bons.php">'.$langs->trans("BackToList").'</a>';
$linkback = '<a href="'.DOL_URL_ROOT.'/compta/prelevement/bons.php'.($object->type != 'bank-transfer' ? '' : '?type=bank-transfer').'">'.$langs->trans("BackToList").'</a>';
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref');
@ -83,13 +92,6 @@ if ($prev_id > 0 || $ref)
print '<tr><td class="titlefield">'.$langs->trans("Date").'</td><td>'.dol_print_date($object->datec, 'day').'</td></tr>';
print '<tr><td>'.$langs->trans("Amount").'</td><td>'.price($object->amount).'</td></tr>';
// Status
/*
print '<tr><td>'.$langs->trans('Status').'</td>';
print '<td>'.$object->getLibStatut(1).'</td>';
print '</tr>';
*/
if ($object->date_trans <> 0)
{
$muser = new User($db);
@ -120,7 +122,9 @@ if ($prev_id > 0 || $ref)
$result = $acc->fetch($conf->global->PRELEVEMENT_ID_BANKACCOUNT);
print '<tr><td class="titlefield">';
print $langs->trans("BankToReceiveWithdraw");
$labelofbankfield = "BankToReceiveWithdraw";
if ($object->type == 'bank-transfer') $labelofbankfield = 'BankToPayCreditTransfer';
print $langs->trans($labelofbankfield);
print '</td>';
print '<td>';
if ($acc->id > 0)
@ -129,9 +133,13 @@ if ($prev_id > 0 || $ref)
print '</tr>';
print '<tr><td class="titlefield">';
print $langs->trans("WithdrawalFile").'</td><td>';
$labelfororderfield = 'WithdrawalFile';
if ($object->type == 'bank-transfer') $labelfororderfield = 'CreditTransferFile';
print $langs->trans($labelfororderfield).'</td><td>';
$relativepath = 'receipts/'.$object->ref.'.xml';
print '<a data-ajax="false" href="'.DOL_URL_ROOT.'/document.php?type=text/plain&amp;modulepart=prelevement&amp;file='.urlencode($relativepath).'">'.$relativepath.'</a>';
$modulepart = 'prelevement';
if ($object->type == 'bank-transfer') $modulepart = 'paymentbybanktransfer';
print '<a data-ajax="false" href="'.DOL_URL_ROOT.'/document.php?type=text/plain&amp;modulepart='.$modulepart.'&amp;file='.urlencode($relativepath).'">'.$relativepath.'</a>';
print '</td></tr></table>';
print '</div>';
@ -142,6 +150,7 @@ if ($prev_id > 0 || $ref)
}
}
$rej = new RejetPrelevement($db, $user);
/*

View File

@ -20,7 +20,7 @@
/**
* \file htdocs/compta/prelevement/fiche-stat.php
* \ingroup prelevement
* \brief Prelevement statistics
* \brief Debit order or credit transfer statistics
*/
require '../../main.inc.php';
@ -54,6 +54,17 @@ $pagenext = $page + 1;
$object = new BonPrelevement($db);
// 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 (!$user->rights->prelevement->bons->lire && $object->type != 'bank-transfer') {
accessforbidden();
}
if (!$user->rights->paymentbybanktransfer->read && $object->type == 'bank-transfer') {
accessforbidden();
}
/*
* View
@ -68,7 +79,7 @@ if ($prev_id > 0 || $ref)
$head = prelevement_prepare_head($object);
dol_fiche_head($head, 'statistics', $langs->trans("WithdrawalsReceipts"), -1, 'payment');
$linkback = '<a href="'.DOL_URL_ROOT.'/compta/prelevement/bons.php">'.$langs->trans("BackToList").'</a>';
$linkback = '<a href="'.DOL_URL_ROOT.'/compta/prelevement/bons.php'.($object->type != 'bank-transfer' ? '' : '?type=bank-transfer').'">'.$langs->trans("BackToList").'</a>';
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref');
@ -80,13 +91,6 @@ if ($prev_id > 0 || $ref)
print '<tr><td class="titlefield">'.$langs->trans("Date").'</td><td>'.dol_print_date($object->datec, 'day').'</td></tr>';
print '<tr><td>'.$langs->trans("Amount").'</td><td>'.price($object->amount).'</td></tr>';
// Status
/*
print '<tr><td>'.$langs->trans('Status').'</td>';
print '<td>'.$object->getLibStatut(1).'</td>';
print '</tr>';
*/
if ($object->date_trans <> 0)
{
$muser = new User($db);
@ -117,7 +121,9 @@ if ($prev_id > 0 || $ref)
$result = $acc->fetch($conf->global->PRELEVEMENT_ID_BANKACCOUNT);
print '<tr><td class="titlefield">';
print $langs->trans("BankToReceiveWithdraw");
$labelofbankfield = "BankToReceiveWithdraw";
if ($object->type == 'bank-transfer') $labelofbankfield = 'BankToPayCreditTransfer';
print $langs->trans($labelofbankfield);
print '</td>';
print '<td>';
if ($acc->id > 0)
@ -126,23 +132,26 @@ if ($prev_id > 0 || $ref)
print '</tr>';
print '<tr><td class="titlefield">';
print $langs->trans("WithdrawalFile").'</td><td>';
$labelfororderfield = 'WithdrawalFile';
if ($object->type == 'bank-transfer') $labelfororderfield = 'CreditTransferFile';
print $langs->trans($labelfororderfield).'</td><td>';
$relativepath = 'receipts/'.$object->ref.'.xml';
print '<a data-ajax="false" href="'.DOL_URL_ROOT.'/document.php?type=text/plain&amp;modulepart=prelevement&amp;file='.urlencode($relativepath).'">'.$relativepath.'</a>';
$modulepart = 'prelevement';
if ($object->type == 'bank-transfer') $modulepart = 'paymentbybanktransfer';
print '<a data-ajax="false" href="'.DOL_URL_ROOT.'/document.php?type=text/plain&amp;modulepart='.$modulepart.'&amp;file='.urlencode($relativepath).'">'.$relativepath.'</a>';
print '</td></tr></table>';
print '</div>';
dol_fiche_end();
} else {
$langs->load("errors");
print $langs->trans("Error");
dol_print_error($db);
}
/*
* Stats
*/
$ligne = new LignePrelevement($db);
$line = new LignePrelevement($db);
$sql = "SELECT sum(pl.amount), pl.statut";
$sql .= " FROM ".MAIN_DB_PREFIX."prelevement_lignes as pl";
@ -168,7 +177,7 @@ if ($prev_id > 0 || $ref)
print '<tr class="oddeven"><td>';
print $ligne->LibStatut($row[1], 1);
print $line->LibStatut($row[1], 1);
print '</td><td class="right">';
print price($row[0]);

View File

@ -22,7 +22,7 @@
/**
* \file htdocs/compta/prelevement/index.php
* \ingroup prelevement
* \brief Prelevement index page
* \brief Home page for direct debit orders
*/
@ -94,7 +94,7 @@ print '</td></tr></table></div><br>';
*/
$sql = "SELECT f.ref, f.rowid, f.total_ttc, f.fk_statut, f.paye, f.type,";
$sql .= " pfd.date_demande, pfd.amount,";
$sql .= " s.nom as name, s.rowid as socid";
$sql .= " s.nom as name, s.email, s.rowid as socid";
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f,";
$sql .= " ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
@ -106,7 +106,9 @@ if (empty($conf->global->WITHDRAWAL_ALLOW_ANY_INVOICE_STATUS))
{
$sql .= " AND f.fk_statut = ".Facture::STATUS_VALIDATED;
}
$sql .= " AND pfd.traite = 0 AND pfd.fk_facture = f.rowid";
$sql .= " AND pfd.traite = 0";
$sql .= " AND pfd.ext_payment_id IS NULL";
$sql .= " AND pfd.fk_facture = f.rowid";
if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
if ($socid) $sql .= " AND f.fk_soc = ".$socid;
@ -133,14 +135,15 @@ if ($resql)
$invoicestatic->type = $obj->type;
$alreadypayed = $invoicestatic->getSommePaiement();
$thirdpartystatic->id = $obj->socid;
$thirdpartystatic->name = $obj->name;
$thirdpartystatic->email = $obj->email;
print '<tr class="oddeven"><td>';
print $invoicestatic->getNomUrl(1, 'withdraw');
print '</td>';
print '<td>';
$thirdpartystatic->id = $obj->socid;
$thirdpartystatic->name = $obj->name;
print $thirdpartystatic->getNomUrl(1, 'customer');
print '</td>';
@ -171,8 +174,9 @@ print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
/*
* Withdraw receipts
* Direct debit orders
*/
$limit = 5;
$sql = "SELECT p.rowid, p.ref, p.amount, p.datec, p.statut";
$sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p";
@ -189,7 +193,8 @@ if ($result)
print"\n<!-- debut table -->\n";
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><th>'.$langs->trans("LastWithdrawalReceipt", $limit).'</th>';
print '<tr class="liste_titre">';
print '<th>'.$langs->trans("LastWithdrawalReceipt", $limit).'</th>';
print '<th>'.$langs->trans("Date").'</th>';
print '<th class="right">'.$langs->trans("Amount").'</th>';
print '<th class="right">'.$langs->trans("Status").'</th>';
@ -217,7 +222,7 @@ if ($result)
$i++;
}
} else {
print '<tr><td class="opacitymedium">'.$langs->trans("None").'</td></tr>';
print '<tr><td class="opacitymedium" colspan="4">'.$langs->trans("None").'</td></tr>';
}
print "</table></div><br>";

View File

@ -486,7 +486,7 @@ if (!empty($conf->tax->enabled) && ($modecompta == 'CREANCES-DETTES' || $modecom
}
/*
* Charges sociales non deductibles
* Social contributions
*/
$subtotal_ht = 0;
@ -499,7 +499,6 @@ if (!empty($conf->tax->enabled) && ($modecompta == 'CREANCES-DETTES' || $modecom
$sql .= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c";
$sql .= ", ".MAIN_DB_PREFIX."chargesociales as cs";
$sql .= " WHERE cs.fk_type = c.id";
$sql .= " AND c.deductible = 0";
if (!empty($date_start) && !empty($date_end))
$sql .= " AND cs.date_ech >= '".$db->idate($date_start)."' AND cs.date_ech <= '".$db->idate($date_end)."'";
} elseif ($modecompta == "RECETTES-DEPENSES")
@ -510,7 +509,6 @@ if (!empty($conf->tax->enabled) && ($modecompta == 'CREANCES-DETTES' || $modecom
$sql .= ", ".MAIN_DB_PREFIX."paiementcharge as p";
$sql .= " WHERE p.fk_charge = cs.rowid";
$sql .= " AND cs.fk_type = c.id";
$sql .= " AND c.deductible = 0";
if (!empty($date_start) && !empty($date_end))
$sql .= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
}
@ -518,67 +516,7 @@ if (!empty($conf->tax->enabled) && ($modecompta == 'CREANCES-DETTES' || $modecom
$sql .= " AND cs.entity = ".$conf->entity;
$sql .= " GROUP BY c.libelle, dm";
dol_syslog("get social contributions deductible=0 ", LOG_DEBUG);
$result = $db->query($sql);
if ($result) {
$num = $db->num_rows($result);
$i = 0;
if ($num) {
while ($i < $num) {
$obj = $db->fetch_object($result);
if (!isset($decaiss[$obj->dm])) $decaiss[$obj->dm] = 0;
$decaiss[$obj->dm] += $obj->amount;
if (!isset($decaiss_ttc[$obj->dm])) $decaiss_ttc[$obj->dm] = 0;
$decaiss_ttc[$obj->dm] += $obj->amount;
$i++;
}
}
} else {
dol_print_error($db);
}
} elseif ($modecompta == "BOOKKEEPING")
{
// Nothing from this table
}
/*
* Charges sociales deductibles
*/
$subtotal_ht = 0;
$subtotal_ttc = 0;
if (!empty($conf->tax->enabled) && ($modecompta == 'CREANCES-DETTES' || $modecompta == "RECETTES-DEPENSES"))
{
if ($modecompta == 'CREANCES-DETTES')
{
$sql = "SELECT c.libelle as nom, date_format(cs.date_ech,'%Y-%m') as dm, sum(cs.amount) as amount";
$sql .= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c";
$sql .= ", ".MAIN_DB_PREFIX."chargesociales as cs";
$sql .= " WHERE cs.fk_type = c.id";
$sql .= " AND c.deductible = 1";
if (!empty($date_start) && !empty($date_end))
$sql .= " AND cs.date_ech >= '".$db->idate($date_start)."' AND cs.date_ech <= '".$db->idate($date_end)."'";
} elseif ($modecompta == "RECETTES-DEPENSES")
{
$sql = "SELECT c.libelle as nom, date_format(p.datep,'%Y-%m') as dm, sum(p.amount) as amount";
$sql .= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c";
$sql .= ", ".MAIN_DB_PREFIX."chargesociales as cs";
$sql .= ", ".MAIN_DB_PREFIX."paiementcharge as p";
$sql .= " WHERE p.fk_charge = cs.rowid";
$sql .= " AND cs.fk_type = c.id";
$sql .= " AND c.deductible = 1";
if (!empty($date_start) && !empty($date_end))
$sql .= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
}
$sql .= " AND cs.entity = ".$conf->entity;
$sql .= " GROUP BY c.libelle, dm";
dol_syslog("get social contributions paid deductible=1", LOG_DEBUG);
dol_syslog("get social contributions", LOG_DEBUG);
$result = $db->query($sql);
if ($result) {
$num = $db->num_rows($result);
@ -713,7 +651,7 @@ if (!empty($conf->expensereport->enabled) && ($modecompta == 'CREANCES-DETTES' |
/*
* Donation get dunning paiement
* Donation get dunning payments
*/
if (!empty($conf->don->enabled) && ($modecompta == 'CREANCES-DETTES' || $modecompta == "RECETTES-DEPENSES"))

View File

@ -481,6 +481,8 @@ if ($id > 0)
}
$morehtmlref .= '</div>';
$morehtmlright = '';
$linkback = '<a href="'.DOL_URL_ROOT.'/compta/sociales/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
$object->totalpaye = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status

View File

@ -683,7 +683,7 @@ class PaymentSocialContribution extends CommonObject
$result = '';
if (empty($this->ref)) $this->ref = $this->lib;
$label = $langs->trans("ShowPayment").': '.$this->ref;
$label = $langs->trans("Payment").': '.$this->ref;
if (!empty($this->id)) {
$link = '<a href="'.DOL_URL_ROOT.'/compta/payment_sc/card.php?id='.$this->id.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';

View File

@ -2041,13 +2041,6 @@ if ($action == 'create')
else print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans("Modify").'</a></div>';
}
if (!empty($conf->facture->enabled) && $object->statut > 0)
{
$langs->load("bills");
if ($user->rights->facture->creer) print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/compta/facture/card.php?action=create&amp;origin='.$object->element.'&amp;originid='.$object->id.'&amp;socid='.$object->thirdparty->id.'">'.$langs->trans("CreateBill").'</a></div>';
else print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans("CreateBill").'</a></div>';
}
if (!empty($conf->commande->enabled) && $object->statut > 0 && $object->nbofservicesclosed < $nbofservices)
{
$langs->load("orders");
@ -2055,9 +2048,11 @@ if ($action == 'create')
else print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans("CreateOrder").'</a></div>';
}
// Clone
if ($user->rights->contrat->creer) {
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;socid='.$object->socid.'&amp;action=clone&amp;object='.$object->element.'">'.$langs->trans("ToClone").'</a></div>';
if (!empty($conf->facture->enabled) && $object->statut > 0)
{
$langs->load("bills");
if ($user->rights->facture->creer) print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/compta/facture/card.php?action=create&amp;origin='.$object->element.'&amp;originid='.$object->id.'&amp;socid='.$object->thirdparty->id.'">'.$langs->trans("CreateBill").'</a></div>';
else print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans("CreateBill").'</a></div>';
}
if ($object->nbofservicesclosed > 0 || $object->nbofserviceswait > 0)
@ -2086,15 +2081,22 @@ if ($action == 'create')
// print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("CloseRefusedBecauseOneServiceActive").'">'.$langs->trans("Close").'</a></div>';
//}
}
if (! empty($conf->global->CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT) && $object->nbofservicesclosed > 0)
{
if ($action == 'showclosedlines') print '<div class="inline-block divButAction"><a class="butAction" id="btnhideclosedlines" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=hideclosedlines">'.$langs->trans("HideClosedServices").'</a></div>';
else print '<div class="inline-block divButAction"><a class="butAction" id="btnshowclosedlines" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=showclosedlines">'.$langs->trans("ShowClosedServices").'</a></div>';
}
// Clone
if ($user->rights->contrat->creer) {
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;socid='.$object->socid.'&amp;action=clone&amp;object='.$object->element.'">'.$langs->trans("ToClone").'</a></div>';
}
// On peut supprimer entite si
// - Droit de creer + mode brouillon (erreur creation)
// - Droit de supprimer
if (($user->rights->contrat->creer && $object->statut == 0) || $user->rights->contrat->supprimer)
if (($user->rights->contrat->creer && $object->statut == $object::STATUS_DRAFT) || $user->rights->contrat->supprimer)
{
print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete">'.$langs->trans("Delete").'</a></div>';
} else {

View File

@ -2776,18 +2776,16 @@ class ContratLigne extends CommonObjectLine
* Load object in memory from database
*
* @param int $id Id object
* @param string $ref Ref of contract
* @param string $ref Ref of contract line
* @return int <0 if KO, >0 if OK
*/
public function fetch($id, $ref = '')
{
// Check parameters
if (empty($id) && empty($ref)) return -1;
$sql = "SELECT";
$sql .= " t.rowid,";
$sql .= " t.tms,";
$sql .= " t.fk_contrat,";
$sql .= " t.fk_product,";
@ -2888,10 +2886,14 @@ class ContratLigne extends CommonObjectLine
$this->fk_user_cloture = $obj->fk_user_cloture;
$this->commentaire = $obj->commentaire;
$this->fk_fournprice = $obj->fk_fournprice;
$marginInfos = getMarginInfos($obj->subprice, $obj->remise_percent, $obj->tva_tx, $obj->localtax1_tx, $obj->localtax2_tx, $this->fk_fournprice, $obj->pa_ht);
$this->pa_ht = $marginInfos[0];
$this->fk_unit = $obj->fk_unit;
$this->fetch_optionals();
}
$this->db->free($resql);
return 1;

View File

@ -576,7 +576,7 @@ while ($i < min($num, $limit))
// Ref
if (!empty($arrayfields['c.ref']['checked']))
{
print '<td>';
print '<td class="nowraponall">';
print $contractstatic->getNomUrl(1, 16);
print '</td>';
if (!$i) $totalarray['nbfield']++;

View File

@ -94,6 +94,12 @@ if ($action == 'add' && !empty($permissiontoadd))
}
}
// Fill array 'array_options' with data from add form
if (!$error) {
$ret = $extrafields->setOptionalsFromPost(null, $object);
if ($ret < 0) $error++;
}
if (!$error)
{
$result = $object->create($user);
@ -165,6 +171,12 @@ if ($action == 'update' && !empty($permissiontoadd))
}
}
// Fill array 'array_options' with data from add form
if (!$error) {
$ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET');
if ($ret < 0) $error++;
}
if (!$error)
{
$result = $object->update($user);
@ -188,7 +200,14 @@ if ($action == "update_extras" && !empty($permissiontoadd))
$attributekey = GETPOST('attribute', 'alpha');
$attributekeylong = 'options_'.$attributekey;
$object->array_options['options_'.$attributekey] = GETPOST($attributekeylong, ' alpha');
if (GETPOSTISSET($attributekeylong.'day') && GETPOSTISSET($attributekeylong.'month') && GETPOSTISSET($attributekeylong.'year')) {
// This is properties of a date
$object->array_options['options_'.$attributekey] = dol_mktime(GETPOST($attributekeylong.'hour', 'int'), GETPOST($attributekeylong.'min', 'int'), GETPOST($attributekeylong.'sec', 'int'), GETPOST($attributekeylong.'month', 'int'), GETPOST($attributekeylong.'day', 'int'), GETPOST($attributekeylong.'year', 'int'));
//var_dump(dol_print_date($object->array_options['options_'.$attributekey]));exit;
} else {
$object->array_options['options_'.$attributekey] = GETPOST($attributekeylong, ' alpha');
}
$result = $object->insertExtraFields(empty($triggermodname) ? '' : $triggermodname, $user);
if ($result > 0)

View File

@ -44,8 +44,10 @@ if (($id > 0 || (!empty($ref) && !in_array($action, array('create', 'createtask'
{
setEventMessages('Fetch on object (type '.get_class($object).') return an error without filling $object->error nor $object->errors', null, 'errors');
}
} else setEventMessages($object->error, $object->errors, 'errors');
$action = '';
} else {
setEventMessages($object->error, $object->errors, 'errors');
}
$action = '';
}
}
}

View File

@ -1173,6 +1173,7 @@ if (!$error && $massaction == 'closed' && $objectclass == "Propal" && $permissio
}
}
//var_dump($_POST);var_dump($massaction);exit;
// Delete record from mass action (massaction = 'delete' for direct delete, action/confirm='delete'/'yes' with a confirmation step before)
if (!$error && ($massaction == 'delete' || ($action == 'delete' && $confirm == 'yes')) && $permissiontodelete)

View File

@ -47,8 +47,8 @@ top_httphead();
print '<!-- Ajax page called with url '.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]).' -->'."\n";
// Registering the location of boxes
if ((!empty($_POST['roworder'])) && (!empty($_POST['table_element_line']))
&& (!empty($_POST['fk_element'])) && (!empty($_POST['element_id'])))
if (GETPOST('roworder', 'alpha') && GETPOST('table_element_line', 'alpha', 2)
&& GETPOST('fk_element', 'alpha', 2) && GETPOST('element_id', 'int', 2))
{
$roworder = GETPOST('roworder', 'alpha', 2);
$table_element_line = GETPOST('table_element_line', 'alpha', 2);

View File

@ -154,10 +154,10 @@ if (empty($reshook))
$arrayresult = array_merge($arrayresult, $hookmanager->resArray);
} else $arrayresult = $hookmanager->resArray;
// This allow to keep a search entry to the top
// This pushes a search entry to the top
if (!empty($conf->global->DEFAULT_SEARCH_INTO_MODULE)) {
$key = 'searchinto'.$conf->global->DEFAULT_SEARCH_INTO_MODULE;
if (array_key_exists($key, $arrayresult)) $arrayresult[$key]['position'] = -10;
if (array_key_exists($key, $arrayresult)) $arrayresult[$key]['position'] = -1000;
}
// Sort on position

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2010 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2011-204 Laurent Destailleur <eldy@users.sourceforge.net>
/* Copyright (C) 2010 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2011-2014 Laurent Destailleur <eldy@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@ -143,7 +143,7 @@ class box_services_contracts extends ModeleBoxes
$thirdpartytmp->code_compta_fournisseur = $objp->code_compta_fournisseur;
$dateline = $this->db->jdate($objp->date_line);
if ($contractstatic->statut == Contrat::STATUS_VALIDATED && $objp->statut == ContratLigne::STATUS_OPEN && ($dateline + $conf->contrat->services->expires->warning_delay) < $now) $late = img_warning($langs->trans("Late"));
if ($contractstatic->statut == Contrat::STATUS_VALIDATED && $objp->statut == ContratLigne::STATUS_OPEN && !empty($dateline) && ($dateline + $conf->contrat->services->expires->warning_delay) < $now) $late = img_warning($langs->trans("Late"));
// Multilangs
if (!empty($conf->global->MAIN_MULTILANGS) && $objp->product_id > 0) // if option multilang is on

View File

@ -420,7 +420,20 @@ class CMailFile
//$this->message->setFrom(array('john@doe.com' => 'John Doe'));
if (!empty($from)) {
try {
$result = $this->message->setFrom($this->getArrayAddress($from));
if (! empty($conf->global->MAIN_FORCE_DISABLE_MAIL_SPOOFING)) {
// Prevent email spoofing for smtp server with a strict configuration
$regexp = '/([a-z0-9_\.\-\+])+\@(([a-z0-9\-])+\.)+([a-z0-9]{2,4})+/i'; // This regular expression extracts all emails from a string
$emailMatchs = preg_match_all($regexp, $from, $adressEmailFrom);
$adressEmailFrom = reset($adressEmailFrom);
if ($emailMatchs !== false && filter_var($conf->global->MAIN_MAIL_SMTPS_ID, FILTER_VALIDATE_EMAIL) && $conf->global->MAIN_MAIL_SMTPS_ID !== $adressEmailFrom)
{
$result = $this->message->setFrom($conf->global->MAIN_MAIL_SMTPS_ID);
} else {
$result = $this->message->setFrom($this->getArrayAddress($from));
}
} else {
$result = $this->message->setFrom($this->getArrayAddress($from));
}
} catch (Exception $e) {
$this->errors[] = $e->getMessage();
}

View File

@ -1072,7 +1072,8 @@ abstract class CommonDocGenerator
$parameters = array(
'curY' => &$curY,
'columnText' => $columnText,
'colKey' => $colKey
'colKey' => $colKey,
'pdf' => &$pdf,
);
$reshook = $hookmanager->executeHooks('printStdColumnContent', $parameters, $this); // Note that $action and $object may have been modified by hook
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
@ -1286,7 +1287,7 @@ abstract class CommonDocGenerator
{
// Sort extrafields by rank
uasort($fields, function ($a, $b) {
return ($a->rank > $b->rank) ? -1 : 1;
return ($a->rank > $b->rank) ? 1 : -1;
});
// define some HTML content with style

View File

@ -1858,14 +1858,15 @@ abstract class CommonObject
$row = $this->db->fetch_row($result);
$this->ref_previous = $row[0];
$sql = "SELECT MIN(te.".$fieldid.")";
$sql .= " FROM ".(empty($nodbprefix) ?MAIN_DB_PREFIX:'').$this->table_element." as te";
if ($this->element == 'user' && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
$sql .= ",".MAIN_DB_PREFIX."usergroup_user as ug";
}
if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 'fk_soc@societe') $sql .= ", ".MAIN_DB_PREFIX."societe as s"; // If we need to link to societe to limit select to entity
elseif ($this->restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe as s"; // If we need to link to societe to limit select to socid
if (isset($this->ismultientitymanaged) && !is_numeric($this->ismultientitymanaged)) {
$tmparray = explode('@', $this->ismultientitymanaged);
$sql .= ", ".MAIN_DB_PREFIX.$tmparray[1]." as ".($tmparray[1] == 'societe' ? 's' : 'parenttable'); // If we need to link to this table to limit select to entity
} elseif ($this->restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe as s"; // If we need to link to societe to limit select to socid
elseif ($this->restrictiononfksoc == 2 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON te.fk_soc = s.rowid"; // If we need to link to societe to limit select to socid
if ($this->restrictiononfksoc && !$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON ".$aliastablesociete.".rowid = sc.fk_soc";
$sql .= " WHERE te.".$fieldid." > '".$this->db->escape($fieldid=='rowid' ? $this->id : $this->ref)."'"; // ->ref must always be defined (set to id if field does not exists)
@ -1876,8 +1877,10 @@ abstract class CommonObject
if (!preg_match('/^\s*AND/i', $filter)) $sql .= " AND "; // For backward compatibility
$sql .= $filter;
}
if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 'fk_soc@societe') $sql .= ' AND te.fk_soc = s.rowid'; // If we need to link to societe to limit select to entity
elseif ($this->restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql .= ' AND te.fk_soc = s.rowid'; // If we need to link to societe to limit select to socid
if (isset($this->ismultientitymanaged) && !is_numeric($this->ismultientitymanaged)) {
$tmparray = explode('@', $this->ismultientitymanaged);
$sql .= ' AND te.'.$tmparray[0].' = '.($tmparray[1] == 'societe' ? 's' : 'parenttable').'.rowid'; // If we need to link to this table to limit select to entity
} elseif ($this->restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql .= ' AND te.fk_soc = s.rowid'; // If we need to link to societe to limit select to socid
if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) {
if ($this->element == 'user' && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
if (!empty($user->admin) && empty($user->entity) && $conf->entity == 1) {
@ -1890,6 +1893,10 @@ abstract class CommonObject
$sql .= ' AND te.entity IN ('.getEntity($this->element).')';
}
}
if (isset($this->ismultientitymanaged) && !is_numeric($this->ismultientitymanaged) && $this->element != 'societe') {
$tmparray = explode('@', $this->ismultientitymanaged);
$sql .= ' AND parenttable.entity IN ('.getEntity($tmparray[1]).')';
}
if ($this->restrictiononfksoc == 1 && $socid && $this->element != 'societe') $sql .= ' AND te.fk_soc = '.$socid;
if ($this->restrictiononfksoc == 2 && $socid && $this->element != 'societe') $sql .= ' AND (te.fk_soc = '.$socid.' OR te.fk_soc IS NULL)';
if ($this->restrictiononfksoc && $socid && $this->element == 'societe') $sql .= ' AND te.rowid = '.$socid;
@ -2525,10 +2532,11 @@ abstract class CommonObject
/**
* Get children of line
*
* @param int $id Id of parent line
* @return array Array with list of children lines id
* @param int $id Id of parent line
* @param int $includealltree 0 = 1st level child, 1 = All level child
* @return array Array with list of children lines id
*/
public function getChildrenOfLine($id)
public function getChildrenOfLine($id, $includealltree = 0)
{
$rows = array();
@ -2541,16 +2549,13 @@ abstract class CommonObject
$resql = $this->db->query($sql);
if ($resql)
{
$i = 0;
$num = $this->db->num_rows($resql);
while ($i < $num)
{
$row = $this->db->fetch_row($resql);
$rows[$i] = $row[0];
$i++;
if ($this->db->num_rows($resql) > 0) {
while ($row = $this->db->fetch_row($resql)) {
$rows[] = $row[0];
if (!empty($includealltree)) $rows = array_merge($rows, $this->getChildrenOfLine($row[0]), $includealltree);
}
}
}
return $rows;
}
@ -5608,7 +5613,7 @@ abstract class CommonObject
* Update an extra field value for the current object.
* Data to describe values to update are stored into $this->array_options=array('options_codeforfield1'=>'valueforfield1', 'options_codeforfield2'=>'valueforfield2', ...)
*
* @param string $key Key of the extrafield (without starting 'options_')
* @param string $key Key of the extrafield to update (without starting 'options_')
* @param string $trigger If defined, call also the trigger (for example COMPANY_MODIFY)
* @param User $userused Object user
* @return int -1=error, O=did nothing, 1=OK
@ -6713,237 +6718,245 @@ abstract class CommonObject
*/
public function showOptionals($extrafields, $mode = 'view', $params = null, $keysuffix = '', $keyprefix = '', $onetrtd = 0)
{
global $db, $conf, $langs, $action, $form;
global $db, $conf, $langs, $action, $form, $hookmanager;
if (!is_object($form)) $form = new Form($db);
$out = '';
if (is_array($extrafields->attributes[$this->table_element]['label']) && count($extrafields->attributes[$this->table_element]['label']) > 0)
$parameters=array();
$reshook=$hookmanager->executeHooks('showOptionals', $parameters, $this, $action); // Note that $action and $object may have been modified by hook
if (empty($reshook))
{
$out .= "\n";
$out .= '<!-- showOptionalsInput --> ';
$out .= "\n";
$extrafields_collapse_num = '';
$e = 0;
foreach ($extrafields->attributes[$this->table_element]['label'] as $key=>$label)
if (is_array($extrafields->attributes[$this->table_element]['label']) && count($extrafields->attributes[$this->table_element]['label']) > 0)
{
// Show only the key field in params
if (is_array($params) && array_key_exists('onlykey', $params) && $key != $params['onlykey']) continue;
$out .= "\n";
$out .= '<!-- showOptionalsInput --> ';
$out .= "\n";
// @todo Add test also on 'enabled' (different than 'list' that is 'visibility')
$enabled = 1;
if ($enabled && isset($extrafields->attributes[$this->table_element]['enabled'][$key]))
$extrafields_collapse_num = '';
$e = 0;
foreach ($extrafields->attributes[$this->table_element]['label'] as $key=>$label)
{
$enabled = dol_eval($extrafields->attributes[$this->table_element]['enabled'][$key], 1);
}
if (empty($enabled)) continue;
// Show only the key field in params
if (is_array($params) && array_key_exists('onlykey', $params) && $key != $params['onlykey']) continue;
$visibility = 1;
if ($visibility && isset($extrafields->attributes[$this->table_element]['list'][$key]))
{
$visibility = dol_eval($extrafields->attributes[$this->table_element]['list'][$key], 1);
}
// @todo Add test also on 'enabled' (different than 'list' that is 'visibility')
$enabled = 1;
if ($enabled && isset($extrafields->attributes[$this->table_element]['enabled'][$key]))
{
$enabled = dol_eval($extrafields->attributes[$this->table_element]['enabled'][$key], 1);
}
if (empty($enabled)) continue;
$perms = 1;
if ($perms && isset($extrafields->attributes[$this->table_element]['perms'][$key]))
{
$perms = dol_eval($extrafields->attributes[$this->table_element]['perms'][$key], 1);
}
if (($mode == 'create') && abs($visibility) != 1 && abs($visibility) != 3) continue; // <> -1 and <> 1 and <> 3 = not visible on forms, only on list
elseif (($mode == 'edit') && abs($visibility) != 1 && abs($visibility) != 3 && abs($visibility) != 4) continue; // <> -1 and <> 1 and <> 3 = not visible on forms, only on list and <> 4 = not visible at the creation
elseif ($mode == 'view' && empty($visibility)) continue;
if (empty($perms)) continue;
// Load language if required
if (!empty($extrafields->attributes[$this->table_element]['langfile'][$key])) {
$langs->load($extrafields->attributes[$this->table_element]['langfile'][$key]);
}
$colspan = '';
if (is_array($params) && count($params) > 0) {
if (array_key_exists('cols', $params)) {
$colspan = $params['cols'];
} elseif (array_key_exists('colspan', $params)) { // For backward compatibility. Use cols instead now.
$reg = array();
if (preg_match('/colspan="(\d+)"/', $params['colspan'], $reg)) {
$colspan = $reg[1];
} else {
$colspan = $params['colspan'];
}
$visibility = 1;
if ($visibility && isset($extrafields->attributes[$this->table_element]['list'][$key]))
{
$visibility = dol_eval($extrafields->attributes[$this->table_element]['list'][$key], 1);
}
}
switch ($mode) {
case "view":
$value = $this->array_options["options_".$key.$keysuffix];
break;
case "create":
case "edit":
$getposttemp = GETPOST($keyprefix.'options_'.$key.$keysuffix, 'none'); // GETPOST can get value from GET, POST or setup of default values.
// GETPOST("options_" . $key) can be 'abc' or array(0=>'abc')
if (is_array($getposttemp) || $getposttemp != '' || GETPOSTISSET($keyprefix.'options_'.$key.$keysuffix))
{
if (is_array($getposttemp)) {
// $getposttemp is an array but following code expects a comma separated string
$value = implode(",", $getposttemp);
} else {
$value = $getposttemp;
}
} else {
$value = $this->array_options["options_".$key]; // No GET, no POST, no default value, so we take value of object.
}
//var_dump($keyprefix.' - '.$key.' - '.$keysuffix.' - '.$keyprefix.'options_'.$key.$keysuffix.' - '.$this->array_options["options_".$key.$keysuffix].' - '.$getposttemp.' - '.$value);
break;
}
$perms = 1;
if ($perms && isset($extrafields->attributes[$this->table_element]['perms'][$key]))
{
$perms = dol_eval($extrafields->attributes[$this->table_element]['perms'][$key], 1);
}
if ($extrafields->attributes[$this->table_element]['type'][$key] == 'separate')
{
$extrafields_collapse_num = '';
$extrafield_param = $extrafields->attributes[$this->table_element]['param'][$key];
if (!empty($extrafield_param) && is_array($extrafield_param)) {
$extrafield_param_list = array_keys($extrafield_param['options']);
if (($mode == 'create') && abs($visibility) != 1 && abs($visibility) != 3) continue; // <> -1 and <> 1 and <> 3 = not visible on forms, only on list
elseif (($mode == 'edit') && abs($visibility) != 1 && abs($visibility) != 3 && abs($visibility) != 4) continue; // <> -1 and <> 1 and <> 3 = not visible on forms, only on list and <> 4 = not visible at the creation
elseif ($mode == 'view' && empty($visibility)) continue;
if (empty($perms)) continue;
// Load language if required
if (!empty($extrafields->attributes[$this->table_element]['langfile'][$key])) {
$langs->load($extrafields->attributes[$this->table_element]['langfile'][$key]);
}
if (count($extrafield_param_list) > 0) {
$extrafield_collapse_display_value = intval($extrafield_param_list[0]);
if ($extrafield_collapse_display_value == 1 || $extrafield_collapse_display_value == 2) {
$extrafields_collapse_num = $extrafields->attributes[$this->table_element]['pos'][$key];
}
}
}
$out .= $extrafields->showSeparator($key, $this, ($colspan + 1));
} else {
$class = (!empty($extrafields->attributes[$this->table_element]['hidden'][$key]) ? 'hideobject ' : '');
$csstyle = '';
$colspan = '';
if (is_array($params) && count($params) > 0) {
if (array_key_exists('class', $params)) {
$class .= $params['class'].' ';
}
if (array_key_exists('style', $params)) {
$csstyle = $params['style'];
if (array_key_exists('cols', $params)) {
$colspan = $params['cols'];
} elseif (array_key_exists('colspan', $params)) { // For backward compatibility. Use cols instead now.
$reg = array();
if (preg_match('/colspan="(\d+)"/', $params['colspan'], $reg)) {
$colspan = $reg[1];
} else {
$colspan = $params['colspan'];
}
}
}
// add html5 elements
$domData = ' data-element="extrafield"';
$domData .= ' data-targetelement="'.$this->element.'"';
$domData .= ' data-targetid="'.$this->id.'"';
$html_id = (empty($this->id) ? '' : 'extrarow-'.$this->element.'_'.$key.'_'.$this->id);
$out .= '<tr '.($html_id ? 'id="'.$html_id.'" ' : '').$csstyle.' class="'.$class.$this->element.'_extras_'.$key.' trextrafields_collapse'.$extrafields_collapse_num.'" '.$domData.' >';
if (!empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && ($e % 2) == 0) { $colspan = '0'; }
if ($action == 'selectlines') { $colspan++; }
// Convert date into timestamp format (value in memory must be a timestamp)
if (in_array($extrafields->attributes[$this->table_element]['type'][$key], array('date', 'datetime')))
{
$datenotinstring = $this->array_options['options_'.$key];
if (!is_numeric($this->array_options['options_'.$key])) // For backward compatibility
{
$datenotinstring = $this->db->jdate($datenotinstring);
}
$value = GETPOSTISSET($keyprefix.'options_'.$key.$keysuffix) ?dol_mktime(GETPOST($keyprefix.'options_'.$key.$keysuffix."hour", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."min", 'int', 3), 0, GETPOST($keyprefix.'options_'.$key.$keysuffix."month", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."day", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."year", 'int', 3)) : $datenotinstring;
}
// Convert float submited string into real php numeric (value in memory must be a php numeric)
if (in_array($extrafields->attributes[$this->table_element]['type'][$key], array('price', 'double')))
{
$value = GETPOSTISSET($keyprefix.'options_'.$key.$keysuffix) ?price2num(GETPOST($keyprefix.'options_'.$key.$keysuffix, 'alpha', 3)) : $this->array_options['options_'.$key];
}
// HTML, select, integer and text add default value
if (in_array($extrafields->attributes[$this->table_element]['type'][$key], array('html', 'text', 'select', 'int')))
{
if ($action == 'create') $value = $extrafields->attributes[$this->table_element]['default'][$key];
else $value = $this->array_options['options_'.$key];
}
$labeltoshow = $langs->trans($label);
$helptoshow = $langs->trans($extrafields->attributes[$this->table_element]['help'][$key]);
$out .= '<td class="';
//$out .= "titlefield";
//if (GETPOST('action', 'none') == 'create') $out.='create';
// BUG #11554 : For public page, use red dot for required fields, instead of bold label
$tpl_context = isset($params["tpl_context"]) ? $params["tpl_context"] : "none";
if ($tpl_context == "public") { // Public page : red dot instead of fieldrequired characters
$out .= '">';
if (!empty($extrafields->attributes[$this->table_element]['help'][$key])) $out .= $form->textwithpicto($labeltoshow, $helptoshow);
else $out .= $labeltoshow;
if ($mode != 'view' && !empty($extrafields->attributes[$this->table_element]['required'][$key])) $out .= '&nbsp;<font color="red">*</font>';
} else {
if ($mode != 'view' && !empty($extrafields->attributes[$this->table_element]['required'][$key])) $out .= ' fieldrequired';
$out .= '">';
if (!empty($extrafields->attributes[$this->table_element]['help'][$key])) $out .= $form->textwithpicto($labeltoshow, $helptoshow);
else $out .= $labeltoshow;
}
$out .= '</td>';
$html_id = !empty($this->id) ? $this->element.'_extras_'.$key.'_'.$this->id : '';
$out .= '<td '.($html_id ? 'id="'.$html_id.'" ' : '').'class="'.$this->element.'_extras_'.$key.'" '.($colspan ? ' colspan="'.$colspan.'"' : '').'>';
switch ($mode) {
case "view":
$out .= $extrafields->showOutputField($key, $value);
$value = $this->array_options["options_".$key.$keysuffix];
break;
case "create":
case "edit":
$out .= $extrafields->showInputField($key, $value, '', $keysuffix, '', 0, $this->id, $this->table_element);
case "create":
case "edit":
$getposttemp = GETPOST($keyprefix.'options_'.$key.$keysuffix, 'none'); // GETPOST can get value from GET, POST or setup of default values.
// GETPOST("options_" . $key) can be 'abc' or array(0=>'abc')
if (is_array($getposttemp) || $getposttemp != '' || GETPOSTISSET($keyprefix.'options_'.$key.$keysuffix))
{
if (is_array($getposttemp)) {
// $getposttemp is an array but following code expects a comma separated string
$value = implode(",", $getposttemp);
} else {
$value = $getposttemp;
}
} else {
$value = $this->array_options["options_".$key]; // No GET, no POST, no default value, so we take value of object.
}
//var_dump($keyprefix.' - '.$key.' - '.$keysuffix.' - '.$keyprefix.'options_'.$key.$keysuffix.' - '.$this->array_options["options_".$key.$keysuffix].' - '.$getposttemp.' - '.$value);
break;
}
$out .= '</td>';
/*for($ii = 0; $ii < ($colspan - 1); $ii++)
if ($extrafields->attributes[$this->table_element]['type'][$key] == 'separate')
{
$out .='<td class="'.$this->element.'_extras_'.$key.'"></td>';
}*/
$extrafields_collapse_num = '';
$extrafield_param = $extrafields->attributes[$this->table_element]['param'][$key];
if (!empty($extrafield_param) && is_array($extrafield_param)) {
$extrafield_param_list = array_keys($extrafield_param['options']);
if (!empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && (($e % 2) == 1)) $out .= '</tr>';
else $out .= '</tr>';
$e++;
}
}
$out .= "\n";
// Add code to manage list depending on others
if (!empty($conf->use_javascript_ajax)) {
$out .= '
<script>
jQuery(document).ready(function() {
function showOptions(child_list, parent_list)
{
var val = $("select[name=\""+parent_list+"\"]").val();
var parentVal = parent_list + ":" + val;
if(val > 0) {
$("select[name=\""+child_list+"\"] option[parent]").hide();
$("select[name=\""+child_list+"\"] option[parent=\""+parentVal+"\"]").show();
} else {
$("select[name=\""+child_list+"\"] option").show();
if (count($extrafield_param_list) > 0) {
$extrafield_collapse_display_value = intval($extrafield_param_list[0]);
if ($extrafield_collapse_display_value == 1 || $extrafield_collapse_display_value == 2) {
$extrafields_collapse_num = $extrafields->attributes[$this->table_element]['pos'][$key];
}
}
}
$out .= $extrafields->showSeparator($key, $this, ($colspan + 1));
} else {
$class = (!empty($extrafields->attributes[$this->table_element]['hidden'][$key]) ? 'hideobject ' : '');
$csstyle = '';
if (is_array($params) && count($params) > 0) {
if (array_key_exists('class', $params)) {
$class .= $params['class'].' ';
}
if (array_key_exists('style', $params)) {
$csstyle = $params['style'];
}
}
function setListDependencies() {
jQuery("select option[parent]").parent().each(function() {
var child_list = $(this).attr("name");
var parent = $(this).find("option[parent]:first").attr("parent");
var infos = parent.split(":");
var parent_list = infos[0];
$("select[name=\""+parent_list+"\"]").change(function() {
showOptions(child_list, parent_list);
});
});
}
setListDependencies();
});
</script>'."\n";
// add html5 elements
$domData = ' data-element="extrafield"';
$domData .= ' data-targetelement="'.$this->element.'"';
$domData .= ' data-targetid="'.$this->id.'"';
$html_id = (empty($this->id) ? '' : 'extrarow-'.$this->element.'_'.$key.'_'.$this->id);
if (!empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && ($e % 2) == 0) { $colspan = '0'; }
if ($action == 'selectlines') { $colspan++; }
// Convert date into timestamp format (value in memory must be a timestamp)
if (in_array($extrafields->attributes[$this->table_element]['type'][$key], array('date', 'datetime')))
{
$datenotinstring = $this->array_options['options_'.$key];
if (!is_numeric($this->array_options['options_'.$key])) // For backward compatibility
{
$datenotinstring = $this->db->jdate($datenotinstring);
}
$value = GETPOSTISSET($keyprefix.'options_'.$key.$keysuffix) ?dol_mktime(GETPOST($keyprefix.'options_'.$key.$keysuffix."hour", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."min", 'int', 3), 0, GETPOST($keyprefix.'options_'.$key.$keysuffix."month", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."day", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."year", 'int', 3)) : $datenotinstring;
}
// Convert float submited string into real php numeric (value in memory must be a php numeric)
if (in_array($extrafields->attributes[$this->table_element]['type'][$key], array('price', 'double')))
{
$value = GETPOSTISSET($keyprefix.'options_'.$key.$keysuffix) ?price2num(GETPOST($keyprefix.'options_'.$key.$keysuffix, 'alpha', 3)) : $this->array_options['options_'.$key];
}
// HTML, select, integer and text add default value
if (in_array($extrafields->attributes[$this->table_element]['type'][$key], array('html', 'text', 'select', 'int')))
{
if ($action == 'create') $value = $extrafields->attributes[$this->table_element]['default'][$key];
else $value = $this->array_options['options_'.$key];
}
$labeltoshow = $langs->trans($label);
$helptoshow = $langs->trans($extrafields->attributes[$this->table_element]['help'][$key]);
$out .= '<tr '.($html_id ? 'id="'.$html_id.'" ' : '').$csstyle.' class="'.$class.$this->element.'_extras_'.$key.' trextrafields_collapse'.$extrafields_collapse_num.'" '.$domData.' >';
$out .= '<td class="';
//$out .= "titlefield";
//if (GETPOST('action', 'none') == 'create') $out.='create';
// BUG #11554 : For public page, use red dot for required fields, instead of bold label
$tpl_context = isset($params["tpl_context"]) ? $params["tpl_context"] : "none";
if ($tpl_context == "public") { // Public page : red dot instead of fieldrequired characters
$out .= '">';
if (!empty($extrafields->attributes[$this->table_element]['help'][$key])) $out .= $form->textwithpicto($labeltoshow, $helptoshow);
else $out .= $labeltoshow;
if ($mode != 'view' && !empty($extrafields->attributes[$this->table_element]['required'][$key])) $out .= '&nbsp;<font color="red">*</font>';
} else {
if ($mode != 'view' && !empty($extrafields->attributes[$this->table_element]['required'][$key])) $out .= ' fieldrequired';
$out .= '">';
if (!empty($extrafields->attributes[$this->table_element]['help'][$key])) $out .= $form->textwithpicto($labeltoshow, $helptoshow);
else $out .= $labeltoshow;
}
$out .= '</td>';
$html_id = !empty($this->id) ? $this->element.'_extras_'.$key.'_'.$this->id : '';
$out .= '<td '.($html_id ? 'id="'.$html_id.'" ' : '').'class="'.$this->element.'_extras_'.$key.'" '.($colspan ? ' colspan="'.$colspan.'"' : '').'>';
switch ($mode) {
case "view":
$out .= $extrafields->showOutputField($key, $value);
break;
case "create":
case "edit":
$out .= $extrafields->showInputField($key, $value, '', $keysuffix, '', 0, $this->id, $this->table_element);
break;
}
$out .= '</td>';
/*for($ii = 0; $ii < ($colspan - 1); $ii++)
{
$out .='<td class="'.$this->element.'_extras_'.$key.'"></td>';
}*/
if (!empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && (($e % 2) == 1)) $out .= '</tr>';
else $out .= '</tr>';
$e++;
}
}
$out .= "\n";
// Add code to manage list depending on others
if (!empty($conf->use_javascript_ajax)) {
$out .= '
<script>
jQuery(document).ready(function() {
function showOptions(child_list, parent_list)
{
var val = $("select[name=\""+parent_list+"\"]").val();
var parentVal = parent_list + ":" + val;
if(val > 0) {
$("select[name=\""+child_list+"\"] option[parent]").hide();
$("select[name=\""+child_list+"\"] option[parent=\""+parentVal+"\"]").show();
} else {
$("select[name=\""+child_list+"\"] option").show();
}
}
function setListDependencies() {
jQuery("select option[parent]").parent().each(function() {
var child_list = $(this).attr("name");
var parent = $(this).find("option[parent]:first").attr("parent");
var infos = parent.split(":");
var parent_list = infos[0];
$("select[name=\""+parent_list+"\"]").change(function() {
showOptions(child_list, parent_list);
});
});
}
setListDependencies();
});
</script>'."\n";
}
$out .= '<!-- /showOptionalsInput --> '."\n";
}
}
$out .= $hookmanager->resPrint;
return $out;
}
@ -7758,6 +7771,11 @@ abstract class CommonObject
if ($obj)
{
$this->setVarsFromFetchObj($obj);
// Retreive all extrafield
// fetch optionals attributes and labels
$this->fetch_optionals();
return $this->id;
} else {
return 0;
@ -7790,6 +7808,9 @@ abstract class CommonObject
$sql .= ' FROM '.MAIN_DB_PREFIX.$objectline->table_element;
$sql .= ' WHERE fk_'.$this->element.' = '.$this->id;
if ($morewhere) $sql .= $morewhere;
if (isset($objectline->fields['position'])) {
$sql .= $this->db->order('position', 'ASC');
}
$resql = $this->db->query($sql);
if ($resql)

View File

@ -197,17 +197,16 @@ class dolReceiptPrinter extends Printer
'dol_print_object_local_tax2' => 'TotalLT2',
'dol_print_object_total' => 'Total',
'dol_print_object_number' => 'DOL_PRINT_OBJECT_NUMBER',
'dol_value_object_points' => 'DOL_VALUE_OBJECT_POINTS',
//'dol_value_object_points' => 'DOL_VALUE_OBJECT_POINTS',
'dol_print_order_lines' => 'DOL_PRINT_ORDER_LINES',
'dol_value_customer_firstname' => 'DOL_VALUE_CUSTOMER_FIRSTNAME',
'dol_value_customer_lastname' => 'DOL_VALUE_CUSTOMER_LASTNAME',
'dol_value_customer_mail' => 'DOL_VALUE_CUSTOMER_MAIL',
'dol_value_customer_phone' => 'DOL_VALUE_CUSTOMER_PHONE',
'dol_value_customer_mobile' => 'DOL_VALUE_CUSTOMER_MOBILE',
'dol_value_customer_skype' => 'DOL_VALUE_CUSTOMER_SKYPE',
'dol_value_customer_tax_number' => 'DOL_VALUE_CUSTOMER_TAX_NUMBER',
'dol_value_customer_account_balance' => 'DOL_VALUE_CUSTOMER_ACCOUNT_BALANCE',
'dol_value_customer_points' => 'DOL_VALUE_CUSTOMER_POINTS',
//'dol_value_customer_account_balance' => 'DOL_VALUE_CUSTOMER_ACCOUNT_BALANCE',
//'dol_value_customer_points' => 'DOL_VALUE_CUSTOMER_POINTS',
'dol_value_mysoc_name' => 'DOL_VALUE_MYSOC_NAME',
'dol_value_mysoc_address' => 'Address',
'dol_value_mysoc_zip' => 'Zip',
@ -552,7 +551,7 @@ class dolReceiptPrinter extends Printer
// tags a remplacer par leur valeur avant de parser (dol_value_xxx)
$this->template = str_replace('<dol_value_object_id>', $object->id, $this->template);
$this->template = str_replace('<dol_value_object_ref>', $object->ref, $this->template);
$this->template = str_replace('<dol_value_object_points>', $object->points, $this->template);
//$this->template = str_replace('<dol_value_object_points>', $object->points, $this->template);
$this->template = str_replace('<dol_value_date>', dol_print_date($object->date, 'day'), $this->template);
$this->template = str_replace('<dol_value_date_time>', dol_print_date($object->date, 'dayhour'), $this->template);
$this->template = str_replace('<dol_value_year>', dol_print_date($object->date, '%Y'), $this->template);
@ -563,12 +562,12 @@ class dolReceiptPrinter extends Printer
$this->template = str_replace('<dol_value_customer_firstname>', $object->thirdparty->firstname, $this->template);
$this->template = str_replace('<dol_value_customer_lastname>', $object->thirdparty->lastname, $this->template);
$this->template = str_replace('<dol_value_customer_mail>', $object->thirdparty->mail, $this->template);
$this->template = str_replace('<dol_value_customer_mail>', $object->thirdparty->email, $this->template);
$this->template = str_replace('<dol_value_customer_phone>', $object->thirdparty->phone, $this->template);
$this->template = str_replace('<dol_value_customer_mobile>', $object->thirdparty->mobile, $this->template);
$this->template = str_replace('<dol_value_customer_tax_number>', $object->thirdparty->vatintra, $this->template);
$this->template = str_replace('<dol_value_customer_account_balance>', $object->customer_account_balance, $this->template);
$this->template = str_replace('<dol_value_customer_points>', $object->customer_points, $this->template);
//$this->template = str_replace('<dol_value_customer_mobile>', $object->thirdparty->mobile, $this->template);
$this->template = str_replace('<dol_value_customer_tax_number>', $object->thirdparty->tva_intra, $this->template);
//$this->template = str_replace('<dol_value_customer_account_balance>', $object->customer_account_balance, $this->template);
//$this->template = str_replace('<dol_value_customer_points>', $object->customer_points, $this->template);
$this->template = str_replace('<dol_value_mysoc_name>', $mysoc->name, $this->template);
$this->template = str_replace('<dol_value_mysoc_address>', $mysoc->address, $this->template);

View File

@ -194,7 +194,7 @@ class EvalMath
*
* @return string Output
*/
private function vars()
public function vars()
{
$output = $this->v;
unset($output['pi']);
@ -270,9 +270,11 @@ class EvalMath
// ===============
} elseif ($op == ')' and $expecting_op) { // ready to close a parenthesis?
while (($o2 = $stack->pop()) != '(') { // pop off the stack back to the last (
if (is_null($o2))
if (is_null($o2)) {
return $this->trigger(5, "unexpected ')'", ")");
else $output[] = $o2;
} else {
$output[] = $o2;
}
}
if (preg_match("/^([a-z]\w*)\($/", $stack->last(2), $matches)) { // did we just close a function?
$fnn = $matches[1]; // get the function name
@ -292,9 +294,11 @@ class EvalMath
// ===============
} elseif ($op == ',' and $expecting_op) { // did we just finish a function argument?
while (($o2 = $stack->pop()) != '(') {
if (is_null($o2))
if (is_null($o2)) {
return $this->trigger(5, "unexpected ','", ","); // oops, never had a (
else $output[] = $o2; // pop the argument expression stuff and push onto the output
} else {
$output[] = $o2; // pop the argument expression stuff and push onto the output
}
}
// make sure there was a function
if (!preg_match("/^([a-z]\w*)\($/", $stack->last(2), $matches))

View File

@ -1621,6 +1621,13 @@ class ExtraFields
$keyList .= implode(', ', $fields_label);
}
$filter_categorie = false;
if (count($InfoFieldList) > 5) {
if ($InfoFieldList[0] == 'categorie') {
$filter_categorie = true;
}
}
$sql = 'SELECT '.$keyList;
$sql .= ' FROM '.MAIN_DB_PREFIX.$InfoFieldList[0];
if (strpos($InfoFieldList[4], 'extra') !== false)
@ -1641,37 +1648,49 @@ class ExtraFields
$resql = $this->db->query($sql);
if ($resql)
{
$value = ''; // value was used, so now we reste it to use it to build final output
if ($filter_categorie === false) {
$value = ''; // value was used, so now we reste it to use it to build final output
$obj = $this->db->fetch_object($resql);
$obj = $this->db->fetch_object($resql);
// Several field into label (eq table:code|libelle:rowid)
$fields_label = explode('|', $InfoFieldList[1]);
// Several field into label (eq table:code|libelle:rowid)
$fields_label = explode('|', $InfoFieldList[1]);
if (is_array($fields_label) && count($fields_label) > 1)
{
foreach ($fields_label as $field_toshow)
{
$translabel = '';
if (!empty($obj->$field_toshow)) {
$translabel = $langs->trans($obj->$field_toshow);
if (is_array($fields_label) && count($fields_label) > 1) {
foreach ($fields_label as $field_toshow) {
$translabel = '';
if (!empty($obj->$field_toshow)) {
$translabel = $langs->trans($obj->$field_toshow);
}
if ($translabel != $field_toshow) {
$value .= dol_trunc($translabel, 18) . ' ';
} else {
$value .= $obj->$field_toshow . ' ';
}
}
if ($translabel != $field_toshow) {
$value .= dol_trunc($translabel, 18).' ';
} else {
$translabel = '';
if (!empty($obj->{$InfoFieldList[1]})) {
$translabel = $langs->trans($obj->{$InfoFieldList[1]});
}
if ($translabel != $obj->{$InfoFieldList[1]}) {
$value = dol_trunc($translabel, 18);
} else {
$value .= $obj->$field_toshow.' ';
$value = $obj->{$InfoFieldList[1]};
}
}
} else {
$translabel = '';
if (!empty($obj->{$InfoFieldList[1]})) {
$translabel = $langs->trans($obj->{$InfoFieldList[1]});
}
if ($translabel != $obj->{$InfoFieldList[1]}) {
$value = dol_trunc($translabel, 18);
} else {
$value = $obj->{$InfoFieldList[1]};
require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
$toprint = array();
$obj = $this->db->fetch_object($resql);
$c = new Categorie($this->db);
$c->fetch($obj->rowid);
$ways = $c->print_all_ways(); // $ways[0] = "ccc2 >> ccc2a >> ccc2a1" with html formatted text
foreach ($ways as $way) {
$toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories"' . ($c->color ? ' style="background: #' . $c->color . ';"' : ' style="background: #aaa"') . '>' . img_object('', 'category') . ' ' . $way . '</li>';
}
$value = '<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">'.implode(' ', $toprint).'</ul></div>';
}
} else dol_syslog(get_class($this).'::showOutputField error '.$this->db->lasterror(), LOG_WARNING);
} elseif ($type == 'radio')
@ -1710,6 +1729,13 @@ class ExtraFields
$keyList .= implode(', ', $fields_label);
}
$filter_categorie = false;
if (count($InfoFieldList) > 5) {
if ($InfoFieldList[0] == 'categorie') {
$filter_categorie = true;
}
}
$sql = 'SELECT '.$keyList;
$sql .= ' FROM '.MAIN_DB_PREFIX.$InfoFieldList[0];
if (strpos($InfoFieldList[4], 'extra') !== false) {
@ -1721,33 +1747,49 @@ class ExtraFields
dol_syslog(get_class($this).':showOutputField:$type=chkbxlst', LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql) {
$value = ''; // value was used, so now we reste it to use it to build final output
$toprint = array();
while ($obj = $this->db->fetch_object($resql)) {
// Several field into label (eq table:code|libelle:rowid)
$fields_label = explode('|', $InfoFieldList[1]);
if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {
if (is_array($fields_label) && count($fields_label) > 1) {
foreach ($fields_label as $field_toshow) {
$translabel = '';
if (!empty($obj->$field_toshow)) {
$translabel = $langs->trans($obj->$field_toshow);
if ($filter_categorie === false) {
$value = ''; // value was used, so now we reste it to use it to build final output
$toprint = array();
while ($obj = $this->db->fetch_object($resql)) {
// Several field into label (eq table:code|libelle:rowid)
$fields_label = explode('|', $InfoFieldList[1]);
if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {
if (is_array($fields_label) && count($fields_label) > 1) {
foreach ($fields_label as $field_toshow) {
$translabel = '';
if (!empty($obj->$field_toshow)) {
$translabel = $langs->trans($obj->$field_toshow);
}
if ($translabel != $field_toshow) {
$toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #aaa">' . dol_trunc($translabel, 18) . '</li>';
} else {
$toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #aaa">' . $obj->$field_toshow . '</li>';
}
}
if ($translabel != $field_toshow) {
$toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #aaa">'.dol_trunc($translabel, 18).'</li>';
} else {
$toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #aaa">'.$obj->$field_toshow.'</li>';
}
}
} else {
$translabel = '';
if (!empty($obj->{$InfoFieldList[1]})) {
$translabel = $langs->trans($obj->{$InfoFieldList[1]});
}
if ($translabel != $obj->{$InfoFieldList[1]}) {
$toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #aaa">'.dol_trunc($translabel, 18).'</li>';
} else {
$toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #aaa">'.$obj->{$InfoFieldList[1]}.'</li>';
$translabel = '';
if (!empty($obj->{$InfoFieldList[1]})) {
$translabel = $langs->trans($obj->{$InfoFieldList[1]});
}
if ($translabel != $obj->{$InfoFieldList[1]}) {
$toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #aaa">' . dol_trunc($translabel, 18) . '</li>';
} else {
$toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #aaa">' . $obj->{$InfoFieldList[1]} . '</li>';
}
}
}
}
} else {
require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
$toprint = array();
while ($obj = $this->db->fetch_object($resql)) {
if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {
$c = new Categorie($this->db);
$c->fetch($obj->rowid);
$ways = $c->print_all_ways(); // $ways[0] = "ccc2 >> ccc2a >> ccc2a1" with html formatted text
foreach ($ways as $way) {
$toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories"' . ($c->color ? ' style="background: #' . $c->color . ';"' : ' style="background: #aaa"') . '>' . img_object('', 'category') . ' ' . $way . '</li>';
}
}
}
@ -1912,7 +1954,9 @@ class ExtraFields
*
* @param array $extralabels Deprecated (old $array of extrafields, now set this to null)
* @param object $object Object
* @param string $onlykey Only the following key is filled. When we make update of only one extrafield ($action = 'update_extras'), calling page must set this to avoid to have other extrafields being reset.
* @param string $onlykey Only some keys are filled:$this
* 'string' => When we make update of only one extrafield ($action = 'update_extras'), calling page can set this to avoid to have other extrafields being reset.
* '@GETPOSTISSET' => When we make update of extrafields ($action = 'update'), calling page can set this to avoid to have fields not into POST being reset.
* @return int 1 if array_options set, 0 if no value, -1 if error (field required missing for example)
*/
public function setOptionalsFromPost($extralabels, &$object, $onlykey = '')
@ -1929,7 +1973,8 @@ class ExtraFields
// Get extra fields
foreach ($extralabels as $key => $value)
{
if (!empty($onlykey) && $key != $onlykey) continue;
if (!empty($onlykey) && $onlykey != '@GETPOSTISSET' && $key != $onlykey) continue;
if (!empty($onlykey) && $onlykey == '@GETPOSTISSET' && ! GETPOSTISSET('options_'.$key)) continue;
$key_type = $this->attributes[$object->table_element]['type'][$key];
if ($key_type == 'separate') continue;
@ -1960,28 +2005,26 @@ class ExtraFields
}
}
if (in_array($key_type, array('date')))
{
if (in_array($key_type, array('date'))) {
// Clean parameters
// TODO GMT date in memory must be GMT so we should add gm=true in parameters
$value_key = dol_mktime(0, 0, 0, $_POST["options_".$key."month"], $_POST["options_".$key."day"], $_POST["options_".$key."year"]);
} elseif (in_array($key_type, array('datetime')))
{
} elseif (in_array($key_type, array('datetime'))) {
// Clean parameters
// TODO GMT date in memory must be GMT so we should add gm=true in parameters
$value_key = dol_mktime($_POST["options_".$key."hour"], $_POST["options_".$key."min"], 0, $_POST["options_".$key."month"], $_POST["options_".$key."day"], $_POST["options_".$key."year"]);
} elseif (in_array($key_type, array('checkbox', 'chkbxlst')))
{
} elseif (in_array($key_type, array('checkbox', 'chkbxlst'))) {
$value_arr = GETPOST("options_".$key, 'array'); // check if an array
if (!empty($value_arr)) {
$value_key = implode($value_arr, ',');
} else {
$value_key = '';
}
} elseif (in_array($key_type, array('price', 'double')))
{
} elseif (in_array($key_type, array('price', 'double'))) {
$value_arr = GETPOST("options_".$key, 'alpha');
$value_key = price2num($value_arr);
} elseif (in_array($key_type, array('html'))) {
$value_key = GETPOST("options_".$key, 'alpha');
} else {
$value_key = GETPOST("options_".$key);
if (in_array($key_type, array('link')) && $value_key == '-1') $value_key = '';

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