Merge branch '17.0' of git@github.com:Dolibarr/dolibarr.git into 18.0

Conflicts:
	htdocs/modulebuilder/template/class/myobject.class.php
	htdocs/modulebuilder/template/core/boxes/mymodulewidget1.php
	htdocs/modulebuilder/template/core/modules/modMyModule.class.php
	htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php
	htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php
	htdocs/modulebuilder/template/myobject_agenda.php
	htdocs/modulebuilder/template/myobject_list.php
This commit is contained in:
Laurent Destailleur 2023-09-05 19:38:45 +02:00
commit f43ef55b26
13 changed files with 49 additions and 42 deletions

View File

@ -389,6 +389,10 @@ function restrictedArea(User $user, $features, $object = 0, $tableandshare = '',
if ($features == 'facturerec') {
$features = 'facture';
}
if ($features == 'supplier_invoicerec') {
$features = 'fournisseur';
$feature2 = 'facture';
}
if ($features == 'mo') {
$features = 'mrp';
}

View File

@ -366,7 +366,7 @@ $num = $db->num_rows($resql);
if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) {
$obj = $db->fetch_object($resql);
$id = $obj->rowid;
header("Location: ".dol_buildpath('/mymodule/myobject_card.php', 1).'?id='.$id);
header("Location: ".dol_buildpath('/fichinter/card.php', 1).'?id='.$id);
exit;
}

View File

