From 7a64ad1a26c0f21b6f1f4f33619e098a1e66546c Mon Sep 17 00:00:00 2001 From: Grand Philippe Date: Mon, 26 Aug 2013 14:29:46 +0200 Subject: [PATCH 1/4] some fix for contract model and clean code --- htdocs/admin/contract.php | 347 +++++++++--------- htdocs/core/menus/standard/auguria_menu.php | 4 +- htdocs/core/modules/modContrat.class.php | 2 +- ...odMailmanspip_Mailmanspipsynchro.class.php | 12 +- 4 files changed, 184 insertions(+), 181 deletions(-) diff --git a/htdocs/admin/contract.php b/htdocs/admin/contract.php index 065886d402b..07912e8759c 100644 --- a/htdocs/admin/contract.php +++ b/htdocs/admin/contract.php @@ -190,23 +190,6 @@ else if ($action == 'set_CONTRAT_DRAFT_WATERMARK') } } -elseif ($action == 'set_CONTRAT_PRINT_PRODUCTS') -{ - $val = GETPOST('CONTRAT_PRINT_PRODUCTS','alpha'); - $res = dolibarr_set_const($db, "CONTRAT_PRINT_PRODUCTS",($val == 'on'),'bool',0,'',$conf->entity); - - if (! $res > 0) $error++; - - if (! $error) - { - setEventMessage($langs->trans("SetupSaved")); - } - else - { - setEventMessage($langs->trans("Error"),'errors'); - } -} - /* * View */ @@ -215,7 +198,6 @@ $dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']); llxHeader(); -$dir=DOL_DOCUMENT_ROOT."/core/modules/contract/"; $form=new Form($db); $linkback=''.$langs->trans("BackToModuleList").''; @@ -244,84 +226,90 @@ print "\n"; clearstatcache(); -$dir = "../core/modules/contract/"; -$handle = opendir($dir); -if (is_resource($handle)) +foreach ($dirmodels as $reldir) { - $var=true; + $dir = dol_buildpath($reldir."core/modules/contract/"); - while (($file = readdir($handle))!==false) - { - if (substr($file, 0, 13) == 'mod_contract_' && substr($file, dol_strlen($file)-3, 3) == 'php') - { - $file = substr($file, 0, dol_strlen($file)-4); + if (is_dir($dir)) + { + $handle = opendir($dir); + if (is_resource($handle)) + { + $var=true; - require_once DOL_DOCUMENT_ROOT ."/core/modules/contract/".$file.'.php'; + while (($file = readdir($handle))!==false) + { + if (substr($file, 0, 13) == 'mod_contract_' && substr($file, dol_strlen($file)-3, 3) == 'php') + { + $file = substr($file, 0, dol_strlen($file)-4); - $module = new $file; + require_once $dir.$file.'.php'; - // Show modules according to features level - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; + $module = new $file($db); - if ($module->isEnabled()) - { - $var=!$var; - print ''.$module->nom."\n"; - print ''; - print $module->info(); - print ''; + // Show modules according to features level + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; - // Show example of numbering model - print ''; - $tmp=$module->getExample(); - if (preg_match('/^Error/',$tmp)) { $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; } - elseif ($tmp=='NotConfigured') print $langs->trans($tmp); - else print $tmp; - print ''."\n"; + if ($module->isEnabled()) + { + $var=!$var; + print ''.$module->nom."\n"; + print $module->info(); + print ''; - print ''; - if ($conf->global->CONTRACT_ADDON == "$file") - { - print img_picto($langs->trans("Activated"),'switch_on'); - } - else - { - print 'scandir.'&label='.urlencode($module->name).'">'; - print img_picto($langs->trans("Disabled"),'switch_off'); - print ''; - } - print ''; + // Show example of numbering model + print ''; + $tmp=$module->getExample(); + if (preg_match('/^Error/',$tmp)) { $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; } + elseif ($tmp=='NotConfigured') print $langs->trans($tmp); + else print $tmp; + print ''."\n"; - $contract=new Contrat($db); - $contract->initAsSpecimen(); + print ''; + if ($conf->global->CONTRACT_ADDON == "$file") + { + print img_picto($langs->trans("Activated"),'switch_on'); + } + else + { + print ''; + print img_picto($langs->trans("Disabled"),'switch_off'); + print ''; + } + print ''; - // Info - $htmltooltip=''; - $htmltooltip.=''.$langs->trans("Version").': '.$module->getVersion().'
'; - $nextval=$module->getNextValue($mysoc,$contract); - if ("$nextval" != $langs->trans("NotAvailable")) // Keep " on nextval - { - $htmltooltip.=''.$langs->trans("NextValue").': '; - if ($nextval) - { - $htmltooltip.=$nextval.'
'; - } - else - { - $htmltooltip.=$langs->trans($module->error).'
'; - } - } + $contract=new Contrat($db); + $contract->initAsSpecimen(); - print ''; - print $form->textwithpicto('',$htmltooltip,1,0); - print ''; + // Info + $htmltooltip=''; + $htmltooltip.=''.$langs->trans("Version").': '.$module->getVersion().'
'; + $nextval=$module->getNextValue($mysoc,$contract); + if ("$nextval" != $langs->trans("NotAvailable")) // Keep " on nextval + { + $htmltooltip.=''.$langs->trans("NextValue").': '; + if ($nextval) + { + $htmltooltip.=$nextval.'
'; + } + else + { + $htmltooltip.=$langs->trans($module->error).'
'; + } + } - print ''; - } - } - } - closedir($handle); + print ''; + print $form->textwithpicto('',$htmltooltip,1,0); + print ''; + + print ''; + } + } + } + closedir($handle); + } + } } print '
'; @@ -372,84 +360,116 @@ clearstatcache(); $var=true; foreach ($dirmodels as $reldir) { - $dir = dol_buildpath($reldir."core/modules/contract/doc/"); + foreach (array('','/doc') as $valdir) + { + $dir = dol_buildpath($reldir."core/modules/contract".$valdir); - if (is_dir($dir)) - { - $handle=opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle))!==false) - { - if (substr($file, dol_strlen($file) -12) == '.modules.php' && substr($file,0,4) == 'pdf_') - { - $name = substr($file, 4, dol_strlen($file) -16); - $classname = substr($file, 0, dol_strlen($file) -12); + if (is_dir($dir)) + { + $handle=opendir($dir); + if (is_resource($handle)) + { + while (($file = readdir($handle))!==false) + { + $filelist[]=$file; + } + closedir($handle); + arsort($filelist); - $var=!$var; + foreach($filelist as $file) + { + if (preg_match('/\.modules\.php$/i',$file) && preg_match('/^(pdf_|doc_)/',$file)) + { - print ''; - echo "$name"; - print "\n"; - require_once $dir.$file; - $module = new $classname($db); - print $module->description; - print ''; + if (file_exists($dir.'/'.$file)) + { + $name = substr($file, 4, dol_strlen($file) -16); + $classname = substr($file, 0, dol_strlen($file) -12); - // Active - if (in_array($name, $def)) - { - print "\n"; - print 'scandir.'&label='.urlencode($module->name).'">'; - print img_picto($langs->trans("Enabled"),'switch_on'); - print ''; - print ""; - } - else - { - print "\n"; - print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').''; - print ""; - } + require_once $dir.'/'.$file; + $module = new $classname($db); - // Default - print ""; - if ($conf->global->CONTRACT_ADDON_PDF == "$name") - { - print img_picto($langs->trans("Default"),'on'); - } - else - { - print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').''; - } - print ''; + $modulequalified=1; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0; - // Info - $htmltooltip = ''.$langs->trans("Name").': '.$module->name; - $htmltooltip.='
'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown")); - $htmltooltip.='
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; - $htmltooltip.='

