diff --git a/htdocs/admin/defaultvalues.php b/htdocs/admin/defaultvalues.php index 9daf076cc5e..094c4a8dd7c 100644 --- a/htdocs/admin/defaultvalues.php +++ b/htdocs/admin/defaultvalues.php @@ -38,6 +38,7 @@ if (!$user->admin) accessforbidden(); $id = GETPOST('rowid', 'int'); $action = GETPOST('action', 'alpha'); +$optioncss = GETPOST('optionscss', 'alphanohtml'); $mode = GETPOST('mode', 'aZ09') ?GETPOST('mode', 'aZ09') : 'createform'; // 'createform', 'filters', 'sortorder', 'focus' @@ -212,10 +213,10 @@ print "
\n"; if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); -if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); -if ($defaulturl) $param .= '&defaulturl='.urlencode($defaulturl); -if ($defaultkey) $param .= '&defaultkey='.urlencode($defaultkey); -if ($defaultvalue) $param .= '&defaultvalue='.urlencode($defaultvalue); +if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); +if ($defaulturl) $param .= '&defaulturl='.urlencode($defaulturl); +if ($defaultkey) $param .= '&defaultkey='.urlencode($defaultkey); +if ($defaultvalue) $param .= '&defaultvalue='.urlencode($defaultvalue); print '
entity) && $debug) ? '?debug=1' : '').'" method="POST">'; @@ -252,7 +253,7 @@ $texthelp = $langs->trans("PageUrlForDefaultValues"); if ($mode == 'createform') $texthelp .= $langs->trans("PageUrlForDefaultValuesCreate", 'societe/card.php', 'societe/card.php?abc=val1&def=val2'); else $texthelp .= $langs->trans("PageUrlForDefaultValuesList", 'societe/list.php', 'societe/list.php?abc=val1&def=val2'); $texthelp .= '

