浏览代码

some fix for contract model and clean code

Grand Philippe 11 年之前
父节点
当前提交
7a64ad1a26

+ 191 - 188
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='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
@@ -244,84 +226,90 @@ print "</tr>\n";
 
 clearstatcache();
 
-$dir = "../core/modules/contract/";
-$handle = opendir($dir);
-if (is_resource($handle))
+foreach ($dirmodels as $reldir)
 {
-    $var=true;
-
-    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);
-
-            require_once DOL_DOCUMENT_ROOT ."/core/modules/contract/".$file.'.php';
+	$dir = dol_buildpath($reldir."core/modules/contract/");
 
-            $module = new $file;
-
-            // 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;
-
-            if ($module->isEnabled())
-            {
-                $var=!$var;
-                print '<tr '.$bc[$var].'><td>'.$module->nom."</td>\n";
-                print '<td>';
-                print $module->info();
-                print '</td>';
-
-                // Show example of numbering model
-                print '<td class="nowrap">';
-                $tmp=$module->getExample();
-                if (preg_match('/^Error/',$tmp)) { $langs->load("errors"); print '<div class="error">'.$langs->trans($tmp).'</div>'; }
-                elseif ($tmp=='NotConfigured') print $langs->trans($tmp);
-                else print $tmp;
-                print '</td>'."\n";
-
-                print '<td align="center">';
-                if ($conf->global->CONTRACT_ADDON == "$file")
-                {
-                    print img_picto($langs->trans("Activated"),'switch_on');
-                }
-                else
-                {
-                    print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&amp;value='.$file.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'">';
-                    print img_picto($langs->trans("Disabled"),'switch_off');
-                    print '</a>';
-                }
-                print '</td>';
-
-                $contract=new Contrat($db);
-                $contract->initAsSpecimen();
-
-                // Info
-                $htmltooltip='';
-                $htmltooltip.=''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
-                $nextval=$module->getNextValue($mysoc,$contract);
-                if ("$nextval" != $langs->trans("NotAvailable"))	// Keep " on nextval
-                {
-                    $htmltooltip.=''.$langs->trans("NextValue").': ';
-                    if ($nextval)
-                    {
-                        $htmltooltip.=$nextval.'<br>';
-                    }
-                    else
-                    {
-                        $htmltooltip.=$langs->trans($module->error).'<br>';
-                    }
-                }
-
-                print '<td align="center">';
-                print $form->textwithpicto('',$htmltooltip,1,0);
-                print '</td>';
-
-                print '</tr>';
-            }
-        }
-    }
-    closedir($handle);
+	if (is_dir($dir))
+	{
+		$handle = opendir($dir);
+		if (is_resource($handle))
+		{
+			$var=true;
+
+			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);
+
+					require_once $dir.$file.'.php';
+
+					$module = new $file($db);
+
+					// 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;
+
+					if ($module->isEnabled())
+					{
+						$var=!$var;
+						print '<tr '.$bc[$var].'><td>'.$module->nom."</td><td>\n";
+						print $module->info();
+						print '</td>';
+
+						// Show example of numbering model
+						print '<td class="nowrap">';
+						$tmp=$module->getExample();
+						if (preg_match('/^Error/',$tmp)) { $langs->load("errors"); print '<div class="error">'.$langs->trans($tmp).'</div>'; }
+						elseif ($tmp=='NotConfigured') print $langs->trans($tmp);
+						else print $tmp;
+						print '</td>'."\n";
+
+						print '<td align="center">';
+						if ($conf->global->CONTRACT_ADDON == "$file")
+						{
+							print img_picto($langs->trans("Activated"),'switch_on');
+						}
+						else
+						{
+							print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&amp;value='.$file.'">';
+							print img_picto($langs->trans("Disabled"),'switch_off');
+							print '</a>';
+						}
+						print '</td>';
+
+						$contract=new Contrat($db);
+						$contract->initAsSpecimen();
+
+						// Info
+						$htmltooltip='';
+						$htmltooltip.=''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
+						$nextval=$module->getNextValue($mysoc,$contract);
+						if ("$nextval" != $langs->trans("NotAvailable"))	// Keep " on nextval
+						{
+							$htmltooltip.=''.$langs->trans("NextValue").': ';
+							if ($nextval)
+							{
+								$htmltooltip.=$nextval.'<br>';
+							}
+							else
+							{
+								$htmltooltip.=$langs->trans($module->error).'<br>';
+							}
+						}
+
+						print '<td align="center">';
+						print $form->textwithpicto('',$htmltooltip,1,0);
+						print '</td>';
+
+						print '</tr>';
+					}
+				}
+			}
+			closedir($handle);
+		}
+	}
 }
 
 print '</table><br>';
