diff --git a/htdocs/asset/class/asset.class.php b/htdocs/asset/class/asset.class.php index 710ae7fd3d0..410af398bc7 100644 --- a/htdocs/asset/class/asset.class.php +++ b/htdocs/asset/class/asset.class.php @@ -155,7 +155,6 @@ class Asset extends CommonObject public $import_key; public $model_pdf; public $status; - public $supplier_invoice_id; // /** // * @var string Field with ID of parent key if this object has a parent diff --git a/htdocs/comm/propal/class/api_proposals.class.php b/htdocs/comm/propal/class/api_proposals.class.php index 9c8b3c653e6..258e264c5a7 100644 --- a/htdocs/comm/propal/class/api_proposals.class.php +++ b/htdocs/comm/propal/class/api_proposals.class.php @@ -135,8 +135,13 @@ class Proposals extends DolibarrApi } // Add external contacts ids. - $this->propal->contacts_ids = $this->propal->liste_contact(-1, 'external', $contact_list); + $tmparray = $this->propal->liste_contact(-1, 'external', $contact_list); + if (is_array($tmparray)) { + $this->propal->contacts_ids = $tmparray; + } + $this->propal->fetchObjectLinked(); + return $this->_cleanObjectDatas($this->propal); } @@ -228,7 +233,10 @@ class Proposals extends DolibarrApi $proposal_static = new Propal($this->db); if ($proposal_static->fetch($obj->rowid)) { // Add external contacts ids - $proposal_static->contacts_ids = $proposal_static->liste_contact(-1, 'external', 1); + $tmparray = $proposal_static->liste_contact(-1, 'external', 1); + if (is_array($tmparray)) { + $proposal_static->contacts_ids = $tmparray; + } $obj_ret[] = $this->_cleanObjectDatas($proposal_static); } $i++; diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php index 2795c325fba..ac9ce98777d 100644 --- a/htdocs/commande/class/api_orders.class.php +++ b/htdocs/commande/class/api_orders.class.php @@ -133,7 +133,10 @@ class Orders extends DolibarrApi } // Add external contacts ids - $this->commande->contacts_ids = $this->commande->liste_contact(-1, 'external', $contact_list); + $tmparray = $this->commande->liste_contact(-1, 'external', $contact_list); + if (is_array($tmparray)) { + $this->commande->contacts_ids = $tmparray; + } $this->commande->fetchObjectLinked(); // Add online_payment_url, cf #20477 @@ -234,7 +237,10 @@ class Orders extends DolibarrApi $commande_static = new Commande($this->db); if ($commande_static->fetch($obj->rowid)) { // Add external contacts ids - $commande_static->contacts_ids = $commande_static->liste_contact(-1, 'external', 1); + $tmparray = $commande_static->liste_contact(-1, 'external', 1); + if (is_array($tmparray)) { + $commande_static->contacts_ids = $tmparray; + } // Add online_payment_url, cf #20477 require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; $commande_static->online_payment_url = getOnlinePaymentUrl(0, 'order', $commande_static->ref); diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index 51fd8c1dd7a..3dababa3dc3 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -148,7 +148,10 @@ class Invoices extends DolibarrApi // Add external contacts ids if ($contact_list > -1) { - $this->invoice->contacts_ids = $this->invoice->liste_contact(-1, 'external', $contact_list); + $tmparray = $this->invoice->liste_contact(-1, 'external', $contact_list); + if(is_array($tmparray)) { + $this->invoice->contacts_ids = $tmparray; + } } $this->invoice->fetchObjectLinked(); @@ -267,8 +270,10 @@ class Invoices extends DolibarrApi $invoice_static->remaintopay = price2num($invoice_static->total_ttc - $invoice_static->totalpaid - $invoice_static->totalcreditnotes - $invoice_static->totaldeposits, 'MT'); // Add external contacts ids - $invoice_static->contacts_ids = $invoice_static->liste_contact(-1, 'external', 1); - + $tmparray = $invoice_static->liste_contact(-1, 'external', 1); + if (is_array($tmparray)) { + $invoice_static->contacts_ids = $tmparray; + } $obj_ret[] = $this->_cleanObjectDatas($invoice_static); } $i++; @@ -1768,7 +1773,10 @@ class Invoices extends DolibarrApi // Add external contacts ids if ($contact_list > -1) { - $this->template_invoice->contacts_ids = $this->template_invoice->liste_contact(-1, 'external', $contact_list); + $tmparray = $this->template_invoice->liste_contact(-1, 'external', $contact_list); + if (is_array($tmparray)) { + $this->template_invoice->contacts_ids = $tmparray; + } } $this->template_invoice->fetchObjectLinked(); diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index bf33cbe224e..14bca386018 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -116,7 +116,7 @@ abstract class CommonObject public $array_languages = null; // Value is array() when load already tried /** - * @var array To sotre result of ->liste_contact() + * @var array To store result of ->liste_contact() */ public $contacts_ids; diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 8466d4c2145..69163f94750 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -238,6 +238,33 @@ if ($dirins && $action == 'initmodule' && $modulename) { } } + // Copy last html.formsetup.class.php' to backport folder + $tryToCopyFromSetupClass = true; + $backportDest = $destdir .'/backport/v17/core/class'; + $backportFileSrc = DOL_DOCUMENT_ROOT.'/core/class/html.formsetup.class.php'; + $backportFileDest = $backportDest.'/html.formsetup.class.php'; + $result = dol_mkdir($backportDest); + + if ($result < 0) { + $error++; + $langs->load("errors"); + setEventMessages($langs->trans("ErrorFailToCreateDir", $backportDest), null, 'errors'); + $tryToCopyFromSetupClass = false; + } + + if ($tryToCopyFromSetupClass) { + $result = dol_copy($backportFileSrc, $backportFileDest); + if ($result <= 0) { + if ($result < 0) { + $error++; + $langs->load("errors"); + setEventMessages($langs->trans("ErrorFailToCopyFile", $backportFileSrc, $backportFileDest), null, 'errors'); + } else { + setEventMessages($langs->trans("FileDidAlreadyExist", $backportFileDest), null, 'warnings'); + } + } + } + if (!empty($conf->global->MODULEBUILDER_USE_ABOUT)) { dol_delete_file($destdir.'/admin/about.php'); } diff --git a/htdocs/modulebuilder/template/admin/setup.php b/htdocs/modulebuilder/template/admin/setup.php index 01f22d744b8..8128ba7ca52 100644 --- a/htdocs/modulebuilder/template/admin/setup.php +++ b/htdocs/modulebuilder/template/admin/setup.php @@ -78,65 +78,75 @@ $label = GETPOST('label', 'alpha'); $scandir = GETPOST('scan_dir', 'alpha'); $type = 'myobject'; -$arrayofparameters = array( - 'MYMODULE_MYPARAM1'=>array('type'=>'string', 'css'=>'minwidth500' ,'enabled'=>1), - 'MYMODULE_MYPARAM2'=>array('type'=>'textarea','enabled'=>1), - //'MYMODULE_MYPARAM3'=>array('type'=>'category:'.Categorie::TYPE_CUSTOMER, 'enabled'=>1), - //'MYMODULE_MYPARAM4'=>array('type'=>'emailtemplate:thirdparty', 'enabled'=>1), - //'MYMODULE_MYPARAM5'=>array('type'=>'yesno', 'enabled'=>1), - //'MYMODULE_MYPARAM5'=>array('type'=>'thirdparty_type', 'enabled'=>1), - //'MYMODULE_MYPARAM6'=>array('type'=>'securekey', 'enabled'=>1), - //'MYMODULE_MYPARAM7'=>array('type'=>'product', 'enabled'=>1), -); $error = 0; $setupnotempty = 0; // Set this to 1 to use the factory to manage constants. Warning, the generated module will be compatible with version v15+ only -$useFormSetup = 0; -// Convert arrayofparameter into a formSetup object -if ($useFormSetup && (float) DOL_VERSION >= 15) { - require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsetup.class.php'; - $formSetup = new FormSetup($db); +$useFormSetup = 1; - // you can use the param convertor - $formSetup->addItemsFromParamsArray($arrayofparameters); - - // or use the new system see exemple as follow (or use both because you can ;-) ) - - /* - // Hôte - $item = $formSetup->newItem('NO_PARAM_JUST_TEXT'); - $item->fieldOverride = (empty($_SERVER['HTTPS']) ? 'http://' : 'https://') . $_SERVER['HTTP_HOST']; - $item->cssClass = 'minwidth500'; - - // Setup conf MYMODULE_MYPARAM1 as a simple string input - $item = $formSetup->newItem('MYMODULE_MYPARAM1'); - - // Setup conf MYMODULE_MYPARAM1 as a simple textarea input but we replace the text of field title - $item = $formSetup->newItem('MYMODULE_MYPARAM2'); - $item->nameText = $item->getNameText().' more html text '; - - // Setup conf MYMODULE_MYPARAM3 - $item = $formSetup->newItem('MYMODULE_MYPARAM3'); - $item->setAsThirdpartyType(); - - // Setup conf MYMODULE_MYPARAM4 : exemple of quick define write style - $formSetup->newItem('MYMODULE_MYPARAM4')->setAsYesNo(); - - // Setup conf MYMODULE_MYPARAM5 - $formSetup->newItem('MYMODULE_MYPARAM5')->setAsEmailTemplate('thirdparty'); - - // Setup conf MYMODULE_MYPARAM6 - $formSetup->newItem('MYMODULE_MYPARAM6')->setAsSecureKey()->enabled = 0; // disabled - - // Setup conf MYMODULE_MYPARAM7 - $formSetup->newItem('MYMODULE_MYPARAM7')->setAsProduct(); - */ - - $setupnotempty = count($formSetup->items); +if (!class_exists('FormSetup')) { + // For retrocompatibility Dolibarr < 16.0 + if (floatval(DOL_VERSION) < 16.0 && !class_exists('FormSetup')) { + require_once __DIR__.'/../backport/v17/core/class/html.formsetup.class.php'; + } else { + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsetup.class.php'; + } } +$formSetup = new FormSetup($db); + + +// Hôte +$item = $formSetup->newItem('NO_PARAM_JUST_TEXT'); +$item->fieldOverride = (empty($_SERVER['HTTPS']) ? 'http://' : 'https://') . $_SERVER['HTTP_HOST']; +$item->cssClass = 'minwidth500'; + +// Setup conf MYMODULE_MYPARAM1 as a simple string input +$item = $formSetup->newItem('MYMODULE_MYPARAM1'); + +// Setup conf MYMODULE_MYPARAM1 as a simple textarea input but we replace the text of field title +$item = $formSetup->newItem('MYMODULE_MYPARAM2'); +$item->nameText = $item->getNameText().' more html text '; + +// Setup conf MYMODULE_MYPARAM3 +$item = $formSetup->newItem('MYMODULE_MYPARAM3'); +$item->setAsThirdpartyType(); + +// Setup conf MYMODULE_MYPARAM4 : exemple of quick define write style +$formSetup->newItem('MYMODULE_MYPARAM4')->setAsYesNo(); + +// Setup conf MYMODULE_MYPARAM5 +$formSetup->newItem('MYMODULE_MYPARAM5')->setAsEmailTemplate('thirdparty'); + +// Setup conf MYMODULE_MYPARAM6 +$formSetup->newItem('MYMODULE_MYPARAM6')->setAsSecureKey()->enabled = 0; // disabled + +// Setup conf MYMODULE_MYPARAM7 +$formSetup->newItem('MYMODULE_MYPARAM7')->setAsProduct(); + +$formSetup->newItem('Title')->setAsTitle(); + +// Setup conf MYMODULE_MYPARAM8 +$item = $formSetup->newItem('MYMODULE_MYPARAM8'); +$TField = array( + 'test01' => $langs->trans('test01'), + 'test02' => $langs->trans('test02'), + 'test03' => $langs->trans('test03'), + 'test04' => $langs->trans('test04'), + 'test05' => $langs->trans('test05'), + 'test06' => $langs->trans('test06'), +); +$item->setAsMultiSelect($TField); +$item->helpText = $langs->transnoentities('MYMODULE_MYPARAM8'); + + +// Setup conf MYMODULE_MYPARAM9 +$formSetup->newItem('MYMODULE_MYPARAM9')->setAsSelect($TField); + + +$setupnotempty =+ count($formSetup->items); + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); @@ -145,6 +155,11 @@ $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); * Actions */ +// For retrocompatibility Dolibarr < 15.0 +if ( versioncompare(explode('.', DOL_VERSION), array(15)) < 0 && $action == 'update' && !empty($user->admin)) { + $formSetup->saveConfFromPost(); +} + include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { @@ -271,191 +286,15 @@ echo ''.$langs->trans("MyModuleSetupPage").'< if ($action == 'edit') { - if ($useFormSetup && (float) DOL_VERSION >= 15) { - print $formSetup->generateOutput(true); - } else { - print '
'; - } - + print $formSetup->generateOutput(true); print '| '.$langs->trans("Parameter").' | '.$langs->trans("Value").' |
| '; - $tooltiphelp = (($langs->trans($constname . 'Tooltip') != $constname . 'Tooltip') ? $langs->trans($constname . 'Tooltip') : ''); - print $form->textwithpicto($langs->trans($constname), $tooltiphelp); - print ' | ';
-
- if ($val['type'] == 'textarea') {
- print dol_nl2br($conf->global->{$constname});
- } elseif ($val['type']== 'html') {
- print $conf->global->{$constname};
- } elseif ($val['type'] == 'yesno') {
- print ajax_constantonoff($constname);
- } elseif (preg_match('/emailtemplate:/', $val['type'])) {
- include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php';
- $formmail = new FormMail($db);
-
- $tmp = explode(':', $val['type']);
-
- $template = $formmail->getEMailTemplate($db, $tmp[1], $user, $langs, $conf->global->{$constname});
- if ($template<0) {
- setEventMessages(null, $formmail->errors, 'errors');
- }
- print $langs->trans($template->label);
- } elseif (preg_match('/category:/', $val['type'])) {
- $c = new Categorie($db);
- $result = $c->fetch($conf->global->{$constname});
- if ($result < 0) {
- setEventMessages(null, $c->errors, 'errors');
- } elseif ($result > 0 ) {
- $ways = $c->print_all_ways(' >> ', 'none', 0, 1); // $ways[0] = "ccc2 >> ccc2a >> ccc2a1" with html formated text
- $toprint = array();
- foreach ($ways as $way) {
- $toprint[] = ' |