'.$langs->trans("AlsoDefaultValuesAreEffectiveForActionCreate"); -$texturl = $form->textwithpicto($langs->trans("Url"), $texthelp); +$texturl = $form->textwithpicto($langs->trans("RelativeURL"), $texthelp); print_liste_field_titre($texturl, $_SERVER["PHP_SELF"], 'page,param', '', $param, '', $sortfield, $sortorder); // Field $texthelp = $langs->trans("TheKeyIsTheNameOfHtmlField"); diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index a21ea9d7d0a..e4e4237db05 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -90,13 +90,13 @@ if (empty($reshook)) // Action clone object if ($action == 'confirm_clone' && $confirm == 'yes') { - if (empty($_REQUEST["clone_content"]) && empty($_REQUEST["clone_receivers"])) + if (! GETPOST("clone_content", 'alpha') && ! GETPOST("clone_receivers", 'alpha')) { setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors'); } else { - $result = $object->createFromClone($user, $object->id, $_REQUEST["clone_content"], $_REQUEST["clone_receivers"]); + $result = $object->createFromClone($user, $object->id, GETPOST("clone_content", 'alpha'), GETPOST("clone_receivers", 'alpha')); if ($result > 0) { header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result); diff --git a/htdocs/comm/mailing/class/mailing.class.php b/htdocs/comm/mailing/class/mailing.class.php index 553c5e79c15..a671db7b7f9 100644 --- a/htdocs/comm/mailing/class/mailing.class.php +++ b/htdocs/comm/mailing/class/mailing.class.php @@ -273,8 +273,8 @@ class Mailing extends CommonObject * * @param User $user User making the clone * @param int $fromid Id of object to clone - * @param int $option1 1=Copy content, 0=Forget content - * @param int $option2 Not used + * @param int $option1 1=Clone content, 0=Forget content + * @param int $option2 1=Clone recipients * @return int New id of clone */ public function createFromClone(User $user, $fromid, $option1, $option2) @@ -305,7 +305,7 @@ class Mailing extends CommonObject $object->bgcolor = ''; $object->bgimage = ''; - $object->email_from = ''; + //$object->email_from = ''; // We do not reset from email because it is a mandatory value $object->email_replyto = ''; $object->email_errorsto = ''; @@ -331,7 +331,7 @@ class Mailing extends CommonObject if (! $error) { - //Clone target + // Clone recipient targets if (!empty($option2)) { require_once DOL_DOCUMENT_ROOT .'/core/modules/mailings/modules_mailings.php'; diff --git a/htdocs/core/lib/modulebuilder.lib.php b/htdocs/core/lib/modulebuilder.lib.php index fe5d707b10a..6ea1d949833 100644 --- a/htdocs/core/lib/modulebuilder.lib.php +++ b/htdocs/core/lib/modulebuilder.lib.php @@ -127,10 +127,10 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir = { $i++; $texttoinsert .= "\t\t'".$key."' => array('type'=>'".$val['type']."', 'label'=>'".$val['label']."',"; - $texttoinsert .= " 'enabled'=>".($val['enabled'] != '' ? $val['enabled'] : 1).","; - $texttoinsert .= " 'position'=>".($val['position'] != '' ? $val['position'] : 50).","; + $texttoinsert .= " 'enabled'=>".($val['enabled'] !== '' ? $val['enabled'] : 1).","; + $texttoinsert .= " 'position'=>".($val['position'] !== '' ? $val['position'] : 50).","; $texttoinsert .= " 'notnull'=>".(empty($val['notnull']) ? 0 : $val['notnull']).","; - $texttoinsert .= " 'visible'=>".($val['visible'] != '' ? $val['visible'] : -1).","; + $texttoinsert .= " 'visible'=>".($val['visible'] !== '' ? $val['visible'] : -1).","; if ($val['noteditable']) $texttoinsert .= " 'noteditable'=>'".$val['noteditable']."',"; if ($val['default']) $texttoinsert .= " 'default'=>'".$val['default']."',"; if ($val['index']) $texttoinsert .= " 'index'=>".$val['index'].","; diff --git a/htdocs/core/tpl/card_presend.tpl.php b/htdocs/core/tpl/card_presend.tpl.php index 795483b08ba..37920ed1ebc 100644 --- a/htdocs/core/tpl/card_presend.tpl.php +++ b/htdocs/core/tpl/card_presend.tpl.php @@ -219,6 +219,7 @@ if ($action == 'presend') if (!empty($origin) && !empty($origin_id)) { $element = $subelement = $origin; + $regs = array(); if (preg_match('/^([^_]+)_([^_]+)/i', $origin, $regs)) { $element = $regs[1]; $subelement = $regs[2]; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 738f07a2c0a..af8ade3571d 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -221,6 +221,7 @@ DoliPartnersDesc=List of companies providing custom-developed modules or feature WebSiteDesc=External websites for more add-on (non-core) modules... DevelopYourModuleDesc=Some solutions to develop your own module... URL=URL +RelativeURL=Relative URL BoxesAvailable=Widgets available BoxesActivated=Widgets activated ActivateOn=Activate on diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index e5233479571..d5ae9ca5124 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -174,6 +174,7 @@ SaveAndStay=Save and stay SaveAndNew=Save and new TestConnection=Test connection ToClone=Clone +ConfirmCloneAsk=Are you sure you want to clone the object %s? ConfirmClone=Choose data you want to clone: NoCloneOptionsSpecified=No data to clone defined. Of=of diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 80b3aa87adb..a3e79aedc71 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -92,6 +92,7 @@ if (empty($newmask)) // This should no happen $result = restrictedArea($user, 'modulebuilder', null); +$error = 0; /* @@ -784,12 +785,20 @@ if ($dirins && $action == 'initobject' && $module && GETPOST('createtablearray', if ($dirins && $action == 'initobject' && $module && $objectname) { + $objectname = ucfirst($objectname); + if (preg_match('/[^a-z0-9_]/i', $objectname)) { $error++; setEventMessages($langs->trans("SpaceOrSpecialCharAreNotAllowed"), null, 'errors'); $tabobj = 'newobject'; } + if (class_exists($objectname)) { + // TODO Add a more efficient detection. Scan disk ? + $error++; + setEventMessages($langs->trans("AnObjectWithThisClassNameAlreadyExists"), null, 'errors'); + $tabobj = 'newobject'; + } $srcdir = DOL_DOCUMENT_ROOT.'/modulebuilder/template'; $destdir = $dirins.'/'.strtolower($module); @@ -881,16 +890,31 @@ if ($dirins && $action == 'initobject' && $module && $objectname) // Edit the class 'class/'.strtolower($objectname).'.class.php' if (GETPOST('includerefgeneration', 'aZ09')) { // Replace 'visible'=>1, 'noteditable'=>0, 'default'=>'' - $arrayreplacement = array('/\'visible\'=>1,\s*\'noteditable\'=>0,\s*\'default\'=>\'\'/' => "'visible'=>4, 'noteditable'=>1, 'default'=>'(PROV)'"); + $arrayreplacement = array( + '/\'visible\'=>1,\s*\'noteditable\'=>0,\s*\'default\'=>\'\'/' => "'visible'=>4, 'noteditable'=>1, 'default'=>'(PROV)'" + ); //var_dump($arrayreplacement);exit; //var_dump($destdir.'/class/'.strtolower($objectname).'.class.php');exit; dolReplaceInFile($destdir.'/class/'.strtolower($objectname).'.class.php', $arrayreplacement, '', 0, 0, 1); + + $arrayreplacement = array( + '/\'models\' => 0,/' => '\'models\' => 1,' + ); + dolReplaceInFile($destdir.'/core/modules/mod'.$module.'.class.php', $arrayreplacement, '', 0, 0, 1); } // Edit the setup file and the card page if (GETPOST('includedocgeneration', 'aZ09')) { - // TODO - // dolReplaceInFile(); + // Replace some var init into some files + $arrayreplacement = array( + '/\$includedocgeneration = 0;/' => '$includedocgeneration = 1;' + ); + dolReplaceInFile($destdir.'/class/'.strtolower($objectname).'.class.php', $arrayreplacement, '', 0, 0, 1); + + $arrayreplacement = array( + '/\'models\' => 0,/' => '\'models\' => 1,' + ); + dolReplaceInFile($destdir.'/core/modules/mod'.$module.'.class.php', $arrayreplacement, '', 0, 0, 1); } // Scan for object class files @@ -1639,12 +1663,90 @@ $head[$h][1] = ''.$langs->trans("New $head[$h][2] = 'initmodule'; $h++; -foreach ($listofmodules as $tmpmodule => $tmpmodulearray) -{ - $head[$h][0] = $_SERVER["PHP_SELF"].'?module='.$tmpmodulearray['modulenamewithcase'].($forceddirread ? '@'.$dirread : ''); - $head[$h][1] = $tmpmodulearray['modulenamewithcase']; - $head[$h][2] = $tmpmodulearray['modulenamewithcase']; - $h++; +$linktoenabledisable = ''; +$modulestatusinfo = ''; + +if (is_array($listofmodules) && count($listofmodules) > 0) { + // Define $linktoenabledisable and $modulestatusinfo + $modulelowercase=strtolower($module); + $const_name = 'MAIN_MODULE_'.strtoupper($module); + + $param=''; + if ($tab) $param.='&tab='.urlencode($tab); + if ($module) $param.='&module='.urlencode($module); + if ($tabobj) $param.='&tabobj='.urlencode($tabobj); + + $urltomodulesetup=''.$langs->trans('Home').'-'.$langs->trans("Setup").'-'.$langs->trans("Modules").''; + if (! empty($conf->global->$const_name)) // If module is already activated + { + $linktoenabledisable.=''; + $linktoenabledisable.=img_picto($langs->trans("Activated"), 'switch_on', '', false, 0, 0, '', '', 1); + $linktoenabledisable.=''; + + $objMod = $moduleobj; + $backtourlparam = ''; + $backtourlparam .= ($backtourlparam ? '&' : '?').'module='.$module; // No urlencode here, done later + if ($tab) $backtourlparam .= ($backtourlparam ? '&' : '?').'tab='.$tab; // No urlencode here, done later + $backtourl = $_SERVER["PHP_SELF"].$backtourlparam; + + $regs = array(); + if (is_array($objMod->config_page_url)) + { + $i = 0; + foreach ($objMod->config_page_url as $page) + { + $urlpage = $page; + if ($i++) + { + $linktoenabledisable .= ' '.img_picto(ucfirst($page), "setup").''; + // print ''.ucfirst($page).' '; + } + else + { + if (preg_match('/^([^@]+)@([^@]+)$/i', $urlpage, $regs)) + { + $urltouse = dol_buildpath('/'.$regs[2].'/admin/'.$regs[1], 1); + $linktoenabledisable .= '   '.img_picto($langs->trans("Setup"), "setup", 'style="padding-right: 6px"').''; + } + else + { + $urltouse = $urlpage; + $linktoenabledisable .= '   '.img_picto($langs->trans("Setup"), "setup", 'style="padding-right: 6px"').''; + } + } + } + } + elseif (preg_match('/^([^@]+)@([^@]+)$/i', $objMod->config_page_url, $regs)) + { + $linktoenabledisable .= '   '.img_picto($langs->trans("Setup"), "setup", 'style="padding-right: 6px"').''; + } + } + else + { + $linktoenabledisable.=''; + $linktoenabledisable.=img_picto($langs->trans("ModuleIsNotActive", $urltomodulesetup), 'switch_off', '', false, 0, 0, '', 'classfortooltip', 1); + $linktoenabledisable.="\n"; + } + + if (! empty($conf->$modulelowercase->enabled)) + { + $modulestatusinfo=$form->textwithpicto('', $langs->trans("Warning").' : '.$langs->trans("ModuleIsLive"), -1, 'warning'); + } + + // Loop to show tab of each module + foreach ($listofmodules as $tmpmodule => $tmpmodulearray) + { + $head[$h][0] = $_SERVER["PHP_SELF"].'?module='.$tmpmodulearray['modulenamewithcase'].($forceddirread ? '@'.$dirread : ''); + $head[$h][1] = $tmpmodulearray['modulenamewithcase']; + $head[$h][2] = $tmpmodulearray['modulenamewithcase']; + + /*if ($tmpmodule == $modulelowercase) { + $head[$h][1] .= ' '.$modulestatusinfo; + $head[$h][1] .= ' '.$linktoenabledisable; + }*/ + + $h++; + } } $head[$h][0] = $_SERVER["PHP_SELF"].'?module=deletemodule'; @@ -1692,9 +1794,6 @@ elseif (!empty($module)) { $dirread = $listofmodules[strtolower($module)]['moduledescriptorrootpath']; - $head2 = array(); - $h = 0; - $modulelowercase = strtolower($module); $const_name = 'MAIN_MODULE_'.strtoupper($module); @@ -1726,6 +1825,9 @@ elseif (!empty($module)) $modulestatusinfo = $form->textwithpicto($langs->trans("ModuleIsLive"), $langs->trans("Warning"), -1, 'warning'); } + $head2 = array(); + $h = 0; + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=description&module='.$module.($forceddirread ? '@'.$dirread : ''); $head2[$h][1] = $langs->trans("Description"); $head2[$h][2] = 'description'; @@ -1746,16 +1848,16 @@ elseif (!empty($module)) $head2[$h][2] = 'objects'; $h++; - $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=menus&module='.$module.($forceddirread ? '@'.$dirread : ''); - $head2[$h][1] = $langs->trans("Menus"); - $head2[$h][2] = 'menus'; - $h++; - $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=permissions&module='.$module.($forceddirread ? '@'.$dirread : ''); $head2[$h][1] = $langs->trans("Permissions"); $head2[$h][2] = 'permissions'; $h++; + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=menus&module='.$module.($forceddirread ? '@'.$dirread : ''); + $head2[$h][1] = $langs->trans("Menus"); + $head2[$h][2] = 'menus'; + $h++; + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=hooks&module='.$module.($forceddirread ? '@'.$dirread : ''); $head2[$h][1] = $langs->trans("Hooks"); $head2[$h][2] = 'hooks'; @@ -1802,8 +1904,8 @@ elseif (!empty($module)) $h++; // Link to enable / disable - print $modulestatusinfo; - print ' '.$linktoenabledisable.'
'; + print '
'.$modulestatusinfo; + print ' '.$linktoenabledisable.'
'; print '
'; @@ -2083,7 +2185,7 @@ elseif (!empty($module)) print_liste_field_titre("Condition", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); print "\n"; - if (is_array($dicts)) + if (is_array($dicts) && is_array($dicts['tabname'])) { $i = 0; $maxi = count($dicts['tabname']); @@ -2567,6 +2669,7 @@ elseif (!empty($module)) print ''; print ''; + // List of existing properties foreach ($properties as $propkey => $propval) { /* If from Reflection @@ -2638,7 +2741,7 @@ elseif (!empty($module)) print $propenabled ? $propenabled : ''; print ''; print ''; - print $propvisible ? $propvisible : ''; + print $propvisible ? $propvisible : '0'; print ''; print ''; print $propnoteditable ? $propnoteditable : ''; diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index a108e9c8a84..284fd9b15d3 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -552,29 +552,31 @@ class MyObject extends CommonObject } $this->newref = $num; - // Validate - $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; - $sql .= " SET ref = '".$this->db->escape($num)."',"; - $sql .= " status = ".self::STATUS_VALIDATED.","; - $sql .= " date_validation = '".$this->db->idate($now)."',"; - $sql .= " fk_user_valid = ".$user->id; - $sql .= " WHERE rowid = ".$this->id; + if (! empty($num)) { + // Validate + $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; + $sql .= " SET ref = '".$this->db->escape($num)."',"; + $sql .= " status = ".self::STATUS_VALIDATED; + if (! empty($this->fields['date_validation'])) $sql .= ", date_validation = '".$this->db->idate($now)."',"; + if (! empty($this->fields['fk_user_valid'])) $sql .= ", fk_user_valid = ".$user->id; + $sql .= " WHERE rowid = ".$this->id; - dol_syslog(get_class($this)."::validate()", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) - { - dol_print_error($this->db); - $this->error = $this->db->lasterror(); - $error++; - } + dol_syslog(get_class($this)."::validate()", LOG_DEBUG); + $resql = $this->db->query($sql); + if (!$resql) + { + dol_print_error($this->db); + $this->error = $this->db->lasterror(); + $error++; + } - if (!$error && !$notrigger) - { - // Call trigger - $result = $this->call_trigger('MYOBJECT_VALIDATE', $user); - if ($result < 0) $error++; - // End call triggers + if (!$error && !$notrigger) + { + // Call trigger + $result = $this->call_trigger('MYOBJECT_VALIDATE', $user); + if ($result < 0) $error++; + // End call triggers + } } if (!$error) @@ -951,7 +953,7 @@ class MyObject extends CommonObject $langs->load("mymodule@myobject"); if (empty($conf->global->MYMODULE_MYOBJECT_ADDON)) { - $conf->global->MYMODULE_MYOBJECT_ADDON = 'mod_mymobject_standard'; + $conf->global->MYMODULE_MYOBJECT_ADDON = 'mod_myobject_standard'; } if (!empty($conf->global->MYMODULE_MYOBJECT_ADDON)) @@ -977,23 +979,28 @@ class MyObject extends CommonObject return ''; } - $obj = new $classname(); - $numref = $obj->getNextValue($this); + if (class_exists($classname)) { + $obj = new $classname(); + $numref = $obj->getNextValue($this); - if ($numref != "") - { - return $numref; - } - else - { - $this->error = $obj->error; - //dol_print_error($this->db,get_class($this)."::getNextNumRef ".$obj->error); + if ($numref != '' && $numref != '-1') + { + return $numref; + } + else + { + $this->error = $obj->error; + //dol_print_error($this->db,get_class($this)."::getNextNumRef ".$obj->error); + return ""; + } + } else { + print $langs->trans("Error")." ".$langs->trans("ClassNotFound").' '.$classname; return ""; } } else { - print $langs->trans("Error")." ".$langs->trans("Error_MYMODULE_MYOBJECT_ADDON_NotDefined"); + print $langs->trans("ErrorNumberingModuleNotSetup", $this->element); return ""; } } @@ -1013,6 +1020,9 @@ class MyObject extends CommonObject { global $conf, $langs; + $result = 0; + $includedocgeneration = 0; + $langs->load("mymodule@mymodule"); if (!dol_strlen($modele)) { @@ -1027,7 +1037,11 @@ class MyObject extends CommonObject $modelpath = "core/modules/mymodule/doc/"; - return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); + if ($includedocgeneration) { + $result = $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); + } + + return $result; } /** diff --git a/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_advanced.php b/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_advanced.php index 09e4902d6f9..42ede9ba800 100644 --- a/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_advanced.php +++ b/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_advanced.php @@ -100,13 +100,18 @@ class mod_myobject_advanced extends ModeleNumRefMyObject { global $conf, $langs, $mysoc; - $old_code_client = $mysoc->code_client; + $object = new MyObject($this->db); + $object->initAsSpecimen(); + + /*$old_code_client = $mysoc->code_client; $old_code_type = $mysoc->typent_code; $mysoc->code_client = 'CCCCCCCCCC'; - $mysoc->typent_code = 'TTTTTTTTTT'; - $numExample = $this->getNextValue($mysoc); - $mysoc->code_client = $old_code_client; - $mysoc->typent_code = $old_code_type; + $mysoc->typent_code = 'TTTTTTTTTT';*/ + + $numExample = $this->getNextValue($object); + + /*$mysoc->code_client = $old_code_client; + $mysoc->typent_code = $old_code_type;*/ if (!$numExample) { diff --git a/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_standard.php b/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_standard.php index d57d817985a..13beaadab95 100644 --- a/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_standard.php +++ b/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_standard.php @@ -76,7 +76,7 @@ class mod_myobject_standard extends ModeleNumRefMyObject * Checks if the numbers already in the database do not * cause conflicts that would prevent this numbering working. * - * @param Object $object Object we need next value for + * @param Object $object Object we need next value for * @return boolean false if conflict, true if ok */ public function canBeActivated($object) @@ -89,7 +89,12 @@ class mod_myobject_standard extends ModeleNumRefMyObject $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; $sql .= " FROM ".MAIN_DB_PREFIX."mymodule_myobject"; $sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; - $sql .= " AND entity = ".$conf->entity; + if ($object->ismultientitymanaged == 1) { + $sql.= " AND entity = ".$conf->entity; + } + elseif ($object->ismultientitymanaged == 2) { + // TODO + } $resql = $db->query($sql); if ($resql) @@ -122,7 +127,12 @@ class mod_myobject_standard extends ModeleNumRefMyObject $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; $sql .= " FROM ".MAIN_DB_PREFIX."mymodule_myobject"; $sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; - $sql .= " AND entity = ".$conf->entity; + if ($object->ismultientitymanaged == 1) { + $sql.= " AND entity = ".$conf->entity; + } + elseif ($object->ismultientitymanaged == 2) { + // TODO + } $resql = $db->query($sql); if ($resql) diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php index 93eb7560aaa..97adff0558f 100644 --- a/htdocs/modulebuilder/template/myobject_card.php +++ b/htdocs/modulebuilder/template/myobject_card.php @@ -290,7 +290,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if ($action == 'clone') { // Create an array for form $formquestion = array(); - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneMyObject', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneAsk', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); } // Confirmation of action xxxx @@ -581,7 +581,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } //Select mail models is same action as presend - /* if (GETPOST('modelselected')) $action = 'presend'; // Presend form @@ -591,7 +590,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $trackid = 'myobject'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; - */ } // End of page