@@ -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);
-
-		    		$var=!$var;
-
-		    		print '<tr '.$bc[$var].'><td>';
-		    		echo "$name";
-		    		print "</td><td>\n";
-		    		require_once $dir.$file;
-		    		$module = new $classname($db);
-		    		print $module->description;
-		    		print '</td>';
-
-		    		// Active
-		    		if (in_array($name, $def))
-		    		{
-		    			print "<td align=\"center\">\n";
-		    			print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'">';
-		    			print img_picto($langs->trans("Enabled"),'switch_on');
-		    			print '</a>';
-		    			print "</td>";
-		    		}
-		    		else
-		    		{
-		    			print "<td align=\"center\">\n";
-		    			print '<a href="'.$_SERVER["PHP_SELF"].'?action=set&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';
-		    			print "</td>";
-		    		}
-
-		    		// Default
-		    		print "<td align=\"center\">";
-		    		if ($conf->global->CONTRACT_ADDON_PDF == "$name")
-		    		{
-		    			print img_picto($langs->trans("Default"),'on');
-		    		}
-		    		else
-		    		{
-		    			print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').'</a>';
-		    		}
-		    		print '</td>';
-
-		    		// Info
-		    		$htmltooltip =    ''.$langs->trans("Name").': '.$module->name;
-		    		$htmltooltip.='<br>'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown"));
-		    		$htmltooltip.='<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
-		    		$htmltooltip.='<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
-		    		$htmltooltip.='<br>'.$langs->trans("Logo").': '.yn($module->option_logo,1,1);
-		    		$htmltooltip.='<br>'.$langs->trans("PaymentMode").': '.yn($module->option_modereg,1,1);
-		    		$htmltooltip.='<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg,1,1);
-		    		$htmltooltip.='<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang,1,1);
-		    		$htmltooltip.='<br>'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark,1,1);
-		    		print '<td align="center">';
-		    		print $form->textwithpicto('',$htmltooltip,-1,0);
-		    		print '</td>';
-		    		
-		    		// Preview
-		    		$link='<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"),'contract').'</a>';
-		    		print '<td align="center">';
-		    		print $link;
-		    		print '</td>';
-
-		    		print '</tr>';
-		    	}
-		    }
-		    closedir($handle);
-		}
-	}
+        if (is_dir($dir))
+        {
+            $handle=opendir($dir);
+            if (is_resource($handle))
+            {
+                while (($file = readdir($handle))!==false)
+                {
+                    $filelist[]=$file;
+                }
+                closedir($handle);
+                arsort($filelist);
+
+                foreach($filelist as $file)
+                {
+                    if (preg_match('/\.modules\.php$/i',$file) && preg_match('/^(pdf_|doc_)/',$file))
+                    {
+
+                    	if (file_exists($dir.'/'.$file))
+                    	{
+                    		$name = substr($file, 4, dol_strlen($file) -16);
+	                        $classname = substr($file, 0, dol_strlen($file) -12);
+
+	                        require_once $dir.'/'.$file;
+	                        $module = new $classname($db);
+
+	                        $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;
+
+	                        if ($modulequalified)
+	                        {
+	                            $var = !$var;
+	                            print '<tr '.$bc[$var].'><td width="100">';
+	                            print (empty($module->name)?$name:$module->name);
+	                            print "</td><td>\n";
+	                            if (method_exists($module,'info')) print $module->info($langs);
+	                            else print $module->description;
+	                            print '</td>';
+
+	                            // Active
+	                            if (in_array($name, $def))
+	                            {
+	                            	print '<td align="center">'."\n";
+	                            	print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'">';
+	                            	print img_picto($langs->trans("Enabled"),'switch_on');
+	                            	print '</a>';
+	                            	print '</td>';
+	                            }
+	                            else
+	                            {
+	                                print '<td align="center">'."\n";
+	                                print '<a href="'.$_SERVER["PHP_SELF"].'?action=set&value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';
+	                                print "</td>";
+	                            }
+
+	                            // Defaut
+	                            print '<td align="center">';
+	                            if ($conf->global->CONTRACT_ADDON_PDF == $name)
+	                            {
+	                                print img_picto($langs->trans("Default"),'on');
+	                            }
+	                            else
+	                            {
+	                                print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').'</a>';
+	                            }
+	                            print '</td>';
+
+	                           // Info
+		    					$htmltooltip =    ''.$langs->trans("Name").': '.$module->name;
+					    		$htmltooltip.='<br>'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown"));
+			                    if ($module->type == 'pdf')
+			                    {
+			                        $htmltooltip.='<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
+			                    }
+					    		$htmltooltip.='<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
+					    		$htmltooltip.='<br>'.$langs->trans("Logo").': '.yn($module->option_logo,1,1);
+					    		$htmltooltip.='<br>'.$langs->trans("PaymentMode").': '.yn($module->option_modereg,1,1);
+					    		$htmltooltip.='<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg,1,1);
+					    		$htmltooltip.='<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang,1,1);
+					    		$htmltooltip.='<br>'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark,1,1);
+
+
+	                            print '<td align="center">';
+	                            print $form->textwithpicto('',$htmltooltip,1,0);
+	                            print '</td>';
+
+	                            // Preview
+	                            print '<td align="center">';
+	                            if ($module->type == 'pdf')
+	                            {
+	                                print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"),'contract').'</a>';
+	                            }
+	                            else
+	                            {
+	                                print img_object($langs->trans("PreviewNotAvailable"),'generic');
+	                            }
+	                            print '</td>';
+
+	                            print "</tr>\n";
+	                        }
+                    	}
+                    }
+                }
+            }
+        }
+    }
 }
 
 print '</table>';
