code syntax core directory

This commit is contained in:
Frédéric FRANCE 2021-02-23 22:03:23 +01:00
parent 2642e1d1b3
commit 554e449e40
No known key found for this signature in database
GPG Key ID: 06809324E4B2ABC1
512 changed files with 34726 additions and 28660 deletions

View File

@ -30,18 +30,17 @@
// $backtopage may be defined
// $triggermodname may be defined
if (!empty($permissionedit) && empty($permissiontoadd)) $permissiontoadd = $permissionedit; // For backward compatibility
if (!empty($permissionedit) && empty($permissiontoadd)) {
$permissiontoadd = $permissionedit; // For backward compatibility
}
if ($cancel)
{
if ($cancel) {
/*var_dump($cancel);
var_dump($backtopage);exit;*/
if (!empty($backtopageforcancel))
{
if (!empty($backtopageforcancel)) {
header("Location: ".$backtopageforcancel);
exit;
} elseif (!empty($backtopage))
{
} elseif (!empty($backtopage)) {
header("Location: ".$backtopage);
exit;
}
@ -50,19 +49,25 @@ if ($cancel)
// Action to add record
if ($action == 'add' && !empty($permissiontoadd))
{
foreach ($object->fields as $key => $val)
{
if ($action == 'add' && !empty($permissiontoadd)) {
foreach ($object->fields as $key => $val) {
if ($object->fields[$key]['type'] == 'duration') {
if (GETPOST($key.'hour') == '' && GETPOST($key.'min') == '') continue; // The field was not submited to be edited
if (GETPOST($key.'hour') == '' && GETPOST($key.'min') == '') {
continue; // The field was not submited to be edited
}
} else {
if (!GETPOSTISSET($key)) continue; // The field was not submited to be edited
if (!GETPOSTISSET($key)) {
continue; // The field was not submited to be edited
}
}
// Ignore special fields
if (in_array($key, array('rowid', 'entity', 'import_key'))) continue;
if (in_array($key, array('rowid', 'entity', 'import_key'))) {
continue;
}
if (in_array($key, array('date_creation', 'tms', 'fk_user_creat', 'fk_user_modif'))) {
if (!in_array(abs($val['visible']), array(1, 3))) continue; // Only 1 and 3 that are case to create
if (!in_array(abs($val['visible']), array(1, 3))) {
continue; // Only 1 and 3 that are case to create
}
}
// Set value to insert
@ -84,17 +89,19 @@ if ($action == 'add' && !empty($permissiontoadd))
} else {
$value = GETPOST($key, 'alphanohtml');
}
if (preg_match('/^integer:/i', $object->fields[$key]['type']) && $value == '-1') $value = ''; // This is an implicit foreign key field
if (!empty($object->fields[$key]['foreignkey']) && $value == '-1') $value = ''; // This is an explicit foreign key field
if (preg_match('/^integer:/i', $object->fields[$key]['type']) && $value == '-1') {
$value = ''; // This is an implicit foreign key field
}
if (!empty($object->fields[$key]['foreignkey']) && $value == '-1') {
$value = ''; // This is an explicit foreign key field
}
//var_dump($key.' '.$value.' '.$object->fields[$key]['type']);
$object->$key = $value;
if ($val['notnull'] > 0 && $object->$key == '' && !is_null($val['default']) && $val['default'] == '(PROV)')
{
if ($val['notnull'] > 0 && $object->$key == '' && !is_null($val['default']) && $val['default'] == '(PROV)') {
$object->$key = '(PROV)';
}
if ($val['notnull'] > 0 && $object->$key == '' && is_null($val['default']))
{
if ($val['notnull'] > 0 && $object->$key == '' && is_null($val['default'])) {
$error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv($val['label'])), null, 'errors');
}
@ -103,14 +110,14 @@ if ($action == 'add' && !empty($permissiontoadd))
// Fill array 'array_options' with data from add form
if (!$error) {
$ret = $extrafields->setOptionalsFromPost(null, $object);
if ($ret < 0) $error++;
if ($ret < 0) {
$error++;
}
}
if (!$error)
{
if (!$error) {
$result = $object->create($user);
if ($result > 0)
{
if ($result > 0) {
// Creation OK
$urltogo = $backtopage ? str_replace('__ID__', $result, $backtopage) : $backurlforlist;
$urltogo = preg_replace('/--IDFORBACKTOPAGE--/', $object->id, $urltogo); // New method to autoselect project after a New on another form object creation
@ -118,8 +125,11 @@ if ($action == 'add' && !empty($permissiontoadd))
exit;
} else {
// Creation KO
if (!empty($object->errors)) setEventMessages(null, $object->errors, 'errors');
else setEventMessages($object->error, null, 'errors');
if (!empty($object->errors)) {
setEventMessages(null, $object->errors, 'errors');
} else {
setEventMessages($object->error, null, 'errors');
}
$action = 'create';
}
} else {
@ -128,25 +138,31 @@ if ($action == 'add' && !empty($permissiontoadd))
}
// Action to update record
if ($action == 'update' && !empty($permissiontoadd))
{
foreach ($object->fields as $key => $val)
{
if ($action == 'update' && !empty($permissiontoadd)) {
foreach ($object->fields as $key => $val) {
// Check if field was submited to be edited
if ($object->fields[$key]['type'] == 'duration') {
if (!GETPOSTISSET($key.'hour') || !GETPOSTISSET($key.'min')) continue; // The field was not submited to be edited
if (!GETPOSTISSET($key.'hour') || !GETPOSTISSET($key.'min')) {
continue; // The field was not submited to be edited
}
} elseif ($object->fields[$key]['type'] == 'boolean') {
if (!GETPOSTISSET($key)) {
$object->$key = 0; // use 0 instead null if the field is defined as not null
continue;
}
} else {
if (!GETPOSTISSET($key)) continue; // The field was not submited to be edited
if (!GETPOSTISSET($key)) {
continue; // The field was not submited to be edited
}
}
// Ignore special fields
if (in_array($key, array('rowid', 'entity', 'import_key'))) continue;
if (in_array($key, array('rowid', 'entity', 'import_key'))) {
continue;
}
if (in_array($key, array('date_creation', 'tms', 'fk_user_creat', 'fk_user_modif'))) {
if (!in_array(abs($val['visible']), array(1, 3, 4))) continue; // Only 1 and 3 and 4 that are case to update
if (!in_array(abs($val['visible']), array(1, 3, 4))) {
continue; // Only 1 and 3 and 4 that are case to update
}
}
// Set value to update
@ -176,12 +192,15 @@ if ($action == 'update' && !empty($permissiontoadd))
} else {
$value = GETPOST($key, 'alpha');
}
if (preg_match('/^integer:/i', $object->fields[$key]['type']) && $value == '-1') $value = ''; // This is an implicit foreign key field
if (!empty($object->fields[$key]['foreignkey']) && $value == '-1') $value = ''; // This is an explicit foreign key field
if (preg_match('/^integer:/i', $object->fields[$key]['type']) && $value == '-1') {
$value = ''; // This is an implicit foreign key field
}
if (!empty($object->fields[$key]['foreignkey']) && $value == '-1') {
$value = ''; // This is an explicit foreign key field
}
$object->$key = $value;
if ($val['notnull'] > 0 && $object->$key == '' && is_null($val['default']))
{
if ($val['notnull'] > 0 && $object->$key == '' && is_null($val['default'])) {
$error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv($val['label'])), null, 'errors');
}
@ -190,14 +209,14 @@ if ($action == 'update' && !empty($permissiontoadd))
// Fill array 'array_options' with data from add form
if (!$error) {
$ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET');
if ($ret < 0) $error++;
if ($ret < 0) {
$error++;
}
}
if (!$error)
{
if (!$error) {
$result = $object->update($user);
if ($result > 0)
{
if ($result > 0) {
$action = 'view';
} else {
// Creation KO
@ -210,8 +229,7 @@ if ($action == 'update' && !empty($permissiontoadd))
}
// Action to update one extrafield
if ($action == "update_extras" && !empty($permissiontoadd))
{
if ($action == "update_extras" && !empty($permissiontoadd)) {
$object->fetch(GETPOST('id', 'int'));
$attributekey = GETPOST('attribute', 'alpha');
@ -226,8 +244,7 @@ if ($action == "update_extras" && !empty($permissiontoadd))
}
$result = $object->insertExtraFields(empty($triggermodname) ? '' : $triggermodname, $user);
if ($result > 0)
{
if ($result > 0) {
setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
$action = 'view';
} else {
@ -237,46 +254,42 @@ if ($action == "update_extras" && !empty($permissiontoadd))
}
// Action to delete
if ($action == 'confirm_delete' && !empty($permissiontodelete))
{
if (!($object->id > 0))
{
if ($action == 'confirm_delete' && !empty($permissiontodelete)) {
if (!($object->id > 0)) {
dol_print_error('', 'Error, object must be fetched before being deleted');
exit;
}
$result = $object->delete($user);
if ($result > 0)
{
if ($result > 0) {
// Delete OK
setEventMessages("RecordDeleted", null, 'mesgs');
header("Location: ".$backurlforlist);
exit;
} else {
if (!empty($object->errors)) setEventMessages(null, $object->errors, 'errors');
else setEventMessages($object->error, null, 'errors');
if (!empty($object->errors)) {
setEventMessages(null, $object->errors, 'errors');
} else {
setEventMessages($object->error, null, 'errors');
}
}
}
// Remove a line
if ($action == 'confirm_deleteline' && $confirm == 'yes' && !empty($permissiontoadd))
{
if ($action == 'confirm_deleteline' && $confirm == 'yes' && !empty($permissiontoadd)) {
if (method_exists($object, 'deleteline')) {
$result = $object->deleteline($user, $lineid); // For backward compatibility
} else {
$result = $object->deleteLine($user, $lineid);
}
if ($result > 0)
{
if ($result > 0) {
// Define output language
$outputlangs = $langs;
$newlang = '';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09'))
{
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
$newlang = GETPOST('lang_id', 'aZ09');
}
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && is_object($object->thirdparty))
{
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && is_object($object->thirdparty)) {
$newlang = $object->thirdparty->default_lang;
}
if (!empty($newlang)) {
@ -299,18 +312,20 @@ if ($action == 'confirm_deleteline' && $confirm == 'yes' && !empty($permissionto
}
// Action validate object
if ($action == 'confirm_validate' && $confirm == 'yes' && $permissiontoadd)
{
if ($action == 'confirm_validate' && $confirm == 'yes' && $permissiontoadd) {
$result = $object->validate($user);
if ($result >= 0)
{
if ($result >= 0) {
// Define output language
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
if (method_exists($object, 'generateDocument')) {
$outputlangs = $langs;
$newlang = '';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09');
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
$newlang = GETPOST('lang_id', 'aZ09');
}
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
$newlang = $object->thirdparty->default_lang;
}
if (!empty($newlang)) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
@ -332,18 +347,20 @@ if ($action == 'confirm_validate' && $confirm == 'yes' && $permissiontoadd)
}
// Action close object
if ($action == 'confirm_close' && $confirm == 'yes' && $permissiontoadd)
{
if ($action == 'confirm_close' && $confirm == 'yes' && $permissiontoadd) {
$result = $object->cancel($user);
if ($result >= 0)
{
if ($result >= 0) {
// Define output language
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
if (method_exists($object, 'generateDocument')) {
$outputlangs = $langs;
$newlang = '';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09');
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
$newlang = GETPOST('lang_id', 'aZ09');
}
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
$newlang = $object->thirdparty->default_lang;
}
if (!empty($newlang)) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
@ -360,11 +377,9 @@ if ($action == 'confirm_close' && $confirm == 'yes' && $permissiontoadd)
}
// Action setdraft object
if ($action == 'confirm_setdraft' && $confirm == 'yes' && $permissiontoadd)
{
if ($action == 'confirm_setdraft' && $confirm == 'yes' && $permissiontoadd) {
$result = $object->setDraft($user);
if ($result >= 0)
{
if ($result >= 0) {
// Nothing else done
} else {
setEventMessages($object->error, $object->errors, 'errors');
@ -372,18 +387,20 @@ if ($action == 'confirm_setdraft' && $confirm == 'yes' && $permissiontoadd)
}
// Action reopen object
if ($action == 'confirm_reopen' && $confirm == 'yes' && $permissiontoadd)
{
if ($action == 'confirm_reopen' && $confirm == 'yes' && $permissiontoadd) {
$result = $object->reopen($user);
if ($result >= 0)
{
if ($result >= 0) {
// Define output language
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
if (method_exists($object, 'generateDocument')) {
$outputlangs = $langs;
$newlang = '';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09');
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
$newlang = GETPOST('lang_id', 'aZ09');
}
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
$newlang = $object->thirdparty->default_lang;
}
if (!empty($newlang)) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
@ -400,21 +417,21 @@ if ($action == 'confirm_reopen' && $confirm == 'yes' && $permissiontoadd)
}
// Action clone object
if ($action == 'confirm_clone' && $confirm == 'yes' && !empty($permissiontoadd))
{
if (1 == 0 && !GETPOST('clone_content') && !GETPOST('clone_receivers'))
{
if ($action == 'confirm_clone' && $confirm == 'yes' && !empty($permissiontoadd)) {
if (1 == 0 && !GETPOST('clone_content') && !GETPOST('clone_receivers')) {
setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors');
} else {
$objectutil = dol_clone($object, 1); // To avoid to denaturate loaded object when setting some properties for clone or if createFromClone modifies the object. We use native clone to keep this->db valid.
//$objectutil->date = dol_mktime(12, 0, 0, GETPOST('newdatemonth', 'int'), GETPOST('newdateday', 'int'), GETPOST('newdateyear', 'int'));
// ...
$result = $objectutil->createFromClone($user, (($object->id > 0) ? $object->id : $id));
if (is_object($result) || $result > 0)
{
if (is_object($result) || $result > 0) {
$newid = 0;
if (is_object($result)) $newid = $result->id;
else $newid = $result;
if (is_object($result)) {
$newid = $result->id;
} else {
$newid = $result;
}
header("Location: ".$_SERVER['PHP_SELF'].'?id='.$newid); // Open record of new object
exit;
} else {

View File

@ -29,27 +29,26 @@
// $upload_dir must be defined (example $conf->projet->dir_output . "/";)
// $hidedetails, $hidedesc, $hideref and $moreparams may have been set or not.
if (!empty($permissioncreate) && empty($permissiontoadd)) $permissiontoadd = $permissioncreate; // For backward compatibility
if (!empty($permissioncreate) && empty($permissiontoadd)) {
$permissiontoadd = $permissioncreate; // For backward compatibility
}
// Build doc
if ($action == 'builddoc' && $permissiontoadd)
{
if (is_numeric(GETPOST('model', 'alpha')))
{
if ($action == 'builddoc' && $permissiontoadd) {
if (is_numeric(GETPOST('model', 'alpha'))) {
$error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Model"));
} else {
// Reload to get all modified line records and be ready for hooks
// Reload to get all modified line records and be ready for hooks
$ret = $object->fetch($id);
$ret = $object->fetch_thirdparty();
/*if (empty($object->id) || ! $object->id > 0)
{
dol_print_error('Object must have been loaded by a fetch');
exit;
}*/
{
dol_print_error('Object must have been loaded by a fetch');
exit;
}*/
// Save last template used to generate document
if (GETPOST('model', 'alpha'))
{
if (GETPOST('model', 'alpha')) {
$object->setDocModel($user, GETPOST('model', 'alpha'));
}
@ -67,29 +66,40 @@ if ($action == 'builddoc' && $permissiontoadd)
$outputlangs = $langs;
$newlang = '';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09');
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($object->thirdparty->default_lang)) $newlang = $object->thirdparty->default_lang; // for proposal, order, invoice, ...
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($object->default_lang)) $newlang = $object->default_lang; // for thirdparty
if (!empty($newlang))
{
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
$newlang = GETPOST('lang_id', 'aZ09');
}
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($object->thirdparty->default_lang)) {
$newlang = $object->thirdparty->default_lang; // for proposal, order, invoice, ...
}
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && isset($object->default_lang)) {
$newlang = $object->default_lang; // for thirdparty
}
if (!empty($newlang)) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
}
// To be sure vars is defined
if (empty($hidedetails)) $hidedetails = 0;
if (empty($hidedesc)) $hidedesc = 0;
if (empty($hideref)) $hideref = 0;
if (empty($moreparams)) $moreparams = null;
if (empty($hidedetails)) {
$hidedetails = 0;
}
if (empty($hidedesc)) {
$hidedesc = 0;
}
if (empty($hideref)) {
$hideref = 0;
}
if (empty($moreparams)) {
$moreparams = null;
}
$result = $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
if ($result <= 0)
{
if ($result <= 0) {
setEventMessages($object->error, $object->errors, 'errors');
$action = '';
} else {
if (empty($donotredirect)) // This is set when include is done by bulk action "Bill Orders"
{
if (empty($donotredirect)) { // This is set when include is done by bulk action "Bill Orders"
setEventMessages($langs->trans("FileGenerated"), null);
$urltoredirect = $_SERVER['REQUEST_URI'];
@ -104,13 +114,11 @@ if ($action == 'builddoc' && $permissiontoadd)
}
// Delete file in doc form
if ($action == 'remove_file' && $permissiontoadd)
{
if ($action == 'remove_file' && $permissiontoadd) {
if (!empty($upload_dir)) {
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
if (empty($object->id) || !$object->id > 0)
{
if (empty($object->id) || !$object->id > 0) {
// Reload to get all modified line records and be ready for hooks
$ret = $object->fetch($id);
$ret = $object->fetch_thirdparty();
@ -120,8 +128,11 @@ if ($action == 'remove_file' && $permissiontoadd)
$filetodelete = GETPOST('file', 'alpha');
$file = $upload_dir.'/'.$filetodelete;
$ret = dol_delete_file($file, 0, 0, 0, $object);
if ($ret) setEventMessages($langs->trans("FileWasRemoved", $filetodelete), null, 'mesgs');
else setEventMessages($langs->trans("ErrorFailToDeleteFile", $filetodelete), null, 'errors');
if ($ret) {
setEventMessages($langs->trans("FileWasRemoved", $filetodelete), null, 'mesgs');
} else {
setEventMessages($langs->trans("ErrorFailToDeleteFile", $filetodelete), null, 'errors');
}
// Make a redirect to avoid to keep the remove_file into the url that create side effects
$urltoredirect = $_SERVER['REQUEST_URI'];

View File

@ -28,14 +28,16 @@
// $object must be defined (object is loaded in this file with fetch)
// Save selection
if (GETPOST('formfilteraction', 'alphanohtml') == 'listafterchangingselectedfields')
{
if (GETPOST('formfilteraction', 'alphanohtml') == 'listafterchangingselectedfields') {
$tabparam = array();
$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
if (GETPOST("selectedfields")) $tabparam["MAIN_SELECTEDFIELDS_".$varpage] = GETPOST("selectedfields");
else $tabparam["MAIN_SELECTEDFIELDS_".$varpage] = '';
if (GETPOST("selectedfields")) {
$tabparam["MAIN_SELECTEDFIELDS_".$varpage] = GETPOST("selectedfields");
} else {
$tabparam["MAIN_SELECTEDFIELDS_".$varpage] = '';
}
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';

View File

@ -33,19 +33,16 @@ $comment = new Comment($db);
* Actions
*/
if ($action == 'addcomment')
{
if ($action == 'addcomment') {
$description = GETPOST('comment_description', 'restricthtml');
if (!empty($description))
{
if (!empty($description)) {
$comment->description = $description;
$comment->datec = time();
$comment->fk_element = GETPOST('id', 'int');
$comment->element_type = GETPOST('comment_element_type', 'alpha');
$comment->fk_user_author = $user->id;
$comment->entity = $conf->entity;
if ($comment->create($user) > 0)
{
if ($comment->create($user) > 0) {
setEventMessages($langs->trans("CommentAdded"), null, 'mesgs');
header('Location: '.$varpage.'?id='.$id.($withproject ? '&withproject=1' : ''));
exit;
@ -55,13 +52,10 @@ if ($action == 'addcomment')
}
}
}
if ($action === 'updatecomment')
{
if ($comment->fetch($idcomment) >= 0)
{
if ($action === 'updatecomment') {
if ($comment->fetch($idcomment) >= 0) {
$comment->description = GETPOST('comment_description', 'restricthtml');
if ($comment->update($user) > 0)
{
if ($comment->update($user) > 0) {
setEventMessages($langs->trans("CommentAdded"), null, 'mesgs');
header('Location: '.$varpage.'?id='.$id.($withproject ? '&withproject=1#comment' : ''));
exit;
@ -71,12 +65,9 @@ if ($action === 'updatecomment')
}
}
}
if ($action == 'deletecomment')
{
if ($comment->fetch($idcomment) >= 0)
{
if ($comment->delete($user) > 0)
{
if ($action == 'deletecomment') {
if ($comment->fetch($idcomment) >= 0) {
if ($comment->delete($user) > 0) {
setEventMessages($langs->trans("CommentDeleted"), null, 'mesgs');
header('Location: '.$varpage.'?id='.$id.($withproject ? '&withproject=1' : ''));
exit;

View File

@ -30,16 +30,16 @@ $dellinkid = GETPOST('dellinkid', 'int');
$addlinkid = GETPOST('idtolinkto', 'int');
// Link invoice to order
if ($action == 'addlink' && !empty($permissiondellink) && !GETPOST('cancel', 'alpha') && $id > 0 && $addlinkid > 0)
{
if ($action == 'addlink' && !empty($permissiondellink) && !GETPOST('cancel', 'alpha') && $id > 0 && $addlinkid > 0) {
$object->fetch($id);
$object->fetch_thirdparty();
$result = $object->add_object_linked(GETPOST('addlink', 'alpha'), $addlinkid);
}
// Delete link
if ($action == 'dellink' && !empty($permissiondellink) && !GETPOST('cancel', 'alpha') && $dellinkid > 0)
{
if ($action == 'dellink' && !empty($permissiondellink) && !GETPOST('cancel', 'alpha') && $dellinkid > 0) {
$result = $object->deleteObjectLinked(0, '', 0, '', $dellinkid);
if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
}
}

View File

@ -31,91 +31,85 @@ $extrasize = GETPOST('size', 'intcomma');
$type = GETPOST('type', 'alpha');
$param = GETPOST('param', 'alpha');
if ($type == 'double' && strpos($extrasize, ',') === false) $extrasize = '24,8';
if ($type == 'date') $extrasize = '';
if ($type == 'datetime') $extrasize = '';
if ($type == 'select') $extrasize = '';
if ($type == 'double' && strpos($extrasize, ',') === false) {
$extrasize = '24,8';
}
if ($type == 'date') {
$extrasize = '';
}
if ($type == 'datetime') {
$extrasize = '';
}
if ($type == 'select') {
$extrasize = '';
}
// Add attribute
if ($action == 'add')
{
if (GETPOST("button") != $langs->trans("Cancel"))
{
if ($action == 'add') {
if (GETPOST("button") != $langs->trans("Cancel")) {
// Check values
if (!$type)
{
if (!$type) {
$error++;
$langs->load("errors");
$mesg[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type"));
$action = 'create';
}
if ($type == 'varchar' && $extrasize <= 0)
{
if ($type == 'varchar' && $extrasize <= 0) {
$error++;
$langs->load("errors");
$mesg[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Size"));
$action = 'edit';
}
if ($type == 'varchar' && $extrasize > $maxsizestring)
{
if ($type == 'varchar' && $extrasize > $maxsizestring) {
$error++;
$langs->load("errors");
$mesg[] = $langs->trans("ErrorSizeTooLongForVarcharType", $maxsizestring);
$action = 'create';
}
if ($type == 'int' && $extrasize > $maxsizeint)
{
if ($type == 'int' && $extrasize > $maxsizeint) {
$error++;
$langs->load("errors");
$mesg[] = $langs->trans("ErrorSizeTooLongForIntType", $maxsizeint);
$action = 'create';
}
if ($type == 'select' && !$param)
{
if ($type == 'select' && !$param) {
$error++;
$langs->load("errors");
$mesg[] = $langs->trans("ErrorNoValueForSelectType");
$action = 'create';
}
if ($type == 'sellist' && !$param)
{
if ($type == 'sellist' && !$param) {
$error++;
$langs->load("errors");
$mesg[] = $langs->trans("ErrorNoValueForSelectListType");
$action = 'create';
}
if ($type == 'checkbox' && !$param)
{
if ($type == 'checkbox' && !$param) {
$error++;
$langs->load("errors");
$mesg[] = $langs->trans("ErrorNoValueForCheckBoxType");
$action = 'create';
}
if ($type == 'link' && !$param)
{
if ($type == 'link' && !$param) {
$error++;
$langs->load("errors");
$mesg[] = $langs->trans("ErrorNoValueForLinkType");
$action = 'create';
}
if ($type == 'radio' && !$param)
{
if ($type == 'radio' && !$param) {
$error++;
$langs->load("errors");
$mesg[] = $langs->trans("ErrorNoValueForRadioType");
$action = 'create';
}
if ((($type == 'radio') || ($type == 'checkbox')) && $param)
{
if ((($type == 'radio') || ($type == 'checkbox')) && $param) {
// Construct array for parameter (value of select list)
$parameters = $param;
$parameters_array = explode("\r\n", $parameters);
foreach ($parameters_array as $param_ligne)
{
foreach ($parameters_array as $param_ligne) {
if (!empty($param_ligne)) {
if (preg_match_all('/,/', $param_ligne, $matches))
{
if (preg_match_all('/,/', $param_ligne, $matches)) {
if (count($matches[0]) > 1) {
$error++;
$langs->load("errors");
@ -160,14 +154,12 @@ if ($action == 'add')
$parameters_array = explode("\r\n", $parameters);
//In sellist we have only one line and it can have come to do SQL expression
if ($type == 'sellist' || $type == 'chkbxlst') {
foreach ($parameters_array as $param_ligne)
{
foreach ($parameters_array as $param_ligne) {
$params['options'] = array($parameters=>null);
}
} else {
// Else it's separated key/value and coma list
foreach ($parameters_array as $param_ligne)
{
foreach ($parameters_array as $param_ligne) {
list($key, $value) = explode(',', $param_ligne);
$params['options'][$key] = $value;
}
@ -175,7 +167,9 @@ if ($action == 'add')
// Visibility: -1=not visible by default in list, 1=visible, 0=hidden
$visibility = GETPOST('list', 'alpha');
if ($type == 'separate') $visibility = 3;
if ($type == 'separate') {
$visibility = 3;
}
$result = $extrafields->addExtraField(
GETPOST('attrname', 'aZ09'),
@ -199,8 +193,7 @@ if ($action == 'add')
(GETPOST('totalizable', 'alpha') ? 1 : 0),
GETPOST('printable', 'alpha')
);
if ($result > 0)
{
if ($result > 0) {
setEventMessages($langs->trans('SetupSaved'), null, 'mesgs');
header("Location: ".$_SERVER["PHP_SELF"]);
exit;
@ -223,77 +216,64 @@ if ($action == 'add')
}
// Rename field
if ($action == 'update')
{
if (GETPOST("button") != $langs->trans("Cancel"))
{
if ($action == 'update') {
if (GETPOST("button") != $langs->trans("Cancel")) {
// Check values
if (!$type)
{
if (!$type) {
$error++;
$langs->load("errors");
$mesg[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type"));
$action = 'edit';
}
if ($type == 'varchar' && $extrasize <= 0)
{
if ($type == 'varchar' && $extrasize <= 0) {
$error++;
$langs->load("errors");
$mesg[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Size"));
$action = 'edit';
}
if ($type == 'varchar' && $extrasize > $maxsizestring)
{
if ($type == 'varchar' && $extrasize > $maxsizestring) {
$error++;
$langs->load("errors");
$mesg[] = $langs->trans("ErrorSizeTooLongForVarcharType", $maxsizestring);
$action = 'edit';
}
if ($type == 'int' && $extrasize > $maxsizeint)
{
if ($type == 'int' && $extrasize > $maxsizeint) {
$error++;
$langs->load("errors");
$mesg[] = $langs->trans("ErrorSizeTooLongForIntType", $maxsizeint);
$action = 'edit';
}
if ($type == 'select' && !$param)
{
if ($type == 'select' && !$param) {
$error++;
$langs->load("errors");
$mesg[] = $langs->trans("ErrorNoValueForSelectType");
$action = 'edit';
}
if ($type == 'sellist' && !$param)
{
if ($type == 'sellist' && !$param) {
$error++;
$langs->load("errors");
$mesg[] = $langs->trans("ErrorNoValueForSelectListType");
$action = 'edit';
}
if ($type == 'checkbox' && !$param)
{
if ($type == 'checkbox' && !$param) {
$error++;
$langs->load("errors");
$mesg[] = $langs->trans("ErrorNoValueForCheckBoxType");
$action = 'edit';
}
if ($type == 'radio' && !$param)
{
if ($type == 'radio' && !$param) {
$error++;
$langs->load("errors");
$mesg[] = $langs->trans("ErrorNoValueForRadioType");
$action = 'edit';
}
if ((($type == 'radio') || ($type == 'checkbox')) && $param)
{
if ((($type == 'radio') || ($type == 'checkbox')) && $param) {
// Construct array for parameter (value of select list)
$parameters = $param;
$parameters_array = explode("\r\n", $parameters);
foreach ($parameters_array as $param_ligne)
{
foreach ($parameters_array as $param_ligne) {
if (!empty($param_ligne)) {
if (preg_match_all('/,/', $param_ligne, $matches))
{
if (preg_match_all('/,/', $param_ligne, $matches)) {
if (count($matches[0]) > 1) {
$error++;
$langs->load("errors");
@ -329,24 +309,20 @@ if ($action == 'update')
}
}
if (!$error)
{
if (GETPOSTISSET("attrname") && preg_match("/^\w[a-zA-Z0-9-_]*$/", GETPOST('attrname', 'aZ09')) && !is_numeric(GETPOST('attrname', 'aZ09')))
{
if (!$error) {
if (GETPOSTISSET("attrname") && preg_match("/^\w[a-zA-Z0-9-_]*$/", GETPOST('attrname', 'aZ09')) && !is_numeric(GETPOST('attrname', 'aZ09'))) {
$pos = GETPOST('pos', 'int');
// Construct array for parameter (value of select list)
$parameters = $param;
$parameters_array = explode("\r\n", $parameters);
//In sellist we have only one line and it can have come to do SQL expression
if ($type == 'sellist' || $type == 'chkbxlst') {
foreach ($parameters_array as $param_ligne)
{
foreach ($parameters_array as $param_ligne) {
$params['options'] = array($parameters=>null);
}
} else {
//Esle it's separated key/value and coma list
foreach ($parameters_array as $param_ligne)
{
foreach ($parameters_array as $param_ligne) {
list($key, $value) = explode(',', $param_ligne);
$params['options'][$key] = $value;
}
@ -354,7 +330,9 @@ if ($action == 'update')
// Visibility: -1=not visible by default in list, 1=visible, 0=hidden
$visibility = GETPOST('list', 'alpha');
if ($type == 'separate') $visibility = 3;
if ($type == 'separate') {
$visibility = 3;
}
// Example: is_object($object) ? ($object->id < 10 ? round($object->id / 2, 2) : (2 * $user->id) * (int) substr($mysoc->zip, 1, 2)) : 'objnotdefined'
$computedvalue = GETPOST('computed_value', 'nohtml');
@ -409,7 +387,9 @@ if ($action == 'delete') {
if ($result >= 0) {
header("Location: ".$_SERVER["PHP_SELF"]);
exit;
} else $mesg = $extrafields->error;
} else {
$mesg = $extrafields->error;
}
} else {
$error++;
$langs->load("errors");

View File

@ -28,20 +28,15 @@
// $cancel must be defined
// $id or $ref must be defined (object is loaded in this file with fetch)
if (($id > 0 || (!empty($ref) && !in_array($action, array('create', 'createtask', 'add')))) && (empty($cancel) || $id > 0))
{
if (($id > 0 && is_numeric($id)) || !empty($ref)) // To discard case when id is list of ids like '1,2,3...'
{
if (($id > 0 || (!empty($ref) && !in_array($action, array('create', 'createtask', 'add')))) && (empty($cancel) || $id > 0)) {
if (($id > 0 && is_numeric($id)) || !empty($ref)) { // To discard case when id is list of ids like '1,2,3...'
$ret = $object->fetch($id, $ref);
if ($ret > 0)
{
if ($ret > 0) {
$object->fetch_thirdparty();
$id = $object->id;
} else {
if (empty($object->error) && !count($object->errors))
{
if ($ret < 0) // if $ret == 0, it means not found.
{
if (empty($object->error) && !count($object->errors)) {
if ($ret < 0) { // if $ret == 0, it means not found.
setEventMessages('Fetch on object (type '.get_class($object).') return an error without filling $object->error nor $object->errors', null, 'errors');
}
} else {

View File

@ -28,15 +28,18 @@
// $langs must be defined
// $hidedetails, $hidedesc, $hideref must de defined
if ($action == 'up' && $permissiontoedit)
{
if ($action == 'up' && $permissiontoedit) {
$object->line_up(GETPOST('rowid'));
// Define output language
$outputlangs = $langs;
$newlang = '';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09');
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
$newlang = GETPOST('lang_id', 'aZ09');
}
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
$newlang = $object->thirdparty->default_lang;
}
if (!empty($newlang)) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
@ -50,15 +53,18 @@ if ($action == 'up' && $permissiontoedit)
exit();
}
if ($action == 'down' && $permissiontoedit)
{
if ($action == 'down' && $permissiontoedit) {
$object->line_down(GETPOST('rowid'));
// Define output language
$outputlangs = $langs;
$newlang = '';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09');
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
$newlang = GETPOST('lang_id', 'aZ09');
}
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
$newlang = $object->thirdparty->default_lang;
}
if (!empty($newlang)) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);

View File

@ -27,17 +27,16 @@
// Submit file/link
if (GETPOST('sendit', 'alpha') && !empty($conf->global->MAIN_UPLOAD_DOC))
{
if (!empty($_FILES))
{
if (is_array($_FILES['userfile']['tmp_name'])) $userfiles = $_FILES['userfile']['tmp_name'];
else $userfiles = array($_FILES['userfile']['tmp_name']);
if (GETPOST('sendit', 'alpha') && !empty($conf->global->MAIN_UPLOAD_DOC)) {
if (!empty($_FILES)) {
if (is_array($_FILES['userfile']['tmp_name'])) {
$userfiles = $_FILES['userfile']['tmp_name'];
} else {
$userfiles = array($_FILES['userfile']['tmp_name']);
}
foreach ($userfiles as $key => $userfile)
{
if (empty($_FILES['userfile']['tmp_name'][$key]))
{
foreach ($userfiles as $key => $userfile) {
if (empty($_FILES['userfile']['tmp_name'][$key])) {
$error++;
if ($_FILES['userfile']['error'][$key] == 1 || $_FILES['userfile']['error'][$key] == 2) {
setEventMessages($langs->trans('ErrorFileSizeTooLarge'), null, 'errors');
@ -47,27 +46,24 @@ if (GETPOST('sendit', 'alpha') && !empty($conf->global->MAIN_UPLOAD_DOC))
}
}
if (!$error)
{
if (!$error) {
// Define if we have to generate thumbs or not
$generatethumbs = 1;
if (GETPOST('section_dir', 'alpha')) $generatethumbs = 0;
if (GETPOST('section_dir', 'alpha')) {
$generatethumbs = 0;
}
$allowoverwrite = (GETPOST('overwritefile', 'int') ? 1 : 0);
if (!empty($upload_dirold) && !empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
{
if (!empty($upload_dirold) && !empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) {
$result = dol_add_file_process($upload_dirold, $allowoverwrite, 1, 'userfile', GETPOST('savingdocmask', 'alpha'), null, '', $generatethumbs, $object);
} elseif (!empty($upload_dir))
{
} elseif (!empty($upload_dir)) {
$result = dol_add_file_process($upload_dir, $allowoverwrite, 1, 'userfile', GETPOST('savingdocmask', 'alpha'), null, '', $generatethumbs, $object);
}
}
}
} elseif (GETPOST('linkit', 'restricthtml') && !empty($conf->global->MAIN_UPLOAD_DOC))
{
} elseif (GETPOST('linkit', 'restricthtml') && !empty($conf->global->MAIN_UPLOAD_DOC)) {
$link = GETPOST('link', 'alpha');
if ($link)
{
if ($link) {
if (substr($link, 0, 7) != 'http://' && substr($link, 0, 8) != 'https://' && substr($link, 0, 7) != 'file://') {
$link = 'http://'.$link;
}
@ -77,17 +73,18 @@ if (GETPOST('sendit', 'alpha') && !empty($conf->global->MAIN_UPLOAD_DOC))
// Delete file/link
if ($action == 'confirm_deletefile' && $confirm == 'yes')
{
if ($action == 'confirm_deletefile' && $confirm == 'yes') {
$urlfile = GETPOST('urlfile', 'alpha', 0, null, null, 1); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
if (GETPOST('section', 'alpha')) {
// For a delete from the ECM module, upload_dir is ECM root dir and urlfile contains relative path from upload_dir
$file = $upload_dir.(preg_match('/\/$/', $upload_dir) ? '' : '/').$urlfile;
} else // For a delete from the file manager into another module, or from documents pages, upload_dir contains already path to file from module dir, so we clean path into urlfile.
{
$urlfile = basename($urlfile);
$file = $upload_dir.(preg_match('/\/$/', $upload_dir) ? '' : '/').$urlfile;
if (!empty($upload_dirold)) $fileold = $upload_dirold."/".$urlfile;
$urlfile = basename($urlfile);
$file = $upload_dir.(preg_match('/\/$/', $upload_dir) ? '' : '/').$urlfile;
if (!empty($upload_dirold)) {
$fileold = $upload_dirold."/".$urlfile;
}
}
$linkid = GETPOST('linkid', 'int');
@ -97,21 +94,20 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes')
$dirthumb = $dir.'/thumbs/'; // Chemin du dossier contenant la vignette (if file is an image)
$ret = dol_delete_file($file, 0, 0, 0, (is_object($object) ? $object : null));
if (!empty($fileold)) dol_delete_file($fileold, 0, 0, 0, (is_object($object) ? $object : null)); // Delete file using old path
if (!empty($fileold)) {
dol_delete_file($fileold, 0, 0, 0, (is_object($object) ? $object : null)); // Delete file using old path
}
// If it exists, remove thumb.
$regs = array();
if (preg_match('/(\.jpg|\.jpeg|\.bmp|\.gif|\.png|\.tiff)$/i', $file, $regs))
{
if (preg_match('/(\.jpg|\.jpeg|\.bmp|\.gif|\.png|\.tiff)$/i', $file, $regs)) {
$photo_vignette = basename(preg_replace('/'.$regs[0].'/i', '', $file).'_small'.$regs[0]);
if (file_exists(dol_osencode($dirthumb.$photo_vignette)))
{
if (file_exists(dol_osencode($dirthumb.$photo_vignette))) {
dol_delete_file($dirthumb.$photo_vignette);
}
$photo_vignette = basename(preg_replace('/'.$regs[0].'/i', '', $file).'_mini'.$regs[0]);
if (file_exists(dol_osencode($dirthumb.$photo_vignette)))
{
if (file_exists(dol_osencode($dirthumb.$photo_vignette))) {
dol_delete_file($dirthumb.$photo_vignette);
}
}
@ -149,33 +145,27 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes')
exit;
}
}
} elseif ($action == 'confirm_updateline' && GETPOST('save', 'alpha') && GETPOST('link', 'alpha'))
{
} elseif ($action == 'confirm_updateline' && GETPOST('save', 'alpha') && GETPOST('link', 'alpha')) {
require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
$langs->load('link');
$link = new Link($db);
$f = $link->fetch(GETPOST('linkid', 'int'));
if ($f)
{
if ($f) {
$link->url = GETPOST('link', 'alpha');
if (substr($link->url, 0, 7) != 'http://' && substr($link->url, 0, 8) != 'https://' && substr($link->url, 0, 7) != 'file://')
{
if (substr($link->url, 0, 7) != 'http://' && substr($link->url, 0, 8) != 'https://' && substr($link->url, 0, 7) != 'file://') {
$link->url = 'http://'.$link->url;
}
$link->label = GETPOST('label', 'alphanohtml');
$res = $link->update($user);
if (!$res)
{
if (!$res) {
setEventMessages($langs->trans("ErrorFailedToUpdateLink", $link->label), null, 'mesgs');
}
} else {
//error fetching
}
} elseif ($action == 'renamefile' && GETPOST('renamefilesave', 'alpha'))
{
} elseif ($action == 'renamefile' && GETPOST('renamefilesave', 'alpha')) {
// For documents pages, upload_dir contains already path to file from module dir, so we clean path into urlfile.
if (!empty($upload_dir))
{
if (!empty($upload_dir)) {
$filenamefrom = dol_sanitizeFileName(GETPOST('renamefilefrom', 'alpha'), '_', 0); // Do not remove accents
$filenameto = dol_sanitizeFileName(GETPOST('renamefileto', 'alpha'), '_', 0); // Do not remove accents
@ -183,24 +173,23 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes')
// this function is also applied when we upload and when we make try to download file (by the GETPOST(filename, 'alphanohtml') call).
$filenameto = dol_string_nohtmltag($filenameto);
if ($filenamefrom != $filenameto)
{
if ($filenamefrom != $filenameto) {
// Security:
// Disallow file with some extensions. We rename them.
// Because if we put the documents directory into a directory inside web root (very bad), this allows to execute on demand arbitrary code.
if (isAFileWithExecutableContent($filenameto) && empty($conf->global->MAIN_DOCUMENT_IS_OUTSIDE_WEBROOT_SO_NOEXE_NOT_REQUIRED))
{
if (isAFileWithExecutableContent($filenameto) && empty($conf->global->MAIN_DOCUMENT_IS_OUTSIDE_WEBROOT_SO_NOEXE_NOT_REQUIRED)) {
// $upload_dir ends with a slash, so be must be sure the medias dir to compare to ends with slash too.
$publicmediasdirwithslash = $conf->medias->multidir_output[$conf->entity];
if (!preg_match('/\/$/', $publicmediasdirwithslash)) $publicmediasdirwithslash .= '/';
if (!preg_match('/\/$/', $publicmediasdirwithslash)) {
$publicmediasdirwithslash .= '/';
}
if (strpos($upload_dir, $publicmediasdirwithslash) !== 0) { // We never add .noexe on files into media directory
$filenameto .= '.noexe';
}
}
if ($filenamefrom && $filenameto)
{
if ($filenamefrom && $filenameto) {
$srcpath = $upload_dir.'/'.$filenamefrom;
$destpath = $upload_dir.'/'.$filenameto;
@ -208,26 +197,24 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes')
$parameters = array('filenamefrom' => $filenamefrom, 'filenameto' => $filenameto, 'upload_dir' => $upload_dir);
$reshook = $hookmanager->executeHooks('renameUploadedFile', $parameters, $object);
if (empty($reshook))
{
if (empty($reshook)) {
if (preg_match('/^\./', $filenameto)) {
$langs->load("errors"); // lang must be loaded because we can't rely on loading during output, we need var substitution to be done now.
setEventMessages($langs->trans("ErrorFilenameCantStartWithDot", $filenameto), null, 'errors');
} elseif (!file_exists($destpath)) {
$result = dol_move($srcpath, $destpath);
if ($result)
{
if ($result) {
// Define if we have to generate thumbs or not
$generatethumbs = 1;
// When we rename a file from the file manager in ecm, we must not regenerate thumbs (not a problem, we do pass here)
// When we rename a file from the website module, we must not regenerate thumbs (module = medias in such a case)
// but when we rename from a tab "Documents", we must regenerate thumbs
if (GETPOST('modulepart') == 'medias') $generatethumbs = 0;
if (GETPOST('modulepart') == 'medias') {
$generatethumbs = 0;
}
if ($generatethumbs)
{
if ($object->id)
{
if ($generatethumbs) {
if ($object->id) {
$object->addThumbs($destpath);
}
@ -250,19 +237,15 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes')
}
// Update properties in ECM table
if (GETPOST('ecmfileid', 'int') > 0)
{
if (GETPOST('ecmfileid', 'int') > 0) {
$shareenabled = GETPOST('shareenabled', 'alpha');
include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
$ecmfile = new EcmFiles($db);
$result = $ecmfile->fetch(GETPOST('ecmfileid', 'int'));
if ($result > 0)
{
if ($shareenabled)
{
if (empty($ecmfile->share))
{
if ($result > 0) {
if ($shareenabled) {
if (empty($ecmfile->share)) {
require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
$ecmfile->share = getRandomPassword(true);
}
@ -270,8 +253,7 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes')
$ecmfile->share = '';
}
$result = $ecmfile->update($user);
if ($result < 0)
{
if ($result < 0) {
setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings');
}
}

File diff suppressed because it is too large Load Diff

View File

@ -55,16 +55,15 @@ if ($action == 'print_file' && $user->rights->printing->read) {
$subdir = '';
$module = GETPOST('printer', 'alpha');
switch ($module)
{
case 'livraison' :
switch ($module) {
case 'livraison':
$subdir = 'receipt';
$module = 'expedition';
break;
case 'expedition' :
case 'expedition':
$subdir = 'sending';
break;
case 'commande_fournisseur' :
case 'commande_fournisseur':
$module = 'fournisseur';
$subdir = 'commande';
break;
@ -75,20 +74,20 @@ if ($action == 'print_file' && $user->rights->printing->read) {
//print '<pre>'.print_r($printer->errors, true).'</pre>';
setEventMessages($printer->error, $printer->errors, 'errors');
}
if ($ret == 0)
{
if ($ret == 0) {
//print '<pre>'.print_r($printer->errors, true).'</pre>';
setEventMessages($printer->error, $printer->errors);
setEventMessages($langs->transnoentitiesnoconv("FileWasSentToPrinter", basename(GETPOST('file', 'alpha'))).' '.$langs->transnoentitiesnoconv("ViaModule").' '.$printer->name, null);
}
} catch (Exception $e)
{
} catch (Exception $e) {
$ret = 1;
setEventMessages($e->getMessage(), null, 'errors');
}
}
}
if ($printerfound == 0) setEventMessages($langs->trans("NoActivePrintingModuleFound", $langs->transnoentities("Module64000Name")), null, 'warnings');
if ($printerfound == 0) {
setEventMessages($langs->trans("NoActivePrintingModuleFound", $langs->transnoentities("Module64000Name")), null, 'warnings');
}
} else {
setEventMessages($langs->trans("NoModuleFound"), null, 'warnings');
}

View File

@ -27,66 +27,60 @@
// $nomessageinupdate can be set to 1
// $nomessageinsetmoduleoptions can be set to 1
if ($action == 'update' && is_array($arrayofparameters))
{
if ($action == 'update' && is_array($arrayofparameters)) {
$db->begin();
foreach ($arrayofparameters as $key => $val)
{
foreach ($arrayofparameters as $key => $val) {
// Modify constant only if key was posted (avoid resetting key to the null value)
if (GETPOSTISSET($key))
{
if (GETPOSTISSET($key)) {
$result = dolibarr_set_const($db, $key, GETPOST($key, 'alpha'), 'chaine', 0, '', $conf->entity);
if ($result < 0)
{
if ($result < 0) {
$error++;
break;
}
}
}
if (!$error)
{
if (!$error) {
$db->commit();
if (empty($nomessageinupdate)) setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
if (empty($nomessageinupdate)) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
} else {
$db->rollback();
if (empty($nomessageinupdate)) setEventMessages($langs->trans("SetupNotSaved"), null, 'errors');
if (empty($nomessageinupdate)) {
setEventMessages($langs->trans("SetupNotSaved"), null, 'errors');
}
}
}
// Define constants for submodules that contains parameters (forms with param1, param2, ... and value1, value2, ...)
if ($action == 'setModuleOptions')
{
if ($action == 'setModuleOptions') {
$db->begin();
// Process common param fields
if (is_array($_POST))
{
foreach ($_POST as $key => $val)
{
if (is_array($_POST)) {
foreach ($_POST as $key => $val) {
$reg = array();
if (preg_match('/^param(\d*)$/', $key, $reg)) // Works for POST['param'], POST['param1'], POST['param2'], ...
{
if (preg_match('/^param(\d*)$/', $key, $reg)) { // Works for POST['param'], POST['param1'], POST['param2'], ...
$param = GETPOST("param".$reg[1], 'alpha');
$value = GETPOST("value".$reg[1], 'alpha');
if ($param)
{
if ($param) {
$res = dolibarr_set_const($db, $param, $value, 'chaine', 0, '', $conf->entity);
if (!($res > 0)) $error++;
if (!($res > 0)) {
$error++;
}
}
}
}
}
// Process upload fields
if (GETPOST('upload', 'alpha') && GETPOST('keyforuploaddir', 'aZ09'))
{
if (GETPOST('upload', 'alpha') && GETPOST('keyforuploaddir', 'aZ09')) {
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
$keyforuploaddir = GETPOST('keyforuploaddir', 'aZ09');
$listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->$keyforuploaddir)));
foreach ($listofdir as $key=>$tmpdir)
{
foreach ($listofdir as $key => $tmpdir) {
$tmpdir = trim($tmpdir);
$tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir);
if (!$tmpdir) {
@ -96,24 +90,27 @@ if ($action == 'setModuleOptions')
if (empty($nomessageinsetmoduleoptions)) {
setEventMessages($langs->trans("ErrorDirNotFound", $tmpdir), null, 'warnings');
}
}
else {
} else {
$upload_dir = $tmpdir;
}
}
if ($upload_dir)
{
if ($upload_dir) {
$result = dol_add_file_process($upload_dir, 1, 1, 'uploadfile', '');
if ($result <= 0) $error++;
if ($result <= 0) {
$error++;
}
}
}
if (!$error)
{
if (!$error) {
$db->commit();
if (empty($nomessageinsetmoduleoptions)) setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
if (empty($nomessageinsetmoduleoptions)) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
} else {
$db->rollback();
if (empty($nomessageinsetmoduleoptions)) setEventMessages($langs->trans("SetupNotSaved"), null, 'errors');
if (empty($nomessageinsetmoduleoptions)) {
setEventMessages($langs->trans("SetupNotSaved"), null, 'errors');
}
}
}

View File

@ -28,23 +28,29 @@
// $id must be defined (object is loaded in this file with fetch)
// Set public note
if ($action == 'setnote_public' && !empty($permissionnote) && !GETPOST('cancel', 'alpha'))
{
if (empty($action) || !is_object($object) || empty($id)) dol_print_error('', 'Include of actions_setnotes.inc.php was done but required variable was not set before');
if (empty($object->id)) $object->fetch($id); // Fetch may not be already done
if ($action == 'setnote_public' && !empty($permissionnote) && !GETPOST('cancel', 'alpha')) {
if (empty($action) || !is_object($object) || empty($id)) {
dol_print_error('', 'Include of actions_setnotes.inc.php was done but required variable was not set before');
}
if (empty($object->id)) {
$object->fetch($id); // Fetch may not be already done
}
$result_update = $object->update_note(dol_html_entity_decode(GETPOST('note_public', 'restricthtml'), ENT_QUOTES | ENT_HTML5, 'UTF-8', 1), '_public');
if ($result_update < 0) setEventMessages($object->error, $object->errors, 'errors');
elseif (in_array($object->table_element, array('supplier_proposal', 'propal', 'commande_fournisseur', 'commande', 'facture_fourn', 'facture')))
{
if ($result_update < 0) {
setEventMessages($object->error, $object->errors, 'errors');
} elseif (in_array($object->table_element, array('supplier_proposal', 'propal', 'commande_fournisseur', 'commande', 'facture_fourn', 'facture'))) {
// Define output language
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
$outputlangs = $langs;
$newlang = '';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09');
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
$newlang = GETPOST('lang_id', 'aZ09');
}
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
$newlang = $object->thirdparty->default_lang;
}
if (!empty($newlang)) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
@ -56,13 +62,21 @@ if ($action == 'setnote_public' && !empty($permissionnote) && !GETPOST('cancel',
$result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
if ($result < 0) dol_print_error($db, $result);
if ($result < 0) {
dol_print_error($db, $result);
}
}
}
} elseif ($action == 'setnote_private' && !empty($permissionnote) && !GETPOST('cancel', 'alpha')) {
// Set public note
if (empty($action) || !is_object($object) || empty($id)) dol_print_error('', 'Include of actions_setnotes.inc.php was done but required variable was not set before');
if (empty($object->id)) $object->fetch($id); // Fetch may not be already done
if (empty($action) || !is_object($object) || empty($id)) {
dol_print_error('', 'Include of actions_setnotes.inc.php was done but required variable was not set before');
}
if (empty($object->id)) {
$object->fetch($id); // Fetch may not be already done
}
$result = $object->update_note(dol_html_entity_decode(GETPOST('note_private', 'restricthtml'), ENT_QUOTES | ENT_HTML5), '_private');
if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
}
}

View File

@ -27,13 +27,20 @@
* ajaxdirpreview.php?mode=nojs&action=preview&module=ecm&section=0&file=xxx
*/
if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); // Disables token renewal
if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1');
if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1');
if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1');
if (!defined('NOTOKENRENEWAL')) {
define('NOTOKENRENEWAL', 1); // Disables token renewal
}
if (!defined('NOREQUIREMENU')) {
define('NOREQUIREMENU', '1');
}
if (!defined('NOREQUIREHTML')) {
define('NOREQUIREHTML', '1');
}
if (!defined('NOREQUIREAJAX')) {
define('NOREQUIREAJAX', '1');
}
if (!isset($mode) || $mode != 'noajax') // For ajax call
{
if (!isset($mode) || $mode != 'noajax') { // For ajax call
require_once '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
@ -50,12 +57,18 @@ if (!isset($mode) || $mode != 'noajax') // For ajax call
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
if (empty($page) || $page == -1) {
$page = 0;
} // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if (!$sortorder) $sortorder = "ASC";
if (!$sortfield) $sortfield = "name";
if (!$sortorder) {
$sortorder = "ASC";
}
if (!$sortfield) {
$sortfield = "name";
}
$rootdirfordoc = $conf->ecm->dir_output;
@ -64,8 +77,7 @@ if (!isset($mode) || $mode != 'noajax') // For ajax call
$ecmdir = new EcmDirectory($db);
if ($section > 0) {
$result = $ecmdir->fetch($section);
if (!$result > 0)
{
if (!$result > 0) {
//dol_print_error($db,$ecmdir->error);
//exit;
}
@ -76,18 +88,15 @@ if (!isset($mode) || $mode != 'noajax') // For ajax call
$ecmdir = new EcmDirectory($db);
$relativepath = '';
if ($section > 0)
{
if ($section > 0) {
$result = $ecmdir->fetch($section);
if (!$result > 0)
{
if (!$result > 0) {
dol_print_error($db, $ecmdir->error);
exit;
}
$relativepath = $ecmdir->getRelativePath(); // Example 'mydir/'
} elseif (GETPOST('section_dir'))
{
} elseif (GETPOST('section_dir')) {
$relativepath = GETPOST('section_dir');
}
//var_dump($section.'-'.GETPOST('section_dir').'-'.$relativepath);
@ -95,24 +104,27 @@ if (!isset($mode) || $mode != 'noajax') // For ajax call
$upload_dir = $rootdirfordoc.'/'.$relativepath;
}
if (empty($url))
{
if (GETPOSTISSET('website')) $url = DOL_URL_ROOT.'/website/index.php';
else $url = DOL_URL_ROOT.'/ecm/index.php';
if (empty($url)) {
if (GETPOSTISSET('website')) {
$url = DOL_URL_ROOT.'/website/index.php';
} else {
$url = DOL_URL_ROOT.'/ecm/index.php';
}
}
// Load translation files required by the page
$langs->loadLangs(array("ecm", "companies", "other"));
// Security check
if ($user->socid > 0) $socid = $user->socid;
if ($user->socid > 0) {
$socid = $user->socid;
}
//print 'xxx'.$upload_dir;
// Security:
// On interdit les remontees de repertoire ainsi que les pipe dans les noms de fichiers.
if (preg_match('/\.\./', $upload_dir) || preg_match('/[<>|]/', $upload_dir))
{
if (preg_match('/\.\./', $upload_dir) || preg_match('/[<>|]/', $upload_dir)) {
dol_syslog("Refused to deliver file ".$upload_dir);
// Do no show plain path in shown error message
dol_print_error(0, $langs->trans("ErrorFileNameInvalid", $upload_dir));
@ -120,12 +132,12 @@ if (preg_match('/\.\./', $upload_dir) || preg_match('/[<>|]/', $upload_dir))
}
// Check permissions
if ($modulepart == 'ecm')
{
if (!$user->rights->ecm->read) accessforbidden();
if ($modulepart == 'ecm') {
if (!$user->rights->ecm->read) {
accessforbidden();
}
}
if ($modulepart == 'medias')
{
if ($modulepart == 'medias') {
// Always allowed
}
@ -142,8 +154,7 @@ if ($modulepart == 'medias')
* View
*/
if (!isset($mode) || $mode != 'noajax')
{
if (!isset($mode) || $mode != 'noajax') {
// Ajout directives pour resoudre bug IE
header('Cache-Control: Public, must-revalidate');
header('Pragma: public');
@ -154,25 +165,27 @@ if (!isset($mode) || $mode != 'noajax')
$type = 'directory';
// This test if file exists should be useless. We keep it to find bug more easily
if (!dol_is_dir($upload_dir))
{
if (!dol_is_dir($upload_dir)) {
//dol_mkdir($upload_dir);
/*$langs->load("install");
dol_print_error(0,$langs->trans("ErrorDirDoesNotExists",$upload_dir));
exit;*/
dol_print_error(0,$langs->trans("ErrorDirDoesNotExists",$upload_dir));
exit;*/
}
print '<!-- ajaxdirpreview type='.$type.' -->'."\n";
//print '<!-- Page called with mode='.dol_escape_htmltag(isset($mode)?$mode:'').' type='.dol_escape_htmltag($type).' module='.dol_escape_htmltag($module).' url='.dol_escape_htmltag($url).' '.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]).' -->'."\n";
$param = ($sortfield ? '&sortfield='.urlencode($sortfield) : '').($sortorder ? '&sortorder='.urlencode($sortorder) : '');
if (!empty($websitekey)) $param .= '&website='.urlencode($websitekey);
if (!empty($pageid)) $param .= '&pageid='.urlencode($pageid);
if (!empty($websitekey)) {
$param .= '&website='.urlencode($websitekey);
}
if (!empty($pageid)) {
$param .= '&pageid='.urlencode($pageid);
}
// Dir scan
if ($type == 'directory')
{
if ($type == 'directory') {
$formfile = new FormFile($db);
$maxlengthname = 40;
@ -203,31 +216,48 @@ if ($type == 'directory')
$parameters = array('modulepart'=>$module);
$reshook = $hookmanager->executeHooks('addSectionECMAuto', $parameters);
if ($reshook > 0 && is_array($hookmanager->resArray) && count($hookmanager->resArray)>0)
{
if ($reshook > 0 && is_array($hookmanager->resArray) && count($hookmanager->resArray)>0) {
$automodules[]=$hookmanager->resArray['module'];
}
// TODO change for multicompany sharing
if ($module == 'company') $upload_dir = $conf->societe->dir_output;
elseif ($module == 'invoice') $upload_dir = $conf->facture->dir_output;
elseif ($module == 'invoice_supplier') $upload_dir = $conf->fournisseur->facture->dir_output;
elseif ($module == 'propal') $upload_dir = $conf->propal->dir_output;
elseif ($module == 'supplier_proposal') $upload_dir = $conf->supplier_proposal->dir_output;
elseif ($module == 'order') $upload_dir = $conf->commande->dir_output;
elseif ($module == 'order_supplier') $upload_dir = $conf->fournisseur->commande->dir_output;
elseif ($module == 'contract') $upload_dir = $conf->contrat->dir_output;
elseif ($module == 'product') $upload_dir = $conf->product->dir_output;
elseif ($module == 'tax') $upload_dir = $conf->tax->dir_output;
elseif ($module == 'project') $upload_dir = $conf->projet->dir_output;
elseif ($module == 'fichinter') $upload_dir = $conf->ficheinter->dir_output;
elseif ($module == 'user') $upload_dir = $conf->user->dir_output;
elseif ($module == 'expensereport') $upload_dir = $conf->expensereport->dir_output;
elseif ($module == 'holiday') $upload_dir = $conf->holiday->dir_output;
elseif ($module == 'recruitment-recruitmentcandidature') $upload_dir = $conf->recruitment->dir_output.'/recruitmentcandidature';
elseif ($module == 'banque') $upload_dir = $conf->bank->dir_output;
elseif ($module == 'mrp-mo') $upload_dir = $conf->mrp->dir_output.'/mo';
else {
if ($module == 'company') {
$upload_dir = $conf->societe->dir_output;
} elseif ($module == 'invoice') {
$upload_dir = $conf->facture->dir_output;
} elseif ($module == 'invoice_supplier') {
$upload_dir = $conf->fournisseur->facture->dir_output;
} elseif ($module == 'propal') {
$upload_dir = $conf->propal->dir_output;
} elseif ($module == 'supplier_proposal') {
$upload_dir = $conf->supplier_proposal->dir_output;
} elseif ($module == 'order') {
$upload_dir = $conf->commande->dir_output;
} elseif ($module == 'order_supplier') {
$upload_dir = $conf->fournisseur->commande->dir_output;
} elseif ($module == 'contract') {
$upload_dir = $conf->contrat->dir_output;
} elseif ($module == 'product') {
$upload_dir = $conf->product->dir_output;
} elseif ($module == 'tax') {
$upload_dir = $conf->tax->dir_output;
} elseif ($module == 'project') {
$upload_dir = $conf->projet->dir_output;
} elseif ($module == 'fichinter') {
$upload_dir = $conf->ficheinter->dir_output;
} elseif ($module == 'user') {
$upload_dir = $conf->user->dir_output;
} elseif ($module == 'expensereport') {
$upload_dir = $conf->expensereport->dir_output;
} elseif ($module == 'holiday') {
$upload_dir = $conf->holiday->dir_output;
} elseif ($module == 'recruitment-recruitmentcandidature') {
$upload_dir = $conf->recruitment->dir_output.'/recruitmentcandidature';
} elseif ($module == 'banque') {
$upload_dir = $conf->bank->dir_output;
} elseif ($module == 'mrp-mo') {
$upload_dir = $conf->mrp->dir_output.'/mo';
} else {
$parameters = array('modulepart'=>$module);
$reshook = $hookmanager->executeHooks('addSectionECMAuto', $parameters);
if ($reshook > 0 && is_array($hookmanager->resArray) && count($hookmanager->resArray) > 0) {
@ -236,14 +266,17 @@ if ($type == 'directory')
}
// Automatic list
if (in_array($module, $automodules))
{
if (in_array($module, $automodules)) {
$param .= '&module='.$module;
if (isset($search_doc_ref) && $search_doc_ref != '') $param .= '&search_doc_ref='.urlencode($search_doc_ref);
if (isset($search_doc_ref) && $search_doc_ref != '') {
$param .= '&search_doc_ref='.urlencode($search_doc_ref);
}
$textifempty = ($section ? $langs->trans("NoFileFound") : ($showonrightsize == 'featurenotyetavailable' ? $langs->trans("FeatureNotYetAvailable") : $langs->trans("NoFileFound")));
if ($module == 'company') $excludefiles[] = '^contact$'; // The subdir 'contact' contains files of contacts with no id of thirdparty.
if ($module == 'company') {
$excludefiles[] = '^contact$'; // The subdir 'contact' contains files of contacts with no id of thirdparty.
}
$filter = preg_quote($search_doc_ref, '/');
$filearray = dol_dir_list($upload_dir, "files", 1, $filter, $excludefiles, $sortfield, $sorting, 1);
@ -254,11 +287,10 @@ if ($type == 'directory')
}
// Manual list
else {
if ($module == 'medias')
{
if ($module == 'medias') {
/*
$_POST is array like
'token' => string '062380e11b7dcd009d07318b57b71750' (length=32)
$_POST is array like
'token' => string '062380e11b7dcd009d07318b57b71750' (length=32)
'action' => string 'file_manager' (length=12)
'website' => string 'template' (length=8)
'pageid' => string '124' (length=3)
@ -266,15 +298,20 @@ if ($type == 'directory')
'section_id' => string '0' (length=1)
'max_file_size' => string '2097152' (length=7)
'sendit' => string 'Envoyer fichier' (length=15)
*/
*/
$relativepath = GETPOST('file', 'alpha') ?GETPOST('file', 'alpha') : GETPOST('section_dir', 'alpha');
if ($relativepath && $relativepath != '/') $relativepath .= '/';
if ($relativepath && $relativepath != '/') {
$relativepath .= '/';
}
$upload_dir = $dolibarr_main_data_root.'/'.$module.'/'.$relativepath;
if (GETPOSTISSET('website') || GETPOSTISSET('file_manager'))
{
if (GETPOSTISSET('website') || GETPOSTISSET('file_manager')) {
$param .= '&file_manager=1';
if (!preg_match('/website=/', $param)) $param .= '&website='.urlencode(GETPOST('website', 'alpha'));
if (!preg_match('/pageid=/', $param)) $param .= '&pageid='.urlencode(GETPOST('pageid', 'int'));
if (!preg_match('/website=/', $param)) {
$param .= '&website='.urlencode(GETPOST('website', 'alpha'));
}
if (!preg_match('/pageid=/', $param)) {
$param .= '&pageid='.urlencode(GETPOST('pageid', 'int'));
}
//if (!preg_match('/backtopage=/',$param)) $param.='&backtopage='.urlencode($_SERVER["PHP_SELF"].'?file_manager=1&website='.$websitekey.'&pageid='.$pageid);
}
} else {
@ -283,47 +320,46 @@ if ($type == 'directory')
}
// If $section defined with value 0
if (($section === '0' || empty($section)) && ($module != 'medias'))
{
if (($section === '0' || empty($section)) && ($module != 'medias')) {
$filearray = array();
} else {
$filearray = dol_dir_list($upload_dir, "files", 0, '', array('^\.', '(\.meta|_preview.*\.png)$', '^temp$', '^CVS$'), $sortfield, $sorting, 1);
}
if ($section)
{
if ($section) {
$param .= '&section='.$section;
if (isset($search_doc_ref) && $search_doc_ref != '') $param .= '&search_doc_ref='.$search_doc_ref;
if (isset($search_doc_ref) && $search_doc_ref != '') {
$param .= '&search_doc_ref='.$search_doc_ref;
}
$textifempty = $langs->trans('NoFileFound');
} elseif ($section === '0')
{
if ($module == 'ecm') $textifempty = '<br><div class="center"><font class="warning">'.$langs->trans("DirNotSynchronizedSyncFirst").'</font></div><br>';
else $textifempty = $langs->trans('NoFileFound');
} else $textifempty = ($showonrightsize == 'featurenotyetavailable' ? $langs->trans("FeatureNotYetAvailable") : $langs->trans("ECMSelectASection"));
} elseif ($section === '0') {
if ($module == 'ecm') {
$textifempty = '<br><div class="center"><font class="warning">'.$langs->trans("DirNotSynchronizedSyncFirst").'</font></div><br>';
} else {
$textifempty = $langs->trans('NoFileFound');
}
} else {
$textifempty = ($showonrightsize == 'featurenotyetavailable' ? $langs->trans("FeatureNotYetAvailable") : $langs->trans("ECMSelectASection"));
}
if ($module == 'medias')
{
if ($module == 'medias') {
$useinecm = 6;
$modulepart = 'medias';
$perm = ($user->rights->website->write || $user->rights->emailing->creer);
$title = 'none';
} elseif ($module == 'ecm') // DMS/ECM -> manual structure
{
if ($user->rights->ecm->read)
{
} elseif ($module == 'ecm') { // DMS/ECM -> manual structure
if ($user->rights->ecm->read) {
// Buttons: Preview
$useinecm = 2;
}
if ($user->rights->ecm->upload)
{
if ($user->rights->ecm->upload) {
// Buttons: Preview + Delete
$useinecm = 4;
}
if ($user->rights->ecm->setup)
{
if ($user->rights->ecm->setup) {
// Buttons: Preview + Delete + Edit
$useinecm = 5;
}
@ -349,18 +385,27 @@ if ($type == 'directory')
// Bottom of page
$useajax = 1;
if (!empty($conf->dol_use_jmobile)) $useajax = 0;
if (empty($conf->use_javascript_ajax)) $useajax = 0;
if (!empty($conf->global->MAIN_ECM_DISABLE_JS)) $useajax = 0;
if (!empty($conf->dol_use_jmobile)) {
$useajax = 0;
}
if (empty($conf->use_javascript_ajax)) {
$useajax = 0;
}
if (!empty($conf->global->MAIN_ECM_DISABLE_JS)) {
$useajax = 0;
}
//$param.=($param?'?':'').(preg_replace('/^&/','',$param));
if ($useajax || $action == 'delete')
{
if ($useajax || $action == 'delete') {
$urlfile = '';
if ($action == 'delete') $urlfile = GETPOST('urlfile', 'alpha');
if ($action == 'delete') {
$urlfile = GETPOST('urlfile', 'alpha');
}
if (empty($section_dir)) $section_dir = GETPOST("file", "alpha");
if (empty($section_dir)) {
$section_dir = GETPOST("file", "alpha");
}
$section_id = $section;
require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
@ -372,22 +417,26 @@ if ($useajax || $action == 'delete')
$formquestion['section_dir'] = array('type'=>'hidden', 'value'=>$section_dir, 'name'=>'section_dir'); // We must always put field, even if empty because it is filled by javascript later
$formquestion['sortfield'] = array('type'=>'hidden', 'value'=>$sortfield, 'name'=>'sortfield'); // We must always put field, even if empty because it is filled by javascript later
$formquestion['sortorder'] = array('type'=>'hidden', 'value'=>$sortorder, 'name'=>'sortorder'); // We must always put field, even if empty because it is filled by javascript later
if (!empty($action) && $action == 'file_manager') $formquestion['file_manager'] = array('type'=>'hidden', 'value'=>1, 'name'=>'file_manager');
if (!empty($websitekey)) $formquestion['website'] = array('type'=>'hidden', 'value'=>$websitekey, 'name'=>'website');
if (!empty($pageid) && $pageid > 0) $formquestion['pageid'] = array('type'=>'hidden', 'value'=>$pageid, 'name'=>'pageid');
if (!empty($action) && $action == 'file_manager') {
$formquestion['file_manager'] = array('type'=>'hidden', 'value'=>1, 'name'=>'file_manager');
}
if (!empty($websitekey)) {
$formquestion['website'] = array('type'=>'hidden', 'value'=>$websitekey, 'name'=>'website');
}
if (!empty($pageid) && $pageid > 0) {
$formquestion['pageid'] = array('type'=>'hidden', 'value'=>$pageid, 'name'=>'pageid');
}
print $form->formconfirm($url, $langs->trans("DeleteFile"), $langs->trans("ConfirmDeleteFile"), 'confirm_deletefile', $formquestion, "no", ($useajax ? 'deletefile' : 0));
}
if ($useajax)
{
if ($useajax) {
print '<script type="text/javascript">';
// Enable jquery handlers on new generated HTML objects (same code than into lib_footer.js.php)
// Because the content is reloaded by ajax call, we must also reenable some jquery hooks
// Wrapper to manage document_preview
if ($conf->browser->layout != 'phone')
{
if ($conf->browser->layout != 'phone') {
print "\n/* JS CODE TO ENABLE document_preview */\n";
print '
jQuery(document).ready(function () {
@ -414,4 +463,6 @@ if ($useajax)
}
// Close db if mode is not noajax
if ((!isset($mode) || $mode != 'noajax') && is_object($db)) $db->close();
if ((!isset($mode) || $mode != 'noajax') && is_object($db)) {
$db->close();
}

View File

@ -26,13 +26,20 @@
// This script is called with a POST method.
// Directory to scan (full path) is inside POST['dir'] and encode by js escape() if ajax is used or encoded by urlencode if mode=noajax
if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); // Disables token renewal
if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1');
if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1');
if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1');
if (!defined('NOTOKENRENEWAL')) {
define('NOTOKENRENEWAL', 1); // Disables token renewal
}
if (!defined('NOREQUIREMENU')) {
define('NOREQUIREMENU', '1');
}
if (!defined('NOREQUIREHTML')) {
define('NOREQUIREHTML', '1');
}
if (!defined('NOREQUIREAJAX')) {
define('NOREQUIREAJAX', '1');
}
if (!isset($mode) || $mode != 'noajax') // For ajax call
{
if (!isset($mode) || $mode != 'noajax') { // For ajax call
$res = @include '../../main.inc.php';
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
@ -48,7 +55,9 @@ if (!isset($mode) || $mode != 'noajax') // For ajax call
$preopened = GETPOST('preopened');
if ($selecteddir != '/') $selecteddir = preg_replace('/\/$/', '', $selecteddir); // We removed last '/' except if it is '/'
if ($selecteddir != '/') {
$selecteddir = preg_replace('/\/$/', '', $selecteddir); // We removed last '/' except if it is '/'
}
} else // For no ajax call
{
//if (GETPOST('preopened')) { $_GET['dir'] = $_POST['dir'] = GETPOST('preopened'); }
@ -59,8 +68,12 @@ if (!isset($mode) || $mode != 'noajax') // For ajax call
$preopened = GETPOST('preopened');
if ($selecteddir != '/') $selecteddir = preg_replace('/\/$/', '', $selecteddir); // We removed last '/' except if it is '/'
if (empty($url)) $url = DOL_URL_ROOT.'/ecm/index.php';
if ($selecteddir != '/') {
$selecteddir = preg_replace('/\/$/', '', $selecteddir); // We removed last '/' except if it is '/'
}
if (empty($url)) {
$url = DOL_URL_ROOT.'/ecm/index.php';
}
}
// Load translation files required by the page
@ -68,12 +81,10 @@ $langs->load("ecm");
// Define fullpathselecteddir.
$fullpathselecteddir = '<none>';
if ($modulepart == 'ecm')
{
if ($modulepart == 'ecm') {
$fullpathselecteddir = $conf->ecm->dir_output.'/'.($selecteddir != '/' ? $selecteddir : '');
$fullpathpreopened = $conf->ecm->dir_output.'/'.($preopened != '/' ? $preopened : '');
} elseif ($modulepart == 'medias')
{
} elseif ($modulepart == 'medias') {
$fullpathselecteddir = $dolibarr_main_data_root.'/medias/'.($selecteddir != '/' ? $selecteddir : '');
$fullpathpreopened = $dolibarr_main_data_root.'/medias/'.($preopened != '/' ? $preopened : '');
}
@ -81,8 +92,7 @@ if ($modulepart == 'ecm')
// Security:
// On interdit les remontees de repertoire ainsi que les pipe dans les noms de fichiers.
if (preg_match('/\.\./', $fullpathselecteddir) || preg_match('/[<>|]/', $fullpathselecteddir))
{
if (preg_match('/\.\./', $fullpathselecteddir) || preg_match('/[<>|]/', $fullpathselecteddir)) {
dol_syslog("Refused to deliver file ".$original_file);
// Do no show plain path in shown error message
dol_print_error(0, $langs->trans("ErrorFileNameInvalid", GETPOST("file")));
@ -90,11 +100,11 @@ if (preg_match('/\.\./', $fullpathselecteddir) || preg_match('/[<>|]/', $fullpat
}
// Check permissions
if ($modulepart == 'ecm')
{
if (!$user->rights->ecm->read) accessforbidden();
} elseif ($modulepart == 'medias')
{
if ($modulepart == 'ecm') {
if (!$user->rights->ecm->read) {
accessforbidden();
}
} elseif ($modulepart == 'medias') {
// Always allowed
}
@ -103,8 +113,7 @@ if ($modulepart == 'ecm')
* View
*/
if (!isset($mode) || $mode != 'noajax') // if ajax mode
{
if (!isset($mode) || $mode != 'noajax') { // if ajax mode
top_httphead();
}
@ -114,21 +123,20 @@ $form = new Form($db);
$ecmdirstatic = new EcmDirectory($db);
// Load full tree of ECM module from database. We will use it to define nbofsubdir and nboffilesinsubdir
if (empty($sqltree)) $sqltree = $ecmdirstatic->get_full_arbo(0);
if (empty($sqltree)) {
$sqltree = $ecmdirstatic->get_full_arbo(0);
}
// Try to find selected dir id into $sqltree and save it into $current_ecmdir_id
$current_ecmdir_id = -1;
foreach ($sqltree as $keycursor => $val)
{
foreach ($sqltree as $keycursor => $val) {
//print $val['fullrelativename']." == ".$selecteddir;
if ($val['fullrelativename'] == $selecteddir)
{
if ($val['fullrelativename'] == $selecteddir) {
$current_ecmdir_id = $keycursor;
}
}
if (!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS))
{
if (!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) {
treeOutputForAbsoluteDir($sqltree, $selecteddir, $fullpathselecteddir, $modulepart, $websitekey, $pageid, $preopened, $fullpathpreopened);
// TODO Find a solution to not output this code for each leaf we open
@ -155,12 +163,13 @@ if (!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_
}
if (empty($conf->use_javascript_ajax) || !empty($conf->global->MAIN_ECM_DISABLE_JS))
{
if (empty($conf->use_javascript_ajax) || !empty($conf->global->MAIN_ECM_DISABLE_JS)) {
print '<ul class="ecmjqft">';
// Load full tree from database. We will use it to define nbofsubdir and nboffilesinsubdir
if (empty($sqltree)) $sqltree = $ecmdirstatic->get_full_arbo(0); // Slow
if (empty($sqltree)) {
$sqltree = $ecmdirstatic->get_full_arbo(0); // Slow
}
// ----- This section will show a tree from a fulltree array -----
// $section must also be defined
@ -168,11 +177,9 @@ if (empty($conf->use_javascript_ajax) || !empty($conf->global->MAIN_ECM_DISABLE_
// Define fullpathselected ( _x_y_z ) of $section parameter (!! not into ajaxdirtree)
$fullpathselected = '';
foreach ($sqltree as $key => $val)
{
foreach ($sqltree as $key => $val) {
//print $val['id']."-".$section."<br>";
if ($val['id'] == $section)
{
if ($val['id'] == $section) {
$fullpathselected = $val['fullpath'];
break;
}
@ -181,28 +188,25 @@ if (empty($conf->use_javascript_ajax) || !empty($conf->global->MAIN_ECM_DISABLE_
// Update expandedsectionarray in session
$expandedsectionarray = array();
if (isset($_SESSION['dol_ecmexpandedsectionarray'])) $expandedsectionarray = explode(',', $_SESSION['dol_ecmexpandedsectionarray']);
if (isset($_SESSION['dol_ecmexpandedsectionarray'])) {
$expandedsectionarray = explode(',', $_SESSION['dol_ecmexpandedsectionarray']);
}
if ($section && GETPOST('sectionexpand') == 'true')
{
if ($section && GETPOST('sectionexpand') == 'true') {
// We add all sections that are parent of opened section
$pathtosection = explode('_', $fullpathselected);
foreach ($pathtosection as $idcursor)
{
if ($idcursor && !in_array($idcursor, $expandedsectionarray)) // Not already in array
{
foreach ($pathtosection as $idcursor) {
if ($idcursor && !in_array($idcursor, $expandedsectionarray)) { // Not already in array
$expandedsectionarray[] = $idcursor;
}
}
$_SESSION['dol_ecmexpandedsectionarray'] = join(',', $expandedsectionarray);
}
if ($section && GETPOST('sectionexpand') == 'false')
{
if ($section && GETPOST('sectionexpand') == 'false') {
// We removed all expanded sections that are child of the closed section
$oldexpandedsectionarray = $expandedsectionarray;
$expandedsectionarray = array(); // Reset
foreach ($oldexpandedsectionarray as $sectioncursor)
{
foreach ($oldexpandedsectionarray as $sectioncursor) {
// TODO is_in_subtree(fulltree,sectionparent,sectionchild) does nox exists. Enable or remove this...
//if ($sectioncursor && ! is_in_subtree($sqltree,$section,$sectioncursor)) $expandedsectionarray[]=$sectioncursor;
}
@ -212,14 +216,12 @@ if (empty($conf->use_javascript_ajax) || !empty($conf->global->MAIN_ECM_DISABLE_
$nbofentries = 0;
$oldvallevel = 0;
foreach ($sqltree as $key => $val)
{
foreach ($sqltree as $key => $val) {
$ecmdirstatic->id = $val['id'];
$ecmdirstatic->ref = $val['label'];
// Refresh cache
if (preg_match('/refresh/i', $action))
{
if (preg_match('/refresh/i', $action)) {
$result = $ecmdirstatic->fetch($val['id']);
$ecmdirstatic->ref = $ecmdirstatic->label;
@ -233,26 +235,35 @@ if (empty($conf->use_javascript_ajax) || !empty($conf->global->MAIN_ECM_DISABLE_
$showline = 0;
// If directory is son of expanded directory, we show line
if (in_array($val['id_mere'], $expandedsectionarray)) $showline = 4;
if (in_array($val['id_mere'], $expandedsectionarray)) {
$showline = 4;
}
// If directory is brother of selected directory, we show line
elseif ($val['id'] != $section && $val['id_mere'] == $ecmdirstatic->motherof[$section]) $showline = 3;
elseif ($val['id'] != $section && $val['id_mere'] == $ecmdirstatic->motherof[$section]) {
$showline = 3;
}
// If directory is parent of selected directory or is selected directory, we show line
elseif (preg_match('/'.$val['fullpath'].'_/i', $fullpathselected.'_')) $showline = 2;
elseif (preg_match('/'.$val['fullpath'].'_/i', $fullpathselected.'_')) {
$showline = 2;
}
// If we are level one we show line
elseif ($val['level'] < 2) $showline = 1;
elseif ($val['level'] < 2) {
$showline = 1;
}
if ($showline)
{
if (in_array($val['id'], $expandedsectionarray)) $option = 'indexexpanded';
else $option = 'indexnotexpanded';
if ($showline) {
if (in_array($val['id'], $expandedsectionarray)) {
$option = 'indexexpanded';
} else {
$option = 'indexnotexpanded';
}
//print $option;
print '<li class="directory collapsed">';
// Show tree graph pictos
$cpt = 1;
while ($cpt < $sqltree[$key]['level'])
{
while ($cpt < $sqltree[$key]['level']) {
print ' &nbsp; &nbsp;';
$cpt++;
}
@ -271,7 +282,9 @@ if (empty($conf->use_javascript_ajax) || !empty($conf->global->MAIN_ECM_DISABLE_
print $val['cachenbofdoc'];
print '</td>';
print '<td class="left">';
if ($nbofsubdir && $nboffilesinsubdir) print '<font color="#AAAAAA">+'.$nboffilesinsubdir.'</font> ';
if ($nbofsubdir && $nboffilesinsubdir) {
print '<font color="#AAAAAA">+'.$nboffilesinsubdir.'</font> ';
}
print '</td>';
// Info
@ -284,8 +297,11 @@ if (empty($conf->use_javascript_ajax) || !empty($conf->global->MAIN_ECM_DISABLE_
$htmltooltip .= '<b>'.$langs->trans("ECMCreationDate").'</b>: '.dol_print_date($val['date_c'], "dayhour").'<br>';
$htmltooltip .= '<b>'.$langs->trans("Description").'</b>: '.$val['description'].'<br>';
$htmltooltip .= '<b>'.$langs->trans("ECMNbOfFilesInDir").'</b>: '.$val['cachenbofdoc'].'<br>';
if ($nbofsubdir) $htmltooltip .= '<b>'.$langs->trans("ECMNbOfFilesInSubDir").'</b>: '.$nboffilesinsubdir;
else $htmltooltip .= '<b>'.$langs->trans("ECMNbOfSubDir").'</b>: '.$nbofsubdir.'<br>';
if ($nbofsubdir) {
$htmltooltip .= '<b>'.$langs->trans("ECMNbOfFilesInSubDir").'</b>: '.$nboffilesinsubdir;
} else {
$htmltooltip .= '<b>'.$langs->trans("ECMNbOfSubDir").'</b>: '.$nbofsubdir.'<br>';
}
print $form->textwithpicto('', $htmltooltip, 1, 'info');
print "</td>";
@ -301,8 +317,7 @@ if (empty($conf->use_javascript_ajax) || !empty($conf->global->MAIN_ECM_DISABLE_
}
// If nothing to show
if ($nbofentries == 0)
{
if ($nbofentries == 0) {
print '<li class="directory collapsed">';
print '<div class="ecmjqft">';
print $langs->trans("ECMNoDirectoryYet");
@ -315,7 +330,9 @@ if (empty($conf->use_javascript_ajax) || !empty($conf->global->MAIN_ECM_DISABLE_
// Close db if mode is not noajax
if ((!isset($mode) || $mode != 'noajax') && is_object($db)) $db->close();
if ((!isset($mode) || $mode != 'noajax') && is_object($db)) {
$db->close();
}
@ -341,21 +358,19 @@ function treeOutputForAbsoluteDir($sqltree, $selecteddir, $fullpathselecteddir,
$ecmdirstatic = new EcmDirectory($db);
$userstatic = new User($db);
if (file_exists($fullpathselecteddir))
{
if (file_exists($fullpathselecteddir)) {
$files = @scandir($fullpathselecteddir);
if (!empty($files))
{
if (!empty($files)) {
natcasesort($files);
if (count($files) > 2) /* The 2 accounts for . and .. */
{
if (count($files) > 2) { /* The 2 accounts for . and .. */
echo '<ul class="ecmjqft" style="display: none;">'."\n";
// All dirs
foreach ($files as $file) // $file can be '.', '..', or 'My dir' or 'My file'
{
if ($file == 'temp') continue;
foreach ($files as $file) { // $file can be '.', '..', or 'My dir' or 'My file'
if ($file == 'temp') {
continue;
}
$nbofsubdir = 0;
$nboffilesinsubdir = 0;
@ -363,17 +378,14 @@ function treeOutputForAbsoluteDir($sqltree, $selecteddir, $fullpathselecteddir,
$val = array();
// Loop on all database entries (sqltree) to find the one matching the subdir found into dir to scan
foreach ($sqltree as $key => $tmpval)
{
foreach ($sqltree as $key => $tmpval) {
//print "-- key=".$key." - ".$tmpval['fullrelativename']." vs ".(($selecteddir != '/'?$selecteddir.'/':'').$file)."<br>\n";
if ($tmpval['fullrelativename'] == (($selecteddir != '/' ? $selecteddir.'/' : '').$file)) // We found equivalent record into database
{
if ($tmpval['fullrelativename'] == (($selecteddir != '/' ? $selecteddir.'/' : '').$file)) { // We found equivalent record into database
$val = $tmpval;
$resarray = tree_showpad($sqltree, $key, 1);
// Refresh cache for this subdir
if (isset($val['cachenbofdoc']) && $val['cachenbofdoc'] < 0) // Cache is not up to date, so we update it for this directory t
{
if (isset($val['cachenbofdoc']) && $val['cachenbofdoc'] < 0) { // Cache is not up to date, so we update it for this directory t
$result = $ecmdirstatic->fetch($val['id']);
$ecmdirstatic->ref = $ecmdirstatic->label;
@ -389,10 +401,8 @@ function treeOutputForAbsoluteDir($sqltree, $selecteddir, $fullpathselecteddir,
}
//print 'modulepart='.$modulepart.' fullpathselecteddir='.$fullpathselecteddir.' - val[fullrelativename] (in database)='.$val['fullrelativename'].' - val[id]='.$val['id'].' - is_dir='.dol_is_dir($fullpathselecteddir . $file).' - file='.$file."\n";
if ($file != '.' && $file != '..' && ((!empty($val['fullrelativename']) && $val['id'] >= 0) || dol_is_dir($fullpathselecteddir.(preg_match('/\/$/', $fullpathselecteddir) ? '' : '/').$file)))
{
if (empty($val['fullrelativename'])) // If we did not find entry into database, but found a directory (dol_is_dir was ok at previous test)
{
if ($file != '.' && $file != '..' && ((!empty($val['fullrelativename']) && $val['id'] >= 0) || dol_is_dir($fullpathselecteddir.(preg_match('/\/$/', $fullpathselecteddir) ? '' : '/').$file))) {
if (empty($val['fullrelativename'])) { // If we did not find entry into database, but found a directory (dol_is_dir was ok at previous test)
$val['fullrelativename'] = (($selecteddir && $selecteddir != '/') ? $selecteddir.'/' : '').$file;
$val['id'] = 0;
$val['label'] = $file;
@ -401,7 +411,9 @@ function treeOutputForAbsoluteDir($sqltree, $selecteddir, $fullpathselecteddir,
}
$collapsedorexpanded = 'collapsed';
if (preg_match('/^'.preg_quote($val['fullrelativename'].'/', '/').'/', $preopened)) $collapsedorexpanded = 'expanded';
if (preg_match('/^'.preg_quote($val['fullrelativename'].'/', '/').'/', $preopened)) {
$collapsedorexpanded = 'expanded';
}
print '<li class="directory '.$collapsedorexpanded.'">'; // collapsed is opposite if expanded
print "<a class=\"fmdirlia jqft ecmjqft\" href=\"";
@ -425,7 +437,9 @@ function treeOutputForAbsoluteDir($sqltree, $selecteddir, $fullpathselecteddir,
print (isset($val['cachenbofdoc']) && $val['cachenbofdoc'] >= 0) ? $val['cachenbofdoc'] : '&nbsp;';
print '</td>';
print '<td class="left">';
if ($nbofsubdir > 0 && $nboffilesinsubdir > 0) print '<font class="opacitymedium">+'.$nboffilesinsubdir.'</font> ';
if ($nbofsubdir > 0 && $nboffilesinsubdir > 0) {
print '<font class="opacitymedium">+'.$nboffilesinsubdir.'</font> ';
}
print '</td>';
// Edit link
@ -439,8 +453,7 @@ function treeOutputForAbsoluteDir($sqltree, $selecteddir, $fullpathselecteddir,
//print '<td class="right" width="14">&nbsp;</td>';
// Info
if ($modulepart == 'ecm')
{
if ($modulepart == 'ecm') {
print '<td class="right" width="18">';
$userstatic->id = isset($val['fk_user_c']) ? $val['fk_user_c'] : 0;
$userstatic->lastname = isset($val['login_c']) ? $val['login_c'] : 0;
@ -450,8 +463,11 @@ function treeOutputForAbsoluteDir($sqltree, $selecteddir, $fullpathselecteddir,
$htmltooltip .= '<b>'.$langs->trans("ECMCreationDate").'</b>: '.(isset($val['date_c']) ?dol_print_date($val['date_c'], "dayhour") : $langs->trans("NeedRefresh")).'<br>';
$htmltooltip .= '<b>'.$langs->trans("Description").'</b>: '.$val['description'].'<br>';
$htmltooltip .= '<b>'.$langs->trans("ECMNbOfFilesInDir").'</b>: '.((isset($val['cachenbofdoc']) && $val['cachenbofdoc'] >= 0) ? $val['cachenbofdoc'] : $langs->trans("NeedRefresh")).'<br>';
if ($nboffilesinsubdir > 0) $htmltooltip .= '<b>'.$langs->trans("ECMNbOfFilesInSubDir").'</b>: '.$nboffilesinsubdir;
else $htmltooltip .= '<b>'.$langs->trans("ECMNbOfSubDir").'</b>: '.($nbofsubdir >= 0 ? $nbofsubdir : $langs->trans("NeedRefresh")).'<br>';
if ($nboffilesinsubdir > 0) {
$htmltooltip .= '<b>'.$langs->trans("ECMNbOfFilesInSubDir").'</b>: '.$nboffilesinsubdir;
} else {
$htmltooltip .= '<b>'.$langs->trans("ECMNbOfSubDir").'</b>: '.($nbofsubdir >= 0 ? $nbofsubdir : $langs->trans("NeedRefresh")).'<br>';
}
print $form->textwithpicto('', $htmltooltip, 1, "info");
print "</td>";
}
@ -460,20 +476,19 @@ function treeOutputForAbsoluteDir($sqltree, $selecteddir, $fullpathselecteddir,
print '</div>';
//print 'selecteddir='.$selecteddir.' preopened='.$preopened.' $val[\'fullrelativename\']='.$val['fullrelativename']."<br>\n";
if (preg_match('/^'.preg_quote($val['fullrelativename'].'/', '/').'/', $preopened))
{
if (preg_match('/^'.preg_quote($val['fullrelativename'].'/', '/').'/', $preopened)) {
//print 'modulepart='.$modulepart.' fullpathselecteddir='.$fullpathselecteddir.' - val[fullrelativename] (in database)='.$val['fullrelativename'].' - val[id]='.$val['id'].' - is_dir='.dol_is_dir($fullpathselecteddir . $file).' - file='.$file."\n";
$newselecteddir = $val['fullrelativename'];
$newfullpathselecteddir = '';
if ($modulepart == 'ecm')
{
if ($modulepart == 'ecm') {
$newfullpathselecteddir = $conf->ecm->dir_output.'/'.($val['fullrelativename'] != '/' ? $val['fullrelativename'] : '');
} elseif ($modulepart == 'medias')
{
} elseif ($modulepart == 'medias') {
$newfullpathselecteddir = $dolibarr_main_data_root.'/medias/'.($val['fullrelativename'] != '/' ? $val['fullrelativename'] : '');
}
if ($newfullpathselecteddir) treeOutputForAbsoluteDir($sqltree, $newselecteddir, $newfullpathselecteddir, $modulepart, $websitekey, $pageid, $preopened, $fullpathpreopened, $depth + 1);
if ($newfullpathselecteddir) {
treeOutputForAbsoluteDir($sqltree, $newselecteddir, $newfullpathselecteddir, $modulepart, $websitekey, $pageid, $preopened, $fullpathpreopened, $depth + 1);
}
}
print "</li>\n";
@ -482,6 +497,8 @@ function treeOutputForAbsoluteDir($sqltree, $selecteddir, $fullpathselecteddir,
echo "</ul>\n";
}
} else print "PermissionDenied";
} else {
print "PermissionDenied";
}
}
}

View File

@ -20,11 +20,21 @@
* \brief File to set data for bank concilation
*/
if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal
if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1');
if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1');
if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1');
if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1');
if (!defined('NOTOKENRENEWAL')) {
define('NOTOKENRENEWAL', '1'); // Disables token renewal
}
if (!defined('NOREQUIREMENU')) {
define('NOREQUIREMENU', '1');
}
if (!defined('NOREQUIREHTML')) {
define('NOREQUIREHTML', '1');
}
if (!defined('NOREQUIREAJAX')) {
define('NOREQUIREAJAX', '1');
}
if (!defined('NOREQUIRESOC')) {
define('NOREQUIRESOC', '1');
}
//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Required to know date format for dol_print_date
require '../../main.inc.php';
@ -47,8 +57,7 @@ top_httphead();
//print '<!-- Ajax page called with url '.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]).' -->'."\n";
if (($user->rights->banque->modifier || $user->rights->banque->consolidate) && $action == 'dvnext')
{
if (($user->rights->banque->modifier || $user->rights->banque->consolidate) && $action == 'dvnext') {
// Increase date
$al = new AccountLine($db);
$al->datev_next(GETPOST('rowid', 'int'));
@ -59,8 +68,7 @@ if (($user->rights->banque->modifier || $user->rights->banque->consolidate) && $
exit;
}
if (($user->rights->banque->modifier || $user->rights->banque->consolidate) && $action == 'dvprev')
{
if (($user->rights->banque->modifier || $user->rights->banque->consolidate) && $action == 'dvprev') {
// Decrease date
$al = new AccountLine($db);
$al->datev_previous(GETPOST('rowid', 'int'));
@ -71,8 +79,7 @@ if (($user->rights->banque->modifier || $user->rights->banque->consolidate) && $
exit;
}
if (($user->rights->banque->modifier || $user->rights->banque->consolidate) && $action == 'donext')
{
if (($user->rights->banque->modifier || $user->rights->banque->consolidate) && $action == 'donext') {
// Increase date
$al = new AccountLine($db);
$al->dateo_next(GETPOST('rowid', 'int'));
@ -83,8 +90,7 @@ if (($user->rights->banque->modifier || $user->rights->banque->consolidate) && $
exit;
}
if (($user->rights->banque->modifier || $user->rights->banque->consolidate) && $action == 'doprev')
{
if (($user->rights->banque->modifier || $user->rights->banque->consolidate) && $action == 'doprev') {
// Decrease date
$al = new AccountLine($db);
$al->dateo_previous(GETPOST('rowid', 'int'));

View File

@ -21,11 +21,21 @@
* \brief File to return Ajax response on Box move or close
*/
if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal
if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1');
if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1');
if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1');
if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1');
if (!defined('NOTOKENRENEWAL')) {
define('NOTOKENRENEWAL', '1'); // Disables token renewal
}
if (!defined('NOREQUIREMENU')) {
define('NOREQUIREMENU', '1');
}
if (!defined('NOREQUIREHTML')) {
define('NOREQUIREHTML', '1');
}
if (!defined('NOREQUIREAJAX')) {
define('NOREQUIREAJAX', '1');
}
if (!defined('NOREQUIRESOC')) {
define('NOREQUIRESOC', '1');
}
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php';
@ -51,28 +61,27 @@ top_httphead();
print '<!-- Ajax page called with url '.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]).' -->'."\n";
// Add a box
if ($boxid > 0 && $zone != '' && $userid > 0)
{
if ($boxid > 0 && $zone != '' && $userid > 0) {
$tmp = explode('-', $boxorder);
$nbboxonleft = substr_count($tmp[0], ',');
$nbboxonright = substr_count($tmp[1], ',');
print $nbboxonleft.'-'.$nbboxonright;
if ($nbboxonleft > $nbboxonright) $boxorder = preg_replace('/B:/', 'B:'.$boxid.',', $boxorder); // Insert id of new box into list
else $boxorder = preg_replace('/^A:/', 'A:'.$boxid.',', $boxorder); // Insert id of new box into list
if ($nbboxonleft > $nbboxonright) {
$boxorder = preg_replace('/B:/', 'B:'.$boxid.',', $boxorder); // Insert id of new box into list
} else {
$boxorder = preg_replace('/^A:/', 'A:'.$boxid.',', $boxorder); // Insert id of new box into list
}
}
// Registering the location of boxes after a move
if ($boxorder && $zone != '' && $userid > 0)
{
if ($boxorder && $zone != '' && $userid > 0) {
// boxorder value is the target order: "A:idboxA1,idboxA2,A-B:idboxB1,idboxB2,B"
dol_syslog("AjaxBox boxorder=".$boxorder." zone=".$zone." userid=".$userid, LOG_DEBUG);
$result = InfoBox::saveboxorder($db, $zone, $boxorder, $userid);
if ($result > 0)
{
if ($result > 0) {
$langs->load("boxes");
if (!GETPOST('closing'))
{
if (!GETPOST('closing')) {
setEventMessages($langs->trans("BoxAdded"), null);
}
}

View File

@ -17,13 +17,27 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1');
if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on)
if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1');
if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1');
if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1');
if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1');
if (!defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1');
if (!defined('NOCSRFCHECK')) {
define('NOCSRFCHECK', '1');
}
if (!defined('NOTOKENRENEWAL')) {
define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on)
}
if (!defined('NOREQUIREMENU')) {
define('NOREQUIREMENU', '1');
}
if (!defined('NOREQUIREHTML')) {
define('NOREQUIREHTML', '1');
}
if (!defined('NOREQUIREAJAX')) {
define('NOREQUIREAJAX', '1');
}
if (!defined('NOREQUIRESOC')) {
define('NOREQUIRESOC', '1');
}
if (!defined('NOREQUIRETRAN')) {
define('NOREQUIRETRAN', '1');
}
//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Do not load object $user
//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); // Do not load object $mysoc
@ -103,25 +117,24 @@ $eventfound = array();
// TODO Try to make a solution with only a javascript timer that is easier. Difficulty is to avoid notification twice when several tabs are opened.
// This need to extend period to be sure to not miss and save in session what we notified to avoid duplicate.
if (empty($_SESSION['auto_check_events_not_before']) || $time >= $_SESSION['auto_check_events_not_before'] || GETPOST('forcechecknow', 'int'))
{
if (empty($_SESSION['auto_check_events_not_before']) || $time >= $_SESSION['auto_check_events_not_before'] || GETPOST('forcechecknow', 'int')) {
/*$time_update = (int) $conf->global->MAIN_BROWSER_NOTIFICATION_FREQUENCY; // Always defined
if (!empty($_SESSION['auto_check_events_not_before']))
{
// We start scan from the not before so if two tabs were opend at differents seconds and we close one (so the js timer),
// then we are not losing periods
$starttime = $_SESSION['auto_check_events_not_before'];
// Protection to avoid too long sessions
if ($starttime < ($time - (int) $conf->global->MAIN_SESSION_TIMEOUT))
{
dol_syslog("We ask to check browser notification on a too large period. We fix this with current date.");
$starttime = $time;
}
} else {
$starttime = $time;
}
if (!empty($_SESSION['auto_check_events_not_before']))
{
// We start scan from the not before so if two tabs were opend at differents seconds and we close one (so the js timer),
// then we are not losing periods
$starttime = $_SESSION['auto_check_events_not_before'];
// Protection to avoid too long sessions
if ($starttime < ($time - (int) $conf->global->MAIN_SESSION_TIMEOUT))
{
dol_syslog("We ask to check browser notification on a too large period. We fix this with current date.");
$starttime = $time;
}
} else {
$starttime = $time;
}
$_SESSION['auto_check_events_not_before'] = $time + $time_update;
$_SESSION['auto_check_events_not_before'] = $time + $time_update;
*/
// Force save of the session change we did.
@ -150,8 +163,7 @@ if (empty($_SESSION['auto_check_events_not_before']) || $time >= $_SESSION['auto
$resql = $db->query($sql);
if ($resql) {
while ($obj = $db->fetch_object($resql))
{
while ($obj = $db->fetch_object($resql)) {
// Message must be formated and translated to be used with javascript directly
$event = array();
$event['type'] = 'agenda';

View File

@ -20,13 +20,27 @@
* \brief File to set or del an on/off constant
*/
if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal
if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1');
if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1');
if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1');
if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1');
if (!defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1');
if (!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Token is required even in GET mode
if (!defined('NOTOKENRENEWAL')) {
define('NOTOKENRENEWAL', '1'); // Disables token renewal
}
if (!defined('NOREQUIREMENU')) {
define('NOREQUIREMENU', '1');
}
if (!defined('NOREQUIREHTML')) {
define('NOREQUIREHTML', '1');
}
if (!defined('NOREQUIREAJAX')) {
define('NOREQUIREAJAX', '1');
}
if (!defined('NOREQUIRESOC')) {
define('NOREQUIRESOC', '1');
}
if (!defined('NOREQUIRETRAN')) {
define('NOREQUIRETRAN', '1');
}
if (!defined('CSRFCHECK_WITH_TOKEN')) {
define('CSRFCHECK_WITH_TOKEN', '1'); // Token is required even in GET mode
}
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
@ -49,18 +63,14 @@ top_httphead();
//print '<!-- Ajax page called with url '.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]).' -->'."\n";
// Registering the new value of constant
if (!empty($action) && !empty($name))
{
if (!empty($action) && !empty($name)) {
$entity = GETPOST('entity', 'int');
$value = (GETPOST('value') ?GETPOST('value') : 1);
if ($user->admin)
{
if ($action == 'set')
{
if ($user->admin) {
if ($action == 'set') {
dolibarr_set_const($db, $name, $value, 'chaine', 0, '', $entity);
} elseif ($action == 'del')
{
} elseif ($action == 'del') {
dolibarr_del_const($db, $name, $entity);
}
}

View File

@ -21,9 +21,15 @@
* \brief File to load contacts combobox
*/
if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal
if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1');
if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1');
if (!defined('NOTOKENRENEWAL')) {
define('NOTOKENRENEWAL', '1'); // Disables token renewal
}
if (!defined('NOREQUIREMENU')) {
define('NOREQUIREMENU', '1');
}
if (!defined('NOREQUIREAJAX')) {
define('NOREQUIREAJAX', '1');
}
require '../../main.inc.php';
@ -45,12 +51,13 @@ top_httphead();
//print '<!-- Ajax page called with url '.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]).' -->'."\n";
// Load original field value
if (!empty($id) && !empty($action) && !empty($htmlname))
{
if (!empty($id) && !empty($action) && !empty($htmlname)) {
$form = new Form($db);
$return = array();
if (empty($showempty)) $showempty = 0;
if (empty($showempty)) {
$showempty = 0;
}
$return['value'] = $form->selectcontacts($id, '', $htmlname, $showempty, '', '', 0, '', true);
$return['num'] = $form->num;

View File

@ -20,11 +20,21 @@
* \brief File to make Ajax action on setting extra parameters of elements
*/
if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal
if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1');
if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1');
if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1');
if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1');
if (!defined('NOTOKENRENEWAL')) {
define('NOTOKENRENEWAL', '1'); // Disables token renewal
}
if (!defined('NOREQUIREMENU')) {
define('NOREQUIREMENU', '1');
}
if (!defined('NOREQUIREHTML')) {
define('NOREQUIREHTML', '1');
}
if (!defined('NOREQUIREAJAX')) {
define('NOREQUIREAJAX', '1');
}
if (!defined('NOREQUIRESOC')) {
define('NOREQUIRESOC', '1');
}
include '../../main.inc.php';
@ -41,8 +51,7 @@ top_httphead();
print '<!-- Ajax page called with url '.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]).' -->'."\n";
if (!empty($id) && !empty($element) && !empty($htmlelement) && !empty($type))
{
if (!empty($id) && !empty($element) && !empty($htmlelement) && !empty($type)) {
$value = GETPOST('value', 'alpha');
$params = array();

View File

@ -21,10 +21,18 @@
* \brief File to return Ajax response on file upload
*/
if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1');
if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1');
if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no menu to show
if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php
if (!defined('NOCSRFCHECK')) {
define('NOCSRFCHECK', '1');
}
if (!defined('NOTOKENRENEWAL')) {
define('NOTOKENRENEWAL', '1');
}
if (!defined('NOREQUIREMENU')) {
define('NOREQUIREMENU', '1'); // If there is no menu to show
}
if (!defined('NOREQUIREHTML')) {
define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php
}
require '../../main.inc.php';

View File

@ -20,9 +20,15 @@
* \brief File to load currency rates
*/
if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal
if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1');
if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1');
if (!defined('NOTOKENRENEWAL')) {
define('NOTOKENRENEWAL', '1'); // Disables token renewal
}
if (!defined('NOREQUIREMENU')) {
define('NOREQUIREMENU', '1');
}
if (!defined('NOREQUIREAJAX')) {
define('NOREQUIREAJAX', '1');
}
require '../../main.inc.php';
@ -38,8 +44,7 @@ top_httphead();
//print '<!-- Ajax page called with url '.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]).' -->'."\n";
// Load original field value
if (!empty($id))
{
if (!empty($id)) {
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
$account = new Account($db);
$result = $account->fetch($id);

View File

@ -20,10 +20,18 @@
* \brief File to load field value
*/
if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal
if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1');
if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1');
if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1');
if (!defined('NOTOKENRENEWAL')) {
define('NOTOKENRENEWAL', '1'); // Disables token renewal
}
if (!defined('NOREQUIREMENU')) {
define('NOREQUIREMENU', '1');
}
if (!defined('NOREQUIREAJAX')) {
define('NOREQUIREAJAX', '1');
}
if (!defined('NOREQUIRESOC')) {
define('NOREQUIRESOC', '1');
}
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php';
@ -42,24 +50,26 @@ top_httphead();
//print '<!-- Ajax page called with url '.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]).' -->'."\n";
// Load original field value
if (!empty($field) && !empty($element) && !empty($table_element) && !empty($fk_element))
{
if (!empty($field) && !empty($element) && !empty($table_element) && !empty($fk_element)) {
$ext_element = GETPOST('ext_element', 'alpha');
$field = substr($field, 8); // remove prefix val_
$type = GETPOST('type', 'alpha');
$loadmethod = (GETPOST('loadmethod', 'alpha') ? GETPOST('loadmethod', 'alpha') : 'getValueFrom');
if ($element != 'order_supplier' && $element != 'invoice_supplier' && preg_match('/^([^_]+)_([^_]+)/i', $element, $regs))
{
if ($element != 'order_supplier' && $element != 'invoice_supplier' && preg_match('/^([^_]+)_([^_]+)/i', $element, $regs)) {
$element = $regs[1];
$subelement = $regs[2];
}
if ($element == 'propal') $element = 'propale';
elseif ($element == 'fichinter') $element = 'ficheinter';
elseif ($element == 'product') $element = 'produit';
elseif ($element == 'member') $element = 'adherent';
elseif ($element == 'order_supplier') {
if ($element == 'propal') {
$element = 'propale';
} elseif ($element == 'fichinter') {
$element = 'ficheinter';
} elseif ($element == 'product') {
$element = 'produit';
} elseif ($element == 'member') {
$element = 'adherent';
} elseif ($element == 'order_supplier') {
$element = 'fournisseur';
$subelement = 'commande';
} elseif ($element == 'invoice_supplier') {
@ -70,23 +80,20 @@ if (!empty($field) && !empty($element) && !empty($table_element) && !empty($fk_e
if ($user->rights->$element->lire || $user->rights->$element->read
|| (isset($subelement) && ($user->rights->$element->$subelement->lire || $user->rights->$element->$subelement->read))
|| ($element == 'payment' && $user->rights->facture->lire)
|| ($element == 'payment_supplier' && $user->rights->fournisseur->facture->lire))
{
if ($type == 'select')
{
|| ($element == 'payment_supplier' && $user->rights->fournisseur->facture->lire)) {
if ($type == 'select') {
$methodname = 'load_cache_'.$loadmethod;
$cachename = 'cache_'.GETPOST('loadmethod', 'alpha');
$form = new Form($db);
if (method_exists($form, $methodname))
{
if (method_exists($form, $methodname)) {
$ret = $form->$methodname();
if ($ret > 0) echo json_encode($form->$cachename);
} elseif (!empty($ext_element))
{
if ($ret > 0) {
echo json_encode($form->$cachename);
}
} elseif (!empty($ext_element)) {
$module = $subelement = $ext_element;
if (preg_match('/^([^_]+)_([^_]+)/i', $ext_element, $regs))
{
if (preg_match('/^([^_]+)_([^_]+)/i', $ext_element, $regs)) {
$module = $regs[1];
$subelement = $regs[2];
}
@ -95,7 +102,9 @@ if (!empty($field) && !empty($element) && !empty($table_element) && !empty($fk_e
$classname = 'Actions'.ucfirst($subelement);
$object = new $classname($db);
$ret = $object->$methodname($fk_element);
if ($ret > 0) echo json_encode($object->$cachename);
if ($ret > 0) {
echo json_encode($object->$cachename);
}
}
} else {
$object = new GenericObject($db);

View File

@ -20,12 +20,24 @@
* This Ajax service is called when option MAIN_DIRECT_STATUS_UPDATE is set.
*/
if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal
if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1');
if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1');
if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1');
if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1');
if (!defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1');
if (!defined('NOTOKENRENEWAL')) {
define('NOTOKENRENEWAL', '1'); // Disables token renewal
}
if (!defined('NOREQUIREMENU')) {
define('NOREQUIREMENU', '1');
}
if (!defined('NOREQUIREHTML')) {
define('NOREQUIREHTML', '1');
}
if (!defined('NOREQUIREAJAX')) {
define('NOREQUIREAJAX', '1');
}
if (!defined('NOREQUIRESOC')) {
define('NOREQUIRESOC', '1');
}
if (!defined('NOREQUIRETRAN')) {
define('NOREQUIRETRAN', '1');
}
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php';
@ -74,7 +86,9 @@ if (($action == 'set') && !empty($id)) {
}
$tablename = $element;
if ($tablename == 'websitepage') $tablename = 'website_page';
if ($tablename == 'websitepage') {
$tablename = 'website_page';
}
$format = 'int';

View File

@ -20,12 +20,24 @@
* \brief File to save result of an anonymous ping into database (1 ping is done per installation)
*/
if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal
if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1');
if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1');
if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1');
if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1');
if (!defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1');
if (!defined('NOTOKENRENEWAL')) {
define('NOTOKENRENEWAL', '1'); // Disables token renewal
}
if (!defined('NOREQUIREMENU')) {
define('NOREQUIREMENU', '1');
}
if (!defined('NOREQUIREHTML')) {
define('NOREQUIREHTML', '1');
}
if (!defined('NOREQUIREAJAX')) {
define('NOREQUIREAJAX', '1');
}
if (!defined('NOREQUIRESOC')) {
define('NOREQUIRESOC', '1');
}
if (!defined('NOREQUIRETRAN')) {
define('NOREQUIRETRAN', '1');
}
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
@ -36,8 +48,9 @@ $hash_algo = GETPOST('hash_algo', 'alpha');
// Security check
if (!empty($user->socid))
if (!empty($user->socid)) {
$socid = $user->socid;
}
$now = dol_now();
@ -51,8 +64,7 @@ top_httphead();
print '<!-- Ajax page called with url '.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]).' -->'."\n";
// If ok
if ($action == 'firstpingok')
{
if ($action == 'firstpingok') {
// Note: pings are per installed instances / entity.
// Once this constants are set, no more ping will be tried (except if we add parameter &forceping=1 on URL). So we can say this are 'first' ping.
dolibarr_set_const($db, 'MAIN_FIRST_PING_OK_DATE', dol_print_date($now, 'dayhourlog', 'gmt'));
@ -61,8 +73,7 @@ if ($action == 'firstpingok')
print 'First ping OK saved for entity '.$conf->entity;
}
// If ko
elseif ($action == 'firstpingko')
{
elseif ($action == 'firstpingko') {
// Note: pings are by installation, done on entity 1.
dolibarr_set_const($db, 'MAIN_LAST_PING_KO_DATE', dol_print_date($now, 'dayhourlog'), 'gmt'); // erase last value
print 'First ping KO saved for entity '.$conf->entity;

View File

@ -20,10 +20,18 @@
* \brief File to get ht and ttc
*/
if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal
if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1');
if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1');
if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1');
if (!defined('NOTOKENRENEWAL')) {
define('NOTOKENRENEWAL', '1'); // Disables token renewal
}
if (!defined('NOREQUIREMENU')) {
define('NOREQUIREMENU', '1');
}
if (!defined('NOREQUIREAJAX')) {
define('NOREQUIREAJAX', '1');
}
if (!defined('NOREQUIRESOC')) {
define('NOREQUIRESOC', '1');
}
require '../../main.inc.php';
@ -40,13 +48,11 @@ top_httphead();
//print '<!-- Ajax page called with url '.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]).' -->'."\n";
// Load original field value
if (!empty($output) && isset($amount) && isset($tva_tx))
{
if (!empty($output) && isset($amount) && isset($tva_tx)) {
$return = array();
$price = '';
if (is_numeric($amount) && $amount != '')
{
if (is_numeric($amount) && $amount != '') {
if ($output == 'price_ttc') {
$price = price2num($amount * (1 + ($tva_tx / 100)), 'MU');
$return['price_ht'] = $amount;

View File

@ -27,12 +27,24 @@
* element_id (Example: 1)
*/
if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disable token renewal
if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1');
if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1');
if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1');
if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1');
if (!defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1');
if (!defined('NOTOKENRENEWAL')) {
define('NOTOKENRENEWAL', '1'); // Disable token renewal
}
if (!defined('NOREQUIREMENU')) {
define('NOREQUIREMENU', '1');
}
if (!defined('NOREQUIREHTML')) {
define('NOREQUIREHTML', '1');
}
if (!defined('NOREQUIREAJAX')) {
define('NOREQUIREAJAX', '1');
}
if (!defined('NOREQUIRESOC')) {
define('NOREQUIRESOC', '1');
}
if (!defined('NOREQUIRETRAN')) {
define('NOREQUIRETRAN', '1');
}
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php';
@ -48,8 +60,7 @@ print '<!-- Ajax page called with url '.dol_escape_htmltag($_SERVER["PHP_SELF"])
// Registering the location of boxes
if (GETPOST('roworder', 'alpha') && GETPOST('table_element_line', 'alpha', 2)
&& GETPOST('fk_element', 'alpha', 2) && GETPOST('element_id', 'int', 2))
{
&& GETPOST('fk_element', 'alpha', 2) && GETPOST('element_id', 'int', 2)) {
$roworder = GETPOST('roworder', 'alpha', 2);
$table_element_line = GETPOST('table_element_line', 'alpha', 2);
$fk_element = GETPOST('fk_element', 'alpha', 2);
@ -59,9 +70,10 @@ if (GETPOST('roworder', 'alpha') && GETPOST('table_element_line', 'alpha', 2)
$rowordertab = explode(',', $roworder);
$newrowordertab = array();
foreach ($rowordertab as $value)
{
if (!empty($value)) $newrowordertab[] = $value;
foreach ($rowordertab as $value) {
if (!empty($value)) {
$newrowordertab[] = $value;
}
}
$row = new GenericObject($db);
@ -73,8 +85,7 @@ if (GETPOST('roworder', 'alpha') && GETPOST('table_element_line', 'alpha', 2)
// Reorder line to have position of children lines sharing same counter than parent lines
// This should be useless because there is no need to have children sharing same counter than parent, but well, it's cleaner into database.
if (in_array($fk_element, array('fk_facture', 'fk_propal', 'fk_commande')))
{
if (in_array($fk_element, array('fk_facture', 'fk_propal', 'fk_commande'))) {
$result = $row->line_order(true);
}
}

View File

@ -20,10 +20,18 @@
* \brief File to save field value
*/
if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal
if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1');
if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1');
if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1');
if (!defined('NOTOKENRENEWAL')) {
define('NOTOKENRENEWAL', '1'); // Disables token renewal
}
if (!defined('NOREQUIREMENU')) {
define('NOREQUIREMENU', '1');
}
if (!defined('NOREQUIREAJAX')) {
define('NOREQUIREAJAX', '1');
}
if (!defined('NOREQUIRESOC')) {
define('NOREQUIRESOC', '1');
}
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php';
@ -56,8 +64,7 @@ top_httphead();
//print_r($_POST);
// Load original field value
if (!empty($field) && !empty($element) && !empty($table_element) && !empty($fk_element))
{
if (!empty($field) && !empty($element) && !empty($table_element) && !empty($fk_element)) {
$ext_element = GETPOST('ext_element', 'alpha', 2);
$field = substr($field, 8); // remove prefix val_
$type = GETPOST('type', 'alpha', 2);
@ -124,18 +131,15 @@ if (!empty($field) && !empty($element) && !empty($table_element) && !empty($fk_e
|| ($element == 'payment_supplier' && $user->rights->fournisseur->facture->creer))
*/
if ($check_access)
{
if ($check_access) {
// Clean parameters
$newvalue = trim($value);
if ($type == 'numeric')
{
if ($type == 'numeric') {
$newvalue = price2num($newvalue);
// Check parameters
if (!is_numeric($newvalue))
{
if (!is_numeric($newvalue)) {
$error++;
$return['error'] = $langs->trans('ErrorBadValue');
}
@ -149,16 +153,13 @@ if (!empty($field) && !empty($element) && !empty($table_element) && !empty($fk_e
$loadviewname = 'view_'.$loadmethod;
$form = new Form($db);
if (method_exists($form, $loadmethodname))
{
if (method_exists($form, $loadmethodname)) {
$ret = $form->$loadmethodname();
if ($ret > 0)
{
if ($ret > 0) {
$loadcache = $form->$loadcachename;
$value = $loadcache[$newvalue];
if (!empty($form->$loadviewname))
{
if (!empty($form->$loadviewname)) {
$loadview = $form->$loadviewname;
$view = $loadview[$newvalue];
}
@ -168,8 +169,7 @@ if (!empty($field) && !empty($element) && !empty($table_element) && !empty($fk_e
}
} else {
$module = $subelement = $ext_element;
if (preg_match('/^([^_]+)_([^_]+)/i', $ext_element, $regs))
{
if (preg_match('/^([^_]+)_([^_]+)/i', $ext_element, $regs)) {
$module = $regs[1];
$subelement = $regs[2];
}
@ -178,13 +178,11 @@ if (!empty($field) && !empty($element) && !empty($table_element) && !empty($fk_e
$classname = 'Actions'.ucfirst($subelement);
$object = new $classname($db);
$ret = $object->$loadmethodname();
if ($ret > 0)
{
if ($ret > 0) {
$loadcache = $object->$loadcachename;
$value = $loadcache[$newvalue];
if (!empty($object->$loadviewname))
{
if (!empty($object->$loadviewname)) {
$loadview = $object->$loadviewname;
$view = $loadview[$newvalue];
}
@ -195,9 +193,10 @@ if (!empty($field) && !empty($element) && !empty($table_element) && !empty($fk_e
}
}
if (!$error)
{
if ((isset($object) && !is_object($object)) || empty($savemethod)) $object = new GenericObject($db);
if (!$error) {
if ((isset($object) && !is_object($object)) || empty($savemethod)) {
$object = new GenericObject($db);
}
// Specific for add_object_linked()
// TODO add a function for variable treatment
@ -207,10 +206,12 @@ if (!empty($field) && !empty($element) && !empty($table_element) && !empty($fk_e
$object->element = $element;
$ret = $object->$savemethodname($field, $newvalue, $table_element, $fk_element, $format);
if ($ret > 0)
{
if ($type == 'numeric') $value = price($newvalue);
elseif ($type == 'textarea') $value = dol_nl2br($newvalue);
if ($ret > 0) {
if ($type == 'numeric') {
$value = price($newvalue);
} elseif ($type == 'textarea') {
$value = dol_nl2br($newvalue);
}
$return['value'] = $value;
$return['view'] = (!empty($view) ? $view : $value);

View File

@ -21,12 +21,24 @@
* like key to use into URL to protect them.
*/
if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal
if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1');
if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1');
if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1');
if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1');
if (!defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1');
if (!defined('NOTOKENRENEWAL')) {
define('NOTOKENRENEWAL', '1'); // Disables token renewal
}
if (!defined('NOREQUIREMENU')) {
define('NOREQUIREMENU', '1');
}
if (!defined('NOREQUIREHTML')) {
define('NOREQUIREHTML', '1');
}
if (!defined('NOREQUIREAJAX')) {
define('NOREQUIREAJAX', '1');
}
if (!defined('NOREQUIRESOC')) {
define('NOREQUIRESOC', '1');
}
if (!defined('NOREQUIRETRAN')) {
define('NOREQUIRETRAN', '1');
}
require '../../main.inc.php';
@ -40,10 +52,8 @@ top_httphead();
//print '<!-- Ajax page called with url '.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]).' -->'."\n";
// Registering the location of boxes
if (isset($_GET['action']) && !empty($_GET['action']))
{
if ($_GET['action'] == 'getrandompassword' && $user->admin)
{
if (isset($_GET['action']) && !empty($_GET['action'])) {
if ($_GET['action'] == 'getrandompassword' && $user->admin) {
require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
$generic = $_GET['generic'] ? true : false;
echo getRandomPassword($generic);

View File

@ -20,12 +20,24 @@
* \brief File to return Ajax response on a selection list request
*/
if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); // Disables token renewal
if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1');
if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1');
if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1');
if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1');
if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1');
if (!defined('NOTOKENRENEWAL')) {
define('NOTOKENRENEWAL', 1); // Disables token renewal
}
if (!defined('NOREQUIREMENU')) {
define('NOREQUIREMENU', '1');
}
if (!defined('NOREQUIREHTML')) {
define('NOREQUIREHTML', '1');
}
if (!defined('NOREQUIREAJAX')) {
define('NOREQUIREAJAX', '1');
}
if (!defined('NOREQUIRESOC')) {
define('NOREQUIRESOC', '1');
}
if (!defined('NOCSRFCHECK')) {
define('NOCSRFCHECK', '1');
}
require '../../main.inc.php';
@ -54,22 +66,21 @@ $form = new Form($db);
top_httphead();
if (empty($htmlname)) return;
if (empty($htmlname)) {
return;
}
$InfoFieldList = explode(":", $objectdesc);
$classname = $InfoFieldList[0];
$classpath = $InfoFieldList[1];
if (!empty($classpath))
{
if (!empty($classpath)) {
dol_include_once($classpath);
if ($classname && class_exists($classname))
{
if ($classname && class_exists($classname)) {
$objecttmp = new $classname($db);
}
}
if (!is_object($objecttmp))
{
if (!is_object($objecttmp)) {
dol_syslog('Error bad param objectdesc', LOG_WARNING);
print 'Error bad param objectdesc';
}
@ -84,4 +95,6 @@ $arrayresult = $form->selectForFormsList($objecttmp, $htmlname, '', 0, $searchke
$db->close();
if ($outjson) print json_encode($arrayresult);
if ($outjson) {
print json_encode($arrayresult);
}

View File

@ -24,21 +24,31 @@
// This script is called with a POST method or as an include.
if (!isset($usedbyinclude) || empty($usedbyinclude))
{
if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); // Disables token renewal
if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1');
if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1');
if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1');
if (!defined('NOREDIRECTBYMAINTOLOGIN')) define('NOREDIRECTBYMAINTOLOGIN', '1');
if (!isset($usedbyinclude) || empty($usedbyinclude)) {
if (!defined('NOTOKENRENEWAL')) {
define('NOTOKENRENEWAL', 1); // Disables token renewal
}
if (!defined('NOREQUIREMENU')) {
define('NOREQUIREMENU', '1');
}
if (!defined('NOREQUIREHTML')) {
define('NOREQUIREHTML', '1');
}
if (!defined('NOREQUIREAJAX')) {
define('NOREQUIREAJAX', '1');
}
if (!defined('NOREDIRECTBYMAINTOLOGIN')) {
define('NOREDIRECTBYMAINTOLOGIN', '1');
}
$res = @include '../../main.inc.php';
if ($res == 'ERROR_NOT_LOGGED')
{
if ($res == 'ERROR_NOT_LOGGED') {
$langs->load("other");
$arrayresult['jumptologin'] = array('img'=>'object_generic', 'label'=>$langs->trans("JumpToLogin"), 'text'=>'<span class="fa fa-sign-in"></span> '.$langs->trans("JumpToLogin"), 'url'=>DOL_URL_ROOT.'/index.php');
print json_encode($arrayresult);
if (is_object($db)) $db->close();
if (is_object($db)) {
$db->close();
}
exit;
}
}
@ -54,74 +64,59 @@ $arrayresult = array();
// Define $searchform
if (!empty($conf->adherent->enabled) && empty($conf->global->MAIN_SEARCHFORM_ADHERENT_DISABLED) && $user->rights->adherent->lire)
{
if (!empty($conf->adherent->enabled) && empty($conf->global->MAIN_SEARCHFORM_ADHERENT_DISABLED) && $user->rights->adherent->lire) {
$arrayresult['searchintomember'] = array('position'=>8, 'shortcut'=>'M', 'img'=>'object_member', 'label'=>$langs->trans("SearchIntoMembers", $search_boxvalue), 'text'=>img_picto('', 'object_member').' '.$langs->trans("SearchIntoMembers", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/adherents/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : ''));
}
if (((!empty($conf->societe->enabled) && (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) || empty($conf->global->SOCIETE_DISABLE_CUSTOMERS))) || !empty($conf->fournisseur->enabled)) && empty($conf->global->MAIN_SEARCHFORM_SOCIETE_DISABLED) && $user->rights->societe->lire)
{
if (((!empty($conf->societe->enabled) && (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) || empty($conf->global->SOCIETE_DISABLE_CUSTOMERS))) || !empty($conf->fournisseur->enabled)) && empty($conf->global->MAIN_SEARCHFORM_SOCIETE_DISABLED) && $user->rights->societe->lire) {
$arrayresult['searchintothirdparty'] = array('position'=>10, 'shortcut'=>'T', 'img'=>'object_company', 'label'=>$langs->trans("SearchIntoThirdparties", $search_boxvalue), 'text'=>img_picto('', 'object_company').' '.$langs->trans("SearchIntoThirdparties", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/societe/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : ''));
}
if (!empty($conf->societe->enabled) && empty($conf->global->MAIN_SEARCHFORM_CONTACT_DISABLED) && $user->rights->societe->lire)
{
if (!empty($conf->societe->enabled) && empty($conf->global->MAIN_SEARCHFORM_CONTACT_DISABLED) && $user->rights->societe->lire) {
$arrayresult['searchintocontact'] = array('position'=>15, 'shortcut'=>'A', 'img'=>'object_contact', 'label'=>$langs->trans("SearchIntoContacts", $search_boxvalue), 'text'=>img_picto('', 'object_contact').' '.$langs->trans("SearchIntoContacts", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/contact/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : ''));
}
if (((!empty($conf->product->enabled) && $user->rights->produit->lire) || (!empty($conf->service->enabled) && $user->rights->service->lire))
&& empty($conf->global->MAIN_SEARCHFORM_PRODUITSERVICE_DISABLED))
{
&& empty($conf->global->MAIN_SEARCHFORM_PRODUITSERVICE_DISABLED)) {
$arrayresult['searchintoproduct'] = array('position'=>30, 'shortcut'=>'P', 'img'=>'object_product', 'label'=>$langs->trans("SearchIntoProductsOrServices", $search_boxvalue), 'text'=>img_picto('', 'object_product').' '.$langs->trans("SearchIntoProductsOrServices", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/product/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : ''));
}
if (!empty($conf->mrp->enabled) && $user->rights->mrp->read && empty($conf->global->MAIN_SEARCHFORM_MRP_DISABLED))
{
if (!empty($conf->mrp->enabled) && $user->rights->mrp->read && empty($conf->global->MAIN_SEARCHFORM_MRP_DISABLED)) {
$arrayresult['searchintomo'] = array('position'=>35, 'shortcut'=>'', 'img'=>'object_mrp', 'label'=>$langs->trans("SearchIntoMO", $search_boxvalue), 'text'=>img_picto('', 'object_mrp').' '.$langs->trans("SearchIntoMO", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/mrp/mo_list.php'.($search_boxvalue ? '?search_all='.urlencode($search_boxvalue) : ''));
}
if (!empty($conf->projet->enabled) && empty($conf->global->MAIN_SEARCHFORM_PROJECT_DISABLED) && $user->rights->projet->lire)
{
if (!empty($conf->projet->enabled) && empty($conf->global->MAIN_SEARCHFORM_PROJECT_DISABLED) && $user->rights->projet->lire) {
$arrayresult['searchintoprojects'] = array('position'=>40, 'shortcut'=>'Q', 'img'=>'object_project', 'label'=>$langs->trans("SearchIntoProjects", $search_boxvalue), 'text'=>img_picto('', 'object_project').' '.$langs->trans("SearchIntoProjects", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/projet/list.php'.($search_boxvalue ? '?search_all='.urlencode($search_boxvalue) : ''));
}
if (!empty($conf->projet->enabled) && empty($conf->global->MAIN_SEARCHFORM_TASK_DISABLED) && $user->rights->projet->lire)
{
if (!empty($conf->projet->enabled) && empty($conf->global->MAIN_SEARCHFORM_TASK_DISABLED) && $user->rights->projet->lire) {
$arrayresult['searchintotasks'] = array('position'=>45, 'img'=>'object_projecttask', 'label'=>$langs->trans("SearchIntoTasks", $search_boxvalue), 'text'=>img_picto('', 'object_projecttask').' '.$langs->trans("SearchIntoTasks", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/projet/tasks/list.php'.($search_boxvalue ? '?search_all='.urlencode($search_boxvalue) : ''));
}
if (!empty($conf->propal->enabled) && empty($conf->global->MAIN_SEARCHFORM_CUSTOMER_PROPAL_DISABLED) && $user->rights->propal->lire)
{
if (!empty($conf->propal->enabled) && empty($conf->global->MAIN_SEARCHFORM_CUSTOMER_PROPAL_DISABLED) && $user->rights->propal->lire) {
$arrayresult['searchintopropal'] = array('position'=>60, 'img'=>'object_propal', 'label'=>$langs->trans("SearchIntoCustomerProposals", $search_boxvalue), 'text'=>img_picto('', 'object_propal').' '.$langs->trans("SearchIntoCustomerProposals", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/comm/propal/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : ''));
}
if (!empty($conf->commande->enabled) && empty($conf->global->MAIN_SEARCHFORM_CUSTOMER_ORDER_DISABLED) && $user->rights->commande->lire)
{
if (!empty($conf->commande->enabled) && empty($conf->global->MAIN_SEARCHFORM_CUSTOMER_ORDER_DISABLED) && $user->rights->commande->lire) {
$arrayresult['searchintoorder'] = array('position'=>70, 'img'=>'object_order', 'label'=>$langs->trans("SearchIntoCustomerOrders", $search_boxvalue), 'text'=>img_picto('', 'object_order').' '.$langs->trans("SearchIntoCustomerOrders", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/commande/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : ''));
}
if (!empty($conf->expedition->enabled) && empty($conf->global->MAIN_SEARCHFORM_CUSTOMER_SHIPMENT_DISABLED) && $user->rights->expedition->lire)
{
if (!empty($conf->expedition->enabled) && empty($conf->global->MAIN_SEARCHFORM_CUSTOMER_SHIPMENT_DISABLED) && $user->rights->expedition->lire) {
$arrayresult['searchintoshipment'] = array('position'=>80, 'img'=>'object_shipment', 'label'=>$langs->trans("SearchIntoCustomerShipments", $search_boxvalue), 'text'=>img_picto('', 'object_shipment').' '.$langs->trans("SearchIntoCustomerShipments", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/expedition/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : ''));
}
if (!empty($conf->facture->enabled) && empty($conf->global->MAIN_SEARCHFORM_CUSTOMER_INVOICE_DISABLED) && $user->rights->facture->lire)
{
if (!empty($conf->facture->enabled) && empty($conf->global->MAIN_SEARCHFORM_CUSTOMER_INVOICE_DISABLED) && $user->rights->facture->lire) {
$arrayresult['searchintoinvoice'] = array('position'=>90, 'img'=>'object_bill', 'label'=>$langs->trans("SearchIntoCustomerInvoices", $search_boxvalue), 'text'=>img_picto('', 'object_bill').' '.$langs->trans("SearchIntoCustomerInvoices", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/compta/facture/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : ''));
}
if (!empty($conf->supplier_proposal->enabled) && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_PROPAL_DISABLED) && $user->rights->supplier_proposal->lire)
{
if (!empty($conf->supplier_proposal->enabled) && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_PROPAL_DISABLED) && $user->rights->supplier_proposal->lire) {
$arrayresult['searchintosupplierpropal'] = array('position'=>100, 'img'=>'object_propal', 'label'=>$langs->trans("SearchIntoSupplierProposals", $search_boxvalue), 'text'=>img_picto('', 'object_supplier_proposal').' '.$langs->trans("SearchIntoSupplierProposals", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/supplier_proposal/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : ''));
}
if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_ORDER_DISABLED) || !empty($conf->supplier_order->enabled)) && $user->rights->fournisseur->commande->lire)
{
if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_ORDER_DISABLED) || !empty($conf->supplier_order->enabled)) && $user->rights->fournisseur->commande->lire) {
$arrayresult['searchintosupplierorder'] = array('position'=>110, 'img'=>'object_order', 'label'=>$langs->trans("SearchIntoSupplierOrders", $search_boxvalue), 'text'=>img_picto('', 'object_supplier_order').' '.$langs->trans("SearchIntoSupplierOrders", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/fourn/commande/list.php'.($search_boxvalue ? '?search_all='.urlencode($search_boxvalue) : ''));
}
if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_INVOICE_DISABLED) || !empty($conf->supplier_invoice->enabled)) && $user->rights->fournisseur->facture->lire)
{
if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_INVOICE_DISABLED) || !empty($conf->supplier_invoice->enabled)) && $user->rights->fournisseur->facture->lire) {
$arrayresult['searchintosupplierinvoice'] = array('position'=>120, 'img'=>'object_bill', 'label'=>$langs->trans("SearchIntoSupplierInvoices", $search_boxvalue), 'text'=>img_picto('', 'object_supplier_invoice').' '.$langs->trans("SearchIntoSupplierInvoices", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/fourn/facture/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : ''));
}
// Customer payments
if (!empty($conf->facture->enabled) && empty($conf->global->MAIN_SEARCHFORM_CUSTOMER_INVOICE_DISABLED) && $user->rights->facture->lire)
{
if (!empty($conf->facture->enabled) && empty($conf->global->MAIN_SEARCHFORM_CUSTOMER_INVOICE_DISABLED) && $user->rights->facture->lire) {
$arrayresult['searchintocustomerpayments'] = array(
'position'=>170,
'img'=>'object_payment',
@ -131,8 +126,7 @@ if (!empty($conf->facture->enabled) && empty($conf->global->MAIN_SEARCHFORM_CUST
}
// Vendor payments
if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_INVOICE_DISABLED) || !empty($conf->supplier_invoice->enabled)) && $user->rights->fournisseur->facture->lire)
{
if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_INVOICE_DISABLED) || !empty($conf->supplier_invoice->enabled)) && $user->rights->fournisseur->facture->lire) {
$arrayresult['searchintovendorpayments'] = array(
'position'=>175,
'img'=>'object_payment',
@ -142,8 +136,7 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_SEARCHFORM
}
// Miscellaneous payments
if (!empty($conf->banque->enabled) && empty($conf->global->MAIN_SEARCHFORM_MISC_PAYMENTS_DISABLED) && $user->rights->banque->lire)
{
if (!empty($conf->banque->enabled) && empty($conf->global->MAIN_SEARCHFORM_MISC_PAYMENTS_DISABLED) && $user->rights->banque->lire) {
$arrayresult['searchintomiscpayments'] = array(
'position'=>180,
'img'=>'object_payment',
@ -152,53 +145,51 @@ if (!empty($conf->banque->enabled) && empty($conf->global->MAIN_SEARCHFORM_MISC_
'url'=>DOL_URL_ROOT.'/compta/bank/various_payment/list.php?leftmenu=tax_various'.($search_boxvalue ? '&sall='.urlencode($search_boxvalue) : ''));
}
if (!empty($conf->contrat->enabled) && empty($conf->global->MAIN_SEARCHFORM_CONTRACT_DISABLED) && $user->rights->contrat->lire)
{
if (!empty($conf->contrat->enabled) && empty($conf->global->MAIN_SEARCHFORM_CONTRACT_DISABLED) && $user->rights->contrat->lire) {
$arrayresult['searchintocontract'] = array('position'=>130, 'img'=>'object_contract', 'label'=>$langs->trans("SearchIntoContracts", $search_boxvalue), 'text'=>img_picto('', 'object_contract').' '.$langs->trans("SearchIntoContracts", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/contrat/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : ''));
}
if (!empty($conf->ficheinter->enabled) && empty($conf->global->MAIN_SEARCHFORM_FICHINTER_DISABLED) && $user->rights->ficheinter->lire)
{
if (!empty($conf->ficheinter->enabled) && empty($conf->global->MAIN_SEARCHFORM_FICHINTER_DISABLED) && $user->rights->ficheinter->lire) {
$arrayresult['searchintointervention'] = array('position'=>140, 'img'=>'object_intervention', 'label'=>$langs->trans("SearchIntoInterventions", $search_boxvalue), 'text'=>img_picto('', 'object_intervention').' '.$langs->trans("SearchIntoInterventions", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/fichinter/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : ''));
}
if (!empty($conf->ticket->enabled) && empty($conf->global->MAIN_SEARCHFORM_TICKET_DISABLED) && $user->rights->ticket->read)
{
if (!empty($conf->ticket->enabled) && empty($conf->global->MAIN_SEARCHFORM_TICKET_DISABLED) && $user->rights->ticket->read) {
$arrayresult['searchintotickets'] = array('position'=>145, 'img'=>'object_ticket', 'label'=>$langs->trans("SearchIntoTickets", $search_boxvalue), 'text'=>img_picto('', 'object_ticket').' '.$langs->trans("SearchIntoTickets", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/ticket/list.php?mainmenu=ticket'.($search_boxvalue ? '&sall='.urlencode($search_boxvalue) : ''));
}
// HR
if (!empty($conf->user->enabled) && empty($conf->global->MAIN_SEARCHFORM_USER_DISABLED) && $user->rights->user->user->lire)
{
if (!empty($conf->user->enabled) && empty($conf->global->MAIN_SEARCHFORM_USER_DISABLED) && $user->rights->user->user->lire) {
$arrayresult['searchintouser'] = array('position'=>200, 'shortcut'=>'U', 'img'=>'object_user', 'label'=>$langs->trans("SearchIntoUsers", $search_boxvalue), 'text'=>img_picto('', 'object_user').' '.$langs->trans("SearchIntoUsers", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/user/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : ''));
}
if (!empty($conf->expensereport->enabled) && empty($conf->global->MAIN_SEARCHFORM_EXPENSEREPORT_DISABLED) && $user->rights->expensereport->lire)
{
if (!empty($conf->expensereport->enabled) && empty($conf->global->MAIN_SEARCHFORM_EXPENSEREPORT_DISABLED) && $user->rights->expensereport->lire) {
$arrayresult['searchintoexpensereport'] = array('position'=>210, 'img'=>'object_trip', 'label'=>$langs->trans("SearchIntoExpenseReports", $search_boxvalue), 'text'=>img_picto('', 'object_trip').' '.$langs->trans("SearchIntoExpenseReports", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/expensereport/list.php?mainmenu=hrm'.($search_boxvalue ? '&sall='.urlencode($search_boxvalue) : ''));
}
if (!empty($conf->holiday->enabled) && empty($conf->global->MAIN_SEARCHFORM_HOLIDAY_DISABLED) && $user->rights->holiday->read)
{
if (!empty($conf->holiday->enabled) && empty($conf->global->MAIN_SEARCHFORM_HOLIDAY_DISABLED) && $user->rights->holiday->read) {
$arrayresult['searchintoleaves'] = array('position'=>220, 'img'=>'object_holiday', 'label'=>$langs->trans("SearchIntoLeaves", $search_boxvalue), 'text'=>img_picto('', 'object_holiday').' '.$langs->trans("SearchIntoLeaves", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/holiday/list.php?mainmenu=hrm'.($search_boxvalue ? '&sall='.urlencode($search_boxvalue) : ''));
}
// Execute hook addSearchEntry
$parameters = array('search_boxvalue'=>$search_boxvalue, 'arrayresult'=>$arrayresult);
$reshook = $hookmanager->executeHooks('addSearchEntry', $parameters);
if (empty($reshook))
{
if (empty($reshook)) {
$arrayresult = array_merge($arrayresult, $hookmanager->resArray);
} else $arrayresult = $hookmanager->resArray;
} else {
$arrayresult = $hookmanager->resArray;
}
// This pushes a search entry to the top
if (!empty($conf->global->DEFAULT_SEARCH_INTO_MODULE)) {
$key = 'searchinto'.$conf->global->DEFAULT_SEARCH_INTO_MODULE;
if (array_key_exists($key, $arrayresult)) $arrayresult[$key]['position'] = -1000;
if (array_key_exists($key, $arrayresult)) {
$arrayresult[$key]['position'] = -1000;
}
}
// Sort on position
$arrayresult = dol_sort_array($arrayresult, 'position');
// Print output if called by ajax or do nothing (var $arrayresult will be used) if called by an include
if (!isset($usedbyinclude) || empty($usedbyinclude))
{
if (!isset($usedbyinclude) || empty($usedbyinclude)) {
print json_encode($arrayresult);
if (is_object($db)) $db->close();
if (is_object($db)) {
$db->close();
}
}

View File

@ -20,9 +20,15 @@
* \brief File to load vat rates combobox
*/
if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal
if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1');
if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1');
if (!defined('NOTOKENRENEWAL')) {
define('NOTOKENRENEWAL', '1'); // Disables token renewal
}
if (!defined('NOREQUIREMENU')) {
define('NOREQUIREMENU', '1');
}
if (!defined('NOREQUIREAJAX')) {
define('NOREQUIREAJAX', '1');
}
require '../../main.inc.php';
@ -41,15 +47,13 @@ top_httphead();
//print '<!-- Ajax page called with url '.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]).' -->'."\n";
// Load original field value
if (!empty($id) && !empty($action) && !empty($htmlname))
{
if (!empty($id) && !empty($action) && !empty($htmlname)) {
$form = new Form($db);
$soc = new Societe($db);
$soc->fetch($id);
if ($action == 'getSellerVATRates')
{
if ($action == 'getSellerVATRates') {
$seller = $mysoc;
$buyer = $soc;
} else {

View File

@ -22,12 +22,24 @@
* \brief File to return Ajax response on zipcode or town request
*/
if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); // Disables token renewal
if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1');
if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1');
if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1');
if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1');
if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1');
if (!defined('NOTOKENRENEWAL')) {
define('NOTOKENRENEWAL', 1); // Disables token renewal
}
if (!defined('NOREQUIREMENU')) {
define('NOREQUIREMENU', '1');
}
if (!defined('NOREQUIREHTML')) {
define('NOREQUIREHTML', '1');
}
if (!defined('NOREQUIREAJAX')) {
define('NOREQUIREAJAX', '1');
}
if (!defined('NOREQUIRESOC')) {
define('NOREQUIRESOC', '1');
}
if (!defined('NOCSRFCHECK')) {
define('NOCSRFCHECK', '1');
}
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
@ -51,8 +63,7 @@ dol_syslog("GET is ".join(',', $_GET).', MAIN_USE_ZIPTOWN_DICTIONNARY='.(empty($
//var_dump($_GET);
// Generation of list of zip-town
if (!empty($_GET['zipcode']) || !empty($_GET['town']))
{
if (!empty($_GET['zipcode']) || !empty($_GET['town'])) {
$return_arr = array();
$formcompany = new FormCompany($db);
@ -60,8 +71,7 @@ if (!empty($_GET['zipcode']) || !empty($_GET['town']))
$zipcode = $_GET['zipcode'] ? $_GET['zipcode'] : '';
$town = $_GET['town'] ? $_GET['town'] : '';
if (!empty($conf->global->MAIN_USE_ZIPTOWN_DICTIONNARY)) // Use zip-town table
{
if (!empty($conf->global->MAIN_USE_ZIPTOWN_DICTIONNARY)) { // Use zip-town table
$sql = "SELECT z.rowid, z.zip, z.town, z.fk_county, z.fk_pays as fk_country";
$sql .= ", c.rowid as fk_country, c.code as country_code, c.label as country";
$sql .= ", d.rowid as fk_county, d.code_departement as county_code, d.nom as county";
@ -71,8 +81,12 @@ if (!empty($_GET['zipcode']) || !empty($_GET['town']))
$sql .= " ".MAIN_DB_PREFIX."c_country as c";
$sql .= " WHERE z.fk_pays = c.rowid";
$sql .= " AND z.active = 1 AND c.active = 1";
if ($zipcode) $sql .= " AND z.zip LIKE '".$db->escape($zipcode)."%'";
if ($town) $sql .= " AND z.town LIKE '%".$db->escape($town)."%'";
if ($zipcode) {
$sql .= " AND z.zip LIKE '".$db->escape($zipcode)."%'";
}
if ($town) {
$sql .= " AND z.town LIKE '%".$db->escape($town)."%'";
}
$sql .= " ORDER BY z.zip, z.town";
$sql .= $db->plimit(100); // Avoid pb with bad criteria
} else // Use table of third parties
@ -84,8 +98,12 @@ if (!empty($_GET['zipcode']) || !empty($_GET['town']))
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as d ON s.fk_departement = d.rowid";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid';
$sql .= " WHERE";
if ($zipcode) $sql .= " s.zip LIKE '".$db->escape($zipcode)."%'";
if ($town) $sql .= " s.town LIKE '%".$db->escape($town)."%'";
if ($zipcode) {
$sql .= " s.zip LIKE '".$db->escape($zipcode)."%'";
}
if ($town) {
$sql .= " s.town LIKE '%".$db->escape($town)."%'";
}
$sql .= " ORDER BY s.fk_pays, s.zip, s.town";
$sql .= $db->plimit(100); // Avoid pb with bad criteria
}
@ -93,10 +111,8 @@ if (!empty($_GET['zipcode']) || !empty($_GET['town']))
//print $sql;
$resql = $db->query($sql);
//var_dump($db);
if ($resql)
{
while ($row = $db->fetch_array($resql))
{
if ($resql) {
while ($row = $db->fetch_array($resql)) {
$country = $row['fk_country'] ? ($langs->transnoentitiesnoconv('Country'.$row['country_code']) != 'Country'.$row['country_code'] ? $langs->transnoentitiesnoconv('Country'.$row['country_code']) : $row['country']) : '';
$county = $row['fk_county'] ? ($langs->transnoentitiesnoconv($row['county_code']) != $row['county_code'] ? $langs->transnoentitiesnoconv($row['county_code']) : ($row['county'] != '-' ? $row['county'] : '')) : '';
@ -106,13 +122,11 @@ if (!empty($_GET['zipcode']) || !empty($_GET['town']))
$row_array['label'] .= ($county && $country ? ' - ' : '');
$row_array['label'] .= $country;
$row_array['label'] .= ($county || $country) ? ')' : '';
if ($zipcode)
{
if ($zipcode) {
$row_array['value'] = $row['zip'];
$row_array['town'] = $row['town'];
}
if ($town)
{
if ($town) {
$row_array['value'] = $row['town'];
$row_array['zipcode'] = $row['zip'];
}

View File

@ -23,12 +23,24 @@
define('NOLOGIN', 1);
if (!defined('NOREQUIREUSER')) define('NOREQUIREUSER', 1);
if (!defined('NOREQUIREDB')) define('NOREQUIREDB', 1);
if (!defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', 1);
if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', 1);
if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', 1);
if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1);
if (!defined('NOREQUIREUSER')) {
define('NOREQUIREUSER', 1);
}
if (!defined('NOREQUIREDB')) {
define('NOREQUIREDB', 1);
}
if (!defined('NOREQUIRETRAN')) {
define('NOREQUIRETRAN', 1);
}
if (!defined('NOREQUIREMENU')) {
define('NOREQUIREMENU', 1);
}
if (!defined('NOREQUIRESOC')) {
define('NOREQUIRESOC', 1);
}
if (!defined('NOTOKENRENEWAL')) {
define('NOTOKENRENEWAL', 1);
}
require_once '../main.inc.php';
@ -41,8 +53,7 @@ $length = 5;
$letters = 'aAbBCDeEFgGhHJKLmMnNpPqQRsStTuVwWXYZz2345679';
$number = strlen($letters);
$string = '';
for ($i = 0; $i < $length; $i++)
{
for ($i = 0; $i < $length; $i++) {
$string .= $letters[mt_rand(0, $number - 1)];
}
//print $string;
@ -52,8 +63,7 @@ $sessionkey = 'dol_antispam_value';
$_SESSION[$sessionkey] = $string;
$img = imagecreate(80, 32);
if (empty($img))
{
if (empty($img)) {
dol_print_error('', "Problem with GD creation");
exit;
}

View File

@ -79,8 +79,7 @@ class box_accountancy_last_manual_entries extends ModeleBoxes
$this->info_box_head = array('text' => $langs->trans("BoxTitleLastManualEntries", $max));
if ($user->rights->accounting->mouvements->lire)
{
if ($user->rights->accounting->mouvements->lire) {
$sql = "SELECT DISTINCT b.piece_num";
$sql .= ", b.doc_date as date_movement";
$sql .= ", b.label_operation";
@ -140,10 +139,12 @@ class box_accountancy_last_manual_entries extends ModeleBoxes
$line++;
}
if ($num == 0) $this->info_box_contents[$line][0] = array(
if ($num == 0) {
$this->info_box_contents[$line][0] = array(
'td' => 'class="center"',
'text'=> '<span class="opacitymedium">'.$langs->trans("NoRecordedManualEntries").'</span>'
);
);
}
$this->db->free($result);
} else {

View File

@ -78,11 +78,9 @@ class box_accountancy_suspense_account extends ModeleBoxes
$this->info_box_head = array('text' => $langs->trans("BoxTitleSuspenseAccount"));
if ($user->rights->accounting->mouvements->lire)
{
if ($user->rights->accounting->mouvements->lire) {
$suspenseAccount = $conf->global->ACCOUNTING_ACCOUNT_SUSPENSE;
if (!empty($suspenseAccount) && $suspenseAccount > 0)
{
if (!empty($suspenseAccount) && $suspenseAccount > 0) {
$sql = "SELECT COUNT(*) as nb_suspense_account";
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b";
$sql .= " WHERE b.numero_compte = ".$suspenseAccount;
@ -90,8 +88,7 @@ class box_accountancy_suspense_account extends ModeleBoxes
$result = $this->db->query($sql);
$nbSuspenseAccount = 0;
if ($result)
{
if ($result) {
$obj = $this->db->fetch_object($result);
$nbSuspenseAccount = $obj->nb_suspense_account;
}

View File

@ -92,14 +92,22 @@ class box_actions extends ModeleBoxes
$sql .= ", s.code_client, s.code_compta, s.client";
$sql .= ", s.logo, s.email, s.entity";
$sql .= " FROM ".MAIN_DB_PREFIX."c_actioncomm AS ta, ".MAIN_DB_PREFIX."actioncomm AS a";
if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc";
if (!$user->rights->societe->client->voir && !$user->socid) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc";
}
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid";
$sql .= " WHERE a.fk_action = ta.id";
$sql .= " AND a.entity IN (".getEntity('actioncomm').")";
$sql .= " AND a.percent >= 0 AND a.percent < 100";
if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND (a.fk_soc IS NULL OR sc.fk_user = ".$user->id.")";
if ($user->socid) $sql .= " AND s.rowid = ".$user->socid;
if (!$user->rights->agenda->allactions->read) $sql .= " AND (a.fk_user_author = ".$user->id." OR a.fk_user_action = ".$user->id." OR a.fk_user_done = ".$user->id.")";
if (!$user->rights->societe->client->voir && !$user->socid) {
$sql .= " AND (a.fk_soc IS NULL OR sc.fk_user = ".$user->id.")";
}
if ($user->socid) {
$sql .= " AND s.rowid = ".$user->socid;
}
if (!$user->rights->agenda->allactions->read) {
$sql .= " AND (a.fk_user_author = ".$user->id." OR a.fk_user_action = ".$user->id." OR a.fk_user_done = ".$user->id.")";
}
$sql .= " ORDER BY a.datec DESC";
$sql .= $this->db->plimit($max, 0);
@ -132,8 +140,9 @@ class box_actions extends ModeleBoxes
$societestatic->email = $objp->email;
$societestatic->entity = $objp->entity;
if ($objp->percentage >= 0 && $objp->percentage < 100 && $datelimite < ($now - $delay_warning))
if ($objp->percentage >= 0 && $objp->percentage < 100 && $datelimite < ($now - $delay_warning)) {
$late = img_warning($langs->trans("Late"));
}
//($langs->transnoentities("Action".$objp->code)!=("Action".$objp->code) ? $langs->transnoentities("Action".$objp->code) : $objp->label)
$label = empty($objp->label) ? $objp->type_label : $objp->label;
@ -172,11 +181,12 @@ class box_actions extends ModeleBoxes
$line++;
}
if ($num == 0)
if ($num == 0) {
$this->info_box_contents[$line][0] = array(
'td' => 'class="center opacitymedium"',
'text'=>$langs->trans("NoActionsToDo")
);
}
$this->db->free($result);
} else {
@ -207,19 +217,15 @@ class box_actions extends ModeleBoxes
global $langs, $conf;
$out = parent::showBox($this->info_box_head, $this->info_box_contents, 1);
if (!empty($conf->global->SHOW_DIALOG_HOMEPAGE))
{
if (!empty($conf->global->SHOW_DIALOG_HOMEPAGE)) {
$actioncejour = false;
$contents = $this->info_box_contents;
$nblines = count($contents);
if ($contents[0][0]['text'] != $langs->trans("NoActionsToDo"))
{
if ($contents[0][0]['text'] != $langs->trans("NoActionsToDo")) {
$out .= '<div id="dialogboxaction" title="'.$nblines." ".$langs->trans("ActionsToDo").'">';
$out .= '<table width=100%>';
for ($line = 0, $n = $nblines; $line < $n; $line++)
{
if (isset($contents[$line]))
{
for ($line = 0, $n = $nblines; $line < $n; $line++) {
if (isset($contents[$line])) {
// on affiche que les évènement du jours ou passé
// qui ne sont pas à 100%
$actioncejour = true;
@ -247,12 +253,10 @@ class box_actions extends ModeleBoxes
$out .= '</table>';
}
$out .= '</div>';
if ($actioncejour)
{
if ($actioncejour) {
$out .= '<script>';
$out .= '$("#dialogboxaction").dialog({ autoOpen: true });';
if ($conf->global->SHOW_DIALOG_HOMEPAGE > 1) // autoclose after this delay
{
if ($conf->global->SHOW_DIALOG_HOMEPAGE > 1) { // autoclose after this delay
$out .= 'setTimeout(function(){';
$out .= '$("#dialogboxaction").dialog("close");';
$out .= '}, '.($conf->global->SHOW_DIALOG_HOMEPAGE * 1000).');';
@ -265,8 +269,11 @@ class box_actions extends ModeleBoxes
}
}
if ($nooutput) return $out;
else print $out;
if ($nooutput) {
return $out;
} else {
print $out;
}
return '';
}

View File

@ -88,7 +88,9 @@ class box_activity extends ModeleBoxes
$now = dol_now();
$nbofperiod = 3;
if (!empty($conf->global->MAIN_BOX_ACTIVITY_DURATION)) $nbofperiod = $conf->global->MAIN_BOX_ACTIVITY_DURATION;
if (!empty($conf->global->MAIN_BOX_ACTIVITY_DURATION)) {
$nbofperiod = $conf->global->MAIN_BOX_ACTIVITY_DURATION;
}
$textHead = $langs->trans("Activity").' - '.$langs->trans("LastXMonthRolling", $nbofperiod);
$this->info_box_head = array(
'text' => $textHead,
@ -201,12 +203,18 @@ class box_activity extends ModeleBoxes
if ($refresh) {
$sql = "SELECT c.fk_statut, sum(c.total_ttc) as Mnttot, count(*) as nb";
$sql .= " FROM (".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as c";
if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
if (!$user->rights->societe->client->voir && !$user->socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= ")";
$sql .= " WHERE c.entity IN (".getEntity('commande').")";
$sql .= " AND c.fk_soc = s.rowid";
if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
if ($user->socid) $sql .= " AND s.rowid = ".$user->socid;
if (!$user->rights->societe->client->voir && !$user->socid) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
}
if ($user->socid) {
$sql .= " AND s.rowid = ".$user->socid;
}
$sql .= " AND c.date_commande >= '".$this->db->idate($tmpdate)."'";
$sql .= " GROUP BY c.fk_statut";
$sql .= " ORDER BY c.fk_statut DESC";
@ -270,8 +278,7 @@ class box_activity extends ModeleBoxes
// list the summary of the bills
if (!empty($conf->facture->enabled) && $user->rights->facture->lire)
{
if (!empty($conf->facture->enabled) && $user->rights->facture->lire) {
include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
$facturestatic = new Facture($this->db);
@ -281,15 +288,20 @@ class box_activity extends ModeleBoxes
$refresh = dol_cache_refresh($cachedir, $filename, $cachetime);
$data = array();
if ($refresh)
{
if ($refresh) {
$sql = "SELECT f.fk_statut, SUM(f.total_ttc) as Mnttot, COUNT(*) as nb";
$sql .= " FROM (".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f";
if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
if (!$user->rights->societe->client->voir && !$user->socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= ")";
$sql .= " WHERE f.entity IN (".getEntity('invoice').')';
if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
if ($user->socid) $sql .= " AND s.rowid = ".$user->socid;
if (!$user->rights->societe->client->voir && !$user->socid) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
}
if ($user->socid) {
$sql .= " AND s.rowid = ".$user->socid;
}
$sql .= " AND f.fk_soc = s.rowid";
$sql .= " AND f.datef >= '".$this->db->idate($tmpdate)."' AND f.paye=1";
$sql .= " GROUP BY f.fk_statut";
@ -343,7 +355,7 @@ class box_activity extends ModeleBoxes
);
// We add only for the current year
$totalnb += $data[$j]->nb;
$totalnb += $data[$j]->nb;
$this->info_box_contents[$line][4] = array(
'td' => 'class="right" width="18"',
@ -352,11 +364,12 @@ class box_activity extends ModeleBoxes
$line++;
$j++;
}
if (count($data) == 0)
if (count($data) == 0) {
$this->info_box_contents[$line][0] = array(
'td' => 'class="center"',
'text'=>$langs->trans("NoRecordedInvoices"),
);
}
}
// part 2

View File

@ -82,8 +82,7 @@ class box_birthdays extends ModeleBoxes
$this->info_box_head = array('text' => $langs->trans("BoxTitleUserBirthdaysOfMonth"));
if ($user->rights->user->user->lire)
{
if ($user->rights->user->user->lire) {
$tmparray = dol_getdate(dol_now(), true);
$sql = "SELECT u.rowid, u.firstname, u.lastname, u.birth, u.email, u.statut as status";
@ -96,13 +95,11 @@ class box_birthdays extends ModeleBoxes
dol_syslog(get_class($this)."::loadBox", LOG_DEBUG);
$result = $this->db->query($sql);
if ($result)
{
if ($result) {
$num = $this->db->num_rows($result);
$line = 0;
while ($line < $num)
{
while ($line < $num) {
$objp = $this->db->fetch_object($result);
$userstatic->id = $objp->rowid;
@ -126,14 +123,16 @@ class box_birthdays extends ModeleBoxes
);
/*$this->info_box_contents[$line][] = array(
'td' => 'class="right" width="18"',
'text' => $userstatic->LibStatut($objp->status, 3)
);*/
'td' => 'class="right" width="18"',
'text' => $userstatic->LibStatut($objp->status, 3)
);*/
$line++;
}
if ($num == 0) $this->info_box_contents[$line][0] = array('td' => 'class="center opacitymedium"', 'text'=>$langs->trans("None"));
if ($num == 0) {
$this->info_box_contents[$line][0] = array('td' => 'class="center opacitymedium"', 'text'=>$langs->trans("None"));
}
$this->db->free($result);
} else {

View File

@ -82,27 +82,24 @@ class box_birthdays_members extends ModeleBoxes
$this->info_box_head = array('text' => $langs->trans("BoxTitleMemberNextBirthdays"));
if ($user->rights->adherent->lire)
{
if ($user->rights->adherent->lire) {
$tmparray = dol_getdate(dol_now(), true);
$sql = "SELECT u.rowid, u.firstname, u.lastname, u.birth";
$sql .= " FROM ".MAIN_DB_PREFIX."adherent as u";
$sql .= " WHERE u.entity IN (".getEntity('adherent').")";
$sql .= " AND u.statut = 1";
$sql .= dolSqlDateFilter('u.birth', 0, $tmparray['mon'], 0);
$sql .= " AND u.statut = 1";
$sql .= dolSqlDateFilter('u.birth', 0, $tmparray['mon'], 0);
$sql .= " ORDER BY DAY(u.birth) ASC";
$sql .= $this->db->plimit($max, 0);
dol_syslog(get_class($this)."::loadBox", LOG_DEBUG);
$result = $this->db->query($sql);
if ($result)
{
if ($result) {
$num = $this->db->num_rows($result);
$line = 0;
while ($line < $num)
{
while ($line < $num) {
$objp = $this->db->fetch_object($result);
$memberstatic->id = $objp->rowid;
$memberstatic->firstname = $objp->firstname;
@ -123,14 +120,16 @@ class box_birthdays_members extends ModeleBoxes
);
/*$this->info_box_contents[$line][] = array(
'td' => 'class="right" width="18"',
'text' => $memberstatic->LibStatut($objp->status, 3)
);*/
'td' => 'class="right" width="18"',
'text' => $memberstatic->LibStatut($objp->status, 3)
);*/
$line++;
}
if ($num == 0) $this->info_box_contents[$line][0] = array('td' => 'class="center opacitymedium"', 'text'=>$langs->trans("None"));
if ($num == 0) {
$this->info_box_contents[$line][0] = array('td' => 'class="center opacitymedium"', 'text'=>$langs->trans("None"));
}
$this->db->free($result);
} else {

View File

@ -84,8 +84,7 @@ class box_boms extends ModeleBoxes
$this->info_box_head = array('text' => $langs->trans("BoxTitleLatestModifiedBoms", $max));
if ($user->rights->bom->read)
{
if ($user->rights->bom->read) {
$sql = "SELECT p.ref as product_ref, p.tobuy, p.tosell";
$sql .= ", c.rowid";
$sql .= ", c.date_creation";
@ -132,7 +131,9 @@ class box_boms extends ModeleBoxes
);
if (!empty($conf->global->BOM_BOX_LAST_BOMS_SHOW_VALIDATE_USER)) {
if ($objp->fk_user_valid > 0) $userstatic->fetch($objp->fk_user_valid);
if ($objp->fk_user_valid > 0) {
$userstatic->fetch($objp->fk_user_valid);
}
$this->info_box_contents[$line][] = array(
'td' => 'class="right"',
'text' => (($objp->fk_user_valid > 0) ? $userstatic->getNomUrl(1) : ''),
@ -153,10 +154,12 @@ class box_boms extends ModeleBoxes
$line++;
}
if ($num == 0) $this->info_box_contents[$line][0] = array(
if ($num == 0) {
$this->info_box_contents[$line][0] = array(
'td' => 'class="center opacitymedium"',
'text'=>$langs->trans("NoRecordedOrders")
);
);
}
$this->db->free($result);
} else {

View File

@ -84,8 +84,7 @@ class box_bookmarks extends ModeleBoxes
$this->info_box_head['subtext'] = $langs->trans("ListOfBookmark");
}
if ($user->rights->bookmark->lire)
{
if ($user->rights->bookmark->lire) {
$sql = "SELECT b.title, b.url, b.target, b.favicon";
$sql .= " FROM ".MAIN_DB_PREFIX."bookmark as b";
$sql .= " WHERE fk_user = ".$user->id;
@ -94,8 +93,7 @@ class box_bookmarks extends ModeleBoxes
$sql .= $this->db->plimit($max, 0);
$result = $this->db->query($sql);
if ($result)
{
if ($result) {
$num = $this->db->num_rows($result);
$line = 0;
@ -123,7 +121,9 @@ class box_bookmarks extends ModeleBoxes
if ($num == 0) {
$mytxt = $langs->trans("NoRecordedBookmarks");
if ($user->rights->bookmark->creer) $mytxt .= ' '.$langs->trans("ClickToAdd");
if ($user->rights->bookmark->creer) {
$mytxt .= ' '.$langs->trans("ClickToAdd");
}
$this->info_box_contents[$line][0] = array(
'td' => 'class="center" colspan="2"',
'tooltip' => $mytxt,

View File

@ -61,7 +61,9 @@ class box_clients extends ModeleBoxes
$this->db = $db;
// disable box for such cases
if (!empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) $this->enabled = 0; // disabled by this option
if (!empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) {
$this->enabled = 0; // disabled by this option
}
$this->hidden = !($user->rights->societe->lire && empty($user->socid));
}
@ -84,30 +86,33 @@ class box_clients extends ModeleBoxes
$this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedCustomers", $max));
if ($user->rights->societe->lire)
{
if ($user->rights->societe->lire) {
$sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias";
$sql .= ", s.code_client, s.code_compta, s.client";
$sql .= ", s.logo, s.email, s.entity";
$sql .= ", s.datec, s.tms, s.status";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
if (!$user->rights->societe->client->voir && !$user->socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE s.client IN (1, 3)";
$sql .= " AND s.entity IN (".getEntity('societe').")";
if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
if ($user->socid) $sql .= " AND s.rowid = ".$user->socid;
if (!$user->rights->societe->client->voir && !$user->socid) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
}
if ($user->socid) {
$sql .= " AND s.rowid = ".$user->socid;
}
$sql .= " ORDER BY s.tms DESC";
$sql .= $this->db->plimit($max, 0);
dol_syslog(get_class($this)."::loadBox", LOG_DEBUG);
$result = $this->db->query($sql);
if ($result)
{
if ($result) {
$num = $this->db->num_rows($result);
$line = 0;
while ($line < $num)
{
while ($line < $num) {
$objp = $this->db->fetch_object($result);
$datec = $this->db->jdate($objp->datec);
$datem = $this->db->jdate($objp->tms);
@ -141,10 +146,12 @@ class box_clients extends ModeleBoxes
$line++;
}
if ($num == 0) $this->info_box_contents[$line][0] = array(
if ($num == 0) {
$this->info_box_contents[$line][0] = array(
'td' => 'class="center opacitymedium"',
'text'=>$langs->trans("NoRecordedCustomers")
);
);
}
$this->db->free($result);
} else {

View File

@ -85,8 +85,7 @@ class box_commandes extends ModeleBoxes
$this->info_box_head = array('text' => $langs->trans("BoxTitleLast".(!empty($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) ? "" : "Modified")."CustomerOrders", $max));
if ($user->rights->commande->lire)
{
if ($user->rights->commande->lire) {
$sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias";
$sql .= ", s.code_client, s.code_compta, s.client";
$sql .= ", s.logo, s.email, s.entity";
@ -102,14 +101,25 @@ class box_commandes extends ModeleBoxes
$sql .= ", c.total_ttc";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql .= ", ".MAIN_DB_PREFIX."commande as c";
if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
if (!$user->rights->societe->client->voir && !$user->socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE c.fk_soc = s.rowid";
$sql .= " AND c.entity IN (".getEntity('commande').")";
if (!empty($conf->global->ORDER_BOX_LAST_ORDERS_VALIDATED_ONLY)) $sql .= " AND c.fk_statut = 1";
if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
if ($user->socid) $sql .= " AND s.rowid = ".$user->socid;
if (!empty($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE)) $sql .= " ORDER BY c.date_commande DESC, c.ref DESC ";
else $sql .= " ORDER BY c.tms DESC, c.ref DESC ";
if (!empty($conf->global->ORDER_BOX_LAST_ORDERS_VALIDATED_ONLY)) {
$sql .= " AND c.fk_statut = 1";
}
if (!$user->rights->societe->client->voir && !$user->socid) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
}
if ($user->socid) {
$sql .= " AND s.rowid = ".$user->socid;
}
if (!empty($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE)) {
$sql .= " ORDER BY c.date_commande DESC, c.ref DESC ";
} else {
$sql .= " ORDER BY c.tms DESC, c.ref DESC ";
}
$sql .= $this->db->plimit($max, 0);
$result = $this->db->query($sql);
@ -158,7 +168,9 @@ class box_commandes extends ModeleBoxes
);
if (!empty($conf->global->ORDER_BOX_LAST_ORDERS_SHOW_VALIDATE_USER)) {
if ($objp->fk_user_valid > 0) $userstatic->fetch($objp->fk_user_valid);
if ($objp->fk_user_valid > 0) {
$userstatic->fetch($objp->fk_user_valid);
}
$this->info_box_contents[$line][] = array(
'td' => 'class="right"',
'text' => (($objp->fk_user_valid > 0) ? $userstatic->getNomUrl(1) : ''),
@ -179,10 +191,12 @@ class box_commandes extends ModeleBoxes
$line++;
}
if ($num == 0) $this->info_box_contents[$line][0] = array(
if ($num == 0) {
$this->info_box_contents[$line][0] = array(
'td' => 'class="center opacitymedium"',
'text'=>$langs->trans("NoRecordedOrders")
);
);
}
$this->db->free($result);
} else {

View File

@ -64,7 +64,9 @@ class box_comptes extends ModeleBoxes
// disable module for such cases
$listofmodulesforexternal = explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL);
if (!in_array('banque', $listofmodulesforexternal) && !empty($user->socid)) $this->enabled = 0; // disabled for external users
if (!in_array('banque', $listofmodulesforexternal) && !empty($user->socid)) {
$this->enabled = 0; // disabled for external users
}
$this->hidden = !($user->rights->banque->lire);
}
@ -142,7 +144,7 @@ class box_comptes extends ModeleBoxes
}
// Total
foreach ($solde_total as $key=>$solde) {
foreach ($solde_total as $key => $solde) {
$this->info_box_contents[$line][] = array(
'tr' => 'class="liste_total"',
'td' => 'class="liste_total left"',

View File

@ -81,8 +81,7 @@ class box_contacts extends ModeleBoxes
$this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedContacts", $max));
if ($user->rights->societe->lire && $user->rights->societe->contact->lire)
{
if ($user->rights->societe->lire && $user->rights->societe->contact->lire) {
$sql = "SELECT sp.rowid as id, sp.lastname, sp.firstname, sp.civility as civility_id, sp.datec, sp.tms, sp.fk_soc, sp.statut as status";
$sql .= ", sp.address, sp.zip, sp.town, sp.phone, sp.phone_perso, sp.phone_mobile, sp.email as spemail";
@ -94,10 +93,16 @@ class box_contacts extends ModeleBoxes
$sql .= " FROM ".MAIN_DB_PREFIX."socpeople as sp";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON sp.fk_pays = co.rowid";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON sp.fk_soc = s.rowid";
if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
if (!$user->rights->societe->client->voir && !$user->socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE sp.entity IN (".getEntity('socpeople').")";
if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
if ($user->socid) $sql .= " AND sp.fk_soc = ".$user->socid;
if (!$user->rights->societe->client->voir && !$user->socid) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
}
if ($user->socid) {
$sql .= " AND sp.fk_soc = ".$user->socid;
}
$sql .= " ORDER BY sp.tms DESC";
$sql .= $this->db->plimit($max, 0);
@ -109,8 +114,7 @@ class box_contacts extends ModeleBoxes
$societestatic = new Societe($this->db);
$line = 0;
while ($line < $num)
{
while ($line < $num) {
$objp = $this->db->fetch_object($result);
$datec = $this->db->jdate($objp->datec);
$datem = $this->db->jdate($objp->tms);
@ -169,12 +173,13 @@ class box_contacts extends ModeleBoxes
$line++;
}
if ($num == 0)
if ($num == 0) {
$this->info_box_contents[$line][0] = array(
'td' => 'class="center"',
'text'=> '<span class="opacitymedium">'.$langs->trans("NoRecordedContacts").'</span>',
'asis'=> 1
);
}
$this->db->free($result);
} else {

View File

@ -78,8 +78,7 @@ class box_contracts extends ModeleBoxes
$this->info_box_head = array('text' => $langs->trans("BoxTitleLastContracts", $max));
if ($user->rights->contrat->lire)
{
if ($user->rights->contrat->lire) {
$contractstatic = new Contrat($this->db);
$thirdpartytmp = new Societe($this->db);
@ -87,18 +86,26 @@ class box_contracts extends ModeleBoxes
$sql .= " c.rowid, c.ref, c.statut as fk_statut, c.date_contrat, c.datec, c.fin_validite, c.date_cloture";
$sql .= ", c.ref_customer, c.ref_supplier";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as c";
if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
if (!$user->rights->societe->client->voir && !$user->socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE c.fk_soc = s.rowid";
$sql .= " AND c.entity = ".$conf->entity;
if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
if ($user->socid) $sql .= " AND s.rowid = ".$user->socid;
if (! empty($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE)) $sql .= " ORDER BY c.date_contrat DESC, c.ref DESC ";
else $sql .= " ORDER BY c.tms DESC, c.ref DESC ";
if (!$user->rights->societe->client->voir && !$user->socid) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
}
if ($user->socid) {
$sql .= " AND s.rowid = ".$user->socid;
}
if (! empty($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE)) {
$sql .= " ORDER BY c.date_contrat DESC, c.ref DESC ";
} else {
$sql .= " ORDER BY c.tms DESC, c.ref DESC ";
}
$sql .= $this->db->plimit($max, 0);
$resql = $this->db->query($sql);
if ($resql)
{
if ($resql) {
$num = $this->db->num_rows($resql);
$now = dol_now();
@ -106,8 +113,7 @@ class box_contracts extends ModeleBoxes
$langs->load("contracts");
while ($line < $num)
{
while ($line < $num) {
$objp = $this->db->fetch_object($resql);
$datec = $this->db->jdate($objp->datec);
@ -162,11 +168,12 @@ class box_contracts extends ModeleBoxes
$line++;
}
if ($num == 0)
if ($num == 0) {
$this->info_box_contents[$line][0] = array(
'td' => 'class="center opacitymedium"',
'text'=>$langs->trans("NoRecordedContracts"),
);
}
$this->db->free($resql);
} else {

View File

@ -61,7 +61,9 @@ class box_customers_outstanding_bill_reached extends ModeleBoxes
$this->db = $db;
// disable box for such cases
if (!empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) $this->enabled = 0; // disabled by this option
if (!empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) {
$this->enabled = 0; // disabled by this option
}
$this->hidden = !($user->rights->societe->lire && empty($user->socid));
}
@ -84,19 +86,24 @@ class box_customers_outstanding_bill_reached extends ModeleBoxes
$this->info_box_head = array('text' => $langs->trans("BoxTitleLastOutstandingBillReached", $max));
if ($user->rights->societe->lire)
{
if ($user->rights->societe->lire) {
$sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias";
$sql .= ", s.code_client, s.code_compta, s.client";
$sql .= ", s.logo, s.email, s.entity";
$sql .= ", s.outstanding_limit";
$sql .= ", s.datec, s.tms, s.status";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
if (!$user->rights->societe->client->voir && !$user->socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE s.client IN (1, 3)";
$sql .= " AND s.entity IN (".getEntity('societe').")";
if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
if ($user->socid) $sql .= " AND s.rowid = $user->socid";
if (!$user->rights->societe->client->voir && !$user->socid) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
}
if ($user->socid) {
$sql .= " AND s.rowid = $user->socid";
}
$sql .= " AND s.outstanding_limit > 0";
$sql .= " AND s.rowid IN (SELECT fk_soc from ".MAIN_DB_PREFIX."facture as f WHERE f.fk_statut = 1 and f.fk_soc = s.rowid)";
$sql .= " ORDER BY s.tms DESC";
@ -104,15 +111,13 @@ class box_customers_outstanding_bill_reached extends ModeleBoxes
dol_syslog(get_class($this)."::loadBox", LOG_DEBUG);
$result = $this->db->query($sql);
if ($result)
{
if ($result) {
$num = $this->db->num_rows($result);
$nboutstandingbillreachedcustomers = 0;
$line = 0;
while ($line < $num)
{
while ($line < $num) {
$objp = $this->db->fetch_object($result);
$datec = $this->db->jdate($objp->datec);
$datem = $this->db->jdate($objp->tms);
@ -131,8 +136,7 @@ class box_customers_outstanding_bill_reached extends ModeleBoxes
$outstandingtotal = $thirdpartystatic->getOutstandingBills()['opened'];
$outstandinglimit = $thirdpartystatic->outstanding_limit;
if ($outstandingtotal >= $outstandinglimit)
{
if ($outstandingtotal >= $outstandinglimit) {
$this->info_box_contents[$nboutstandingbillreachedcustomers][] = array(
'td' => '',
'text' => $thirdpartystatic->getNomUrl(1, 'customer'),
@ -149,10 +153,12 @@ class box_customers_outstanding_bill_reached extends ModeleBoxes
$line++;
}
if ($num == 0 || $nboutstandingbillreachedcustomers == 0) $this->info_box_contents[$line][0] = array(
if ($num == 0 || $nboutstandingbillreachedcustomers == 0) {
$this->info_box_contents[$line][0] = array(
'td' => 'class="center"',
'text'=> '<span class="opacitymedium">'.$langs->trans("None").'</span>'
);
);
}
$this->db->free($result);
} else {

View File

@ -249,7 +249,9 @@ class box_dolibarr_state_board extends ModeleBoxes
$class = $classes[$val];
// Search in cache if load_state_board is already realized
$classkeyforcache = $class;
if ($classkeyforcache == 'ProductService') $classkeyforcache = 'Product'; // ProductService use same load_state_board than Product
if ($classkeyforcache == 'ProductService') {
$classkeyforcache = 'Product'; // ProductService use same load_state_board than Product
}
if (!isset($boardloaded[$classkeyforcache]) || !is_object($boardloaded[$classkeyforcache])) {
include_once $includes[$val]; // Loading a class cost around 1Mb

View File

@ -98,11 +98,12 @@ class box_external_rss extends ModeleBoxes
$link = $rssparser->getLink();
$title = $langs->trans("BoxTitleLastRssInfos", $max, $conf->global->$keyforparamtitle);
if ($result < 0 || !empty($rssparser->error))
{
if ($result < 0 || !empty($rssparser->error)) {
// Show warning
$errormessage = $langs->trans("FailedToRefreshDataInfoNotUpToDate", ($rssparser->getLastFetchDate() ? dol_print_date($rssparser->getLastFetchDate(), "dayhourtext") : $langs->trans("Unknown")));
if ($rssparser->error) $errormessage .= " - ".$rssparser->error;
if ($rssparser->error) {
$errormessage .= " - ".$rssparser->error;
}
$title .= " ".img_error($errormessage);
$this->info_box_head = array('text' => $title, 'limit' => 0);
} else {
@ -119,34 +120,44 @@ class box_external_rss extends ModeleBoxes
$items = $rssparser->getItems();
//print '<pre>'.print_r($items,true).'</pre>';
$nbitems = count($items);
for ($line = 0; $line < $max && $line < $nbitems; $line++)
{
for ($line = 0; $line < $max && $line < $nbitems; $line++) {
$item = $items[$line];
// Feed common fields
$href = $item['link'];
$title = urldecode($item['title']);
$date = $item['date_timestamp']; // date will be empty if conversion into timestamp failed
if ($rssparser->getFormat() == 'rss') // If RSS
{
if (!$date && isset($item['pubdate'])) $date = $item['pubdate'];
if (!$date && isset($item['dc']['date'])) $date = $item['dc']['date'];
if ($rssparser->getFormat() == 'rss') { // If RSS
if (!$date && isset($item['pubdate'])) {
$date = $item['pubdate'];
}
if (!$date && isset($item['dc']['date'])) {
$date = $item['dc']['date'];
}
//$item['dc']['language']
//$item['dc']['publisher']
}
if ($rssparser->getFormat() == 'atom') // If Atom
{
if (!$date && isset($item['issued'])) $date = $item['issued'];
if (!$date && isset($item['modified'])) $date = $item['modified'];
if ($rssparser->getFormat() == 'atom') { // If Atom
if (!$date && isset($item['issued'])) {
$date = $item['issued'];
}
if (!$date && isset($item['modified'])) {
$date = $item['modified'];
}
//$item['issued']
//$item['modified']
//$item['atom_content']
}
if (is_numeric($date)) $date = dol_print_date($date, "dayhour");
if (is_numeric($date)) {
$date = dol_print_date($date, "dayhour");
}
$isutf8 = utf8_check($title);
if (!$isutf8 && $conf->file->character_set_client == 'UTF-8') $title = utf8_encode($title);
elseif ($isutf8 && $conf->file->character_set_client == 'ISO-8859-1') $title = utf8_decode($title);
if (!$isutf8 && $conf->file->character_set_client == 'UTF-8') {
$title = utf8_encode($title);
} elseif ($isutf8 && $conf->file->character_set_client == 'ISO-8859-1') {
$title = utf8_decode($title);
}
$title = preg_replace("/([[:alnum:]])\?([[:alnum:]])/", "\\1'\\2", $title); // Gere probleme des apostrophes mal codee/decodee par utf8
$title = preg_replace("/^\s+/", "", $title); // Supprime espaces de debut
@ -155,8 +166,11 @@ class box_external_rss extends ModeleBoxes
$tooltip = $title;
$description = !empty($item['description']) ? $item['description'] : '';
$isutf8 = utf8_check($description);
if (!$isutf8 && $conf->file->character_set_client == 'UTF-8') $description = utf8_encode($description);
elseif ($isutf8 && $conf->file->character_set_client == 'ISO-8859-1') $description = utf8_decode($description);
if (!$isutf8 && $conf->file->character_set_client == 'UTF-8') {
$description = utf8_encode($description);
} elseif ($isutf8 && $conf->file->character_set_client == 'ISO-8859-1') {
$description = utf8_decode($description);
}
$description = preg_replace("/([[:alnum:]])\?([[:alnum:]])/", "\\1'\\2", $description);
$description = preg_replace("/^\s+/", "", $description);
$description = str_replace("\r\n", "", $description);

View File

@ -100,19 +100,27 @@ class box_factures extends ModeleBoxes
$sql .= ", s.logo, s.email, s.entity";
$sql .= ", s.tva_intra, s.siren as idprof1, s.siret as idprof2, s.ape as idprof3, s.idprof4, s.idprof5, s.idprof6";
$sql .= " FROM (".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f";
if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
if (!$user->rights->societe->client->voir && !$user->socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= ")";
$sql .= " WHERE f.fk_soc = s.rowid";
$sql .= " AND f.entity IN (".getEntity('invoice').")";
if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
if ($user->socid) $sql .= " AND s.rowid = ".$user->socid;
if (!empty($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE)) $sql .= " ORDER BY f.datef DESC, f.ref DESC ";
else $sql .= " ORDER BY f.tms DESC, f.ref DESC ";
if (!$user->rights->societe->client->voir && !$user->socid) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
}
if ($user->socid) {
$sql .= " AND s.rowid = ".$user->socid;
}
if (!empty($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE)) {
$sql .= " ORDER BY f.datef DESC, f.ref DESC ";
} else {
$sql .= " ORDER BY f.tms DESC, f.ref DESC ";
}
$sql .= $this->db->plimit($max, 0);
$result = $this->db->query($sql);
if ($result)
{
if ($result) {
$num = $this->db->num_rows($result);
$now = dol_now();
@ -187,11 +195,12 @@ class box_factures extends ModeleBoxes
$line++;
}
if ($num == 0)
if ($num == 0) {
$this->info_box_contents[$line][0] = array(
'td' => 'class="center"',
'text'=>$langs->trans("NoRecordedInvoices"),
);
}
$this->db->free($result);
} else {

View File

@ -84,8 +84,7 @@ class box_factures_fourn extends ModeleBoxes
'text' => $langs->trans("BoxTitleLast".(!empty($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) ? "" : "Modified")."SupplierBills", $max)
);
if ($user->rights->fournisseur->facture->lire)
{
if ($user->rights->fournisseur->facture->lire) {
$sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias";
$sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
$sql .= ", s.logo, s.email, s.entity";
@ -99,18 +98,26 @@ class box_factures_fourn extends ModeleBoxes
$sql .= ', f.date_lim_reglement as datelimite, f.tms, f.type';
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql .= ", ".MAIN_DB_PREFIX."facture_fourn as f";
if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
if (!$user->rights->societe->client->voir && !$user->socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE f.fk_soc = s.rowid";
$sql .= " AND f.entity = ".$conf->entity;
if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
if ($user->socid) $sql .= " AND s.rowid = ".$user->socid;
if (!empty($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE)) $sql .= " ORDER BY f.datef DESC, f.ref DESC ";
else $sql .= " ORDER BY f.tms DESC, f.ref DESC ";
if (!$user->rights->societe->client->voir && !$user->socid) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
}
if ($user->socid) {
$sql .= " AND s.rowid = ".$user->socid;
}
if (!empty($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE)) {
$sql .= " ORDER BY f.datef DESC, f.ref DESC ";
} else {
$sql .= " ORDER BY f.tms DESC, f.ref DESC ";
}
$sql .= $this->db->plimit($max, 0);
$result = $this->db->query($sql);
if ($result)
{
if ($result) {
$num = $this->db->num_rows($result);
$line = 0;
@ -188,11 +195,12 @@ class box_factures_fourn extends ModeleBoxes
$line++;
}
if ($num == 0)
if ($num == 0) {
$this->info_box_contents[$line][0] = array(
'td' => 'class="center"',
'text'=>$langs->trans("NoModifiedSupplierBills"),
);
}
$this->db->free($result);
} else {

View File

@ -80,8 +80,7 @@ class box_factures_fourn_imp extends ModeleBoxes
$this->info_box_head = array('text' => $langs->trans("BoxTitleOldestUnpaidSupplierBills", $max));
if ($user->rights->fournisseur->facture->lire)
{
if ($user->rights->fournisseur->facture->lire) {
$sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias";
$sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
$sql .= ", s.logo, s.email, s.entity";
@ -93,19 +92,24 @@ class box_factures_fourn_imp extends ModeleBoxes
$sql .= ", f.paye, f.fk_statut, f.type";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql .= ",".MAIN_DB_PREFIX."facture_fourn as f";
if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
if (!$user->rights->societe->client->voir && !$user->socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE f.fk_soc = s.rowid";
$sql .= " AND f.entity = ".$conf->entity;
$sql .= " AND f.paye=0";
$sql .= " AND fk_statut = 1";
if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
if ($user->socid) $sql .= " AND s.rowid = ".$user->socid;
if (!$user->rights->societe->client->voir && !$user->socid) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
}
if ($user->socid) {
$sql .= " AND s.rowid = ".$user->socid;
}
$sql .= " ORDER BY datelimite DESC, f.ref_supplier DESC ";
$sql .= $this->db->plimit($max, 0);
$result = $this->db->query($sql);
if ($result)
{
if ($result) {
$num = $this->db->num_rows($result);
$line = 0;
@ -113,8 +117,7 @@ class box_factures_fourn_imp extends ModeleBoxes
$facturestatic = new FactureFournisseur($this->db);
while ($line < $num)
{
while ($line < $num) {
$objp = $this->db->fetch_object($result);
$datelimite = $this->db->jdate($objp->datelimite);
$date = $this->db->jdate($objp->df);
@ -179,11 +182,12 @@ class box_factures_fourn_imp extends ModeleBoxes
$line++;
}
if ($num == 0)
if ($num == 0) {
$this->info_box_contents[$line][0] = array(
'td' => 'class="center"',
'text'=>$langs->trans("NoUnpaidSupplierBills"),
);
}
$this->db->free($result);
} else {

View File

@ -86,8 +86,7 @@ class box_factures_imp extends ModeleBoxes
$this->info_box_head = array('text' => $langs->trans("BoxTitleOldestUnpaidCustomerBills", $max));
if ($user->rights->facture->lire)
{
if ($user->rights->facture->lire) {
$sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias";
$sql .= ", s.code_client, s.code_compta, s.client";
$sql .= ", s.logo, s.email, s.entity";
@ -101,15 +100,21 @@ class box_factures_imp extends ModeleBoxes
$sql .= ", f.paye, f.fk_statut, f.rowid as facid";
$sql .= ", sum(pf.amount) as am";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
if (!$user->rights->societe->client->voir && !$user->socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= ", ".MAIN_DB_PREFIX."facture as f";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid=pf.fk_facture ";
$sql .= " WHERE f.fk_soc = s.rowid";
$sql .= " AND f.entity IN (".getEntity('invoice').")";
$sql .= " AND f.paye = 0";
$sql .= " AND fk_statut = 1";
if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
if ($user->socid) $sql .= " AND s.rowid = ".$user->socid;
if (!$user->rights->societe->client->voir && !$user->socid) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
}
if ($user->socid) {
$sql .= " AND s.rowid = ".$user->socid;
}
$sql .= " GROUP BY s.rowid, s.nom, s.name_alias, s.code_client, s.code_compta, s.client, s.logo, s.email, s.entity, s.tva_intra, s.siren, s.siret, s.ape, s.idprof4, s.idprof5, s.idprof6,";
$sql .= " f.ref, f.date_lim_reglement,";
$sql .= " f.type, f.datef, f.total, f.tva, f.total_ttc, f.paye, f.fk_statut, f.rowid";
@ -118,16 +123,14 @@ class box_factures_imp extends ModeleBoxes
$sql .= $this->db->plimit($max, 0);
$result = $this->db->query($sql);
if ($result)
{
if ($result) {
$num = $this->db->num_rows($result);
$now = dol_now();
$line = 0;
$l_due_date = $langs->trans('Late').' ('.strtolower($langs->trans('DateDue')).': %s)';
while ($line < $num)
{
while ($line < $num) {
$objp = $this->db->fetch_object($result);
$datelimite = $this->db->jdate($objp->datelimite);
$facturestatic->id = $objp->facid;
@ -192,10 +195,12 @@ class box_factures_imp extends ModeleBoxes
$line++;
}
if ($num == 0) $this->info_box_contents[$line][0] = array(
if ($num == 0) {
$this->info_box_contents[$line][0] = array(
'td' => 'class="center opacitymedium"',
'text'=>$langs->trans("NoUnpaidCustomerBills")
);
);
}
$this->db->free($result);
} else {

View File

@ -80,8 +80,7 @@ class box_ficheinter extends ModeleBoxes
$this->info_box_head = array('text' => $langs->trans("BoxTitleLastFicheInter", $max));
if (!empty($user->rights->ficheinter->lire))
{
if (!empty($user->rights->ficheinter->lire)) {
$sql = "SELECT f.rowid, f.ref, f.fk_soc, f.fk_statut";
$sql .= ", f.datec";
$sql .= ", f.date_valid as datev";
@ -90,26 +89,30 @@ class box_ficheinter extends ModeleBoxes
$sql .= ", s.code_client, s.code_compta, s.client";
$sql .= ", s.logo, s.email, s.entity";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->societe->client->voir) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
if (!$user->rights->societe->client->voir) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= ", ".MAIN_DB_PREFIX."fichinter as f";
$sql .= " WHERE f.fk_soc = s.rowid ";
$sql .= " AND f.entity = ".$conf->entity;
if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
if ($user->socid) $sql .= " AND s.rowid = ".$user->socid;
if (!$user->rights->societe->client->voir && !$user->socid) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
}
if ($user->socid) {
$sql .= " AND s.rowid = ".$user->socid;
}
$sql .= " ORDER BY f.tms DESC";
$sql .= $this->db->plimit($max, 0);
dol_syslog(get_class($this).'::loadBox', LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
if ($resql) {
$num = $this->db->num_rows($resql);
$now = dol_now();
$i = 0;
while ($i < $num)
{
while ($i < $num) {
$objp = $this->db->fetch_object($resql);
$datec = $this->db->jdate($objp->datec);
@ -153,10 +156,12 @@ class box_ficheinter extends ModeleBoxes
$i++;
}
if ($num == 0) $this->info_box_contents[$i][0] = array(
if ($num == 0) {
$this->info_box_contents[$i][0] = array(
'td' => 'class="center opacitymedium"',
'text'=>$langs->trans("NoRecordedInterventions")
);
);
}
$this->db->free($resql);
} else {

View File

@ -81,29 +81,32 @@ class box_fournisseurs extends ModeleBoxes
$this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedSuppliers", $max));
if ($user->rights->societe->lire)
{
if ($user->rights->societe->lire) {
$sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias";
$sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
$sql .= ", s.logo, s.email, s.entity";
$sql .= ", s.datec, s.tms, s.status";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
if (!$user->rights->societe->client->voir && !$user->socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE s.fournisseur = 1";
$sql .= " AND s.entity IN (".getEntity('societe').")";
if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
if ($user->socid) $sql .= " AND s.rowid = ".$user->socid;
if (!$user->rights->societe->client->voir && !$user->socid) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
}
if ($user->socid) {
$sql .= " AND s.rowid = ".$user->socid;
}
$sql .= " ORDER BY s.tms DESC ";
$sql .= $this->db->plimit($max, 0);
$result = $this->db->query($sql);
if ($result)
{
if ($result) {
$num = $this->db->num_rows($result);
$line = 0;
while ($line < $num)
{
while ($line < $num) {
$objp = $this->db->fetch_object($result);
$datec = $this->db->jdate($objp->datec);
$datem = $this->db->jdate($objp->tms);
@ -118,7 +121,7 @@ class box_fournisseurs extends ModeleBoxes
$thirdpartystatic->email = $objp->email;
$thirdpartystatic->entity = $objp->entity;
$this->info_box_contents[$line][] = array(
$this->info_box_contents[$line][] = array(
'td' => '',
'text' => $thirdpartystatic->getNomUrl(1, '', 40),
'asis' => 1,

View File

@ -62,8 +62,12 @@ class box_goodcustomers extends ModeleBoxes
$this->db = $db;
// disable box for such cases
if (!empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) $this->enabled = 0; // disabled by this option
if (empty($conf->global->MAIN_BOX_ENABLE_BEST_CUSTOMERS)) $this->enabled = 0; // not enabled by default. Very slow on large database
if (!empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) {
$this->enabled = 0; // disabled by this option
}
if (empty($conf->global->MAIN_BOX_ENABLE_BEST_CUSTOMERS)) {
$this->enabled = 0; // not enabled by default. Very slow on large database
}
$this->hidden = !($user->rights->societe->lire);
}
@ -86,8 +90,7 @@ class box_goodcustomers extends ModeleBoxes
$this->info_box_head = array('text' => $langs->trans("BoxTitleGoodCustomers", $max));
if ($user->rights->societe->lire)
{
if ($user->rights->societe->lire) {
$sql = "SELECT s.rowid, s.nom as name, s.logo, s.code_client, s.code_fournisseur, s.client, s.fournisseur, s.tms as datem, s.status as status,";
$sql .= " count(*) as nbfact, sum(".$this->db->ifsql('f.paye=1', '1', '0').") as nbfactpaye";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as f";
@ -99,13 +102,11 @@ class box_goodcustomers extends ModeleBoxes
dol_syslog(get_class($this)."::loadBox", LOG_DEBUG);
$result = $this->db->query($sql);
if ($result)
{
if ($result) {
$num = $this->db->num_rows($result);
$line = 0;
while ($line < $num)
{
while ($line < $num) {
$objp = $this->db->fetch_object($result);
$datem = $this->db->jdate($objp->tms);
$thirdpartystatic->id = $objp->rowid;
@ -142,10 +143,12 @@ class box_goodcustomers extends ModeleBoxes
$line++;
}
if ($num == 0) $this->info_box_contents[$line][0] = array(
if ($num == 0) {
$this->info_box_contents[$line][0] = array(
'td' => 'class="center opacitymedium"',
'text'=>$langs->trans("NoRecordedCustomers")
);
);
}
$this->db->free($result);
} else {

View File

@ -75,7 +75,9 @@ class box_graph_invoices_permonth extends ModeleBoxes
//$facturestatic=new Facture($this->db);
$startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1;
if (empty($conf->global->GRAPH_USE_FISCAL_YEAR)) $startmonth = 1;
if (empty($conf->global->GRAPH_USE_FISCAL_YEAR)) {
$startmonth = 1;
}
$text = $langs->trans("BoxCustomersInvoicesPerMonth", $max);
$this->info_box_head = array(
@ -92,11 +94,14 @@ class box_graph_invoices_permonth extends ModeleBoxes
$dir = ''; // We don't need a path because image file will not be saved into disk
$prefix = '';
$socid = 0;
if ($user->socid) $socid = $user->socid;
if (!$user->rights->societe->client->voir || $socid) $prefix .= 'private-'.$user->id.'-'; // If user has no permission to see all, output dir is specific to user
if ($user->socid) {
$socid = $user->socid;
}
if (!$user->rights->societe->client->voir || $socid) {
$prefix .= 'private-'.$user->id.'-'; // If user has no permission to see all, output dir is specific to user
}
if ($user->rights->facture->lire)
{
if ($user->rights->facture->lire) {
$mesg = '';
$param_year = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_year';
@ -106,20 +111,23 @@ class box_graph_invoices_permonth extends ModeleBoxes
include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facturestats.class.php';
$autosetarray = preg_split("/[,;:]+/", GETPOST('DOL_AUTOSET_COOKIE'));
if (in_array('DOLUSERCOOKIE_box_'.$this->boxcode, $autosetarray))
{
if (in_array('DOLUSERCOOKIE_box_'.$this->boxcode, $autosetarray)) {
$endyear = GETPOST($param_year, 'int');
$shownb = GETPOST($param_shownb, 'alpha');
$showtot = GETPOST($param_showtot, 'alpha');
} else {
$tmparray = (!empty($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode]) ? json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode], true) : array());
$endyear = (!empty($tmparray['year']) ? $tmparray['year'] : '');
$shownb = (!empty($tmparray['shownb']) ? $tmparray['shownb'] : '');
$showtot = (!empty($tmparray['showtot']) ? $tmparray['showtot'] : '');
$tmparray = (!empty($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode]) ? json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode], true) : array());
$endyear = (!empty($tmparray['year']) ? $tmparray['year'] : '');
$shownb = (!empty($tmparray['shownb']) ? $tmparray['shownb'] : '');
$showtot = (!empty($tmparray['showtot']) ? $tmparray['showtot'] : '');
}
if (empty($shownb) && empty($showtot)) {
$shownb = 1; $showtot = 1;
}
if (empty($shownb) && empty($showtot)) { $shownb = 1; $showtot = 1; }
$nowarray = dol_getdate(dol_now(), true);
if (empty($endyear)) $endyear = $nowarray['year'];
if (empty($endyear)) {
$endyear = $nowarray['year'];
}
$startyear = $endyear - (empty($conf->global->MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH) ? 1 : $conf->global->MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH);
$mode = 'customer';
@ -129,28 +137,26 @@ class box_graph_invoices_permonth extends ModeleBoxes
$stats = new FactureStats($this->db, $socid, $mode, 0);
// Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
if ($shownb)
{
if ($shownb) {
$data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)), ($WIDTH < 300 ? 2 : 0), $startmonth);
$filenamenb = $dir."/".$prefix."invoicesnbinyear-".$endyear.".png";
// default value for customer mode
$fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&amp;file=invoicesnbinyear-'.$endyear.'.png';
if ($mode == 'supplier') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstatssupplier&amp;file=invoicessuppliernbinyear-'.$endyear.'.png';
if ($mode == 'supplier') {
$fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstatssupplier&amp;file=invoicessuppliernbinyear-'.$endyear.'.png';
}
$px1 = new DolGraph();
$mesg = $px1->isGraphKo();
if (!$mesg)
{
if (!$mesg) {
$langs->load("bills");
$px1->SetData($data1);
unset($data1);
$i = $startyear; $legend = array();
while ($i <= $endyear)
{
if ($startmonth != 1)
{
while ($i <= $endyear) {
if ($startmonth != 1) {
$legend[] = sprintf("%d/%d", $i - 2001, $i - 2000);
} else {
$legend[] = $i;
@ -174,28 +180,26 @@ class box_graph_invoices_permonth extends ModeleBoxes
}
// Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
if ($showtot)
{
if ($showtot) {
$data2 = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)), ($WIDTH < 300 ? 2 : 0), $startmonth);
$filenamenb = $dir."/".$prefix."invoicesamountinyear-".$endyear.".png";
// default value for customer mode
$fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&amp;file=invoicesamountinyear-'.$endyear.'.png';
if ($mode == 'supplier') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstatssupplier&amp;file=invoicessupplieramountinyear-'.$endyear.'.png';
if ($mode == 'supplier') {
$fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstatssupplier&amp;file=invoicessupplieramountinyear-'.$endyear.'.png';
}
$px2 = new DolGraph();
$mesg = $px2->isGraphKo();
if (!$mesg)
{
if (!$mesg) {
$langs->load("bills");
$px2->SetData($data2);
unset($data2);
$i = $startyear; $legend = array();
while ($i <= $endyear)
{
if ($startmonth != 1)
{
while ($i <= $endyear) {
if ($startmonth != 1) {
$legend[] = sprintf("%d/%d", $i - 2001, $i - 2000);
} else {
$legend[] = $i;
@ -217,14 +221,12 @@ class box_graph_invoices_permonth extends ModeleBoxes
}
}
if (empty($conf->use_javascript_ajax))
{
if (empty($conf->use_javascript_ajax)) {
$langs->load("errors");
$mesg = $langs->trans("WarningFeatureDisabledWithDisplayOptimizedForBlindNoJs");
}
if (!$mesg)
{
if (!$mesg) {
$stringtoshow = '';
$stringtoshow .= '<script type="text/javascript" language="javascript">
jQuery(document).ready(function() {
@ -247,20 +249,21 @@ class box_graph_invoices_permonth extends ModeleBoxes
$stringtoshow .= '<input class="reposition inline-block valigntextbottom" type="image" alt="'.$langs->trans("Refresh").'" src="'.img_picto($langs->trans("Refresh"), 'refresh.png', '', '', 1).'">';
$stringtoshow .= '</form>';
$stringtoshow .= '</div>';
if ($shownb && $showtot)
{
if ($shownb && $showtot) {
$stringtoshow .= '<div class="fichecenter">';
$stringtoshow .= '<div class="fichehalfleft">';
}
if ($shownb) $stringtoshow .= $px1->show();
if ($shownb && $showtot)
{
if ($shownb) {
$stringtoshow .= $px1->show();
}
if ($shownb && $showtot) {
$stringtoshow .= '</div>';
$stringtoshow .= '<div class="fichehalfright">';
}
if ($showtot) $stringtoshow .= $px2->show();
if ($shownb && $showtot)
{
if ($showtot) {
$stringtoshow .= $px2->show();
}
if ($shownb && $showtot) {
$stringtoshow .= '</div>';
$stringtoshow .= '</div>';
}

View File

@ -74,7 +74,9 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes
include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
$startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1;
if (empty($conf->global->GRAPH_USE_FISCAL_YEAR)) $startmonth = 1;
if (empty($conf->global->GRAPH_USE_FISCAL_YEAR)) {
$startmonth = 1;
}
$text = $langs->trans("BoxSuppliersInvoicesPerMonth", $max);
$this->info_box_head = array(
@ -91,11 +93,14 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes
$dir = ''; // We don't need a path because image file will not be saved into disk
$prefix = '';
$socid = 0;
if ($user->socid) $socid = $user->socid;
if (!$user->rights->societe->client->voir || $socid) $prefix .= 'private-'.$user->id.'-'; // If user has no permission to see all, output dir is specific to user
if ($user->socid) {
$socid = $user->socid;
}
if (!$user->rights->societe->client->voir || $socid) {
$prefix .= 'private-'.$user->id.'-'; // If user has no permission to see all, output dir is specific to user
}
if ($user->rights->fournisseur->facture->lire)
{
if ($user->rights->fournisseur->facture->lire) {
$param_year = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_year';
$param_shownb = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_shownb';
$param_showtot = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_showtot';
@ -103,21 +108,26 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes
include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facturestats.class.php';
$autosetarray = preg_split("/[,;:]+/", GETPOST('DOL_AUTOSET_COOKIE'));
if (in_array('DOLUSERCOOKIE_box_'.$this->boxcode, $autosetarray))
{
if (in_array('DOLUSERCOOKIE_box_'.$this->boxcode, $autosetarray)) {
$endyear = GETPOST($param_year, 'int');
$shownb = GETPOST($param_shownb, 'alpha');
$showtot = GETPOST($param_showtot, 'alpha');
} else {
$tmparray = (!empty($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode]) ? json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode], true) : array());
$endyear = (!empty($tmparray['year']) ? $tmparray['year'] : '');
$shownb = (!empty($tmparray['shownb']) ? $tmparray['shownb'] : '');
$showtot = (!empty($tmparray['showtot']) ? $tmparray['showtot'] : '');
$tmparray = (!empty($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode]) ? json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode], true) : array());
$endyear = (!empty($tmparray['year']) ? $tmparray['year'] : '');
$shownb = (!empty($tmparray['shownb']) ? $tmparray['shownb'] : '');
$showtot = (!empty($tmparray['showtot']) ? $tmparray['showtot'] : '');
}
if (empty($shownb) && empty($showtot)) {
$shownb = 1; $showtot = 1;
}
if (empty($shownb) && empty($showtot)) { $shownb = 1; $showtot = 1; }
$nowarray = dol_getdate(dol_now(), true);
if (empty($year)) $year = $nowarray['year'];
if (empty($endyear)) $endyear = $nowarray['year'];
if (empty($year)) {
$year = $nowarray['year'];
}
if (empty($endyear)) {
$endyear = $nowarray['year'];
}
$startyear = $endyear - (empty($conf->global->MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH) ? 1 : $conf->global->MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH);
$mode = 'supplier';
@ -127,29 +137,27 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes
$stats = new FactureStats($this->db, $socid, $mode, 0);
// Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
if ($shownb)
{
if ($shownb) {
$data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)), ($WIDTH < 300 ? 2 : 0), $startmonth);
$filenamenb = $dir."/".$prefix."invoicessuppliernbinyear-".$year.".png";
// default value for customer mode
$fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&amp;file=invoicesnbinyear-'.$year.'.png';
if ($mode == 'supplier') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstatssupplier&amp;file=invoicessuppliernbinyear-'.$year.'.png';
if ($mode == 'supplier') {
$fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstatssupplier&amp;file=invoicessuppliernbinyear-'.$year.'.png';
}
$px1 = new DolGraph();
$mesg = $px1->isGraphKo();
if (!$mesg)
{
if (!$mesg) {
$langs->load("bills");
$px1->SetData($data1);
unset($data1);
$i = $startyear;
$legend = array();
while ($i <= $endyear)
{
if ($startmonth != 1)
{
while ($i <= $endyear) {
if ($startmonth != 1) {
$legend[] = sprintf("%d/%d", $i - 2001, $i - 2000);
} else {
$legend[] = $i;
@ -172,28 +180,26 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes
}
// Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
if ($showtot)
{
if ($showtot) {
$data2 = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)), ($WIDTH < 300 ? 2 : 0), $startmonth);
$filenamenb = $dir."/".$prefix."invoicessupplieramountinyear-".$year.".png";
// default value for customer mode
$fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&amp;file=invoicesamountinyear-'.$year.'.png';
if ($mode == 'supplier') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstatssupplier&amp;file=invoicessupplieramountinyear-'.$year.'.png';
if ($mode == 'supplier') {
$fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstatssupplier&amp;file=invoicessupplieramountinyear-'.$year.'.png';
}
$px2 = new DolGraph();
$mesg = $px2->isGraphKo();
if (!$mesg)
{
if (!$mesg) {
$langs->load("bills");
$px2->SetData($data2);
unset($data2);
$i = $startyear; $legend = array();
while ($i <= $endyear)
{
if ($startmonth != 1)
{
while ($i <= $endyear) {
if ($startmonth != 1) {
$legend[] = sprintf("%d/%d", $i - 2001, $i - 2000);
} else {
$legend[] = $i;
@ -215,14 +221,12 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes
}
}
if (empty($conf->use_javascript_ajax))
{
if (empty($conf->use_javascript_ajax)) {
$langs->load("errors");
$mesg = $langs->trans("WarningFeatureDisabledWithDisplayOptimizedForBlindNoJs");
}
if (!$mesg)
{
if (!$mesg) {
$stringtoshow = '';
$stringtoshow .= '<script type="text/javascript" language="javascript">
jQuery(document).ready(function() {
@ -245,20 +249,21 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes
$stringtoshow .= '<input type="image" class="reposition inline-block valigntextbottom" alt="'.$langs->trans("Refresh").'" src="'.img_picto($langs->trans("Refresh"), 'refresh.png', '', '', 1).'">';
$stringtoshow .= '</form>';
$stringtoshow .= '</div>';
if ($shownb && $showtot)
{
if ($shownb && $showtot) {
$stringtoshow .= '<div class="fichecenter">';
$stringtoshow .= '<div class="fichehalfleft">';
}
if ($shownb) $stringtoshow .= $px1->show();
if ($shownb && $showtot)
{
if ($shownb) {
$stringtoshow .= $px1->show();
}
if ($shownb && $showtot) {
$stringtoshow .= '</div>';
$stringtoshow .= '<div class="fichehalfright">';
}
if ($showtot) $stringtoshow .= $px2->show();
if ($shownb && $showtot)
{
if ($showtot) {
$stringtoshow .= $px2->show();
}
if ($shownb && $showtot) {
$stringtoshow .= '</div>';
$stringtoshow .= '</div>';
}

View File

@ -75,7 +75,9 @@ class box_graph_orders_permonth extends ModeleBoxes
//$commandestatic=new Commande($this->db);
$startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1;
if (empty($conf->global->GRAPH_USE_FISCAL_YEAR)) $startmonth = 1;
if (empty($conf->global->GRAPH_USE_FISCAL_YEAR)) {
$startmonth = 1;
}
$text = $langs->trans("BoxCustomersOrdersPerMonth", $max);
$this->info_box_head = array(
@ -92,11 +94,14 @@ class box_graph_orders_permonth extends ModeleBoxes
$dir = ''; // We don't need a path because image file will not be saved into disk
$prefix = '';
$socid = 0;
if ($user->socid) $socid = $user->socid;
if (!$user->rights->societe->client->voir || $socid) $prefix .= 'private-'.$user->id.'-'; // If user has no permission to see all, output dir is specific to user
if ($user->socid) {
$socid = $user->socid;
}
if (!$user->rights->societe->client->voir || $socid) {
$prefix .= 'private-'.$user->id.'-'; // If user has no permission to see all, output dir is specific to user
}
if ($user->rights->commande->lire)
{
if ($user->rights->commande->lire) {
$langs->load("orders");
$param_year = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_year';
@ -106,20 +111,23 @@ class box_graph_orders_permonth extends ModeleBoxes
include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
include_once DOL_DOCUMENT_ROOT.'/commande/class/commandestats.class.php';
$autosetarray = preg_split("/[,;:]+/", GETPOST('DOL_AUTOSET_COOKIE'));
if (in_array('DOLUSERCOOKIE_box_'.$this->boxcode, $autosetarray))
{
if (in_array('DOLUSERCOOKIE_box_'.$this->boxcode, $autosetarray)) {
$endyear = GETPOST($param_year, 'int');
$shownb = GETPOST($param_shownb, 'alpha');
$showtot = GETPOST($param_showtot, 'alpha');
} else {
$tmparray = (!empty($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode]) ? json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode], true) : array());
$endyear = (!empty($tmparray['year']) ? $tmparray['year'] : '');
$shownb = (!empty($tmparray['shownb']) ? $tmparray['shownb'] : '');
$showtot = (!empty($tmparray['showtot']) ? $tmparray['showtot'] : '');
$tmparray = (!empty($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode]) ? json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode], true) : array());
$endyear = (!empty($tmparray['year']) ? $tmparray['year'] : '');
$shownb = (!empty($tmparray['shownb']) ? $tmparray['shownb'] : '');
$showtot = (!empty($tmparray['showtot']) ? $tmparray['showtot'] : '');
}
if (empty($shownb) && empty($showtot)) {
$shownb = 1; $showtot = 1;
}
if (empty($shownb) && empty($showtot)) { $shownb = 1; $showtot = 1; }
$nowarray = dol_getdate(dol_now(), true);
if (empty($endyear)) $endyear = $nowarray['year'];
if (empty($endyear)) {
$endyear = $nowarray['year'];
}
$startyear = $endyear - (empty($conf->global->MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH) ? 1 : $conf->global->MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH);
$mode = 'customer';
@ -129,27 +137,25 @@ class box_graph_orders_permonth extends ModeleBoxes
$stats = new CommandeStats($this->db, $socid, $mode, 0);
// Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
if ($shownb)
{
if ($shownb) {
$data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)), ($WIDTH < 300 ? 2 : 0), $startmonth);
$filenamenb = $dir."/".$prefix."ordersnbinyear-".$endyear.".png";
// default value for customer mode
$fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&amp;file=ordersnbinyear-'.$endyear.'.png';
if ($mode == 'supplier') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&amp;file=ordersnbinyear-'.$endyear.'.png';
if ($mode == 'supplier') {
$fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&amp;file=ordersnbinyear-'.$endyear.'.png';
}
$px1 = new DolGraph();
$mesg = $px1->isGraphKo();
if (!$mesg)
{
if (!$mesg) {
$px1->SetData($data1);
unset($data1);
$i = $startyear;
$legend = array();
while ($i <= $endyear)
{
if ($startmonth != 1)
{
while ($i <= $endyear) {
if ($startmonth != 1) {
$legend[] = sprintf("%d/%d", $i - 2001, $i - 2000);
} else {
$legend[] = $i;
@ -172,26 +178,24 @@ class box_graph_orders_permonth extends ModeleBoxes
}
// Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
if ($showtot)
{
if ($showtot) {
$data2 = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)), ($WIDTH < 300 ? 2 : 0), $startmonth);
$filenamenb = $dir."/".$prefix."ordersamountinyear-".$endyear.".png";
// default value for customer mode
$fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&amp;file=ordersamountinyear-'.$endyear.'.png';
if ($mode == 'supplier') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&amp;file=ordersamountinyear-'.$endyear.'.png';
if ($mode == 'supplier') {
$fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&amp;file=ordersamountinyear-'.$endyear.'.png';
}
$px2 = new DolGraph();
$mesg = $px2->isGraphKo();
if (!$mesg)
{
if (!$mesg) {
$px2->SetData($data2);
unset($data2);
$i = $startyear; $legend = array();
while ($i <= $endyear)
{
if ($startmonth != 1)
{
while ($i <= $endyear) {
if ($startmonth != 1) {
$legend[] = sprintf("%d/%d", $i - 2001, $i - 2000);
} else {
$legend[] = $i;
@ -213,14 +217,12 @@ class box_graph_orders_permonth extends ModeleBoxes
}
}
if (empty($conf->use_javascript_ajax))
{
if (empty($conf->use_javascript_ajax)) {
$langs->load("errors");
$mesg = $langs->trans("WarningFeatureDisabledWithDisplayOptimizedForBlindNoJs");
}
if (!$mesg)
{
if (!$mesg) {
$stringtoshow = '';
$stringtoshow .= '<script type="text/javascript" language="javascript">
jQuery(document).ready(function() {
@ -243,20 +245,21 @@ class box_graph_orders_permonth extends ModeleBoxes
$stringtoshow .= '<input type="image" class="reposition inline-block valigntextbottom" alt="'.$langs->trans("Refresh").'" src="'.img_picto($langs->trans("Refresh"), 'refresh.png', '', '', 1).'">';
$stringtoshow .= '</form>';
$stringtoshow .= '</div>';
if ($shownb && $showtot)
{
if ($shownb && $showtot) {
$stringtoshow .= '<div class="fichecenter">';
$stringtoshow .= '<div class="fichehalfleft">';
}
if ($shownb) $stringtoshow .= $px1->show();
if ($shownb && $showtot)
{
if ($shownb) {
$stringtoshow .= $px1->show();
}
if ($shownb && $showtot) {
$stringtoshow .= '</div>';
$stringtoshow .= '<div class="fichehalfright">';
}
if ($showtot) $stringtoshow .= $px2->show();
if ($shownb && $showtot)
{
if ($showtot) {
$stringtoshow .= $px2->show();
}
if ($shownb && $showtot) {
$stringtoshow .= '</div>';
$stringtoshow .= '</div>';
}

View File

@ -74,7 +74,9 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes
include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
$startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1;
if (empty($conf->global->GRAPH_USE_FISCAL_YEAR)) $startmonth = 1;
if (empty($conf->global->GRAPH_USE_FISCAL_YEAR)) {
$startmonth = 1;
}
$text = $langs->trans("BoxSuppliersOrdersPerMonth", $max);
$this->info_box_head = array(
@ -91,11 +93,14 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes
$dir = ''; // We don't need a path because image file will not be saved into disk
$prefix = '';
$socid = 0;
if ($user->socid) $socid = $user->socid;
if (!$user->rights->societe->client->voir || $socid) $prefix .= 'private-'.$user->id.'-'; // If user has no permission to see all, output dir is specific to user
if ($user->socid) {
$socid = $user->socid;
}
if (!$user->rights->societe->client->voir || $socid) {
$prefix .= 'private-'.$user->id.'-'; // If user has no permission to see all, output dir is specific to user
}
if ($user->rights->fournisseur->commande->lire)
{
if ($user->rights->fournisseur->commande->lire) {
$langs->load("orders");
$param_year = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_year';
@ -105,20 +110,23 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes
include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
include_once DOL_DOCUMENT_ROOT.'/commande/class/commandestats.class.php';
$autosetarray = preg_split("/[,;:]+/", GETPOST('DOL_AUTOSET_COOKIE'));
if (in_array('DOLUSERCOOKIE_box_'.$this->boxcode, $autosetarray))
{
if (in_array('DOLUSERCOOKIE_box_'.$this->boxcode, $autosetarray)) {
$endyear = GETPOST($param_year, 'int');
$shownb = GETPOST($param_shownb, 'alpha');
$showtot = GETPOST($param_showtot, 'alpha');
} else {
$tmparray = (!empty($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode]) ? json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode], true) : array());
$tmparray = (!empty($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode]) ? json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode], true) : array());
$endyear = (!empty($tmparray['year']) ? $tmparray['year'] : '');
$shownb = (!empty($tmparray['shownb']) ? $tmparray['shownb'] : '');
$showtot = (!empty($tmparray['showtot']) ? $tmparray['showtot'] : '');
}
if (empty($shownb) && empty($showtot)) { $shownb = 1; $showtot = 1; }
if (empty($shownb) && empty($showtot)) {
$shownb = 1; $showtot = 1;
}
$nowarray = dol_getdate(dol_now(), true);
if (empty($endyear)) $endyear = $nowarray['year'];
if (empty($endyear)) {
$endyear = $nowarray['year'];
}
$startyear = $endyear - (empty($conf->global->MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH) ? 1 : $conf->global->MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH);
$mode = 'supplier';
@ -128,27 +136,25 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes
$stats = new CommandeStats($this->db, $socid, $mode, 0);
// Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
if ($shownb)
{
if ($shownb) {
$data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)), ($WIDTH < 300 ? 2 : 0), $startmonth);
$filenamenb = $dir."/".$prefix."orderssuppliernbinyear-".$endyear.".png";
// default value for customer mode
$fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&amp;file=ordersnbinyear-'.$endyear.'.png';
if ($mode == 'supplier') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&amp;file=orderssuppliernbinyear-'.$endyear.'.png';
if ($mode == 'supplier') {
$fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&amp;file=orderssuppliernbinyear-'.$endyear.'.png';
}
$px1 = new DolGraph();
$mesg = $px1->isGraphKo();
if (!$mesg)
{
if (!$mesg) {
$px1->SetData($data1);
unset($data1);
$i = $startyear;
$legend = array();
while ($i <= $endyear)
{
if ($startmonth != 1)
{
while ($i <= $endyear) {
if ($startmonth != 1) {
$legend[] = sprintf("%d/%d", $i - 2001, $i - 2000);
} else {
$legend[] = $i;
@ -171,26 +177,24 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes
}
// Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
if ($showtot)
{
if ($showtot) {
$data2 = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)), ($WIDTH < 300 ? 2 : 0), $startmonth);
$filenamenb = $dir."/".$prefix."orderssupplieramountinyear-".$endyear.".png";
// default value for customer mode
$fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&amp;file=ordersamountinyear-'.$endyear.'.png';
if ($mode == 'supplier') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&amp;file=orderssupplieramountinyear-'.$endyear.'.png';
if ($mode == 'supplier') {
$fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&amp;file=orderssupplieramountinyear-'.$endyear.'.png';
}
$px2 = new DolGraph();
$mesg = $px2->isGraphKo();
if (!$mesg)
{
if (!$mesg) {
$px2->SetData($data2);
unset($data2);
$i = $startyear; $legend = array();
while ($i <= $endyear)
{
if ($startmonth != 1)
{
while ($i <= $endyear) {
if ($startmonth != 1) {
$legend[] = sprintf("%d/%d", $i - 2001, $i - 2000);
} else {
$legend[] = $i;
@ -212,14 +216,12 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes
}
}
if (empty($conf->use_javascript_ajax))
{
if (empty($conf->use_javascript_ajax)) {
$langs->load("errors");
$mesg = $langs->trans("WarningFeatureDisabledWithDisplayOptimizedForBlindNoJs");
}
if (!$mesg)
{
if (!$mesg) {
$stringtoshow = '';
$stringtoshow .= '<script type="text/javascript" language="javascript">
jQuery(document).ready(function() {
@ -242,20 +244,21 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes
$stringtoshow .= '<input type="image" class="reposition inline-block valigntextbottom" alt="'.$langs->trans("Refresh").'" src="'.img_picto($langs->trans("Refresh"), 'refresh.png', '', '', 1).'">';
$stringtoshow .= '</form>';
$stringtoshow .= '</div>';
if ($shownb && $showtot)
{
if ($shownb && $showtot) {
$stringtoshow .= '<div class="fichecenter">';
$stringtoshow .= '<div class="fichehalfleft">';
}
if ($shownb) $stringtoshow .= $px1->show();
if ($shownb && $showtot)
{
if ($shownb) {
$stringtoshow .= $px1->show();
}
if ($shownb && $showtot) {
$stringtoshow .= '</div>';
$stringtoshow .= '<div class="fichehalfright">';
}
if ($showtot) $stringtoshow .= $px2->show();
if ($shownb && $showtot)
{
if ($showtot) {
$stringtoshow .= $px2->show();
}
if ($shownb && $showtot) {
$stringtoshow .= '</div>';
$stringtoshow .= '</div>';
}

View File

@ -88,31 +88,46 @@ class box_graph_product_distribution extends ModeleBoxes
$param_showpropalnb = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_showpropalnb';
$param_showordernb = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_showordernb';
$autosetarray = preg_split("/[,;:]+/", GETPOST('DOL_AUTOSET_COOKIE'));
if (in_array('DOLUSERCOOKIE_box_'.$this->boxcode, $autosetarray))
{
if (in_array('DOLUSERCOOKIE_box_'.$this->boxcode, $autosetarray)) {
$year = GETPOST($param_year, 'int');
$showinvoicenb = GETPOST($param_showinvoicenb, 'alpha');
$showpropalnb = GETPOST($param_showpropalnb, 'alpha');
$showordernb = GETPOST($param_showordernb, 'alpha');
} else {
$tmparray = (!empty($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode]) ? json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode], true) : array());
$year = (!empty($tmparray['year']) ? $tmparray['year'] : '');
$showinvoicenb = (!empty($tmparray['showinvoicenb']) ? $tmparray['showinvoicenb'] : '');
$showpropalnb = (!empty($tmparray['showpropalnb']) ? $tmparray['showpropalnb'] : '');
$showordernb = (!empty($tmparray['showordernb']) ? $tmparray['showordernb'] : '');
$tmparray = (!empty($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode]) ? json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode], true) : array());
$year = (!empty($tmparray['year']) ? $tmparray['year'] : '');
$showinvoicenb = (!empty($tmparray['showinvoicenb']) ? $tmparray['showinvoicenb'] : '');
$showpropalnb = (!empty($tmparray['showpropalnb']) ? $tmparray['showpropalnb'] : '');
$showordernb = (!empty($tmparray['showordernb']) ? $tmparray['showordernb'] : '');
}
if (empty($showinvoicenb) && empty($showpropalnb) && empty($showordernb)) {
$showpropalnb = 1; $showinvoicenb = 1; $showordernb = 1;
}
if (empty($conf->facture->enabled) || empty($user->rights->facture->lire)) {
$showinvoicenb = 0;
}
if (empty($conf->propal->enabled) || empty($user->rights->propale->lire)) {
$showpropalnb = 0;
}
if (empty($conf->commande->enabled) || empty($user->rights->commande->lire)) {
$showordernb = 0;
}
if (empty($showinvoicenb) && empty($showpropalnb) && empty($showordernb)) { $showpropalnb = 1; $showinvoicenb = 1; $showordernb = 1; }
if (empty($conf->facture->enabled) || empty($user->rights->facture->lire)) $showinvoicenb = 0;
if (empty($conf->propal->enabled) || empty($user->rights->propale->lire)) $showpropalnb = 0;
if (empty($conf->commande->enabled) || empty($user->rights->commande->lire)) $showordernb = 0;
$nowarray = dol_getdate(dol_now(), true);
if (empty($year)) $year = $nowarray['year'];
if (empty($year)) {
$year = $nowarray['year'];
}
$nbofgraph = 0;
if ($showinvoicenb) $nbofgraph++;
if ($showpropalnb) $nbofgraph++;
if ($showordernb) $nbofgraph++;
if ($showinvoicenb) {
$nbofgraph++;
}
if ($showpropalnb) {
$nbofgraph++;
}
if ($showordernb) {
$nbofgraph++;
}
$text = $langs->trans("BoxProductDistribution", $max).' - '.$langs->trans("Year").': '.$year;
$this->info_box_head = array(
@ -133,19 +148,16 @@ class box_graph_product_distribution extends ModeleBoxes
$WIDTH = ($nbofgraph >= 2 || !empty($conf->dol_optimize_smallscreen)) ? '160' : '320';
$HEIGHT = '192';
if (!empty($conf->propal->enabled) && !empty($user->rights->propale->lire))
{
if (!empty($conf->propal->enabled) && !empty($user->rights->propale->lire)) {
// Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
if ($showpropalnb)
{
if ($showpropalnb) {
$langs->load("propal");
include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propalestats.class.php';
$showpointvalue = 1; $nocolor = 0;
$stats_proposal = new PropaleStats($this->db, $socid, ($userid > 0 ? $userid : 0));
$data2 = $stats_proposal->getAllByProductEntry($year, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)), 5);
if (empty($data2))
{
if (empty($data2)) {
$showpointvalue = 0;
$nocolor = 1;
$data2 = array(array(0=>$langs->trans("None"), 1=>1));
@ -156,12 +168,10 @@ class box_graph_product_distribution extends ModeleBoxes
$px2 = new DolGraph();
$mesg = $px2->isGraphKo();
if (!$mesg)
{
if (!$mesg) {
$i = 0; $legend = array();
foreach ($data2 as $key => $val)
{
foreach ($data2 as $key => $val) {
$data2[$key][0] = dol_trunc($data2[$key][0], 32);
$legend[] = $data2[$key][0];
$i++;
@ -170,7 +180,9 @@ class box_graph_product_distribution extends ModeleBoxes
$px2->SetData($data2);
unset($data2);
if ($nocolor) $px2->SetDataColor(array(array(220, 220, 220)));
if ($nocolor) {
$px2->SetDataColor(array(array(220, 220, 220)));
}
$px2->SetLegend($legend);
$px2->setShowLegend(2);
$px2->setShowPointValue($showpointvalue);
@ -192,11 +204,9 @@ class box_graph_product_distribution extends ModeleBoxes
}
}
if (!empty($conf->commande->enabled) && !empty($user->rights->commande->lire))
{
if (!empty($conf->commande->enabled) && !empty($user->rights->commande->lire)) {
// Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
if ($showordernb)
{
if ($showordernb) {
$langs->load("orders");
include_once DOL_DOCUMENT_ROOT.'/commande/class/commandestats.class.php';
@ -204,8 +214,7 @@ class box_graph_product_distribution extends ModeleBoxes
$mode = 'customer';
$stats_order = new CommandeStats($this->db, $socid, $mode, ($userid > 0 ? $userid : 0));
$data3 = $stats_order->getAllByProductEntry($year, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)), 5);
if (empty($data3))
{
if (empty($data3)) {
$showpointvalue = 0;
$nocolor = 1;
$data3 = array(array(0=>$langs->trans("None"), 1=>1));
@ -216,12 +225,10 @@ class box_graph_product_distribution extends ModeleBoxes
$px3 = new DolGraph();
$mesg = $px3->isGraphKo();
if (!$mesg)
{
if (!$mesg) {
$i = 0; $legend = array();
foreach ($data3 as $key => $val)
{
foreach ($data3 as $key => $val) {
$data3[$key][0] = dol_trunc($data3[$key][0], 32);
$legend[] = $data3[$key][0];
$i++;
@ -230,7 +237,9 @@ class box_graph_product_distribution extends ModeleBoxes
$px3->SetData($data3);
unset($data3);
if ($nocolor) $px3->SetDataColor(array(array(220, 220, 220)));
if ($nocolor) {
$px3->SetDataColor(array(array(220, 220, 220)));
}
$px3->SetLegend($legend);
$px3->setShowLegend(2);
$px3->setShowPointValue($showpointvalue);
@ -253,11 +262,9 @@ class box_graph_product_distribution extends ModeleBoxes
}
if (!empty($conf->facture->enabled) && !empty($user->rights->facture->lire))
{
if (!empty($conf->facture->enabled) && !empty($user->rights->facture->lire)) {
// Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
if ($showinvoicenb)
{
if ($showinvoicenb) {
$langs->load("bills");
include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facturestats.class.php';
@ -266,8 +273,7 @@ class box_graph_product_distribution extends ModeleBoxes
$stats_invoice = new FactureStats($this->db, $socid, $mode, ($userid > 0 ? $userid : 0));
$data1 = $stats_invoice->getAllByProductEntry($year, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)), 5);
if (empty($data1))
{
if (empty($data1)) {
$showpointvalue = 0;
$nocolor = 1;
$data1 = array(array(0=>$langs->trans("None"), 1=>1));
@ -277,12 +283,10 @@ class box_graph_product_distribution extends ModeleBoxes
$px1 = new DolGraph();
$mesg = $px1->isGraphKo();
if (!$mesg)
{
if (!$mesg) {
$i = 0; $legend = array();
foreach ($data1 as $key => $val)
{
foreach ($data1 as $key => $val) {
$data1[$key][0] = dol_trunc($data1[$key][0], 32);
$legend[] = $data1[$key][0];
$i++;
@ -291,7 +295,9 @@ class box_graph_product_distribution extends ModeleBoxes
$px1->SetData($data1);
unset($data1);
if ($nocolor) $px1->SetDataColor(array(array(220, 220, 220)));
if ($nocolor) {
$px1->SetDataColor(array(array(220, 220, 220)));
}
$px1->SetLegend($legend);
$px1->setShowLegend(2);
$px1->setShowPointValue($showpointvalue);
@ -313,19 +319,16 @@ class box_graph_product_distribution extends ModeleBoxes
}
}
if (empty($nbofgraph))
{
if (empty($nbofgraph)) {
$langs->load("errors");
$mesg = $langs->trans("ReadPermissionNotAllowed");
}
if (empty($conf->use_javascript_ajax))
{
if (empty($conf->use_javascript_ajax)) {
$langs->load("errors");
$mesg = $langs->trans("WarningFeatureDisabledWithDisplayOptimizedForBlindNoJs");
}
if (!$mesg)
{
if (!$mesg) {
$stringtoshow = '';
$stringtoshow .= '<script type="text/javascript" language="javascript">
jQuery(document).ready(function() {
@ -340,17 +343,14 @@ class box_graph_product_distribution extends ModeleBoxes
$stringtoshow .= '<input type="hidden" name="action" value="'.$refreshaction.'">';
$stringtoshow .= '<input type="hidden" name="page_y" value="">';
$stringtoshow .= '<input type="hidden" name="DOL_AUTOSET_COOKIE" value="DOLUSERCOOKIE_box_'.$this->boxcode.':year,showinvoicenb,showpropalnb,showordernb">';
if (!empty($conf->propal->enabled) || !empty($user->rights->propale->lire))
{
if (!empty($conf->propal->enabled) || !empty($user->rights->propale->lire)) {
$stringtoshow .= '<input type="checkbox" name="'.$param_showpropalnb.'"'.($showpropalnb ? ' checked' : '').'> '.$langs->trans("ForProposals");
$stringtoshow .= '&nbsp;';
}
if (!empty($conf->commande->enabled) || !empty($user->rights->commande->lire))
{
if (!empty($conf->commande->enabled) || !empty($user->rights->commande->lire)) {
$stringtoshow .= '<input type="checkbox" name="'.$param_showordernb.'"'.($showordernb ? ' checked' : '').'> '.$langs->trans("ForCustomersOrders");
}
if (!empty($conf->facture->enabled) || !empty($user->rights->facture->lire))
{
if (!empty($conf->facture->enabled) || !empty($user->rights->facture->lire)) {
$stringtoshow .= '<input type="checkbox" name="'.$param_showinvoicenb.'"'.($showinvoicenb ? ' checked' : '').'> '.$langs->trans("ForCustomersInvoices");
$stringtoshow .= ' &nbsp; ';
}
@ -360,24 +360,31 @@ class box_graph_product_distribution extends ModeleBoxes
$stringtoshow .= '</form>';
$stringtoshow .= '</div>';
if ($nbofgraph == 1)
{
if ($showpropalnb) $stringtoshow .= $px2->show();
elseif ($showordernb) $stringtoshow .= $px3->show();
else $stringtoshow .= $px1->show();
if ($nbofgraph == 1) {
if ($showpropalnb) {
$stringtoshow .= $px2->show();
} elseif ($showordernb) {
$stringtoshow .= $px3->show();
} else {
$stringtoshow .= $px1->show();
}
}
if ($nbofgraph == 2)
{
if ($nbofgraph == 2) {
$stringtoshow .= '<div class="fichecenter"><div class="containercenter"><div class="fichehalfleft">';
if ($showpropalnb) $stringtoshow .= $px2->show();
elseif ($showordernb) $stringtoshow .= $px3->show();
if ($showpropalnb) {
$stringtoshow .= $px2->show();
} elseif ($showordernb) {
$stringtoshow .= $px3->show();
}
$stringtoshow .= '</div><div class="fichehalfright">';
if ($showinvoicenb) $stringtoshow .= $px1->show();
elseif ($showordernb) $stringtoshow .= $px3->show();
if ($showinvoicenb) {
$stringtoshow .= $px1->show();
} elseif ($showordernb) {
$stringtoshow .= $px3->show();
}
$stringtoshow .= '</div></div></div>';
}
if ($nbofgraph == 3)
{
if ($nbofgraph == 3) {
$stringtoshow .= '<div class="fichecenter"><div class="containercenter"><div class="fichehalfleft">';
$stringtoshow .= $px2->show();
$stringtoshow .= '</div><div class="fichehalfright">';

View File

@ -75,7 +75,9 @@ class box_graph_propales_permonth extends ModeleBoxes
//$propalstatic=new Propal($this->db);
$startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1;
if (empty($conf->global->GRAPH_USE_FISCAL_YEAR)) $startmonth = 1;
if (empty($conf->global->GRAPH_USE_FISCAL_YEAR)) {
$startmonth = 1;
}
$langs->load("propal");
@ -94,11 +96,14 @@ class box_graph_propales_permonth extends ModeleBoxes
$dir = ''; // We don't need a path because image file will not be saved into disk
$prefix = '';
$socid = 0;
if ($user->socid) $socid = $user->socid;
if (!$user->rights->societe->client->voir || $socid) $prefix .= 'private-'.$user->id.'-'; // If user has no permission to see all, output dir is specific to user
if ($user->socid) {
$socid = $user->socid;
}
if (!$user->rights->societe->client->voir || $socid) {
$prefix .= 'private-'.$user->id.'-'; // If user has no permission to see all, output dir is specific to user
}
if ($user->rights->propale->lire)
{
if ($user->rights->propale->lire) {
$param_year = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_year';
$param_shownb = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_shownb';
$param_showtot = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_showtot';
@ -106,20 +111,23 @@ class box_graph_propales_permonth extends ModeleBoxes
include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propalestats.class.php';
$autosetarray = preg_split("/[,;:]+/", GETPOST('DOL_AUTOSET_COOKIE'));
if (in_array('DOLUSERCOOKIE_box_'.$this->boxcode, $autosetarray))
{
if (in_array('DOLUSERCOOKIE_box_'.$this->boxcode, $autosetarray)) {
$endyear = GETPOST($param_year, 'int');
$shownb = GETPOST($param_shownb, 'alpha');
$showtot = GETPOST($param_showtot, 'alpha');
} else {
$tmparray = (!empty($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode]) ? json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode], true) : array());
$endyear = (!empty($tmparray['year']) ? $tmparray['year'] : '');
$shownb = (!empty($tmparray['shownb']) ? $tmparray['shownb'] : '');
$showtot = (!empty($tmparray['showtot']) ? $tmparray['showtot'] : '');
$tmparray = (!empty($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode]) ? json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode], true) : array());
$endyear = (!empty($tmparray['year']) ? $tmparray['year'] : '');
$shownb = (!empty($tmparray['shownb']) ? $tmparray['shownb'] : '');
$showtot = (!empty($tmparray['showtot']) ? $tmparray['showtot'] : '');
}
if (empty($shownb) && empty($showtot)) {
$shownb = 1; $showtot = 1;
}
if (empty($shownb) && empty($showtot)) { $shownb = 1; $showtot = 1; }
$nowarray = dol_getdate(dol_now(), true);
if (empty($endyear)) $endyear = $nowarray['year'];
if (empty($endyear)) {
$endyear = $nowarray['year'];
}
$startyear = $endyear - (empty($conf->global->MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH) ? 1 : $conf->global->MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH);
$WIDTH = (($shownb && $showtot) || !empty($conf->dol_optimize_smallscreen)) ? '256' : '320';
@ -128,8 +136,7 @@ class box_graph_propales_permonth extends ModeleBoxes
$stats = new PropaleStats($this->db, $socid, 0);
// Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
if ($shownb)
{
if ($shownb) {
$data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)), ($WIDTH < 300 ? 2 : 0), $startmonth);
$datatype1 = array_pad(array(), ($endyear - $startyear + 1), 'bars');
@ -138,16 +145,13 @@ class box_graph_propales_permonth extends ModeleBoxes
$px1 = new DolGraph();
$mesg = $px1->isGraphKo();
if (!$mesg)
{
if (!$mesg) {
$px1->SetType($datatype1);
$px1->SetData($data1);
unset($data1);
$i = $startyear; $legend = array();
while ($i <= $endyear)
{
if ($startmonth != 1)
{
while ($i <= $endyear) {
if ($startmonth != 1) {
$legend[] = sprintf("%d/%d", $i - 2001, $i - 2000);
} else {
$legend[] = $i;
@ -170,30 +174,30 @@ class box_graph_propales_permonth extends ModeleBoxes
}
// Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...)
if ($showtot)
{
if ($showtot) {
$data2 = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)), ($WIDTH < 300 ? 2 : 0), $startmonth);
$datatype2 = array_pad(array(), ($endyear - $startyear + 1), 'bars');
//$datatype2 = array('lines','bars');
$filenamenb = $dir."/".$prefix."propalsamountinyear-".$endyear.".png";
if (!empty($mode)) {
if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=propalstats&amp;file=propalsamountinyear-'.$endyear.'.png';
if ($mode == 'supplier') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=propalstatssupplier&amp;file=propalsamountinyear-'.$endyear.'.png';
if ($mode == 'customer') {
$fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=propalstats&amp;file=propalsamountinyear-'.$endyear.'.png';
}
if ($mode == 'supplier') {
$fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=propalstatssupplier&amp;file=propalsamountinyear-'.$endyear.'.png';
}
}
$px2 = new DolGraph();
$mesg = $px2->isGraphKo();
if (!$mesg)
{
if (!$mesg) {
$px2->SetType($datatype2);
$px2->SetData($data2);
unset($data2);
$i = $startyear; $legend = array();
while ($i <= $endyear)
{
if ($startmonth != 1)
{
while ($i <= $endyear) {
if ($startmonth != 1) {
$legend[] = sprintf("%d/%d", $i - 2001, $i - 2000);
} else {
$legend[] = $i;
@ -215,14 +219,12 @@ class box_graph_propales_permonth extends ModeleBoxes
}
}
if (empty($conf->use_javascript_ajax))
{
if (empty($conf->use_javascript_ajax)) {
$langs->load("errors");
$mesg = $langs->trans("WarningFeatureDisabledWithDisplayOptimizedForBlindNoJs");
}
if (!$mesg)
{
if (!$mesg) {
$stringtoshow = '';
$stringtoshow .= '<script type="text/javascript" language="javascript">
jQuery(document).ready(function() {
@ -245,20 +247,21 @@ class box_graph_propales_permonth extends ModeleBoxes
$stringtoshow .= '<input type="image" class="reposition inline-block valigntextbottom" alt="'.$langs->trans("Refresh").'" src="'.img_picto($langs->trans("Refresh"), 'refresh.png', '', '', 1).'">';
$stringtoshow .= '</form>';
$stringtoshow .= '</div>';
if ($shownb && $showtot)
{
if ($shownb && $showtot) {
$stringtoshow .= '<div class="fichecenter">';
$stringtoshow .= '<div class="fichehalfleft">';
}
if ($shownb) $stringtoshow .= $px1->show();
if ($shownb && $showtot)
{
if ($shownb) {
$stringtoshow .= $px1->show();
}
if ($shownb && $showtot) {
$stringtoshow .= '</div>';
$stringtoshow .= '<div class="fichehalfright">';
}
if ($showtot) $stringtoshow .= $px2->show();
if ($shownb && $showtot)
{
if ($showtot) {
$stringtoshow .= $px2->show();
}
if ($shownb && $showtot) {
$stringtoshow .= '</div>';
$stringtoshow .= '</div>';
}

View File

@ -75,8 +75,8 @@ class box_last_modified_ticket extends ModeleBoxes
$text = $langs->trans("BoxLastModifiedTicketDescription", $max);
$this->info_box_head = array(
'text' => $text,
'limit' => dol_strlen($text)
'text' => $text,
'limit' => dol_strlen($text)
);
$this->info_box_contents[0][0] = array(

View File

@ -92,8 +92,11 @@ class box_lastlogin extends ModeleBoxes
'td' => '',
'text' => $langs->trans("PreviousConnexion"),
);
if ($user->datepreviouslogin) $tmp = dol_print_date($user->datepreviouslogin, "dayhour", 'tzuser');
else $tmp = $langs->trans("Unknown");
if ($user->datepreviouslogin) {
$tmp = dol_print_date($user->datepreviouslogin, "dayhour", 'tzuser');
} else {
$tmp = $langs->trans("Unknown");
}
$this->info_box_contents[$line][1] = array(
'td' => '',
'text' => $tmp,

View File

@ -84,8 +84,7 @@ class box_mos extends ModeleBoxes
$this->info_box_head = array('text' => $langs->trans("BoxTitleLatestModifiedMos", $max));
if ($user->rights->mrp->read)
{
if ($user->rights->mrp->read) {
$sql = "SELECT p.ref as product_ref";
$sql .= ", c.rowid";
$sql .= ", c.date_creation";
@ -128,7 +127,9 @@ class box_mos extends ModeleBoxes
);
if (!empty($conf->global->MRP_BOX_LAST_MOS_SHOW_VALIDATE_USER)) {
if ($objp->fk_user_valid > 0) $userstatic->fetch($objp->fk_user_valid);
if ($objp->fk_user_valid > 0) {
$userstatic->fetch($objp->fk_user_valid);
}
$this->info_box_contents[$line][] = array(
'td' => 'class="right"',
'text' => (($objp->fk_user_valid > 0) ? $userstatic->getNomUrl(1) : ''),
@ -149,10 +150,12 @@ class box_mos extends ModeleBoxes
$line++;
}
if ($num == 0) $this->info_box_contents[$line][0] = array(
if ($num == 0) {
$this->info_box_contents[$line][0] = array(
'td' => 'class="center"',
'text'=> '<span class="opacitymedium">'.$langs->trans("NoRecordedOrders").'</span>'
);
);
}
$this->db->free($result);
} else {

View File

@ -86,8 +86,7 @@ class box_produits_alerte_stock extends ModeleBoxes
$this->info_box_head = array('text' => $langs->trans("BoxTitleProductsAlertStock", $max));
if (($user->rights->produit->lire || $user->rights->service->lire) && $user->rights->stock->lire)
{
if (($user->rights->produit->lire || $user->rights->service->lire) && $user->rights->stock->lire) {
$sql = "SELECT p.rowid, p.label, p.price, p.ref, p.price_base_type, p.price_ttc, p.fk_product_type, p.tms, p.tosell, p.tobuy, p.barcode, p.seuil_stock_alerte, p.entity,";
$sql .= " p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export,";
$sql .= " p.accountancy_code_buy, p.accountancy_code_buy_intra, p.accountancy_code_buy_export,";
@ -96,11 +95,14 @@ class box_produits_alerte_stock extends ModeleBoxes
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as s on p.rowid = s.fk_product";
$sql .= ' WHERE p.entity IN ('.getEntity($productstatic->element).')';
$sql .= " AND p.tosell = 1 AND p.seuil_stock_alerte > 0";
if (empty($user->rights->produit->lire)) $sql .= ' AND p.fk_product_type != 0';
if (empty($user->rights->service->lire)) $sql .= ' AND p.fk_product_type != 1';
if (empty($user->rights->produit->lire)) {
$sql .= ' AND p.fk_product_type != 0';
}
if (empty($user->rights->service->lire)) {
$sql .= ' AND p.fk_product_type != 1';
}
// Add where from hooks
if (is_object($hookmanager))
{
if (is_object($hookmanager)) {
$parameters = array('boxproductalertstocklist'=>1);
$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager->resPrint;
@ -113,8 +115,7 @@ class box_produits_alerte_stock extends ModeleBoxes
$sql .= $this->db->plimit($max, 0);
$result = $this->db->query($sql);
if ($result)
{
if ($result) {
$langs->load("stocks");
$num = $this->db->num_rows($result);
$line = 0;
@ -125,8 +126,7 @@ class box_produits_alerte_stock extends ModeleBoxes
$price_base_type = '';
// Multilangs
if (!empty($conf->global->MAIN_MULTILANGS)) // si l'option est active
{
if (!empty($conf->global->MAIN_MULTILANGS)) { // si l'option est active
$sqld = "SELECT label";
$sqld .= " FROM ".MAIN_DB_PREFIX."product_lang";
$sqld .= " WHERE fk_product=".$objp->rowid;
@ -134,11 +134,11 @@ class box_produits_alerte_stock extends ModeleBoxes
$sqld .= " LIMIT 1";
$resultd = $this->db->query($sqld);
if ($resultd)
{
if ($resultd) {
$objtp = $this->db->fetch_object($resultd);
if (isset($objtp->label) && $objtp->label != '')
if (isset($objtp->label) && $objtp->label != '') {
$objp->label = $objtp->label;
}
}
}
$productstatic->id = $objp->rowid;
@ -167,18 +167,16 @@ class box_produits_alerte_stock extends ModeleBoxes
'text' => $objp->label,
);
if (empty($conf->dynamicprices->enabled) || empty($objp->fk_price_expression))
{
if (empty($conf->dynamicprices->enabled) || empty($objp->fk_price_expression)) {
$price_base_type = $langs->trans($objp->price_base_type);
$price = ($objp->price_base_type == 'HT') ?price($objp->price) : $price = price($objp->price_ttc);
} else //Parse the dynamic price
{
{
$productstatic->fetch($objp->rowid, '', '', 1);
$priceparser = new PriceParser($this->db);
$price_result = $priceparser->parseProduct($productstatic);
if ($price_result >= 0) {
if ($objp->price_base_type == 'HT')
{
if ($objp->price_base_type == 'HT') {
$price_base_type = $langs->trans("HT");
} else {
$price_result = $price_result * (1 + ($productstatic->tva_tx / 100));
@ -186,7 +184,7 @@ class box_produits_alerte_stock extends ModeleBoxes
}
$price = price($price_result);
}
}
}
$this->info_box_contents[$line][] = array(
'td' => 'class="right nowraponall"',

View File

@ -94,13 +94,17 @@ class box_project extends ModeleBoxes
// Get list of project id allowed to user (in a string list separated by coma)
$projectsListId = '';
if (!$user->rights->projet->all->lire) $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $socid);
if (!$user->rights->projet->all->lire) {
$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $socid);
}
$sql = "SELECT p.rowid, p.ref, p.title, p.fk_statut as status, p.public";
$sql .= " FROM ".MAIN_DB_PREFIX."projet as p";
$sql .= " WHERE p.entity IN (".getEntity('project').")"; // Only current entity or severals if permission ok
$sql .= " AND p.fk_statut = 1"; // Only open projects
if (!$user->rights->projet->all->lire) $sql .= " AND p.rowid IN (".$projectsListId.")"; // public and assigned to, or restricted to company for external users
if (!$user->rights->projet->all->lire) {
$sql .= " AND p.rowid IN (".$projectsListId.")"; // public and assigned to, or restricted to company for external users
}
$sql .= " ORDER BY p.datec DESC";
//$sql.= $this->db->plimit($max, 0);
@ -141,12 +145,14 @@ class box_project extends ModeleBoxes
'td' => 'class="right"',
'text' => $objTask->nb."&nbsp;".$langs->trans("Tasks"),
);
if ($objTask->nb > 0)
if ($objTask->nb > 0) {
$this->info_box_contents[$i][] = array(
'td' => 'class="right"',
'text' => round($objTask->totprogress / $objTask->nb, 0)."%",
);
else $this->info_box_contents[$i][] = array('td' => 'class="right"', 'text' => "N/A&nbsp;");
} else {
$this->info_box_contents[$i][] = array('td' => 'class="right"', 'text' => "N/A&nbsp;");
}
$totalnbTask += $objTask->nb;
} else {
$this->info_box_contents[$i][] = array('td' => 'class="right"', 'text' => round(0));
@ -156,8 +162,7 @@ class box_project extends ModeleBoxes
$i++;
}
if ($max < $num)
{
if ($max < $num) {
$this->info_box_contents[$i][] = array('td' => 'colspan="5"', 'text' => '...');
$i++;
}

View File

@ -63,7 +63,9 @@ class box_prospect extends ModeleBoxes
$this->db = $db;
// disable box for such cases
if (!empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) $this->enabled = 0; // disabled by this option
if (!empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) {
$this->enabled = 0; // disabled by this option
}
$this->hidden = !($user->rights->societe->lire && empty($user->socid));
}
@ -84,31 +86,34 @@ class box_prospect extends ModeleBoxes
$this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedProspects", $max));
if ($user->rights->societe->lire)
{
if ($user->rights->societe->lire) {
$sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias";
$sql .= ", s.code_client, s.code_compta, s.client";
$sql .= ", s.logo, s.email, s.entity";
$sql .= ", s.fk_stcomm";
$sql .= ", s.datec, s.tms, s.status";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
if (!$user->rights->societe->client->voir && !$user->socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE s.client IN (2, 3)";
$sql .= " AND s.entity IN (".getEntity('societe').")";
if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
if ($user->socid) $sql .= " AND s.rowid = ".$user->socid;
if (!$user->rights->societe->client->voir && !$user->socid) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
}
if ($user->socid) {
$sql .= " AND s.rowid = ".$user->socid;
}
$sql .= " ORDER BY s.tms DESC";
$sql .= $this->db->plimit($max, 0);
dol_syslog(get_class($this)."::loadBox", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
if ($resql) {
$num = $this->db->num_rows($resql);
$line = 0;
while ($line < $num)
{
while ($line < $num) {
$objp = $this->db->fetch_object($resql);
$datec = $this->db->jdate($objp->datec);
$datem = $this->db->jdate($objp->tms);

View File

@ -81,8 +81,7 @@ class box_services_contracts extends ModeleBoxes
$this->info_box_head = array('text' => $langs->trans("BoxLastProductsInContract", $max));
if ($user->rights->service->lire && $user->rights->contrat->lire)
{
if ($user->rights->service->lire && $user->rights->contrat->lire) {
$contractstatic = new Contrat($this->db);
$contractlinestatic = new ContratLigne($this->db);
$thirdpartytmp = new Societe($this->db);
@ -96,23 +95,25 @@ class box_services_contracts extends ModeleBoxes
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."contrat as c ON s.rowid = c.fk_soc";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."contratdet as cd ON c.rowid = cd.fk_contrat";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid";
if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
if (!$user->rights->societe->client->voir && !$user->socid) {
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
}
$sql .= ")";
$sql .= " WHERE c.entity = ".$conf->entity;
if ($user->socid) $sql .= " AND s.rowid = ".$user->socid;
if ($user->socid) {
$sql .= " AND s.rowid = ".$user->socid;
}
$sql .= $this->db->order("c.tms", "DESC");
$sql .= $this->db->plimit($max, 0);
$result = $this->db->query($sql);
if ($result)
{
if ($result) {
$num = $this->db->num_rows($result);
$now = dol_now();
$i = 0;
while ($i < $num)
{
while ($i < $num) {
$late = '';
$objp = $this->db->fetch_object($result);
@ -145,11 +146,12 @@ class box_services_contracts extends ModeleBoxes
$thirdpartytmp->code_compta_fournisseur = $objp->code_compta_fournisseur;
$dateline = $this->db->jdate($objp->date_line);
if ($contractstatic->statut == Contrat::STATUS_VALIDATED && $objp->contractline_status == ContratLigne::STATUS_OPEN && !empty($dateline) && ($dateline + $conf->contrat->services->expires->warning_delay) < $now) $late = img_warning($langs->trans("Late"));
if ($contractstatic->statut == Contrat::STATUS_VALIDATED && $objp->contractline_status == ContratLigne::STATUS_OPEN && !empty($dateline) && ($dateline + $conf->contrat->services->expires->warning_delay) < $now) {
$late = img_warning($langs->trans("Late"));
}
// Label
if ($objp->product_id > 0)
{
if ($objp->product_id > 0) {
$productstatic->id = $objp->product_id;
$productstatic->type = $objp->product_type;
$productstatic->ref = $objp->product_ref;
@ -159,8 +161,7 @@ class box_services_contracts extends ModeleBoxes
$productstatic->status_buy = $objp->tobuy;
$text = $productstatic->getNomUrl(1, '', 20);
if ($objp->product_label)
{
if ($objp->product_label) {
$text .= ' - ';
//$productstatic->ref=$objp->label;
//$text .= $productstatic->getNomUrl(0,'',16);
@ -169,8 +170,7 @@ class box_services_contracts extends ModeleBoxes
$description = $objp->description;
// Add description in form
if (!empty($conf->global->PRODUIT_DESC_IN_FORM))
{
if (!empty($conf->global->PRODUIT_DESC_IN_FORM)) {
//$text .= (! empty($objp->description) && $objp->description!=$objp->product_label)?'<br>'.dol_htmlentitiesbr($objp->description):'';
$description = ''; // Already added into main visible desc
}
@ -212,10 +212,12 @@ class box_services_contracts extends ModeleBoxes
$i++;
}
if ($num == 0) $this->info_box_contents[$i][0] = array(
if ($num == 0) {
$this->info_box_contents[$i][0] = array(
'td' => 'class="center opacitymedium"',
'text'=>$langs->trans("NoContractedProducts")
);
);
}
$this->db->free($result);
} else {

View File

@ -79,28 +79,32 @@ class box_services_expired extends ModeleBoxes
$this->info_box_head = array('text' => $langs->trans("BoxLastExpiredServices", $max));
if ($user->rights->contrat->lire)
{
if ($user->rights->contrat->lire) {
// Select contracts with at least one expired service
$sql = "SELECT ";
$sql .= " c.rowid, c.ref, c.statut as fk_statut, c.date_contrat, c.ref_customer, c.ref_supplier,";
$sql .= " s.nom as name, s.rowid as socid, s.email, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,";
$sql .= " MIN(cd.date_fin_validite) as date_line, COUNT(cd.rowid) as nb_services";
$sql .= " FROM ".MAIN_DB_PREFIX."contrat as c, ".MAIN_DB_PREFIX."societe s, ".MAIN_DB_PREFIX."contratdet as cd";
if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
if (!$user->rights->societe->client->voir && !$user->socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE cd.statut = 4 AND cd.date_fin_validite <= '".$this->db->idate($now)."'";
$sql .= " AND c.entity = ".$conf->entity;
$sql .= " AND c.fk_soc=s.rowid AND cd.fk_contrat=c.rowid AND c.statut > 0";
if ($user->socid) $sql .= ' AND c.fk_soc = '.$user->socid;
if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
if ($user->socid) {
$sql .= ' AND c.fk_soc = '.$user->socid;
}
if (!$user->rights->societe->client->voir && !$user->socid) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
}
$sql .= " GROUP BY c.rowid, c.ref, c.statut, c.date_contrat, c.ref_customer, c.ref_supplier, s.nom, s.rowid";
$sql .= ", s.email, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur";
$sql .= " ORDER BY date_line ASC";
$sql .= $this->db->plimit($max, 0);
$resql = $this->db->query($sql);
if ($resql)
{
if ($resql) {
$num = $this->db->num_rows($resql);
$i = 0;
@ -108,8 +112,7 @@ class box_services_expired extends ModeleBoxes
$thirdpartytmp = new Societe($this->db);
$contract = new Contrat($this->db);
while ($i < $num)
{
while ($i < $num) {
$late = '';
$objp = $this->db->fetch_object($resql);
@ -131,7 +134,9 @@ class box_services_expired extends ModeleBoxes
$contract->ref_supplier = $objp->ref_supplier;
$dateline = $this->db->jdate($objp->date_line);
if (($dateline + $conf->contrat->services->expires->warning_delay) < $now) $late = img_warning($langs->trans("Late"));
if (($dateline + $conf->contrat->services->expires->warning_delay) < $now) {
$late = img_warning($langs->trans("Late"));
}
$this->info_box_contents[$i][] = array(
'td' => 'class="nowraponall"',
@ -160,8 +165,7 @@ class box_services_expired extends ModeleBoxes
$i++;
}
if ($num == 0)
{
if ($num == 0) {
$langs->load("contracts");
$this->info_box_contents[$i][] = array(
'td' => 'class="nohover opacitymedium center"',

View File

@ -86,8 +86,7 @@ class box_shipments extends ModeleBoxes
$this->info_box_head = array('text' => $langs->trans("BoxTitleLastCustomerShipments", $max));
if ($user->rights->expedition->lire)
{
if ($user->rights->expedition->lire) {
$sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias";
$sql .= ", s.code_client, s.code_compta, s.client";
$sql .= ", s.logo, s.email, s.entity";
@ -102,12 +101,21 @@ class box_shipments extends ModeleBoxes
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON e.rowid = el.fk_target AND el.targettype = 'shipping' AND el.sourcetype IN ('commande')";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON el.fk_source = c.rowid AND el.sourcetype IN ('commande') AND el.targettype = 'shipping'";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc";
if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON e.fk_soc = sc.fk_soc";
if (!$user->rights->societe->client->voir && !$user->socid) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON e.fk_soc = sc.fk_soc";
}
$sql .= " WHERE e.entity IN (".getEntity('expedition').")";
if (!empty($conf->global->ORDER_BOX_LAST_SHIPMENTS_VALIDATED_ONLY)) $sql .= " AND e.fk_statut = 1";
if ($user->socid > 0) $sql.= " AND s.rowid = ".$user->socid;
if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND sc.fk_user = ".$user->id;
else $sql .= " ORDER BY e.date_delivery, e.ref DESC ";
if (!empty($conf->global->ORDER_BOX_LAST_SHIPMENTS_VALIDATED_ONLY)) {
$sql .= " AND e.fk_statut = 1";
}
if ($user->socid > 0) {
$sql.= " AND s.rowid = ".$user->socid;
}
if (!$user->rights->societe->client->voir && !$user->socid) {
$sql .= " AND sc.fk_user = ".$user->id;
} else {
$sql .= " ORDER BY e.date_delivery, e.ref DESC ";
}
$sql .= $this->db->plimit($max, 0);
$result = $this->db->query($sql);
@ -162,10 +170,12 @@ class box_shipments extends ModeleBoxes
$line++;
}
if ($num == 0) $this->info_box_contents[$line][0] = array(
if ($num == 0) {
$this->info_box_contents[$line][0] = array(
'td' => 'class="center opacitymedium"',
'text'=>$langs->trans("NoRecordedShipments")
);
);
}
$this->db->free($result);
} else {

View File

@ -81,8 +81,7 @@ class box_supplier_orders extends ModeleBoxes
$this->info_box_head = array('text' => $langs->trans("BoxTitleLatest".(!empty($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) ? "" : "Modified")."SupplierOrders", $max));
if ($user->rights->fournisseur->commande->lire)
{
if ($user->rights->fournisseur->commande->lire) {
$sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias";
$sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
$sql .= ", s.logo, s.email, s.entity";
@ -93,18 +92,26 @@ class box_supplier_orders extends ModeleBoxes
$sql .= ", c.fk_statut";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql .= ", ".MAIN_DB_PREFIX."commande_fournisseur as c";
if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
if (!$user->rights->societe->client->voir && !$user->socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE c.fk_soc = s.rowid";
$sql .= " AND c.entity IN (".getEntity('supplier_order').")";
if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
if ($user->socid) $sql .= " AND s.rowid = ".$user->socid;
if (!empty($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE)) $sql .= " ORDER BY c.date_commande DESC, c.ref DESC ";
else $sql .= " ORDER BY c.tms DESC, c.ref DESC ";
if (!$user->rights->societe->client->voir && !$user->socid) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
}
if ($user->socid) {
$sql .= " AND s.rowid = ".$user->socid;
}
if (!empty($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE)) {
$sql .= " ORDER BY c.date_commande DESC, c.ref DESC ";
} else {
$sql .= " ORDER BY c.tms DESC, c.ref DESC ";
}
$sql .= $this->db->plimit($max, 0);
$result = $this->db->query($sql);
if ($result)
{
if ($result) {
$num = $this->db->num_rows($result);
$line = 0;
@ -156,11 +163,12 @@ class box_supplier_orders extends ModeleBoxes
$line++;
}
if ($num == 0)
if ($num == 0) {
$this->info_box_contents[$line][] = array(
'td' => 'class="center"',
'text' => $langs->trans("NoSupplierOrder"),
);
}
$this->db->free($result);
} else {

View File

@ -81,8 +81,7 @@ class box_supplier_orders_awaiting_reception extends ModeleBoxes
$this->info_box_head = array('text' => $langs->trans("BoxTitleSupplierOrdersAwaitingReception", $max));
if ($user->rights->fournisseur->commande->lire)
{
if ($user->rights->fournisseur->commande->lire) {
$sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias";
$sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.fournisseur";
$sql .= ", s.logo, s.email, s.entity";
@ -93,19 +92,27 @@ class box_supplier_orders_awaiting_reception extends ModeleBoxes
$sql .= ", c.fk_statut";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql .= ", ".MAIN_DB_PREFIX."commande_fournisseur as c";
if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
if (!$user->rights->societe->client->voir && !$user->socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE c.fk_soc = s.rowid";
$sql .= " AND c.entity IN (".getEntity('supplier_order').")";
$sql .= " AND c.fk_statut IN (".CommandeFournisseur::STATUS_ORDERSENT.", ".CommandeFournisseur::STATUS_RECEIVED_PARTIALLY.")";
if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
if ($user->socid) $sql .= " AND s.rowid = ".$user->socid;
if (!empty($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE)) $sql .= " ORDER BY c.date_commande DESC, c.ref DESC";
else $sql .= " ORDER BY c.date_livraison ASC, c.fk_statut ASC";
if (!$user->rights->societe->client->voir && !$user->socid) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
}
if ($user->socid) {
$sql .= " AND s.rowid = ".$user->socid;
}
if (!empty($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE)) {
$sql .= " ORDER BY c.date_commande DESC, c.ref DESC";
} else {
$sql .= " ORDER BY c.date_livraison ASC, c.fk_statut ASC";
}
$sql .= $this->db->plimit($max, 0);
$result = $this->db->query($sql);
if ($result)
{
if ($result) {
$num = $this->db->num_rows($result);
$line = 0;
@ -162,11 +169,12 @@ class box_supplier_orders_awaiting_reception extends ModeleBoxes
$line++;
}
if ($num == 0)
if ($num == 0) {
$this->info_box_contents[$line][] = array(
'td' => 'class="center"',
'text' => $langs->trans("NoSupplierOrder"),
);
}
$this->db->free($result);
} else {

View File

@ -145,7 +145,9 @@ class box_task extends ModeleBoxes
// Get list of project id allowed to user (in a string list separated by coma)
$projectsListId = '';
if (!$user->rights->projet->all->lire) $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $socid);
if (!$user->rights->projet->all->lire) {
$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $socid);
}
$sql = "SELECT pt.rowid, pt.ref, pt.fk_projet, pt.fk_task_parent, pt.datec, pt.dateo, pt.datee, pt.datev, pt.label, pt.description, pt.duration_effective, pt.planned_workload, pt.progress";
$sql .= ", p.rowid project_id, p.ref project_ref, p.title project_title";
@ -166,7 +168,9 @@ class box_task extends ModeleBoxes
$sql .= " AND p.fk_statut = ".Project::STATUS_VALIDATED;
$sql .= " AND (pt.progress < 100 OR pt.progress IS NULL ) "; // 100% is done and not displayed
$sql .= " AND p.usage_task = 1 ";
if (!$user->rights->projet->all->lire) $sql .= " AND p.rowid IN (".$projectsListId.")"; // public and assigned to, or restricted to company for external users
if (!$user->rights->projet->all->lire) {
$sql .= " AND p.rowid IN (".$projectsListId.")"; // public and assigned to, or restricted to company for external users
}
$sql .= " ORDER BY pt.datee ASC, pt.dateo ASC";
$sql .= $this->db->plimit($max, 0);

View File

@ -67,7 +67,9 @@ class box_validated_projects extends ModeleBoxes
$this->hidden = !($user->rights->projet->lire);
if ($conf->global->MAIN_FEATURES_LEVEL < 2) $this->enabled = 0;
if ($conf->global->MAIN_FEATURES_LEVEL < 2) {
$this->enabled = 0;
}
}
/**
@ -99,7 +101,9 @@ class box_validated_projects extends ModeleBoxes
// Get list of project id allowed to user (in a string list separated by coma)
$projectsListId = '';
if (!$user->rights->projet->all->lire) $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $socid);
if (!$user->rights->projet->all->lire) {
$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $socid);
}
// I tried to solve sql error and performance problem, rewriting sql request but it is not clear what we want.
// Count of tasks without time spent for tasks we are assigned too or
@ -111,7 +115,9 @@ class box_validated_projects extends ModeleBoxes
// TODO Replace -1, -2, -3 with ID used for type of contat project_task into llx_c_type_contact. Once done, we can switch widget as stable.
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."element_contact as ec ON ec.element_id = t.rowid AND fk_c_type_contact IN (-1, -2, -3)";
$sql .= " WHERE p.fk_statut = 1"; // Only open projects
if ($projectsListId) $sql .= ' AND p.rowid IN ('.$this->db->sanitize($projectsListId).')'; // Only project we ara allowed
if ($projectsListId) {
$sql .= ' AND p.rowid IN ('.$this->db->sanitize($projectsListId).')'; // Only project we ara allowed
}
$sql .= " AND t.rowid NOT IN (SELECT fk_task FROM ".MAIN_DB_PREFIX."projet_task_time WHERE fk_user =".$user->id.")";
$sql .= " GROUP BY p.rowid, p.ref, p.fk_soc, p.dateo";
$sql .= " ORDER BY p.dateo ASC";
@ -161,8 +167,7 @@ class box_validated_projects extends ModeleBoxes
'asis' => 1,
'url' => DOL_URL_ROOT.'/societe/card.php?socid='.$obj2->rowid
);
}
else {
} else {
$this->info_box_contents[$i][] = array(
'td' => 'class="tdoverflowmax150 maxwidth200onsmartphone"',
'text' => '',

View File

@ -150,11 +150,9 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" box
dol_syslog(get_class($this)."::fetch rowid=".$rowid);
$resql = $this->db->query($sql);
if ($resql)
{
if ($resql) {
$obj = $this->db->fetch_object($resql);
if ($obj)
{
if ($obj) {
$this->id = $obj->id;
$this->rowid = $obj->id; // For backward compatibility
$this->box_id = $obj->box_id;
@ -182,7 +180,9 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" box
{
global $langs, $user, $conf;
if (!empty($this->hidden)) return '\n<!-- Box ".get_class($this)." hidden -->\n'; // Nothing done if hidden (for example when user has no permission)
if (!empty($this->hidden)) {
return '\n<!-- Box ".get_class($this)." hidden -->\n'; // Nothing done if hidden (for example when user has no permission)
}
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
@ -200,47 +200,51 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" box
// Define nbcol and nblines of the box to show
$nbcol = 0;
if (isset($contents[0])) $nbcol = count($contents[0]);
if (isset($contents[0])) {
$nbcol = count($contents[0]);
}
$nblines = count($contents);
$out .= "\n<!-- Box ".get_class($this)." start -->\n";
$out .= '<div class="box boxdraggable" id="boxto_'.$this->box_id.'">'."\n";
if (!empty($head['text']) || !empty($head['sublink']) || !empty($head['subpicto']) || $nblines)
{
if (!empty($head['text']) || !empty($head['sublink']) || !empty($head['subpicto']) || $nblines) {
$out .= '<table summary="boxtable'.$this->box_id.'" width="100%" class="noborder boxtable">'."\n";
}
// Show box title
if (!empty($head['text']) || !empty($head['sublink']) || !empty($head['subpicto']))
{
if (!empty($head['text']) || !empty($head['sublink']) || !empty($head['subpicto'])) {
$out .= '<tr class="liste_titre box_titre">';
$out .= '<td';
if ($nbcol > 0) { $out .= ' colspan="'.$nbcol.'"'; }
if ($nbcol > 0) {
$out .= ' colspan="'.$nbcol.'"';
}
$out .= '>';
if (!empty($conf->use_javascript_ajax))
{
if (!empty($conf->use_javascript_ajax)) {
//$out.= '<table summary="" class="nobordernopadding" width="100%"><tr><td class="tdoverflowmax150 maxwidth150onsmartphone">';
$out .= '<div class="tdoverflowmax250 maxwidth150onsmartphone float">';
}
if (!empty($head['text']))
{
if (!empty($head['text'])) {
$s = dol_trunc($head['text'], isset($head['limit']) ? $head['limit'] : $MAXLENGTHBOX);
$out .= $s;
}
if (!empty($conf->use_javascript_ajax))
{
if (!empty($conf->use_javascript_ajax)) {
$out .= '</div>';
}
//$out.= '</td>';
if (!empty($conf->use_javascript_ajax))
{
if (!empty($conf->use_javascript_ajax)) {
$sublink = '';
if (!empty($head['sublink'])) $sublink .= '<a href="'.$head['sublink'].'"'.(empty($head['target']) ? '' : ' target="'.$head['target'].'"').'>';
if (!empty($head['subpicto'])) $sublink .= img_picto($head['subtext'], $head['subpicto'], 'class="opacitymedium marginleftonly '.(empty($head['subclass']) ? '' : $head['subclass']).'" id="idsubimg'.$this->boxcode.'"');
if (!empty($head['sublink'])) $sublink .= '</a>';
if (!empty($head['sublink'])) {
$sublink .= '<a href="'.$head['sublink'].'"'.(empty($head['target']) ? '' : ' target="'.$head['target'].'"').'>';
}
if (!empty($head['subpicto'])) {
$sublink .= img_picto($head['subtext'], $head['subpicto'], 'class="opacitymedium marginleftonly '.(empty($head['subclass']) ? '' : $head['subclass']).'" id="idsubimg'.$this->boxcode.'"');
}
if (!empty($head['sublink'])) {
$sublink .= '</a>';
}
//$out.= '<td class="nocellnopadd boxclose right nowraponall">';
$out .= '<div class="nocellnopadd boxclose floatright nowraponall">';
@ -250,7 +254,9 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" box
$out .= img_picto($langs->trans("CloseBox", $this->box_id), 'close_title', 'class="opacitymedium boxclose cursorpointer marginleftonly" rel="x:y" id="imgclose'.$this->box_id.'"');
$label = $head['text'];
//if (! empty($head['graph'])) $label.=' ('.$langs->trans("Graph").')';
if (!empty($head['graph'])) $label .= ' <span class="opacitymedium fa fa-bar-chart"></span>';
if (!empty($head['graph'])) {
$label .= ' <span class="opacitymedium fa fa-bar-chart"></span>';
}
$out .= '<input type="hidden" id="boxlabelentry'.$this->box_id.'" value="'.dol_escape_htmltag($label).'">';
//$out.= '</td></tr></table>';
$out .= '</div>';
@ -261,23 +267,25 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" box
}
// Show box lines
if ($nblines)
{
if ($nblines) {
// Loop on each record
for ($i = 0, $n = $nblines; $i < $n; $i++)
{
if (isset($contents[$i]))
{
for ($i = 0, $n = $nblines; $i < $n; $i++) {
if (isset($contents[$i])) {
// TR
if (isset($contents[$i][0]['tr'])) $out .= '<tr '.$contents[$i][0]['tr'].'>';
else $out .= '<tr class="oddeven">';
if (isset($contents[$i][0]['tr'])) {
$out .= '<tr '.$contents[$i][0]['tr'].'>';
} else {
$out .= '<tr class="oddeven">';
}
// Loop on each TD
$nbcolthisline = count($contents[$i]);
for ($j = 0; $j < $nbcolthisline; $j++) {
// Define tdparam
$tdparam = '';
if (!empty($contents[$i][$j]['td'])) $tdparam .= ' '.$contents[$i][$j]['td'];
if (!empty($contents[$i][$j]['td'])) {
$tdparam .= ' '.$contents[$i][$j]['td'];
}
$text = isset($contents[$i][$j]['text']) ? $contents[$i][$j]['text'] : '';
$textwithnotags = preg_replace('/<([^>]+)>/i', '', $text);
@ -286,14 +294,15 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" box
$textnoformat = isset($contents[$i][$j]['textnoformat']) ? $contents[$i][$j]['textnoformat'] : '';
//$out.= "xxx $textwithnotags y";
if (empty($contents[$i][$j]['tooltip'])) $contents[$i][$j]['tooltip'] = "";
if (empty($contents[$i][$j]['tooltip'])) {
$contents[$i][$j]['tooltip'] = "";
}
$tooltip = isset($contents[$i][$j]['tooltip']) ? $contents[$i][$j]['tooltip'] : '';
$out .= '<td'.$tdparam.'>'."\n";
// Url
if (!empty($contents[$i][$j]['url']) && empty($contents[$i][$j]['logo']))
{
if (!empty($contents[$i][$j]['url']) && empty($contents[$i][$j]['logo'])) {
$out .= '<a href="'.$contents[$i][$j]['url'].'"';
if (!empty($tooltip)) {
$out .= ' title="'.dol_escape_htmltag($langs->trans("Show").' '.$tooltip, 1).'" class="classfortooltip"';
@ -304,27 +313,40 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" box
}
// Logo
if (!empty($contents[$i][$j]['logo']))
{
if (!empty($contents[$i][$j]['logo'])) {
$logo = preg_replace("/^object_/i", "", $contents[$i][$j]['logo']);
$out .= '<a href="'.$contents[$i][$j]['url'].'">';
$out .= img_object($langs->trans("Show").' '.$tooltip, $logo, 'class="classfortooltip"');
}
$maxlength = $MAXLENGTHBOX;
if (!empty($contents[$i][$j]['maxlength'])) $maxlength = $contents[$i][$j]['maxlength'];
if (!empty($contents[$i][$j]['maxlength'])) {
$maxlength = $contents[$i][$j]['maxlength'];
}
if ($maxlength) $textwithnotags = dol_trunc($textwithnotags, $maxlength);
if (preg_match('/^<(img|div|span)/i', $text) || !empty($contents[$i][$j]['asis'])) $out .= $text; // show text with no html cleaning
else $out .= $textwithnotags; // show text with html cleaning
if ($maxlength) {
$textwithnotags = dol_trunc($textwithnotags, $maxlength);
}
if (preg_match('/^<(img|div|span)/i', $text) || !empty($contents[$i][$j]['asis'])) {
$out .= $text; // show text with no html cleaning
} else {
$out .= $textwithnotags; // show text with html cleaning
}
// End Url
if (!empty($contents[$i][$j]['url'])) $out .= '</a>';
if (!empty($contents[$i][$j]['url'])) {
$out .= '</a>';
}
if (preg_match('/^<(img|div|span)/i', $text2) || !empty($contents[$i][$j]['asis2'])) $out .= $text2; // show text with no html cleaning
else $out .= $text2withnotags; // show text with html cleaning
if (preg_match('/^<(img|div|span)/i', $text2) || !empty($contents[$i][$j]['asis2'])) {
$out .= $text2; // show text with no html cleaning
} else {
$out .= $text2withnotags; // show text with html cleaning
}
if (!empty($textnoformat)) $out .= "\n".$textnoformat."\n";
if (!empty($textnoformat)) {
$out .= "\n".$textnoformat."\n";
}
$out .= "</td>\n";
}
@ -334,13 +356,14 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" box
}
}
if (!empty($head['text']) || !empty($head['sublink']) || !empty($head['subpicto']) || $nblines)
{
if (!empty($head['text']) || !empty($head['sublink']) || !empty($head['subpicto']) || $nblines) {
$out .= "</table>\n";
}
// If invisible box with no contents
if (empty($head['text']) && empty($head['sublink']) && empty($head['subpicto']) && !$nblines) $out .= "<br>\n";
if (empty($head['text']) && empty($head['sublink']) && empty($head['subpicto']) && !$nblines) {
$out .= "<br>\n";
}
$out .= "</div>\n";
@ -354,8 +377,11 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" box
$out .= dol_readcachefile($cachedir, $filename);
}
if ($nooutput) return $out;
else print $out;
if ($nooutput) {
return $out;
} else {
print $out;
}
return '';
}
@ -382,42 +408,39 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" box
//$dirwidget=array_merge(array('/core/boxes/'), $conf->modules_parts['widgets']);
$dirwidget = array('/core/boxes/'); // $conf->modules_parts['widgets'] is not required
if (is_array($forcedirwidget))
{
if (is_array($forcedirwidget)) {
$dirwidget = $forcedirwidget;
}
foreach ($dirwidget as $reldir)
{
foreach ($dirwidget as $reldir) {
$dir = dol_buildpath($reldir, 0);
$newdir = dol_osencode($dir);
// Check if directory exists (we do not use dol_is_dir to avoid loading files.lib.php at each call)
if (!is_dir($newdir)) continue;
if (!is_dir($newdir)) {
continue;
}
$handle = opendir($newdir);
if (is_resource($handle))
{
while (($file = readdir($handle)) !== false)
{
if (is_resource($handle)) {
while (($file = readdir($handle)) !== false) {
$reg = array();
if (is_readable($newdir.'/'.$file) && preg_match('/^(.+)\.php/', $file, $reg))
{
if (preg_match('/\.back$/', $file)) continue;
if (is_readable($newdir.'/'.$file) && preg_match('/^(.+)\.php/', $file, $reg)) {
if (preg_match('/\.back$/', $file)) {
continue;
}
$part1 = $reg[1];
$modName = ucfirst($reg[1]);
//print "file=$file"; print "modName=$modName"; exit;
if (in_array($modName, $modules))
{
if (in_array($modName, $modules)) {
$langs->load("errors");
print '<div class="error">'.$langs->trans("Error").' : '.$langs->trans("ErrorDuplicateWidget", $modName, "").'</div>';
} else {
try {
include_once $newdir.'/'.$file;
} catch (Exception $e)
{
} catch (Exception $e) {
print $e->getMessage();
}
}
@ -442,27 +465,28 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" box
$j = 0;
// Loop on each widget
foreach ($orders as $key => $value)
{
foreach ($orders as $key => $value) {
$modName = $modules[$key];
if (empty($modName)) continue;
if (empty($modName)) {
continue;
}
if (!class_exists($modName))
{
if (!class_exists($modName)) {
print 'Error: A widget file was found but its class "'.$modName.'" was not found.'."<br>\n";
continue;
}
$objMod = new $modName($db);
if (is_object($objMod))
{
if (is_object($objMod)) {
// Define disabledbyname and disabledbymodule
$disabledbyname = 0;
$disabledbymodule = 0; // TODO Set to 2 if module is not enabled
$module = '';
// Check if widget file is disabled by name
if (preg_match('/NORUN$/i', $files[$key])) $disabledbyname = 1;
if (preg_match('/NORUN$/i', $files[$key])) {
$disabledbyname = 1;
}
// We set info of modules
$widget[$j]['picto'] = $objMod->picto ?img_object('', $objMod->picto) : img_object('', 'generic');
@ -472,12 +496,16 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" box
$widget[$j]['iscoreorexternal'] = $iscoreorexternal[$key];
//$widget[$j]['version'] = $objMod->getVersion();
$widget[$j]['status'] = img_picto($langs->trans("Active"), 'tick');
if ($disabledbyname > 0 || $disabledbymodule > 1) $widget[$j]['status'] = '';
if ($disabledbyname > 0 || $disabledbymodule > 1) {
$widget[$j]['status'] = '';
}
$text = '<b>'.$langs->trans("Description").':</b><br>';
$text .= $objMod->boxlabel.'<br>';
$text .= '<br><b>'.$langs->trans("Status").':</b><br>';
if ($disabledbymodule == 2) $text .= $langs->trans("WidgetDisabledAsModuleDisabled", $module).'<br>';
if ($disabledbymodule == 2) {
$text .= $langs->trans("WidgetDisabledAsModuleDisabled", $module).'<br>';
}
$widget[$j]['info'] = $text;
}

View File

@ -70,12 +70,15 @@ class CSMSFile
// On definit fin de ligne
$this->eol = "\n";
if (preg_match('/^win/i', PHP_OS)) $this->eol = "\r\n";
if (preg_match('/^mac/i', PHP_OS)) $this->eol = "\r";
if (preg_match('/^win/i', PHP_OS)) {
$this->eol = "\r\n";
}
if (preg_match('/^mac/i', PHP_OS)) {
$this->eol = "\r";
}
// If ending method not defined
if (empty($conf->global->MAIN_SMS_SENDMODE))
{
if (empty($conf->global->MAIN_SMS_SENDMODE)) {
$this->error = 'No SMS Engine defined';
return -1;
}
@ -113,13 +116,13 @@ class CSMSFile
$this->message = stripslashes($this->message);
if (!empty($conf->global->MAIN_SMS_DEBUG)) $this->dump_sms();
if (!empty($conf->global->MAIN_SMS_DEBUG)) {
$this->dump_sms();
}
if (empty($conf->global->MAIN_DISABLE_ALL_SMS))
{
if (empty($conf->global->MAIN_DISABLE_ALL_SMS)) {
// Action according to choosed sending method
if ($conf->global->MAIN_SMS_SENDMODE == 'ovh') // Backward compatibility @deprecated
{
if ($conf->global->MAIN_SMS_SENDMODE == 'ovh') { // Backward compatibility @deprecated
dol_include_once('/ovh/class/ovhsms.class.php');
$sms = new OvhSms($this->db);
$sms->expe = $this->addr_from;
@ -136,17 +139,17 @@ class CSMSFile
$res = $sms->SmsSend();
if ($res <= 0)
{
if ($res <= 0) {
$this->error = $sms->error;
dol_syslog("CSMSFile::sendfile: sms send error=".$this->error, LOG_ERR);
} else {
dol_syslog("CSMSFile::sendfile: sms send success with id=".$res, LOG_DEBUG);
//var_dump($res); // 1973128
if (!empty($conf->global->MAIN_SMS_DEBUG)) $this->dump_sms_result($res);
if (!empty($conf->global->MAIN_SMS_DEBUG)) {
$this->dump_sms_result($res);
}
}
} elseif (!empty($conf->global->MAIN_SMS_SENDMODE)) // $conf->global->MAIN_SMS_SENDMODE looks like a value 'class@module'
{
} elseif (!empty($conf->global->MAIN_SMS_SENDMODE)) { // $conf->global->MAIN_SMS_SENDMODE looks like a value 'class@module'
$tmp = explode('@', $conf->global->MAIN_SMS_SENDMODE);
$classfile = $tmp[0]; $module = (empty($tmp[1]) ? $tmp[0] : $tmp[1]);
dol_include_once('/'.$module.'/class/'.$classfile.'.class.php');
@ -169,16 +172,16 @@ class CSMSFile
$this->error = $sms->error;
$this->errors = $sms->errors;
if ($res <= 0)
{
if ($res <= 0) {
dol_syslog("CSMSFile::sendfile: sms send error=".$this->error, LOG_ERR);
} else {
dol_syslog("CSMSFile::sendfile: sms send success with id=".$res, LOG_DEBUG);
//var_dump($res); // 1973128
if (!empty($conf->global->MAIN_SMS_DEBUG)) $this->dump_sms_result($res);
if (!empty($conf->global->MAIN_SMS_DEBUG)) {
$this->dump_sms_result($res);
}
}
} catch (Exception $e)
{
} catch (Exception $e) {
dol_print_error('', 'Error to get list of senders: '.$e->getMessage());
}
} else {
@ -210,8 +213,7 @@ class CSMSFile
// phpcs:enable
global $conf, $dolibarr_main_data_root;
if (@is_writeable($dolibarr_main_data_root)) // Avoid fatal error on fopen with open_basedir
{
if (@is_writeable($dolibarr_main_data_root)) { // Avoid fatal error on fopen with open_basedir
$outputfile = $dolibarr_main_data_root."/dolibarr_sms.log";
$fp = fopen($outputfile, "w");
@ -224,8 +226,9 @@ class CSMSFile
fputs($fp, "Message:\n".$this->message);
fclose($fp);
if (!empty($conf->global->MAIN_UMASK))
@chmod($outputfile, octdec($conf->global->MAIN_UMASK));
if (!empty($conf->global->MAIN_UMASK)) {
@chmod($outputfile, octdec($conf->global->MAIN_UMASK));
}
}
}
@ -242,16 +245,16 @@ class CSMSFile
// phpcs:enable
global $conf, $dolibarr_main_data_root;
if (@is_writeable($dolibarr_main_data_root)) // Avoid fatal error on fopen with open_basedir
{
if (@is_writeable($dolibarr_main_data_root)) { // Avoid fatal error on fopen with open_basedir
$outputfile = $dolibarr_main_data_root."/dolibarr_sms.log";
$fp = fopen($outputfile, "a+");
fputs($fp, "\nResult id=".$result);
fclose($fp);
if (!empty($conf->global->MAIN_UMASK))
@chmod($outputfile, octdec($conf->global->MAIN_UMASK));
if (!empty($conf->global->MAIN_UMASK)) {
@chmod($outputfile, octdec($conf->global->MAIN_UMASK));
}
}
}
}

View File

@ -75,8 +75,7 @@ class AntiVir
$return = 0;
if (preg_match('/\.virus$/i', $file))
{
if (preg_match('/\.virus$/i', $file)) {
$this->errors[] = 'File has an extension saying file is a virus';
return -97;
}
@ -93,12 +92,14 @@ class AntiVir
// Run CLI command. If run of Windows, you can get return with echo %ERRORLEVEL%
$lastline = exec($fullcommand, $output, $return_var);
if (is_null($output)) $output = array();
if (is_null($output)) {
$output = array();
}
//print "x".$lastline." - ".join(',',$output)." - ".$return_var."y";exit;
/*
$outputfile=$conf->admin->dir_temp.'/dol_avscan_file.out.'.session_id();
$outputfile=$conf->admin->dir_temp.'/dol_avscan_file.out.'.session_id();
$handle = fopen($outputfile, 'w');
if ($handle)
{
@ -130,14 +131,12 @@ class AntiVir
dol_syslog("AntiVir::dol_avscan_file Result return_var=".$return_var." output=".join(',', $output));
$returncodevirus = 1;
if ($return_var == $returncodevirus) // Virus found
{
if ($return_var == $returncodevirus) { // Virus found
$this->errors = $output;
return -99;
}
if ($return_var > 0) // If other error
{
if ($return_var > 0) { // If other error
$this->errors = $output;
return -98;
}
@ -174,10 +173,13 @@ class AntiVir
$param = preg_replace('/%maxfilesize/', $maxfilesize, $param);
$param = preg_replace('/%file/', trim($file), $param);
if (!preg_match('/%file/', $conf->global->MAIN_ANTIVIRUS_PARAM))
if (!preg_match('/%file/', $conf->global->MAIN_ANTIVIRUS_PARAM)) {
$param = $param." ".escapeshellarg(trim($file));
}
if (preg_match("/\s/", $command)) $command = escapeshellarg($command); // Use quotes on command. Using escapeshellcmd fails.
if (preg_match("/\s/", $command)) {
$command = escapeshellarg($command); // Use quotes on command. Using escapeshellcmd fails.
}
$ret = $command.' '.$param;
//$ret=$command.' '.$param.' 2>&1';

View File

@ -76,9 +76,15 @@ class Canvas
private function _cleanaction($action)
{
$newaction = $action;
if ($newaction == 'add') $newaction = 'create';
if ($newaction == 'update') $newaction = 'edit';
if (empty($newaction) || $newaction == 'delete' || $newaction == 'create_user' || $newaction == 'presend' || $newaction == 'send') $newaction = 'view';
if ($newaction == 'add') {
$newaction = 'create';
}
if ($newaction == 'update') {
$newaction = 'edit';
}
if (empty($newaction) || $newaction == 'delete' || $newaction == 'create_user' || $newaction == 'presend' || $newaction == 'send') {
$newaction = 'view';
}
return $newaction;
}
@ -101,18 +107,18 @@ class Canvas
$this->card = $card;
$this->dirmodule = $module;
// Correct values if canvas is into an external module
if (preg_match('/^([^@]+)@([^@]+)$/i', $canvas, $regs))
{
if (preg_match('/^([^@]+)@([^@]+)$/i', $canvas, $regs)) {
$this->canvas = $regs[1];
$this->dirmodule = $regs[2];
}
// For compatibility
if ($this->dirmodule == 'thirdparty') { $this->dirmodule = 'societe'; }
if ($this->dirmodule == 'thirdparty') {
$this->dirmodule = 'societe';
}
// Control file
$controlclassfile = dol_buildpath('/'.$this->dirmodule.'/canvas/'.$this->canvas.'/actions_'.$this->card.'_'.$this->canvas.'.class.php');
if (file_exists($controlclassfile))
{
if (file_exists($controlclassfile)) {
// Include actions class (controller)
$this->control_file = $controlclassfile;
require_once $controlclassfile;
@ -124,8 +130,7 @@ class Canvas
// Template dir
$this->template_dir = dol_buildpath('/'.$this->dirmodule.'/canvas/'.$this->canvas.'/tpl/');
if (!is_dir($this->template_dir))
{
if (!is_dir($this->template_dir)) {
$this->template_dir = '';
}
@ -145,7 +150,9 @@ class Canvas
public function assign_values(&$action = 'view', $id = 0, $ref = '')
{
// phpcs:enable
if (method_exists($this->control, 'assign_values')) $this->control->assign_values($action, $id, $ref);
if (method_exists($this->control, 'assign_values')) {
$this->control->assign_values($action, $id, $ref);
}
}
/**
@ -156,10 +163,15 @@ class Canvas
*/
public function displayCanvasExists($action)
{
if (empty($this->template_dir)) return 0;
if (empty($this->template_dir)) {
return 0;
}
if (file_exists($this->template_dir.(!empty($this->card) ? $this->card.'_' : '').$this->_cleanaction($action).'.tpl.php')) return 1;
else return 0;
if (file_exists($this->template_dir.(!empty($this->card) ? $this->card.'_' : '').$this->_cleanaction($action).'.tpl.php')) {
return 1;
} else {
return 0;
}
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
@ -207,8 +219,7 @@ class Canvas
*/
public function doActions(&$action = 'view', $id = 0)
{
if (method_exists($this->control, 'doActions'))
{
if (method_exists($this->control, 'doActions')) {
$ret = $this->control->doActions($action, $id);
return $ret;
}

View File

@ -94,10 +94,18 @@ class Ccountry // extends CommonObject
$error = 0;
// Clean parameters
if (isset($this->code)) $this->code = trim($this->code);
if (isset($this->code_iso)) $this->code_iso = trim($this->code_iso);
if (isset($this->label)) $this->label = trim($this->label);
if (isset($this->active)) $this->active = trim($this->active);
if (isset($this->code)) {
$this->code = trim($this->code);
}
if (isset($this->code_iso)) {
$this->code_iso = trim($this->code_iso);
}
if (isset($this->label)) {
$this->label = trim($this->label);
}
if (isset($this->active)) {
$this->active = trim($this->active);
}
// Check parameters
// Put here code to add control on parameters values
@ -119,20 +127,19 @@ class Ccountry // extends CommonObject
$this->db->begin();
dol_syslog(get_class($this)."::create", LOG_DEBUG);
dol_syslog(get_class($this)."::create", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
if (!$resql) {
$error++; $this->errors[] = "Error ".$this->db->lasterror();
}
if (!$error)
{
if (!$error) {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."c_country");
}
// Commit or rollback
if ($error)
{
foreach ($this->errors as $errmsg)
{
if ($error) {
foreach ($this->errors as $errmsg) {
dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR);
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
}
@ -156,22 +163,24 @@ class Ccountry // extends CommonObject
public function fetch($id, $code = '', $code_iso = '')
{
$sql = "SELECT";
$sql .= " t.rowid,";
$sql .= " t.code,";
$sql .= " t.code_iso,";
$sql .= " t.label,";
$sql .= " t.active";
$sql .= " t.rowid,";
$sql .= " t.code,";
$sql .= " t.code_iso,";
$sql .= " t.label,";
$sql .= " t.active";
$sql .= " FROM ".MAIN_DB_PREFIX."c_country as t";
if ($id) $sql .= " WHERE t.rowid = ".((int) $id);
elseif ($code) $sql .= " WHERE t.code = '".$this->db->escape(strtoupper($code))."'";
elseif ($code_iso) $sql .= " WHERE t.code_iso = '".$this->db->escape(strtoupper($code_iso))."'";
if ($id) {
$sql .= " WHERE t.rowid = ".((int) $id);
} elseif ($code) {
$sql .= " WHERE t.code = '".$this->db->escape(strtoupper($code))."'";
} elseif ($code_iso) {
$sql .= " WHERE t.code_iso = '".$this->db->escape(strtoupper($code_iso))."'";
}
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
if ($this->db->num_rows($resql))
{
if ($resql) {
if ($this->db->num_rows($resql)) {
$obj = $this->db->fetch_object($resql);
if ($obj) {
@ -188,7 +197,7 @@ class Ccountry // extends CommonObject
return 0;
}
} else {
$this->error = "Error ".$this->db->lasterror();
$this->error = "Error ".$this->db->lasterror();
return -1;
}
}
@ -207,10 +216,18 @@ class Ccountry // extends CommonObject
$error = 0;
// Clean parameters
if (isset($this->code)) $this->code = trim($this->code);
if (isset($this->code_iso)) $this->code_iso = trim($this->code_iso);
if (isset($this->label)) $this->label = trim($this->label);
if (isset($this->active)) $this->active = trim($this->active);
if (isset($this->code)) {
$this->code = trim($this->code);
}
if (isset($this->code_iso)) {
$this->code_iso = trim($this->code_iso);
}
if (isset($this->label)) {
$this->label = trim($this->label);
}
if (isset($this->active)) {
$this->active = trim($this->active);
}
// Check parameters
@ -228,13 +245,13 @@ class Ccountry // extends CommonObject
dol_syslog(get_class($this)."::update", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
if (!$resql) {
$error++; $this->errors[] = "Error ".$this->db->lasterror();
}
// Commit or rollback
if ($error)
{
foreach ($this->errors as $errmsg)
{
if ($error) {
foreach ($this->errors as $errmsg) {
dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
}
@ -247,13 +264,13 @@ class Ccountry // extends CommonObject
}
/**
* Delete object in database
*
* @param User $user User that delete
* @param int $notrigger 0=launch triggers after, 1=disable triggers
* @return int <0 if KO, >0 if OK
*/
/**
* Delete object in database
*
* @param User $user User that delete
* @param int $notrigger 0=launch triggers after, 1=disable triggers
* @return int <0 if KO, >0 if OK
*/
public function delete($user, $notrigger = 0)
{
global $conf, $langs;
@ -266,13 +283,13 @@ class Ccountry // extends CommonObject
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
if (!$resql) {
$error++; $this->errors[] = "Error ".$this->db->lasterror();
}
// Commit or rollback
if ($error)
{
foreach ($this->errors as $errmsg)
{
if ($error) {
foreach ($this->errors as $errmsg) {
dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
}

View File

@ -92,12 +92,12 @@ abstract class CommonDocGenerator
'myuser_fullname'=>$user->getFullName($outputlangs, 1),
'myuser_login'=>$user->login,
'myuser_phone'=>$user->office_phone,
'myuser_address'=>$user->address,
'myuser_zip'=>$user->zip,
'myuser_town'=>$user->town,
'myuser_country'=>$user->country,
'myuser_address'=>$user->address,
'myuser_zip'=>$user->zip,
'myuser_town'=>$user->town,
'myuser_country'=>$user->country,
'myuser_country_code'=>$user->country_code,
'myuser_state'=>$user->state,
'myuser_state'=>$user->state,
'myuser_state_code'=>$user->state_code,
'myuser_fax'=>$user->office_fax,
'myuser_mobile'=>$user->user_mobile,
@ -173,16 +173,13 @@ abstract class CommonDocGenerator
// phpcs:enable
global $conf;
if (empty($mysoc->forme_juridique) && !empty($mysoc->forme_juridique_code))
{
if (empty($mysoc->forme_juridique) && !empty($mysoc->forme_juridique_code)) {
$mysoc->forme_juridique = getFormeJuridiqueLabel($mysoc->forme_juridique_code);
}
if (empty($mysoc->country) && !empty($mysoc->country_code))
{
if (empty($mysoc->country) && !empty($mysoc->country_code)) {
$mysoc->country = $outputlangs->transnoentitiesnoconv("Country".$mysoc->country_code);
}
if (empty($mysoc->state) && !empty($mysoc->state_code))
{
if (empty($mysoc->state) && !empty($mysoc->state_code)) {
$mysoc->state = getState($mysoc->state_code, 0);
}
@ -234,12 +231,10 @@ abstract class CommonDocGenerator
// phpcs:enable
global $conf, $extrafields;
if (empty($object->country) && !empty($object->country_code))
{
if (empty($object->country) && !empty($object->country_code)) {
$object->country = $outputlangs->transnoentitiesnoconv("Country".$object->country_code);
}
if (empty($object->state) && !empty($object->state_code))
{
if (empty($object->state) && !empty($object->state_code)) {
$object->state = getState($object->state_code, 0);
}
@ -279,8 +274,7 @@ abstract class CommonDocGenerator
);
// Retrieve extrafields
if (is_array($object->array_options) && count($object->array_options))
{
if (is_array($object->array_options) && count($object->array_options)) {
$object->fetch_optionals();
$array_thirdparty = $this->fill_substitutionarray_with_extrafields($object, $array_thirdparty, $extrafields, $array_key, $outputlangs);
@ -302,12 +296,10 @@ abstract class CommonDocGenerator
// phpcs:enable
global $conf, $extrafields;
if (empty($object->country) && !empty($object->country_code))
{
if (empty($object->country) && !empty($object->country_code)) {
$object->country = $outputlangs->transnoentitiesnoconv("Country".$object->country_code);
}
if (empty($object->state) && !empty($object->state_code))
{
if (empty($object->state) && !empty($object->state_code)) {
$object->state = getState($object->state_code, 0);
}
@ -342,8 +334,7 @@ abstract class CommonDocGenerator
);
// Retrieve extrafields
if (is_array($object->array_options) && count($object->array_options))
{
if (is_array($object->array_options) && count($object->array_options)) {
$object->fetch_optionals();
$array_contact = $this->fill_substitutionarray_with_extrafields($object, $array_contact, $extrafields, $array_key, $outputlangs);
@ -369,20 +360,22 @@ abstract class CommonDocGenerator
// Date in default language
'current_date'=>dol_print_date($now, 'day', 'tzuser'),
'current_datehour'=>dol_print_date($now, 'dayhour', 'tzuser'),
'current_server_date'=>dol_print_date($now, 'day', 'tzserver'),
'current_server_datehour'=>dol_print_date($now, 'dayhour', 'tzserver'),
'current_server_date'=>dol_print_date($now, 'day', 'tzserver'),
'current_server_datehour'=>dol_print_date($now, 'dayhour', 'tzserver'),
// Date in requested output language
'current_date_locale'=>dol_print_date($now, 'day', 'tzuser', $outputlangs),
'current_datehour_locale'=>dol_print_date($now, 'dayhour', 'tzuser', $outputlangs),
'current_server_date_locale'=>dol_print_date($now, 'day', 'tzserver', $outputlangs),
'current_server_datehour_locale'=>dol_print_date($now, 'dayhour', 'tzserver', $outputlangs),
'current_datehour_locale'=>dol_print_date($now, 'dayhour', 'tzuser', $outputlangs),
'current_server_date_locale'=>dol_print_date($now, 'day', 'tzserver', $outputlangs),
'current_server_datehour_locale'=>dol_print_date($now, 'dayhour', 'tzserver', $outputlangs),
);
foreach ($conf->global as $key => $val)
{
if (isASecretKey($key)) $newval = '*****forbidden*****';
else $newval = $val;
foreach ($conf->global as $key => $val) {
if (isASecretKey($key)) {
$newval = '*****forbidden*****';
} else {
$newval = $val;
}
$array_other['__['.$key.']__'] = $newval;
}
@ -407,11 +400,9 @@ abstract class CommonDocGenerator
$sumpayed = $sumdeposit = $sumcreditnote = '';
$already_payed_all = 0;
$remain_to_pay = 0;
if ($object->element == 'facture')
{
if ($object->element == 'facture') {
$invoice_source = new Facture($this->db);
if ($object->fk_facture_source > 0)
{
if ($object->fk_facture_source > 0) {
$invoice_source->fetch($object->fk_facture_source);
}
$sumpayed = $object->getSommePaiement();
@ -508,10 +499,8 @@ abstract class CommonDocGenerator
}
// Fetch project information if there is a project assigned to this object
if ($object->element != "project" && !empty($object->fk_project) && $object->fk_project > 0)
{
if (!is_object($object->project))
{
if ($object->element != "project" && !empty($object->fk_project) && $object->fk_project > 0) {
if (!is_object($object->project)) {
$object->fetch_projet();
}
@ -523,18 +512,20 @@ abstract class CommonDocGenerator
}
// Add vat by rates
if (is_array($object->lines) && count($object->lines) > 0)
{
if (is_array($object->lines) && count($object->lines) > 0) {
$totalUp = 0;
foreach ($object->lines as $line)
{
foreach ($object->lines as $line) {
// $line->tva_tx format depends on database field accuraty, no reliable. This is kept for backward compatibility
if (empty($resarray[$array_key.'_total_vat_'.$line->tva_tx])) $resarray[$array_key.'_total_vat_'.$line->tva_tx] = 0;
if (empty($resarray[$array_key.'_total_vat_'.$line->tva_tx])) {
$resarray[$array_key.'_total_vat_'.$line->tva_tx] = 0;
}
$resarray[$array_key.'_total_vat_'.$line->tva_tx] += $line->total_tva;
$resarray[$array_key.'_total_vat_locale_'.$line->tva_tx] = price($resarray[$array_key.'_total_vat_'.$line->tva_tx]);
// $vatformated is vat without not expected chars (so 20, or 8.5 or 5.99 for example)
$vatformated = vatrate($line->tva_tx);
if (empty($resarray[$array_key.'_total_vat_'.$vatformated])) $resarray[$array_key.'_total_vat_'.$vatformated] = 0;
if (empty($resarray[$array_key.'_total_vat_'.$vatformated])) {
$resarray[$array_key.'_total_vat_'.$vatformated] = 0;
}
$resarray[$array_key.'_total_vat_'.$vatformated] += $line->total_tva;
$resarray[$array_key.'_total_vat_locale_'.$vatformated] = price($resarray[$array_key.'_total_vat_'.$vatformated]);
@ -560,8 +551,7 @@ abstract class CommonDocGenerator
}
// Retrieve extrafields
if (is_array($object->array_options) && count($object->array_options))
{
if (is_array($object->array_options) && count($object->array_options)) {
$object->fetch_optionals();
$resarray = $this->fill_substitutionarray_with_extrafields($object, $resarray, $extrafields, $array_key, $outputlangs);
@ -630,8 +620,7 @@ abstract class CommonDocGenerator
);
// Units
if (!empty($conf->global->PRODUCT_USE_UNITS))
{
if (!empty($conf->global->PRODUCT_USE_UNITS)) {
$resarray['line_unit'] = $outputlangs->trans($line->getLabelOfUnit('long'));
$resarray['line_unit_short'] = $outputlangs->trans($line->getLabelOfUnit('short'));
}
@ -647,32 +636,26 @@ abstract class CommonDocGenerator
$resarray = $this->fill_substitutionarray_with_extrafields($line, $resarray, $extrafields, $array_key, $outputlangs);
// Check if the current line belongs to a supplier order
if (get_class($line) == 'CommandeFournisseurLigne')
{
if (get_class($line) == 'CommandeFournisseurLigne') {
// Add the product supplier extrafields to the substitutions
$extrafields->fetch_name_optionals_label("product_fournisseur_price");
$extralabels = $extrafields->attributes["product_fournisseur_price"]['label'];
if (!empty($extralabels) && is_array($extralabels))
{
if (!empty($extralabels) && is_array($extralabels)) {
$columns = "";
foreach ($extralabels as $key => $label)
{
foreach ($extralabels as $key => $label) {
$columns .= "$key, ";
}
if ($columns != "")
{
if ($columns != "") {
$columns = substr($columns, 0, strlen($columns) - 2);
$resql = $this->db->query("SELECT ".$columns." FROM ".MAIN_DB_PREFIX."product_fournisseur_price_extrafields AS ex INNER JOIN ".MAIN_DB_PREFIX."product_fournisseur_price AS f ON ex.fk_object = f.rowid WHERE f.ref_fourn = '".$this->db->escape($line->ref_supplier)."'");
if ($this->db->num_rows($resql) > 0)
{
if ($this->db->num_rows($resql) > 0) {
$resql = $this->db->fetch_object($resql);
foreach ($extralabels as $key => $label)
{
foreach ($extralabels as $key => $label) {
$resarray['line_product_supplier_'.$key] = $resql->{$key};
}
}
@ -681,12 +664,12 @@ abstract class CommonDocGenerator
}
// Load product data optional fields to the line -> enables to use "line_options_{extrafield}"
if (isset($line->fk_product) && $line->fk_product > 0)
{
if (isset($line->fk_product) && $line->fk_product > 0) {
$tmpproduct = new Product($this->db);
$result = $tmpproduct->fetch($line->fk_product);
foreach ($tmpproduct->array_options as $key=>$label)
foreach ($tmpproduct->array_options as $key => $label) {
$resarray["line_product_".$key] = $label;
}
}
return $resarray;
@ -734,15 +717,15 @@ abstract class CommonDocGenerator
);
// Add vat by rates
foreach ($object->lines as $line)
{
if (empty($array_shipment[$array_key.'_total_vat_'.$line->tva_tx])) $array_shipment[$array_key.'_total_vat_'.$line->tva_tx] = 0;
foreach ($object->lines as $line) {
if (empty($array_shipment[$array_key.'_total_vat_'.$line->tva_tx])) {
$array_shipment[$array_key.'_total_vat_'.$line->tva_tx] = 0;
}
$array_shipment[$array_key.'_total_vat_'.$line->tva_tx] += $line->total_tva;
}
// Retrieve extrafields
if (is_array($object->array_options) && count($object->array_options))
{
if (is_array($object->array_options) && count($object->array_options)) {
$object->fetch_optionals();
$array_shipment = $this->fill_substitutionarray_with_extrafields($object, $array_shipment, $extrafields, $array_key, $outputlangs);
@ -853,30 +836,25 @@ abstract class CommonDocGenerator
global $conf;
if (is_array($extrafields->attributes[$object->table_element]['label'])) {
foreach ($extrafields->attributes[$object->table_element]['label'] as $key=>$label)
{
if ($extrafields->attributes[$object->table_element]['type'][$key] == 'price')
{
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $label) {
if ($extrafields->attributes[$object->table_element]['type'][$key] == 'price') {
$object->array_options['options_'.$key] = price2num($object->array_options['options_'.$key]);
$object->array_options['options_'.$key.'_currency'] = price($object->array_options['options_'.$key], 0, $outputlangs, 0, 0, -1, $conf->currency);
//Add value to store price with currency
$array_to_fill = array_merge($array_to_fill, array($array_key.'_options_'.$key.'_currency' => $object->array_options['options_'.$key.'_currency']));
} elseif ($extrafields->attributes[$object->table_element]['type'][$key] == 'select')
{
} elseif ($extrafields->attributes[$object->table_element]['type'][$key] == 'select') {
$object->array_options['options_'.$key] = $extrafields->attributes[$object->table_element]['param'][$key]['options'][$object->array_options['options_'.$key]];
} elseif ($extrafields->attributes[$object->table_element]['type'][$key] == 'checkbox') {
$valArray = explode(',', $object->array_options['options_'.$key]);
$output = array();
foreach ($extrafields->attributes[$object->table_element]['param'][$key]['options'] as $keyopt=>$valopt) {
foreach ($extrafields->attributes[$object->table_element]['param'][$key]['options'] as $keyopt => $valopt) {
if (in_array($keyopt, $valArray)) {
$output[] = $valopt;
}
}
$object->array_options['options_'.$key] = implode(', ', $output);
} elseif ($extrafields->attributes[$object->table_element]['type'][$key] == 'date')
{
if (strlen($object->array_options['options_'.$key]) > 0)
{
} elseif ($extrafields->attributes[$object->table_element]['type'][$key] == 'date') {
if (strlen($object->array_options['options_'.$key]) > 0) {
$date = $object->array_options['options_'.$key];
$object->array_options['options_'.$key] = dol_print_date($date, 'day'); // using company output language
$object->array_options['options_'.$key.'_locale'] = dol_print_date($date, 'day', 'tzserver', $outputlangs); // using output language format
@ -888,29 +866,24 @@ abstract class CommonDocGenerator
}
$array_to_fill = array_merge($array_to_fill, array($array_key.'_options_'.$key.'_locale' => $object->array_options['options_'.$key.'_locale']));
$array_to_fill = array_merge($array_to_fill, array($array_key.'_options_'.$key.'_rfc' => $object->array_options['options_'.$key.'_rfc']));
} elseif ($extrafields->attributes[$object->table_element]['label'][$key] == 'datetime')
{
} elseif ($extrafields->attributes[$object->table_element]['label'][$key] == 'datetime') {
$datetime = $object->array_options['options_'.$key];
$object->array_options['options_'.$key] = ($datetime != "0000-00-00 00:00:00" ?dol_print_date($object->array_options['options_'.$key], 'dayhour') : ''); // using company output language
$object->array_options['options_'.$key.'_locale'] = ($datetime != "0000-00-00 00:00:00" ?dol_print_date($object->array_options['options_'.$key], 'dayhour', 'tzserver', $outputlangs) : ''); // using output language format
$object->array_options['options_'.$key.'_rfc'] = ($datetime != "0000-00-00 00:00:00" ?dol_print_date($object->array_options['options_'.$key], 'dayhourrfc') : ''); // international format
$array_to_fill = array_merge($array_to_fill, array($array_key.'_options_'.$key.'_locale' => $object->array_options['options_'.$key.'_locale']));
$array_to_fill = array_merge($array_to_fill, array($array_key.'_options_'.$key.'_rfc' => $object->array_options['options_'.$key.'_rfc']));
} elseif ($extrafields->attributes[$object->table_element]['type'][$key] == 'link')
{
} elseif ($extrafields->attributes[$object->table_element]['type'][$key] == 'link') {
$id = $object->array_options['options_'.$key];
if ($id != "")
{
if ($id != "") {
$param = $extrafields->attributes[$object->table_element]['param'][$key];
$param_list = array_keys($param['options']); // $param_list='ObjectName:classPath'
$InfoFieldList = explode(":", $param_list[0]);
$classname = $InfoFieldList[0];
$classpath = $InfoFieldList[1];
if (!empty($classpath))
{
if (!empty($classpath)) {
dol_include_once($InfoFieldList[1]);
if ($classname && class_exists($classname))
{
if ($classname && class_exists($classname)) {
$tmpobject = new $classname($this->db);
$tmpobject->fetch($id);
// completely replace the id with the linked object name
@ -942,9 +915,13 @@ abstract class CommonDocGenerator
*/
public function printRect($pdf, $x, $y, $l, $h, $hidetop = 0, $hidebottom = 0)
{
if (empty($hidetop) || $hidetop == -1) $pdf->line($x, $y, $x + $l, $y);
if (empty($hidetop) || $hidetop == -1) {
$pdf->line($x, $y, $x + $l, $y);
}
$pdf->line($x + $l, $y, $x + $l, $y + $h);
if (empty($hidebottom)) $pdf->line($x + $l, $y + $h, $x, $y + $h);
if (empty($hidebottom)) {
$pdf->line($x + $l, $y + $h, $x, $y + $h);
}
$pdf->line($x, $y + $h, $x, $y);
}
@ -958,8 +935,12 @@ abstract class CommonDocGenerator
*/
public function columnSort($a, $b)
{
if (empty($a['rank'])) { $a['rank'] = 0; }
if (empty($b['rank'])) { $b['rank'] = 0; }
if (empty($a['rank'])) {
$a['rank'] = 0;
}
if (empty($b['rank'])) {
$b['rank'] = 0;
}
if ($a['rank'] == $b['rank']) {
return 0;
}
@ -995,9 +976,10 @@ abstract class CommonDocGenerator
// Count flexible column
$totalDefinedColWidth = 0;
$countFlexCol = 0;
foreach ($this->cols as $colKey =>& $colDef)
{
if (!$this->getColumnStatus($colKey)) continue; // continue if disabled
foreach ($this->cols as $colKey => & $colDef) {
if (!$this->getColumnStatus($colKey)) {
continue; // continue if disabled
}
if (!empty($colDef['scale'])) {
// In case of column width is defined by percentage
@ -1011,8 +993,7 @@ abstract class CommonDocGenerator
}
}
foreach ($this->cols as $colKey =>& $colDef)
{
foreach ($this->cols as $colKey => & $colDef) {
// setting empty conf with default
if (!empty($colDef['title'])) {
$colDef['title'] = array_replace($this->defaultTitlesFieldsStyle, $colDef['title']);
@ -1027,8 +1008,7 @@ abstract class CommonDocGenerator
$colDef['content'] = $this->defaultContentsFieldsStyle;
}
if ($this->getColumnStatus($colKey))
{
if ($this->getColumnStatus($colKey)) {
// In case of flexible column
if (empty($colDef['width'])) {
$colDef['width'] = abs(($arrayWidth - $totalDefinedColWidth)) / $countFlexCol;
@ -1076,7 +1056,9 @@ abstract class CommonDocGenerator
*/
public function getColumnRank($colKey)
{
if (!isset($this->cols[$colKey]['rank'])) return -1;
if (!isset($this->cols[$colKey]['rank'])) {
return -1;
}
return $this->cols[$colKey]['rank'];
}
@ -1097,7 +1079,9 @@ abstract class CommonDocGenerator
// try to get rank from target column
if (!empty($targetCol)) {
$rank = $this->getColumnRank($targetCol);
if ($rank >= 0 && $insertAfterTarget) { $rank++; }
if ($rank >= 0 && $insertAfterTarget) {
$rank++;
}
}
// get rank from new column definition
@ -1106,12 +1090,12 @@ abstract class CommonDocGenerator
}
// error: no rank
if ($rank < 0) { return -1; }
if ($rank < 0) {
return -1;
}
foreach ($this->cols as $colKey =>& $colDef)
{
if ($rank <= $colDef['rank'])
{
foreach ($this->cols as $colKey => & $colDef) {
if ($rank <= $colDef['rank']) {
$colDef['rank'] = $colDef['rank'] + 1;
}
}
@ -1143,10 +1127,13 @@ abstract class CommonDocGenerator
'pdf' => &$pdf,
);
$reshook = $hookmanager->executeHooks('printStdColumnContent', $parameters, $this); // Note that $action and $object may have been modified by hook
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if (!$reshook)
{
if (empty($columnText)) return;
if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if (!$reshook) {
if (empty($columnText)) {
return;
}
$pdf->SetXY($this->getColumnContentXStart($colKey), $curY); // Set curent position
$colDef = $this->cols[$colKey];
// save curent cell padding
@ -1215,7 +1202,9 @@ abstract class CommonDocGenerator
{
global $hookmanager;
if (empty($object->table_element)) { return; }
if (empty($object->table_element)) {
return;
}
$extrafieldsKeyPrefix = "options_";
@ -1229,8 +1218,12 @@ abstract class CommonDocGenerator
// Load extrafiels if not allready does
if (empty($this->extrafieldsCache)) { $this->extrafieldsCache = new ExtraFields($this->db); }
if (empty($this->extrafieldsCache->attributes[$object->table_element])) { $this->extrafieldsCache->fetch_name_optionals_label($object->table_element); }
if (empty($this->extrafieldsCache)) {
$this->extrafieldsCache = new ExtraFields($this->db);
}
if (empty($this->extrafieldsCache->attributes[$object->table_element])) {
$this->extrafieldsCache->fetch_name_optionals_label($object->table_element);
}
$extrafields = $this->extrafieldsCache;
$extrafieldOutputContent = $extrafields->showOutputField($extrafieldKey, $object->array_options[$extrafieldOptionsKey], '', $object->table_element);
@ -1248,9 +1241,10 @@ abstract class CommonDocGenerator
'extrafieldOutputContent' =>& $extrafieldOutputContent
);
$reshook = $hookmanager->executeHooks('getPDFExtrafieldContent', $parameters, $this); // Note that $action and $object may have been modified by hook
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if ($reshook)
{
if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if ($reshook) {
$extrafieldOutputContent = $hookmanager->resPrint;
}
@ -1275,8 +1269,12 @@ abstract class CommonDocGenerator
}
// Load extrafiels if not allready does
if (empty($this->extrafieldsCache)) { $this->extrafieldsCache = new ExtraFields($this->db); }
if (empty($this->extrafieldsCache->attributes[$object->table_element])) { $this->extrafieldsCache->fetch_name_optionals_label($object->table_element); }
if (empty($this->extrafieldsCache)) {
$this->extrafieldsCache = new ExtraFields($this->db);
}
if (empty($this->extrafieldsCache->attributes[$object->table_element])) {
$this->extrafieldsCache->fetch_name_optionals_label($object->table_element);
}
$extrafields = $this->extrafieldsCache;
$defaultParams = array(
@ -1315,8 +1313,7 @@ abstract class CommonDocGenerator
$fields = array();
if (!empty($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label'])) {
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $label)
{
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $label) {
// Enable extrafield ?
$enabled = 0;
$disableOnEmpty = 0;
@ -1350,8 +1347,7 @@ abstract class CommonDocGenerator
}
}
if (!empty($fields))
{
if (!empty($fields)) {
// Sort extrafields by rank
uasort($fields, function ($a, $b) {
return ($a->rank > $b->rank) ? 1 : -1;
@ -1445,7 +1441,9 @@ abstract class CommonDocGenerator
{
if (!empty($this->cols[$colKey]['status'])) {
return true;
} else return false;
} else {
return false;
}
}
/**
@ -1476,7 +1474,9 @@ abstract class CommonDocGenerator
if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
} elseif (empty($reshook)) {
if (!$this->getColumnStatus($colKey)) continue;
if (!$this->getColumnStatus($colKey)) {
continue;
}
// get title label
$colDef['title']['label'] = !empty($colDef['title']['label']) ? $colDef['title']['label'] : $outputlangs->transnoentities($colDef['title']['textkey']);
@ -1546,17 +1546,19 @@ abstract class CommonDocGenerator
}
// Load extrafiels if not allready does
if (empty($this->extrafieldsCache)) { $this->extrafieldsCache = new ExtraFields($this->db); }
if (empty($this->extrafieldsCache->attributes[$object->table_element])) { $this->extrafieldsCache->fetch_name_optionals_label($object->table_element); }
if (empty($this->extrafieldsCache)) {
$this->extrafieldsCache = new ExtraFields($this->db);
}
if (empty($this->extrafieldsCache->attributes[$object->table_element])) {
$this->extrafieldsCache->fetch_name_optionals_label($object->table_element);
}
$extrafields = $this->extrafieldsCache;
if (!empty($extrafields->attributes[$object->table_element]) && is_array($extrafields->attributes[$object->table_element]['label'])) {
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $label)
{
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $label) {
// Dont display separator yet even is set to be displayed (not compatible yet)
if ($extrafields->attributes[$object->table_element]['type'][$key] == 'separate')
{
if ($extrafields->attributes[$object->table_element]['type'][$key] == 'separate') {
continue;
}
@ -1570,10 +1572,14 @@ abstract class CommonDocGenerator
// Note : if $printable === 3 or 4 so, it's displayed after line description not in cols
}
if (!$enabled) { continue; } // don't wast resourses if we don't need them...
if (!$enabled) {
continue;
} // don't wast resourses if we don't need them...
// Load language if required
if (!empty($extrafields->attributes[$object->table_element]['langfile'][$key])) $outputlangs->load($extrafields->attributes[$object->table_element]['langfile'][$key]);
if (!empty($extrafields->attributes[$object->table_element]['langfile'][$key])) {
$outputlangs->load($extrafields->attributes[$object->table_element]['langfile'][$key]);
}
// TODO : add more extrafield customisation capacities for PDF like width, rank...

View File

@ -59,12 +59,10 @@ trait CommonIncoterm
$out = '';
$this->label_incoterms = '';
if (!empty($this->fk_incoterms))
{
if (!empty($this->fk_incoterms)) {
$sql = 'SELECT code FROM '.MAIN_DB_PREFIX.'c_incoterms WHERE rowid = '.(int) $this->fk_incoterms;
$result = $this->db->query($sql);
if ($result)
{
if ($result) {
$res = $this->db->fetch_object($result);
$out .= $res->code;
}
@ -84,11 +82,9 @@ trait CommonIncoterm
{
$sql = 'SELECT code FROM '.MAIN_DB_PREFIX.'c_incoterms WHERE rowid = '.(int) $this->fk_incoterms;
$resql = $this->db->query($sql);
if ($resql)
{
if ($resql) {
$num = $this->db->num_rows($resql);
if ($num > 0)
{
if ($num > 0) {
$res = $this->db->fetch_object($resql);
return 'Incoterm : '.$res->code.' - '.$this->location_incoterms;
} else {
@ -109,23 +105,20 @@ trait CommonIncoterm
*/
public function setIncoterms($id_incoterm, $location)
{
if ($this->id && $this->table_element)
{
if ($this->id && $this->table_element) {
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
$sql .= " SET fk_incoterms = ".($id_incoterm > 0 ? $id_incoterm : "null");
$sql .= ", location_incoterms = ".($id_incoterm > 0 ? "'".$this->db->escape($location)."'" : "null");
$sql .= " WHERE rowid = ".$this->id;
dol_syslog(get_class($this).'::setIncoterms', LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
if ($resql) {
$this->fk_incoterms = $id_incoterm;
$this->location_incoterms = $location;
$sql = 'SELECT libelle as label_incotermsFROM '.MAIN_DB_PREFIX.'c_incoterms WHERE rowid = '.(int) $this->fk_incoterms;
$res = $this->db->query($sql);
if ($res)
{
if ($res) {
$obj = $this->db->fetch_object($res);
$this->label_incoterms = $obj->label_incoterms;
}

View File

@ -125,8 +125,7 @@ abstract class CommonInvoice extends CommonObject
{
$table = 'paiement_facture';
$field = 'fk_facture';
if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier')
{
if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') {
$table = 'paiementfourn_facturefourn';
$field = 'fk_facturefourn';
}
@ -137,12 +136,14 @@ abstract class CommonInvoice extends CommonObject
dol_syslog(get_class($this)."::getSommePaiement", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
if ($resql) {
$obj = $this->db->fetch_object($resql);
$this->db->free($resql);
if ($multicurrency) return $obj->multicurrency_amount;
else return $obj->amount;
if ($multicurrency) {
return $obj->multicurrency_amount;
} else {
return $obj->amount;
}
} else {
$this->error = $this->db->lasterror();
return -1;
@ -158,8 +159,7 @@ abstract class CommonInvoice extends CommonObject
*/
public function getSumDepositsUsed($multicurrency = 0)
{
if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier')
{
if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') {
// TODO
return 0.0;
}
@ -230,12 +230,10 @@ abstract class CommonInvoice extends CommonObject
$sql .= ' WHERE fk_facture_source = '.$this->id;
$sql .= ' AND type = 2';
$resql = $this->db->query($sql);
if ($resql)
{
if ($resql) {
$num = $this->db->num_rows($resql);
$i = 0;
while ($i < $num)
{
while ($i < $num) {
$row = $this->db->fetch_row($resql);
$idarray[] = $row[0];
$i++;
@ -258,7 +256,9 @@ abstract class CommonInvoice extends CommonObject
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element;
$sql .= ' WHERE fk_facture_source = '.$this->id;
$sql .= ' AND type < 2';
if ($option == 'validated') $sql .= ' AND fk_statut = 1';
if ($option == 'validated') {
$sql .= ' AND fk_statut = 1';
}
// PROTECTION BAD DATA
// In case the database is corrupted and there is a valid replectement invoice
// and another no, priority is given to the valid one.
@ -267,11 +267,9 @@ abstract class CommonInvoice extends CommonObject
$sql .= ' ORDER BY fk_statut DESC';
$resql = $this->db->query($sql);
if ($resql)
{
if ($resql) {
$obj = $this->db->fetch_object($resql);
if ($obj)
{
if ($obj) {
// If there is any
return $obj->rowid;
} else {
@ -299,8 +297,7 @@ abstract class CommonInvoice extends CommonObject
$field2 = 'fk_paiement';
$field3 = ', p.ref_ext';
$sharedentity = 'facture';
if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier')
{
if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') {
$table = 'paiementfourn_facturefourn';
$table2 = 'paiementfourn';
$field = 'fk_facturefourn';
@ -316,16 +313,16 @@ abstract class CommonInvoice extends CommonObject
$sql .= ' AND pf.'.$field2.' = p.rowid';
$sql .= ' AND p.fk_paiement = t.id';
$sql .= ' AND p.entity IN ('.getEntity($sharedentity).')';
if ($filtertype) $sql .= " AND t.code='PRE'";
if ($filtertype) {
$sql .= " AND t.code='PRE'";
}
dol_syslog(get_class($this)."::getListOfPayments", 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);
$tmp = array('amount'=>$obj->amount, 'type'=>$obj->code, 'date'=>$obj->datep, 'num'=>$obj->num, 'ref'=>$obj->ref);
if (!empty($field3)) {
@ -338,14 +335,12 @@ abstract class CommonInvoice extends CommonObject
//look for credit notes and discounts and deposits
$sql = '';
if ($this->element == 'facture' || $this->element == 'invoice')
{
if ($this->element == 'facture' || $this->element == 'invoice') {
$sql = 'SELECT rc.amount_ttc as amount, rc.multicurrency_amount_ttc as multicurrency_amount, rc.datec as date, f.ref as ref, rc.description as type';
$sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture as f';
$sql .= ' WHERE rc.fk_facture_source=f.rowid AND rc.fk_facture = '.$this->id;
$sql .= ' AND (f.type = 2 OR f.type = 0 OR f.type = 3)'; // Find discount coming from credit note or excess received or deposits (payments from deposits are always null except if FACTURE_DEPOSITS_ARE_JUST_PAYMENTS is set)
} elseif ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier')
{
} elseif ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') {
$sql = 'SELECT rc.amount_ttc as amount, rc.multicurrency_amount_ttc as multicurrency_amount, rc.datec as date, f.ref as ref, rc.description as type';
$sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture_fourn as f';
$sql .= ' WHERE rc.fk_invoice_supplier_source=f.rowid AND rc.fk_invoice_supplier = '.$this->id;
@ -354,12 +349,10 @@ abstract class CommonInvoice extends CommonObject
if ($sql) {
$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 ($multicurrency) {
$retarray[] = array('amount'=>$obj->multicurrency_amount, 'type'=>$obj->type, 'date'=>$obj->date, 'num'=>'0', 'ref'=>$obj->ref);
@ -407,42 +400,50 @@ abstract class CommonInvoice extends CommonObject
// We check if invoice is a temporary number (PROVxxxx)
$tmppart = substr($this->ref, 1, 4);
if ($this->statut == self::STATUS_DRAFT && $tmppart === 'PROV') // If draft invoice and ref not yet defined
{
if ($this->statut == self::STATUS_DRAFT && $tmppart === 'PROV') { // If draft invoice and ref not yet defined
return 1;
}
if (!empty($conf->global->INVOICE_CAN_NEVER_BE_REMOVED)) return 0;
if (!empty($conf->global->INVOICE_CAN_NEVER_BE_REMOVED)) {
return 0;
}
// If not a draft invoice and not temporary invoice
if ($tmppart !== 'PROV')
{
if ($tmppart !== 'PROV') {
$ventilExportCompta = $this->getVentilExportCompta();
if ($ventilExportCompta != 0) return -1;
if ($ventilExportCompta != 0) {
return -1;
}
// Get last number of validated invoice
if ($this->element != 'invoice_supplier')
{
if (empty($this->thirdparty)) $this->fetch_thirdparty(); // We need to have this->thirdparty defined, in case of numbering rule use tags that depend on thirdparty (like {t} tag).
if ($this->element != 'invoice_supplier') {
if (empty($this->thirdparty)) {
$this->fetch_thirdparty(); // We need to have this->thirdparty defined, in case of numbering rule use tags that depend on thirdparty (like {t} tag).
}
$maxref = $this->getNextNumRef($this->thirdparty, 'last');
// If there is no invoice into the reset range and not already dispatched, we can delete
// If invoice to delete is last one and not already dispatched, we can delete
if (empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED) && $maxref != '' && $maxref != $this->ref) return -2;
if (empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED) && $maxref != '' && $maxref != $this->ref) {
return -2;
}
// TODO If there is payment in bookkeeping, check payment is not dispatched in accounting
// ...
if ($this->situation_cycle_ref && method_exists($this, 'is_last_in_cycle'))
{
if ($this->situation_cycle_ref && method_exists($this, 'is_last_in_cycle')) {
$last = $this->is_last_in_cycle();
if (!$last) return -3;
if (!$last) {
return -3;
}
}
}
}
// Test if there is at least one payment. If yes, refuse to delete.
if (empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED) && $this->getSommePaiement() > 0) return -4;
if (empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED) && $this->getSommePaiement() > 0) {
return -4;
}
return 2;
}
@ -457,15 +458,15 @@ abstract class CommonInvoice extends CommonObject
$alreadydispatched = 0;
$type = 'customer_invoice';
if ($this->element == 'invoice_supplier') $type = 'supplier_invoice';
if ($this->element == 'invoice_supplier') {
$type = 'supplier_invoice';
}
$sql = " SELECT COUNT(ab.rowid) as nb FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='".$this->db->escape($type)."' AND ab.fk_doc = ".$this->id;
$resql = $this->db->query($sql);
if ($resql)
{
if ($resql) {
$obj = $this->db->fetch_object($resql);
if ($obj)
{
if ($obj) {
$alreadydispatched = $obj->nb;
}
} else {
@ -473,8 +474,7 @@ abstract class CommonInvoice extends CommonObject
return -1;
}
if ($alreadydispatched)
{
if ($alreadydispatched) {
return 1;
}
return 0;
@ -489,12 +489,19 @@ abstract class CommonInvoice extends CommonObject
public function getLibType()
{
global $langs;
if ($this->type == CommonInvoice::TYPE_STANDARD) return $langs->trans("InvoiceStandard");
elseif ($this->type == CommonInvoice::TYPE_REPLACEMENT) return $langs->trans("InvoiceReplacement");
elseif ($this->type == CommonInvoice::TYPE_CREDIT_NOTE) return $langs->trans("InvoiceAvoir");
elseif ($this->type == CommonInvoice::TYPE_DEPOSIT) return $langs->trans("InvoiceDeposit");
elseif ($this->type == CommonInvoice::TYPE_PROFORMA) return $langs->trans("InvoiceProForma"); // Not used.
elseif ($this->type == CommonInvoice::TYPE_SITUATION) return $langs->trans("InvoiceSituation");
if ($this->type == CommonInvoice::TYPE_STANDARD) {
return $langs->trans("InvoiceStandard");
} elseif ($this->type == CommonInvoice::TYPE_REPLACEMENT) {
return $langs->trans("InvoiceReplacement");
} elseif ($this->type == CommonInvoice::TYPE_CREDIT_NOTE) {
return $langs->trans("InvoiceAvoir");
} elseif ($this->type == CommonInvoice::TYPE_DEPOSIT) {
return $langs->trans("InvoiceDeposit");
} elseif ($this->type == CommonInvoice::TYPE_PROFORMA) {
return $langs->trans("InvoiceProForma"); // Not used.
} elseif ($this->type == CommonInvoice::TYPE_SITUATION) {
return $langs->trans("InvoiceSituation");
}
return $langs->trans("Unknown");
}
@ -527,7 +534,9 @@ abstract class CommonInvoice extends CommonObject
global $langs;
$langs->load('bills');
if ($type == -1) $type = $this->type;
if ($type == -1) {
$type = $this->type;
}
$statusType = 'status0';
$prefix = 'Short';
@ -581,8 +590,12 @@ abstract class CommonInvoice extends CommonObject
public function calculate_date_lim_reglement($cond_reglement = 0)
{
// phpcs:enable
if (!$cond_reglement) $cond_reglement = $this->cond_reglement_code;
if (!$cond_reglement) $cond_reglement = $this->cond_reglement_id;
if (!$cond_reglement) {
$cond_reglement = $this->cond_reglement_code;
}
if (!$cond_reglement) {
$cond_reglement = $this->cond_reglement_id;
}
$cdr_nbjour = 0;
$cdr_type = 0;
@ -590,18 +603,17 @@ abstract class CommonInvoice extends CommonObject
$sqltemp = 'SELECT c.type_cdr, c.nbjour, c.decalage';
$sqltemp .= ' FROM '.MAIN_DB_PREFIX.'c_payment_term as c';
if (is_numeric($cond_reglement)) $sqltemp .= " WHERE c.rowid=".$cond_reglement;
else {
if (is_numeric($cond_reglement)) {
$sqltemp .= " WHERE c.rowid=".$cond_reglement;
} else {
$sqltemp .= " WHERE c.entity IN (".getEntity('c_payment_term').")";
$sqltemp .= " AND c.code='".$this->db->escape($cond_reglement)."'";
}
dol_syslog(get_class($this).'::calculate_date_lim_reglement', LOG_DEBUG);
$resqltemp = $this->db->query($sqltemp);
if ($resqltemp)
{
if ($this->db->num_rows($resqltemp))
{
if ($resqltemp) {
if ($this->db->num_rows($resqltemp)) {
$obj = $this->db->fetch_object($resqltemp);
$cdr_nbjour = $obj->nbjour;
$cdr_type = $obj->type_cdr;
@ -616,21 +628,18 @@ abstract class CommonInvoice extends CommonObject
/* Definition de la date limite */
// 0 : adding the number of days
if ($cdr_type == 0)
{
if ($cdr_type == 0) {
$datelim = $this->date + ($cdr_nbjour * 3600 * 24);
$datelim += ($cdr_decalage * 3600 * 24);
}
// 1 : application of the "end of the month" rule
elseif ($cdr_type == 1)
{
elseif ($cdr_type == 1) {
$datelim = $this->date + ($cdr_nbjour * 3600 * 24);
$mois = date('m', $datelim);
$annee = date('Y', $datelim);
if ($mois == 12)
{
if ($mois == 12) {
$mois = 1;
$annee += 1;
} else {
@ -643,8 +652,7 @@ abstract class CommonInvoice extends CommonObject
$datelim += ($cdr_decalage * 3600 * 24);
}
// 2 : application of the rule, the N of the current or next month
elseif ($cdr_type == 2 && !empty($cdr_decalage))
{
elseif ($cdr_type == 2 && !empty($cdr_decalage)) {
include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
$datelim = $this->date + ($cdr_nbjour * 3600 * 24);
@ -654,8 +662,11 @@ abstract class CommonInvoice extends CommonObject
$diff = $date_piece - $date_lim_current;
if ($diff < 0) $datelim = $date_lim_current;
else $datelim = $date_lim_next;
if ($diff < 0) {
$datelim = $date_lim_current;
} else {
$datelim = $date_lim_next;
}
} else {
return 'Bad value for type_cdr in database for record cond_reglement = '.$cond_reglement;
}
@ -683,8 +694,7 @@ abstract class CommonInvoice extends CommonObject
dol_syslog(get_class($this)."::demande_prelevement", LOG_DEBUG);
if ($this->statut > self::STATUS_DRAFT && $this->paye == 0)
{
if ($this->statut > self::STATUS_DRAFT && $this->paye == 0) {
require_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php';
$bac = new CompanyBankAccount($this->db);
$bac->fetch(0, $this->socid);
@ -701,11 +711,9 @@ abstract class CommonInvoice extends CommonObject
dol_syslog(get_class($this)."::demande_prelevement", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
if ($resql) {
$row = $this->db->fetch_row($resql);
if ($row[0] == 0)
{
if ($row[0] == 0) {
$now = dol_now();
$totalpaye = $this->getSommePaiement();
@ -717,10 +725,11 @@ abstract class CommonInvoice extends CommonObject
// For example print 239.2 - 229.3 - 9.9; does not return 0.
//$resteapayer=bcadd($this->total_ttc,$totalpaye,$conf->global->MAIN_MAX_DECIMALS_TOT);
//$resteapayer=bcadd($resteapayer,$totalavoir,$conf->global->MAIN_MAX_DECIMALS_TOT);
if (empty($amount)) $amount = price2num($this->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits, 'MT');
if (empty($amount)) {
$amount = price2num($this->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits, 'MT');
}
if (is_numeric($amount) && $amount != 0)
{
if (is_numeric($amount) && $amount != 0) {
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'prelevement_facture_demande(';
if ($type == 'bank-transfer') {
$sql .= 'fk_facture_fourn, ';
@ -761,7 +770,9 @@ abstract class CommonInvoice extends CommonObject
}
}
if ($error) return -1;
if ($error) {
return -1;
}
return 1;
} else {
$this->error = "A request already exists";
@ -794,8 +805,7 @@ abstract class CommonInvoice extends CommonObject
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.'prelevement_facture_demande';
$sql .= ' WHERE rowid = '.$did;
$sql .= ' AND traite = 0';
if ($this->db->query($sql))
{
if ($this->db->query($sql)) {
return 0;
} else {
$this->error = $this->db->lasterror();

File diff suppressed because it is too large Load Diff

View File

@ -80,15 +80,21 @@ abstract class CommonObjectLine extends CommonObject
$label_type = 'label';
$label_type = 'label';
if ($type == 'short') $label_type = 'short_label';
elseif ($type == 'code') $label_type = 'code';
if ($type == 'short') {
$label_type = 'short_label';
} elseif ($type == 'code') {
$label_type = 'code';
}
$sql = 'select '.$label_type.', code from '.MAIN_DB_PREFIX.'c_units where rowid='.$this->fk_unit;
$resql = $this->db->query($sql);
if ($resql && $this->db->num_rows($resql) > 0) {
$res = $this->db->fetch_array($resql);
if ($label_type == 'code') $label = 'unit'.$res['code'];
else $label = $res[$label_type];
if ($label_type == 'code') {
$label = 'unit'.$res['code'];
} else {
$label = $res[$label_type];
}
$this->db->free($resql);
return $label;
} else {

View File

@ -121,7 +121,7 @@ abstract class CommonStickerGenerator
* @param string $outputdir Output directory for pdf file
* @return int 1=OK, 0=KO
*/
public abstract function write_file($arrayofrecords, $outputlangs, $srctemplatepath, $outputdir = '');
abstract public function write_file($arrayofrecords, $outputlangs, $srctemplatepath, $outputdir = '');
// phpcs:enable
/**
@ -132,7 +132,7 @@ abstract class CommonStickerGenerator
* @param array $param Associative array containing label content and optional parameters
* @return void
*/
public abstract function addSticker(&$pdf, $outputlangs, $param);
abstract public function addSticker(&$pdf, $outputlangs, $param);
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**

View File

@ -168,17 +168,14 @@ class Conf
$sql .= " ORDER BY entity"; // This is to have entity 0 first, then entity 1 that overwrite.
$resql = $db->query($sql);
if ($resql)
{
if ($resql) {
$i = 0;
$numr = $db->num_rows($resql);
while ($i < $numr)
{
while ($i < $numr) {
$objp = $db->fetch_object($resql);
$key = $objp->name;
$value = $objp->value;
if ($key)
{
if ($key) {
// Allow constants values to be overridden by environment variables
if (isset($_SERVER['DOLIBARR_'.$key])) {
$value = $_SERVER['DOLIBARR_'.$key];
@ -189,15 +186,15 @@ class Conf
//if (! defined("$key")) define("$key", $value); // In some cases, the constant might be already forced (Example: SYSLOG_HANDLERS during install)
$this->global->$key = $value;
if ($value && strpos($key, 'MAIN_MODULE_') === 0)
{
if ($value && strpos($key, 'MAIN_MODULE_') === 0) {
$reg = array();
// If this is constant for a new tab page activated by a module. It initializes modules_parts['tabs'].
if (preg_match('/^MAIN_MODULE_([0-9A-Z_]+)_TABS_/i', $key))
{
if (preg_match('/^MAIN_MODULE_([0-9A-Z_]+)_TABS_/i', $key)) {
$partname = 'tabs';
$params = explode(':', $value, 2);
if (!is_array($this->modules_parts[$partname])) { $this->modules_parts[$partname] = array(); }
if (!is_array($this->modules_parts[$partname])) {
$this->modules_parts[$partname] = array();
}
$this->modules_parts[$partname][$params[0]][] = $value; // $value may be a string or an array
}
// If this is constant for all generic part activated by a module. It initializes
@ -205,26 +202,38 @@ class Conf
// modules_parts['models'], modules_parts['theme']
// modules_parts['sms'],
// modules_parts['css'], ...
elseif (preg_match('/^MAIN_MODULE_([0-9A-Z_]+)_([A-Z]+)$/i', $key, $reg))
{
elseif (preg_match('/^MAIN_MODULE_([0-9A-Z_]+)_([A-Z]+)$/i', $key, $reg)) {
$modulename = strtolower($reg[1]);
$partname = strtolower($reg[2]);
if (!isset($this->modules_parts[$partname]) || !is_array($this->modules_parts[$partname])) { $this->modules_parts[$partname] = array(); }
if (!isset($this->modules_parts[$partname]) || !is_array($this->modules_parts[$partname])) {
$this->modules_parts[$partname] = array();
}
$arrValue = json_decode($value, true);
if (is_array($arrValue) && !empty($arrValue)) $value = $arrValue;
elseif (in_array($partname, array('login', 'menus', 'substitutions', 'triggers', 'tpl'))) $value = '/'.$modulename.'/core/'.$partname.'/';
elseif (in_array($partname, array('models', 'theme'))) $value = '/'.$modulename.'/';
elseif (in_array($partname, array('sms'))) $value = '/'.$modulename.'/';
elseif ($value == 1) $value = '/'.$modulename.'/core/modules/'.$partname.'/'; // ex: partname = societe
if (is_array($arrValue) && !empty($arrValue)) {
$value = $arrValue;
} elseif (in_array($partname, array('login', 'menus', 'substitutions', 'triggers', 'tpl'))) {
$value = '/'.$modulename.'/core/'.$partname.'/';
} elseif (in_array($partname, array('models', 'theme'))) {
$value = '/'.$modulename.'/';
} elseif (in_array($partname, array('sms'))) {
$value = '/'.$modulename.'/';
} elseif ($value == 1) {
$value = '/'.$modulename.'/core/modules/'.$partname.'/'; // ex: partname = societe
}
$this->modules_parts[$partname] = array_merge($this->modules_parts[$partname], array($modulename => $value)); // $value may be a string or an array
}
// If this is a module constant (must be at end)
elseif (preg_match('/^MAIN_MODULE_([0-9A-Z_]+)$/i', $key, $reg))
{
elseif (preg_match('/^MAIN_MODULE_([0-9A-Z_]+)$/i', $key, $reg)) {
$modulename = strtolower($reg[1]);
if ($modulename == 'propale') $modulename = 'propal';
if ($modulename == 'supplierproposal') $modulename = 'supplier_proposal';
if (!isset($this->$modulename) || !is_object($this->$modulename)) $this->$modulename = new stdClass();
if ($modulename == 'propale') {
$modulename = 'propal';
}
if ($modulename == 'supplierproposal') {
$modulename = 'supplier_proposal';
}
if (!isset($this->$modulename) || !is_object($this->$modulename)) {
$this->$modulename = new stdClass();
}
$this->$modulename->enabled = true;
$this->modules[] = $modulename; // Add this module in list of enabled modules
}
@ -251,12 +260,10 @@ class Conf
// If you can't set timezone of your PHP, set this constant. Better is to set it to UTC.
// In future, this constant will be forced to 'UTC' so PHP server timezone will not have effect anymore.
//$this->global->MAIN_SERVER_TZ='Europe/Paris';
if (!empty($this->global->MAIN_SERVER_TZ) && $this->global->MAIN_SERVER_TZ != 'auto')
{
if (!empty($this->global->MAIN_SERVER_TZ) && $this->global->MAIN_SERVER_TZ != 'auto') {
try {
date_default_timezone_set($this->global->MAIN_SERVER_TZ);
} catch (Exception $e)
{
} catch (Exception $e) {
dol_syslog("Error: Bad value for parameter MAIN_SERVER_TZ=".$this->global->MAIN_SERVER_TZ, LOG_ERR);
}
}
@ -272,36 +279,58 @@ class Conf
}
// Clean some variables
if (empty($this->global->MAIN_MENU_STANDARD)) $this->global->MAIN_MENU_STANDARD = "eldy_menu.php";
if (empty($this->global->MAIN_MENUFRONT_STANDARD)) $this->global->MAIN_MENUFRONT_STANDARD = "eldy_menu.php";
if (empty($this->global->MAIN_MENU_SMARTPHONE)) $this->global->MAIN_MENU_SMARTPHONE = "eldy_menu.php"; // Use eldy by default because smartphone does not work on all phones
if (empty($this->global->MAIN_MENUFRONT_SMARTPHONE)) $this->global->MAIN_MENUFRONT_SMARTPHONE = "eldy_menu.php"; // Use eldy by default because smartphone does not work on all phones
if (!isset($this->global->FACTURE_TVAOPTION)) $this->global->FACTURE_TVAOPTION = 1;
if (empty($this->global->MAIN_MENU_STANDARD)) {
$this->global->MAIN_MENU_STANDARD = "eldy_menu.php";
}
if (empty($this->global->MAIN_MENUFRONT_STANDARD)) {
$this->global->MAIN_MENUFRONT_STANDARD = "eldy_menu.php";
}
if (empty($this->global->MAIN_MENU_SMARTPHONE)) {
$this->global->MAIN_MENU_SMARTPHONE = "eldy_menu.php"; // Use eldy by default because smartphone does not work on all phones
}
if (empty($this->global->MAIN_MENUFRONT_SMARTPHONE)) {
$this->global->MAIN_MENUFRONT_SMARTPHONE = "eldy_menu.php"; // Use eldy by default because smartphone does not work on all phones
}
if (!isset($this->global->FACTURE_TVAOPTION)) {
$this->global->FACTURE_TVAOPTION = 1;
}
// Variable globales LDAP
if (empty($this->global->LDAP_FIELD_FULLNAME)) $this->global->LDAP_FIELD_FULLNAME = '';
if (!isset($this->global->LDAP_KEY_USERS)) $this->global->LDAP_KEY_USERS = $this->global->LDAP_FIELD_FULLNAME;
if (!isset($this->global->LDAP_KEY_GROUPS)) $this->global->LDAP_KEY_GROUPS = $this->global->LDAP_FIELD_FULLNAME;
if (!isset($this->global->LDAP_KEY_CONTACTS)) $this->global->LDAP_KEY_CONTACTS = $this->global->LDAP_FIELD_FULLNAME;
if (!isset($this->global->LDAP_KEY_MEMBERS)) $this->global->LDAP_KEY_MEMBERS = $this->global->LDAP_FIELD_FULLNAME;
if (!isset($this->global->LDAP_KEY_MEMBERS_TYPES)) $this->global->LDAP_KEY_MEMBERS_TYPES = $this->global->LDAP_FIELD_FULLNAME;
if (empty($this->global->LDAP_FIELD_FULLNAME)) {
$this->global->LDAP_FIELD_FULLNAME = '';
}
if (!isset($this->global->LDAP_KEY_USERS)) {
$this->global->LDAP_KEY_USERS = $this->global->LDAP_FIELD_FULLNAME;
}
if (!isset($this->global->LDAP_KEY_GROUPS)) {
$this->global->LDAP_KEY_GROUPS = $this->global->LDAP_FIELD_FULLNAME;
}
if (!isset($this->global->LDAP_KEY_CONTACTS)) {
$this->global->LDAP_KEY_CONTACTS = $this->global->LDAP_FIELD_FULLNAME;
}
if (!isset($this->global->LDAP_KEY_MEMBERS)) {
$this->global->LDAP_KEY_MEMBERS = $this->global->LDAP_FIELD_FULLNAME;
}
if (!isset($this->global->LDAP_KEY_MEMBERS_TYPES)) {
$this->global->LDAP_KEY_MEMBERS_TYPES = $this->global->LDAP_FIELD_FULLNAME;
}
// Load translation object with current language
if (empty($this->global->MAIN_LANG_DEFAULT)) $this->global->MAIN_LANG_DEFAULT = "en_US";
if (empty($this->global->MAIN_LANG_DEFAULT)) {
$this->global->MAIN_LANG_DEFAULT = "en_US";
}
$rootfordata = DOL_DATA_ROOT;
$rootforuser = DOL_DATA_ROOT;
// If multicompany module is enabled, we redefine the root of data
if (!empty($this->multicompany->enabled) && !empty($this->entity) && $this->entity > 1)
{
if (!empty($this->multicompany->enabled) && !empty($this->entity) && $this->entity > 1) {
$rootfordata .= '/'.$this->entity;
}
// Set standard temporary folder name or global override
$rootfortemp = empty($this->global->MAIN_TEMP_DIR) ? $rootfordata : $this->global->MAIN_TEMP_DIR;
// Define default dir_output and dir_temp for directories of modules
foreach ($this->modules as $module)
{
foreach ($this->modules as $module) {
//var_dump($module);
// For multicompany sharings
$this->$module->multidir_output = array($this->entity => $rootfordata."/".$module);
@ -312,19 +341,14 @@ class Conf
}
// External modules storage
if (!empty($this->modules_parts['dir']))
{
foreach ($this->modules_parts['dir'] as $module => $dirs)
{
if (!empty($this->$module->enabled))
{
foreach ($dirs as $type => $name) // $type is 'output' or 'temp'
{
if (!empty($this->modules_parts['dir'])) {
foreach ($this->modules_parts['dir'] as $module => $dirs) {
if (!empty($this->$module->enabled)) {
foreach ($dirs as $type => $name) { // $type is 'output' or 'temp'
$multidirname = 'multidir_'.$type;
$dirname = 'dir_'.$type;
if ($type != 'temp')
{
if ($type != 'temp') {
// For multicompany sharings
$this->$module->$multidirname = array($this->entity => $rootfordata."/".$name);
@ -380,8 +404,7 @@ class Conf
$this->delivery_note->enabled = (!empty($this->global->MAIN_SUBMODULE_DELIVERY) ? $this->global->MAIN_SUBMODULE_DELIVERY : 0);
// Module fournisseur
if (!empty($this->fournisseur))
{
if (!empty($this->fournisseur)) {
$this->fournisseur->commande = new stdClass();
$this->fournisseur->commande->multidir_output = array($this->entity => $rootfordata."/fournisseur/commande");
$this->fournisseur->commande->multidir_temp = array($this->entity => $rootfortemp."/fournisseur/commande/temp");
@ -407,8 +430,7 @@ class Conf
$this->fournisseur->payment->dir_temp = $rootfortemp."/fournisseur/payment/temp"; // For backward compatibility
// To prepare split of module fournisseur into module 'fournisseur' + supplier_order + supplier_invoice
if (!empty($this->fournisseur->enabled) && empty($this->global->MAIN_USE_NEW_SUPPLIERMOD)) // By default, if module supplier is on, and we don't use yet the new modules, we set artificialy the module properties
{
if (!empty($this->fournisseur->enabled) && empty($this->global->MAIN_USE_NEW_SUPPLIERMOD)) { // By default, if module supplier is on, and we don't use yet the new modules, we set artificialy the module properties
$this->supplier_order = new stdClass();
$this->supplier_order->enabled = 1;
$this->supplier_order->multidir_output = array($this->entity => $rootfordata."/fournisseur/commande");
@ -459,30 +481,42 @@ class Conf
$this->global->MAIN_MAIL_USE_MULTI_PART = 1;
// societe
if (empty($this->global->SOCIETE_CODECLIENT_ADDON)) $this->global->SOCIETE_CODECLIENT_ADDON = "mod_codeclient_leopard";
if (empty($this->global->SOCIETE_CODECOMPTA_ADDON)) $this->global->SOCIETE_CODECOMPTA_ADDON = "mod_codecompta_panicum";
if (empty($this->global->SOCIETE_CODECLIENT_ADDON)) {
$this->global->SOCIETE_CODECLIENT_ADDON = "mod_codeclient_leopard";
}
if (empty($this->global->SOCIETE_CODECOMPTA_ADDON)) {
$this->global->SOCIETE_CODECOMPTA_ADDON = "mod_codecompta_panicum";
}
if (empty($this->global->CHEQUERECEIPTS_ADDON)) $this->global->CHEQUERECEIPTS_ADDON = 'mod_chequereceipt_mint';
if (empty($this->global->TICKET_ADDON)) $this->global->TICKET_ADDON = 'mod_ticket_simple';
if (empty($this->global->CHEQUERECEIPTS_ADDON)) {
$this->global->CHEQUERECEIPTS_ADDON = 'mod_chequereceipt_mint';
}
if (empty($this->global->TICKET_ADDON)) {
$this->global->TICKET_ADDON = 'mod_ticket_simple';
}
// Security
if (empty($this->global->USER_PASSWORD_GENERATED)) $this->global->USER_PASSWORD_GENERATED = 'standard'; // Default password generator
if (empty($this->global->MAIN_UMASK)) $this->global->MAIN_UMASK = '0664'; // Default mask
if (empty($this->global->USER_PASSWORD_GENERATED)) {
$this->global->USER_PASSWORD_GENERATED = 'standard'; // Default password generator
}
if (empty($this->global->MAIN_UMASK)) {
$this->global->MAIN_UMASK = '0664'; // Default mask
}
// conf->use_javascript_ajax
$this->use_javascript_ajax = 1;
if (isset($this->global->MAIN_DISABLE_JAVASCRIPT)) $this->use_javascript_ajax = !$this->global->MAIN_DISABLE_JAVASCRIPT;
if (isset($this->global->MAIN_DISABLE_JAVASCRIPT)) {
$this->use_javascript_ajax = !$this->global->MAIN_DISABLE_JAVASCRIPT;
}
// If no javascript_ajax, Ajax features are disabled.
if (empty($this->use_javascript_ajax))
{
if (empty($this->use_javascript_ajax)) {
unset($this->global->PRODUIT_USE_SEARCH_TO_SELECT);
unset($this->global->COMPANY_USE_SEARCH_TO_SELECT);
unset($this->global->CONTACT_USE_SEARCH_TO_SELECT);
unset($this->global->PROJECT_USE_SEARCH_TO_SELECT);
}
if (!empty($this->productbatch->enabled))
{
if (!empty($this->productbatch->enabled)) {
$this->global->STOCK_CALCULATE_ON_BILL = 0;
$this->global->STOCK_CALCULATE_ON_VALIDATE_ORDER = 0;
$this->global->STOCK_CALCULATE_ON_SHIPMENT = 1;
@ -491,59 +525,88 @@ class Conf
$this->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER = 0;
if (empty($this->reception->enabled)) {
$this->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER = 1;
}
else {
} else {
$this->global->STOCK_CALCULATE_ON_RECEPTION = 1;
$this->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE = 0;
}
}
// conf->currency
if (empty($this->global->MAIN_MONNAIE)) $this->global->MAIN_MONNAIE = 'EUR';
if (empty($this->global->MAIN_MONNAIE)) {
$this->global->MAIN_MONNAIE = 'EUR';
}
$this->currency = $this->global->MAIN_MONNAIE;
if (empty($this->global->MAIN_BROWSER_NOTIFICATION_FREQUENCY)) $this->global->MAIN_BROWSER_NOTIFICATION_FREQUENCY = 30; // Less than 1 minutes to be sure
if (empty($this->global->MAIN_BROWSER_NOTIFICATION_FREQUENCY)) {
$this->global->MAIN_BROWSER_NOTIFICATION_FREQUENCY = 30; // Less than 1 minutes to be sure
}
// conf->global->ACCOUNTING_MODE = Option des modules Comptabilites (simple ou expert). Defini le mode de calcul des etats comptables (CA,...)
if (empty($this->global->ACCOUNTING_MODE)) $this->global->ACCOUNTING_MODE = 'RECETTES-DEPENSES'; // By default. Can be 'RECETTES-DEPENSES' ou 'CREANCES-DETTES'
if (empty($this->global->ACCOUNTING_MODE)) {
$this->global->ACCOUNTING_MODE = 'RECETTES-DEPENSES'; // By default. Can be 'RECETTES-DEPENSES' ou 'CREANCES-DETTES'
}
// By default, suppliers objects can be linked to all projects
if (!isset($this->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS)) $this->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS = 1;
if (!isset($this->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS)) {
$this->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS = 1;
}
// By default we enable feature to bill time spent
if (!isset($this->global->PROJECT_BILL_TIME_SPENT)) $this->global->PROJECT_BILL_TIME_SPENT = 1;
if (!isset($this->global->PROJECT_BILL_TIME_SPENT)) {
$this->global->PROJECT_BILL_TIME_SPENT = 1;
}
// MAIN_HTML_TITLE
if (!isset($this->global->MAIN_HTML_TITLE)) $this->global->MAIN_HTML_TITLE = 'noapp,thirdpartynameonly,contactnameonly,projectnameonly';
if (!isset($this->global->MAIN_HTML_TITLE)) {
$this->global->MAIN_HTML_TITLE = 'noapp,thirdpartynameonly,contactnameonly,projectnameonly';
}
// conf->liste_limit = constante de taille maximale des listes
if (empty($this->global->MAIN_SIZE_LISTE_LIMIT)) $this->global->MAIN_SIZE_LISTE_LIMIT = 25;
if (empty($this->global->MAIN_SIZE_LISTE_LIMIT)) {
$this->global->MAIN_SIZE_LISTE_LIMIT = 25;
}
$this->liste_limit = $this->global->MAIN_SIZE_LISTE_LIMIT;
// conf->product->limit_size = constante de taille maximale des select de produit
if (!isset($this->global->PRODUIT_LIMIT_SIZE)) $this->global->PRODUIT_LIMIT_SIZE = 1000;
if (!isset($this->global->PRODUIT_LIMIT_SIZE)) {
$this->global->PRODUIT_LIMIT_SIZE = 1000;
}
$this->product->limit_size = $this->global->PRODUIT_LIMIT_SIZE;
// conf->theme et $this->css
if (empty($this->global->MAIN_THEME)) $this->global->MAIN_THEME = "eldy";
if (!empty($this->global->MAIN_FORCETHEME)) $this->global->MAIN_THEME = $this->global->MAIN_FORCETHEME;
if (empty($this->global->MAIN_THEME)) {
$this->global->MAIN_THEME = "eldy";
}
if (!empty($this->global->MAIN_FORCETHEME)) {
$this->global->MAIN_THEME = $this->global->MAIN_FORCETHEME;
}
$this->theme = $this->global->MAIN_THEME;
$this->css = "/theme/".$this->theme."/style.css.php";
// conf->email_from = email pour envoi par dolibarr des mails automatiques
$this->email_from = "robot@example.com";
if (!empty($this->global->MAIN_MAIL_EMAIL_FROM)) $this->email_from = $this->global->MAIN_MAIL_EMAIL_FROM;
if (!empty($this->global->MAIN_MAIL_EMAIL_FROM)) {
$this->email_from = $this->global->MAIN_MAIL_EMAIL_FROM;
}
// conf->notification->email_from = email pour envoi par Dolibarr des notifications
$this->notification->email_from = $this->email_from;
if (!empty($this->global->NOTIFICATION_EMAIL_FROM)) $this->notification->email_from = $this->global->NOTIFICATION_EMAIL_FROM;
if (!empty($this->global->NOTIFICATION_EMAIL_FROM)) {
$this->notification->email_from = $this->global->NOTIFICATION_EMAIL_FROM;
}
// conf->mailing->email_from = email pour envoi par Dolibarr des mailings
$this->mailing->email_from = $this->email_from;
if (!empty($this->global->MAILING_EMAIL_FROM)) $this->mailing->email_from = $this->global->MAILING_EMAIL_FROM;
if (!isset($this->global->MAIN_EMAIL_ADD_TRACK_ID)) $this->global->MAIN_EMAIL_ADD_TRACK_ID = 1;
if (!empty($this->global->MAILING_EMAIL_FROM)) {
$this->mailing->email_from = $this->global->MAILING_EMAIL_FROM;
}
if (!isset($this->global->MAIN_EMAIL_ADD_TRACK_ID)) {
$this->global->MAIN_EMAIL_ADD_TRACK_ID = 1;
}
if (!isset($this->global->MAIN_HIDE_WARNING_TO_ENCOURAGE_SMTP_SETUP)) $this->global->MAIN_HIDE_WARNING_TO_ENCOURAGE_SMTP_SETUP = 1;
if (!isset($this->global->MAIN_HIDE_WARNING_TO_ENCOURAGE_SMTP_SETUP)) {
$this->global->MAIN_HIDE_WARNING_TO_ENCOURAGE_SMTP_SETUP = 1;
}
// Format for date (used by default when not found or not searched in lang)
$this->format_date_short = "%d/%m/%Y"; // Format of day with PHP/C tags (strftime functions)
@ -558,54 +621,93 @@ class Conf
$this->format_date_hour_text = "%d %B %Y %H:%M";
// Duration of workday
if (!isset($this->global->MAIN_DURATION_OF_WORKDAY)) $this->global->MAIN_DURATION_OF_WORKDAY = 86400;
if (!isset($this->global->MAIN_DURATION_OF_WORKDAY)) {
$this->global->MAIN_DURATION_OF_WORKDAY = 86400;
}
// Limites decimales si non definie (peuvent etre egale a 0)
if (!isset($this->global->MAIN_MAX_DECIMALS_UNIT)) $this->global->MAIN_MAX_DECIMALS_UNIT = 5;
if (!isset($this->global->MAIN_MAX_DECIMALS_TOT)) $this->global->MAIN_MAX_DECIMALS_TOT = 2;
if (!isset($this->global->MAIN_MAX_DECIMALS_SHOWN)) $this->global->MAIN_MAX_DECIMALS_SHOWN = 8;
if (!isset($this->global->MAIN_MAX_DECIMALS_UNIT)) {
$this->global->MAIN_MAX_DECIMALS_UNIT = 5;
}
if (!isset($this->global->MAIN_MAX_DECIMALS_TOT)) {
$this->global->MAIN_MAX_DECIMALS_TOT = 2;
}
if (!isset($this->global->MAIN_MAX_DECIMALS_SHOWN)) {
$this->global->MAIN_MAX_DECIMALS_SHOWN = 8;
}
// Default pdf option
if (!isset($this->global->MAIN_PDF_DASH_BETWEEN_LINES)) $this->global->MAIN_PDF_DASH_BETWEEN_LINES = 1; // use dash between lines
if (!isset($this->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) $this->global->PDF_ALLOW_HTML_FOR_FREE_TEXT = 1; // allow html content into free footer text
if (!isset($this->global->MAIN_PDF_DASH_BETWEEN_LINES)) {
$this->global->MAIN_PDF_DASH_BETWEEN_LINES = 1; // use dash between lines
}
if (!isset($this->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) {
$this->global->PDF_ALLOW_HTML_FOR_FREE_TEXT = 1; // allow html content into free footer text
}
// Default max file size for upload
$this->maxfilesize = (empty($this->global->MAIN_UPLOAD_DOC) ? 0 : (int) $this->global->MAIN_UPLOAD_DOC * 1024);
// By default, we propagate contacts
if (!isset($this->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN)) $this->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN = '*'; // Can be also '*' or '^(BILLING|SHIPPING|CUSTOMER|.*)$' (regex not yet implemented)
if (!isset($this->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN)) {
$this->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN = '*'; // Can be also '*' or '^(BILLING|SHIPPING|CUSTOMER|.*)$' (regex not yet implemented)
}
// By default, we do not use the zip town table but the table of third parties
if (!isset($this->global->MAIN_USE_ZIPTOWN_DICTIONNARY)) $this->global->MAIN_USE_ZIPTOWN_DICTIONNARY = 0;
if (!isset($this->global->MAIN_USE_ZIPTOWN_DICTIONNARY)) {
$this->global->MAIN_USE_ZIPTOWN_DICTIONNARY = 0;
}
// By default, we open card if one found
if (!isset($this->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE)) $this->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE = 1;
if (!isset($this->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE)) {
$this->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE = 1;
}
// By default, we show state code in combo list
if (!isset($this->global->MAIN_SHOW_STATE_CODE)) $this->global->MAIN_SHOW_STATE_CODE = 1;
if (!isset($this->global->MAIN_SHOW_STATE_CODE)) {
$this->global->MAIN_SHOW_STATE_CODE = 1;
}
// Use a SCA ready workflow with Stripe module (STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION by default if nothing defined)
if (!isset($this->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION) && empty($this->global->STRIPE_USE_NEW_CHECKOUT)) $this->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION = 1;
if (!isset($this->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION) && empty($this->global->STRIPE_USE_NEW_CHECKOUT)) {
$this->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION = 1;
}
// Define list of limited modules (value must be key found for "name" property of module, so for example 'supplierproposal' for Module "Supplier Proposal"
if (!isset($this->global->MAIN_MODULES_FOR_EXTERNAL)) $this->global->MAIN_MODULES_FOR_EXTERNAL = 'user,societe,propal,commande,facture,categorie,supplierproposal,fournisseur,contact,projet,contrat,ficheinter,expedition,agenda,resource,adherent,blockedlog'; // '' means 'all'. Note that contact is added here as it should be a module later.
if (!empty($this->modules_parts['moduleforexternal'])) // Module part to include an external module into the MAIN_MODULES_FOR_EXTERNAL list
{
foreach ($this->modules_parts['moduleforexternal'] as $key=>$value) $this->global->MAIN_MODULES_FOR_EXTERNAL .= ",".$key;
if (!isset($this->global->MAIN_MODULES_FOR_EXTERNAL)) {
$this->global->MAIN_MODULES_FOR_EXTERNAL = 'user,societe,propal,commande,facture,categorie,supplierproposal,fournisseur,contact,projet,contrat,ficheinter,expedition,agenda,resource,adherent,blockedlog'; // '' means 'all'. Note that contact is added here as it should be a module later.
}
if (!empty($this->modules_parts['moduleforexternal'])) { // Module part to include an external module into the MAIN_MODULES_FOR_EXTERNAL list
foreach ($this->modules_parts['moduleforexternal'] as $key => $value) {
$this->global->MAIN_MODULES_FOR_EXTERNAL .= ",".$key;
}
}
// Enable select2
if (empty($this->global->MAIN_USE_JQUERY_MULTISELECT) || $this->global->MAIN_USE_JQUERY_MULTISELECT == '1') $this->global->MAIN_USE_JQUERY_MULTISELECT = 'select2';
if (empty($this->global->MAIN_USE_JQUERY_MULTISELECT) || $this->global->MAIN_USE_JQUERY_MULTISELECT == '1') {
$this->global->MAIN_USE_JQUERY_MULTISELECT = 'select2';
}
// Timeouts
if (empty($this->global->MAIN_USE_CONNECT_TIMEOUT)) $this->global->MAIN_USE_CONNECT_TIMEOUT = 10;
if (empty($this->global->MAIN_USE_RESPONSE_TIMEOUT)) $this->global->MAIN_USE_RESPONSE_TIMEOUT = 30;
if (empty($this->global->MAIN_USE_CONNECT_TIMEOUT)) {
$this->global->MAIN_USE_CONNECT_TIMEOUT = 10;
}
if (empty($this->global->MAIN_USE_RESPONSE_TIMEOUT)) {
$this->global->MAIN_USE_RESPONSE_TIMEOUT = 30;
}
// Set default variable to calculate VAT as if option tax_mode was 0 (standard)
if (empty($this->global->TAX_MODE_SELL_PRODUCT)) $this->global->TAX_MODE_SELL_PRODUCT = 'invoice';
if (empty($this->global->TAX_MODE_BUY_PRODUCT)) $this->global->TAX_MODE_BUY_PRODUCT = 'invoice';
if (empty($this->global->TAX_MODE_SELL_SERVICE)) $this->global->TAX_MODE_SELL_SERVICE = 'payment';
if (empty($this->global->TAX_MODE_BUY_SERVICE)) $this->global->TAX_MODE_BUY_SERVICE = 'payment';
if (empty($this->global->TAX_MODE_SELL_PRODUCT)) {
$this->global->TAX_MODE_SELL_PRODUCT = 'invoice';
}
if (empty($this->global->TAX_MODE_BUY_PRODUCT)) {
$this->global->TAX_MODE_BUY_PRODUCT = 'invoice';
}
if (empty($this->global->TAX_MODE_SELL_SERVICE)) {
$this->global->TAX_MODE_SELL_SERVICE = 'payment';
}
if (empty($this->global->TAX_MODE_BUY_SERVICE)) {
$this->global->TAX_MODE_BUY_SERVICE = 'payment';
}
// Delay before warnings
// Avoid strict errors. TODO: Replace xxx->warning_delay with a property ->warning_delay_xxx
@ -616,8 +718,7 @@ class Conf
if (isset($this->agenda)) {
$this->agenda->warning_delay = (isset($this->global->MAIN_DELAY_ACTIONS_TODO) ? $this->global->MAIN_DELAY_ACTIONS_TODO : 7) * 86400;
}
if (isset($this->projet))
{
if (isset($this->projet)) {
$this->projet->warning_delay = (isset($this->global->MAIN_DELAY_PROJECT_TO_CLOSE) ? $this->global->MAIN_DELAY_PROJECT_TO_CLOSE : 7) * 86400;
$this->projet->task = new StdClass();
$this->projet->task->warning_delay = (isset($this->global->MAIN_DELAY_TASKS_TODO) ? $this->global->MAIN_DELAY_TASKS_TODO : 7) * 86400;
@ -644,9 +745,9 @@ class Conf
if (isset($this->contrat)) {
$this->contrat->services = new stdClass();
$this->contrat->services->inactifs = new stdClass();
$this->contrat->services->expires = new stdClass();
$this->contrat->services->inactifs->warning_delay = (isset($this->global->MAIN_DELAY_NOT_ACTIVATED_SERVICES) ? $this->global->MAIN_DELAY_NOT_ACTIVATED_SERVICES : 0) * 86400;
$this->contrat->services->expires->warning_delay = (isset($this->global->MAIN_DELAY_RUNNING_SERVICES) ? $this->global->MAIN_DELAY_RUNNING_SERVICES : 0) * 86400;
$this->contrat->services->expires = new stdClass();
$this->contrat->services->inactifs->warning_delay = (isset($this->global->MAIN_DELAY_NOT_ACTIVATED_SERVICES) ? $this->global->MAIN_DELAY_NOT_ACTIVATED_SERVICES : 0) * 86400;
$this->contrat->services->expires->warning_delay = (isset($this->global->MAIN_DELAY_RUNNING_SERVICES) ? $this->global->MAIN_DELAY_RUNNING_SERVICES : 0) * 86400;
}
if (isset($this->commande)) {
$this->bank->rappro = new stdClass();
@ -665,37 +766,57 @@ class Conf
$this->holiday->approve->warning_delay = (isset($this->global->MAIN_DELAY_HOLIDAYS) ? $this->global->MAIN_DELAY_HOLIDAYS : 0) * 86400;
}
if (!empty($this->global->PRODUIT_MULTIPRICES) && empty($this->global->PRODUIT_MULTIPRICES_LIMIT))
{
if (!empty($this->global->PRODUIT_MULTIPRICES) && empty($this->global->PRODUIT_MULTIPRICES_LIMIT)) {
$this->global->PRODUIT_MULTIPRICES_LIMIT = 5;
}
// For modules that want to disable top or left menu
if (!empty($this->global->MAIN_HIDE_TOP_MENU)) $this->dol_hide_topmenu = $this->global->MAIN_HIDE_TOP_MENU;
if (!empty($this->global->MAIN_HIDE_LEFT_MENU)) $this->dol_hide_leftmenu = $this->global->MAIN_HIDE_LEFT_MENU;
if (!empty($this->global->MAIN_HIDE_TOP_MENU)) {
$this->dol_hide_topmenu = $this->global->MAIN_HIDE_TOP_MENU;
}
if (!empty($this->global->MAIN_HIDE_LEFT_MENU)) {
$this->dol_hide_leftmenu = $this->global->MAIN_HIDE_LEFT_MENU;
}
if (empty($this->global->MAIN_SIZE_SHORTLIST_LIMIT)) $this->global->MAIN_SIZE_SHORTLIST_LIMIT = 3;
if (empty($this->global->MAIN_SIZE_SHORTLIST_LIMIT)) {
$this->global->MAIN_SIZE_SHORTLIST_LIMIT = 3;
}
if (!isset($this->global->THEME_HIDE_BORDER_ON_INPUT)) $this->global->THEME_HIDE_BORDER_ON_INPUT = 0;
if (!isset($this->global->THEME_HIDE_BORDER_ON_INPUT)) {
$this->global->THEME_HIDE_BORDER_ON_INPUT = 0;
}
// Save inconsistent option
if (empty($this->global->AGENDA_USE_EVENT_TYPE) && (!isset($this->global->AGENDA_DEFAULT_FILTER_TYPE) || $this->global->AGENDA_DEFAULT_FILTER_TYPE == 'AC_NON_AUTO'))
{
if (empty($this->global->AGENDA_USE_EVENT_TYPE) && (!isset($this->global->AGENDA_DEFAULT_FILTER_TYPE) || $this->global->AGENDA_DEFAULT_FILTER_TYPE == 'AC_NON_AUTO')) {
$this->global->AGENDA_DEFAULT_FILTER_TYPE = '0'; // 'AC_NON_AUTO' does not exists when AGENDA_DEFAULT_FILTER_TYPE is not on.
}
if (!isset($this->global->MAIN_JS_GRAPH)) $this->global->MAIN_JS_GRAPH = 'chart'; // Use chart.js library
if (!isset($this->global->MAIN_JS_GRAPH)) {
$this->global->MAIN_JS_GRAPH = 'chart'; // Use chart.js library
}
if (empty($this->global->MAIN_MODULE_DOLISTORE_API_SRV)) $this->global->MAIN_MODULE_DOLISTORE_API_SRV = 'https://www.dolistore.com';
if (empty($this->global->MAIN_MODULE_DOLISTORE_API_KEY)) $this->global->MAIN_MODULE_DOLISTORE_API_KEY = 'dolistorecatalogpublickey1234567';
if (empty($this->global->MAIN_MODULE_DOLISTORE_API_SRV)) {
$this->global->MAIN_MODULE_DOLISTORE_API_SRV = 'https://www.dolistore.com';
}
if (empty($this->global->MAIN_MODULE_DOLISTORE_API_KEY)) {
$this->global->MAIN_MODULE_DOLISTORE_API_KEY = 'dolistorecatalogpublickey1234567';
}
// If we are in develop mode, we activate the option MAIN_SECURITY_CSRF_WITH_TOKEN to 1 if not already defined.
if (!isset($this->global->MAIN_SECURITY_CSRF_WITH_TOKEN) && $this->global->MAIN_FEATURES_LEVEL >= 2) $this->global->MAIN_SECURITY_CSRF_WITH_TOKEN = 1;
if (!isset($this->global->MAIN_SECURITY_CSRF_WITH_TOKEN) && $this->global->MAIN_FEATURES_LEVEL >= 2) {
$this->global->MAIN_SECURITY_CSRF_WITH_TOKEN = 1;
}
if (defined('MAIN_ANTIVIRUS_COMMAND')) $this->global->MAIN_ANTIVIRUS_COMMAND = constant('MAIN_ANTIVIRUS_COMMAND');
if (defined('MAIN_ANTIVIRUS_PARAM')) $this->global->MAIN_ANTIVIRUS_PARAM = constant('MAIN_ANTIVIRUS_PARAM');
if (defined('MAIN_ANTIVIRUS_COMMAND')) {
$this->global->MAIN_ANTIVIRUS_COMMAND = constant('MAIN_ANTIVIRUS_COMMAND');
}
if (defined('MAIN_ANTIVIRUS_PARAM')) {
$this->global->MAIN_ANTIVIRUS_PARAM = constant('MAIN_ANTIVIRUS_PARAM');
}
if (!empty($this->global->MAIN_TZUSERINPUTKEY)) $this->tzuserinputkey = $this->global->MAIN_TZUSERINPUTKEY; // 'tzserver' or 'tzuserrel'
if (!empty($this->global->MAIN_TZUSERINPUTKEY)) {
$this->tzuserinputkey = $this->global->MAIN_TZUSERINPUTKEY; // 'tzserver' or 'tzuserrel'
}
if (!empty($this->global->PRODUIT_AUTOFILL_DESC)) {
$this->global->MAIN_NO_CONCAT_DESCRIPTION = 1;
@ -704,17 +825,30 @@ class Conf
}
// For backward compatibility
if (isset($this->product)) $this->produit = $this->product;
if (isset($this->facture)) $this->invoice = $this->facture;
if (isset($this->commande)) $this->order = $this->commande;
if (isset($this->contrat)) $this->contract = $this->contrat;
if (isset($this->categorie)) $this->category = $this->categorie;
if (isset($this->project)) $this->project = $this->projet;
if (isset($this->product)) {
$this->produit = $this->product;
}
if (isset($this->facture)) {
$this->invoice = $this->facture;
}
if (isset($this->commande)) {
$this->order = $this->commande;
}
if (isset($this->contrat)) {
$this->contract = $this->contrat;
}
if (isset($this->categorie)) {
$this->category = $this->categorie;
}
if (isset($this->project)) {
$this->project = $this->projet;
}
// Object $mc
if (!defined('NOREQUIREMC') && !empty($this->multicompany->enabled))
{
if (is_object($mc)) $mc->setValues($this);
if (!defined('NOREQUIREMC') && !empty($this->multicompany->enabled)) {
if (is_object($mc)) {
$mc->setValues($this);
}
}
if (!empty($this->syslog->enabled)) {

View File

@ -59,15 +59,19 @@ class CoreObject extends CommonObject
$this->datec = 0;
$this->tms = 0;
if (!empty($this->fields))
{
foreach ($this->fields as $field=>$info)
{
if ($this->isDate($info)) $this->{$field} = time();
elseif ($this->isArray($info)) $this->{$field} = array();
elseif ($this->isInt($info)) $this->{$field} = (int) 0;
elseif ($this->isFloat($info)) $this->{$field} = (double) 0;
else $this->{$field} = '';
if (!empty($this->fields)) {
foreach ($this->fields as $field => $info) {
if ($this->isDate($info)) {
$this->{$field} = time();
} elseif ($this->isArray($info)) {
$this->{$field} = array();
} elseif ($this->isInt($info)) {
$this->{$field} = (int) 0;
} elseif ($this->isFloat($info)) {
$this->{$field} = (double) 0;
} else {
$this->{$field} = '';
}
}
$this->to_delete = false;
@ -88,8 +92,7 @@ class CoreObject extends CommonObject
*/
private function checkFieldType($field, $type)
{
if (isset($this->fields[$field]) && method_exists($this, 'is_'.$type))
{
if (isset($this->fields[$field]) && method_exists($this, 'is_'.$type)) {
return $this->{'is_'.$type}($this->fields[$field]);
} else {
return false;
@ -107,7 +110,9 @@ class CoreObject extends CommonObject
{
$res = $this->fetchCommon($id);
if ($res > 0) {
if ($loadChild) $this->fetchChild();
if ($loadChild) {
$this->fetchChild();
}
}
return $res;
@ -125,11 +130,11 @@ class CoreObject extends CommonObject
*/
public function addChild($tabName, $id = 0, $key = 'id', $try_to_load = false)
{
if (!empty($id))
{
foreach ($this->{$tabName} as $k=>&$object)
{
if ($object->{$key} === $id) return $k;
if (!empty($id)) {
foreach ($this->{$tabName} as $k => &$object) {
if ($object->{$key} === $id) {
return $k;
}
}
}
@ -137,8 +142,7 @@ class CoreObject extends CommonObject
$className = ucfirst($tabName);
$this->{$tabName}[$k] = new $className($this->db);
if ($id > 0 && $key === 'id' && $try_to_load)
{
if ($id > 0 && $key === 'id' && $try_to_load) {
$this->{$tabName}[$k]->fetch($id);
}
@ -156,10 +160,8 @@ class CoreObject extends CommonObject
*/
public function removeChild($tabName, $id, $key = 'id')
{
foreach ($this->{$tabName} as &$object)
{
if ($object->{$key} == $id)
{
foreach ($this->{$tabName} as &$object) {
if ($object->{$key} == $id) {
$object->to_delete = true;
return true;
}
@ -175,10 +177,8 @@ class CoreObject extends CommonObject
*/
public function fetchChild()
{
if ($this->withChild && !empty($this->childtables) && !empty($this->fk_element))
{
foreach ($this->childtables as &$childTable)
{
if ($this->withChild && !empty($this->childtables) && !empty($this->fk_element)) {
foreach ($this->childtables as &$childTable) {
$className = ucfirst($childTable);
$this->{$className} = array();
@ -186,10 +186,8 @@ class CoreObject extends CommonObject
$sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.$childTable.' WHERE '.$this->fk_element.' = '.$this->id;
$res = $this->db->query($sql);
if ($res)
{
while ($obj = $this->db->fetch_object($res))
{
if ($res) {
while ($obj = $this->db->fetch_object($res)) {
$o = new $className($this->db);
$o->fetch($obj->rowid);
@ -210,19 +208,17 @@ class CoreObject extends CommonObject
*/
public function saveChild(User &$user)
{
if ($this->withChild && !empty($this->childtables) && !empty($this->fk_element))
{
foreach ($this->childtables as &$childTable)
{
if ($this->withChild && !empty($this->childtables) && !empty($this->fk_element)) {
foreach ($this->childtables as &$childTable) {
$className = ucfirst($childTable);
if (!empty($this->{$className}))
{
foreach ($this->{$className} as $i => &$object)
{
if (!empty($this->{$className})) {
foreach ($this->{$className} as $i => &$object) {
$object->{$this->fk_element} = $this->id;
$object->update($user);
if ($this->unsetChildDeleted && isset($object->to_delete) && $object->to_delete == true) unset($this->{$className}[$i]);
if ($this->unsetChildDeleted && isset($object->to_delete) && $object->to_delete == true) {
unset($this->{$className}[$i]);
}
}
}
}
@ -238,26 +234,30 @@ class CoreObject extends CommonObject
*/
public function update(User &$user)
{
if (empty($this->id)) return $this->create($user); // To test, with that, no need to test on high level object, the core decide it, update just needed
elseif (isset($this->to_delete) && $this->to_delete == true) return $this->delete($user);
if (empty($this->id)) {
return $this->create($user); // To test, with that, no need to test on high level object, the core decide it, update just needed
} elseif (isset($this->to_delete) && $this->to_delete == true) {
return $this->delete($user);
}
$error = 0;
$this->db->begin();
$res = $this->updateCommon($user);
if ($res)
{
if ($res) {
$result = $this->call_trigger(strtoupper($this->element).'_UPDATE', $user);
if ($result < 0) $error++;
else $this->saveChild($user);
if ($result < 0) {
$error++;
} else {
$this->saveChild($user);
}
} else {
$error++;
$this->error = $this->db->lasterror();
$this->errors[] = $this->error;
}
if (empty($error))
{
if (empty($error)) {
$this->db->commit();
return $this->id;
} else {
@ -274,27 +274,30 @@ class CoreObject extends CommonObject
*/
public function create(User $user)
{
if ($this->id > 0) return $this->update($user);
if ($this->id > 0) {
return $this->update($user);
}
$error = 0;
$this->db->begin();
$res = $this->createCommon($user);
if ($res)
{
if ($res) {
$this->id = $this->db->last_insert_id($this->table_element);
$result = $this->call_trigger(strtoupper($this->element).'_CREATE', $user);
if ($result < 0) $error++;
else $this->saveChild($user);
if ($result < 0) {
$error++;
} else {
$this->saveChild($user);
}
} else {
$error++;
$this->error = $this->db->lasterror();
$this->errors[] = $this->error;
}
if (empty($error))
{
if (empty($error)) {
$this->db->commit();
return $this->id;
} else {
@ -311,26 +314,25 @@ class CoreObject extends CommonObject
*/
public function delete(User &$user)
{
if ($this->id <= 0) return 0;
if ($this->id <= 0) {
return 0;
}
$error = 0;
$this->db->begin();
$result = $this->call_trigger(strtoupper($this->element).'_DELETE', $user);
if ($result < 0) $error++;
if ($result < 0) {
$error++;
}
if (!$error)
{
if (!$error) {
$this->deleteCommon($user);
if ($this->withChild && !empty($this->childtables))
{
foreach ($this->childtables as &$childTable)
{
if ($this->withChild && !empty($this->childtables)) {
foreach ($this->childtables as &$childTable) {
$className = ucfirst($childTable);
if (!empty($this->{$className}))
{
foreach ($this->{$className} as &$object)
{
if (!empty($this->{$className})) {
foreach ($this->{$className} as &$object) {
$object->delete($user);
}
}
@ -338,8 +340,7 @@ class CoreObject extends CommonObject
}
}
if (empty($error))
{
if (empty($error)) {
$this->db->commit();
return 1;
} else {
@ -360,8 +361,9 @@ class CoreObject extends CommonObject
*/
public function getDate($field, $format = '')
{
if (empty($this->{$field})) return '';
else {
if (empty($this->{$field})) {
return '';
} else {
return dol_print_date($this->{$field}, $format);
}
}
@ -375,8 +377,7 @@ class CoreObject extends CommonObject
*/
public function setDate($field, $date)
{
if (empty($date))
{
if (empty($date)) {
$this->{$field} = 0;
} else {
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
@ -395,13 +396,10 @@ class CoreObject extends CommonObject
*/
public function setValues(&$Tab)
{
foreach ($Tab as $key => $value)
{
if ($this->checkFieldType($key, 'date'))
{
foreach ($Tab as $key => $value) {
if ($this->checkFieldType($key, 'date')) {
$this->setDate($key, $value);
} elseif ($this->checkFieldType($key, 'float'))
{
} elseif ($this->checkFieldType($key, 'float')) {
$this->{$key} = (double) price2num($value);
} elseif ($this->checkFieldType($key, 'int')) {
$this->{$key} = (int) price2num($value);

View File

@ -116,7 +116,7 @@ class CProductNature // extends CommonObject
$this->db->begin();
dol_syslog(get_class($this)."::create", LOG_DEBUG);
dol_syslog(get_class($this)."::create", LOG_DEBUG);
$resql = $this->db->query($sql);
// Commit or rollback
if (!$resql) {
@ -150,17 +150,19 @@ class CProductNature // extends CommonObject
$sql .= " t.active";
$sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t";
$sql_where = array();
if ($id) $sql_where[] = " t.rowid = ".$id;
if ($code >= 0) $sql_where[] = " t.code = ".((int) $code);
if ($id) {
$sql_where[] = " t.rowid = ".$id;
}
if ($code >= 0) {
$sql_where[] = " t.code = ".((int) $code);
}
if (count($sql_where) > 0) {
$sql .= ' WHERE '.implode(' AND ', $sql_where);
}
$resql = $this->db->query($sql);
if ($resql)
{
if ($this->db->num_rows($resql))
{
if ($resql) {
if ($this->db->num_rows($resql)) {
$obj = $this->db->fetch_object($resql);
$this->id = $obj->rowid;
@ -172,7 +174,7 @@ class CProductNature // extends CommonObject
return 1;
} else {
$this->error = "Error ".$this->db->lasterror();
$this->error = "Error ".$this->db->lasterror();
return -1;
}
}
@ -232,8 +234,7 @@ class CProductNature // extends CommonObject
$this->records = array();
$num = $this->db->num_rows($resql);
if ($num > 0) {
while ($obj = $this->db->fetch_object($resql))
{
while ($obj = $this->db->fetch_object($resql)) {
$record = new self($this->db);
$record->id = $obj->rowid;
@ -289,13 +290,13 @@ class CProductNature // extends CommonObject
}
/**
* Delete object in database
*
* @param User $user User that delete
* @param int $notrigger 0=launch triggers after, 1=disable triggers
* @return int <0 if KO, >0 if OK
*/
/**
* Delete object in database
*
* @param User $user User that delete
* @param int $notrigger 0=launch triggers after, 1=disable triggers
* @return int <0 if KO, >0 if OK
*/
public function delete($user, $notrigger = 0)
{
global $conf, $langs;

View File

@ -92,9 +92,15 @@ class Cstate // extends CommonObject
$error = 0;
// Clean parameters
if (isset($this->code_departement)) $this->code_departement = trim($this->code_departement);
if (isset($this->nom)) $this->nom = trim($this->nom);
if (isset($this->active)) $this->active = trim($this->active);
if (isset($this->code_departement)) {
$this->code_departement = trim($this->code_departement);
}
if (isset($this->nom)) {
$this->nom = trim($this->nom);
}
if (isset($this->active)) {
$this->active = trim($this->active);
}
// Check parameters
// Put here code to add control on parameters values
@ -114,19 +120,19 @@ class Cstate // extends CommonObject
$this->db->begin();
dol_syslog(get_class($this)."::create", LOG_DEBUG);
dol_syslog(get_class($this)."::create", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
if (!$resql) {
$error++; $this->errors[] = "Error ".$this->db->lasterror();
}
if (!$error) {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."c_departements");
}
// Commit or rollback
if ($error)
{
foreach ($this->errors as $errmsg)
{
if ($error) {
foreach ($this->errors as $errmsg) {
dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR);
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
}
@ -155,15 +161,16 @@ class Cstate // extends CommonObject
$sql .= " t.nom,";
$sql .= " t.active";
$sql .= " FROM ".MAIN_DB_PREFIX."c_departements as t";
if ($id) $sql .= " WHERE t.rowid = ".$id;
elseif ($code) $sql .= " WHERE t.code_departement = '".$this->db->escape($code)."'";
if ($id) {
$sql .= " WHERE t.rowid = ".$id;
} elseif ($code) {
$sql .= " WHERE t.code_departement = '".$this->db->escape($code)."'";
}
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
if ($this->db->num_rows($resql))
{
if ($resql) {
if ($this->db->num_rows($resql)) {
$obj = $this->db->fetch_object($resql);
$this->id = $obj->rowid;
@ -177,7 +184,7 @@ class Cstate // extends CommonObject
return 1;
} else {
$this->error = "Error ".$this->db->lasterror();
$this->error = "Error ".$this->db->lasterror();
return -1;
}
}
@ -196,9 +203,15 @@ class Cstate // extends CommonObject
$error = 0;
// Clean parameters
if (isset($this->code_departement)) $this->code_departement = trim($this->code_departement);
if (isset($this->nom)) $this->nom = trim($this->nom);
if (isset($this->active)) $this->active = trim($this->active);
if (isset($this->code_departement)) {
$this->code_departement = trim($this->code_departement);
}
if (isset($this->nom)) {
$this->nom = trim($this->nom);
}
if (isset($this->active)) {
$this->active = trim($this->active);
}
// Check parameters
@ -215,7 +228,9 @@ class Cstate // extends CommonObject
dol_syslog(get_class($this)."::update", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
if (!$resql) {
$error++; $this->errors[] = "Error ".$this->db->lasterror();
}
// Commit or rollback
if ($error) {
@ -231,13 +246,13 @@ class Cstate // extends CommonObject
}
}
/**
* Delete object in database
*
* @param User $user User that delete
* @param int $notrigger 0=launch triggers after, 1=disable triggers
* @return int <0 if KO, >0 if OK
*/
/**
* Delete object in database
*
* @param User $user User that delete
* @param int $notrigger 0=launch triggers after, 1=disable triggers
* @return int <0 if KO, >0 if OK
*/
public function delete($user, $notrigger = 0)
{
global $conf, $langs;
@ -250,13 +265,13 @@ class Cstate // extends CommonObject
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
if (!$resql) {
$error++; $this->errors[] = "Error ".$this->db->lasterror();
}
// Commit or rollback
if ($error)
{
foreach ($this->errors as $errmsg)
{
if ($error) {
foreach ($this->errors as $errmsg) {
dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
}

View File

@ -83,11 +83,21 @@ class Ctypent // extends CommonObject
// Clean parameters
if (isset($this->id)) $this->id = trim($this->id);
if (isset($this->code)) $this->code = trim($this->code);
if (isset($this->libelle)) $this->libelle = trim($this->libelle);
if (isset($this->active)) $this->active = trim($this->active);
if (isset($this->module)) $this->module = trim($this->module);
if (isset($this->id)) {
$this->id = trim($this->id);
}
if (isset($this->code)) {
$this->code = trim($this->code);
}
if (isset($this->libelle)) {
$this->libelle = trim($this->libelle);
}
if (isset($this->active)) {
$this->active = trim($this->active);
}
if (isset($this->module)) {
$this->module = trim($this->module);
}
@ -117,20 +127,19 @@ class Ctypent // extends CommonObject
$this->db->begin();
dol_syslog(get_class($this)."::create", LOG_DEBUG);
dol_syslog(get_class($this)."::create", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
if (!$resql) {
$error++; $this->errors[] = "Error ".$this->db->lasterror();
}
if (!$error)
{
if (!$error) {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."c_typent");
}
// Commit or rollback
if ($error)
{
foreach ($this->errors as $errmsg)
{
if ($error) {
foreach ($this->errors as $errmsg) {
dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR);
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
}
@ -162,15 +171,17 @@ class Ctypent // extends CommonObject
$sql .= " t.active,";
$sql .= " t.module";
$sql .= " FROM ".MAIN_DB_PREFIX."c_typent as t";
if ($id) $sql .= " WHERE t.id = ".$id;
elseif ($code) $sql .= " WHERE t.code = '".$this->db->escape($code)."'";
elseif ($label) $sql .= " WHERE t.libelle = '".$this->db->escape($label)."'";
if ($id) {
$sql .= " WHERE t.id = ".$id;
} elseif ($code) {
$sql .= " WHERE t.code = '".$this->db->escape($code)."'";
} elseif ($label) {
$sql .= " WHERE t.libelle = '".$this->db->escape($label)."'";
}
$resql = $this->db->query($sql);
if ($resql)
{
if ($this->db->num_rows($resql))
{
if ($resql) {
if ($this->db->num_rows($resql)) {
$obj = $this->db->fetch_object($resql);
$this->id = $obj->id;
@ -184,7 +195,7 @@ class Ctypent // extends CommonObject
return 1;
} else {
$this->error = "Error ".$this->db->lasterror();
$this->error = "Error ".$this->db->lasterror();
return -1;
}
}
@ -203,10 +214,18 @@ class Ctypent // extends CommonObject
$error = 0;
// Clean parameters
if (isset($this->code)) $this->code = trim($this->code);
if (isset($this->libelle)) $this->libelle = trim($this->libelle);
if (isset($this->active)) $this->active = trim($this->active);
if (isset($this->module)) $this->module = trim($this->module);
if (isset($this->code)) {
$this->code = trim($this->code);
}
if (isset($this->libelle)) {
$this->libelle = trim($this->libelle);
}
if (isset($this->active)) {
$this->active = trim($this->active);
}
if (isset($this->module)) {
$this->module = trim($this->module);
}
// Check parameters
@ -224,13 +243,13 @@ class Ctypent // extends CommonObject
dol_syslog(get_class($this)."::update", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
if (!$resql) {
$error++; $this->errors[] = "Error ".$this->db->lasterror();
}
// Commit or rollback
if ($error)
{
foreach ($this->errors as $errmsg)
{
if ($error) {
foreach ($this->errors as $errmsg) {
dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
}
@ -243,13 +262,13 @@ class Ctypent // extends CommonObject
}
/**
* Delete object in database
*
* @param User $user User that delete
* @param int $notrigger 0=launch triggers after, 1=disable triggers
* @return int <0 if KO, >0 if OK
*/
/**
* Delete object in database
*
* @param User $user User that delete
* @param int $notrigger 0=launch triggers after, 1=disable triggers
* @return int <0 if KO, >0 if OK
*/
public function delete($user, $notrigger = 0)
{
global $conf, $langs;
@ -262,13 +281,13 @@ class Ctypent // extends CommonObject
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
if (!$resql) {
$error++; $this->errors[] = "Error ".$this->db->lasterror();
}
// Commit or rollback
if ($error)
{
foreach ($this->errors as $errmsg)
{
if ($error) {
foreach ($this->errors as $errmsg) {
dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
}

View File

@ -172,9 +172,13 @@ class Ctyperesource
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
if ($id) $sql .= " WHERE t.id = ".$id;
elseif ($code) $sql .= " WHERE t.code = '".$this->db->escape($code)."'";
elseif ($label) $sql .= " WHERE t.label = '".$this->db->escape($label)."'";
if ($id) {
$sql .= " WHERE t.id = ".$id;
} elseif ($code) {
$sql .= " WHERE t.code = '".$this->db->escape($code)."'";
} elseif ($label) {
$sql .= " WHERE t.label = '".$this->db->escape($label)."'";
}
$resql = $this->db->query($sql);

View File

@ -86,13 +86,27 @@ class CUnits // extends CommonObject
// Clean parameters
if (isset($this->id)) $this->id = (int) $this->id;
if (isset($this->code)) $this->code = trim($this->code);
if (isset($this->label)) $this->libelle = trim($this->label);
if (isset($this->short_label)) $this->libelle = trim($this->short_label);
if (isset($this->unit_type)) $this->active = trim($this->unit_type);
if (isset($this->active)) $this->active = trim($this->active);
if (isset($this->scale)) $this->scale = trim($this->scale);
if (isset($this->id)) {
$this->id = (int) $this->id;
}
if (isset($this->code)) {
$this->code = trim($this->code);
}
if (isset($this->label)) {
$this->libelle = trim($this->label);
}
if (isset($this->short_label)) {
$this->libelle = trim($this->short_label);
}
if (isset($this->unit_type)) {
$this->active = trim($this->unit_type);
}
if (isset($this->active)) {
$this->active = trim($this->active);
}
if (isset($this->scale)) {
$this->scale = trim($this->scale);
}
// Check parameters
// Put here code to add control on parameters values
@ -116,20 +130,19 @@ class CUnits // extends CommonObject
$this->db->begin();
dol_syslog(get_class($this)."::create", LOG_DEBUG);
dol_syslog(get_class($this)."::create", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
if (!$resql) {
$error++; $this->errors[] = "Error ".$this->db->lasterror();
}
if (!$error)
{
if (!$error) {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."c_units");
}
// Commit or rollback
if ($error)
{
foreach ($this->errors as $errmsg)
{
if ($error) {
foreach ($this->errors as $errmsg) {
dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR);
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
}
@ -166,19 +179,25 @@ class CUnits // extends CommonObject
$sql .= " t.active";
$sql .= " FROM ".MAIN_DB_PREFIX."c_units as t";
$sql_where = array();
if ($id) $sql_where[] = " t.rowid = ".$id;
if ($unit_type) $sql_where[] = " t.unit_type = '".$this->db->escape($unit_type)."'";
if ($code) $sql_where[] = " t.code = '".$this->db->escape($code)."'";
if ($short_label) $sql_where[] = " t.short_label = '".$this->db->escape($short_label)."'";
if ($id) {
$sql_where[] = " t.rowid = ".$id;
}
if ($unit_type) {
$sql_where[] = " t.unit_type = '".$this->db->escape($unit_type)."'";
}
if ($code) {
$sql_where[] = " t.code = '".$this->db->escape($code)."'";
}
if ($short_label) {
$sql_where[] = " t.short_label = '".$this->db->escape($short_label)."'";
}
if (count($sql_where) > 0) {
$sql .= ' WHERE '.implode(' AND ', $sql_where);
}
$resql = $this->db->query($sql);
if ($resql)
{
if ($this->db->num_rows($resql))
{
if ($resql) {
if ($this->db->num_rows($resql)) {
$obj = $this->db->fetch_object($resql);
$this->id = $obj->rowid;
@ -194,7 +213,7 @@ class CUnits // extends CommonObject
return 1;
} else {
$this->error = "Error ".$this->db->lasterror();
$this->error = "Error ".$this->db->lasterror();
return -1;
}
}
@ -295,12 +314,24 @@ class CUnits // extends CommonObject
$error = 0;
// Clean parameters
if (isset($this->code)) $this->code = trim($this->code);
if (isset($this->label)) $this->libelle = trim($this->label);
if (isset($this->short_label)) $this->libelle = trim($this->short_label);
if (isset($this->unit_type)) $this->libelle = trim($this->unit_type);
if (isset($this->scale)) $this->scale = trim($this->scale);
if (isset($this->active)) $this->active = trim($this->active);
if (isset($this->code)) {
$this->code = trim($this->code);
}
if (isset($this->label)) {
$this->libelle = trim($this->label);
}
if (isset($this->short_label)) {
$this->libelle = trim($this->short_label);
}
if (isset($this->unit_type)) {
$this->libelle = trim($this->unit_type);
}
if (isset($this->scale)) {
$this->scale = trim($this->scale);
}
if (isset($this->active)) {
$this->active = trim($this->active);
}
// Check parameters
// Put here code to add control on parameters values
@ -319,13 +350,13 @@ class CUnits // extends CommonObject
dol_syslog(get_class($this)."::update", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
if (!$resql) {
$error++; $this->errors[] = "Error ".$this->db->lasterror();
}
// Commit or rollback
if ($error)
{
foreach ($this->errors as $errmsg)
{
if ($error) {
foreach ($this->errors as $errmsg) {
dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
}
@ -338,13 +369,13 @@ class CUnits // extends CommonObject
}
/**
* Delete object in database
*
* @param User $user User that delete
* @param int $notrigger 0=launch triggers after, 1=disable triggers
* @return int <0 if KO, >0 if OK
*/
/**
* Delete object in database
*
* @param User $user User that delete
* @param int $notrigger 0=launch triggers after, 1=disable triggers
* @return int <0 if KO, >0 if OK
*/
public function delete($user, $notrigger = 0)
{
global $conf, $langs;
@ -357,13 +388,13 @@ class CUnits // extends CommonObject
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
if (!$resql) {
$error++; $this->errors[] = "Error ".$this->db->lasterror();
}
// Commit or rollback
if ($error)
{
foreach ($this->errors as $errmsg)
{
if ($error) {
foreach ($this->errors as $errmsg) {
dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
}
@ -414,8 +445,7 @@ class CUnits // extends CommonObject
if ($fk_new_unit != 0) {
// Calcul en unité de base
$scaleUnitPow = $this->scaleOfUnitPow($fk_new_unit);
if (!empty($scaleUnitPow))
{
if (!empty($scaleUnitPow)) {
// convert to new unit
$value = $value / $scaleUnitPow;
}

View File

@ -126,8 +126,7 @@ class DiscountAbsolute
global $conf;
// Check parameters
if (!$rowid && !$fk_facture_source && !$fk_invoice_supplier_source)
{
if (!$rowid && !$fk_facture_source && !$fk_invoice_supplier_source) {
$this->error = 'ErrorBadParameters';
return -1;
}
@ -144,16 +143,20 @@ class DiscountAbsolute
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON sr.fk_facture_source = f.rowid";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as fsup ON sr.fk_invoice_supplier_source = fsup.rowid";
$sql .= " WHERE sr.entity IN (".getEntity('invoice').")";
if ($rowid) $sql .= " AND sr.rowid=".$rowid;
if ($fk_facture_source) $sql .= " AND sr.fk_facture_source=".$fk_facture_source;
if ($fk_invoice_supplier_source) $sql .= " AND sr.fk_invoice_supplier_source=".$fk_invoice_supplier_source;
if ($rowid) {
$sql .= " AND sr.rowid=".$rowid;
}
if ($fk_facture_source) {
$sql .= " AND sr.fk_facture_source=".$fk_facture_source;
}
if ($fk_invoice_supplier_source) {
$sql .= " AND sr.fk_invoice_supplier_source=".$fk_invoice_supplier_source;
}
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
if ($this->db->num_rows($resql))
{
if ($resql) {
if ($this->db->num_rows($resql)) {
$obj = $this->db->fetch_object($resql);
$this->id = $obj->rowid;
@ -219,22 +222,28 @@ class DiscountAbsolute
$this->multicurrency_amount_tva = price2num($this->multicurrency_amount_tva);
$this->multicurrency_amount_ttc = price2num($this->multicurrency_amount_ttc);
if (empty($this->multicurrency_amount_ht)) $this->multicurrency_amount_ht = 0;
if (empty($this->multicurrency_amount_tva)) $this->multicurrency_amount_tva = 0;
if (empty($this->multicurrency_amount_ttc)) $this->multicurrency_amount_ttc = 0;
if (empty($this->tva_tx)) $this->tva_tx = 0;
if (empty($this->multicurrency_amount_ht)) {
$this->multicurrency_amount_ht = 0;
}
if (empty($this->multicurrency_amount_tva)) {
$this->multicurrency_amount_tva = 0;
}
if (empty($this->multicurrency_amount_ttc)) {
$this->multicurrency_amount_ttc = 0;
}
if (empty($this->tva_tx)) {
$this->tva_tx = 0;
}
// Check parameters
if (empty($this->description))
{
if (empty($this->description)) {
$this->error = 'BadValueForPropertyDescription';
dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR);
return -1;
}
$userid = $user->id;
if (!($userid > 0)) // For example when record is saved into an anonymous context with a not loaded object $user.
{
if (!($userid > 0)) { // For example when record is saved into an anonymous context with a not loaded object $user.
include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
$tmpinvoice = new Facture($this->db);
$tmpinvoice->fetch($this->fk_facture_source);
@ -257,8 +266,7 @@ class DiscountAbsolute
dol_syslog(get_class($this)."::create", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
if ($resql) {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."societe_remise_except");
return $this->id;
} else {
@ -279,8 +287,7 @@ class DiscountAbsolute
global $conf, $langs;
// Check if we can remove the discount
if ($this->fk_facture_source)
{
if ($this->fk_facture_source) {
$sql = "SELECT COUNT(rowid) as nb";
$sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except";
$sql .= " WHERE (fk_facture_line IS NOT NULL"; // Not used as absolute simple discount
@ -290,11 +297,9 @@ class DiscountAbsolute
dol_syslog(get_class($this)."::delete Check if we can remove discount", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
if ($resql) {
$obj = $this->db->fetch_object($resql);
if ($obj->nb > 0)
{
if ($obj->nb > 0) {
$this->error = 'ErrorThisPartOrAnotherIsAlreadyUsedSoDiscountSerieCantBeRemoved';
return -2;
}
@ -305,8 +310,7 @@ class DiscountAbsolute
}
// Check if we can remove the discount
if ($this->fk_invoice_supplier_source)
{
if ($this->fk_invoice_supplier_source) {
$sql = "SELECT COUNT(rowid) as nb";
$sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except";
$sql .= " WHERE (fk_invoice_supplier_line IS NOT NULL"; // Not used as absolute simple discount
@ -316,11 +320,9 @@ class DiscountAbsolute
dol_syslog(get_class($this)."::delete Check if we can remove discount", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
if ($resql) {
$obj = $this->db->fetch_object($resql);
if ($obj->nb > 0)
{
if ($obj->nb > 0) {
$this->error = 'ErrorThisPartOrAnotherIsAlreadyUsedSoDiscountSerieCantBeRemoved';
return -2;
}
@ -334,9 +336,13 @@ class DiscountAbsolute
// Delete but only if not used
$sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_remise_except ";
if ($this->fk_facture_source) $sql .= " WHERE fk_facture_source = ".$this->fk_facture_source; // Delete all lines of same serie
elseif ($this->fk_invoice_supplier_source) $sql .= " WHERE fk_invoice_supplier_source = ".$this->fk_invoice_supplier_source; // Delete all lines of same serie
else $sql .= " WHERE rowid = ".$this->id; // Delete only line
if ($this->fk_facture_source) {
$sql .= " WHERE fk_facture_source = ".$this->fk_facture_source; // Delete all lines of same serie
} elseif ($this->fk_invoice_supplier_source) {
$sql .= " WHERE fk_invoice_supplier_source = ".$this->fk_invoice_supplier_source; // Delete all lines of same serie
} else {
$sql .= " WHERE rowid = ".$this->id; // Delete only line
}
$sql .= " AND (fk_facture_line IS NULL"; // Not used as absolute simple discount
$sql .= " AND fk_facture IS NULL)"; // Not used as credit note and not used as deposit
$sql .= " AND (fk_invoice_supplier_line IS NULL"; // Not used as absolute simple discount
@ -344,19 +350,16 @@ class DiscountAbsolute
dol_syslog(get_class($this)."::delete Delete discount", LOG_DEBUG);
$result = $this->db->query($sql);
if ($result)
{
if ($result) {
// If source of discount was a credit note or deposit, we change source statut.
if ($this->fk_facture_source)
{
if ($this->fk_facture_source) {
$sql = "UPDATE ".MAIN_DB_PREFIX."facture";
$sql .= " set paye=0, fk_statut=1";
$sql .= " WHERE (type = 2 or type = 3) AND rowid=".$this->fk_facture_source;
dol_syslog(get_class($this)."::delete Update credit note or deposit invoice statut", LOG_DEBUG);
$result = $this->db->query($sql);
if ($result)
{
if ($result) {
$this->db->commit();
return 1;
} else {
@ -371,8 +374,7 @@ class DiscountAbsolute
dol_syslog(get_class($this)."::delete Update credit note or deposit invoice statut", LOG_DEBUG);
$result = $this->db->query($sql);
if ($result)
{
if ($result) {
$this->db->commit();
return 1;
} else {
@ -407,31 +409,36 @@ class DiscountAbsolute
{
// phpcs:enable
// Check parameters
if (!$rowidline && !$rowidinvoice)
{
if (!$rowidline && !$rowidinvoice) {
$this->error = 'ErrorBadParameters';
return -1;
}
if ($rowidline && $rowidinvoice)
{
if ($rowidline && $rowidinvoice) {
$this->error = 'ErrorBadParameters';
return -2;
}
$sql = "UPDATE ".MAIN_DB_PREFIX."societe_remise_except";
if (!empty($this->discount_type)) {
if ($rowidline) $sql .= " SET fk_invoice_supplier_line = ".$rowidline;
if ($rowidinvoice) $sql .= " SET fk_invoice_supplier = ".$rowidinvoice;
if ($rowidline) {
$sql .= " SET fk_invoice_supplier_line = ".$rowidline;
}
if ($rowidinvoice) {
$sql .= " SET fk_invoice_supplier = ".$rowidinvoice;
}
} else {
if ($rowidline) $sql .= " SET fk_facture_line = ".$rowidline;
if ($rowidinvoice) $sql .= " SET fk_facture = ".$rowidinvoice;
if ($rowidline) {
$sql .= " SET fk_facture_line = ".$rowidline;
}
if ($rowidinvoice) {
$sql .= " SET fk_facture = ".$rowidinvoice;
}
}
$sql .= " WHERE rowid = ".$this->id;
dol_syslog(get_class($this)."::link_to_invoice", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
if ($resql) {
if (!empty($this->discount_type)) {
$this->fk_invoice_supplier_line = $rowidline;
$this->fk_invoice_supplier = $rowidinvoice;
@ -467,8 +474,7 @@ class DiscountAbsolute
dol_syslog(get_class($this)."::unlink_invoice", LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
if ($resql) {
return 1;
} else {
$this->error = $this->db->error();
@ -503,22 +509,28 @@ class DiscountAbsolute
} else {
$sql .= " AND (rc.fk_facture IS NULL AND rc.fk_facture_line IS NULL)"; // Available to customer
}
if (is_object($company)) $sql .= " AND rc.fk_soc = ".$company->id;
if (is_object($user)) $sql .= " AND rc.fk_user = ".$user->id;
if ($filter) $sql .= ' AND ('.$filter.')';
if ($maxvalue) $sql .= ' AND rc.amount_ttc <= '.price2num($maxvalue);
if (is_object($company)) {
$sql .= " AND rc.fk_soc = ".$company->id;
}
if (is_object($user)) {
$sql .= " AND rc.fk_user = ".$user->id;
}
if ($filter) {
$sql .= ' AND ('.$filter.')';
}
if ($maxvalue) {
$sql .= ' AND rc.amount_ttc <= '.price2num($maxvalue);
}
$resql = $this->db->query($sql);
if ($resql)
{
if ($resql) {
$obj = $this->db->fetch_object($resql);
//while ($obj)
//{
//print 'zz'.$obj->amount;
//$obj = $this->db->fetch_object($resql);
//}
if ($multicurrency)
{
if ($multicurrency) {
return $obj->amount_multicurrency;
}
@ -540,14 +552,12 @@ class DiscountAbsolute
{
dol_syslog(get_class($this)."::getSumDepositsUsed", LOG_DEBUG);
if ($invoice->element == 'facture' || $invoice->element == 'invoice')
{
if ($invoice->element == 'facture' || $invoice->element == 'invoice') {
$sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount';
$sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture as f';
$sql .= ' WHERE rc.fk_facture_source=f.rowid AND rc.fk_facture = '.$invoice->id;
$sql .= ' AND f.type = 3';
} elseif ($invoice->element == 'invoice_supplier')
{
} elseif ($invoice->element == 'invoice_supplier') {
$sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount';
$sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture_fourn as f';
$sql .= ' WHERE rc.fk_invoice_supplier_source=f.rowid AND rc.fk_invoice_supplier = '.$invoice->id;
@ -559,11 +569,13 @@ class DiscountAbsolute
}
$resql = $this->db->query($sql);
if ($resql)
{
if ($resql) {
$obj = $this->db->fetch_object($resql);
if ($multicurrency == 1) return $obj->multicurrency_amount;
else return $obj->amount;
if ($multicurrency == 1) {
return $obj->multicurrency_amount;
} else {
return $obj->amount;
}
} else {
$this->error = $this->db->lasterror();
return -1;
@ -581,14 +593,12 @@ class DiscountAbsolute
{
dol_syslog(get_class($this)."::getSumCreditNotesUsed", LOG_DEBUG);
if ($invoice->element == 'facture' || $invoice->element == 'invoice')
{
if ($invoice->element == 'facture' || $invoice->element == 'invoice') {
$sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount';
$sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture as f';
$sql .= ' WHERE rc.fk_facture_source=f.rowid AND rc.fk_facture = '.$invoice->id;
$sql .= ' AND f.type IN ('.$invoice::TYPE_STANDARD.', '.$invoice::TYPE_CREDIT_NOTE.', '.$invoice::TYPE_SITUATION.')'; // Find discount coming from credit note or excess received
} elseif ($invoice->element == 'invoice_supplier')
{
} elseif ($invoice->element == 'invoice_supplier') {
$sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount';
$sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture_fourn as f';
$sql .= ' WHERE rc.fk_invoice_supplier_source=f.rowid AND rc.fk_invoice_supplier = '.$invoice->id;
@ -600,11 +610,13 @@ class DiscountAbsolute
}
$resql = $this->db->query($sql);
if ($resql)
{
if ($resql) {
$obj = $this->db->fetch_object($resql);
if ($multicurrency == 1) return $obj->multicurrency_amount;
else return $obj->amount;
if ($multicurrency == 1) {
return $obj->multicurrency_amount;
} else {
return $obj->amount;
}
} else {
$this->error = $this->db->lasterror();
return -1;
@ -621,13 +633,11 @@ class DiscountAbsolute
{
dol_syslog(get_class($this)."::getSumCreditNotesUsed", LOG_DEBUG);
if ($invoice->element == 'facture' || $invoice->element == 'invoice')
{
if ($invoice->element == 'facture' || $invoice->element == 'invoice') {
$sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount';
$sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc';
$sql .= ' WHERE rc.fk_facture IS NULL AND rc.fk_facture_source = '.$invoice->id;
} elseif ($invoice->element == 'invoice_supplier')
{
} elseif ($invoice->element == 'invoice_supplier') {
$sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount';
$sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc';
$sql .= ' WHERE rc.fk_invoice_supplier IS NULL AND rc.fk_invoice_supplier_source = '.$invoice->id;
@ -638,11 +648,13 @@ class DiscountAbsolute
}
$resql = $this->db->query($sql);
if ($resql)
{
if ($resql) {
$obj = $this->db->fetch_object($resql);
if ($multicurrency) return $obj->multicurrency_amount;
else return $obj->amount;
if ($multicurrency) {
return $obj->multicurrency_amount;
} else {
return $obj->amount;
}
} else {
$this->error = $this->db->lasterror();
return -1;
@ -685,8 +697,12 @@ class DiscountAbsolute
}
if ($withpicto) $result .= ($link.img_object($label, $picto, 'class="classfortooltip"').$linkend);
if ($withpicto && $withpicto != 2) $result .= ' ';
if ($withpicto) {
$result .= ($link.img_object($label, $picto, 'class="classfortooltip"').$linkend);
}
if ($withpicto && $withpicto != 2) {
$result .= ' ';
}
$result .= $link.$ref.$linkend;
return $result;
}

View File

@ -70,8 +70,12 @@ class DolEditor
dol_syslog(get_class($this)."::DolEditor htmlname=".$htmlname." width=".$width." height=".$height." toolbarname=".$toolbarname);
if (!$rows) $rows = round($height / 20);
if (!$cols) $cols = ($width ?round($width / 6) : 80);
if (!$rows) {
$rows = round($height / 20);
}
if (!$cols) {
$cols = ($width ?round($width / 6) : 80);
}
$shorttoolbarname = preg_replace('/_encoded$/', '', $toolbarname);
// Name of extended editor to use (FCKEDITOR_EDITORNAME can be 'ckeditor' or 'fckeditor')
@ -81,17 +85,19 @@ class DolEditor
$this->readonly = $readonly;
// Check if extended editor is ok. If not we force textarea
if ((empty($conf->fckeditor->enabled) && $okforextendededitor != 'ace') || empty($okforextendededitor)) $this->tool = 'textarea';
if ($okforextendededitor === 'ace') $this->tool = 'ace';
if ((empty($conf->fckeditor->enabled) && $okforextendededitor != 'ace') || empty($okforextendededitor)) {
$this->tool = 'textarea';
}
if ($okforextendededitor === 'ace') {
$this->tool = 'ace';
}
//if ($conf->dol_use_jmobile) $this->tool = 'textarea'; // ckeditor and ace seems ok with mobile
// Define some properties
if (in_array($this->tool, array('textarea', 'ckeditor', 'ace')))
{
if (in_array($this->tool, array('textarea', 'ckeditor', 'ace'))) {
if ($this->tool == 'ckeditor' && !dol_textishtml($content)) { // We force content to be into HTML if we are using an advanced editor if content is not HTML.
$this->content = dol_nl2br($content);
}
else {
} else {
$this->content = $content;
}
$this->htmlname = $htmlname;
@ -122,16 +128,14 @@ class DolEditor
global $conf, $langs;
$fullpage = false;
if (isset($conf->global->FCKEDITOR_ALLOW_ANY_CONTENT))
{
if (isset($conf->global->FCKEDITOR_ALLOW_ANY_CONTENT)) {
$disallowAnyContent = empty($conf->global->FCKEDITOR_ALLOW_ANY_CONTENT); // Only predefined list of html tags are allowed or all
}
$found = 0;
$out = '';
if (in_array($this->tool, array('textarea', 'ckeditor')))
{
if (in_array($this->tool, array('textarea', 'ckeditor'))) {
$found = 1;
//$out.= '<textarea id="'.$this->htmlname.'" name="'.$this->htmlname.'" '.($this->readonly?' disabled':'').' rows="'.$this->rows.'"'.(preg_match('/%/',$this->cols)?' style="margin-top: 5px; width: '.$this->cols.'"':' cols="'.$this->cols.'"').' class="flat">';
// TODO We do not put the 'disabled' tag because on a read form, it change style with grey.
@ -140,9 +144,10 @@ class DolEditor
$out .= htmlspecialchars($this->content);
$out .= '</textarea>';
if ($this->tool == 'ckeditor' && !empty($conf->use_javascript_ajax) && !empty($conf->fckeditor->enabled))
{
if (!defined('REQUIRE_CKEDITOR')) define('REQUIRE_CKEDITOR', '1');
if ($this->tool == 'ckeditor' && !empty($conf->use_javascript_ajax) && !empty($conf->fckeditor->enabled)) {
if (!defined('REQUIRE_CKEDITOR')) {
define('REQUIRE_CKEDITOR', '1');
}
if (!empty($conf->global->FCKEDITOR_SKIN)) {
$skin = $conf->global->FCKEDITOR_SKIN;
@ -191,8 +196,7 @@ class DolEditor
},
disableNativeSpellChecker: '.(empty($conf->global->CKEDITOR_NATIVE_SPELLCHECKER) ? 'true' : 'false');
if ($this->uselocalbrowser)
{
if ($this->uselocalbrowser) {
$out .= ','."\n";
// To use filemanager with old fckeditor (GPL)
$out .= ' filebrowserBrowseUrl : ckeditorFilebrowserBrowseUrl,';
@ -202,11 +206,11 @@ class DolEditor
$out .= "\n";
// To use filemanager with ckfinder (Non free) and ckfinder directory is inside htdocs/includes
/* $out.= ' filebrowserBrowseUrl : \''.DOL_URL_ROOT.'/includes/ckfinder/ckfinder.html\',
filebrowserImageBrowseUrl : \''.DOL_URL_ROOT.'/includes/ckfinder/ckfinder.html?Type=Images\',
filebrowserFlashBrowseUrl : \''.DOL_URL_ROOT.'/includes/ckfinder/ckfinder.html?Type=Flash\',
filebrowserUploadUrl : \''.DOL_URL_ROOT.'/includes/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files\',
filebrowserImageUploadUrl : \''.DOL_URL_ROOT.'/includes/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images\',
filebrowserFlashUploadUrl : \''.DOL_URL_ROOT.'/includes/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Flash\','."\n";
filebrowserImageBrowseUrl : \''.DOL_URL_ROOT.'/includes/ckfinder/ckfinder.html?Type=Images\',
filebrowserFlashBrowseUrl : \''.DOL_URL_ROOT.'/includes/ckfinder/ckfinder.html?Type=Flash\',
filebrowserUploadUrl : \''.DOL_URL_ROOT.'/includes/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files\',
filebrowserImageUploadUrl : \''.DOL_URL_ROOT.'/includes/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images\',
filebrowserFlashUploadUrl : \''.DOL_URL_ROOT.'/includes/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Flash\','."\n";
*/
$out .= ' filebrowserWindowWidth : \'900\',
filebrowserWindowHeight : \'500\',
@ -221,15 +225,13 @@ class DolEditor
// Output editor ACE
// Warning: ace.js and ext-statusbar.js must be loaded by the parent page.
if (preg_match('/^ace/', $this->tool))
{
if (preg_match('/^ace/', $this->tool)) {
$found = 1;
$format = $option;
$out .= "\n".'<!-- Output Ace editor -->'."\n";
if ($titlecontent)
{
if ($titlecontent) {
$out .= '<div class="aceeditorstatusbar" id="statusBar'.$this->htmlname.'">'.$titlecontent;
$out .= ' &nbsp; - &nbsp; <a id="morelines" href="#" class="right morelines'.$this->htmlname.' reposition">'.dol_escape_htmltag($langs->trans("ShowMoreLines")).'</a> &nbsp; &nbsp; ';
$out .= '</div>';
@ -304,12 +306,14 @@ class DolEditor
$out .= '</script>'."\n";
}
if (empty($found))
{
if (empty($found)) {
$out .= 'Error, unknown value for tool '.$this->tool.' in DolEditor Create function.';
}
if ($noprint) return $out;
else print $out;
if ($noprint) {
return $out;
} else {
print $out;
}
}
}

View File

@ -46,54 +46,48 @@ class DolGeoIP
global $conf;
$geoipversion = '2'; // 'php', or '2'
if (!empty($conf->global->GEOIP_VERSION)) $geoipversion = $conf->global->GEOIP_VERSION;
if (!empty($conf->global->GEOIP_VERSION)) {
$geoipversion = $conf->global->GEOIP_VERSION;
}
if ($type == 'country')
{
if ($type == 'country') {
// geoip may have been already included with PEAR
if ($geoipversion == '2' || ($geoipversion != 'php' && !function_exists('geoip_country_code_by_name')))
{
if ($geoipversion == '2' || ($geoipversion != 'php' && !function_exists('geoip_country_code_by_name'))) {
require_once DOL_DOCUMENT_ROOT.'/includes/geoip2/geoip2.phar';
}
} elseif ($type == 'city')
{
} elseif ($type == 'city') {
// geoip may have been already included with PEAR
if ($geoipversion == '2' || ($geoipversion != 'php' && !function_exists('geoip_country_code_by_name')))
{
if ($geoipversion == '2' || ($geoipversion != 'php' && !function_exists('geoip_country_code_by_name'))) {
require_once DOL_DOCUMENT_ROOT.'/includes/geoip2/geoip2.phar';
}
} else { print 'ErrorBadParameterInConstructor'; return 0; }
} else {
print 'ErrorBadParameterInConstructor'; return 0;
}
// Here, function exists (embedded into PHP or exists because we made include)
if (empty($type) || empty($datfile))
{
if (empty($type) || empty($datfile)) {
$this->errorlabel = 'Constructor was called with no datafile parameter';
dol_syslog('DolGeoIP '.$this->errorlabel, LOG_ERR);
return 0;
}
if (!file_exists($datfile) || !is_readable($datfile))
{
if (!file_exists($datfile) || !is_readable($datfile)) {
$this->error = 'ErrorGeoIPClassNotInitialized';
$this->errorlabel = "Datafile ".$datfile." not found";
dol_syslog('DolGeoIP '.$this->errorlabel, LOG_ERR);
return 0;
}
if ($geoipversion == '2')
{
if ($geoipversion == '2') {
try {
$this->gi = new GeoIp2\Database\Reader($datfile); // '/usr/local/share/GeoIP/GeoIP2-City.mmdb'
} catch (Exception $e)
{
} catch (Exception $e) {
$this->error = $e->getMessage();
dol_syslog('DolGeoIP '.$this->errorlabel, LOG_ERR);
return 0;
}
} elseif (function_exists('geoip_open'))
{
} elseif (function_exists('geoip_open')) {
$this->gi = geoip_open($datfile, GEOIP_STANDARD);
}
elseif (function_exists('geoip_country_code_by_name')) {
} elseif (function_exists('geoip_country_code_by_name')) {
$this->gi = 'NOGI'; // We are using embedded php geoip functions
//print 'function_exists(geoip_country_code_by_name))='.function_exists('geoip_country_code_by_name');
//print geoip_database_info();
@ -113,21 +107,19 @@ class DolGeoIP
global $conf;
$geoipversion = '2'; // 'php', or '2'
if (!empty($conf->global->GEOIP_VERSION)) $geoipversion = $conf->global->GEOIP_VERSION;
if (!empty($conf->global->GEOIP_VERSION)) {
$geoipversion = $conf->global->GEOIP_VERSION;
}
if (empty($this->gi))
{
if (empty($this->gi)) {
return '';
}
if ($this->gi == 'NOGI')
{
if ($this->gi == 'NOGI') {
// geoip_country_code_by_addr does not exists
return strtolower(geoip_country_code_by_name($ip));
} else {
if (preg_match('/^[0-9]+.[0-9]+\.[0-9]+\.[0-9]+/', $ip))
{
if ($geoipversion == '2')
{
if (preg_match('/^[0-9]+.[0-9]+\.[0-9]+\.[0-9]+/', $ip)) {
if ($geoipversion == '2') {
try {
$record = $this->gi->country($ip);
return strtolower($record->country->isoCode);
@ -136,12 +128,13 @@ class DolGeoIP
return '';
}
} else {
if (!function_exists('geoip_country_code_by_addr')) return strtolower(geoip_country_code_by_name($this->gi, $ip));
if (!function_exists('geoip_country_code_by_addr')) {
return strtolower(geoip_country_code_by_name($this->gi, $ip));
}
return strtolower(geoip_country_code_by_addr($this->gi, $ip));
}
} else {
if ($geoipversion == '2')
{
if ($geoipversion == '2') {
try {
$record = $this->gi->country($ip);
return strtolower($record->country->isoCode);
@ -150,7 +143,9 @@ class DolGeoIP
return '';
}
} else {
if (!function_exists('geoip_country_code_by_addr_v6')) return strtolower(geoip_country_code_by_name_v6($this->gi, $ip));
if (!function_exists('geoip_country_code_by_addr_v6')) {
return strtolower(geoip_country_code_by_name_v6($this->gi, $ip));
}
return strtolower(geoip_country_code_by_addr_v6($this->gi, $ip));
}
}
@ -168,15 +163,15 @@ class DolGeoIP
global $conf;
$geoipversion = '2'; // 'php', or '2'
if (!empty($conf->global->GEOIP_VERSION)) $geoipversion = $conf->global->GEOIP_VERSION;
if (!empty($conf->global->GEOIP_VERSION)) {
$geoipversion = $conf->global->GEOIP_VERSION;
}
if (empty($this->gi))
{
if (empty($this->gi)) {
return '';
}
if ($geoipversion == '2')
{
if ($geoipversion == '2') {
try {
$record = $this->gi->country($name);
return $record->country->isoCode;
@ -199,12 +194,16 @@ class DolGeoIP
global $conf;
$geoipversion = '2'; // 'php', or '2'
if (!empty($conf->global->GEOIP_VERSION)) $geoipversion = $conf->global->GEOIP_VERSION;
if (!empty($conf->global->GEOIP_VERSION)) {
$geoipversion = $conf->global->GEOIP_VERSION;
}
if ($geoipversion == 'php')
{
if ($this->gi == 'NOGI') return geoip_database_info();
else return 'geoip_database_info() function not available';
if ($geoipversion == 'php') {
if ($this->gi == 'NOGI') {
return geoip_database_info();
} else {
return 'geoip_database_info() function not available';
}
}
return 'Not available (not using PHP internal geo functions - We are using embedded Geoip v'.$geoipversion.')';

View File

@ -114,9 +114,15 @@ class DolGraph
$color_file = DOL_DOCUMENT_ROOT . '/theme/' . $conf->theme . '/theme_vars.inc.php';
if (is_readable($color_file)) {
include_once $color_file;
if (isset($theme_bordercolor)) $this->bordercolor = $theme_bordercolor;
if (isset($theme_datacolor)) $this->datacolor = $theme_datacolor;
if (isset($theme_bgcolor)) $this->bgcolor = $theme_bgcolor;
if (isset($theme_bordercolor)) {
$this->bordercolor = $theme_bordercolor;
}
if (isset($theme_datacolor)) {
$this->datacolor = $theme_datacolor;
}
if (isset($theme_bgcolor)) {
$this->bgcolor = $theme_bgcolor;
}
}
//print 'bgcolor: '.join(',',$this->bgcolor).'<br>';
@ -597,7 +603,9 @@ class DolGraph
public function GetMaxValueInData()
{
// phpcs:enable
if (!is_array($this->data)) return 0;
if (!is_array($this->data)) {
return 0;
}
$k = 0;
$vals = array();
@ -624,7 +632,9 @@ class DolGraph
public function GetMinValueInData()
{
// phpcs:enable
if (!is_array($this->data)) return 0;
if (!is_array($this->data)) {
return 0;
}
$k = 0;
$vals = array();
@ -652,7 +662,9 @@ class DolGraph
{
// phpcs:enable
$max = $this->GetMaxValueInData();
if ($max != 0) $max++;
if ($max != 0) {
$max++;
}
$size = dol_strlen(abs(ceil($max)));
$factor = 1;
for ($i = 0; $i < ($size - 1); $i++) {
@ -660,7 +672,9 @@ class DolGraph
}
$res = 0;
if (is_numeric($max)) $res = ceil($max / $factor) * $factor;
if (is_numeric($max)) {
$res = ceil($max / $factor) * $factor;
}
//print "max=".$max." res=".$res;
return $res;
@ -676,8 +690,12 @@ class DolGraph
{
// phpcs:enable
$min = $this->GetMinValueInData();
if ($min == '') $min = 0;
if ($min != 0) $min--;
if ($min == '') {
$min = 0;
}
if ($min != 0) {
$min--;
}
$size = dol_strlen(abs(floor($min)));
$factor = 1;
for ($i = 0; $i < ($size - 1); $i++) {
@ -751,22 +769,22 @@ class DolGraph
if (is_array($this->data) && is_array($this->data[0])) {
$nblot = count($this->data[0]) - 1; // -1 to remove legend
}
if ($nblot < 0) dol_syslog('Bad value for property ->data. Must be set by mydolgraph->SetData before calling mydolgrapgh->draw', LOG_WARNING);
if ($nblot < 0) {
dol_syslog('Bad value for property ->data. Must be set by mydolgraph->SetData before calling mydolgrapgh->draw', LOG_WARNING);
}
$firstlot = 0;
// Works with line but not with bars
//if ($nblot > 2) $firstlot = ($nblot - 2); // We limit nblot to 2 because jflot can't manage more than 2 bars on same x
$i = $firstlot;
$serie = array();
while ($i < $nblot) // Loop on each serie
{
while ($i < $nblot) { // Loop on each serie
$values = array(); // Array with horizontal y values (specific values of a serie) for each abscisse x
$serie[$i] = "var d" . $i . " = [];\n";
// Fill array $values
$x = 0;
foreach ($this->data as $valarray) // Loop on each x
{
foreach ($this->data as $valarray) { // Loop on each x
$legends[$x] = $valarray[0];
$values[$x] = (is_numeric($valarray[$i + 1]) ? $valarray[$i + 1] : null);
$x++;
@ -774,11 +792,15 @@ class DolGraph
if (isset($this->type[$firstlot]) && in_array($this->type[$firstlot], array('pie', 'piesemicircle', 'polar'))) {
foreach ($values as $x => $y) {
if (isset($y)) $serie[$i] .= 'd' . $i . '.push({"label":"' . dol_escape_js($legends[$x]) . '", "data":' . $y . '});' . "\n";
if (isset($y)) {
$serie[$i] .= 'd' . $i . '.push({"label":"' . dol_escape_js($legends[$x]) . '", "data":' . $y . '});' . "\n";
}
}
} else {
foreach ($values as $x => $y) {
if (isset($y)) $serie[$i] .= 'd' . $i . '.push([' . $x . ', ' . $y . ']);' . "\n";
if (isset($y)) {
$serie[$i] .= 'd' . $i . '.push([' . $x . ', ' . $y . ']);' . "\n";
}
}
}
@ -788,7 +810,9 @@ class DolGraph
$tag = dol_escape_htmltag(dol_string_unaccent(dol_string_nospecial(basename($file), '_', array('-', '.'))));
$this->stringtoshow = '<!-- Build using jflot -->' . "\n";
if (!empty($this->title)) $this->stringtoshow .= '<div class="center dolgraphtitle' . (empty($this->cssprefix) ? '' : ' dolgraphtitle' . $this->cssprefix) . '">' . $this->title . '</div>';
if (!empty($this->title)) {
$this->stringtoshow .= '<div class="center dolgraphtitle' . (empty($this->cssprefix) ? '' : ' dolgraphtitle' . $this->cssprefix) . '">' . $this->title . '</div>';
}
if (!empty($this->shownographyet)) {
$this->stringtoshow .= '<div style="width:' . $this->width . 'px;height:' . $this->height . 'px;" class="nographyet"></div>';
$this->stringtoshow .= '<div class="nographyettext margintoponly">' . $langs->trans("NotEnoughDataYet") . '...</div>';
@ -797,7 +821,9 @@ class DolGraph
// Start the div that will contains all the graph
$dolxaxisvertical = '';
if (count($this->data) > 20) $dolxaxisvertical = 'dol-xaxis-vertical';
if (count($this->data) > 20) {
$dolxaxisvertical = 'dol-xaxis-vertical';
}
$this->stringtoshow .= '<div id="placeholder_' . $tag . '" style="width:' . $this->width . 'px;height:' . $this->height . 'px;" class="dolgraph' . (empty($dolxaxisvertical) ? '' : ' ' . $dolxaxisvertical) . (empty($this->cssprefix) ? '' : ' dolgraph' . $this->cssprefix) . ' center"></div>' . "\n";
$this->stringtoshow .= '<script id="' . $tag . '">' . "\n";
@ -818,8 +844,11 @@ class DolGraph
if (isset($this->type[$firstlot]) && in_array($this->type[$firstlot], array('pie', 'piesemicircle', 'polar'))) {
$datacolor = array();
foreach ($this->datacolor as $val) {
if (is_array($val)) $datacolor[] = "#" . sprintf("%02x%02x%02x", $val[0], $val[1], $val[2]); // If datacolor is array(R, G, B)
else $datacolor[] = "#" . str_replace(array('#', '-'), '', $val); // If $val is '124' or '#124'
if (is_array($val)) {
$datacolor[] = "#" . sprintf("%02x%02x%02x", $val[0], $val[1], $val[2]); // If datacolor is array(R, G, B)
} else {
$datacolor[] = "#" . str_replace(array('#', '-'), '', $val); // If $val is '124' or '#124'
}
}
$urltemp = ''; // TODO Add support for url link into labels
@ -847,13 +876,17 @@ class DolGraph
var number=series.data[0][1];
return \'';
$this->stringtoshow .= '<span style="font-size:8pt;text-align:center;padding:2px;color:black;">';
if ($urltemp) $this->stringtoshow .= '<a style="color: #FFFFFF;" border="0" href="' . $urltemp . '">';
if ($urltemp) {
$this->stringtoshow .= '<a style="color: #FFFFFF;" border="0" href="' . $urltemp . '">';
}
$this->stringtoshow .= '\'+';
$this->stringtoshow .= ($showlegend ? '' : 'label+\' \'+'); // Hide label if already shown in legend
$this->stringtoshow .= ($showpointvalue ? 'number+' : '');
$this->stringtoshow .= ($showpercent ? '\'<br/>\'+percent+\'%\'+' : '');
$this->stringtoshow .= '\'';
if ($urltemp) $this->stringtoshow .= '</a>';
if ($urltemp) {
$this->stringtoshow .= '</a>';
}
$this->stringtoshow .= '</span>\';
},
background: {
@ -912,9 +945,11 @@ class DolGraph
var y = item.datapoint[1].toFixed(2);
var z = item.series.xaxis.ticks[item.dataIndex].label;
';
if ($this->showpointvalue > 0) $this->stringtoshow .= '
if ($this->showpointvalue > 0) {
$this->stringtoshow .= '
showTooltip_' . $tag . '(item.pageX, item.pageY, item.series.label + "<br>" + z + " => " + y);
';
}
$this->stringtoshow .= '
}
}
@ -931,18 +966,28 @@ class DolGraph
$this->stringtoshow .= '$.plot($("#placeholder_' . $tag . '"), [ ' . "\n";
$i = $firstlot;
while ($i < $nblot) {
if ($i > $firstlot) $this->stringtoshow .= ', ' . "\n";
if ($i > $firstlot) {
$this->stringtoshow .= ', ' . "\n";
}
$color = sprintf("%02x%02x%02x", $this->datacolor[$i][0], $this->datacolor[$i][1], $this->datacolor[$i][2]);
$this->stringtoshow .= '{ ';
if (!isset($this->type[$i]) || $this->type[$i] == 'bars') {
if ($nblot == 3) {
if ($i == $firstlot) $align = 'right';
elseif ($i == $firstlot + 1) $align = 'center';
else $align = 'left';
if ($i == $firstlot) {
$align = 'right';
} elseif ($i == $firstlot + 1) {
$align = 'center';
} else {
$align = 'left';
}
$this->stringtoshow .= 'bars: { lineWidth: 1, show: true, align: "' . $align . '", barWidth: 0.45 }, ';
} else $this->stringtoshow .= 'bars: { lineWidth: 1, show: true, align: "' . ($i == $firstlot ? 'center' : 'left') . '", barWidth: 0.5 }, ';
} else {
$this->stringtoshow .= 'bars: { lineWidth: 1, show: true, align: "' . ($i == $firstlot ? 'center' : 'left') . '", barWidth: 0.5 }, ';
}
}
if (isset($this->type[$i]) && ($this->type[$i] == 'lines' || $this->type[$i] == 'linesnopoint')) {
$this->stringtoshow .= 'lines: { show: true, fill: false }, points: { show: ' . ($this->type[$i] == 'linesnopoint' ? 'false' : 'true') . ' }, ';
}
if (isset($this->type[$i]) && ($this->type[$i] == 'lines' || $this->type[$i] == 'linesnopoint')) $this->stringtoshow .= 'lines: { show: true, fill: false }, points: { show: ' . ($this->type[$i] == 'linesnopoint' ? 'false' : 'true') . ' }, ';
$this->stringtoshow .= 'color: "#' . $color . '", label: "' . (isset($this->Legend[$i]) ? dol_escape_js($this->Legend[$i]) : '') . '", data: d' . $i . ' }';
$i++;
}
@ -953,7 +998,9 @@ class DolGraph
$this->stringtoshow .= ', xaxis: { ticks: [' . "\n";
$x = 0;
foreach ($this->data as $key => $valarray) {
if ($x > 0) $this->stringtoshow .= ', ' . "\n";
if ($x > 0) {
$this->stringtoshow .= ', ' . "\n";
}
$this->stringtoshow .= ' [' . $x . ', "' . $valarray[0] . '"]';
$x++;
}
@ -1010,13 +1057,14 @@ class DolGraph
$legends = array();
$nblot = 0;
if (is_array($this->data)) {
foreach ($this->data as $valarray) // Loop on each x
{
foreach ($this->data as $valarray) { // Loop on each x
$nblot = max($nblot, count($valarray) - 1); // -1 to remove legend
}
}
//var_dump($nblot);
if ($nblot < 0) dol_syslog('Bad value for property ->data. Must be set by mydolgraph->SetData before calling mydolgrapgh->draw', LOG_WARNING);
if ($nblot < 0) {
dol_syslog('Bad value for property ->data. Must be set by mydolgraph->SetData before calling mydolgrapgh->draw', LOG_WARNING);
}
$firstlot = 0;
// Works with line but not with bars
//if ($nblot > 2) $firstlot = ($nblot - 2); // We limit nblot to 2 because jflot can't manage more than 2 bars on same x
@ -1026,15 +1074,13 @@ class DolGraph
//var_dump($this->data);
$i = $firstlot;
while ($i < $nblot) // Loop on each serie
{
while ($i < $nblot) { // Loop on each serie
$values = array(); // Array with horizontal y values (specific values of a serie) for each abscisse x (with x=0,1,2,...)
$serie[$i] = "";
// Fill array $values
$x = 0;
foreach ($this->data as $valarray) // Loop on each x
{
foreach ($this->data as $valarray) { // Loop on each x
$legends[$x] = (array_key_exists('label', $valarray) ? $valarray['label'] : $valarray[0]);
$array_of_ykeys = array_keys($valarray);
$alabelexists = 1;
@ -1074,7 +1120,9 @@ class DolGraph
$tag = dol_escape_htmltag(dol_string_unaccent(dol_string_nospecial(basename($file), '_', array('-', '.'))));
$this->stringtoshow = '<!-- Build using chart -->' . "\n";
if (!empty($this->title)) $this->stringtoshow .= '<div class="center dolgraphtitle' . (empty($this->cssprefix) ? '' : ' dolgraphtitle' . $this->cssprefix) . '">' . $this->title . '</div>';
if (!empty($this->title)) {
$this->stringtoshow .= '<div class="center dolgraphtitle' . (empty($this->cssprefix) ? '' : ' dolgraphtitle' . $this->cssprefix) . '">' . $this->title . '</div>';
}
if (!empty($this->shownographyet)) {
$this->stringtoshow .= '<div style="width:' . $this->width . (strpos($this->width, '%') > 0 ? '' : 'px') . '; height:' . $this->height . 'px;" class="nographyet"></div>';
$this->stringtoshow .= '<div class="nographyettext margintoponly">' . $langs->trans("NotEnoughDataYet") . '...</div>';
@ -1083,10 +1131,14 @@ class DolGraph
// Start the div that will contains all the graph
$dolxaxisvertical = '';
if (count($this->data) > 20) $dolxaxisvertical = 'dol-xaxis-vertical';
if (count($this->data) > 20) {
$dolxaxisvertical = 'dol-xaxis-vertical';
}
// No height for the pie grah
$cssfordiv = 'dolgraphchart';
if (isset($this->type[$firstlot])) $cssfordiv .= ' dolgraphchar' . $this->type[$firstlot];
if (isset($this->type[$firstlot])) {
$cssfordiv .= ' dolgraphchar' . $this->type[$firstlot];
}
$this->stringtoshow .= '<div id="placeholder_' . $tag . '" style="min-height: ' . $this->height . (strpos($this->height, '%') > 0 ? '' : 'px') . '; width:' . $this->width . (strpos($this->width, '%') > 0 ? '' : 'px') . ';" class="' . $cssfordiv . ' dolgraph' . (empty($dolxaxisvertical) ? '' : ' ' . $dolxaxisvertical) . (empty($this->cssprefix) ? '' : ' dolgraph' . $this->cssprefix) . ' center"><canvas id="canvas_' . $tag . '"></canvas></div>' . "\n";
$this->stringtoshow .= '<script id="' . $tag . '">' . "\n";
@ -1126,16 +1178,20 @@ class DolGraph
$this->stringtoshow .= 'backgroundColor: [';
$i = 0;
$foundnegativecolor = 0;
foreach ($legends as $val) // Loop on each serie
{
if ($i > 0) $this->stringtoshow .= ', ' . "\n";
if (is_array($this->datacolor[$i])) $color = 'rgb(' . $this->datacolor[$i][0] . ', ' . $this->datacolor[$i][1] . ', ' . $this->datacolor[$i][2] . ')'; // If datacolor is array(R, G, B)
else {
foreach ($legends as $val) { // Loop on each serie
if ($i > 0) {
$this->stringtoshow .= ', ' . "\n";
}
if (is_array($this->datacolor[$i])) {
$color = 'rgb(' . $this->datacolor[$i][0] . ', ' . $this->datacolor[$i][1] . ', ' . $this->datacolor[$i][2] . ')'; // If datacolor is array(R, G, B)
} else {
$tmp = str_replace('#', '', $this->datacolor[$i]);
if (strpos($tmp, '-') !== false) {
$foundnegativecolor++;
$color = '#FFFFFF'; // If $val is '-123'
} else $color = "#" . $tmp; // If $val is '123' or '#123'
} else {
$color = "#" . $tmp; // If $val is '123' or '#123'
}
}
$this->stringtoshow .= "'" . $color . "'";
$i++;
@ -1145,14 +1201,19 @@ class DolGraph
if ($foundnegativecolor) {
$this->stringtoshow .= 'borderColor: [';
$i = 0;
foreach ($legends as $val) // Loop on each serie
{
if ($i > 0) $this->stringtoshow .= ', ' . "\n";
if (is_array($this->datacolor[$i])) $color = 'null'; // If datacolor is array(R, G, B)
else {
foreach ($legends as $val) { // Loop on each serie
if ($i > 0) {
$this->stringtoshow .= ', ' . "\n";
}
if (is_array($this->datacolor[$i])) {
$color = 'null'; // If datacolor is array(R, G, B)
} else {
$tmp = str_replace('#', '', $this->datacolor[$i]);
if (strpos($tmp, '-') !== false) $color = '#' . str_replace('-', '', $tmp); // If $val is '-123'
else $color = 'null'; // If $val is '123' or '#123'
if (strpos($tmp, '-') !== false) {
$color = '#' . str_replace('-', '', $tmp); // If $val is '-123'
} else {
$color = 'null'; // If $val is '123' or '#123'
}
}
$this->stringtoshow .= ($color == 'null' ? "'rgba(0,0,0,0.2)'" : "'" . $color . "'");
$i++;
@ -1172,9 +1233,10 @@ class DolGraph
labels: [';
$i = 0;
foreach ($legends as $val) // Loop on each serie
{
if ($i > 0) $this->stringtoshow .= ', ';
foreach ($legends as $val) { // Loop on each serie
if ($i > 0) {
$this->stringtoshow .= ', ';
}
$this->stringtoshow .= "'" . dol_escape_js(dol_trunc($val, 32)) . "'";
$i++;
}
@ -1183,12 +1245,13 @@ class DolGraph
datasets: [';
$i = 0;
$i = 0;
while ($i < $nblot) // Loop on each serie
{
while ($i < $nblot) { // Loop on each serie
$color = 'rgb(' . $this->datacolor[$i][0] . ', ' . $this->datacolor[$i][1] . ', ' . $this->datacolor[$i][2] . ')';
//$color = (!empty($data['seriescolor']) ? json_encode($data['seriescolor']) : json_encode($datacolor));
if ($i > 0) $this->stringtoshow .= ', ' . "\n";
if ($i > 0) {
$this->stringtoshow .= ', ' . "\n";
}
$this->stringtoshow .= '{' . "\n";
//$this->stringtoshow .= 'borderColor: \''.$color.'\', ';
//$this->stringtoshow .= 'backgroundColor: \''.$color.'\', ';
@ -1204,9 +1267,15 @@ class DolGraph
else {
$type = 'bar';
if (!isset($this->type[$firstlot]) || $this->type[$firstlot] == 'bars') $type = 'bar';
if (isset($this->type[$firstlot]) && $this->type[$firstlot] == 'horizontalbars') $type = 'horizontalBar';
if (isset($this->type[$firstlot]) && ($this->type[$firstlot] == 'lines' || $this->type[$firstlot] == 'linesnopoint')) $type = 'line';
if (!isset($this->type[$firstlot]) || $this->type[$firstlot] == 'bars') {
$type = 'bar';
}
if (isset($this->type[$firstlot]) && $this->type[$firstlot] == 'horizontalbars') {
$type = 'horizontalBar';
}
if (isset($this->type[$firstlot]) && ($this->type[$firstlot] == 'lines' || $this->type[$firstlot] == 'linesnopoint')) {
$type = 'line';
}
$this->stringtoshow .= 'var options = { maintainAspectRatio: false, aspectRatio: 2.5, ';
if (empty($showlegend)) {
@ -1259,9 +1328,10 @@ class DolGraph
labels: [';
$i = 0;
foreach ($legends as $val) // Loop on each serie
{
if ($i > 0) $this->stringtoshow .= ', ';
foreach ($legends as $val) { // Loop on each serie
if ($i > 0) {
$this->stringtoshow .= ', ';
}
$this->stringtoshow .= "'" . dol_escape_js(dol_trunc($val, 32)) . "'";
$i++;
}
@ -1276,8 +1346,7 @@ class DolGraph
$i = 0;
$iinstack = 0;
$oldstacknum = -1;
while ($i < $nblot) // Loop on each serie
{
while ($i < $nblot) { // Loop on each serie
$foundnegativecolor = 0;
$usecolorvariantforgroupby = 0;
// We used a 'group by' and we have too many colors so we generated color variants per
@ -1335,7 +1404,9 @@ class DolGraph
}
}
}
if ($i > 0) $this->stringtoshow .= ', ';
if ($i > 0) {
$this->stringtoshow .= ', ';
}
$this->stringtoshow .= "\n";
$this->stringtoshow .= '{';
$this->stringtoshow .= 'dolibarrinfo: \'y_' . $i . '\', ';
@ -1347,7 +1418,9 @@ class DolGraph
}
$this->stringtoshow .= 'borderColor: \'' . $bordercolor . '\', ';
$this->stringtoshow .= 'backgroundColor: \'' . $color . '\', ';
if (!empty($arrayofgroupslegend) && !empty($arrayofgroupslegend[$i])) $this->stringtoshow .= 'stack: \'' . $arrayofgroupslegend[$i]['stacknum'] . '\', ';
if (!empty($arrayofgroupslegend) && !empty($arrayofgroupslegend[$i])) {
$this->stringtoshow .= 'stack: \'' . $arrayofgroupslegend[$i]['stacknum'] . '\', ';
}
$this->stringtoshow .= 'data: [';
$this->stringtoshow .= $this->mirrorGraphValues ? '[' . -$serie[$i] . ',' . $serie[$i] . ']' : $serie[$i];
@ -1374,8 +1447,7 @@ class DolGraph
public function total()
{
$value = 0;
foreach ($this->data as $valarray) // Loop on each x
{
foreach ($this->data as $valarray) { // Loop on each x
$value += $valarray[1];
}
return $value;
@ -1419,8 +1491,11 @@ class DolGraph
global $conf;
if ($direction == 'width') {
if (empty($conf->dol_optimize_smallscreen)) return ($defaultsize ? $defaultsize : '500');
else return (empty($_SESSION['dol_screen_width']) ? '280' : ($_SESSION['dol_screen_width'] - 40));
if (empty($conf->dol_optimize_smallscreen)) {
return ($defaultsize ? $defaultsize : '500');
} else {
return (empty($_SESSION['dol_screen_width']) ? '280' : ($_SESSION['dol_screen_width'] - 40));
}
}
if ($direction == 'height') {
return (empty($conf->dol_optimize_smallscreen) ? ($defaultsize ? $defaultsize : '200') : '160');

View File

@ -109,7 +109,6 @@ use Mike42\Escpos\CapabilityProfile;
use Mike42\Escpos\Printer;
use Mike42\Escpos\EscposImage;
/**
* Class to manage Receipt Printers
*/
@ -127,8 +126,8 @@ class dolReceiptPrinter extends Printer
public $db;
/*
* @var string[] array of tags
*/
* @var string[] array of tags
*/
public $tags;
public $printer;
public $template;
@ -540,8 +539,7 @@ class dolReceiptPrinter extends Printer
$this->printer->cut();
// If is DummyPrintConnector send to log to debugging
if ($this->printer->connector instanceof DummyPrintConnector)
{
if ($this->printer->connector instanceof DummyPrintConnector) {
$data = $this->printer->connector-> getData();
dol_syslog($data);
}
@ -631,14 +629,12 @@ class dolReceiptPrinter extends Printer
break;
case 'DOL_PRINT_OBJECT_LINES':
foreach ($object->lines as $line) {
if ($line->fk_product)
{
if ($line->fk_product) {
$spacestoadd = $nbcharactbyline - strlen($line->ref) - strlen($line->qty) - 10 - 1;
$spaces = str_repeat(' ', $spacestoadd > 0 ? $spacestoadd : 0);
$this->printer->text($line->ref.$spaces.$line->qty.' '.str_pad(price($line->total_ttc), 10, ' ', STR_PAD_LEFT)."\n");
$this->printer->text(strip_tags(htmlspecialchars_decode($line->product_label))."\n");
}
else {
} else {
$spacestoadd = $nbcharactbyline - strlen($line->description) - strlen($line->qty) - 10 - 1;
$spaces = str_repeat(' ', $spacestoadd > 0 ? $spacestoadd : 0);
$this->printer->text($line->description.$spaces.$line->qty.' '.str_pad(price($line->total_ttc), 10, ' ', STR_PAD_LEFT)."\n");
@ -775,8 +771,7 @@ class dolReceiptPrinter extends Printer
break;
case 'DOL_PRINT_ORDER_LINES':
foreach ($object->lines as $line) {
if ($line->special_code == $this->orderprinter)
{
if ($line->special_code == $this->orderprinter) {
$spacestoadd = $nbcharactbyline - strlen($line->ref) - strlen($line->qty) - 10 - 1;
$spaces = str_repeat(' ', $spacestoadd > 0 ? $spacestoadd : 0);
$this->printer->text($line->ref.$spaces.$line->qty.' '.str_pad(price($line->total_ttc), 10, ' ', STR_PAD_LEFT)."\n");
@ -792,8 +787,7 @@ class dolReceiptPrinter extends Printer
$sql .= " WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = ".$object->id;
$sql .= " ORDER BY p.datep";
$resql = $this->db->query($sql);
if ($resql)
{
if ($resql) {
$num = $this->db->num_rows($resql);
$i = 0;
while ($i < $num) {
@ -801,10 +795,11 @@ class dolReceiptPrinter extends Printer
$spacestoadd = $nbcharactbyline - strlen($langs->transnoentitiesnoconv("PaymentTypeShort".$row->code)) - 12;
$spaces = str_repeat(' ', $spacestoadd > 0 ? $spacestoadd : 0);
$amount_payment = (!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount;
if ($row->code == "LIQ") $amount_payment = $amount_payment + $row->pos_change; // Show amount with excess received if is cash payment
if ($row->code == "LIQ") {
$amount_payment = $amount_payment + $row->pos_change; // Show amount with excess received if is cash payment
}
$this->printer->text($spaces.$langs->transnoentitiesnoconv("PaymentTypeShort".$row->code).' '.str_pad(price($amount_payment), 10, ' ', STR_PAD_LEFT)."\n");
if ($row->code == "LIQ" && $row->pos_change > 0) // Print change only in cash payments
{
if ($row->code == "LIQ" && $row->pos_change > 0) { // Print change only in cash payments
$spacestoadd = $nbcharactbyline - strlen($langs->trans("Change")) - 12;
$spaces = str_repeat(' ', $spacestoadd > 0 ? $spacestoadd : 0);
$this->printer->text($spaces.$langs->trans("Change").' '.str_pad(price($row->pos_change), 10, ' ', STR_PAD_LEFT)."\n");
@ -822,10 +817,11 @@ class dolReceiptPrinter extends Printer
}
}
// If is DummyPrintConnector send to log to debugging
if ($this->printer->connector instanceof DummyPrintConnector || $conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector")
{
if ($this->printer->connector instanceof DummyPrintConnector || $conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") {
$data = $this->printer->connector->getData();
if ($conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") echo rtrim(strtr(base64_encode($data), '+/', '-_'), '=');
if ($conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") {
echo rtrim(strtr(base64_encode($data), '+/', '-_'), '=');
}
dol_syslog($data);
}
// Close and print

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