Merge remote-tracking branch 'Dolibarr/13.0' into 13
This commit is contained in:
commit
69c99063b2
@ -50,6 +50,9 @@ jobs:
|
||||
- if: type = push AND branch = develop
|
||||
php: nightly
|
||||
env: DB=mysql
|
||||
- if: type = push AND branch = 13.0
|
||||
php: nightly
|
||||
env: DB=mysql
|
||||
|
||||
notifications:
|
||||
email:
|
||||
@ -400,7 +403,7 @@ script:
|
||||
php step5.php 12.0.0 13.0.0 > $TRAVIS_BUILD_DIR/upgrade12001300-3.log
|
||||
|
||||
# Enable modules not enabled into original dump
|
||||
php upgrade2.php 0.0.0 0.0.0 MAIN_MODULE_API,MAIN_MODULE_SUPPLIERPROPOSAL,MAIN_MODULE_WEBSITE,MAIN_MODULE_TICKET,MAIN_MODULE_ACCOUNTING,MAIN_MODULE_MRP > $TRAVIS_BUILD_DIR/enablemodule.log
|
||||
php upgrade2.php 0.0.0 0.0.0 MAIN_MODULE_API,MAIN_MODULE_PRODUCTBATCH,MAIN_MODULE_SUPPLIERPROPOSAL,MAIN_MODULE_WEBSITE,MAIN_MODULE_TICKET,MAIN_MODULE_ACCOUNTING,MAIN_MODULE_MRP > $TRAVIS_BUILD_DIR/enablemodule.log
|
||||
php upgrade2.php 0.0.0 0.0.0 MAIN_MODULE_RECEPTION,MAIN_MODULE_RECRUITMENT > $TRAVIS_BUILD_DIR/enablemodule.log
|
||||
echo $?
|
||||
cd -
|
||||
|
||||
@ -29,7 +29,7 @@ PHPoAuthLib 0.8.2 MIT License Yes
|
||||
PHPPrintIPP 1.3 GPL-2+ Yes Library to send print IPP requests
|
||||
PSR/Logs 1.0 Library for logs (used by DebugBar)
|
||||
PSR/simple-cache ? Library for cache (used by PHPSpreadSheet)
|
||||
Restler 3.0.0RC6 LGPL-3+ Yes Library to develop REST Web services (+ swagger-ui js lib into dir explorer)
|
||||
Restler 3.1.1 LGPL-3+ Yes Library to develop REST Web services (+ swagger-ui js lib into dir explorer)
|
||||
Sabre 3.2.2 BSD Yes DAV support
|
||||
Swift Mailer 5.4.2-DEV MIT license Yes Comprehensive mailing tools for PHP
|
||||
Stripe 6.43.1 MIT licence Yes Library for Stripe module
|
||||
|
||||
@ -60,18 +60,19 @@ ONLY vulnerabilities discovered, when the following setup on test platform is us
|
||||
* ONLY security reports on modules provided by default and with the "stable" status are valid (troubles into "experimental", "developement" or external modules are not valid vulnerabilities).
|
||||
* The root of web server must link to htdocs and the documents directory must be outside of the web server root (this is the default when using the default installer but may differs with external installer).
|
||||
* The web server setup must be done so only the documents directory is in write mode. The root directory called htdocs must be readonly.
|
||||
* CSRF attacks are accepted for all when using a POST URL, but when using GET URL, they are validated only for creating or updating data resctricted to the admin user.
|
||||
* CSRF attacks are accepted when using a POST URL, but when using GET URL, they are validated only for creating, updating or deleting data resctricted from pages restricted to admin users.
|
||||
* Ability for a high level user to edit web site pages into the CMS by including HTML or Javascript is an expected feature. Vulnerabilities into the website module are validated only if HTML or Javascript injection can be done by a non allowed user.
|
||||
|
||||
Scope is the web application (back office) and the APIs.
|
||||
|
||||
|
||||
## Qualifying vulnerabilities for Bug bounty programs
|
||||
|
||||
* Remote code execution (RCE)
|
||||
* Local files access and manipulation (LFI, RFI, XXE, SSRF, XSPA)
|
||||
* Code injections (HTML, JS, SQL, PHP, ...)
|
||||
* Cross-Site Scripting (XSS)
|
||||
* Cross-Site Requests Forgery (CSRF) with real security impact
|
||||
* Cross-Site Requests Forgery (CSRF) with real security impact (when using GET URLs, CSRF are qualified only for creating, updating or deleting data from pages restricted to admin users)
|
||||
* Open redirect
|
||||
* Broken authentication & session management
|
||||
* Insecure direct object references
|
||||
@ -83,6 +84,7 @@ Scope is the web application (back office) and the APIs.
|
||||
|
||||
|
||||
## Non-qualifying vulnerabilities for Bug bounty programs, but qualified for reporting
|
||||
|
||||
* "Self" XSS
|
||||
* SSL/TLS best practices
|
||||
* Denial of Service attacks
|
||||
|
||||
@ -292,6 +292,7 @@ done >>%{name}.lang
|
||||
%_datadir/dolibarr/htdocs/product
|
||||
%_datadir/dolibarr/htdocs/projet
|
||||
%_datadir/dolibarr/htdocs/public
|
||||
%_datadir/dolibarr/htdocs/recruitment
|
||||
%_datadir/dolibarr/htdocs/reception
|
||||
%_datadir/dolibarr/htdocs/resource
|
||||
%_datadir/dolibarr/htdocs/salaries
|
||||
|
||||
@ -209,6 +209,7 @@ done >>%{name}.lang
|
||||
%_datadir/dolibarr/htdocs/product
|
||||
%_datadir/dolibarr/htdocs/projet
|
||||
%_datadir/dolibarr/htdocs/public
|
||||
%_datadir/dolibarr/htdocs/recruitment
|
||||
%_datadir/dolibarr/htdocs/reception
|
||||
%_datadir/dolibarr/htdocs/resource
|
||||
%_datadir/dolibarr/htdocs/salaries
|
||||
|
||||
@ -220,6 +220,7 @@ done >>%{name}.lang
|
||||
%_datadir/dolibarr/htdocs/product
|
||||
%_datadir/dolibarr/htdocs/projet
|
||||
%_datadir/dolibarr/htdocs/public
|
||||
%_datadir/dolibarr/htdocs/recruitment
|
||||
%_datadir/dolibarr/htdocs/reception
|
||||
%_datadir/dolibarr/htdocs/resource
|
||||
%_datadir/dolibarr/htdocs/salaries
|
||||
|
||||
@ -229,11 +229,21 @@ Change content of file htdocs/includes/restler/framework/Luracast/Restler/explor
|
||||
public static function getShortName($className)
|
||||
{
|
||||
// @CHANGE LDR
|
||||
if (! is_string($className)) return;
|
||||
if (!is_string($className)) return;
|
||||
//var_dump($className);
|
||||
|
||||
|
||||
|
||||
* Add line into Data/Text.php to complete function
|
||||
|
||||
public static function endsWith($haystack, $needle)
|
||||
{
|
||||
$length = strlen($needle);
|
||||
if ($length == 0) {
|
||||
return true;
|
||||
}
|
||||
// @CHANGE LDR
|
||||
if (!is_string($haystack)) return false;
|
||||
|
||||
|
||||
PARSEDOWN
|
||||
---------
|
||||
|
||||
|
||||
@ -15,6 +15,9 @@ function faaa()
|
||||
return 'faaa';
|
||||
}
|
||||
|
||||
/**
|
||||
* Class Aaa
|
||||
*/
|
||||
class Aaa
|
||||
{
|
||||
const AAA='aaa';
|
||||
|
||||
@ -12,6 +12,9 @@ function fbbb()
|
||||
return 'fbbb';
|
||||
}
|
||||
|
||||
/**
|
||||
* Class Bbb
|
||||
*/
|
||||
class Bbb
|
||||
{
|
||||
const BBB='bbb';
|
||||
|
||||
@ -146,12 +146,7 @@ $arrayfields = array(
|
||||
'd.statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000)
|
||||
);
|
||||
// Extra fields
|
||||
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) {
|
||||
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
|
||||
if (!empty($extrafields->attributes[$object->table_element]['list'][$key]))
|
||||
$arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key]));
|
||||
}
|
||||
}
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
|
||||
|
||||
|
||||
/*
|
||||
|
||||
@ -135,12 +135,13 @@ if ($action == 'deletefilter')
|
||||
{
|
||||
$emailcollectorfilter = new EmailCollectorFilter($db);
|
||||
$emailcollectorfilter->fetch(GETPOST('filterid', 'int'));
|
||||
$result = $emailcollectorfilter->delete($user);
|
||||
if ($result > 0)
|
||||
{
|
||||
$object->fetchFilters();
|
||||
} else {
|
||||
setEventMessages($emailcollectorfilter->errors, $emailcollectorfilter->error, 'errors');
|
||||
if ($emailcollectorfilter->id > 0) {
|
||||
$result = $emailcollectorfilter->delete($user);
|
||||
if ($result > 0) {
|
||||
$object->fetchFilters();
|
||||
} else {
|
||||
setEventMessages($emailcollectorfilter->errors, $emailcollectorfilter->error, 'errors');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -153,13 +154,25 @@ if (GETPOST('addoperation', 'alpha'))
|
||||
$emailcollectoroperation->status = 1;
|
||||
$emailcollectoroperation->position = 50;
|
||||
|
||||
$result = $emailcollectoroperation->create($user);
|
||||
if ($emailcollectoroperation->type == '-1') {
|
||||
$error++;
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Operation")), null, 'errors');
|
||||
}
|
||||
if (in_array($emailcollectoroperation->type, array('loadthirdparty', 'loadandcreatethirdparty'))
|
||||
&& empty($emailcollectoroperation->actionparam)) {
|
||||
$error++;
|
||||
setEventMessages($langs->trans("ErrorAParameterIsRequiredForThisOperation"), null, 'errors');
|
||||
}
|
||||
|
||||
if ($result > 0)
|
||||
{
|
||||
$object->fetchActions();
|
||||
} else {
|
||||
setEventMessages($emailcollectoroperation->errors, $emailcollectoroperation->error, 'errors');
|
||||
if (!$error) {
|
||||
$result = $emailcollectoroperation->create($user);
|
||||
|
||||
if ($result > 0) {
|
||||
$object->fetchActions();
|
||||
} else {
|
||||
$error++;
|
||||
setEventMessages($emailcollectoroperation->errors, $emailcollectoroperation->error, 'errors');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -170,25 +183,35 @@ if ($action == 'updateoperation')
|
||||
|
||||
$emailcollectoroperation->actionparam = GETPOST('operationparam2', 'restricthtml');
|
||||
|
||||
$result = $emailcollectoroperation->update($user);
|
||||
if (in_array($emailcollectoroperation->type, array('loadthirdparty', 'loadandcreatethirdparty'))
|
||||
&& empty($emailcollectoroperation->actionparam)) {
|
||||
$error++;
|
||||
setEventMessages($langs->trans("ErrorAParameterIsRequiredForThisOperation"), null, 'errors');
|
||||
}
|
||||
|
||||
if ($result > 0)
|
||||
{
|
||||
$object->fetchActions();
|
||||
} else {
|
||||
setEventMessages($emailcollectoroperation->errors, $emailcollectoroperation->error, 'errors');
|
||||
if (!$error) {
|
||||
$result = $emailcollectoroperation->update($user);
|
||||
|
||||
if ($result > 0)
|
||||
{
|
||||
$object->fetchActions();
|
||||
} else {
|
||||
$error++;
|
||||
setEventMessages($emailcollectoroperation->errors, $emailcollectoroperation->error, 'errors');
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($action == 'deleteoperation')
|
||||
{
|
||||
$emailcollectoroperation = new EmailCollectorAction($db);
|
||||
$emailcollectoroperation->fetch(GETPOST('operationid', 'int'));
|
||||
$result = $emailcollectoroperation->delete($user);
|
||||
if ($result > 0)
|
||||
{
|
||||
$object->fetchActions();
|
||||
} else {
|
||||
setEventMessages($emailcollectoroperation->errors, $emailcollectoroperation->error, 'errors');
|
||||
if ($emailcollectoroperation->id > 0) {
|
||||
$result = $emailcollectoroperation->delete($user);
|
||||
if ($result > 0) {
|
||||
$object->fetchActions();
|
||||
} else {
|
||||
setEventMessages($emailcollectoroperation->errors, $emailcollectoroperation->error, 'errors');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -458,7 +481,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
print '<div class="div-table-responsive">';
|
||||
print '<table class="border centpercent tableforfield">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans("Filters").'</td><td></td><td></td>';
|
||||
print '<td>'.$form->textwithpicto($langs->trans("Filters"), $langs->trans("EmailCollectorFilterDesc")).'</td><td></td><td></td>';
|
||||
print '</tr>';
|
||||
// Add filter
|
||||
print '<tr class="oddeven">';
|
||||
@ -491,7 +514,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
'isnotanswer'=>array('label'=>'IsNotAnAnswer', 'data-noparam'=>1),
|
||||
'isanswer'=>array('label'=>'IsAnAnswer', 'data-noparam'=>1)
|
||||
);
|
||||
print $form->selectarray('filtertype', $arrayoftypes, '', 1, 0, 0, '', 1, 0, 0, '', 'maxwidth500', 0, '', 2);
|
||||
print $form->selectarray('filtertype', $arrayoftypes, '', 1, 0, 0, '', 1, 0, 0, '', 'maxwidth500', 1, '', 2);
|
||||
|
||||
print "\n";
|
||||
print '<script>';
|
||||
@ -544,7 +567,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
print '<div class="div-table-responsive">';
|
||||
print '<table id="tablelines" class="noborder noshadow tableforfield">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans("EmailcollectorOperations").'</td><td></td><td></td><td></td>';
|
||||
print '<td>'.$form->textwithpicto($langs->trans("EmailcollectorOperations"), $langs->trans("EmailcollectorOperationsDesc")).'</td><td></td><td></td><td></td>';
|
||||
print '</tr>';
|
||||
// Add operation
|
||||
print '<tr class="oddeven">';
|
||||
@ -561,13 +584,15 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
$parameters = array('arrayoftypes' => $arrayoftypes);
|
||||
$res = $hookmanager->executeHooks('addMoreActionsEmailCollector', $parameters, $object, $action);
|
||||
|
||||
if ($res)
|
||||
if ($res) {
|
||||
$arrayoftypes = $hookmanager->resArray;
|
||||
else foreach ($hookmanager->resArray as $k=>$desc)
|
||||
} else {
|
||||
foreach ($hookmanager->resArray as $k=>$desc) {
|
||||
$arrayoftypes[$k] = $desc;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
print $form->selectarray('operationtype', $arrayoftypes, '', 1, 0, 0, '', 1, 0, 0, '', 'maxwidth300');
|
||||
print $form->selectarray('operationtype', $arrayoftypes, '', 1, 0, 0, '', 1, 0, 0, '', 'maxwidth300', 1);
|
||||
print '</td><td>';
|
||||
print '<input type="text" name="operationparam">';
|
||||
print '</td>';
|
||||
|
||||
@ -123,7 +123,7 @@ print '</td></tr>';
|
||||
|
||||
print '<tr class="oddeven"><td>';
|
||||
print $langs->trans("MailingDelay").'</td><td>';
|
||||
print '<input size="32" type="text" name="MAILING_DELAY" value="'.$conf->global->MAILING_DELAY.'">';
|
||||
print '<input class="width75" type="text" name="MAILING_DELAY" value="'.$conf->global->MAILING_DELAY.'">';
|
||||
print '</td></tr>';
|
||||
|
||||
|
||||
|
||||
@ -1,118 +0,0 @@
|
||||
<?php
|
||||
/* Copyright (C) 2018 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2019 Alexandre Spangaro <aspangaro@open-dsi.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/socialnetworks.php
|
||||
* \ingroup socialnetworks
|
||||
* \brief Page to setup the module Social Networks
|
||||
*/
|
||||
|
||||
require '../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/mailmanspip.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array("admin", "errors"));
|
||||
|
||||
if (!$user->admin) accessforbidden();
|
||||
|
||||
$type = array('yesno', 'texte', 'chaine');
|
||||
|
||||
$action = GETPOST('action', 'aZ09');
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Action
|
||||
*/
|
||||
if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg))
|
||||
{
|
||||
$code = $reg[1];
|
||||
if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0)
|
||||
{
|
||||
header("Location: ".$_SERVER["PHP_SELF"]);
|
||||
exit;
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
}
|
||||
|
||||
if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg))
|
||||
{
|
||||
$code = $reg[1];
|
||||
if (dolibarr_del_const($db, $code, $conf->entity) > 0)
|
||||
{
|
||||
header("Location: ".$_SERVER["PHP_SELF"]);
|
||||
exit;
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
$help_url = '';
|
||||
|
||||
llxHeader('', $langs->trans("SocialNetworkSetup"), $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("SocialNetworkSetup"), $linkback, 'title_setup');
|
||||
|
||||
//$head = socialnetworks_admin_prepare_head();
|
||||
$h = 0;
|
||||
$head = array();
|
||||
$head[$h][0] = DOL_URL_ROOT.'/admin/socialnetworks.php';
|
||||
$head[$h][1] = $langs->trans("Setup");
|
||||
$head[$h][2] = 'setup';
|
||||
$h++;
|
||||
|
||||
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
||||
|
||||
print dol_get_fiche_head($head, 'setup', '', 0, 'user');
|
||||
|
||||
print '<br>';
|
||||
|
||||
$arrayofsocialnetworks = array('jabber'=>'Jabber', 'skype'=>'Skype', 'twitter'=>'Twitter', 'facebook'=>'Facebook', 'linkedin'=>'LinkedIn');
|
||||
|
||||
foreach ($arrayofsocialnetworks as $snkey => $snlabel) {
|
||||
$consttocheck = 'SOCIALNETWORKS_'.strtoupper($snkey);
|
||||
if ($conf->use_javascript_ajax) {
|
||||
$link = ajax_constantonoff($consttocheck);
|
||||
} else {
|
||||
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
|
||||
$link = $form->selectarray($consttocheck, $arrval, $conf->global->$consttocheck);
|
||||
}
|
||||
|
||||
print $langs->trans('EnableFeatureFor', $snlabel).' '.$link.'<br><br>';
|
||||
}
|
||||
|
||||
|
||||
print dol_get_fiche_end();
|
||||
|
||||
print '</form>';
|
||||
|
||||
|
||||
// End of page
|
||||
llxFooter();
|
||||
$db->close();
|
||||
@ -173,7 +173,7 @@ class DolibarrApi
|
||||
unset($object->name_bis);
|
||||
unset($object->newref);
|
||||
|
||||
if ($object->table_element != 'ticket') {
|
||||
if (!isset($object->table_element) || $object->table_element != 'ticket') {
|
||||
unset($object->comments);
|
||||
}
|
||||
|
||||
|
||||
@ -707,7 +707,7 @@ class Documents extends DolibarrApi
|
||||
|
||||
if (!empty($createdirifnotexists)) {
|
||||
if (dol_mkdir($upload_dir) < 0) { // needed by products
|
||||
throw new RestException(500, 'Error while trying to create directory.');
|
||||
throw new RestException(500, 'Error while trying to create directory '.$upload_dir);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -48,8 +48,8 @@ class Login
|
||||
* @param int $reset Reset token (0=get current token, 1=ask a new token and canceled old token. This means access using current existing API token of user will fails: new token will be required for new access)
|
||||
* @return array Response status and user token
|
||||
*
|
||||
* @throws RestException 403
|
||||
* @throws RestException 500
|
||||
* @throws RestException 403 Access denied
|
||||
* @throws RestException 500 System error
|
||||
*
|
||||
* @url GET /
|
||||
* @url POST /
|
||||
@ -109,7 +109,7 @@ class Login
|
||||
}
|
||||
|
||||
// Generate token for user
|
||||
$token = dol_hash($login.uniqid().$conf->global->MAIN_API_KEY, 1);
|
||||
$token = dol_hash($login.uniqid().(empty($conf->global->MAIN_API_KEY)?'':$conf->global->MAIN_API_KEY), 1);
|
||||
|
||||
// We store API token into database
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."user";
|
||||
@ -132,7 +132,7 @@ class Login
|
||||
'code' => 200,
|
||||
'token' => $token,
|
||||
'entity' => $tmpuser->entity,
|
||||
'message' => 'Welcome '.$login.($reset ? ' - Token is new' : ' - This is your token (generated by a previous call). You can use it to make any REST API call, or enter it into the DOLAPIKEY field to use the Dolibarr API explorer.')
|
||||
'message' => 'Welcome '.$login.($reset ? ' - Token is new' : ' - This is your token (recorded for your user). You can use it to make any REST API call, or enter it into the DOLAPIKEY field to use the Dolibarr API explorer.')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@ -75,10 +75,8 @@ class Setup extends DolibarrApi
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."c_input_method as t";
|
||||
$sql .= " WHERE t.active = ".$active;
|
||||
// Add sql filters
|
||||
if ($sqlfilters)
|
||||
{
|
||||
if (!DolibarrApi::_checkFilters($sqlfilters))
|
||||
{
|
||||
if ($sqlfilters) {
|
||||
if (!DolibarrApi::_checkFilters($sqlfilters)) {
|
||||
throw new RestException(400, 'error when validating parameter sqlfilters '.$sqlfilters);
|
||||
}
|
||||
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
|
||||
@ -112,70 +110,68 @@ class Setup extends DolibarrApi
|
||||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of ordering origins.
|
||||
*
|
||||
* @param string $sortfield Sort field
|
||||
* @param string $sortorder Sort order
|
||||
* @param int $limit Number of items per page
|
||||
* @param int $page Page number {@min 0}
|
||||
* @param int $active Payment type is active or not {@min 0} {@max 1}
|
||||
* @param string $sqlfilters SQL criteria to filter with. Syntax example "(t.code:=:'OrderByWWW')"
|
||||
*
|
||||
* @url GET dictionary/ordering_origins
|
||||
*
|
||||
* @return array [List of ordering reasons]
|
||||
*
|
||||
* @throws RestException 400
|
||||
*/
|
||||
public function getOrderingOrigins($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '')
|
||||
{
|
||||
$list = array();
|
||||
/**
|
||||
* Get the list of ordering origins.
|
||||
*
|
||||
* @param string $sortfield Sort field
|
||||
* @param string $sortorder Sort order
|
||||
* @param int $limit Number of items per page
|
||||
* @param int $page Page number {@min 0}
|
||||
* @param int $active Payment type is active or not {@min 0} {@max 1}
|
||||
* @param string $sqlfilters SQL criteria to filter with. Syntax example "(t.code:=:'OrderByWWW')"
|
||||
*
|
||||
* @url GET dictionary/ordering_origins
|
||||
*
|
||||
* @return array [List of ordering reasons]
|
||||
*
|
||||
* @throws RestException 400
|
||||
*/
|
||||
public function getOrderingOrigins($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '')
|
||||
{
|
||||
$list = array();
|
||||
|
||||
if (!DolibarrApiAccess::$user->rights->commande->lire) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
if (!DolibarrApiAccess::$user->rights->commande->lire) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
$sql = "SELECT rowid, code, label, module";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."c_input_reason as t";
|
||||
$sql .= " WHERE t.active = ".$active;
|
||||
// Add sql filters
|
||||
if ($sqlfilters)
|
||||
{
|
||||
if (!DolibarrApi::_checkFilters($sqlfilters))
|
||||
{
|
||||
throw new RestException(400, 'error when validating parameter sqlfilters '.$sqlfilters);
|
||||
}
|
||||
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
|
||||
$sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
|
||||
}
|
||||
$sql = "SELECT rowid, code, label, module";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."c_input_reason as t";
|
||||
$sql .= " WHERE t.active = ".$active;
|
||||
// Add sql filters
|
||||
if ($sqlfilters) {
|
||||
if (!DolibarrApi::_checkFilters($sqlfilters)) {
|
||||
throw new RestException(400, 'error when validating parameter sqlfilters '.$sqlfilters);
|
||||
}
|
||||
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
|
||||
$sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
|
||||
}
|
||||
|
||||
|
||||
$sql .= $this->db->order($sortfield, $sortorder);
|
||||
$sql .= $this->db->order($sortfield, $sortorder);
|
||||
|
||||
if ($limit) {
|
||||
if ($page < 0) {
|
||||
$page = 0;
|
||||
}
|
||||
$offset = $limit * $page;
|
||||
if ($limit) {
|
||||
if ($page < 0) {
|
||||
$page = 0;
|
||||
}
|
||||
$offset = $limit * $page;
|
||||
|
||||
$sql .= $this->db->plimit($limit, $offset);
|
||||
}
|
||||
$sql .= $this->db->plimit($limit, $offset);
|
||||
}
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
$result = $this->db->query($sql);
|
||||
|
||||
if ($result) {
|
||||
$num = $this->db->num_rows($result);
|
||||
$min = min($num, ($limit <= 0 ? $num : $limit));
|
||||
for ($i = 0; $i < $min; $i++) {
|
||||
$list[] = $this->db->fetch_object($result);
|
||||
}
|
||||
} else {
|
||||
throw new RestException(400, $this->db->lasterror());
|
||||
}
|
||||
if ($result) {
|
||||
$num = $this->db->num_rows($result);
|
||||
$min = min($num, ($limit <= 0 ? $num : $limit));
|
||||
for ($i = 0; $i < $min; $i++) {
|
||||
$list[] = $this->db->fetch_object($result);
|
||||
}
|
||||
} else {
|
||||
throw new RestException(400, $this->db->lasterror());
|
||||
}
|
||||
|
||||
return $list;
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of payments types.
|
||||
@ -206,10 +202,8 @@ class Setup extends DolibarrApi
|
||||
$sql .= " WHERE t.entity IN (".getEntity('c_paiement').")";
|
||||
$sql .= " AND t.active = ".$active;
|
||||
// Add sql filters
|
||||
if ($sqlfilters)
|
||||
{
|
||||
if (!DolibarrApi::_checkFilters($sqlfilters))
|
||||
{
|
||||
if ($sqlfilters) {
|
||||
if (!DolibarrApi::_checkFilters($sqlfilters)) {
|
||||
throw new RestException(400, 'error when validating parameter sqlfilters '.$sqlfilters);
|
||||
}
|
||||
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
|
||||
@ -272,10 +266,8 @@ class Setup extends DolibarrApi
|
||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."c_departements as t";
|
||||
$sql .= " WHERE 1 = 1";
|
||||
// Add sql filters
|
||||
if ($sqlfilters)
|
||||
{
|
||||
if (!DolibarrApi::_checkFilters($sqlfilters))
|
||||
{
|
||||
if ($sqlfilters) {
|
||||
if (!DolibarrApi::_checkFilters($sqlfilters)) {
|
||||
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
|
||||
}
|
||||
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
|
||||
@ -374,10 +366,8 @@ class Setup extends DolibarrApi
|
||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."c_country as t";
|
||||
$sql .= " WHERE 1 = 1";
|
||||
// Add sql filters
|
||||
if ($sqlfilters)
|
||||
{
|
||||
if (!DolibarrApi::_checkFilters($sqlfilters))
|
||||
{
|
||||
if ($sqlfilters) {
|
||||
if (!DolibarrApi::_checkFilters($sqlfilters)) {
|
||||
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
|
||||
}
|
||||
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
|
||||
@ -551,10 +541,8 @@ class Setup extends DolibarrApi
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."c_availability as t";
|
||||
$sql .= " WHERE t.active = ".$active;
|
||||
// Add sql filters
|
||||
if ($sqlfilters)
|
||||
{
|
||||
if (!DolibarrApi::_checkFilters($sqlfilters))
|
||||
{
|
||||
if ($sqlfilters) {
|
||||
if (!DolibarrApi::_checkFilters($sqlfilters)) {
|
||||
throw new RestException(400, 'error when validating parameter sqlfilters '.$sqlfilters);
|
||||
}
|
||||
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
|
||||
@ -659,10 +647,8 @@ class Setup extends DolibarrApi
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."c_shipment_mode as t";
|
||||
$sql .= " WHERE t.active = ".$active;
|
||||
// Add sql filters
|
||||
if ($sqlfilters)
|
||||
{
|
||||
if (!DolibarrApi::_checkFilters($sqlfilters))
|
||||
{
|
||||
if ($sqlfilters) {
|
||||
if (!DolibarrApi::_checkFilters($sqlfilters)) {
|
||||
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
|
||||
}
|
||||
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
|
||||
@ -720,13 +706,15 @@ class Setup extends DolibarrApi
|
||||
$sql = "SELECT id, code, type, libelle as label, module";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."c_actioncomm as t";
|
||||
$sql .= " WHERE t.active = ".$active;
|
||||
if ($type) $sql .= " AND t.type LIKE '%".$this->db->escape($type)."%'";
|
||||
if ($module) $sql .= " AND t.module LIKE '%".$this->db->escape($module)."%'";
|
||||
if ($type) {
|
||||
$sql .= " AND t.type LIKE '%".$this->db->escape($type)."%'";
|
||||
}
|
||||
if ($module) {
|
||||
$sql .= " AND t.module LIKE '%".$this->db->escape($module)."%'";
|
||||
}
|
||||
// Add sql filters
|
||||
if ($sqlfilters)
|
||||
{
|
||||
if (!DolibarrApi::_checkFilters($sqlfilters))
|
||||
{
|
||||
if ($sqlfilters) {
|
||||
if (!DolibarrApi::_checkFilters($sqlfilters)) {
|
||||
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
|
||||
}
|
||||
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
|
||||
@ -784,12 +772,12 @@ class Setup extends DolibarrApi
|
||||
$sql = "SELECT id, code, label, accountancy_code, active, module, position";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."c_type_fees as t";
|
||||
$sql .= " WHERE t.active = ".$active;
|
||||
if ($module) $sql .= " AND t.module LIKE '%".$this->db->escape($module)."%'";
|
||||
if ($module) {
|
||||
$sql .= " AND t.module LIKE '%".$this->db->escape($module)."%'";
|
||||
}
|
||||
// Add sql filters
|
||||
if ($sqlfilters)
|
||||
{
|
||||
if (!DolibarrApi::_checkFilters($sqlfilters))
|
||||
{
|
||||
if ($sqlfilters) {
|
||||
if (!DolibarrApi::_checkFilters($sqlfilters)) {
|
||||
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
|
||||
}
|
||||
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
|
||||
@ -848,13 +836,15 @@ class Setup extends DolibarrApi
|
||||
$sql = "SELECT rowid, code, element as type, libelle as label, source, module, position";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."c_type_contact as t";
|
||||
$sql .= " WHERE t.active = ".$active;
|
||||
if ($type) $sql .= " AND type LIKE '%".$this->db->escape($type)."%'";
|
||||
if ($module) $sql .= " AND t.module LIKE '%".$this->db->escape($module)."%'";
|
||||
if ($type) {
|
||||
$sql .= " AND type LIKE '%".$this->db->escape($type)."%'";
|
||||
}
|
||||
if ($module) {
|
||||
$sql .= " AND t.module LIKE '%".$this->db->escape($module)."%'";
|
||||
}
|
||||
// Add sql filters
|
||||
if ($sqlfilters)
|
||||
{
|
||||
if (!DolibarrApi::_checkFilters($sqlfilters))
|
||||
{
|
||||
if ($sqlfilters) {
|
||||
if (!DolibarrApi::_checkFilters($sqlfilters)) {
|
||||
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
|
||||
}
|
||||
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
|
||||
@ -911,12 +901,12 @@ class Setup extends DolibarrApi
|
||||
$sql = "SELECT rowid, code, label, module";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."c_civility as t";
|
||||
$sql .= " WHERE t.active = ".$active;
|
||||
if ($module) $sql .= " AND t.module LIKE '%".$this->db->escape($module)."%'";
|
||||
if ($module) {
|
||||
$sql .= " AND t.module LIKE '%".$this->db->escape($module)."%'";
|
||||
}
|
||||
// Add sql filters
|
||||
if ($sqlfilters)
|
||||
{
|
||||
if (!DolibarrApi::_checkFilters($sqlfilters))
|
||||
{
|
||||
if ($sqlfilters) {
|
||||
if (!DolibarrApi::_checkFilters($sqlfilters)) {
|
||||
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
|
||||
}
|
||||
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
|
||||
@ -970,7 +960,9 @@ class Setup extends DolibarrApi
|
||||
{
|
||||
$list = array();
|
||||
$sql = "SELECT t.code_iso, t.label, t.unicode";
|
||||
if (!empty($multicurrency)) $sql .= " , cr.date_sync, cr.rate ";
|
||||
if (!empty($multicurrency)) {
|
||||
$sql .= " , cr.date_sync, cr.rate ";
|
||||
}
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."c_currencies as t";
|
||||
if (!empty($multicurrency)) {
|
||||
$sql .= " JOIN ".MAIN_DB_PREFIX."multicurrency as m ON m.code=t.code_iso";
|
||||
@ -985,10 +977,8 @@ class Setup extends DolibarrApi
|
||||
}
|
||||
|
||||
// Add sql filters
|
||||
if ($sqlfilters)
|
||||
{
|
||||
if (!DolibarrApi::_checkFilters($sqlfilters))
|
||||
{
|
||||
if ($sqlfilters) {
|
||||
if (!DolibarrApi::_checkFilters($sqlfilters)) {
|
||||
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
|
||||
}
|
||||
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
|
||||
@ -1043,18 +1033,22 @@ class Setup extends DolibarrApi
|
||||
throw new RestException(401, 'Only an admin user can get list of extrafields');
|
||||
}
|
||||
|
||||
if ($type == 'thirdparty') $type = 'societe';
|
||||
if ($type == 'contact') $type = 'socpeople';
|
||||
if ($type == 'thirdparty') {
|
||||
$type = 'societe';
|
||||
}
|
||||
if ($type == 'contact') {
|
||||
$type = 'socpeople';
|
||||
}
|
||||
|
||||
$sql = "SELECT t.rowid, t.name, t.label, t.type, t.size, t.elementtype, t.fieldunique, t.fieldrequired, t.param, t.pos, t.alwayseditable, t.perms, t.list, t.fielddefault, t.fieldcomputed";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."extrafields as t";
|
||||
$sql .= " WHERE t.entity IN (".getEntity('extrafields').")";
|
||||
if (!empty($type)) $sql .= " AND t.elementtype = '".$this->db->escape($type)."'";
|
||||
if (!empty($type)) {
|
||||
$sql .= " AND t.elementtype = '".$this->db->escape($type)."'";
|
||||
}
|
||||
// Add sql filters
|
||||
if ($sqlfilters)
|
||||
{
|
||||
if (!DolibarrApi::_checkFilters($sqlfilters))
|
||||
{
|
||||
if ($sqlfilters) {
|
||||
if (!DolibarrApi::_checkFilters($sqlfilters)) {
|
||||
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
|
||||
}
|
||||
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
|
||||
@ -1064,12 +1058,9 @@ class Setup extends DolibarrApi
|
||||
$sql .= $this->db->order($sortfield, $sortorder);
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($this->db->num_rows($resql))
|
||||
{
|
||||
while ($tab = $this->db->fetch_object($resql))
|
||||
{
|
||||
if ($resql) {
|
||||
if ($this->db->num_rows($resql)) {
|
||||
while ($tab = $this->db->fetch_object($resql)) {
|
||||
// New usage
|
||||
$list[$tab->elementtype][$tab->name]['type'] = $tab->type;
|
||||
$list[$tab->elementtype][$tab->name]['label'] = $tab->label;
|
||||
@ -1090,8 +1081,7 @@ class Setup extends DolibarrApi
|
||||
throw new RestException(503, 'Error when retrieving list of extra fields : '.$this->db->lasterror());
|
||||
}
|
||||
|
||||
if (!count($list))
|
||||
{
|
||||
if (!count($list)) {
|
||||
throw new RestException(404, 'No extrafield found');
|
||||
}
|
||||
|
||||
@ -1123,13 +1113,15 @@ class Setup extends DolibarrApi
|
||||
$sql = "SELECT rowid AS id, zip, town, fk_county, fk_pays AS fk_country";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."c_ziptown as t";
|
||||
$sql .= " AND t.active = ".$active;
|
||||
if ($zipcode) $sql .= " AND t.zip LIKE '%".$this->db->escape($zipcode)."%'";
|
||||
if ($town) $sql .= " AND t.town LIKE '%".$this->db->escape($town)."%'";
|
||||
if ($zipcode) {
|
||||
$sql .= " AND t.zip LIKE '%".$this->db->escape($zipcode)."%'";
|
||||
}
|
||||
if ($town) {
|
||||
$sql .= " AND t.town LIKE '%".$this->db->escape($town)."%'";
|
||||
}
|
||||
// Add sql filters
|
||||
if ($sqlfilters)
|
||||
{
|
||||
if (!DolibarrApi::_checkFilters($sqlfilters))
|
||||
{
|
||||
if ($sqlfilters) {
|
||||
if (!DolibarrApi::_checkFilters($sqlfilters)) {
|
||||
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
|
||||
}
|
||||
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
|
||||
@ -1192,10 +1184,8 @@ class Setup extends DolibarrApi
|
||||
$sql .= " WHERE t.entity IN (".getEntity('c_payment_term').")";
|
||||
$sql .= " AND t.active = ".$active;
|
||||
// Add sql filters
|
||||
if ($sqlfilters)
|
||||
{
|
||||
if (!DolibarrApi::_checkFilters($sqlfilters))
|
||||
{
|
||||
if ($sqlfilters) {
|
||||
if (!DolibarrApi::_checkFilters($sqlfilters)) {
|
||||
throw new RestException(400, 'Error when validating parameter sqlfilters '.$sqlfilters);
|
||||
}
|
||||
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
|
||||
@ -1252,10 +1242,8 @@ class Setup extends DolibarrApi
|
||||
$sql .= " WHERE t.entity IN (".getEntity('c_shipment_mode').")";
|
||||
$sql .= " AND t.active = ".$active;
|
||||
// Add sql filters
|
||||
if ($sqlfilters)
|
||||
{
|
||||
if (!DolibarrApi::_checkFilters($sqlfilters))
|
||||
{
|
||||
if ($sqlfilters) {
|
||||
if (!DolibarrApi::_checkFilters($sqlfilters)) {
|
||||
throw new RestException(400, 'Error when validating parameter sqlfilters '.$sqlfilters);
|
||||
}
|
||||
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
|
||||
@ -1313,10 +1301,8 @@ class Setup extends DolibarrApi
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."c_units as t";
|
||||
$sql .= " WHERE t.active = ".$active;
|
||||
// Add sql filters
|
||||
if ($sqlfilters)
|
||||
{
|
||||
if (!DolibarrApi::_checkFilters($sqlfilters))
|
||||
{
|
||||
if ($sqlfilters) {
|
||||
if (!DolibarrApi::_checkFilters($sqlfilters)) {
|
||||
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
|
||||
}
|
||||
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
|
||||
@ -1380,10 +1366,8 @@ class Setup extends DolibarrApi
|
||||
$sql .= " WHERE t.entity IN (".getEntity('c_socialnetworks').")";
|
||||
$sql .= " AND t.active = ".$active;
|
||||
// Add sql filters
|
||||
if ($sqlfilters)
|
||||
{
|
||||
if (!DolibarrApi::_checkFilters($sqlfilters))
|
||||
{
|
||||
if ($sqlfilters) {
|
||||
if (!DolibarrApi::_checkFilters($sqlfilters)) {
|
||||
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
|
||||
}
|
||||
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
|
||||
@ -1440,10 +1424,8 @@ class Setup extends DolibarrApi
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."c_ticket_category as t";
|
||||
$sql .= " WHERE t.active = ".$active;
|
||||
// Add sql filters
|
||||
if ($sqlfilters)
|
||||
{
|
||||
if (!DolibarrApi::_checkFilters($sqlfilters))
|
||||
{
|
||||
if ($sqlfilters) {
|
||||
if (!DolibarrApi::_checkFilters($sqlfilters)) {
|
||||
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
|
||||
}
|
||||
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
|
||||
@ -1500,10 +1482,8 @@ class Setup extends DolibarrApi
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."c_ticket_severity as t";
|
||||
$sql .= " WHERE t.active = ".$active;
|
||||
// Add sql filters
|
||||
if ($sqlfilters)
|
||||
{
|
||||
if (!DolibarrApi::_checkFilters($sqlfilters))
|
||||
{
|
||||
if ($sqlfilters) {
|
||||
if (!DolibarrApi::_checkFilters($sqlfilters)) {
|
||||
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
|
||||
}
|
||||
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
|
||||
@ -1562,10 +1542,8 @@ class Setup extends DolibarrApi
|
||||
// if ($type) $sql .= " AND t.type LIKE '%".$this->db->escape($type)."%'";
|
||||
// if ($module) $sql .= " AND t.module LIKE '%".$this->db->escape($module)."%'";
|
||||
// Add sql filters
|
||||
if ($sqlfilters)
|
||||
{
|
||||
if (!DolibarrApi::_checkFilters($sqlfilters))
|
||||
{
|
||||
if ($sqlfilters) {
|
||||
if (!DolibarrApi::_checkFilters($sqlfilters)) {
|
||||
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
|
||||
}
|
||||
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
|
||||
@ -1604,13 +1582,13 @@ class Setup extends DolibarrApi
|
||||
*
|
||||
* @url GET /company
|
||||
*
|
||||
* @return array|mixed Data without useless information
|
||||
* @return array|mixed Mysoc object
|
||||
*
|
||||
* @throws RestException 403 Forbidden
|
||||
*/
|
||||
public function getCompany()
|
||||
{
|
||||
global $mysoc;
|
||||
global $conf, $mysoc;
|
||||
|
||||
if (!DolibarrApiAccess::$user->admin
|
||||
&& (empty($conf->global->API_LOGINS_ALLOWED_FOR_GET_COMPANY) || DolibarrApiAccess::$user->login != $conf->global->API_LOGINS_ALLOWED_FOR_GET_COMPANY)) {
|
||||
@ -1710,8 +1688,7 @@ class Setup extends DolibarrApi
|
||||
global $langs, $conf;
|
||||
|
||||
if (!DolibarrApiAccess::$user->admin
|
||||
&& (empty($conf->global->API_LOGIN_ALLOWED_FOR_INTEGRITY_CHECK) || DolibarrApiAccess::$user->login != $conf->global->API_LOGIN_ALLOWED_FOR_INTEGRITY_CHECK))
|
||||
{
|
||||
&& (empty($conf->global->API_LOGIN_ALLOWED_FOR_INTEGRITY_CHECK) || DolibarrApiAccess::$user->login != $conf->global->API_LOGIN_ALLOWED_FOR_INTEGRITY_CHECK)) {
|
||||
throw new RestException(403, 'Error API open to admin users only or to the users with logins defined into constant API_LOGIN_ALLOWED_FOR_INTEGRITY_CHECK');
|
||||
}
|
||||
|
||||
@ -1731,10 +1708,16 @@ class Setup extends DolibarrApi
|
||||
$xmlfile = DOL_DOCUMENT_ROOT.$xmlshortfile;
|
||||
// Remote file to compare to
|
||||
$xmlremote = ($target == 'default' ? '' : $target);
|
||||
if (empty($xmlremote) && !empty($conf->global->MAIN_FILECHECK_URL)) $xmlremote = $conf->global->MAIN_FILECHECK_URL;
|
||||
if (empty($xmlremote) && !empty($conf->global->MAIN_FILECHECK_URL)) {
|
||||
$xmlremote = $conf->global->MAIN_FILECHECK_URL;
|
||||
}
|
||||
$param = 'MAIN_FILECHECK_URL_'.DOL_VERSION;
|
||||
if (empty($xmlremote) && !empty($conf->global->$param)) $xmlremote = $conf->global->$param;
|
||||
if (empty($xmlremote)) $xmlremote = 'https://www.dolibarr.org/files/stable/signatures/filelist-'.DOL_VERSION.'.xml';
|
||||
if (empty($xmlremote) && !empty($conf->global->$param)) {
|
||||
$xmlremote = $conf->global->$param;
|
||||
}
|
||||
if (empty($xmlremote)) {
|
||||
$xmlremote = 'https://www.dolibarr.org/files/stable/signatures/filelist-'.DOL_VERSION.'.xml';
|
||||
}
|
||||
|
||||
if ($target == 'local') {
|
||||
if (dol_is_file($xmlfile)) {
|
||||
@ -1756,8 +1739,7 @@ class Setup extends DolibarrApi
|
||||
}
|
||||
}
|
||||
|
||||
if ($xml)
|
||||
{
|
||||
if ($xml) {
|
||||
$checksumconcat = array();
|
||||
$file_list = array();
|
||||
$out = '';
|
||||
@ -1776,14 +1758,15 @@ class Setup extends DolibarrApi
|
||||
$out .= '</tr>'."\n";
|
||||
|
||||
$i = 0;
|
||||
foreach ($xml->dolibarr_constants[0]->constant as $constant) // $constant is a simpleXMLElement
|
||||
{
|
||||
foreach ($xml->dolibarr_constants[0]->constant as $constant) { // $constant is a simpleXMLElement
|
||||
$constname = $constant['name'];
|
||||
$constvalue = (string) $constant;
|
||||
$constvalue = (empty($constvalue) ? '0' : $constvalue);
|
||||
// Value found
|
||||
$value = '';
|
||||
if ($constname && $conf->global->$constname != '') $value = $conf->global->$constname;
|
||||
if ($constname && $conf->global->$constname != '') {
|
||||
$value = $conf->global->$constname;
|
||||
}
|
||||
$valueforchecksum = (empty($value) ? '0' : $value);
|
||||
|
||||
$checksumconcat[] = $valueforchecksum;
|
||||
@ -1797,8 +1780,7 @@ class Setup extends DolibarrApi
|
||||
$out .= "</tr>\n";
|
||||
}
|
||||
|
||||
if ($i == 0)
|
||||
{
|
||||
if ($i == 0) {
|
||||
$out .= '<tr class="oddeven"><td colspan="4" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
|
||||
}
|
||||
$out .= '</table>';
|
||||
@ -1808,9 +1790,7 @@ class Setup extends DolibarrApi
|
||||
}
|
||||
|
||||
// Scan htdocs
|
||||
if (is_object($xml->dolibarr_htdocs_dir[0]))
|
||||
{
|
||||
//var_dump($xml->dolibarr_htdocs_dir[0]['includecustom']);exit;
|
||||
if (is_object($xml->dolibarr_htdocs_dir[0])) {
|
||||
$includecustom = (empty($xml->dolibarr_htdocs_dir[0]['includecustom']) ? 0 : $xml->dolibarr_htdocs_dir[0]['includecustom']);
|
||||
|
||||
// Defined qualified files (must be same than into generate_filelist_xml.php)
|
||||
@ -1821,11 +1801,9 @@ class Setup extends DolibarrApi
|
||||
// Fill file_list with files in signature, new files, modified files
|
||||
$ret = getFilesUpdated($file_list, $xml->dolibarr_htdocs_dir[0], '', DOL_DOCUMENT_ROOT, $checksumconcat); // Fill array $file_list
|
||||
// Complete with list of new files
|
||||
foreach ($scanfiles as $keyfile => $valfile)
|
||||
{
|
||||
foreach ($scanfiles as $keyfile => $valfile) {
|
||||
$tmprelativefilename = preg_replace('/^'.preg_quote(DOL_DOCUMENT_ROOT, '/').'/', '', $valfile['fullname']);
|
||||
if (!in_array($tmprelativefilename, $file_list['insignature']))
|
||||
{
|
||||
if (!in_array($tmprelativefilename, $file_list['insignature'])) {
|
||||
$md5newfile = @md5_file($valfile['fullname']); // Can fails if we don't have permission to open/read file
|
||||
$file_list['added'][] = array('filename'=>$tmprelativefilename, 'md5'=>$md5newfile);
|
||||
}
|
||||
@ -1842,11 +1820,9 @@ class Setup extends DolibarrApi
|
||||
$out .= '<td class="center">'.$langs->trans("ExpectedChecksum").'</td>';
|
||||
$out .= '</tr>'."\n";
|
||||
$tmpfilelist = dol_sort_array($file_list['missing'], 'filename');
|
||||
if (is_array($tmpfilelist) && count($tmpfilelist))
|
||||
{
|
||||
if (is_array($tmpfilelist) && count($tmpfilelist)) {
|
||||
$i = 0;
|
||||
foreach ($tmpfilelist as $file)
|
||||
{
|
||||
foreach ($tmpfilelist as $file) {
|
||||
$i++;
|
||||
$out .= '<tr class="oddeven">';
|
||||
$out .= '<td>'.$i.'</td>'."\n";
|
||||
@ -1877,11 +1853,9 @@ class Setup extends DolibarrApi
|
||||
$out .= '<td class="right">'.$langs->trans("DateModification").'</td>';
|
||||
$out .= '</tr>'."\n";
|
||||
$tmpfilelist2 = dol_sort_array($file_list['updated'], 'filename');
|
||||
if (is_array($tmpfilelist2) && count($tmpfilelist2))
|
||||
{
|
||||
if (is_array($tmpfilelist2) && count($tmpfilelist2)) {
|
||||
$i = 0;
|
||||
foreach ($tmpfilelist2 as $file)
|
||||
{
|
||||
foreach ($tmpfilelist2 as $file) {
|
||||
$i++;
|
||||
$out .= '<tr class="oddeven">';
|
||||
$out .= '<td>'.$i.'</td>'."\n";
|
||||
@ -1925,11 +1899,9 @@ class Setup extends DolibarrApi
|
||||
$out .= '<td class="right">'.$langs->trans("DateModification").'</td>';
|
||||
$out .= '</tr>'."\n";
|
||||
$tmpfilelist3 = dol_sort_array($file_list['added'], 'filename');
|
||||
if (is_array($tmpfilelist3) && count($tmpfilelist3))
|
||||
{
|
||||
if (is_array($tmpfilelist3) && count($tmpfilelist3)) {
|
||||
$i = 0;
|
||||
foreach ($tmpfilelist3 as $file)
|
||||
{
|
||||
foreach ($tmpfilelist3 as $file) {
|
||||
$i++;
|
||||
$out .= '<tr class="oddeven">';
|
||||
$out .= '<td>'.$i.'</td>'."\n";
|
||||
@ -1958,8 +1930,7 @@ class Setup extends DolibarrApi
|
||||
|
||||
|
||||
// Show warning
|
||||
if (empty($tmpfilelist) && empty($tmpfilelist2) && empty($tmpfilelist3))
|
||||
{
|
||||
if (empty($tmpfilelist) && empty($tmpfilelist2) && empty($tmpfilelist3)) {
|
||||
//setEventMessages($langs->trans("FileIntegrityIsStrictlyConformedWithReference"), null, 'mesgs');
|
||||
} else {
|
||||
//setEventMessages($langs->trans("FileIntegritySomeFilesWereRemovedOrModified"), null, 'warnings');
|
||||
@ -1970,17 +1941,13 @@ class Setup extends DolibarrApi
|
||||
|
||||
|
||||
// Scan scripts
|
||||
|
||||
|
||||
asort($checksumconcat); // Sort list of checksum
|
||||
//var_dump($checksumconcat);
|
||||
$checksumget = md5(join(',', $checksumconcat));
|
||||
$checksumtoget = trim((string) $xml->dolibarr_htdocs_dir_checksum);
|
||||
|
||||
$outexpectedchecksum = ($checksumtoget ? $checksumtoget : $langs->trans("Unknown"));
|
||||
if ($checksumget == $checksumtoget) {
|
||||
if (count($file_list['added']))
|
||||
{
|
||||
if (count($file_list['added'])) {
|
||||
$resultcode = 'warning';
|
||||
$resultcomment = 'FileIntegrityIsOkButFilesWereAdded';
|
||||
//$outcurrentchecksum = $checksumget.' - <span class="'.$resultcode.'">'.$langs->trans("FileIntegrityIsOkButFilesWereAdded").'</span>';
|
||||
@ -2019,8 +1986,7 @@ class Setup extends DolibarrApi
|
||||
global $conf;
|
||||
|
||||
if (!DolibarrApiAccess::$user->admin
|
||||
&& (empty($conf->global->API_LOGIN_ALLOWED_FOR_GET_MODULES) || DolibarrApiAccess::$user->login != $conf->global->API_LOGIN_ALLOWED_FOR_GET_MODULES))
|
||||
{
|
||||
&& (empty($conf->global->API_LOGIN_ALLOWED_FOR_GET_MODULES) || DolibarrApiAccess::$user->login != $conf->global->API_LOGIN_ALLOWED_FOR_GET_MODULES)) {
|
||||
throw new RestException(403, 'Error API open to admin users only or to the users with logins defined into constant API_LOGIN_ALLOWED_FOR_GET_MODULES');
|
||||
}
|
||||
|
||||
|
||||
@ -141,14 +141,8 @@ $arrayfields = array(
|
||||
'a.tms'=>array('label'=>'DateModification', 'checked'=>0)
|
||||
);
|
||||
// Extra fields
|
||||
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0)
|
||||
{
|
||||
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val)
|
||||
{
|
||||
if (!empty($extrafields->attributes[$object->table_element]['list'][$key]))
|
||||
$arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key]));
|
||||
}
|
||||
}
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
|
||||
|
||||
$object->fields = dol_sort_array($object->fields, 'position');
|
||||
$arrayfields = dol_sort_array($arrayfields, 'position');
|
||||
|
||||
|
||||
@ -331,11 +331,10 @@ if (empty($reshook))
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($conf->global->MAILING_DELAY))
|
||||
{
|
||||
dol_syslog("Wait a delay of MAILING_DELAY=".$conf->global->MAILING_DELAY);
|
||||
sleep($conf->global->MAILING_DELAY);
|
||||
}
|
||||
if (!empty($conf->global->MAILING_DELAY)) {
|
||||
dol_syslog("Wait a delay of MAILING_DELAY=".$conf->global->MAILING_DELAY);
|
||||
usleep((float) $conf->global->MAILING_DELAY * 1000000);
|
||||
}
|
||||
|
||||
//test if CHECK READ change statut prospect contact
|
||||
} else {
|
||||
|
||||
@ -463,24 +463,51 @@ if ($object->fetch($id) >= 0)
|
||||
$sql .= " mc.source_url, mc.source_id, mc.source_type, mc.error_text";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc";
|
||||
$sql .= " WHERE mc.fk_mailing=".$object->id;
|
||||
if ($search_lastname) $sql .= natural_search("mc.lastname", $search_lastname);
|
||||
if ($search_firstname) $sql .= natural_search("mc.firstname", $search_firstname);
|
||||
if ($search_email) $sql .= natural_search("mc.email", $search_email);
|
||||
if ($search_other) $sql .= natural_search("mc.other", $search_other);
|
||||
if ($search_dest_status != '' && $search_dest_status >= -1) $sql .= " AND mc.statut=".$db->escape($search_dest_status)." ";
|
||||
$asearchcriteriahasbeenset = 0;
|
||||
if ($search_lastname) {
|
||||
$sql .= natural_search("mc.lastname", $search_lastname);
|
||||
$asearchcriteriahasbeenset++;
|
||||
}
|
||||
if ($search_firstname) {
|
||||
$sql .= natural_search("mc.firstname", $search_firstname);
|
||||
$asearchcriteriahasbeenset++;
|
||||
}
|
||||
if ($search_email) {
|
||||
$sql .= natural_search("mc.email", $search_email);
|
||||
$asearchcriteriahasbeenset++;
|
||||
}
|
||||
if ($search_other) {
|
||||
$sql .= natural_search("mc.other", $search_other);
|
||||
$asearchcriteriahasbeenset++;
|
||||
}
|
||||
if ($search_dest_status != '' && $search_dest_status >= -1) {
|
||||
$sql .= " AND mc.statut=".$db->escape($search_dest_status)." ";
|
||||
$asearchcriteriahasbeenset++;
|
||||
}
|
||||
$sql .= $db->order($sortfield, $sortorder);
|
||||
|
||||
// Count total nb of records
|
||||
$nbtotalofrecords = '';
|
||||
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
|
||||
{
|
||||
$result = $db->query($sql);
|
||||
$nbtotalofrecords = $db->num_rows($result);
|
||||
if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
|
||||
{
|
||||
$page = 0;
|
||||
$offset = 0;
|
||||
}
|
||||
$result = $db->query($sql);
|
||||
$nbtotalofrecords = $db->num_rows($result);
|
||||
if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
|
||||
$page = 0;
|
||||
$offset = 0;
|
||||
}
|
||||
|
||||
// Fix/update nbemail on emailing record if it differs (may happen if user edit lines from database directly)
|
||||
if (empty($asearchcriteriahasbeenset)) {
|
||||
if ($nbtotalofrecords != $object->email) {
|
||||
dol_syslog("We found a difference in nb of record in target table and the property ->nbemail, we fix ->nbemail");
|
||||
//print "nbemail=".$object->nbemail." nbtotalofrecords=".$nbtotalofrecords;
|
||||
$resultrefresh = $object->refreshNbOfTargets();
|
||||
if ($resultrefresh < 0) {
|
||||
dol_print_error($db, $object->error, $object->errors);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//$nbtotalofrecords=$object->nbemail; // nbemail is a denormalized field storing nb of targets
|
||||
|
||||
@ -510,6 +510,8 @@ class Mailing extends CommonObject
|
||||
dol_syslog("Mailing::delete_targets", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
$this->refreshNbOfTargets();
|
||||
|
||||
return 1;
|
||||
} else {
|
||||
$this->error = $this->db->lasterror();
|
||||
@ -577,6 +579,38 @@ class Mailing extends CommonObject
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Refresh denormalized value ->nbemail into emailing record
|
||||
* Note: There is also the method update_nb into modules_mailings that is used for this.
|
||||
*
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
public function refreshNbOfTargets()
|
||||
{
|
||||
$sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."mailing_cibles";
|
||||
$sql .= " WHERE fk_mailing = ".$this->id;
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
if ($obj) {
|
||||
$nbforupdate = $obj->nb;
|
||||
|
||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.'mailing SET nbemail = '.((int) $nbforupdate);
|
||||
$sql .= ' WHERE rowid = '.$this->id;
|
||||
|
||||
$resqlupdate = $this->db->query($sql);
|
||||
if (! $resqlupdate) {
|
||||
$this->error = $this->db->lasterror();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->error = $this->db->lasterror();
|
||||
return -1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a link to the object card (with optionally the picto)
|
||||
|
||||
@ -3159,8 +3159,8 @@ class Commande extends CommonOrder
|
||||
$this->line->tva_tx = $txtva;
|
||||
$this->line->localtax1_tx = $txlocaltax1;
|
||||
$this->line->localtax2_tx = $txlocaltax2;
|
||||
$this->line->localtax1_type = $localtaxes_type[0];
|
||||
$this->line->localtax2_type = $localtaxes_type[2];
|
||||
$this->line->localtax1_type = empty($localtaxes_type[0]) ? '' : $localtaxes_type[0];
|
||||
$this->line->localtax2_type = empty($localtaxes_type[2]) ? '' : $localtaxes_type[2];
|
||||
$this->line->remise_percent = $remise_percent;
|
||||
$this->line->subprice = $subprice;
|
||||
$this->line->info_bits = $info_bits;
|
||||
|
||||
@ -529,7 +529,7 @@ print '<span class="opacitymedium">'.$langs->trans("ExportAccountingSourceDocHel
|
||||
print '<br>';
|
||||
|
||||
print $langs->trans("ReportPeriod").': '.$form->selectDate($date_start, 'date_start', 0, 0, 0, "", 1, 1, 0);
|
||||
print ' - '.$form->selectDate($date_stop, 'date_stop', 0, 0, 0, "", 1, 1, 0)."\n</a>";
|
||||
print ' - '.$form->selectDate($date_stop, 'date_stop', 0, 0, 0, "", 1, 1, 0)."\n";
|
||||
|
||||
// Export is for current company only
|
||||
if (!empty($conf->multicompany->enabled) && is_object($mc))
|
||||
@ -560,7 +560,7 @@ $listofchoices = array(
|
||||
);
|
||||
foreach ($listofchoices as $choice => $val) {
|
||||
$checked = (((!GETPOSTISSET('search') && $action != 'searchfiles') || GETPOST($choice)) ? ' checked="checked"' : '');
|
||||
print '<div class="paddingleft inline-block marginrightonly"><input type="checkbox" name="'.$choice.'" value="1"'.$checked.'> '.$langs->trans($val['label']).'</div>';
|
||||
print '<div class="paddingleft inline-block marginrightonly"><input type="checkbox" id="'.$choice.'" name="'.$choice.'" value="1"'.$checked.'> <label for="'.$choice.'">'.$langs->trans($val['label']).'</label></div>';
|
||||
}
|
||||
|
||||
print '<input class="button" type="submit" name="search" value="'.$langs->trans("Search").'">';
|
||||
|
||||
@ -155,14 +155,8 @@ $arrayfields = array(
|
||||
'b.conciliated'=>array('label'=>$langs->trans("Conciliated"), 'enabled'=> $object->rappro, 'checked'=>($action == 'reconcile' ? 1 : 0), 'position'=>1020),
|
||||
);
|
||||
// Extra fields
|
||||
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0)
|
||||
{
|
||||
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val)
|
||||
{
|
||||
if (!empty($extrafields->attributes[$object->table_element]['list'][$key]))
|
||||
$arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key]));
|
||||
}
|
||||
}
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
|
||||
|
||||
$object->fields = dol_sort_array($object->fields, 'position');
|
||||
$arrayfields = dol_sort_array($arrayfields, 'position');
|
||||
|
||||
@ -496,7 +490,7 @@ if (dol_strlen($search_dv_end) > 0) $sql .= " AND b.datev <= '".$db->idate($sear
|
||||
if ($search_ref) $sql .= natural_search("b.rowid", $search_ref, 1);
|
||||
if ($search_req_nb) $sql .= natural_search("b.num_chq", $search_req_nb);
|
||||
if ($search_num_releve) $sql .= natural_search("b.num_releve", $search_num_releve);
|
||||
if ($search_conciliated != '' && $search_conciliated != '-1') $sql .= " AND b.rappro = ".$search_conciliated;
|
||||
if ($search_conciliated != '' && $search_conciliated != '-1') $sql .= " AND b.rappro = ".urlencode($search_conciliated);
|
||||
if ($search_thirdparty) $sql .= natural_search("s.nom", $search_thirdparty);
|
||||
if ($search_description)
|
||||
{
|
||||
@ -861,6 +855,10 @@ if ($resql)
|
||||
|
||||
$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
|
||||
$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
|
||||
// When action is 'reconcile', we force to have the column num_releve always enabled (otherwise we can't make reconciliation).
|
||||
if ($action == 'reconcile') {
|
||||
$arrayfields['b.num_releve']['checked'] = 1;
|
||||
}
|
||||
|
||||
print '<div class="div-table-responsive">';
|
||||
print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
|
||||
@ -993,9 +991,8 @@ if ($resql)
|
||||
while ($i < min($num, $limit))
|
||||
{
|
||||
$objp = $db->fetch_object($resql);
|
||||
|
||||
// If we are in a situation where we need/can show balance, we calculate the start of balance
|
||||
if (!$balancecalculated && (!empty($arrayfields['balancebefore']['checked']) || !empty($arrayfields['balance']['checked'])) && $mode_balance_ok)
|
||||
if (!$balancecalculated && (!empty($arrayfields['balancebefore']['checked']) || !empty($arrayfields['balance']['checked'])) && ($mode_balance_ok || $search_conciliated === '0'))
|
||||
{
|
||||
if (!$search_account)
|
||||
{
|
||||
@ -1016,11 +1013,9 @@ if ($resql)
|
||||
$sqlforbalance .= " AND (b.datev < '".$db->idate($db->jdate($objp->dv))."' OR (b.datev = '".$db->idate($db->jdate($objp->dv))."' AND (b.dateo < '".$db->idate($db->jdate($objp->do))."' OR (b.dateo = '".$db->idate($db->jdate($objp->do))."' AND b.rowid < ".$objp->rowid."))))";
|
||||
$resqlforbalance = $db->query($sqlforbalance);
|
||||
//print $sqlforbalance;
|
||||
if ($resqlforbalance)
|
||||
{
|
||||
if ($resqlforbalance) {
|
||||
$objforbalance = $db->fetch_object($resqlforbalance);
|
||||
if ($objforbalance)
|
||||
{
|
||||
if ($objforbalance) {
|
||||
// If sort is desc,desc,desc then total of previous date + amount is the balancebefore of the previous line before the line to show
|
||||
if ($sortfield == 'b.datev,b.dateo,b.rowid' && $sortorder == 'desc,desc,desc')
|
||||
{
|
||||
@ -1081,24 +1076,30 @@ if ($resql)
|
||||
if (!empty($arrayfields['balancebefore']['checked']))
|
||||
{
|
||||
print '<td class="right">';
|
||||
print price(price2num($balance, 'MT'), 1, $langs);
|
||||
if ($search_conciliated !== '0') {
|
||||
print price(price2num($balance, 'MT'), 1, $langs);
|
||||
}
|
||||
print '</td>';
|
||||
}
|
||||
if (!empty($arrayfields['balance']['checked']))
|
||||
{
|
||||
print '<td class="right">';
|
||||
print price(price2num($balance, 'MT'), 1, $langs);
|
||||
if ($search_conciliated !== '0') {
|
||||
print price(price2num($balance, 'MT'), 1, $langs);
|
||||
}
|
||||
print '</td>';
|
||||
}
|
||||
if (!empty($arrayfields['b.num_releve']['checked']))
|
||||
{
|
||||
print '<td class="center">';
|
||||
print '<input type="checkbox" id="selectAll" title="'.dol_escape_htmltag($langs->trans("SelectAll")).'" />';
|
||||
print ' <script type="text/javascript">
|
||||
$("input#selectAll").change(function() {
|
||||
$("input[type=checkbox][name^=rowid]").prop("checked", $(this).is(":checked"));
|
||||
});
|
||||
</script>';
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
print '<td class="center">';
|
||||
print '<input type="checkbox" id="selectAll" title="'.dol_escape_htmltag($langs->trans("SelectAll")).'" />';
|
||||
print ' <script type="text/javascript">
|
||||
$("input#selectAll").change(function() {
|
||||
$("input[type=checkbox][name^=rowid]").prop("checked", $(this).is(":checked"));
|
||||
});
|
||||
</script>';
|
||||
print '</td>';
|
||||
print '<td colspan="'.($tmpnbfieldafterbalance + 2).'">';
|
||||
print ' ';
|
||||
print '</td>';
|
||||
|
||||
@ -93,7 +93,18 @@ class PaymentVarious extends CommonObject
|
||||
public $fk_project;
|
||||
|
||||
/**
|
||||
* @var int ID
|
||||
* @var int Bank account ID
|
||||
*/
|
||||
public $fk_account;
|
||||
|
||||
/**
|
||||
* @var int Bank account ID
|
||||
* @deprecated See fk_account
|
||||
*/
|
||||
public $accountid;
|
||||
|
||||
/**
|
||||
* @var int ID record into llx_bank
|
||||
*/
|
||||
public $fk_bank;
|
||||
|
||||
@ -102,11 +113,6 @@ class PaymentVarious extends CommonObject
|
||||
*/
|
||||
public $categorie_transaction;
|
||||
|
||||
/**
|
||||
* @var int Account ID
|
||||
*/
|
||||
public $accountid;
|
||||
|
||||
/**
|
||||
* @var int ID
|
||||
*/
|
||||
@ -397,6 +403,10 @@ class PaymentVarious extends CommonObject
|
||||
$this->fk_bank = (int) $this->fk_bank;
|
||||
$this->fk_user_author = (int) $this->fk_user_author;
|
||||
$this->fk_user_modif = (int) $this->fk_user_modif;
|
||||
$this->fk_account = (int) $this->fk_account;
|
||||
if (empty($this->fk_account) && isset($this->accountid)) { // For compatibility
|
||||
$this->fk_account = $this->accountid;
|
||||
}
|
||||
|
||||
// Check parameters
|
||||
if (!$this->label)
|
||||
@ -409,9 +419,9 @@ class PaymentVarious extends CommonObject
|
||||
$this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount"));
|
||||
return -5;
|
||||
}
|
||||
if (!empty($conf->banque->enabled) && (empty($this->accountid) || $this->accountid <= 0))
|
||||
if (!empty($conf->banque->enabled) && (empty($this->fk_account) || $this->fk_account <= 0))
|
||||
{
|
||||
$this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Account"));
|
||||
$this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("BankAccount"));
|
||||
return -6;
|
||||
}
|
||||
if (!empty($conf->banque->enabled) && (empty($this->type_payment) || $this->type_payment <= 0))
|
||||
@ -454,7 +464,7 @@ class PaymentVarious extends CommonObject
|
||||
$sql .= ", ".($this->fk_project > 0 ? $this->fk_project : 0);
|
||||
$sql .= ", ".$user->id;
|
||||
$sql .= ", '".$this->db->idate($now)."'";
|
||||
$sql .= ", NULL";
|
||||
$sql .= ", NULL"; // Filled later
|
||||
$sql .= ", ".$conf->entity;
|
||||
$sql .= ")";
|
||||
|
||||
@ -473,7 +483,7 @@ class PaymentVarious extends CommonObject
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
|
||||
|
||||
$acc = new Account($this->db);
|
||||
$result = $acc->fetch($this->accountid);
|
||||
$result = $acc->fetch($this->fk_account);
|
||||
if ($result <= 0) dol_print_error($this->db);
|
||||
|
||||
// Insert payment into llx_bank
|
||||
@ -495,7 +505,7 @@ class PaymentVarious extends CommonObject
|
||||
$this->datev
|
||||
);
|
||||
|
||||
// Update fk_bank into llx_paiement.
|
||||
// Update fk_bank into llx_payment_various
|
||||
// So we know the payment which has generate the banking ecriture
|
||||
if ($bank_line_id > 0) {
|
||||
$this->update_fk_bank($bank_line_id);
|
||||
|
||||
@ -106,14 +106,8 @@ $arrayfields = array(
|
||||
'balance'=>array('label'=>$langs->trans("Balance"), 'checked'=>1, 'position'=>1010),
|
||||
);
|
||||
// Extra fields
|
||||
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0)
|
||||
{
|
||||
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val)
|
||||
{
|
||||
if (!empty($extrafields->attributes[$object->table_element]['list'][$key]))
|
||||
$arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key]));
|
||||
}
|
||||
}
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
|
||||
|
||||
$object->fields = dol_sort_array($object->fields, 'position');
|
||||
$arrayfields = dol_sort_array($arrayfields, 'position');
|
||||
|
||||
|
||||
@ -491,7 +491,7 @@ if ($id)
|
||||
);
|
||||
$formquestion[] = array('type' => 'date', 'tdclass'=>'fieldrequired', 'name' => 'clone_date_payment', 'label' => $langs->trans("DatePayment"), 'value' => -1);
|
||||
$formquestion[] = array('type' => 'date', 'name' => 'clone_date_value', 'label' => $langs->trans("DateValue"), 'value' => -1);
|
||||
$formquestion[] = array('type' => 'other', 'tdclass'=>'fieldrequired', 'name' => 'accountid', 'label' => $langs->trans("BankAccount"), 'value' => $form->select_comptes($accountid, "accountid", 0, '', 1));
|
||||
$formquestion[] = array('type' => 'other', 'tdclass'=>'fieldrequired', 'name' => 'accountid', 'label' => $langs->trans("BankAccount"), 'value' => $form->select_comptes($accountid, "accountid", 0, '', 1, '', 0, 'minwidth200', 1));
|
||||
|
||||
print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneVariousPayment', $object->ref), 'confirm_clone', $formquestion, 'yes', 1, 300);
|
||||
}
|
||||
|
||||
@ -466,14 +466,18 @@ if ($result)
|
||||
|
||||
// Project
|
||||
if ($arrayfields['project']['checked']) {
|
||||
$proj->fetch($obj->fk_project);
|
||||
print '<td class="nowraponall">'.$proj->getNomUrl(1).'</td>';
|
||||
print '<td class="nowraponall">';
|
||||
if ($obj->fk_project > 0) {
|
||||
$proj->fetch($obj->fk_project);
|
||||
print $proj->getNomUrl(1);
|
||||
}
|
||||
print '</td>';
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
}
|
||||
|
||||
// Bank account
|
||||
if ($arrayfields['bank']['checked']) {
|
||||
print '<td>';
|
||||
print '<td class="nowraponall">';
|
||||
if ($obj->bid > 0)
|
||||
{
|
||||
$accountstatic->id = $obj->bid;
|
||||
|
||||
@ -120,14 +120,8 @@ foreach ($object->fields as $key => $val)
|
||||
if (!empty($val['visible'])) $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>$val['enabled'], 'position'=>$val['position']);
|
||||
}
|
||||
// Extra fields
|
||||
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0)
|
||||
{
|
||||
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val)
|
||||
{
|
||||
if (!empty($extrafields->attributes[$object->table_element]['list'][$key]))
|
||||
$arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key]));
|
||||
}
|
||||
}
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
|
||||
|
||||
$object->fields = dol_sort_array($object->fields, 'position');
|
||||
$arrayfields = dol_sort_array($arrayfields, 'position');
|
||||
|
||||
|
||||
@ -3136,8 +3136,8 @@ class Facture extends CommonInvoice
|
||||
$this->line->tva_tx = $txtva;
|
||||
$this->line->localtax1_tx = ($total_localtax1 ? $localtaxes_type[1] : 0);
|
||||
$this->line->localtax2_tx = ($total_localtax2 ? $localtaxes_type[3] : 0);
|
||||
$this->line->localtax1_type = isset($localtaxes_type[0]) ? $localtaxes_type[0] : '';
|
||||
$this->line->localtax2_type = isset($localtaxes_type[2]) ? $localtaxes_type[2] : '';
|
||||
$this->line->localtax1_type = empty($localtaxes_type[0]) ? '' : $localtaxes_type[0];
|
||||
$this->line->localtax2_type = empty($localtaxes_type[2]) ? '' : $localtaxes_type[2];
|
||||
|
||||
$this->line->total_ht = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ?-abs($total_ht) : $total_ht); // For credit note and if qty is negative, total is negative
|
||||
$this->line->total_ttc = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ?-abs($total_ttc) : $total_ttc); // For credit note and if qty is negative, total is negative
|
||||
@ -3375,8 +3375,8 @@ class Facture extends CommonInvoice
|
||||
$this->line->tva_tx = $txtva;
|
||||
$this->line->localtax1_tx = $txlocaltax1;
|
||||
$this->line->localtax2_tx = $txlocaltax2;
|
||||
$this->line->localtax1_type = $localtaxes_type[0];
|
||||
$this->line->localtax2_type = $localtaxes_type[2];
|
||||
$this->line->localtax1_type = empty($localtaxes_type[0]) ? '' : $localtaxes_type[0];
|
||||
$this->line->localtax2_type = empty($localtaxes_type[2]) ? '' : $localtaxes_type[2];
|
||||
|
||||
$this->line->remise_percent = $remise_percent;
|
||||
$this->line->subprice = ($this->type == self::TYPE_CREDIT_NOTE ?-abs($pu_ht) : $pu_ht); // For credit note, unit price always negative, always positive otherwise
|
||||
|
||||
@ -135,14 +135,8 @@ $arrayfields = array(
|
||||
'f.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500),
|
||||
);
|
||||
// Extra fields
|
||||
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0)
|
||||
{
|
||||
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val)
|
||||
{
|
||||
if (!empty($extrafields->attributes[$object->table_element]['list'][$key]))
|
||||
$arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key]));
|
||||
}
|
||||
}
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
|
||||
|
||||
$object->fields = dol_sort_array($object->fields, 'position');
|
||||
$arrayfields = dol_sort_array($arrayfields, 'position');
|
||||
|
||||
|
||||
@ -213,7 +213,7 @@ if ($object->id > 0)
|
||||
$head = facture_prepare_head($object);
|
||||
}
|
||||
|
||||
print dol_get_fiche_head($head, 'standingorders', $title, -1, 'bill');
|
||||
print dol_get_fiche_head($head, 'standingorders', $title, -1, ($type == 'bank-transfer' ? 'supplier_invoice' : 'bill'));
|
||||
|
||||
// Invoice content
|
||||
if ($type == 'bank-transfer') {
|
||||
|
||||
@ -229,6 +229,8 @@ if ($modecompta == 'BOOKKEEPING')
|
||||
print "</tr>\n";
|
||||
|
||||
|
||||
$total_ht_outcome = $total_ttc_outcome = $total_ht_income = $total_ttc_income = 0;
|
||||
|
||||
|
||||
if ($modecompta == 'BOOKKEEPING')
|
||||
{
|
||||
@ -438,16 +440,97 @@ if ($modecompta == 'BOOKKEEPING')
|
||||
if ($total_ttc == 0)
|
||||
{
|
||||
print '<tr class="oddeven"><td> </td>';
|
||||
print '<td colspan="3" class="opacitymedium">'.$langs->trans("None").'</td>';
|
||||
print '<td colspan="3"><span class="opacitymedium">'.$langs->trans("None").'</span></td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
$total_ht_income += $total_ht;
|
||||
$total_ttc_income += $total_ttc;
|
||||
print '<tr class="liste_total">';
|
||||
if ($modecompta == 'CREANCES-DETTES')
|
||||
print '<td colspan="3" class="right">'.price($total_ht).'</td>';
|
||||
print '<td colspan="3" class="right">'.price($total_ttc).'</td>';
|
||||
print '</tr>';
|
||||
|
||||
/*
|
||||
* Donations
|
||||
*/
|
||||
|
||||
if (!empty($conf->don->enabled))
|
||||
{
|
||||
print '<tr class="trforbreak"><td colspan="4">'.$langs->trans("Donations").'</td></tr>';
|
||||
|
||||
if ($modecompta == 'CREANCES-DETTES' || $modecompta == 'RECETTES-DEPENSES')
|
||||
{
|
||||
if ($modecompta == 'CREANCES-DETTES')
|
||||
{
|
||||
$sql = "SELECT p.societe as name, p.firstname, p.lastname, date_format(p.datedon,'%Y-%m') as dm, sum(p.amount) as amount";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."don as p";
|
||||
$sql .= " WHERE p.entity IN (".getEntity('donation').")";
|
||||
$sql .= " AND fk_statut in (1,2)";
|
||||
} else {
|
||||
$sql = "SELECT p.societe as nom, p.firstname, p.lastname, date_format(p.datedon,'%Y-%m') as dm, sum(p.amount) as amount";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."don as p";
|
||||
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."payment_donation as pe ON pe.fk_donation = p.rowid";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON pe.fk_typepayment = c.id";
|
||||
$sql .= " WHERE p.entity IN (".getEntity('donation').")";
|
||||
$sql .= " AND fk_statut >= 2";
|
||||
}
|
||||
if (!empty($date_start) && !empty($date_end))
|
||||
$sql .= " AND p.datedon >= '".$db->idate($date_start)."' AND p.datedon <= '".$db->idate($date_end)."'";
|
||||
}
|
||||
$sql .= " GROUP BY p.societe, p.firstname, p.lastname, dm";
|
||||
$newsortfield = $sortfield;
|
||||
if ($newsortfield == 's.nom, s.rowid') $newsortfield = 'p.societe, p.firstname, p.lastname, dm';
|
||||
if ($newsortfield == 'amount_ht') $newsortfield = 'amount';
|
||||
if ($newsortfield == 'amount_ttc') $newsortfield = 'amount';
|
||||
$sql .= $db->order($newsortfield, $sortorder);
|
||||
|
||||
dol_syslog("get dunning");
|
||||
$result = $db->query($sql);
|
||||
$subtotal_ht = 0;
|
||||
$subtotal_ttc = 0;
|
||||
if ($result)
|
||||
{
|
||||
$num = $db->num_rows($result);
|
||||
$i = 0;
|
||||
if ($num)
|
||||
{
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $db->fetch_object($result);
|
||||
|
||||
$total_ht += $obj->amount;
|
||||
$total_ttc += $obj->amount;
|
||||
$subtotal_ht += $obj->amount;
|
||||
$subtotal_ttc += $obj->amount;
|
||||
|
||||
print '<tr class="oddeven"><td> </td>';
|
||||
|
||||
print "<td>".$langs->trans("Donation")." <a href=\"".DOL_URL_ROOT."/don/list.php?search_company=".$obj->name."&search_name=".$obj->firstname." ".$obj->lastname."\">".$obj->name." ".$obj->firstname." ".$obj->lastname."</a></td>\n";
|
||||
|
||||
if ($modecompta == 'CREANCES-DETTES') print '<td class="right">'.price($obj->amount).'</td>';
|
||||
print '<td class="right">'.price($obj->amount).'</td>';
|
||||
print '</tr>';
|
||||
$i++;
|
||||
}
|
||||
} else {
|
||||
print '<tr class="oddeven"><td> </td>';
|
||||
print '<td colspan="3"><span class="opacitymedium">'.$langs->trans("None").'</span></td>';
|
||||
print '</tr>';
|
||||
}
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
$total_ht_income += $subtotal_ht;
|
||||
$total_ttc_income += $subtotal_ttc;
|
||||
print '<tr class="liste_total">';
|
||||
if ($modecompta == 'CREANCES-DETTES')
|
||||
print '<td colspan="3" class="right">'.price($subtotal_ht).'</td>';
|
||||
print '<td colspan="3" class="right">'.price($subtotal_ttc).'</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
/*
|
||||
* Suppliers invoices
|
||||
@ -515,7 +598,7 @@ if ($modecompta == 'BOOKKEEPING')
|
||||
}
|
||||
} else {
|
||||
print '<tr class="oddeven"><td> </td>';
|
||||
print '<td colspan="3" class="opacitymedium">'.$langs->trans("None").'</td>';
|
||||
print '<td colspan="3"><span class="opacitymedium">'.$langs->trans("None").'</span></td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
@ -523,6 +606,9 @@ if ($modecompta == 'BOOKKEEPING')
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
$total_ht_outcome += $subtotal_ht;
|
||||
$total_ttc_outcome += $subtotal_ttc;
|
||||
print '<tr class="liste_total">';
|
||||
if ($modecompta == 'CREANCES-DETTES')
|
||||
print '<td colspan="3" class="right">'.price(-$subtotal_ht).'</td>';
|
||||
@ -530,7 +616,6 @@ if ($modecompta == 'BOOKKEEPING')
|
||||
print '</tr>';
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Charges sociales non deductibles
|
||||
*/
|
||||
@ -592,12 +677,15 @@ if ($modecompta == 'BOOKKEEPING')
|
||||
}
|
||||
} else {
|
||||
print '<tr class="oddeven"><td> </td>';
|
||||
print '<td colspan="3" class="opacitymedium">'.$langs->trans("None").'</td>';
|
||||
print '<td colspan="3"><span class="opacitymedium">'.$langs->trans("None").'</span></td>';
|
||||
print '</tr>';
|
||||
}
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
$total_ht_outcome += $subtotal_ht;
|
||||
$total_ttc_outcome += $subtotal_ttc;
|
||||
print '<tr class="liste_total">';
|
||||
if ($modecompta == 'CREANCES-DETTES')
|
||||
print '<td colspan="3" class="right">'.price(-$subtotal_ht).'</td>';
|
||||
@ -667,36 +755,21 @@ if ($modecompta == 'BOOKKEEPING')
|
||||
}
|
||||
} else {
|
||||
print '<tr class="oddeven"><td> </td>';
|
||||
print '<td colspan="3" class="opacitymedium">'.$langs->trans("None").'</td>';
|
||||
print '<td colspan="3"><span class="opacitymedium">'.$langs->trans("None").'</span></td>';
|
||||
print '</tr>';
|
||||
}
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
$total_ht_outcome += $subtotal_ht;
|
||||
$total_ttc_outcome += $subtotal_ttc;
|
||||
print '<tr class="liste_total">';
|
||||
if ($modecompta == 'CREANCES-DETTES')
|
||||
print '<td colspan="3" class="right">'.price(-$subtotal_ht).'</td>';
|
||||
print '<td colspan="3" class="right">'.price(-$subtotal_ttc).'</td>';
|
||||
print '</tr>';
|
||||
|
||||
if ($mysoc->tva_assuj == 'franchise') // Non assujetti
|
||||
{
|
||||
// Total
|
||||
print '<tr>';
|
||||
print '<td colspan="4"> </td>';
|
||||
print '</tr>';
|
||||
|
||||
print '<tr class="liste_total"><td class="left" colspan="2">'.$langs->trans("Profit").'</td>';
|
||||
if ($modecompta == 'CREANCES-DETTES')
|
||||
print '<td class="border right">'.price($total_ht).'</td>';
|
||||
print '<td class="right">'.price($total_ttc).'</td>';
|
||||
print '</tr>';
|
||||
|
||||
print '<tr>';
|
||||
print '<td colspan="4"> </td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Salaries
|
||||
@ -759,12 +832,15 @@ if ($modecompta == 'BOOKKEEPING')
|
||||
}
|
||||
} else {
|
||||
print '<tr class="oddeven"><td> </td>';
|
||||
print '<td colspan="3" class="opacitymedium">'.$langs->trans("None").'</td>';
|
||||
print '<td colspan="3"><span class="opacitymedium">'.$langs->trans("None").'</span></td>';
|
||||
print '</tr>';
|
||||
}
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
$total_ht_outcome += $subtotal_ht;
|
||||
$total_ttc_outcome += $subtotal_ttc;
|
||||
print '<tr class="liste_total">';
|
||||
if ($modecompta == 'CREANCES-DETTES')
|
||||
print '<td colspan="3" class="right">'.price(-$subtotal_ht).'</td>';
|
||||
@ -841,98 +917,26 @@ if ($modecompta == 'BOOKKEEPING')
|
||||
}
|
||||
} else {
|
||||
print '<tr class="oddeven"><td> </td>';
|
||||
print '<td colspan="3" class="opacitymedium">'.$langs->trans("None").'</td>';
|
||||
print '<td colspan="3"><span class="opacitymedium">'.$langs->trans("None").'</span></td>';
|
||||
print '</tr>';
|
||||
}
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
$total_ht_outcome += $subtotal_ht;
|
||||
$total_ttc_outcome += $subtotal_ttc;
|
||||
print '<tr class="liste_total">';
|
||||
if ($modecompta == 'CREANCES-DETTES') print '<td colspan="3" class="right">'.price(-$subtotal_ht).'</td>';
|
||||
print '<td colspan="3" class="right">'.price(-$subtotal_ttc).'</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
/*
|
||||
* Donations
|
||||
*/
|
||||
|
||||
if (!empty($conf->don->enabled))
|
||||
{
|
||||
print '<tr class="trforbreak"><td colspan="4">'.$langs->trans("Donations").'</td></tr>';
|
||||
|
||||
if ($modecompta == 'CREANCES-DETTES' || $modecompta == 'RECETTES-DEPENSES')
|
||||
{
|
||||
if ($modecompta == 'CREANCES-DETTES')
|
||||
{
|
||||
$sql = "SELECT p.societe as name, p.firstname, p.lastname, date_format(p.datedon,'%Y-%m') as dm, sum(p.amount) as amount";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."don as p";
|
||||
$sql .= " WHERE p.entity IN (".getEntity('donation').")";
|
||||
$sql .= " AND fk_statut in (1,2)";
|
||||
} else {
|
||||
$sql = "SELECT p.societe as nom, p.firstname, p.lastname, date_format(p.datedon,'%Y-%m') as dm, sum(p.amount) as amount";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."don as p";
|
||||
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."payment_donation as pe ON pe.fk_donation = p.rowid";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON pe.fk_typepayment = c.id";
|
||||
$sql .= " WHERE p.entity IN (".getEntity('donation').")";
|
||||
$sql .= " AND fk_statut >= 2";
|
||||
}
|
||||
if (!empty($date_start) && !empty($date_end))
|
||||
$sql .= " AND p.datedon >= '".$db->idate($date_start)."' AND p.datedon <= '".$db->idate($date_end)."'";
|
||||
}
|
||||
$sql .= " GROUP BY p.societe, p.firstname, p.lastname, dm";
|
||||
$newsortfield = $sortfield;
|
||||
if ($newsortfield == 's.nom, s.rowid') $newsortfield = 'p.societe, p.firstname, p.lastname, dm';
|
||||
if ($newsortfield == 'amount_ht') $newsortfield = 'amount';
|
||||
if ($newsortfield == 'amount_ttc') $newsortfield = 'amount';
|
||||
$sql .= $db->order($newsortfield, $sortorder);
|
||||
|
||||
dol_syslog("get dunning");
|
||||
$result = $db->query($sql);
|
||||
$subtotal_ht = 0;
|
||||
$subtotal_ttc = 0;
|
||||
if ($result)
|
||||
{
|
||||
$num = $db->num_rows($result);
|
||||
$i = 0;
|
||||
if ($num)
|
||||
{
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $db->fetch_object($result);
|
||||
|
||||
$total_ht += $obj->amount;
|
||||
$total_ttc += $obj->amount;
|
||||
$subtotal_ht += $obj->amount;
|
||||
$subtotal_ttc += $obj->amount;
|
||||
|
||||
print '<tr class="oddeven"><td> </td>';
|
||||
|
||||
print "<td>".$langs->trans("Donation")." <a href=\"".DOL_URL_ROOT."/don/list.php?search_company=".$obj->name."&search_name=".$obj->firstname." ".$obj->lastname."\">".$obj->name." ".$obj->firstname." ".$obj->lastname."</a></td>\n";
|
||||
|
||||
if ($modecompta == 'CREANCES-DETTES') print '<td class="right">'.price($obj->amount).'</td>';
|
||||
print '<td class="right">'.price($obj->amount).'</td>';
|
||||
print '</tr>';
|
||||
$i++;
|
||||
}
|
||||
} else {
|
||||
print '<tr class="oddeven"><td> </td>';
|
||||
print '<td colspan="3" class="opacitymedium">'.$langs->trans("None").'</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
print '<tr class="liste_total">';
|
||||
if ($modecompta == 'CREANCES-DETTES')
|
||||
print '<td colspan="3" class="right">'.price($subtotal_ht).'</td>';
|
||||
print '<td colspan="3" class="right">'.price($subtotal_ttc).'</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
/*
|
||||
* Various Payments
|
||||
*/
|
||||
//$conf->global->ACCOUNTING_REPORTS_INCLUDE_VARPAY = 1;
|
||||
|
||||
if (!empty($conf->global->ACCOUNTING_REPORTS_INCLUDE_VARPAY) && !empty($conf->banque->enabled) && ($modecompta == 'CREANCES-DETTES' || $modecompta == "RECETTES-DEPENSES"))
|
||||
{
|
||||
@ -953,12 +957,14 @@ if ($modecompta == 'BOOKKEEPING')
|
||||
$result = $db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
// Debit
|
||||
// Debit (payment of suppliers for example)
|
||||
$obj = $db->fetch_object($result);
|
||||
if (isset($obj->amount))
|
||||
{
|
||||
$subtotal_ht += -$obj->amount;
|
||||
$subtotal_ttc += -$obj->amount;
|
||||
$total_ht_outcome += $obj->amount;
|
||||
$total_ttc_outcome += $obj->amount;
|
||||
}
|
||||
print '<tr class="oddeven"><td> </td>';
|
||||
print "<td>".$langs->trans("Debit")."</td>\n";
|
||||
@ -966,12 +972,14 @@ if ($modecompta == 'BOOKKEEPING')
|
||||
print '<td class="right">'.price(-$obj->amount)."</td>\n";
|
||||
print "</tr>\n";
|
||||
|
||||
// Credit
|
||||
// Credit (payment received from customer for example)
|
||||
$obj = $db->fetch_object($result);
|
||||
if (isset($obj->amount))
|
||||
{
|
||||
$subtotal_ht += $obj->amount;
|
||||
$subtotal_ttc += $obj->amount;
|
||||
$total_ht_income += $obj->amount;
|
||||
$total_ttc_income += $obj->amount;
|
||||
}
|
||||
print '<tr class="oddeven"><td> </td>';
|
||||
print "<td>".$langs->trans("Credit")."</td>\n";
|
||||
@ -1030,6 +1038,8 @@ if ($modecompta == 'BOOKKEEPING')
|
||||
}
|
||||
$total_ht += $subtotal_ht;
|
||||
$total_ttc += $subtotal_ttc;
|
||||
$total_ht_income += $subtotal_ht;
|
||||
$total_ttc_income += $subtotal_ttc;
|
||||
print '<tr class="liste_total">';
|
||||
if ($modecompta == 'CREANCES-DETTES')
|
||||
print '<td colspan="3" class="right">'.price($subtotal_ht).'</td>';
|
||||
@ -1050,7 +1060,7 @@ if ($modecompta == 'BOOKKEEPING')
|
||||
{
|
||||
if ($modecompta == 'CREANCES-DETTES')
|
||||
{
|
||||
// TVA a payer
|
||||
// VAT to pay
|
||||
$amount = 0;
|
||||
$sql = "SELECT date_format(f.datef,'%Y-%m') as dm, sum(f.tva) as amount";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f";
|
||||
@ -1091,13 +1101,15 @@ if ($modecompta == 'BOOKKEEPING')
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
$total_ht_outcome -= 0;
|
||||
$total_ttc_outcome -= $amount;
|
||||
print '<tr class="oddeven"><td> </td>';
|
||||
print "<td>".$langs->trans("VATToPay")."</td>\n";
|
||||
print '<td class="right"> </td>'."\n";
|
||||
print '<td class="right">'.price($amount)."</td>\n";
|
||||
print "</tr>\n";
|
||||
|
||||
// TVA a recuperer
|
||||
// VAT to retreive
|
||||
$amount = 0;
|
||||
$sql = "SELECT date_format(f.datef,'%Y-%m') as dm, sum(f.total_tva) as amount";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f";
|
||||
@ -1139,6 +1151,9 @@ if ($modecompta == 'BOOKKEEPING')
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
$total_ht_income += 0;
|
||||
$total_ttc_income += $amount;
|
||||
|
||||
print '<tr class="oddeven"><td> </td>';
|
||||
print '<td>'.$langs->trans("VATToCollect")."</td>\n";
|
||||
print '<td class="right"> </td>'."\n";
|
||||
@ -1182,10 +1197,12 @@ if ($modecompta == 'BOOKKEEPING')
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
$total_ht_outcome -= 0;
|
||||
$total_ttc_outcome -= $amount;
|
||||
print '<tr class="oddeven"><td> </td>';
|
||||
print "<td>".$langs->trans("VATPaid")."</td>\n";
|
||||
if ($modecompta == 'CREANCES-DETTES')
|
||||
print '<td <class="right">'.price($amount)."</td>\n";
|
||||
print '<td <class="right"></td>'."\n";
|
||||
print '<td class="right">'.price($amount)."</td>\n";
|
||||
print "</tr>\n";
|
||||
|
||||
@ -1226,16 +1243,18 @@ if ($modecompta == 'BOOKKEEPING')
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
$total_ht_income += 0;
|
||||
$total_ttc_income += $amount;
|
||||
print '<tr class="oddeven"><td> </td>';
|
||||
print "<td>".$langs->trans("VATCollected")."</td>\n";
|
||||
if ($modecompta == 'CREANCES-DETTES')
|
||||
print '<td class="right">'.price($amount)."</td>\n";
|
||||
print '<td class="right"></td>'."\n";
|
||||
print '<td class="right">'.price($amount)."</td>\n";
|
||||
print "</tr>\n";
|
||||
}
|
||||
}
|
||||
|
||||
if ($mysoc->tva_assuj != 'franchise') // Assujetti
|
||||
if ($mysoc->tva_assuj != '0') // Assujetti
|
||||
{
|
||||
print '<tr class="liste_total">';
|
||||
if ($modecompta == 'CREANCES-DETTES')
|
||||
@ -1250,25 +1269,31 @@ $object = array(&$total_ht, &$total_ttc);
|
||||
$parameters["mode"] = $modecompta;
|
||||
$parameters["date_start"] = $date_start;
|
||||
$parameters["date_end"] = $date_end;
|
||||
$parameters["bc"] = $bc;
|
||||
// Initialize technical object to manage hooks of expenses. Note that conf->hooks_modules contains array array
|
||||
$hookmanager->initHooks(array('externalbalance'));
|
||||
$reshook = $hookmanager->executeHooks('addBalanceLine', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||
print $hookmanager->resPrint;
|
||||
|
||||
if ($mysoc->tva_assuj != 'franchise') // Assujetti
|
||||
{
|
||||
// Total
|
||||
print '<tr>';
|
||||
print '<td colspan="4"> </td>';
|
||||
print '</tr>';
|
||||
// Total
|
||||
print '<tr>';
|
||||
print '<td colspan="4"> </td>';
|
||||
print '</tr>';
|
||||
|
||||
print '<tr class="liste_total"><td class="left" colspan="2">'.$langs->trans("Profit").'</td>';
|
||||
if ($modecompta == 'CREANCES-DETTES')
|
||||
print '<td class="liste_total right">'.price(price2num($total_ht, 'MT')).'</td>';
|
||||
print '<td class="liste_total right">'.price(price2num($total_ttc, 'MT')).'</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
print '<tr class="liste_total"><td class="left" colspan="2">'.$langs->trans("Outcome").'</td>';
|
||||
if ($modecompta == 'CREANCES-DETTES')
|
||||
print '<td class="liste_total right">'.price(price2num(-$total_ht_outcome, 'MT')).'</td>';
|
||||
print '<td class="liste_total right">'.price(price2num(-$total_ttc_outcome, 'MT')).'</td>';
|
||||
print '</tr>';
|
||||
print '<tr class="liste_total"><td class="left" colspan="2">'.$langs->trans("Income").'</td>';
|
||||
if ($modecompta == 'CREANCES-DETTES')
|
||||
print '<td class="liste_total right">'.price(price2num($total_ht_income, 'MT')).'</td>';
|
||||
print '<td class="liste_total right">'.price(price2num($total_ttc_income, 'MT')).'</td>';
|
||||
print '</tr>';
|
||||
print '<tr class="liste_total"><td class="left" colspan="2">'.$langs->trans("Profit").'</td>';
|
||||
if ($modecompta == 'CREANCES-DETTES')
|
||||
print '<td class="liste_total right">'.price(price2num($total_ht, 'MT')).'</td>';
|
||||
print '<td class="liste_total right">'.price(price2num($total_ttc, 'MT')).'</td>';
|
||||
print '</tr>';
|
||||
|
||||
print "</table>";
|
||||
print '<br>';
|
||||
|
||||
@ -131,14 +131,8 @@ $arrayfields = array(
|
||||
'status'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000),
|
||||
);
|
||||
// Extra fields
|
||||
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0)
|
||||
{
|
||||
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val)
|
||||
{
|
||||
if (!empty($extrafields->attributes[$object->table_element]['list'][$key]))
|
||||
$arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key]));
|
||||
}
|
||||
}
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
|
||||
|
||||
$object->fields = dol_sort_array($object->fields, 'position');
|
||||
$arrayfields = dol_sort_array($arrayfields, 'position');
|
||||
|
||||
@ -620,14 +614,14 @@ while ($i < min($num, $limit))
|
||||
$socstatic->logo = $obj->logo;
|
||||
$socstatic->country_id = $obj->country_id;
|
||||
$socstatic->country_code = '';
|
||||
$socstatic->country_label = '';*/
|
||||
$socstatic->country = '';*/
|
||||
if ($obj->country_id > 0) {
|
||||
if (!isset($cacheCountryIDCode[$obj->country_id]['code'])) {
|
||||
$tmparray = getCountry($obj->country_id, 'all');
|
||||
$cacheCountryIDCode[$obj->country_id] = array('code'=> empty($tmparray['code']) ? '' : $tmparray['code'], 'label' => empty($tmparray['label']) ? '' : $tmparray['label']);
|
||||
}
|
||||
$socstatic->country_code = $cacheCountryIDCode[$obj->country_id]['code'];
|
||||
$socstatic->country_label = $cacheCountryIDCode[$obj->country_id]['label'];
|
||||
$socstatic->country = $cacheCountryIDCode[$obj->country_id]['label'];
|
||||
}
|
||||
|
||||
|
||||
@ -701,7 +695,7 @@ while ($i < min($num, $limit))
|
||||
if (!empty($arrayfields['country.code_iso']['checked']))
|
||||
{
|
||||
print '<td class="center">';
|
||||
print $socstatic->country_label;
|
||||
print $socstatic->country;
|
||||
print '</td>';
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
}
|
||||
|
||||
@ -130,14 +130,8 @@ $arrayfields = array(
|
||||
'cd.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500)
|
||||
);
|
||||
// Extra fields
|
||||
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0)
|
||||
{
|
||||
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val)
|
||||
{
|
||||
if (!empty($extrafields->attributes[$object->table_element]['list'][$key]))
|
||||
$arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key]));
|
||||
}
|
||||
}
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
|
||||
|
||||
$object->fields = dol_sort_array($object->fields, 'position');
|
||||
$arrayfields = dol_sort_array($arrayfields, 'position');
|
||||
|
||||
|
||||
@ -61,9 +61,9 @@ class box_funnel_of_prospection extends ModeleBoxes
|
||||
|
||||
$this->db = $db;
|
||||
|
||||
$this->enabled = ($conf->global->MAIN_FEATURES_LEVEL >= 1); // Not enabled by default, still need some work
|
||||
$this->enabled = ($conf->global->MAIN_FEATURES_LEVEL >= 1 ? 1 : 0); // Not enabled by default, still need some work
|
||||
|
||||
$this->hidden = !($user->rights->projet->lire);
|
||||
$this->hidden = empty($user->rights->projet->lire);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -165,7 +165,7 @@ class box_scheduled_jobs extends ModeleBoxes
|
||||
);
|
||||
$this->info_box_contents[$line][] = array(
|
||||
'td' => 'class="center"',
|
||||
'textnoformat' => ($nbjobsinerror ? '<span class="error"><a href="'.DOL_URL_ROOT.'/cron/list.php?search_lastresult='.urlencode('<>0').'">'.$nbjobsinerror.img_error() : '<div class="center badge-status4">0</div></a></span>')
|
||||
'textnoformat' => ($nbjobsinerror ? '<a href="'.DOL_URL_ROOT.'/cron/list.php?search_lastresult='.urlencode('<>0').'"><div class="badge badge-danger"><i class="fa fa-exclamation-triangle"></i> '.$nbjobsinerror.'</div></a>' : '<div class="center badge-status4">0</div>')
|
||||
);
|
||||
} else {
|
||||
$this->info_box_contents[0][0] = array(
|
||||
|
||||
@ -56,7 +56,7 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" box
|
||||
/**
|
||||
* @var boolean Condition to have widget visible (in most cases, permissions)
|
||||
*/
|
||||
public $hidden = 0;
|
||||
public $hidden = false;
|
||||
|
||||
/**
|
||||
* @var int Box definition database ID
|
||||
|
||||
@ -355,7 +355,7 @@ abstract class CommonObject
|
||||
public $last_main_doc;
|
||||
|
||||
/**
|
||||
* @var int Bank account ID
|
||||
* @var int Bank account ID sometimes, ID of record into llx_bank sometimes
|
||||
* @deprecated
|
||||
* @see $fk_account
|
||||
*/
|
||||
|
||||
@ -52,9 +52,11 @@ class Conf
|
||||
public $disable_compute;
|
||||
//! Used to store current currency (ISO code like 'USD', 'EUR', ...)
|
||||
public $currency;
|
||||
|
||||
//! Used to store current css (from theme)
|
||||
public $theme; // Contains current theme ("eldy", "auguria", ...)
|
||||
public $css; // Contains full path of css page ("/theme/eldy/style.css.php", ...)
|
||||
|
||||
//! Used to store current menu handler
|
||||
public $standard_menu;
|
||||
// List of activated modules
|
||||
@ -98,6 +100,8 @@ class Conf
|
||||
public $dol_no_mouse_hover; // Set if we force param dol_no_mouse_hover into login url or if browser is smartphone
|
||||
public $dol_use_jmobile; // Set if we force param dol_use_jmobile into login url
|
||||
|
||||
public $liste_limit;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
|
||||
@ -891,7 +891,6 @@ class DolGraph
|
||||
$color1 = sprintf("%02x%02x%02x", $this->bgcolorgrid[0], $this->bgcolorgrid[0], $this->bgcolorgrid[2]);
|
||||
$color2 = sprintf("%02x%02x%02x", $this->bgcolorgrid[0], $this->bgcolorgrid[1], $this->bgcolorgrid[2]);
|
||||
$this->stringtoshow .= ', grid: { hoverable: true, backgroundColor: { colors: ["#' . $color1 . '", "#' . $color2 . '"] }, borderWidth: 1, borderColor: \'#e6e6e6\', tickColor : \'#e6e6e6\' }' . "\n";
|
||||
//$this->stringtoshow.=', shadowSize: 20'."\n"; TODO Uncommet this
|
||||
$this->stringtoshow .= '});' . "\n";
|
||||
$this->stringtoshow .= '}' . "\n";
|
||||
}
|
||||
|
||||
@ -991,32 +991,23 @@ class ExtraFields
|
||||
else return '';
|
||||
}
|
||||
|
||||
if (empty($morecss))
|
||||
{
|
||||
if ($type == 'date')
|
||||
{
|
||||
if (empty($morecss)) {
|
||||
if ($type == 'date') {
|
||||
$morecss = 'minwidth100imp';
|
||||
} elseif ($type == 'datetime' || $type == 'link')
|
||||
{
|
||||
} elseif ($type == 'datetime' || $type == 'link') {
|
||||
$morecss = 'minwidth200imp';
|
||||
} elseif (in_array($type, array('int', 'integer', 'double', 'price')))
|
||||
{
|
||||
} elseif (in_array($type, array('int', 'integer', 'double', 'price'))) {
|
||||
$morecss = 'maxwidth75';
|
||||
} elseif ($type == 'password')
|
||||
{
|
||||
} elseif ($type == 'password') {
|
||||
$morecss = 'maxwidth100';
|
||||
} elseif ($type == 'url')
|
||||
{
|
||||
} elseif ($type == 'url') {
|
||||
$morecss = 'minwidth400';
|
||||
} elseif ($type == 'boolean')
|
||||
{
|
||||
} elseif ($type == 'boolean') {
|
||||
$morecss = '';
|
||||
} else {
|
||||
if (round($size) < 12)
|
||||
{
|
||||
if (empty($size) || round($size) < 12) {
|
||||
$morecss = 'minwidth100';
|
||||
} elseif (round($size) <= 48)
|
||||
{
|
||||
} elseif (round($size) <= 48) {
|
||||
$morecss = 'minwidth200';
|
||||
} else {
|
||||
$morecss = 'minwidth400';
|
||||
@ -1024,8 +1015,7 @@ class ExtraFields
|
||||
}
|
||||
}
|
||||
|
||||
if (in_array($type, array('date', 'datetime')))
|
||||
{
|
||||
if (in_array($type, array('date', 'datetime'))) {
|
||||
$tmp = explode(',', $size);
|
||||
$newsize = $tmp[0];
|
||||
|
||||
|
||||
@ -3939,13 +3939,16 @@ class Form
|
||||
* @param string $moreattrib To add more attribute on select
|
||||
* @param int $showcurrency Show currency in label
|
||||
* @param string $morecss More CSS
|
||||
* @param int $nooutput 1=Return string, do not send to output
|
||||
* @return int <0 if error, Num of bank account found if OK (0, 1, 2, ...)
|
||||
*/
|
||||
public function select_comptes($selected = '', $htmlname = 'accountid', $status = 0, $filtre = '', $useempty = 0, $moreattrib = '', $showcurrency = 0, $morecss = '')
|
||||
public function select_comptes($selected = '', $htmlname = 'accountid', $status = 0, $filtre = '', $useempty = 0, $moreattrib = '', $showcurrency = 0, $morecss = '', $nooutput = 0)
|
||||
{
|
||||
// phpcs:enable
|
||||
global $langs, $conf;
|
||||
|
||||
$out = '';
|
||||
|
||||
$langs->load("admin");
|
||||
$num = 0;
|
||||
|
||||
@ -3964,10 +3967,10 @@ class Form
|
||||
$i = 0;
|
||||
if ($num)
|
||||
{
|
||||
print '<select id="select'.$htmlname.'" class="flat selectbankaccount'.($morecss ? ' '.$morecss : '').'" name="'.$htmlname.'"'.($moreattrib ? ' '.$moreattrib : '').'>';
|
||||
$out .= '<select id="select'.$htmlname.'" class="flat selectbankaccount'.($morecss ? ' '.$morecss : '').'" name="'.$htmlname.'"'.($moreattrib ? ' '.$moreattrib : '').'>';
|
||||
if ($useempty == 1 || ($useempty == 2 && $num > 1))
|
||||
{
|
||||
print '<option value="-1"> </option>';
|
||||
$out .= '<option value="-1"> </option>';
|
||||
}
|
||||
|
||||
while ($i < $num)
|
||||
@ -3975,26 +3978,30 @@ class Form
|
||||
$obj = $this->db->fetch_object($result);
|
||||
if ($selected == $obj->rowid || ($useempty == 2 && $num == 1 && empty($selected)))
|
||||
{
|
||||
print '<option value="'.$obj->rowid.'" selected>';
|
||||
$out .= '<option value="'.$obj->rowid.'" selected>';
|
||||
} else {
|
||||
print '<option value="'.$obj->rowid.'">';
|
||||
$out .= '<option value="'.$obj->rowid.'">';
|
||||
}
|
||||
print trim($obj->label);
|
||||
if ($showcurrency) print ' ('.$obj->currency_code.')';
|
||||
if ($status == 2 && $obj->status == 1) print ' ('.$langs->trans("Closed").')';
|
||||
print '</option>';
|
||||
$out .= trim($obj->label);
|
||||
if ($showcurrency) $out .= ' ('.$obj->currency_code.')';
|
||||
if ($status == 2 && $obj->status == 1) $out .= ' ('.$langs->trans("Closed").')';
|
||||
$out .= '</option>';
|
||||
$i++;
|
||||
}
|
||||
print "</select>";
|
||||
print ajax_combobox('select'.$htmlname);
|
||||
$out .= "</select>";
|
||||
$out .= ajax_combobox('select'.$htmlname);
|
||||
} else {
|
||||
if ($status == 0) print '<span class="opacitymedium">'.$langs->trans("NoActiveBankAccountDefined").'</span>';
|
||||
else print '<span class="opacitymedium">'.$langs->trans("NoBankAccountFound").'</span>';
|
||||
if ($status == 0) $out .= '<span class="opacitymedium">'.$langs->trans("NoActiveBankAccountDefined").'</span>';
|
||||
else $out .= '<span class="opacitymedium">'.$langs->trans("NoBankAccountFound").'</span>';
|
||||
}
|
||||
} else {
|
||||
dol_print_error($this->db);
|
||||
}
|
||||
|
||||
// Output or return
|
||||
if (empty($nooutput)) print $out;
|
||||
else return $out;
|
||||
|
||||
return $num;
|
||||
}
|
||||
|
||||
|
||||
@ -112,26 +112,40 @@ class Notify
|
||||
|
||||
$listofnotiftodo = $this->getNotificationsArray($action, $socid, $object, 0);
|
||||
|
||||
$texte = '';
|
||||
$nb = -1;
|
||||
if (is_array($listofnotiftodo)) $nb = count($listofnotiftodo);
|
||||
if ($nb < 0) $texte = img_object($langs->trans("Notifications"), 'email').' '.$langs->trans("ErrorFailedToGetListOfNotificationsToSend");
|
||||
if ($nb == 0) $texte = img_object($langs->trans("Notifications"), 'email').' '.$langs->trans("NoNotificationsWillBeSent");
|
||||
if ($nb == 1) $texte = img_object($langs->trans("Notifications"), 'email').' '.$langs->trans("ANotificationsWillBeSent");
|
||||
if ($nb >= 2) $texte = img_object($langs->trans("Notifications"), 'email').' '.$langs->trans("SomeNotificationsWillBeSent", $nb);
|
||||
if (is_array($listofnotiftodo)) {
|
||||
$nb = count($listofnotiftodo);
|
||||
}
|
||||
if ($nb < 0) {
|
||||
$texte = img_object($langs->trans("Notifications"), 'email').' '.$langs->trans("ErrorFailedToGetListOfNotificationsToSend");
|
||||
} elseif ($nb == 0) {
|
||||
$texte = img_object($langs->trans("Notifications"), 'email').' '.$langs->trans("NoNotificationsWillBeSent");
|
||||
} elseif ($nb == 1) {
|
||||
$texte = img_object($langs->trans("Notifications"), 'email').' '.$langs->trans("ANotificationsWillBeSent");
|
||||
} elseif ($nb >= 2) {
|
||||
$texte = img_object($langs->trans("Notifications"), 'email').' '.$langs->trans("SomeNotificationsWillBeSent", $nb);
|
||||
}
|
||||
|
||||
if (is_array($listofnotiftodo))
|
||||
{
|
||||
if (is_array($listofnotiftodo)) {
|
||||
$i = 0;
|
||||
foreach ($listofnotiftodo as $key => $val)
|
||||
{
|
||||
if ($i) $texte .= ', ';
|
||||
else $texte .= ' (';
|
||||
if ($val['isemailvalid']) $texte .= $val['email'];
|
||||
else $texte .= $val['emaildesc'];
|
||||
foreach ($listofnotiftodo as $key => $val) {
|
||||
if ($i) {
|
||||
$texte .= ', ';
|
||||
} else {
|
||||
$texte .= ' (';
|
||||
}
|
||||
if ($val['isemailvalid']) {
|
||||
$texte .= $val['email'];
|
||||
} else {
|
||||
$texte .= $val['emaildesc'];
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
if ($i) $texte .= ')';
|
||||
}
|
||||
if ($i) {
|
||||
$texte .= ')';
|
||||
}
|
||||
}
|
||||
|
||||
return $texte;
|
||||
}
|
||||
@ -154,12 +168,21 @@ class Notify
|
||||
$resarray = array();
|
||||
|
||||
$valueforthreshold = 0;
|
||||
if (is_object($object)) $valueforthreshold = $object->total_ht;
|
||||
if (is_object($object)) {
|
||||
$valueforthreshold = $object->total_ht;
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if ($socid >= 0 && in_array('thirdparty', $scope))
|
||||
{
|
||||
$sqlnotifcode = '';
|
||||
if ($notifcode) {
|
||||
if (is_numeric($notifcode)) {
|
||||
$sqlnotifcode = " AND n.fk_action = ".$notifcode; // Old usage
|
||||
} else {
|
||||
$sqlnotifcode = " AND a.code = '".$this->db->escape($notifcode)."'"; // New usage
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
if ($socid >= 0 && in_array('thirdparty', $scope)) {
|
||||
$sql = "SELECT a.code, c.email, c.rowid";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."notify_def as n,";
|
||||
$sql .= " ".MAIN_DB_PREFIX."socpeople as c,";
|
||||
@ -168,29 +191,26 @@ class Notify
|
||||
$sql .= " WHERE n.fk_contact = c.rowid";
|
||||
$sql .= " AND a.rowid = n.fk_action";
|
||||
$sql .= " AND n.fk_soc = s.rowid";
|
||||
if ($notifcode)
|
||||
{
|
||||
if (is_numeric($notifcode)) $sql .= " AND n.fk_action = ".$notifcode; // Old usage
|
||||
else $sql .= " AND a.code = '".$this->db->escape($notifcode)."'"; // New usage
|
||||
}
|
||||
$sql .= $sqlnotifcode;
|
||||
$sql .= " AND s.entity IN (".getEntity('societe').")";
|
||||
if ($socid > 0) $sql .= " AND s.rowid = ".$socid;
|
||||
if ($socid > 0) {
|
||||
$sql .= " AND s.rowid = ".$socid;
|
||||
}
|
||||
|
||||
dol_syslog(__METHOD__." ".$notifcode.", ".$socid."", LOG_DEBUG);
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($resql) {
|
||||
$num = $this->db->num_rows($resql);
|
||||
$i = 0;
|
||||
while ($i < $num)
|
||||
{
|
||||
while ($i < $num) {
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
if ($obj)
|
||||
{
|
||||
if ($obj) {
|
||||
$newval2 = trim($obj->email);
|
||||
$isvalid = isValidEmail($newval2);
|
||||
if (empty($resarray[$newval2])) $resarray[$newval2] = array('type'=> 'tocontact', 'code'=>trim($obj->code), 'emaildesc'=>'Contact id '.$obj->rowid, 'email'=>$newval2, 'contactid'=>$obj->rowid, 'isemailvalid'=>$isvalid);
|
||||
if (empty($resarray[$newval2])) {
|
||||
$resarray[$newval2] = array('type'=> 'tocontact', 'code'=>trim($obj->code), 'emaildesc'=>'Contact id '.$obj->rowid, 'email'=>$newval2, 'contactid'=>$obj->rowid, 'isemailvalid'=>$isvalid);
|
||||
}
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
@ -201,39 +221,34 @@ class Notify
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if ($userid >= 0 && in_array('user', $scope))
|
||||
{
|
||||
if (!$error) {
|
||||
if ($userid >= 0 && in_array('user', $scope)) {
|
||||
$sql = "SELECT a.code, c.email, c.rowid";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."notify_def as n,";
|
||||
$sql .= " ".MAIN_DB_PREFIX."user as c,";
|
||||
$sql .= " ".MAIN_DB_PREFIX."c_action_trigger as a";
|
||||
$sql .= " WHERE n.fk_user = c.rowid";
|
||||
$sql .= " AND a.rowid = n.fk_action";
|
||||
if ($notifcode)
|
||||
{
|
||||
if (is_numeric($notifcode)) $sql .= " AND n.fk_action = ".$notifcode; // Old usage
|
||||
else $sql .= " AND a.code = '".$this->db->escape($notifcode)."'"; // New usage
|
||||
}
|
||||
$sql .= $sqlnotifcode;
|
||||
$sql .= " AND c.entity IN (".getEntity('user').")";
|
||||
if ($userid > 0) $sql .= " AND c.rowid = ".$userid;
|
||||
if ($userid > 0) {
|
||||
$sql .= " AND c.rowid = ".$userid;
|
||||
}
|
||||
|
||||
dol_syslog(__METHOD__." ".$notifcode.", ".$socid."", LOG_DEBUG);
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($resql) {
|
||||
$num = $this->db->num_rows($resql);
|
||||
$i = 0;
|
||||
while ($i < $num)
|
||||
{
|
||||
while ($i < $num) {
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
if ($obj)
|
||||
{
|
||||
if ($obj) {
|
||||
$newval2 = trim($obj->email);
|
||||
$isvalid = isValidEmail($newval2);
|
||||
if (empty($resarray[$newval2])) $resarray[$newval2] = array('type'=> 'touser', 'code'=>trim($obj->code), 'emaildesc'=>'User id '.$obj->rowid, 'email'=>$newval2, 'userid'=>$obj->rowid, 'isemailvalid'=>$isvalid);
|
||||
if (empty($resarray[$newval2])) {
|
||||
$resarray[$newval2] = array('type'=> 'touser', 'code'=>trim($obj->code), 'emaildesc'=>'User id '.$obj->rowid, 'email'=>$newval2, 'userid'=>$obj->rowid, 'isemailvalid'=>$isvalid);
|
||||
}
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
@ -244,48 +259,55 @@ class Notify
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (in_array('global', $scope))
|
||||
{
|
||||
if (!$error) {
|
||||
if (in_array('global', $scope)) {
|
||||
// List of notifications enabled for fixed email
|
||||
foreach ($conf->global as $key => $val)
|
||||
{
|
||||
if ($notifcode)
|
||||
{
|
||||
if ($val == '' || !preg_match('/^NOTIFICATION_FIXEDEMAIL_'.$notifcode.'_THRESHOLD_HIGHER_(.*)$/', $key, $reg)) continue;
|
||||
foreach ($conf->global as $key => $val) {
|
||||
if ($notifcode) {
|
||||
if ($val == '' || !preg_match('/^NOTIFICATION_FIXEDEMAIL_'.$notifcode.'_THRESHOLD_HIGHER_(.*)$/', $key, $reg)) {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
if ($val == '' || !preg_match('/^NOTIFICATION_FIXEDEMAIL_.*_THRESHOLD_HIGHER_(.*)$/', $key, $reg)) continue;
|
||||
if ($val == '' || !preg_match('/^NOTIFICATION_FIXEDEMAIL_.*_THRESHOLD_HIGHER_(.*)$/', $key, $reg)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$threshold = (float) $reg[1];
|
||||
if ($valueforthreshold < $threshold) continue;
|
||||
if ($valueforthreshold < $threshold) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$tmpemail = explode(',', $val);
|
||||
foreach ($tmpemail as $key2 => $val2)
|
||||
{
|
||||
foreach ($tmpemail as $key2 => $val2) {
|
||||
$newval2 = trim($val2);
|
||||
if ($newval2 == '__SUPERVISOREMAIL__')
|
||||
{
|
||||
if ($user->fk_user > 0)
|
||||
{
|
||||
if ($newval2 == '__SUPERVISOREMAIL__') {
|
||||
if ($user->fk_user > 0) {
|
||||
$tmpuser = new User($this->db);
|
||||
$tmpuser->fetch($user->fk_user);
|
||||
if ($tmpuser->email) $newval2 = trim($tmpuser->email);
|
||||
else $newval2 = '';
|
||||
} else $newval2 = '';
|
||||
if ($tmpuser->email) {
|
||||
$newval2 = trim($tmpuser->email);
|
||||
} else {
|
||||
$newval2 = '';
|
||||
}
|
||||
} else {
|
||||
$newval2 = '';
|
||||
}
|
||||
}
|
||||
if ($newval2)
|
||||
{
|
||||
if ($newval2) {
|
||||
$isvalid = isValidEmail($newval2, 0);
|
||||
if (empty($resarray[$newval2])) $resarray[$newval2] = array('type'=> 'tofixedemail', 'code'=>trim($key), 'emaildesc'=>trim($val2), 'email'=>$newval2, 'isemailvalid'=>$isvalid);
|
||||
if (empty($resarray[$newval2])) {
|
||||
$resarray[$newval2] = array('type'=> 'tofixedemail', 'code'=>trim($key), 'emaildesc'=>trim($val2), 'email'=>$newval2, 'isemailvalid'=>$isvalid);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($error) return -1;
|
||||
if ($error) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
//var_dump($resarray);
|
||||
return $resarray;
|
||||
@ -309,11 +331,12 @@ class Notify
|
||||
global $dolibarr_main_url_root;
|
||||
global $action;
|
||||
|
||||
if (!in_array($notifcode, $this->arrayofnotifsupported)) return 0;
|
||||
if (!in_array($notifcode, $this->arrayofnotifsupported)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
if (!is_object($hookmanager))
|
||||
{
|
||||
if (!is_object($hookmanager)) {
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
|
||||
$hookmanager = new HookManager($this->db);
|
||||
}
|
||||
@ -330,7 +353,9 @@ class Notify
|
||||
|
||||
// Define some vars
|
||||
$application = 'Dolibarr';
|
||||
if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $application = $conf->global->MAIN_APPLICATION_TITLE;
|
||||
if (!empty($conf->global->MAIN_APPLICATION_TITLE)) {
|
||||
$application = $conf->global->MAIN_APPLICATION_TITLE;
|
||||
}
|
||||
$replyto = $conf->notification->email_from;
|
||||
$object_type = '';
|
||||
$link = '';
|
||||
@ -343,8 +368,7 @@ class Notify
|
||||
$sql = '';
|
||||
|
||||
// Check notification per third party
|
||||
if (!empty($object->socid) && $object->socid > 0)
|
||||
{
|
||||
if (!empty($object->socid) && $object->socid > 0) {
|
||||
$sql .= "SELECT 'tocontactid' as type_target, c.email, c.rowid as cid, c.lastname, c.firstname, c.default_lang,";
|
||||
$sql .= " a.rowid as adid, a.label, a.code, n.rowid, n.type";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."socpeople as c,";
|
||||
@ -354,8 +378,11 @@ class Notify
|
||||
$sql .= " WHERE n.fk_contact = c.rowid AND a.rowid = n.fk_action";
|
||||
$sql .= " AND n.fk_soc = s.rowid";
|
||||
$sql .= " AND c.statut = 1";
|
||||
if (is_numeric($notifcode)) $sql .= " AND n.fk_action = ".$notifcode; // Old usage
|
||||
else $sql .= " AND a.code = '".$this->db->escape($notifcode)."'"; // New usage
|
||||
if (is_numeric($notifcode)) {
|
||||
$sql .= " AND n.fk_action = ".$notifcode; // Old usage
|
||||
} else {
|
||||
$sql .= " AND a.code = '".$this->db->escape($notifcode)."'"; // New usage
|
||||
}
|
||||
$sql .= " AND s.rowid = ".$object->socid;
|
||||
|
||||
$sql .= "\nUNION\n";
|
||||
@ -369,41 +396,42 @@ class Notify
|
||||
$sql .= " ".MAIN_DB_PREFIX."notify_def as n";
|
||||
$sql .= " WHERE n.fk_user = c.rowid AND a.rowid = n.fk_action";
|
||||
$sql .= " AND c.statut = 1";
|
||||
if (is_numeric($notifcode)) $sql .= " AND n.fk_action = ".$notifcode; // Old usage
|
||||
else $sql .= " AND a.code = '".$this->db->escape($notifcode)."'"; // New usage
|
||||
if (is_numeric($notifcode)) {
|
||||
$sql .= " AND n.fk_action = ".$notifcode; // Old usage
|
||||
} else {
|
||||
$sql .= " AND a.code = '".$this->db->escape($notifcode)."'"; // New usage
|
||||
}
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
if ($result) {
|
||||
$num = $this->db->num_rows($result);
|
||||
$projtitle = '';
|
||||
if (!empty($object->fk_project))
|
||||
{
|
||||
if (!empty($object->fk_project)) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
||||
$proj = new Project($this->db);
|
||||
$proj->fetch($object->fk_project);
|
||||
$projtitle = '('.$proj->title.')';
|
||||
}
|
||||
|
||||
if ($num > 0)
|
||||
{
|
||||
if ($num > 0) {
|
||||
$i = 0;
|
||||
while ($i < $num && !$error) // For each notification couple defined (third party/actioncode)
|
||||
{
|
||||
while ($i < $num && !$error) { // For each notification couple defined (third party/actioncode)
|
||||
$obj = $this->db->fetch_object($result);
|
||||
|
||||
$sendto = dolGetFirstLastname($obj->firstname, $obj->lastname)." <".$obj->email.">";
|
||||
$notifcodedefid = $obj->adid;
|
||||
$trackid = '';
|
||||
if ($obj->type_target == 'tocontactid') $trackid = 'con'.$obj->id;
|
||||
if ($obj->type_target == 'touserid') $trackid = 'use'.$obj->id;
|
||||
if ($obj->type_target == 'tocontactid') {
|
||||
$trackid = 'con'.$obj->id;
|
||||
}
|
||||
if ($obj->type_target == 'touserid') {
|
||||
$trackid = 'use'.$obj->id;
|
||||
}
|
||||
|
||||
if (dol_strlen($obj->email))
|
||||
{
|
||||
if (dol_strlen($obj->email)) {
|
||||
// Set output language
|
||||
$outputlangs = $langs;
|
||||
if ($obj->default_lang && $obj->default_lang != $langs->defaultlang)
|
||||
{
|
||||
if ($obj->default_lang && $obj->default_lang != $langs->defaultlang) {
|
||||
$outputlangs = new Translate('', $conf);
|
||||
$outputlangs->setDefaultLang($obj->default_lang);
|
||||
$outputlangs->loadLangs(array("main", "other"));
|
||||
@ -511,8 +539,7 @@ class Notify
|
||||
}
|
||||
$ref = dol_sanitizeFileName($newref);
|
||||
$pdf_path = $dir_output."/".$ref."/".$ref.".pdf";
|
||||
if (!dol_is_file($pdf_path))
|
||||
{
|
||||
if (!dol_is_file($pdf_path)) {
|
||||
// We can't add PDF as it is not generated yet.
|
||||
$filepdf = '';
|
||||
} else {
|
||||
@ -525,13 +552,18 @@ class Notify
|
||||
$message .= $mesg;
|
||||
|
||||
$parameters = array('notifcode'=>$notifcode, 'sendto'=>$sendto, 'replyto'=>$replyto, 'file'=>$filename_list, 'mimefile'=>$mimetype_list, 'filename'=>$mimefilename_list);
|
||||
if (!isset($action)) $action = '';
|
||||
if (!isset($action)) {
|
||||
$action = '';
|
||||
}
|
||||
|
||||
$reshook = $hookmanager->executeHooks('formatNotificationMessage', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||
if (empty($reshook))
|
||||
{
|
||||
if (!empty($hookmanager->resArray['subject'])) $subject .= $hookmanager->resArray['subject'];
|
||||
if (!empty($hookmanager->resArray['message'])) $message .= $hookmanager->resArray['message'];
|
||||
if (empty($reshook)) {
|
||||
if (!empty($hookmanager->resArray['subject'])) {
|
||||
$subject .= $hookmanager->resArray['subject'];
|
||||
}
|
||||
if (!empty($hookmanager->resArray['message'])) {
|
||||
$message .= $hookmanager->resArray['message'];
|
||||
}
|
||||
}
|
||||
|
||||
$mailfile = new CMailFile(
|
||||
@ -553,17 +585,15 @@ class Notify
|
||||
'notification'
|
||||
);
|
||||
|
||||
if ($mailfile->sendfile())
|
||||
{
|
||||
if ($mailfile->sendfile()) {
|
||||
if ($obj->type_target == 'touserid') {
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."notify (daten, fk_action, fk_soc, fk_user, type, objet_type, type_target, objet_id, email)";
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."notify (daten, fk_action, fk_soc, fk_user, type, objet_type, type_target, objet_id, email)";
|
||||
$sql .= " VALUES ('".$this->db->idate(dol_now())."', ".$notifcodedefid.", ".($object->socid ? $object->socid : 'null').", ".$obj->cid.", '".$obj->type."', '".$object_type."', '".$obj->type_target."', ".$object->id.", '".$this->db->escape($obj->email)."')";
|
||||
} else {
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."notify (daten, fk_action, fk_soc, fk_contact, type, objet_type, type_target, objet_id, email)";
|
||||
$sql .= " VALUES ('".$this->db->idate(dol_now())."', ".$notifcodedefid.", ".($object->socid ? $object->socid : 'null').", ".$obj->cid.", '".$obj->type."', '".$object_type."', '".$obj->type_target."', ".$object->id.", '".$this->db->escape($obj->email)."')";
|
||||
}
|
||||
if (!$this->db->query($sql))
|
||||
{
|
||||
if (!$this->db->query($sql)) {
|
||||
dol_print_error($this->db);
|
||||
}
|
||||
} else {
|
||||
@ -579,23 +609,22 @@ class Notify
|
||||
dol_syslog("No notification to thirdparty sent, nothing into notification setup for the thirdparty socid = ".(empty($object->socid) ? '' : $object->socid));
|
||||
}
|
||||
} else {
|
||||
$error++;
|
||||
$error++;
|
||||
$this->errors[] = $this->db->lasterror();
|
||||
dol_syslog("Failed to get list of notification to send ".$this->db->lasterror(), LOG_ERR);
|
||||
return -1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Check notification using fixed email
|
||||
if (!$error)
|
||||
{
|
||||
foreach ($conf->global as $key => $val)
|
||||
{
|
||||
if (!$error) {
|
||||
foreach ($conf->global as $key => $val) {
|
||||
$reg = array();
|
||||
if ($val == '' || !preg_match('/^NOTIFICATION_FIXEDEMAIL_'.$notifcode.'_THRESHOLD_HIGHER_(.*)$/', $key, $reg)) continue;
|
||||
if ($val == '' || !preg_match('/^NOTIFICATION_FIXEDEMAIL_'.$notifcode.'_THRESHOLD_HIGHER_(.*)$/', $key, $reg)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$threshold = (float) $reg[1];
|
||||
if (!empty($object->total_ht) && $object->total_ht <= $threshold)
|
||||
{
|
||||
if (!empty($object->total_ht) && $object->total_ht <= $threshold) {
|
||||
dol_syslog("A notification is requested for notifcode = ".$notifcode." but amount = ".$object->total_ht." so lower than threshold = ".$threshold.". We discard this notification");
|
||||
continue;
|
||||
}
|
||||
@ -604,7 +633,9 @@ class Notify
|
||||
|
||||
$sendto = $conf->global->$param;
|
||||
$notifcodedefid = dol_getIdFromCode($this->db, $notifcode, 'c_action_trigger', 'code', 'rowid');
|
||||
if ($notifcodedefid <= 0) dol_print_error($this->db, 'Failed to get id from code');
|
||||
if ($notifcodedefid <= 0) {
|
||||
dol_print_error($this->db, 'Failed to get id from code');
|
||||
}
|
||||
$trackid = '';
|
||||
|
||||
$object_type = '';
|
||||
@ -721,8 +752,7 @@ class Notify
|
||||
}
|
||||
$ref = dol_sanitizeFileName($newref);
|
||||
$pdf_path = $dir_output."/".$ref."/".$ref.".pdf";
|
||||
if (!dol_is_file($pdf_path))
|
||||
{
|
||||
if (!dol_is_file($pdf_path)) {
|
||||
// We can't add PDF as it is not generated yet.
|
||||
$filepdf = '';
|
||||
} else {
|
||||
@ -736,14 +766,14 @@ class Notify
|
||||
$message = nl2br($message);
|
||||
|
||||
// Replace keyword __SUPERVISOREMAIL__
|
||||
if (preg_match('/__SUPERVISOREMAIL__/', $sendto))
|
||||
{
|
||||
if (preg_match('/__SUPERVISOREMAIL__/', $sendto)) {
|
||||
$newval = '';
|
||||
if ($user->fk_user > 0)
|
||||
{
|
||||
if ($user->fk_user > 0) {
|
||||
$supervisoruser = new User($this->db);
|
||||
$supervisoruser->fetch($user->fk_user);
|
||||
if ($supervisoruser->email) $newval = trim(dolGetFirstLastname($supervisoruser->firstname, $supervisoruser->lastname).' <'.$supervisoruser->email.'>');
|
||||
if ($supervisoruser->email) {
|
||||
$newval = trim(dolGetFirstLastname($supervisoruser->firstname, $supervisoruser->lastname).' <'.$supervisoruser->email.'>');
|
||||
}
|
||||
}
|
||||
dol_syslog("Replace the __SUPERVISOREMAIL__ key into recipient email string with ".$newval);
|
||||
$sendto = preg_replace('/__SUPERVISOREMAIL__/', $newval, $sendto);
|
||||
@ -752,14 +782,16 @@ class Notify
|
||||
$sendto = preg_replace('/[\s,]+$/', '', $sendto); // Clean end of string
|
||||
}
|
||||
|
||||
if ($sendto)
|
||||
{
|
||||
if ($sendto) {
|
||||
$parameters = array('notifcode'=>$notifcode, 'sendto'=>$sendto, 'replyto'=>$replyto, 'file'=>$filename_list, 'mimefile'=>$mimetype_list, 'filename'=>$mimefilename_list);
|
||||
$reshook = $hookmanager->executeHooks('formatNotificationMessage', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||
if (empty($reshook))
|
||||
{
|
||||
if (!empty($hookmanager->resArray['subject'])) $subject .= $hookmanager->resArray['subject'];
|
||||
if (!empty($hookmanager->resArray['message'])) $message .= $hookmanager->resArray['message'];
|
||||
if (empty($reshook)) {
|
||||
if (!empty($hookmanager->resArray['subject'])) {
|
||||
$subject .= $hookmanager->resArray['subject'];
|
||||
}
|
||||
if (!empty($hookmanager->resArray['message'])) {
|
||||
$message .= $hookmanager->resArray['message'];
|
||||
}
|
||||
}
|
||||
$mailfile = new CMailFile(
|
||||
$subject,
|
||||
@ -780,12 +812,10 @@ class Notify
|
||||
'notification'
|
||||
);
|
||||
|
||||
if ($mailfile->sendfile())
|
||||
{
|
||||
if ($mailfile->sendfile()) {
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."notify (daten, fk_action, fk_soc, fk_contact, type, type_target, objet_type, objet_id, email)";
|
||||
$sql .= " VALUES ('".$this->db->idate(dol_now())."', ".$notifcodedefid.", ".($object->socid ? $object->socid : 'null').", null, 'email', 'tofixedemail', '".$object_type."', ".$object->id.", '".$this->db->escape($conf->global->$param)."')";
|
||||
if (!$this->db->query($sql))
|
||||
{
|
||||
if (!$this->db->query($sql)) {
|
||||
dol_print_error($this->db);
|
||||
}
|
||||
} else {
|
||||
@ -796,7 +826,10 @@ class Notify
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error) return $num;
|
||||
else return -1 * $error;
|
||||
if (!$error) {
|
||||
return $num;
|
||||
} else {
|
||||
return -1 * $error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -168,7 +168,7 @@ class Utils
|
||||
$this->output = $langs->trans("PurgeNDirectoriesDeleted", $countdeleted);
|
||||
if ($count > $countdeleted) $this->output .= '<br>'.$langs->trans("PurgeNDirectoriesFailed", ($count - $countdeleted));
|
||||
} else {
|
||||
$this->output = $langs->trans("PurgeNothingToDelete").($choice == 'tempfilesold' ? ' (older than 24h)' : '');
|
||||
$this->output = $langs->trans("PurgeNothingToDelete").(in_array('tempfilesold', $choicesarray) ? ' (older than 24h for temp files)' : '');
|
||||
}
|
||||
|
||||
// Recreate temp dir that are not automatically recreated by core code for performance purpose, we need them
|
||||
|
||||
@ -2647,7 +2647,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity,
|
||||
}
|
||||
$original_file = $conf->accounting->dir_output.'/'.$original_file;
|
||||
} // Wrapping pour les expedition
|
||||
elseif ($modulepart == 'expedition' && !empty($conf->expedition->dir_output))
|
||||
elseif (($modulepart == 'expedition' || $modulepart == 'shipment') && !empty($conf->expedition->dir_output))
|
||||
{
|
||||
if ($fuser->rights->expedition->{$lire} || preg_match('/^specimen/i', $original_file))
|
||||
{
|
||||
@ -2655,7 +2655,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity,
|
||||
}
|
||||
$original_file = $conf->expedition->dir_output."/sending/".$original_file;
|
||||
} // Delivery Note Wrapping
|
||||
elseif ($modulepart == 'delivery' && !empty($conf->expedition->dir_output))
|
||||
elseif (($modulepart == 'livraison' || $modulepart == 'delivery') && !empty($conf->expedition->dir_output))
|
||||
{
|
||||
if ($fuser->rights->expedition->delivery->{$lire} || preg_match('/^specimen/i', $original_file))
|
||||
{
|
||||
|
||||
@ -2887,12 +2887,16 @@ function getUserRemoteIP()
|
||||
{
|
||||
if (empty($_SERVER['HTTP_X_FORWARDED_FOR']) || preg_match('/[^0-9\.\:,\[\]]/', $_SERVER['HTTP_X_FORWARDED_FOR'])) {
|
||||
if (empty($_SERVER['HTTP_CLIENT_IP']) || preg_match('/[^0-9\.\:,\[\]]/', $_SERVER['HTTP_CLIENT_IP'])) {
|
||||
$ip = (empty($_SERVER['REMOTE_ADDR']) ? '' : $_SERVER['REMOTE_ADDR']);
|
||||
if (empty($_SERVER["HTTP_CF_CONNECTING_IP"])) {
|
||||
$ip = (empty($_SERVER['REMOTE_ADDR']) ? '' : $_SERVER['REMOTE_ADDR']); // value may have been forged by client
|
||||
} else {
|
||||
$ip = $_SERVER["HTTP_CF_CONNECTING_IP"]; // value here may have been forged by client
|
||||
}
|
||||
} else {
|
||||
$ip = $_SERVER['HTTP_CLIENT_IP']; // value is clean here
|
||||
$ip = $_SERVER['HTTP_CLIENT_IP']; // value is clean here but may have been forged by proxy
|
||||
}
|
||||
} else {
|
||||
$ip = $_SERVER['HTTP_X_FORWARDED_FOR']; // value is clean here
|
||||
$ip = $_SERVER['HTTP_X_FORWARDED_FOR']; // value is clean here but may have been forged by proxy
|
||||
}
|
||||
return $ip;
|
||||
}
|
||||
@ -4457,7 +4461,7 @@ function print_barre_liste($titre, $page, $file, $options = '', $sortfield = '',
|
||||
|
||||
$savlimit = $limit;
|
||||
$savtotalnboflines = $totalnboflines;
|
||||
$totalnboflines = abs($totalnboflines);
|
||||
$totalnboflines = abs((int) $totalnboflines);
|
||||
|
||||
if ($picto == 'setup') $picto = 'title_setup.png';
|
||||
if (($conf->browser->name == 'ie') && $picto == 'generic') $picto = 'title.gif';
|
||||
@ -4873,7 +4877,7 @@ function price2num($amount, $rounding = '', $option = 0)
|
||||
elseif ($rounding == 'CR') $nbofdectoround = 8;
|
||||
elseif (is_numeric($rounding)) $nbofdectoround = $rounding;
|
||||
//print "RR".$amount.' - '.$nbofdectoround.'<br>';
|
||||
if (dol_strlen($nbofdectoround)) $amount = round($amount, $nbofdectoround); // $nbofdectoround can be 0.
|
||||
if (dol_strlen($nbofdectoround)) $amount = round(is_string($amount) ? (float) $amount : $amount, $nbofdectoround); // $nbofdectoround can be 0.
|
||||
else return 'ErrorBadParameterProvidedToFunction';
|
||||
//print 'SS'.$amount.' - '.$nbofdec.' - '.$dec.' - '.$thousand.' - '.$nbofdectoround.'<br>';
|
||||
|
||||
|
||||
@ -129,7 +129,7 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt
|
||||
$localtax1_type = 0;
|
||||
$localtax2_type = 0;
|
||||
|
||||
if (is_array($localtaxes_array)) {
|
||||
if (is_array($localtaxes_array) && count($localtaxes_array)) {
|
||||
$localtax1_type = $localtaxes_array[0];
|
||||
$localtax1_rate = $localtaxes_array[1];
|
||||
$localtax2_type = $localtaxes_array[2];
|
||||
|
||||
@ -50,7 +50,7 @@ function salaries_prepare_head($object)
|
||||
$nbLinks = Link::count($db, $object->element, $object->id);
|
||||
$head[$h][0] = DOL_URL_ROOT.'/salaries/document.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans('Documents');
|
||||
if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= '<span class="badge ">'.($nbFiles + $nbLinks).'</span>';
|
||||
if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
|
||||
$head[$h][2] = 'documents';
|
||||
$h++;
|
||||
|
||||
|
||||
@ -332,7 +332,7 @@ class modCategorie extends DolibarrModules
|
||||
$this->export_sql_end[$r] .= ' INNER JOIN '.MAIN_DB_PREFIX.'categorie_contact as cc ON cc.fk_categorie = cat.rowid';
|
||||
$this->export_sql_end[$r] .= ' INNER JOIN '.MAIN_DB_PREFIX.'socpeople as p ON p.rowid = cc.fk_socpeople';
|
||||
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople_extrafields as extra ON extra.fk_object = p.rowid';
|
||||
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_civility as civ ON civ.rowid = p.civility';
|
||||
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_civility as civ ON civ.code = p.civility';
|
||||
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON c.rowid = p.fk_pays';
|
||||
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON s.rowid = p.fk_soc';
|
||||
$this->export_sql_end[$r] .= ' WHERE cat.entity IN ('.getEntity('category').')';
|
||||
|
||||
@ -294,12 +294,15 @@ class modStock extends DolibarrModules
|
||||
include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
|
||||
|
||||
$this->export_sql_start[$r] = 'SELECT DISTINCT ';
|
||||
$this->export_sql_end[$r] = ' FROM ('.MAIN_DB_PREFIX.'product as p, '.MAIN_DB_PREFIX.'product_stock as ps, '.MAIN_DB_PREFIX.'product_batch as pb)';
|
||||
$this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'product_batch as pb';
|
||||
$this->export_sql_end[$r] .= ' INNER JOIN '.MAIN_DB_PREFIX.'product_stock as ps ON ps.rowid = pb.fk_product_stock';
|
||||
$this->export_sql_end[$r] .= ' INNER JOIN '.MAIN_DB_PREFIX.'product as p ON p.rowid = ps.fk_product';
|
||||
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_lot as pl ON pl.fk_product = p.rowid AND pl.batch = pb.batch';
|
||||
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_lot_extrafields as extra ON extra.fk_object = pl.rowid,';
|
||||
$this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'entrepot as e';
|
||||
$this->export_sql_end[$r] .= ' WHERE p.rowid = ps.fk_product AND ps.fk_entrepot = e.rowid AND ps.rowid = pb.fk_product_stock';
|
||||
$this->export_sql_end[$r] .= ' AND e.entity IN ('.getEntity('stock').')'; }
|
||||
$this->export_sql_end[$r] .= ' WHERE ps.fk_entrepot = e.rowid';
|
||||
$this->export_sql_end[$r] .= ' AND e.entity IN ('.getEntity('stock').')';
|
||||
}
|
||||
|
||||
// Export of stock movements
|
||||
$r++;
|
||||
|
||||
@ -23,7 +23,7 @@ if (!empty($extrafieldsobjectkey)) // $extrafieldsobject is the $object->table_e
|
||||
'label' => $extrafields->attributes[$extrafieldsobjectkey]['label'][$key],
|
||||
'checked' => (($extrafields->attributes[$extrafieldsobjectkey]['list'][$key] < 0) ? 0 : 1),
|
||||
'position' => $extrafields->attributes[$extrafieldsobjectkey]['pos'][$key],
|
||||
'enabled' => (abs($extrafields->attributes[$extrafieldsobjectkey]['list'][$key]) != 3 && $extrafields->attributes[$extrafieldsobjectkey]['perms'][$key]),
|
||||
'enabled' => (abs((int) $extrafields->attributes[$extrafieldsobjectkey]['list'][$key]) != 3 && $extrafields->attributes[$extrafieldsobjectkey]['perms'][$key]),
|
||||
'langfile' => $extrafields->attributes[$extrafieldsobjectkey]['langfile'][$key],
|
||||
'help' => $extrafields->attributes[$extrafieldsobjectkey]['help'][$key],
|
||||
);
|
||||
|
||||
@ -56,7 +56,7 @@ class EmailCollector extends CommonObject
|
||||
/**
|
||||
* @var string String with name of icon for emailcollector. Must be the part after the 'object_' into object_emailcollector.png
|
||||
*/
|
||||
public $picto = 'generic';
|
||||
public $picto = 'email';
|
||||
|
||||
/**
|
||||
* @var string Field with ID of parent key if this field has a parent
|
||||
@ -1555,10 +1555,9 @@ class EmailCollector extends CommonObject
|
||||
// Search and create thirdparty
|
||||
if ($operation['type'] == 'loadthirdparty' || $operation['type'] == 'loadandcreatethirdparty')
|
||||
{
|
||||
if (empty($operation['actionparam']))
|
||||
{
|
||||
if (empty($operation['actionparam'])) {
|
||||
$errorforactions++;
|
||||
$this->error = "Action loadthirdparty or loadandcreatethirdparty has empty parameter. Must be 'SET:xxx' or 'EXTRACT:(body|subject):regex' to define how to extract data";
|
||||
$this->error = "Action loadthirdparty or loadandcreatethirdparty has empty parameter. Must be a rule like 'SET:xxx' or 'EXTRACT:(body|subject):regex' to define how to set or extract data";
|
||||
$this->errors[] = $this->error;
|
||||
} else {
|
||||
$actionparam = $operation['actionparam'];
|
||||
|
||||
@ -140,14 +140,7 @@ $arrayfields = array(
|
||||
'd.fk_statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000),
|
||||
);
|
||||
// Extra fields
|
||||
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0)
|
||||
{
|
||||
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val)
|
||||
{
|
||||
if (!empty($extrafields->attributes[$object->table_element]['list'][$key]))
|
||||
$arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key]));
|
||||
}
|
||||
}
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
|
||||
|
||||
$canedituser = (!empty($user->admin) || $user->rights->user->user->creer);
|
||||
|
||||
|
||||
@ -117,14 +117,8 @@ $arrayfields = array(
|
||||
'fd.duree'=>array('label'=>'DurationOfLine', 'checked'=>1, 'enabled'=>empty($conf->global->FICHINTER_DISABLE_DETAILS) ? 1 : 0),
|
||||
);
|
||||
// Extra fields
|
||||
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0)
|
||||
{
|
||||
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val)
|
||||
{
|
||||
if (!empty($extrafields->attributes[$object->table_element]['list'][$key]))
|
||||
$arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key]));
|
||||
}
|
||||
}
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
|
||||
|
||||
$object->fields = dol_sort_array($object->fields, 'position');
|
||||
$arrayfields = dol_sort_array($arrayfields, 'position');
|
||||
|
||||
|
||||
@ -1714,8 +1714,8 @@ class CommandeFournisseur extends CommonOrder
|
||||
$multicurrency_total_ttc = $tabprice[18];
|
||||
$pu_ht_devise = $tabprice[19];
|
||||
|
||||
$localtax1_type = $localtaxes_type[0];
|
||||
$localtax2_type = $localtaxes_type[2];
|
||||
$localtax1_type = empty($localtaxes_type[0]) ? '' : $localtaxes_type[0];
|
||||
$localtax2_type = empty($localtaxes_type[2]) ? '' : $localtaxes_type[2];
|
||||
|
||||
$rangmax = $this->line_max();
|
||||
$rang = $rangmax + 1;
|
||||
@ -1734,8 +1734,8 @@ class CommandeFournisseur extends CommonOrder
|
||||
$this->line->tva_tx = $txtva;
|
||||
$this->line->localtax1_tx = ($total_localtax1 ? $localtaxes_type[1] : 0);
|
||||
$this->line->localtax2_tx = ($total_localtax2 ? $localtaxes_type[3] : 0);
|
||||
$this->line->localtax1_type = $localtaxes_type[0];
|
||||
$this->line->localtax2_type = $localtaxes_type[2];
|
||||
$this->line->localtax1_type = $localtax1_type;
|
||||
$this->line->localtax2_type = $localtax2_type;
|
||||
$this->line->fk_product = $fk_product;
|
||||
$this->line->product_type = $product_type;
|
||||
$this->line->remise_percent = $remise_percent;
|
||||
@ -2594,8 +2594,8 @@ class CommandeFournisseur extends CommonOrder
|
||||
$multicurrency_total_ttc = $tabprice[18];
|
||||
$pu_ht_devise = $tabprice[19];
|
||||
|
||||
$localtax1_type = $localtaxes_type[0];
|
||||
$localtax2_type = $localtaxes_type[2];
|
||||
$localtax1_type = empty($localtaxes_type[0]) ? '' : $localtaxes_type[0];
|
||||
$localtax2_type = empty($localtaxes_type[2]) ? '' : $localtaxes_type[2];
|
||||
|
||||
//Fetch current line from the database and then clone the object and set it in $oldline property
|
||||
$this->line = new CommandeFournisseurLigne($this->db);
|
||||
@ -2633,8 +2633,8 @@ class CommandeFournisseur extends CommonOrder
|
||||
$this->line->tva_tx = $txtva;
|
||||
$this->line->localtax1_tx = $txlocaltax1;
|
||||
$this->line->localtax2_tx = $txlocaltax2;
|
||||
$this->line->localtax1_type = $localtaxes_type[0];
|
||||
$this->line->localtax2_type = $localtaxes_type[2];
|
||||
$this->line->localtax1_type = empty($localtaxes_type[0]) ? '' : $localtaxes_type[0];
|
||||
$this->line->localtax2_type = empty($localtaxes_type[2]) ? '' : $localtaxes_type[2];
|
||||
$this->line->remise_percent = $remise_percent;
|
||||
$this->line->subprice = $pu_ht;
|
||||
$this->line->rang = $this->rang;
|
||||
|
||||
@ -1765,8 +1765,8 @@ class FactureFournisseur extends CommonInvoice
|
||||
$this->line->tva_tx = $txtva;
|
||||
$this->line->localtax1_tx = ($total_localtax1 ? $localtaxes_type[1] : 0);
|
||||
$this->line->localtax2_tx = ($total_localtax2 ? $localtaxes_type[3] : 0);
|
||||
$this->line->localtax1_type = $localtaxes_type[0];
|
||||
$this->line->localtax2_type = $localtaxes_type[2];
|
||||
$this->line->localtax1_type = empty($localtaxes_type[0]) ? '' : $localtaxes_type[0];
|
||||
$this->line->localtax2_type = empty($localtaxes_type[2]) ? '' : $localtaxes_type[2];
|
||||
|
||||
$this->line->total_ht = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ?-abs($total_ht) : $total_ht); // For credit note and if qty is negative, total is negative
|
||||
$this->line->total_tva = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ?-abs($total_tva) : $total_tva);
|
||||
@ -1952,8 +1952,8 @@ class FactureFournisseur extends CommonInvoice
|
||||
$line->tva_tx = $vatrate;
|
||||
$line->localtax1_tx = $txlocaltax1;
|
||||
$line->localtax2_tx = $txlocaltax2;
|
||||
$line->localtax1_type = $localtaxes_type[0];
|
||||
$line->localtax2_type = $localtaxes_type[2];
|
||||
$line->localtax1_type = empty($localtaxes_type[0]) ? '' : $localtaxes_type[0];
|
||||
$line->localtax2_type = empty($localtaxes_type[2]) ? '' : $localtaxes_type[2];
|
||||
$line->total_ht = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ?-abs($total_ht) : $total_ht);
|
||||
$line->total_tva = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ?-abs($total_tva) : $total_tva);
|
||||
$line->total_localtax1 = $total_localtax1;
|
||||
|
||||
@ -168,14 +168,8 @@ $arrayfields = array(
|
||||
'cf.billed'=>array('label'=>$langs->trans("Billed"), 'checked'=>1, 'position'=>1000, 'enabled'=>1)
|
||||
);
|
||||
// Extra fields
|
||||
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0)
|
||||
{
|
||||
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val)
|
||||
{
|
||||
if (!empty($extrafields->attributes[$object->table_element]['list'][$key]))
|
||||
$arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key]));
|
||||
}
|
||||
}
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
|
||||
|
||||
$object->fields = dol_sort_array($object->fields, 'position');
|
||||
$arrayfields = dol_sort_array($arrayfields, 'position');
|
||||
|
||||
|
||||
@ -115,6 +115,8 @@ $permissiondellink = $usercancreate; // Used by the include of actions_dellink.i
|
||||
$permissiontoedit = $usercancreate; // Used by the include of actions_lineupdown.inc.php
|
||||
$permissiontoadd = $usercancreate; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
|
||||
|
||||
$error = 0;
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
@ -183,8 +185,7 @@ if (empty($reshook))
|
||||
}
|
||||
|
||||
// Check parameters
|
||||
if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL) && $qualified_for_stock_change)
|
||||
{
|
||||
if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL) && $qualified_for_stock_change) {
|
||||
$langs->load("stocks");
|
||||
if (!$idwarehouse || $idwarehouse == -1)
|
||||
{
|
||||
@ -194,11 +195,9 @@ if (empty($reshook))
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
$result = $object->validate($user, '', $idwarehouse);
|
||||
if ($result < 0)
|
||||
{
|
||||
if ($result < 0) {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
} else {
|
||||
// Define output language
|
||||
@ -220,8 +219,7 @@ if (empty($reshook))
|
||||
}
|
||||
}
|
||||
}
|
||||
} elseif ($action == 'confirm_delete' && $confirm == 'yes')
|
||||
{
|
||||
} elseif ($action == 'confirm_delete' && $confirm == 'yes') {
|
||||
$object->fetch($id);
|
||||
$object->fetch_thirdparty();
|
||||
|
||||
@ -280,15 +278,13 @@ if (empty($reshook))
|
||||
} elseif ($action == 'confirm_paid' && $confirm == 'yes' && $usercancreate) {
|
||||
$object->fetch($id);
|
||||
$result = $object->set_paid($user);
|
||||
if ($result < 0)
|
||||
{
|
||||
if ($result < 0) {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
// Set supplier ref
|
||||
if ($action == 'setref_supplier' && $usercancreate)
|
||||
{
|
||||
if ($action == 'setref_supplier' && $usercancreate) {
|
||||
$object->ref_supplier = GETPOST('ref_supplier', 'alpha');
|
||||
|
||||
if ($object->update($user) < 0) {
|
||||
@ -315,8 +311,7 @@ if (empty($reshook))
|
||||
}
|
||||
|
||||
// payments conditions
|
||||
if ($action == 'setconditions' && $usercancreate)
|
||||
{
|
||||
if ($action == 'setconditions' && $usercancreate) {
|
||||
$object->fetch($id);
|
||||
$object->cond_reglement_code = 0; // To clean property
|
||||
$object->cond_reglement_id = 0; // To clean property
|
||||
@ -1680,20 +1675,17 @@ if ($action == 'create')
|
||||
$currency_code = $conf->currency;
|
||||
|
||||
$societe = '';
|
||||
if (GETPOST('socid') > 0)
|
||||
{
|
||||
if (GETPOST('socid') > 0) {
|
||||
$societe = new Societe($db);
|
||||
$societe->fetch(GETPOST('socid', 'int'));
|
||||
if (!empty($conf->multicurrency->enabled) && !empty($societe->multicurrency_code)) $currency_code = $societe->multicurrency_code;
|
||||
}
|
||||
|
||||
if (!empty($origin) && !empty($originid))
|
||||
{
|
||||
if (!empty($origin) && !empty($originid)) {
|
||||
// Parse element/subelement (ex: project_task)
|
||||
$element = $subelement = $origin;
|
||||
|
||||
if ($element == 'project')
|
||||
{
|
||||
if ($element == 'project') {
|
||||
$projectid = $originid;
|
||||
$element = 'projet';
|
||||
}
|
||||
@ -2204,8 +2196,7 @@ if ($action == 'create')
|
||||
|
||||
|
||||
// Show origin lines
|
||||
if (is_object($objectsrc))
|
||||
{
|
||||
if (is_object($objectsrc)) {
|
||||
print '<br>';
|
||||
|
||||
$title = $langs->trans('ProductsAndServices');
|
||||
@ -2218,8 +2209,7 @@ if ($action == 'create')
|
||||
print '</table>';
|
||||
}
|
||||
} else {
|
||||
if ($id > 0 || !empty($ref))
|
||||
{
|
||||
if ($id > 0 || !empty($ref)) {
|
||||
/* *************************************************************************** */
|
||||
/* */
|
||||
/* Fiche en mode visu ou edition */
|
||||
@ -2275,7 +2265,7 @@ if ($action == 'create')
|
||||
$head = facturefourn_prepare_head($object);
|
||||
$titre = $langs->trans('SupplierInvoice');
|
||||
|
||||
print dol_get_fiche_head($head, 'card', $titre, -1, 'bill');
|
||||
print dol_get_fiche_head($head, 'card', $titre, -1, 'supplier_invoice');
|
||||
|
||||
$formconfirm = '';
|
||||
|
||||
|
||||
@ -134,7 +134,7 @@ if ($id > 0 || !empty($ref))
|
||||
|
||||
$head = facturefourn_prepare_head($object);
|
||||
|
||||
print dol_get_fiche_head($head, 'contact', $langs->trans('SupplierInvoice'), -1, 'bill');
|
||||
print dol_get_fiche_head($head, 'contact', $langs->trans('SupplierInvoice'), -1, 'supplier_invoice');
|
||||
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/compta/facture/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
|
||||
|
||||
|
||||
@ -90,7 +90,7 @@ llxHeader('', $title, $helpurl);
|
||||
if ($object->id > 0)
|
||||
{
|
||||
$head = facturefourn_prepare_head($object);
|
||||
print dol_get_fiche_head($head, 'documents', $langs->trans('SupplierInvoice'), -1, 'bill');
|
||||
print dol_get_fiche_head($head, 'documents', $langs->trans('SupplierInvoice'), -1, 'supplier_invoice');
|
||||
|
||||
$totalpaye = $object->getSommePaiement();
|
||||
|
||||
|
||||
@ -51,7 +51,7 @@ $maxOpenCount = empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->globa
|
||||
|
||||
llxHeader("", $langs->trans("SupplierInvoicesArea"), 'EN:Suppliers_Invoices|FR:FactureFournisseur|ES:Facturas_de_proveedores');
|
||||
|
||||
print load_fiche_titre($langs->trans("SupplierInvoicesArea"), '', 'bill');
|
||||
print load_fiche_titre($langs->trans("SupplierInvoicesArea"), '', 'supplier_invoice');
|
||||
|
||||
print '<div class="fichecenter">';
|
||||
|
||||
|
||||
@ -65,7 +65,7 @@ $alreadypaid = $object->getSommePaiement();
|
||||
|
||||
$head = facturefourn_prepare_head($object);
|
||||
$titre = $langs->trans('SupplierInvoice');
|
||||
print dol_get_fiche_head($head, 'info', $langs->trans('SupplierInvoice'), -1, 'bill');
|
||||
print dol_get_fiche_head($head, 'info', $langs->trans('SupplierInvoice'), -1, 'supplier_invoice');
|
||||
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/compta/facture/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
|
||||
|
||||
|
||||
@ -189,14 +189,8 @@ $arrayfields = array(
|
||||
'f.fk_statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000),
|
||||
);
|
||||
// Extra fields
|
||||
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0)
|
||||
{
|
||||
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val)
|
||||
{
|
||||
if (!empty($extrafields->attributes[$object->table_element]['list'][$key]))
|
||||
$arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key]));
|
||||
}
|
||||
}
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
|
||||
|
||||
$object->fields = dol_sort_array($object->fields, 'position');
|
||||
$arrayfields = dol_sort_array($arrayfields, 'position');
|
||||
|
||||
|
||||
@ -82,7 +82,7 @@ if ($object->id > 0)
|
||||
|
||||
$head = facturefourn_prepare_head($object);
|
||||
$titre = $langs->trans('SupplierInvoice');
|
||||
print dol_get_fiche_head($head, 'note', $titre, -1, 'bill');
|
||||
print dol_get_fiche_head($head, 'note', $titre, -1, 'supplier_invoice');
|
||||
|
||||
|
||||
// Supplier invoice card
|
||||
|
||||
@ -143,14 +143,7 @@ $arrayfields = array(
|
||||
'cp.statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000),
|
||||
);
|
||||
// Extra fields
|
||||
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0)
|
||||
{
|
||||
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val)
|
||||
{
|
||||
if (!empty($extrafields->attributes[$object->table_element]['list'][$key]))
|
||||
$arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key]));
|
||||
}
|
||||
}
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
|
||||
|
||||
if (empty($conf->holiday->enabled))
|
||||
{
|
||||
|
||||
@ -13,7 +13,7 @@ use Luracast\Restler\iCache;
|
||||
* @copyright 2013 Luracast
|
||||
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
||||
* @link http://luracast.com/products/restler/
|
||||
* @version 3.0.0rc6
|
||||
*
|
||||
*/
|
||||
class ApcCache implements iCache
|
||||
{
|
||||
|
||||
@ -12,7 +12,7 @@ namespace Luracast\Restler {
|
||||
* @subpackage helper
|
||||
* @author Nick Lombard <github@jigsoft.co.za>
|
||||
* @copyright 2012 Luracast
|
||||
* @version 3.0.0rc6
|
||||
*
|
||||
*/
|
||||
class AutoLoader
|
||||
{
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace Luracast\Restler;
|
||||
|
||||
use Exception;
|
||||
@ -14,7 +15,7 @@ use Luracast\Restler\Data\Text;
|
||||
* @copyright 2010 Luracast
|
||||
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
||||
* @link http://luracast.com/products/restler/
|
||||
* @version 3.0.0rc6
|
||||
*
|
||||
*/
|
||||
class CommentParser
|
||||
{
|
||||
@ -55,8 +56,8 @@ class CommentParser
|
||||
* @var array annotations that support array value
|
||||
*/
|
||||
public static $allowsArrayValue = array(
|
||||
'choice' => true,
|
||||
'select' => true,
|
||||
'choice' => true,
|
||||
'select' => true,
|
||||
'properties' => true,
|
||||
);
|
||||
|
||||
@ -220,7 +221,7 @@ class CommentParser
|
||||
*/
|
||||
private function parseParam($param, array $value, array $embedded)
|
||||
{
|
||||
$data = & $this->_data;
|
||||
$data = &$this->_data;
|
||||
$allowMultiple = false;
|
||||
switch ($param) {
|
||||
case 'param' :
|
||||
@ -237,7 +238,7 @@ class CommentParser
|
||||
$value = $this->formatReturn($value);
|
||||
break;
|
||||
case 'class' :
|
||||
$data = & $data[$param];
|
||||
$data = &$data[$param];
|
||||
list ($param, $value) = $this->formatClass($value);
|
||||
break;
|
||||
case 'access' :
|
||||
@ -294,7 +295,7 @@ class CommentParser
|
||||
+= $data[$param][self::$embeddedDataName];
|
||||
}
|
||||
if (!is_array($data[$param])) {
|
||||
$data[$param] = array('description' => (string) $data[$param]);
|
||||
$data[$param] = array('description' => (string)$data[$param]);
|
||||
}
|
||||
if (is_array($value)) {
|
||||
$data[$param] = $value + $data[$param];
|
||||
@ -320,19 +321,24 @@ class CommentParser
|
||||
$data['pattern'] = $matches[2];
|
||||
}
|
||||
while (preg_match('/{@(\w+)\s?([^}]*)}/ms', $subject, $matches)) {
|
||||
$name = $matches[1];
|
||||
$value = $matches[2];
|
||||
$subject = str_replace($matches[0], '', $subject);
|
||||
if ($matches[1] == 'pattern') {
|
||||
if ($name == 'pattern') {
|
||||
throw new Exception('Inline pattern tag should follow {@pattern /REGEX_PATTERN_HERE/} format and can optionally include PCRE modifiers following the ending `/`');
|
||||
} elseif (isset(static::$allowsArrayValue[$matches[1]])) {
|
||||
$matches[2] = explode(static::$arrayDelimiter, $matches[2]);
|
||||
} elseif ($matches[2] == 'true' || $matches[2] == 'false') {
|
||||
$matches[2] = $matches[2] == 'true';
|
||||
} elseif ($matches[2] == '') {
|
||||
$matches[2] = true;
|
||||
} elseif ($matches[1] == 'required') {
|
||||
$matches[2] = explode(static::$arrayDelimiter, $matches[2]);
|
||||
} elseif (isset(static::$allowsArrayValue[$name])) {
|
||||
$value = explode(static::$arrayDelimiter, $value);
|
||||
} elseif ($value == 'true' || $value == 'false') {
|
||||
$value = $value == 'true';
|
||||
} elseif ($value == '') {
|
||||
$value = true;
|
||||
} elseif ($name == 'required') {
|
||||
$value = explode(static::$arrayDelimiter, $value);
|
||||
}
|
||||
$data[$matches[1]] = $matches[2];
|
||||
if (defined('Luracast\\Restler\\UI\\HtmlForm::'.$name)) {
|
||||
$value = constant($value);
|
||||
}
|
||||
$data[$name] = $value;
|
||||
}
|
||||
|
||||
while (preg_match(self::$embeddedDataPattern, $subject, $matches)) {
|
||||
@ -340,9 +346,9 @@ class CommentParser
|
||||
$str = $matches[self::$embeddedDataIndex];
|
||||
if (isset ($this->restler)
|
||||
&& self::$embeddedDataIndex > 1
|
||||
&& !empty ($matches[1])
|
||||
&& !empty ($name)
|
||||
) {
|
||||
$extension = $matches[1];
|
||||
$extension = $name;
|
||||
$formatMap = $this->restler->getFormatMap();
|
||||
if (isset ($formatMap[$extension])) {
|
||||
/**
|
||||
@ -397,15 +403,15 @@ class CommentParser
|
||||
{
|
||||
$code = 500;
|
||||
$exception = 'Exception';
|
||||
if(count($value)>1){
|
||||
if (count($value) > 1) {
|
||||
$v1 = $value[0];
|
||||
$v2 = $value[1];
|
||||
if(is_numeric($v1)){
|
||||
if (is_numeric($v1)) {
|
||||
$code = $v1;
|
||||
$exception = $v2;
|
||||
array_shift($value);
|
||||
array_shift($value);
|
||||
} elseif(is_numeric($v2)){
|
||||
} elseif (is_numeric($v2)) {
|
||||
$code = $v2;
|
||||
$exception = $v1;
|
||||
array_shift($value);
|
||||
@ -414,17 +420,17 @@ class CommentParser
|
||||
$exception = $v1;
|
||||
array_shift($value);
|
||||
}
|
||||
} elseif(count($value) && is_numeric($value[0])) {
|
||||
} elseif (count($value) && is_numeric($value[0])) {
|
||||
$code = $value[0];
|
||||
array_shift($value);
|
||||
}
|
||||
$message = implode(' ', $value);
|
||||
if(!isset(RestException::$codes[$code])){
|
||||
if (!isset(RestException::$codes[$code])) {
|
||||
$code = 500;
|
||||
} elseif(empty($message)){
|
||||
} elseif (empty($message)) {
|
||||
$message = RestException::$codes[$code];
|
||||
}
|
||||
return compact('code','message','exception');
|
||||
return compact('code', 'message', 'exception');
|
||||
}
|
||||
|
||||
private function formatClass(array $value)
|
||||
|
||||
@ -11,7 +11,7 @@ namespace Luracast\Restler;
|
||||
* @copyright 2010 Luracast
|
||||
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
||||
* @link http://luracast.com/products/restler/
|
||||
* @version 3.0.0rc6
|
||||
*
|
||||
*/
|
||||
class Compose implements iCompose
|
||||
{
|
||||
|
||||
@ -11,7 +11,7 @@ namespace Luracast\Restler\Data;
|
||||
* @copyright 2010 Luracast
|
||||
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
||||
* @link http://luracast.com/products/restler/
|
||||
* @version 3.0.0rc6
|
||||
*
|
||||
*/
|
||||
class ApiMethodInfo extends ValueObject
|
||||
{
|
||||
|
||||
@ -10,7 +10,7 @@ namespace Luracast\Restler\Data;
|
||||
* @copyright 2010 Luracast
|
||||
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
||||
* @link http://luracast.com/products/restler/
|
||||
* @version 3.0.0rc6
|
||||
*
|
||||
*/
|
||||
class Arr
|
||||
{
|
||||
|
||||
@ -12,7 +12,7 @@ use Exception;
|
||||
* @copyright 2010 Luracast
|
||||
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
||||
* @link http://luracast.com/products/restler/
|
||||
* @version 3.0.0rc6
|
||||
*
|
||||
*/
|
||||
class Invalid extends Exception
|
||||
{
|
||||
|
||||
@ -11,7 +11,7 @@ namespace Luracast\Restler\Data;
|
||||
* @copyright 2010 Luracast
|
||||
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
||||
* @link http://luracast.com/products/restler/
|
||||
* @version 3.0.0rc6
|
||||
*
|
||||
*/
|
||||
class Obj
|
||||
{
|
||||
|
||||
@ -10,87 +10,91 @@ namespace Luracast\Restler\Data;
|
||||
* @copyright 2010 Luracast
|
||||
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
||||
* @link http://luracast.com/products/restler/
|
||||
* @version 3.0.0rc6
|
||||
*
|
||||
*/
|
||||
class Text
|
||||
{
|
||||
/**
|
||||
* Given haystack contains the needle or not?
|
||||
*
|
||||
* @param string $haystack
|
||||
* @param string $needle
|
||||
* @param bool $caseSensitive
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function contains($haystack, $needle, $caseSensitive = true)
|
||||
{
|
||||
if (empty($needle))
|
||||
return true;
|
||||
return $caseSensitive
|
||||
? strpos($haystack, $needle) !== false
|
||||
: stripos($haystack, $needle) !== false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given haystack begins with the needle or not?
|
||||
*
|
||||
* @param string $haystack
|
||||
* @param string $needle
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function beginsWith($haystack, $needle)
|
||||
{
|
||||
$length = strlen($needle);
|
||||
return (substr($haystack, 0, $length) === $needle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Given haystack ends with the needle or not?
|
||||
*
|
||||
* @param string $haystack
|
||||
* @param string $needle
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function endsWith($haystack, $needle)
|
||||
{
|
||||
$length = strlen($needle);
|
||||
if ($length == 0) {
|
||||
return true;
|
||||
}
|
||||
return (substr($haystack, -$length) === $needle);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convert camelCased or underscored string in to a title
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function title($name)
|
||||
{
|
||||
return
|
||||
ucwords(
|
||||
preg_replace(
|
||||
array('/(?<=[^A-Z])([A-Z])/', '/(?<=[^0-9])([0-9])/', '/([_-])/', '/[^a-zA-Z0-9\s]|\s\s+/'),
|
||||
array(' $0', ' $0', ' ', ' '),
|
||||
$name
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert given string to be used as a slug or css class
|
||||
*
|
||||
* @param string $name
|
||||
* @return string
|
||||
*/
|
||||
public static function slug($name)
|
||||
{
|
||||
return preg_replace('/[^a-zA-Z]+/', '-', strtolower(strip_tags($name)));
|
||||
}
|
||||
/**
|
||||
* Given haystack contains the needle or not?
|
||||
*
|
||||
* @param string $haystack
|
||||
* @param string $needle
|
||||
* @param bool $caseSensitive
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function contains($haystack, $needle, $caseSensitive = true)
|
||||
{
|
||||
if (empty($needle))
|
||||
return true;
|
||||
return $caseSensitive
|
||||
? strpos($haystack, $needle) !== false
|
||||
: stripos($haystack, $needle) !== false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given haystack begins with the needle or not?
|
||||
*
|
||||
* @param string $haystack
|
||||
* @param string $needle
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function beginsWith($haystack, $needle)
|
||||
{
|
||||
$length = strlen($needle);
|
||||
return (substr($haystack, 0, $length) === $needle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Given haystack ends with the needle or not?
|
||||
*
|
||||
* @param string $haystack
|
||||
* @param string $needle
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function endsWith($haystack, $needle)
|
||||
{
|
||||
$length = strlen($needle);
|
||||
if ($length == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// @CHANGE LDR
|
||||
if (!is_string($haystack)) return false;
|
||||
|
||||
return (substr($haystack, -$length) === $needle);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convert camelCased or underscored string in to a title
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function title($name)
|
||||
{
|
||||
return
|
||||
ucwords(
|
||||
preg_replace(
|
||||
array('/(?<=[^A-Z])([A-Z])/', '/(?<=[^0-9])([0-9])/', '/([_-])/', '/[^a-zA-Z0-9\s]|\s\s+/'),
|
||||
array(' $0', ' $0', ' ', ' '),
|
||||
$name
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert given string to be used as a slug or css class
|
||||
*
|
||||
* @param string $name
|
||||
* @return string
|
||||
*/
|
||||
public static function slug($name)
|
||||
{
|
||||
return preg_replace('/[^a-zA-Z]+/', '-', strtolower(strip_tags($name)));
|
||||
}
|
||||
}
|
||||
@ -15,7 +15,7 @@ use Luracast\Restler\Util;
|
||||
* @copyright 2010 Luracast
|
||||
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
||||
* @link http://luracast.com/products/restler/
|
||||
* @version 3.0.0rc6
|
||||
*
|
||||
*/
|
||||
class ValidationInfo implements iValueObject
|
||||
{
|
||||
|
||||
@ -18,7 +18,7 @@ use Luracast\Restler\Util;
|
||||
* @copyright 2010 Luracast
|
||||
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
||||
* @link http://luracast.com/products/restler/
|
||||
* @version 3.0.0rc6
|
||||
*
|
||||
*/
|
||||
class Validator implements iValidate
|
||||
{
|
||||
|
||||
@ -11,7 +11,7 @@ namespace Luracast\Restler\Data;
|
||||
* @copyright 2010 Luracast
|
||||
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
||||
* @link http://luracast.com/products/restler/
|
||||
* @version 3.0.0rc6
|
||||
*
|
||||
*/
|
||||
class ValueObject implements iValueObject
|
||||
{
|
||||
|
||||
@ -10,7 +10,7 @@ namespace Luracast\Restler\Data;
|
||||
* @copyright 2010 Luracast
|
||||
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
||||
* @link http://luracast.com/products/restler/
|
||||
* @version 3.0.0rc6
|
||||
*
|
||||
*/
|
||||
interface iValidate {
|
||||
|
||||
|
||||
@ -11,7 +11,7 @@ namespace Luracast\Restler\Data;
|
||||
* @copyright 2010 Luracast
|
||||
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
||||
* @link http://luracast.com/products/restler/
|
||||
* @version 3.0.0rc6
|
||||
*
|
||||
*/
|
||||
interface iValueObject
|
||||
{
|
||||
|
||||
@ -15,7 +15,7 @@ use Luracast\Restler\Data\Validator;
|
||||
* @copyright 2010 Luracast
|
||||
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
||||
* @link http://luracast.com/products/restler/
|
||||
* @version 3.0.0rc6
|
||||
*
|
||||
*/
|
||||
class Defaults
|
||||
{
|
||||
|
||||
@ -9,7 +9,7 @@ namespace Luracast\Restler;
|
||||
* @copyright 2010 Luracast
|
||||
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
||||
* @link http://luracast.com/products/restler/
|
||||
* @version 3.0.0rc6
|
||||
*
|
||||
*/
|
||||
use Closure;
|
||||
|
||||
|
||||
@ -15,7 +15,7 @@ use Luracast\Restler\RestException;
|
||||
* @copyright 2010 Luracast
|
||||
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
||||
* @link http://luracast.com/products/restler/
|
||||
* @version 3.0.0rc6
|
||||
*
|
||||
*/
|
||||
class RateLimit implements iFilter, iUseAuthentication
|
||||
{
|
||||
|
||||
@ -15,7 +15,7 @@ use ArrayAccess;
|
||||
* @copyright 2010 Luracast
|
||||
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
||||
* @link http://luracast.com/products/restler/
|
||||
* @version 3.0.0rc6
|
||||
*
|
||||
*/
|
||||
class Flash implements ArrayAccess
|
||||
{
|
||||
|
||||
@ -17,7 +17,7 @@ use ZendAmf\Parser\OutputStream;
|
||||
* @copyright 2010 Luracast
|
||||
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
||||
* @link http://luracast.com/products/restler/
|
||||
* @version 3.0.0rc6
|
||||
*
|
||||
*/
|
||||
class AmfFormat extends DependentFormat
|
||||
{
|
||||
|
||||
@ -15,7 +15,7 @@ use Luracast\Restler\RestException;
|
||||
* @copyright 2010 Luracast
|
||||
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
||||
* @link http://luracast.com/products/restler/
|
||||
* @version 3.0.0rc6
|
||||
*
|
||||
*/
|
||||
class CsvFormat extends Format implements iDecodeStream
|
||||
{
|
||||
|
||||
@ -10,7 +10,7 @@ namespace Luracast\Restler\Format;
|
||||
* @copyright 2010 Luracast
|
||||
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
||||
* @link http://luracast.com/products/restler/
|
||||
* @version 3.0.0rc6
|
||||
*
|
||||
*/
|
||||
abstract class Format implements iFormat
|
||||
{
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace Luracast\Restler\Format;
|
||||
|
||||
use Exception;
|
||||
@ -6,8 +7,8 @@ use Illuminate\Events\Dispatcher;
|
||||
use Illuminate\Filesystem\Filesystem;
|
||||
use Illuminate\View\Compilers\BladeCompiler;
|
||||
use Illuminate\View\Engines\CompilerEngine;
|
||||
use Illuminate\View\Engines\PhpEngine;
|
||||
use Illuminate\View\Engines\EngineResolver;
|
||||
use Illuminate\View\Engines\PhpEngine;
|
||||
use Illuminate\View\Factory;
|
||||
use Illuminate\View\FileViewFinder;
|
||||
use Illuminate\View\View;
|
||||
@ -18,6 +19,10 @@ use Luracast\Restler\Restler;
|
||||
use Luracast\Restler\Scope;
|
||||
use Luracast\Restler\UI\Nav;
|
||||
use Luracast\Restler\Util;
|
||||
use Twig\Environment;
|
||||
use Twig\Extension\DebugExtension;
|
||||
use Twig\Loader\FilesystemLoader;
|
||||
use Twig\TwigFunction;
|
||||
|
||||
/**
|
||||
* Html template format
|
||||
@ -29,10 +34,14 @@ use Luracast\Restler\Util;
|
||||
* @copyright 2010 Luracast
|
||||
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
||||
* @link http://luracast.com/products/restler/
|
||||
* @version 3.0.0rc6
|
||||
*
|
||||
*/
|
||||
class HtmlFormat extends DependentFormat
|
||||
{
|
||||
const BLADE = 'Illuminate\View\View';
|
||||
const TWIG = 'Twig\Environment';
|
||||
const MUSTACHE = 'Mustache_Engine';
|
||||
|
||||
public static $mime = 'text/html';
|
||||
public static $extension = 'html';
|
||||
public static $view;
|
||||
@ -84,11 +93,12 @@ class HtmlFormat extends DependentFormat
|
||||
}
|
||||
}
|
||||
|
||||
public function getDependencyMap(){
|
||||
public function getDependencyMap()
|
||||
{
|
||||
return array(
|
||||
'Illuminate\View\View' => 'illuminate/view:4.2.*',
|
||||
'Twig_Environment' => 'twig/twig:v1.13.*',
|
||||
'Mustache_Engine' => 'mustache/mustache:dev-master',
|
||||
self::BLADE => 'illuminate/view:^8',
|
||||
self::TWIG => 'twig/twig:^3',
|
||||
self::MUSTACHE => 'mustache/mustache:dev-master',
|
||||
);
|
||||
}
|
||||
|
||||
@ -101,7 +111,7 @@ class HtmlFormat extends DependentFormat
|
||||
$resolver->register('blade', function () use ($engine) {
|
||||
return $engine;
|
||||
});
|
||||
$phpEngine = new PhpEngine();
|
||||
$phpEngine = new PhpEngine($files);
|
||||
$resolver->register('php', function () use ($phpEngine) {
|
||||
return $phpEngine;
|
||||
});
|
||||
@ -128,32 +138,43 @@ class HtmlFormat extends DependentFormat
|
||||
return $view->render();
|
||||
}
|
||||
|
||||
public static function twig(array $data, $debug = true)
|
||||
/**
|
||||
* @param array|object $data
|
||||
* @param bool $debug
|
||||
*
|
||||
* @return string
|
||||
* @throws \Twig\Error\LoaderError
|
||||
* @throws \Twig\Error\RuntimeError
|
||||
* @throws \Twig\Error\SyntaxError
|
||||
*/
|
||||
public static function twig($data, $debug = true)
|
||||
{
|
||||
$loader = new \Twig_Loader_Filesystem(static::$viewPath);
|
||||
$twig = new \Twig_Environment($loader, array(
|
||||
'cache' => static::$cacheDirectory,
|
||||
'debug' => $debug,
|
||||
$loader = new FilesystemLoader(static::$viewPath);
|
||||
$twig = new Environment($loader, array(
|
||||
'cache' => is_string(static::$cacheDirectory)
|
||||
? static::$cacheDirectory : false,
|
||||
'debug' => $debug,
|
||||
'use_strict_variables' => $debug,
|
||||
));
|
||||
if ($debug)
|
||||
$twig->addExtension(new \Twig_Extension_Debug());
|
||||
if ($debug) {
|
||||
$twig->addExtension(new DebugExtension());
|
||||
}
|
||||
|
||||
$twig->addFunction(
|
||||
new \Twig_SimpleFunction(
|
||||
new TwigFunction(
|
||||
'form',
|
||||
'Luracast\Restler\UI\Forms::get',
|
||||
array('is_safe' => array('html'))
|
||||
)
|
||||
);
|
||||
$twig->addFunction(
|
||||
new \Twig_SimpleFunction(
|
||||
new TwigFunction(
|
||||
'form_key',
|
||||
'Luracast\Restler\UI\Forms::key'
|
||||
)
|
||||
);
|
||||
$twig->addFunction(
|
||||
new \Twig_SimpleFunction(
|
||||
new TwigFunction(
|
||||
'nav',
|
||||
'Luracast\Restler\UI\Nav::get'
|
||||
)
|
||||
@ -164,7 +185,7 @@ class HtmlFormat extends DependentFormat
|
||||
isset(HtmlFormat::$data[$name]) &&
|
||||
is_callable(HtmlFormat::$data[$name])
|
||||
) {
|
||||
return new \Twig_SimpleFunction(
|
||||
return new TwigFunction(
|
||||
$name,
|
||||
HtmlFormat::$data[$name]
|
||||
);
|
||||
@ -172,21 +193,35 @@ class HtmlFormat extends DependentFormat
|
||||
return false;
|
||||
});
|
||||
|
||||
$template = $twig->loadTemplate(static::getViewFile());
|
||||
return $template->render($data);
|
||||
$template = $twig->load(static::getViewFile());
|
||||
return $template->render((array)$data);
|
||||
}
|
||||
|
||||
public static function handlebar(array $data, $debug = true)
|
||||
/**
|
||||
* @param array|object $data
|
||||
* @param bool $debug
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function handlebar($data, $debug = true)
|
||||
{
|
||||
return static::mustache($data, $debug);
|
||||
}
|
||||
|
||||
public static function mustache(array $data, $debug = true)
|
||||
/**
|
||||
* @param array|object $data
|
||||
* @param bool $debug
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function mustache($data, $debug = true)
|
||||
{
|
||||
if (!isset($data['nav']))
|
||||
$data = (array)$data;
|
||||
if (!isset($data['nav'])) {
|
||||
$data['nav'] = array_values(Nav::get());
|
||||
}
|
||||
$options = array(
|
||||
'loader' => new \Mustache_Loader_FilesystemLoader(
|
||||
'loader' => new \Mustache_Loader_FilesystemLoader(
|
||||
static::$viewPath,
|
||||
array('extension' => static::getViewExtension())
|
||||
),
|
||||
@ -200,16 +235,25 @@ class HtmlFormat extends DependentFormat
|
||||
},
|
||||
)
|
||||
);
|
||||
if (!$debug)
|
||||
if (!$debug) {
|
||||
$options['cache'] = static::$cacheDirectory;
|
||||
}
|
||||
$m = new \Mustache_Engine($options);
|
||||
return $m->render(static::getViewFile(), $data);
|
||||
}
|
||||
|
||||
public static function php(array $data, $debug = true)
|
||||
/**
|
||||
* @param array|object $data
|
||||
* @param bool $debug
|
||||
*
|
||||
* @return string
|
||||
* @throws RestException
|
||||
*/
|
||||
public static function php($data, $debug = true)
|
||||
{
|
||||
if (static::$view == 'debug')
|
||||
if (static::$view == 'debug') {
|
||||
static::$viewPath = dirname(__DIR__) . '/views';
|
||||
}
|
||||
$view = static::getViewFile(true);
|
||||
|
||||
if (!is_readable($view)) {
|
||||
@ -222,22 +266,26 @@ class HtmlFormat extends DependentFormat
|
||||
|
||||
$path = static::$viewPath . DIRECTORY_SEPARATOR;
|
||||
$template = function ($view) use ($data, $path) {
|
||||
$data = (array)$data;
|
||||
$form = function () {
|
||||
return call_user_func_array(
|
||||
'Luracast\Restler\UI\Forms::get',
|
||||
func_get_args()
|
||||
);
|
||||
};
|
||||
if (!isset($data['form']))
|
||||
if (!isset($data['form'])) {
|
||||
$data['form'] = $form;
|
||||
}
|
||||
$nav = function () {
|
||||
return call_user_func_array(
|
||||
'Luracast\Restler\UI\Nav::get',
|
||||
func_get_args()
|
||||
);
|
||||
};
|
||||
if (!isset($data['nav']))
|
||||
if (!isset($data['nav'])) {
|
||||
$data['nav'] = $nav;
|
||||
}
|
||||
|
||||
|
||||
$_ = function () use ($data, $path) {
|
||||
extract($data);
|
||||
@ -254,7 +302,7 @@ class HtmlFormat extends DependentFormat
|
||||
) {
|
||||
$str = '';
|
||||
foreach ($arrays as $arr) {
|
||||
extract($arr);
|
||||
extract((array)$arr);
|
||||
$str .= include $file;
|
||||
}
|
||||
return $str;
|
||||
@ -264,15 +312,18 @@ class HtmlFormat extends DependentFormat
|
||||
}
|
||||
break;
|
||||
case 'if':
|
||||
if (count($args) < 2)
|
||||
if (count($args) < 2) {
|
||||
$args[1] = '';
|
||||
if (count($args) < 3)
|
||||
}
|
||||
if (count($args) < 3) {
|
||||
$args[2] = '';
|
||||
}
|
||||
return $args[0] ? $args[1] : $args[2];
|
||||
break;
|
||||
default:
|
||||
if (isset($data[$task]) && is_callable($data[$task]))
|
||||
if (isset($data[$task]) && is_callable($data[$task])) {
|
||||
return call_user_func_array($data[$task], $args);
|
||||
}
|
||||
}
|
||||
return '';
|
||||
};
|
||||
@ -280,8 +331,9 @@ class HtmlFormat extends DependentFormat
|
||||
return @include $view;
|
||||
};
|
||||
$value = $template($view);
|
||||
if (is_string($value))
|
||||
if (is_string($value)) {
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -294,8 +346,8 @@ class HtmlFormat extends DependentFormat
|
||||
* Formatter has to make the encoded
|
||||
* output more human readable
|
||||
*
|
||||
* @throws \Exception
|
||||
* @return string encoded string
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function encode($data, $humanReadable = false)
|
||||
{
|
||||
@ -317,9 +369,9 @@ class HtmlFormat extends DependentFormat
|
||||
'response' => static::$convertResponseToArray
|
||||
? Obj::toArray($data)
|
||||
: $data,
|
||||
'stages' => $this->restler->getEvents(),
|
||||
'success' => $success,
|
||||
'error' => $error
|
||||
'stages' => $this->restler->getEvents(),
|
||||
'success' => $success,
|
||||
'error' => $error
|
||||
);
|
||||
$info = $data['api'] = $this->restler->apiMethodInfo;
|
||||
$metadata = Util::nestedValue(
|
||||
@ -358,7 +410,9 @@ class HtmlFormat extends DependentFormat
|
||||
if ($value) {
|
||||
$data = Util::nestedValue($data, explode('.', $value));
|
||||
}
|
||||
$data += static::$data;
|
||||
if (is_array($data)) {
|
||||
$data += static::$data;
|
||||
}
|
||||
if (false === ($i = strrpos(self::$view, '.'))) {
|
||||
$template = self::$template;
|
||||
} else {
|
||||
@ -369,17 +423,18 @@ class HtmlFormat extends DependentFormat
|
||||
static::$cacheDirectory = Defaults::$cacheDirectory . DIRECTORY_SEPARATOR . $template;
|
||||
if (!file_exists(static::$cacheDirectory)) {
|
||||
if (!mkdir(static::$cacheDirectory, 0770, true)) {
|
||||
throw new RestException(500, 'Unable to create cache directory `' . static::$cacheDirectory . '`');
|
||||
throw new RestException(500,
|
||||
'Unable to create cache directory `' . static::$cacheDirectory . '`');
|
||||
}
|
||||
}
|
||||
}
|
||||
if (method_exists($class = get_called_class(), $template)) {
|
||||
if ($template == 'blade') {
|
||||
$this->checkDependency('Illuminate\View\View');
|
||||
$this->checkDependency(self::BLADE);
|
||||
} elseif ($template == 'twig') {
|
||||
$this->checkDependency('Twig_Environment');
|
||||
$this->checkDependency(self::TWIG);
|
||||
} elseif ($template == 'mustache' || $template == 'handlebar') {
|
||||
$this->checkDependency('Mustache_Engine');
|
||||
$this->checkDependency(self::MUSTACHE);
|
||||
}
|
||||
return call_user_func("$class::$template", $data, $humanReadable);
|
||||
}
|
||||
@ -416,8 +471,9 @@ class HtmlFormat extends DependentFormat
|
||||
{
|
||||
$v = $fullPath ? static::$viewPath . '/' : '';
|
||||
$v .= static::$view;
|
||||
if ($includeExtension)
|
||||
if ($includeExtension) {
|
||||
$v .= '.' . static::getViewExtension();
|
||||
}
|
||||
return $v;
|
||||
}
|
||||
|
||||
|
||||
@ -11,7 +11,7 @@ namespace Luracast\Restler\Format;
|
||||
* @copyright 2010 Luracast
|
||||
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
||||
* @link http://luracast.com/products/restler/
|
||||
* @version 3.0.0rc6
|
||||
*
|
||||
*/
|
||||
class JsFormat extends JsonFormat
|
||||
{
|
||||
|
||||
@ -15,7 +15,7 @@ use Luracast\Restler\RestException;
|
||||
* @copyright 2010 Luracast
|
||||
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
||||
* @link http://luracast.com/products/restler/
|
||||
* @version 3.0.0rc6
|
||||
*
|
||||
*/
|
||||
class JsonFormat extends Format
|
||||
{
|
||||
|
||||
@ -9,7 +9,7 @@ namespace Luracast\Restler\Format;
|
||||
* @copyright 2010 Luracast
|
||||
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
||||
* @link http://luracast.com/products/restler/
|
||||
* @version 3.0.0rc6
|
||||
*
|
||||
*/
|
||||
abstract class MultiFormat implements iFormat
|
||||
{
|
||||
|
||||
@ -18,7 +18,7 @@ use CFPropertyList\CFPropertyList;
|
||||
* @copyright 2010 Luracast
|
||||
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
||||
* @link http://luracast.com/products/restler/
|
||||
* @version 3.0.0rc6
|
||||
*
|
||||
*/
|
||||
class PlistFormat extends DependentMultiFormat
|
||||
{
|
||||
|
||||
@ -11,7 +11,7 @@ namespace Luracast\Restler\Format;
|
||||
* @copyright 2010 Luracast
|
||||
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
||||
* @link http://luracast.com/products/restler/
|
||||
* @version 3.0.0rc6
|
||||
*
|
||||
*/
|
||||
class TsvFormat extends CsvFormat
|
||||
{
|
||||
|
||||
@ -13,7 +13,7 @@ use Luracast\Restler\RestException;
|
||||
* @copyright 2010 Luracast
|
||||
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
||||
* @link http://luracast.com/products/restler/
|
||||
* @version 3.0.0rc6
|
||||
*
|
||||
*/
|
||||
class UploadFormat extends Format
|
||||
{
|
||||
|
||||
@ -11,7 +11,7 @@ namespace Luracast\Restler\Format;
|
||||
* @copyright 2010 Luracast
|
||||
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
||||
* @link http://luracast.com/products/restler/
|
||||
* @version 3.0.0rc6
|
||||
*
|
||||
*/
|
||||
class UrlEncodedFormat extends Format
|
||||
{
|
||||
|
||||
@ -16,7 +16,7 @@ use XMLWriter;
|
||||
* @copyright 2010 Luracast
|
||||
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
||||
* @link http://luracast.com/products/restler/
|
||||
* @version 3.0.0rc6
|
||||
*
|
||||
*/
|
||||
class XmlFormat extends Format
|
||||
{
|
||||
|
||||
@ -14,7 +14,7 @@ use Luracast\Restler\Data\Obj;
|
||||
* @copyright 2010 Luracast
|
||||
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
||||
* @link http://luracast.com/products/restler/
|
||||
* @version 3.0.0rc6
|
||||
*
|
||||
*/
|
||||
class YamlFormat extends DependentFormat
|
||||
{
|
||||
|
||||
@ -11,7 +11,7 @@ namespace Luracast\Restler\Format;
|
||||
* @copyright 2010 Luracast
|
||||
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
||||
* @link http://luracast.com/products/restler/
|
||||
* @version 3.0.0rc6
|
||||
*
|
||||
*/
|
||||
interface iDecodeStream
|
||||
{
|
||||
|
||||
@ -11,7 +11,7 @@ namespace Luracast\Restler\Format;
|
||||
* @copyright 2010 Luracast
|
||||
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
||||
* @link http://luracast.com/products/restler/
|
||||
* @version 3.0.0rc6
|
||||
*
|
||||
*/
|
||||
interface iFormat
|
||||
{
|
||||
|
||||
@ -10,7 +10,7 @@ namespace Luracast\Restler;
|
||||
* @copyright 2010 Luracast
|
||||
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
||||
* @link http://luracast.com/products/restler/
|
||||
* @version 3.0.0rc6
|
||||
*
|
||||
*/
|
||||
class HumanReadableCache implements iCache
|
||||
{
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user