@@ -492,25 +512,8 @@ print '<input size="50" class="flat" type="text" name="CONTRAT_DRAFT_WATERMARK"
 print '</td><td align="right">';
 print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
 print "</td></tr>\n";
-
-// print products on fichinter
-$var=! $var;
-print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
-print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
-print '<input type="hidden" name="action" value="set_CONTRAT_PRINT_PRODUCTS">';
-print '<tr '.$bc[$var].'><td>';
-print $langs->trans("PrintProductsOnContract").' ('.$langs->trans("PrintProductsOnContractDetails").')</td>';
-print '<td align="center"><input type="checkbox" name="CONTRAT_PRINT_PRODUCTS" ';
-if ($conf->global->CONTRAT_PRINT_PRODUCTS)
-	print 'checked="checked" ';
-print '/>';
-print '</td><td align="right">';
-print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
-print "</td></tr>\n";
-
 print '</form>';
 
-
 print '</table>';
 
 print '<br>';

+ 2 - 2
htdocs/core/menus/standard/auguria_menu.php

@@ -214,8 +214,8 @@ class MenuManager
 						print str_pad('',1).'<li data-role="list-divider" class="lilevel1 ui-btn-icon-right ui-btn">';	 // ui-btn to highlight on clic
 						print '<a href="'.$relurl.'">';
 						print str_pad('',12,'&nbsp;');
-						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 '</a>';
 						print '</li>'."\n";
         			}

+ 1 - 1
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");

+ 6 - 6
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)
         	{