'.$langs->trans("FeaturesSupported").':'; - $htmltooltip.='
'.$langs->trans("Logo").': '.yn($module->option_logo,1,1); - $htmltooltip.='
'.$langs->trans("PaymentMode").': '.yn($module->option_modereg,1,1); - $htmltooltip.='
'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg,1,1); - $htmltooltip.='
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang,1,1); - $htmltooltip.='
'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark,1,1); - print ''; - print $form->textwithpicto('',$htmltooltip,-1,0); - print ''; - - // Preview - $link=''.img_object($langs->trans("Preview"),'contract').''; - print ''; - print $link; - print ''; + if ($modulequalified) + { + $var = !$var; + print ''; + print (empty($module->name)?$name:$module->name); + print "\n"; + if (method_exists($module,'info')) print $module->info($langs); + else print $module->description; + print ''; - print ''; - } - } - closedir($handle); - } - } + // Active + if (in_array($name, $def)) + { + print ''."\n"; + print ''; + print img_picto($langs->trans("Enabled"),'switch_on'); + print ''; + print ''; + } + else + { + print ''."\n"; + print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').''; + print ""; + } + + // Defaut + print ''; + if ($conf->global->CONTRACT_ADDON_PDF == $name) + { + print img_picto($langs->trans("Default"),'on'); + } + else + { + print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').''; + } + print ''; + + // Info + $htmltooltip = ''.$langs->trans("Name").': '.$module->name; + $htmltooltip.='
'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown")); + if ($module->type == 'pdf') + { + $htmltooltip.='
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; + } + $htmltooltip.='