@ -126,7 +126,8 @@ $now = dol_now();
$error = 0;
$result = restrictedArea($user, 'facture', $object->id, $objecttype);
$result = restrictedArea($user, 'supplier_invoicerec', $object->id, $objecttype);
/*

View File

@ -66,7 +66,6 @@ $objecttype = 'facture_fourn_rec';
if ($action == "create" || $action == "add") {
$objecttype = '';
}
$result = restrictedArea($user, 'facture', $id, $objecttype);
$search_ref = GETPOST('search_ref');
$search_societe = GETPOST('search_societe');
@ -169,7 +168,7 @@ if ($socid > 0) {
}
$objecttype = 'facture_fourn_rec';
$result = restrictedArea($user, 'facture', $object->id, $objecttype);
$result = restrictedArea($user, 'supplier_invoicerec', $object->id, $objecttype);
/*

View File

@ -448,7 +448,7 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) {
// We calculate $totallate. Must be defined before start of next loop because it is show in first fetch on next loop
foreach ($valid_dashboardlines as $board) {
if ($board->nbtodolate > 0) {
if (is_numeric($board->nbtodo) && is_numeric($board->nbtodolate) && $board->nbtodolate > 0) {
$totaltodo += $board->nbtodo;
$totallate += $board->nbtodolate;
}

View File

@ -257,7 +257,7 @@ if ($action == 'updateMask') {
if (dolibarr_set_const($db, $constforval, $value, 'chaine', 0, '', $conf->entity)) {
// The constant that was read before the new set
// We therefore requires a variable to have a coherent view
$conf->global->$constforval = $value;
$conf->global->{$constforval} = $value;
}
// We disable/enable the document template (into llx_document_model table)

View File

@ -85,7 +85,7 @@ class MyObject extends CommonObject
* Note: Filter must be a Dolibarr Universal Filter syntax string. Example: "(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.status:!=:0) or (t.nature:is:NULL)"
* 'label' the translation key.
* 'picto' is code of a picto to show before value in forms
* 'enabled' is a condition when the field must be managed (Example: 1 or 'getDolGlobalInt('MY_SETUP_PARAM') or 'isModEnabled("multicurrency")' ...)
* 'enabled' is a condition when the field must be managed (Example: 1 or 'getDolGlobalInt("MY_SETUP_PARAM")' or 'isModEnabled("multicurrency")' ...)
* 'position' is the sort order of field.
* 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0).
* 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only, 3=Visible on create/update/view form only (not list), 4=Visible on list and update/view form only (not create). 5=Visible on list and view only (not create/not update). Using a negative value means field is not shown by default on list but can be selected for viewing)
@ -572,7 +572,7 @@ class MyObject extends CommonObject
return 0;
}
/*if (! ((!getDolGlobalInt('MAIN_USE_ADVANCED_PERMS') && !empty($user->rights->mymodule->myobject->write))
/* if (! ((!getDolGlobalInt('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('mymodule','write'))
|| (getDolGlobalInt('MAIN_USE_ADVANCED_PERMS') && !empty($user->rights->mymodule->myobject->myobject_advance->validate))))
{
$this->error='NotEnoughPermissions';
@ -690,8 +690,8 @@ class MyObject extends CommonObject
return 0;
}
/*if (! ((!getDolGlobalInt('MAIN_USE_ADVANCED_PERMS') && !empty($user->rights->mymodule->write))
|| (getDolGlobalInt('MAIN_USE_ADVANCED_PERMS') && !empty($user->rights->mymodule->mymodule_advance->validate))))
/* if (! ((!getDolGlobalInt('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('mymodule','write'))
|| (getDolGlobalInt('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('mymodule','mymodule_advance','validate'))))
{
$this->error='Permission denied';
return -1;
@ -714,8 +714,8 @@ class MyObject extends CommonObject
return 0;
}
/*if (! ((!getDolGlobalInt('MAIN_USE_ADVANCED_PERMS') && !empty($user->rights->mymodule->write))
|| (getDolGlobalInt('MAIN_USE_ADVANCED_PERMS') && !empty($user->rights->mymodule->mymodule_advance->validate))))
/* if (! ((!getDolGlobalInt('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('mymodule','write'))
|| (getDolGlobalInt('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('mymodule','mymodule_advance','validate'))))
{
$this->error='Permission denied';
return -1;
@ -738,13 +738,14 @@ class MyObject extends CommonObject
return 0;
}
/*if (! ((!getDolGlobalInt('MAIN_USE_ADVANCED_PERMS') && !empty($user->rights->mymodule->write))
|| (getDolGlobalInt('MAIN_USE_ADVANCED_PERMS') && !empty($user->rights->mymodule->mymodule_advance->validate))))
/*if (! ((!getDolGlobalInt('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('mymodule','write'))
|| (getDolGlobalInt('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('mymodule','mymodule_advance','validate'))))
{
$this->error='Permission denied';
return -1;
}*/
return $this->setStatusCommon($user, self::STATUS_VALIDATED, $notrigger, 'MYOBJECT_REOPEN');
}
@ -862,7 +863,7 @@ class MyObject extends CommonObject
$pospoint = strpos($filearray[0]['name'], '.');
$pathtophoto = $class.'/'.$this->ref.'/thumbs/'.substr($filename, 0, $pospoint).'_mini'.substr($filename, $pospoint);
if (!getDolGlobalInt(strtoupper($module.'_'.$class).'_FORMATLISTPHOTOSASUSERS')) {
if (!getDolGlobalString(strtoupper($module.'_'.$class).'_FORMATLISTPHOTOSASUSERS')) {
$result .= '<div class="floatleft inline-block valignmiddle divphotoref"><div class="photoref"><img class="photo'.$module.'" alt="No photo" border="0" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$module.'&entity='.$conf->entity.'&file='.urlencode($pathtophoto).'"></div></div>';
} else {
$result .= '<div class="floatleft inline-block valignmiddle divphotoref"><img class="photouserphoto userphoto" alt="No photo" border="0" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$module.'&entity='.$conf->entity.'&file='.urlencode($pathtophoto).'"></div>';

View File

@ -283,8 +283,8 @@ class doc_generic_myobject_odt extends ModelePDFMyObject
// Get extension (ods or odt)
$newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
if (getDolGlobalInt('MAIN_DOC_USE_TIMING')) {
$format = getDolGlobalInt('MAIN_DOC_USE_TIMING');
if (getDolGlobalString('MAIN_DOC_USE_TIMING')) {
$format = getDolGlobalString('MAIN_DOC_USE_TIMING');
if ($format == '1') {
$format = '%Y%m%d%H%M%S';
}

View File

@ -197,8 +197,7 @@ class pdf_standard_myobject extends ModelePDFMyObject
$realpatharray = array();
$this->atleastonephoto = false;
/*
if (getDolGlobalInt('MAIN_GENERATE_MYOBJECT_WITH_PICTURE')))
{
if (getDolGlobalInt('MAIN_GENERATE_MYOBJECT_WITH_PICTURE'))) {
$objphoto = new Product($this->db);
for ($i = 0; $i < $nblines; $i++)
@ -284,7 +283,7 @@ class pdf_standard_myobject extends ModelePDFMyObject
$pdf->SetAutoPageBreak(1, 0);
$heightforinfotot = 50; // Height reserved to output the info and total part and payment part
$heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
$heightforfreetext = getDolGlobalInt('MAIN_PDF_FREETEXT_HEIGHT', 5); // Height reserved to output the free text on last page
$heightforfooter = $this->marge_basse + (getDolGlobalInt('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS') ? 12 : 22); // Height reserved to output the footer (value include bottom margin)
if (class_exists('TCPDF')) {
@ -316,7 +315,7 @@ class pdf_standard_myobject extends ModelePDFMyObject
$cert = empty($user->conf->CERTIFICATE_CRT) ? '' : $user->conf->CERTIFICATE_CRT;
// If user has no certificate, we try to take the company one
if (!$cert) {
$cert = getDolGlobalString('CERTIFICATE_CRT') ? '' : getDolGlobalString('CERTIFICATE_CRT');
$cert = getDolGlobalString('CERTIFICATE_CRT');
}
// If a certificate is found
if ($cert) {
@ -1080,7 +1079,7 @@ class pdf_standard_myobject extends ModelePDFMyObject
}
// Recipient name
if ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT))) {
if ($object->contact->socid != $object->thirdparty->id && getDolGlobalInt('MAIN_USE_COMPANY_NAME_OF_CONTACT')) {
$thirdparty = $object->contact;
} else {
$thirdparty = $object->thirdparty;
@ -1239,7 +1238,7 @@ class pdf_standard_myobject extends ModelePDFMyObject
'border-left' => true, // add left line separator
);
if (getDolGlobalInt('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT') && !getDolGlobalInt('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN')) {
if (!getDolGlobalInt('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT') && !getDolGlobalInt('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN')) {
$this->cols['vat']['status'] = true;
}
@ -1290,7 +1289,7 @@ class pdf_standard_myobject extends ModelePDFMyObject
),
'border-left' => true, // add left line separator
);
if (!empty($conf->global->PRODUCT_USE_UNITS)) {
if (getDolGlobalInt('PRODUCT_USE_UNITS')) {
$this->cols['unit']['status'] = true;
}

View File

@ -189,6 +189,7 @@ if ($object->id > 0) {
$title = $langs->trans("Agenda");
//if (getDolGlobalString('MAIN_HTML_TITLE') && preg_match('/thirdpartynameonly/',getDolGlobalString('MAIN_HTML_TITLE')) && $object->name) $title=$object->name." - ".$title;
$help_url = 'EN:Module_Agenda_En|DE:Modul_Terminplanung';
llxHeader('', $title, $help_url);
if (isModEnabled('notification')) {

View File

@ -400,10 +400,10 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
/*
// Ref customer
$morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $usercancreate, 'string', '', 0, 1);
$morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $usercancreate, 'string'.(isset($conf->global->THIRDPARTY_REF_INPUT_SIZE) ? ':'.$conf->global->THIRDPARTY_REF_INPUT_SIZE : ''), '', null, null, '', 1);
$morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $usercancreate, 'string'.(getDolGlobalInt('THIRDPARTY_REF_INPUT_SIZE') ? ':'.getDolGlobalInt('THIRDPARTY_REF_INPUT_SIZE') : ''), '', null, null, '', 1);
// Thirdparty
$morehtmlref .= '<br>'.$object->thirdparty->getNomUrl(1, 'customer');
if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) {
if (!getDolGlobalInt('MAIN_DISABLE_OTHER_LINK') && $object->thirdparty->id > 0) {
$morehtmlref .= ' (<a href="'.DOL_URL_ROOT.'/commande/list.php?socid='.$object->thirdparty->id.'&search_societe='.urlencode($object->thirdparty->name).'">'.$langs->trans("OtherOrders").'</a>)';
}
// Project

View File

@ -411,7 +411,7 @@ $num = $db->num_rows($resql);
// Direct jump if only one record found
if ($num == 1 && !getDolGlobalInt('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) {
if ($num == 1 && getDolGlobalInt('MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) {
$obj = $db->fetch_object($resql);
$id = $obj->rowid;
header("Location: ".dol_buildpath('/mymodule/myobject_card.php', 1).'?id='.((int) $id));

View File

@ -53,7 +53,6 @@ $discard_closed = GETPOST('discardclosed', 'int');
// Security check
restrictedArea($user, 'projet', 0, 'projet&project');
/*
* View
*/
@ -62,29 +61,32 @@ dol_syslog("Call ajax projet/ajax/projects.php");
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
top_httphead('application/json');
if (empty($htmlname) && !GETPOST('mode', 'aZ09')) {
return;
}
// Mode to get list of projects
if (empty($mode) || $mode != 'gettasks') {
top_httphead('application/json');
// When used from jQuery, the search term is added as GET param "term".
$searchkey = (GETPOSTISSET($htmlname) ? GETPOST($htmlname, 'aZ09') : '');
$formproject = new FormProjets($db);
$arrayresult = $formproject->select_projects_list($socid, '', $htmlname, 0, 0, 1, $discard_closed, 0, 0, 1, $searchkey);
}
$arrayresult = $formproject->select_projects_list($socid, '', '', 0, 0, 1, $discard_closed, 0, 0, 1, $searchkey);
$db->close();
print json_encode($arrayresult);
// Mode to get list of tasks
if ($mode == 'gettasks') {
$formproject = new FormProjets($db);
$formproject->selectTasks((!empty($socid) ? $socid : -1), 0, 'taskid', 24, 1, '1', 1, 0, 0, 'maxwidth500', GETPOST('projectid', 'int'), '');
return;
}
// Mode to get list of tasks
// THIS MODE RETURNS HTML NOT JSON - THE CALL SHOULD BE UPDATE IN THE FUTURE
if ($mode == 'gettasks') {
top_httphead();
$db->close();
$formproject = new FormProjets($db);
$formproject->selectTasks((!empty($socid) ? $socid : -1), 0, 'taskid', 24, 1, '1', 1, 0, 0, 'maxwidth500', GETPOST('projectid', 'int'), '');
print json_encode($arrayresult);
$db->close();
return;
}