'.$langs->trans("FeaturesSupported").':'; + $htmltooltip.='
'.$langs->trans("Logo").': '.yn($module->option_logo,1,1); + $htmltooltip.='
'.$langs->trans("PaymentMode").': '.yn($module->option_modereg,1,1); + $htmltooltip.='
'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg,1,1); + $htmltooltip.='
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang,1,1); + $htmltooltip.='
'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark,1,1); + + + print ''; + print $form->textwithpicto('',$htmltooltip,1,0); + print ''; + + // Preview + print ''; + if ($module->type == 'pdf') + { + print ''.img_object($langs->trans("Preview"),'contract').''; + } + else + { + print img_object($langs->trans("PreviewNotAvailable"),'generic'); + } + print ''; + + print "\n"; + } + } + } + } + } + } + } } print ''; @@ -492,25 +512,8 @@ print ''; print ''; print "\n"; - -// print products on fichinter -$var=! $var; -print '
'; -print ''; -print ''; -print ''; -print $langs->trans("PrintProductsOnContract").' ('.$langs->trans("PrintProductsOnContractDetails").')'; -print 'global->CONTRAT_PRINT_PRODUCTS) - print 'checked="checked" '; -print '/>'; -print ''; -print ''; -print "\n"; - print '
'; - print ''; print '
'; diff --git a/htdocs/core/menus/standard/auguria_menu.php b/htdocs/core/menus/standard/auguria_menu.php index b24247100ef..159038d00f6 100644 --- a/htdocs/core/menus/standard/auguria_menu.php +++ b/htdocs/core/menus/standard/auguria_menu.php @@ -214,8 +214,8 @@ class MenuManager print str_pad('',1).'
  • '; // ui-btn to highlight on clic print ''; print str_pad('',12,' '); - if ($langs->trans(ucfirst($val['mainmenu'])."Dashboard") == ucfirst($val['mainmenu'])."Dashboard") print $langs->trans("Access"); // No translation - else print $langs->trans(ucfirst($val['mainmenu'])."Dashboard"); + if ($langs->trans(ucfirst($val['mainmenu'])."Dashboard") == ucfirst($val['mainmenu'])."Dashboard") print $langs->trans("Access"); // No translation + else print $langs->trans(ucfirst($val['mainmenu'])."Dashboard"); print ''; print '
  • '."\n"; } diff --git a/htdocs/core/modules/modContrat.class.php b/htdocs/core/modules/modContrat.class.php index 8a43ec9af92..1ec212fb07b 100644 --- a/htdocs/core/modules/modContrat.class.php +++ b/htdocs/core/modules/modContrat.class.php @@ -57,7 +57,7 @@ class modContrat extends DolibarrModules $this->picto='contract'; // Data directories to create when module is enabled - $this->dirs = array("/contracts/temp"); + $this->dirs = array("/contract/temp"); // Dependances $this->depends = array("modSociete","modService"); diff --git a/htdocs/core/triggers/interface_50_modMailmanspip_Mailmanspipsynchro.class.php b/htdocs/core/triggers/interface_50_modMailmanspip_Mailmanspipsynchro.class.php index a2f4f2406fd..20556018b58 100644 --- a/htdocs/core/triggers/interface_50_modMailmanspip_Mailmanspipsynchro.class.php +++ b/htdocs/core/triggers/interface_50_modMailmanspip_Mailmanspipsynchro.class.php @@ -153,12 +153,12 @@ class InterfaceMailmanSpipsynchro $return=1; } - return $return; - } - elseif ($action == 'CATEGORY_UNLINK') - { - dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - + return $return; + } + elseif ($action == 'CATEGORY_UNLINK') + { + dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); + // We remove subscription if we change category (lessw category may means less mailing-list to subscribe) if ($object->unlinkoff->del_to_abo() < 0) { From 2591fa95f0ea9fc4f0b86deb56fb895802748578 Mon Sep 17 00:00:00 2001 From: Grand Philippe Date: Mon, 26 Aug 2013 15:07:36 +0200 Subject: [PATCH 2/4] some trad for contract model --- htdocs/langs/fr_FR/contracts.lang | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/langs/fr_FR/contracts.lang b/htdocs/langs/fr_FR/contracts.lang index 3516404f8e7..ae1f56c0a67 100644 --- a/htdocs/langs/fr_FR/contracts.lang +++ b/htdocs/langs/fr_FR/contracts.lang @@ -90,6 +90,7 @@ ListOfServicesToExpireWithDuration=Liste des services actifs expirant dans %s jo ListOfServicesToExpireWithDurationNeg=Liste des services actifs expiré depuis plus de %s jours ListOfServicesToExpire=Liste des services actifs en expiration NoteListOfYourExpiredServices=Cette list ne contient que les contrats de services des tiers pour lesquels vous êtes liés comme représentant commercial. +DocumentModelStandard=Modèle de contrat standard ##### Types de contacts ##### TypeContact_contrat_internal_SALESREPSIGN=Commercial signataire du contrat From 24e6042378146a43f778448c28c3e5a4f28d1993 Mon Sep 17 00:00:00 2001 From: Grand Philippe Date: Mon, 26 Aug 2013 15:32:56 +0200 Subject: [PATCH 3/4] some fix for contract model --- htdocs/core/modules/contract/modules_contract.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/htdocs/core/modules/contract/modules_contract.php b/htdocs/core/modules/contract/modules_contract.php index 1df45d7e009..341aa4daefc 100644 --- a/htdocs/core/modules/contract/modules_contract.php +++ b/htdocs/core/modules/contract/modules_contract.php @@ -154,10 +154,10 @@ class ModelNumRefContracts * @param int $hideref Hide ref * @return int 0 if KO, 1 if OK */ -function contract_create($db, $object, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0) +function contract_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0) { - global $conf,$langs,$user; - $langs->load("contract"); + global $conf,$langs,$user,$hookmanager; + $langs->load("contracts"); $error=0; @@ -223,6 +223,9 @@ function contract_create($db, $object, $modele, $outputlangs, $hidedetails=0, $h // We delete old preview require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; dol_delete_preview($object); + + // Success in building document. We build meta file. + dol_meta_create($object); // Appel des triggers include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; From ed31c83fbbb9b8aca54ecf351ce54702f3c3007e Mon Sep 17 00:00:00 2001 From: Grand Philippe Date: Mon, 26 Aug 2013 15:42:01 +0200 Subject: [PATCH 4/4] some fix for contract model --- htdocs/contrat/class/contrat.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 4575f43592d..b9a2de433ef 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -88,7 +88,7 @@ class Contrat extends CommonObject function getNextNumRef($soc) { global $db, $langs, $conf; - $langs->load("contract"); + $langs->load("contracts"); $dir = DOL_DOCUMENT_ROOT . "/core/modules/contract";