Passed
Push — master ( 222e44...208bd5 )
by Alxarafe
31:22
created
dolibarr/htdocs/core/modules/modPrelevement.class.php 2 patches
Indentation   +113 added lines, -113 removed lines patch added patch discarded remove patch
@@ -35,94 +35,94 @@  discard block
 block discarded – undo
35 35
 class modPrelevement extends DolibarrModules
36 36
 {
37 37
 
38
-	/**
39
-	 *   Constructor. Define names, constants, directories, boxes, permissions
40
-	 *
41
-	 *   @param      DoliDB		$db      Database handler
42
-	 */
43
-	function __construct($db)
44
-	{
45
-		global $conf;
46
-
47
-		$this->db = $db;
48
-		$this->numero = 57;
49
-
50
-		$this->family = "financial";
51
-		$this->module_position = '52';
52
-		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
53
-		$this->name = preg_replace('/^mod/i','',get_class($this));
54
-		$this->description = "Gestion des Prelevements";
55
-
56
-		// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
57
-		$this->version = 'dolibarr';
58
-
59
-		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
60
-		// Name of png file (without png) used for this module
61
-		$this->picto='payment';
62
-
63
-		// Data directories to create when module is enabled
64
-		$this->dirs = array("/prelevement/temp","/prelevement/receipts");
65
-
66
-		// Dependencies
67
-		$this->hidden = false;			// A condition to hide module
68
-		$this->depends = array("modFacture","modBanque");		// List of module class names as string that must be enabled if this module is enabled
69
-		$this->requiredby = array();	// List of module ids to disable if this one is disabled
70
-		$this->conflictwith = array();	// List of module class names as string this module is in conflict with
71
-		$this->phpmin = array(5,4);		// Minimum version of PHP required by module
72
-
73
-		// Config pages
74
-		$this->config_page_url = array("prelevement.php");
75
-
76
-		// Constants
77
-		$this->const = array();
78
-		$r=0;
79
-
80
-		$this->const[$r][0] = "BANK_ADDON_PDF";
81
-		$this->const[$r][1] = "chaine";
82
-		$this->const[$r][2] = "sepamandate";
83
-		$this->const[$r][3] = 'Name of manager to generate SEPA mandate';
84
-		$this->const[$r][4] = 0;
85
-		$r++;
86
-
87
-
88
-		// Boxes
89
-		$this->boxes = array();
90
-
91
-		// Permissions
92
-		$this->rights = array();
93
-		$this->rights_class = 'prelevement';
94
-		$r=0;
95
-		$r++;
96
-		$this->rights[$r][0] = 151;
97
-		$this->rights[$r][1] = 'Read direct debit payment orders';
98
-		$this->rights[$r][2] = 'r';
99
-		$this->rights[$r][3] = 0;
100
-		$this->rights[$r][4] = 'bons';
101
-		$this->rights[$r][5] = 'lire';
102
-
103
-		$r++;
104
-		$this->rights[$r][0] = 152;
105
-		$this->rights[$r][1] = 'Create/modify a direct debit payment order';
106
-		$this->rights[$r][2] = 'w';
107
-		$this->rights[$r][3] = 0;
108
-		$this->rights[$r][4] = 'bons';
109
-		$this->rights[$r][5] = 'creer';
110
-
111
-		$r++;
112
-		$this->rights[$r][0] = 153;
113
-		$this->rights[$r][1] = 'Send/Transmit direct debit payment orders';
114
-		$this->rights[$r][2] = 'a';
115
-		$this->rights[$r][3] = 0;
116
-		$this->rights[$r][4] = 'bons';
117
-		$this->rights[$r][5] = 'send';
118
-
119
-		$r++;
120
-		$this->rights[$r][0] = 154;
121
-		$this->rights[$r][1] = 'Record Credits/Rejects of direct debit payment orders';
122
-		$this->rights[$r][2] = 'a';
123
-		$this->rights[$r][3] = 0;
124
-		$this->rights[$r][4] = 'bons';
125
-		$this->rights[$r][5] = 'credit';
38
+    /**
39
+     *   Constructor. Define names, constants, directories, boxes, permissions
40
+     *
41
+     *   @param      DoliDB		$db      Database handler
42
+     */
43
+    function __construct($db)
44
+    {
45
+        global $conf;
46
+
47
+        $this->db = $db;
48
+        $this->numero = 57;
49
+
50
+        $this->family = "financial";
51
+        $this->module_position = '52';
52
+        // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
53
+        $this->name = preg_replace('/^mod/i','',get_class($this));
54
+        $this->description = "Gestion des Prelevements";
55
+
56
+        // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
57
+        $this->version = 'dolibarr';
58
+
59
+        $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
60
+        // Name of png file (without png) used for this module
61
+        $this->picto='payment';
62
+
63
+        // Data directories to create when module is enabled
64
+        $this->dirs = array("/prelevement/temp","/prelevement/receipts");
65
+
66
+        // Dependencies
67
+        $this->hidden = false;			// A condition to hide module
68
+        $this->depends = array("modFacture","modBanque");		// List of module class names as string that must be enabled if this module is enabled
69
+        $this->requiredby = array();	// List of module ids to disable if this one is disabled
70
+        $this->conflictwith = array();	// List of module class names as string this module is in conflict with
71
+        $this->phpmin = array(5,4);		// Minimum version of PHP required by module
72
+
73
+        // Config pages
74
+        $this->config_page_url = array("prelevement.php");
75
+
76
+        // Constants
77
+        $this->const = array();
78
+        $r=0;
79
+
80
+        $this->const[$r][0] = "BANK_ADDON_PDF";
81
+        $this->const[$r][1] = "chaine";
82
+        $this->const[$r][2] = "sepamandate";
83
+        $this->const[$r][3] = 'Name of manager to generate SEPA mandate';
84
+        $this->const[$r][4] = 0;
85
+        $r++;
86
+
87
+
88
+        // Boxes
89
+        $this->boxes = array();
90
+
91
+        // Permissions
92
+        $this->rights = array();
93
+        $this->rights_class = 'prelevement';
94
+        $r=0;
95
+        $r++;
96
+        $this->rights[$r][0] = 151;
97
+        $this->rights[$r][1] = 'Read direct debit payment orders';
98
+        $this->rights[$r][2] = 'r';
99
+        $this->rights[$r][3] = 0;
100
+        $this->rights[$r][4] = 'bons';
101
+        $this->rights[$r][5] = 'lire';
102
+
103
+        $r++;
104
+        $this->rights[$r][0] = 152;
105
+        $this->rights[$r][1] = 'Create/modify a direct debit payment order';
106
+        $this->rights[$r][2] = 'w';
107
+        $this->rights[$r][3] = 0;
108
+        $this->rights[$r][4] = 'bons';
109
+        $this->rights[$r][5] = 'creer';
110
+
111
+        $r++;
112
+        $this->rights[$r][0] = 153;
113
+        $this->rights[$r][1] = 'Send/Transmit direct debit payment orders';
114
+        $this->rights[$r][2] = 'a';
115
+        $this->rights[$r][3] = 0;
116
+        $this->rights[$r][4] = 'bons';
117
+        $this->rights[$r][5] = 'send';
118
+
119
+        $r++;
120
+        $this->rights[$r][0] = 154;
121
+        $this->rights[$r][1] = 'Record Credits/Rejects of direct debit payment orders';
122
+        $this->rights[$r][2] = 'a';
123
+        $this->rights[$r][3] = 0;
124
+        $this->rights[$r][4] = 'bons';
125
+        $this->rights[$r][5] = 'credit';
126 126
 
127 127
 /*        $this->rights[2][0] = 154;
128 128
         $this->rights[2][1] = 'Setup withdraw account';
@@ -132,32 +132,32 @@  discard block
 block discarded – undo
132 132
         $this->rights[2][5] = 'configurer';
133 133
 */
134 134
 
135
-		// Menus
136
-		//-------
137
-		$this->menu = 1;        // This module add menu entries. They are coded into menu manager.
138
-	}
135
+        // Menus
136
+        //-------
137
+        $this->menu = 1;        // This module add menu entries. They are coded into menu manager.
138
+    }
139 139
 
140 140
 
141
-	/**
142
-	 *		Function called when module is enabled.
143
-	 *		The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
144
-	 *		It also creates data directories
145
-	 *
141
+    /**
142
+     *		Function called when module is enabled.
143
+     *		The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
144
+     *		It also creates data directories
145
+     *
146 146
      *      @param      string	$options    Options when enabling module ('', 'noboxes')
147
-	 *      @return     int             	1 if OK, 0 if KO
148
-	 */
149
-	function init($options='')
150
-	{
151
-		global $conf;
152
-
153
-		// Permissions
154
-		$this->remove($options);
155
-
156
-		$sql = array(
157
-		    "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'bankaccount' AND entity = ".$conf->entity,
158
-		    "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','bankaccount',".$conf->entity.")",
159
-		);
160
-
161
-		return $this->_init($sql,$options);
162
-	}
147
+     *      @return     int             	1 if OK, 0 if KO
148
+     */
149
+    function init($options='')
150
+    {
151
+        global $conf;
152
+
153
+        // Permissions
154
+        $this->remove($options);
155
+
156
+        $sql = array(
157
+            "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'bankaccount' AND entity = ".$conf->entity,
158
+            "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','bankaccount',".$conf->entity.")",
159
+        );
160
+
161
+        return $this->_init($sql,$options);
162
+    }
163 163
 }
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
  *	\brief      	Fichier de description et activation du module Prelevement
27 27
  */
28 28
 
29
-include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
29
+include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
30 30
 
31 31
 
32 32
 /**
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 		$this->family = "financial";
51 51
 		$this->module_position = '52';
52 52
 		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
53
-		$this->name = preg_replace('/^mod/i','',get_class($this));
53
+		$this->name = preg_replace('/^mod/i', '', get_class($this));
54 54
 		$this->description = "Gestion des Prelevements";
55 55
 
56 56
 		// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
@@ -58,24 +58,24 @@  discard block
 block discarded – undo
58 58
 
59 59
 		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
60 60
 		// Name of png file (without png) used for this module
61
-		$this->picto='payment';
61
+		$this->picto = 'payment';
62 62
 
63 63
 		// Data directories to create when module is enabled
64
-		$this->dirs = array("/prelevement/temp","/prelevement/receipts");
64
+		$this->dirs = array("/prelevement/temp", "/prelevement/receipts");
65 65
 
66 66
 		// Dependencies
67
-		$this->hidden = false;			// A condition to hide module
68
-		$this->depends = array("modFacture","modBanque");		// List of module class names as string that must be enabled if this module is enabled
69
-		$this->requiredby = array();	// List of module ids to disable if this one is disabled
70
-		$this->conflictwith = array();	// List of module class names as string this module is in conflict with
71
-		$this->phpmin = array(5,4);		// Minimum version of PHP required by module
67
+		$this->hidden = false; // A condition to hide module
68
+		$this->depends = array("modFacture", "modBanque"); // List of module class names as string that must be enabled if this module is enabled
69
+		$this->requiredby = array(); // List of module ids to disable if this one is disabled
70
+		$this->conflictwith = array(); // List of module class names as string this module is in conflict with
71
+		$this->phpmin = array(5, 4); // Minimum version of PHP required by module
72 72
 
73 73
 		// Config pages
74 74
 		$this->config_page_url = array("prelevement.php");
75 75
 
76 76
 		// Constants
77 77
 		$this->const = array();
78
-		$r=0;
78
+		$r = 0;
79 79
 
80 80
 		$this->const[$r][0] = "BANK_ADDON_PDF";
81 81
 		$this->const[$r][1] = "chaine";
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 		// Permissions
92 92
 		$this->rights = array();
93 93
 		$this->rights_class = 'prelevement';
94
-		$r=0;
94
+		$r = 0;
95 95
 		$r++;
96 96
 		$this->rights[$r][0] = 151;
97 97
 		$this->rights[$r][1] = 'Read direct debit payment orders';
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 
135 135
 		// Menus
136 136
 		//-------
137
-		$this->menu = 1;        // This module add menu entries. They are coded into menu manager.
137
+		$this->menu = 1; // This module add menu entries. They are coded into menu manager.
138 138
 	}
139 139
 
140 140
 
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
      *      @param      string	$options    Options when enabling module ('', 'noboxes')
147 147
 	 *      @return     int             	1 if OK, 0 if KO
148 148
 	 */
149
-	function init($options='')
149
+	function init($options = '')
150 150
 	{
151 151
 		global $conf;
152 152
 
@@ -158,6 +158,6 @@  discard block
 block discarded – undo
158 158
 		    "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','bankaccount',".$conf->entity.")",
159 159
 		);
160 160
 
161
-		return $this->_init($sql,$options);
161
+		return $this->_init($sql, $options);
162 162
 	}
163 163
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php 3 patches
Indentation   +404 added lines, -404 removed lines patch added patch discarded remove patch
@@ -36,409 +36,409 @@  discard block
 block discarded – undo
36 36
  */
37 37
 class doc_generic_user_odt extends ModelePDFUser
38 38
 {
39
-	/**
40
-	 * Issuer
41
-	 * @var Societe
42
-	 */
43
-	public $emetteur;
44
-
45
-	/**
46
-   * @var array() Minimum version of PHP required by module.
47
-	 * e.g.: PHP ≥ 5.4 = array(5, 4)
48
-   */
49
-	public $phpmin = array(5, 4);
50
-
51
-	/**
52
-   * Dolibarr version of the loaded document
53
-   * @public string
54
-   */
55
-	public $version = 'dolibarr';
56
-
57
-
58
-	/**
59
-	 *	Constructor
60
-	 *
61
-	 *  @param		DoliDB		$db      Database handler
62
-	 */
63
-	function __construct($db)
64
-	{
65
-		global $conf, $langs, $mysoc;
66
-
67
-		// Load translation files required by the page
39
+    /**
40
+     * Issuer
41
+     * @var Societe
42
+     */
43
+    public $emetteur;
44
+
45
+    /**
46
+     * @var array() Minimum version of PHP required by module.
47
+     * e.g.: PHP ≥ 5.4 = array(5, 4)
48
+     */
49
+    public $phpmin = array(5, 4);
50
+
51
+    /**
52
+     * Dolibarr version of the loaded document
53
+     * @public string
54
+     */
55
+    public $version = 'dolibarr';
56
+
57
+
58
+    /**
59
+     *	Constructor
60
+     *
61
+     *  @param		DoliDB		$db      Database handler
62
+     */
63
+    function __construct($db)
64
+    {
65
+        global $conf, $langs, $mysoc;
66
+
67
+        // Load translation files required by the page
68 68
     $langs->loadLangs(array("main","companies"));
69 69
 
70
-		$this->db = $db;
71
-		$this->name = "ODT templates";
72
-		$this->description = $langs->trans("DocumentModelOdt");
73
-		$this->scandir = 'USER_ADDON_PDF_ODT_PATH';	// Name of constant that is used to save list of directories to scan
74
-
75
-		// Dimension page pour format A4
76
-		$this->type = 'odt';
77
-		$this->page_largeur = 0;
78
-		$this->page_hauteur = 0;
79
-		$this->format = array($this->page_largeur,$this->page_hauteur);
80
-		$this->marge_gauche=0;
81
-		$this->marge_droite=0;
82
-		$this->marge_haute=0;
83
-		$this->marge_basse=0;
84
-
85
-		$this->option_logo = 1;                    // Affiche logo
86
-		$this->option_tva = 0;                     // Gere option tva USER_TVAOPTION
87
-		$this->option_modereg = 0;                 // Affiche mode reglement
88
-		$this->option_condreg = 0;                 // Affiche conditions reglement
89
-		$this->option_codeproduitservice = 0;      // Affiche code produit-service
90
-		$this->option_multilang = 1;               // Dispo en plusieurs langues
91
-		$this->option_escompte = 0;                // Affiche si il y a eu escompte
92
-		$this->option_credit_note = 0;             // Support credit notes
93
-		$this->option_freetext = 1;				   // Support add of a personalised text
94
-		$this->option_draft_watermark = 0;		   // Support add of a watermark on drafts
95
-
96
-		// Recupere emetteur
97
-		$this->emetteur=$mysoc;
98
-		if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
99
-	}
100
-
101
-
102
-	/**
103
-	 *	Return description of a module
104
-	 *
105
-	 *	@param	Translate	$langs      Lang object to use for output
106
-	 *	@return string       			Description
107
-	 */
108
-	function info($langs)
109
-	{
110
-		global $conf, $langs;
111
-
112
-		// Load translation files required by the page
70
+        $this->db = $db;
71
+        $this->name = "ODT templates";
72
+        $this->description = $langs->trans("DocumentModelOdt");
73
+        $this->scandir = 'USER_ADDON_PDF_ODT_PATH';	// Name of constant that is used to save list of directories to scan
74
+
75
+        // Dimension page pour format A4
76
+        $this->type = 'odt';
77
+        $this->page_largeur = 0;
78
+        $this->page_hauteur = 0;
79
+        $this->format = array($this->page_largeur,$this->page_hauteur);
80
+        $this->marge_gauche=0;
81
+        $this->marge_droite=0;
82
+        $this->marge_haute=0;
83
+        $this->marge_basse=0;
84
+
85
+        $this->option_logo = 1;                    // Affiche logo
86
+        $this->option_tva = 0;                     // Gere option tva USER_TVAOPTION
87
+        $this->option_modereg = 0;                 // Affiche mode reglement
88
+        $this->option_condreg = 0;                 // Affiche conditions reglement
89
+        $this->option_codeproduitservice = 0;      // Affiche code produit-service
90
+        $this->option_multilang = 1;               // Dispo en plusieurs langues
91
+        $this->option_escompte = 0;                // Affiche si il y a eu escompte
92
+        $this->option_credit_note = 0;             // Support credit notes
93
+        $this->option_freetext = 1;				   // Support add of a personalised text
94
+        $this->option_draft_watermark = 0;		   // Support add of a watermark on drafts
95
+
96
+        // Recupere emetteur
97
+        $this->emetteur=$mysoc;
98
+        if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
99
+    }
100
+
101
+
102
+    /**
103
+     *	Return description of a module
104
+     *
105
+     *	@param	Translate	$langs      Lang object to use for output
106
+     *	@return string       			Description
107
+     */
108
+    function info($langs)
109
+    {
110
+        global $conf, $langs;
111
+
112
+        // Load translation files required by the page
113 113
         $langs->loadLangs(array('companies', 'errors'));
114 114
 
115
-		$form = new Form($this->db);
116
-
117
-		$texte = $this->description.".<br>\n";
118
-		$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
119
-		$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
120
-		$texte.= '<input type="hidden" name="action" value="setModuleOptions">';
121
-		$texte.= '<input type="hidden" name="param1" value="USER_ADDON_PDF_ODT_PATH">';
122
-		if ($conf->global->MAIN_PROPAL_CHOOSE_ODT_DOCUMENT > 0)
123
-		{
124
-			$texte.= '<input type="hidden" name="param2" value="USER_ADDON_PDF_ODT_DEFAULT">';
125
-			$texte.= '<input type="hidden" name="param3" value="USER_ADDON_PDF_ODT_TOBILL">';
126
-			$texte.= '<input type="hidden" name="param4" value="USER_ADDON_PDF_ODT_CLOSED">';
127
-		}
128
-		$texte.= '<table class="nobordernopadding" width="100%">';
129
-
130
-		// List of directories area
131
-		$texte.= '<tr><td>';
132
-		$texttitle=$langs->trans("ListOfDirectories");
133
-		$listofdir=explode(',',preg_replace('/[\r\n]+/',',',trim($conf->global->USER_ADDON_PDF_ODT_PATH)));
134
-		$listoffiles=array();
135
-		foreach($listofdir as $key=>$tmpdir)
136
-		{
137
-			$tmpdir=trim($tmpdir);
138
-			$tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir);
139
-			if (! $tmpdir) {
140
-				unset($listofdir[$key]); continue;
141
-			}
142
-			if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
143
-			else
144
-			{
145
-				$tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)');
146
-				if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles);
147
-			}
148
-		}
149
-		$texthelp=$langs->trans("ListOfDirectoriesForModelGenODT");
150
-		// Add list of substitution keys
151
-		$texthelp.='<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
152
-		$texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation");    // This contains an url, we don't modify it
153
-
154
-		$texte.= $form->textwithpicto($texttitle,$texthelp,1,'help','',1);
155
-		$texte.= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
156
-		$texte.= '<textarea class="flat" cols="60" name="value1">';
157
-		$texte.=$conf->global->USER_ADDON_PDF_ODT_PATH;
158
-		$texte.= '</textarea>';
159
-		$texte.= '</div><div style="display: inline-block; vertical-align: middle;">';
160
-		$texte.= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
161
-		$texte.= '<br></div></div>';
162
-
163
-		// Scan directories
164
-		if (count($listofdir))
165
-		{
166
-			$texte.=$langs->trans("NumberOfModelFilesFound").': <b>'.count($listoffiles).'</b>';
167
-
168
-			if ($conf->global->MAIN_PROPAL_CHOOSE_ODT_DOCUMENT > 0)
169
-			{
170
-				// Model for creation
171
-				$liste=ModelePDFUser::liste_modeles($this->db);
172
-				$texte.= '<table width="50%;">';
173
-				$texte.= '<tr>';
174
-				$texte.= '<td width="60%;">'.$langs->trans("DefaultModelPropalCreate").'</td>';
175
-				$texte.= '<td colspan="">';
176
-				$texte.= $form->selectarray('value2',$liste,$conf->global->USER_ADDON_PDF_ODT_DEFAULT);
177
-				$texte.= "</td></tr>";
178
-
179
-				$texte.= '<tr>';
180
-				$texte.= '<td width="60%;">'.$langs->trans("DefaultModelPropalToBill").'</td>';
181
-				$texte.= '<td colspan="">';
182
-				$texte.= $form->selectarray('value3',$liste,$conf->global->USER_ADDON_PDF_ODT_TOBILL);
183
-				$texte.= "</td></tr>";
184
-				$texte.= '<tr>';
185
-
186
-				$texte.= '<td width="60%;">'.$langs->trans("DefaultModelPropalClosed").'</td>';
187
-				$texte.= '<td colspan="">';
188
-				$texte.= $form->selectarray('value4',$liste,$conf->global->USER_ADDON_PDF_ODT_CLOSED);
189
-				$texte.= "</td></tr>";
190
-				$texte.= '</table>';
191
-			}
192
-		}
193
-
194
-		$texte.= '</td>';
195
-
196
-		$texte.= '<td valign="top" rowspan="2" class="hideonsmartphone">';
197
-		$texte.= $langs->trans("ExampleOfDirectoriesForModelGen");
198
-		$texte.= '</td>';
199
-		$texte.= '</tr>';
200
-
201
-		$texte.= '</table>';
202
-		$texte.= '</form>';
203
-
204
-		return $texte;
205
-	}
115
+        $form = new Form($this->db);
116
+
117
+        $texte = $this->description.".<br>\n";
118
+        $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
119
+        $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
120
+        $texte.= '<input type="hidden" name="action" value="setModuleOptions">';
121
+        $texte.= '<input type="hidden" name="param1" value="USER_ADDON_PDF_ODT_PATH">';
122
+        if ($conf->global->MAIN_PROPAL_CHOOSE_ODT_DOCUMENT > 0)
123
+        {
124
+            $texte.= '<input type="hidden" name="param2" value="USER_ADDON_PDF_ODT_DEFAULT">';
125
+            $texte.= '<input type="hidden" name="param3" value="USER_ADDON_PDF_ODT_TOBILL">';
126
+            $texte.= '<input type="hidden" name="param4" value="USER_ADDON_PDF_ODT_CLOSED">';
127
+        }
128
+        $texte.= '<table class="nobordernopadding" width="100%">';
129
+
130
+        // List of directories area
131
+        $texte.= '<tr><td>';
132
+        $texttitle=$langs->trans("ListOfDirectories");
133
+        $listofdir=explode(',',preg_replace('/[\r\n]+/',',',trim($conf->global->USER_ADDON_PDF_ODT_PATH)));
134
+        $listoffiles=array();
135
+        foreach($listofdir as $key=>$tmpdir)
136
+        {
137
+            $tmpdir=trim($tmpdir);
138
+            $tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir);
139
+            if (! $tmpdir) {
140
+                unset($listofdir[$key]); continue;
141
+            }
142
+            if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
143
+            else
144
+            {
145
+                $tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)');
146
+                if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles);
147
+            }
148
+        }
149
+        $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT");
150
+        // Add list of substitution keys
151
+        $texthelp.='<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
152
+        $texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation");    // This contains an url, we don't modify it
153
+
154
+        $texte.= $form->textwithpicto($texttitle,$texthelp,1,'help','',1);
155
+        $texte.= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
156
+        $texte.= '<textarea class="flat" cols="60" name="value1">';
157
+        $texte.=$conf->global->USER_ADDON_PDF_ODT_PATH;
158
+        $texte.= '</textarea>';
159
+        $texte.= '</div><div style="display: inline-block; vertical-align: middle;">';
160
+        $texte.= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
161
+        $texte.= '<br></div></div>';
162
+
163
+        // Scan directories
164
+        if (count($listofdir))
165
+        {
166
+            $texte.=$langs->trans("NumberOfModelFilesFound").': <b>'.count($listoffiles).'</b>';
167
+
168
+            if ($conf->global->MAIN_PROPAL_CHOOSE_ODT_DOCUMENT > 0)
169
+            {
170
+                // Model for creation
171
+                $liste=ModelePDFUser::liste_modeles($this->db);
172
+                $texte.= '<table width="50%;">';
173
+                $texte.= '<tr>';
174
+                $texte.= '<td width="60%;">'.$langs->trans("DefaultModelPropalCreate").'</td>';
175
+                $texte.= '<td colspan="">';
176
+                $texte.= $form->selectarray('value2',$liste,$conf->global->USER_ADDON_PDF_ODT_DEFAULT);
177
+                $texte.= "</td></tr>";
178
+
179
+                $texte.= '<tr>';
180
+                $texte.= '<td width="60%;">'.$langs->trans("DefaultModelPropalToBill").'</td>';
181
+                $texte.= '<td colspan="">';
182
+                $texte.= $form->selectarray('value3',$liste,$conf->global->USER_ADDON_PDF_ODT_TOBILL);
183
+                $texte.= "</td></tr>";
184
+                $texte.= '<tr>';
185
+
186
+                $texte.= '<td width="60%;">'.$langs->trans("DefaultModelPropalClosed").'</td>';
187
+                $texte.= '<td colspan="">';
188
+                $texte.= $form->selectarray('value4',$liste,$conf->global->USER_ADDON_PDF_ODT_CLOSED);
189
+                $texte.= "</td></tr>";
190
+                $texte.= '</table>';
191
+            }
192
+        }
193
+
194
+        $texte.= '</td>';
195
+
196
+        $texte.= '<td valign="top" rowspan="2" class="hideonsmartphone">';
197
+        $texte.= $langs->trans("ExampleOfDirectoriesForModelGen");
198
+        $texte.= '</td>';
199
+        $texte.= '</tr>';
200
+
201
+        $texte.= '</table>';
202
+        $texte.= '</form>';
203
+
204
+        return $texte;
205
+    }
206 206
 
207 207
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
208
-	/**
209
-	 *	Function to build a document on disk using the generic odt module.
210
-	 *
211
-	 *	@param		User		$object				Object source to build document
212
-	 *	@param		Translate	$outputlangs		Lang output object
213
-	 * 	@param		string		$srctemplatepath	Full path of source filename for generator using a template file
214
-	 *  @param		int			$hidedetails		Do not show line details
215
-	 *  @param		int			$hidedesc			Do not show desc
216
-	 *  @param		int			$hideref			Do not show ref
217
-	 *	@return		int         					1 if OK, <=0 if KO
218
-	 */
219
-	function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0)
220
-	{
208
+    /**
209
+     *	Function to build a document on disk using the generic odt module.
210
+     *
211
+     *	@param		User		$object				Object source to build document
212
+     *	@param		Translate	$outputlangs		Lang output object
213
+     * 	@param		string		$srctemplatepath	Full path of source filename for generator using a template file
214
+     *  @param		int			$hidedetails		Do not show line details
215
+     *  @param		int			$hidedesc			Do not show desc
216
+     *  @param		int			$hideref			Do not show ref
217
+     *	@return		int         					1 if OK, <=0 if KO
218
+     */
219
+    function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0)
220
+    {
221 221
         // phpcs:enable
222
-		global $user, $langs, $conf, $mysoc, $hookmanager;
223
-
224
-		if (empty($srctemplatepath))
225
-		{
226
-			dol_syslog("doc_generic_odt::write_file parameter srctemplatepath empty", LOG_WARNING);
227
-			return -1;
228
-		}
229
-
230
-		// Add odtgeneration hook
231
-		if (! is_object($hookmanager))
232
-		{
233
-			include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
234
-			$hookmanager=new HookManager($this->db);
235
-		}
236
-		$hookmanager->initHooks(array('odtgeneration'));
237
-		global $action;
238
-
239
-		if (! is_object($outputlangs)) $outputlangs=$langs;
240
-		$sav_charset_output=$outputlangs->charset_output;
241
-		$outputlangs->charset_output='UTF-8';
242
-
243
-		// Load translation files required by the page
244
-		$outputlangs->loadLangs(array("main", "companies", "bills", "dict"));
245
-
246
-		if ($conf->user->dir_output)
247
-		{
248
-			// If $object is id instead of object
249
-			if (! is_object($object))
250
-			{
251
-				$id = $object;
252
-				$object = new User($this->db);
253
-				$result=$object->fetch($id);
254
-				if ($result < 0)
255
-				{
256
-					dol_print_error($this->db,$object->error);
257
-					return -1;
258
-				}
259
-			}
260
-
261
-			$dir = $conf->user->dir_output;
262
-			$objectref = dol_sanitizeFileName($object->ref);
263
-			if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
264
-			$file = $dir . "/" . $objectref . ".odt";
265
-
266
-			if (! file_exists($dir))
267
-			{
268
-				if (dol_mkdir($dir) < 0)
269
-				{
270
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
271
-					return -1;
272
-				}
273
-			}
274
-
275
-			if (file_exists($dir))
276
-			{
277
-				//print "srctemplatepath=".$srctemplatepath;	// Src filename
278
-				$newfile=basename($srctemplatepath);
279
-				$newfiletmp=preg_replace('/\.od(t|s)/i','',$newfile);
280
-				$newfiletmp=preg_replace('/template_/i','',$newfiletmp);
281
-				$newfiletmp=preg_replace('/modele_/i','',$newfiletmp);
282
-
283
-				$newfiletmp=$objectref.'_'.$newfiletmp;
284
-
285
-				// Get extension (ods or odt)
286
-				$newfileformat=substr($newfile, strrpos($newfile, '.')+1);
287
-				if ( ! empty($conf->global->MAIN_DOC_USE_TIMING))
288
-				{
289
-				    $format=$conf->global->MAIN_DOC_USE_TIMING;
290
-				    if ($format == '1') $format='%Y%m%d%H%M%S';
291
-					$filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat;
292
-				}
293
-				else
294
-				{
295
-					$filename=$newfiletmp.'.'.$newfileformat;
296
-				}
297
-				$file=$dir.'/'.$filename;
298
-				//print "newdir=".$dir;
299
-				//print "newfile=".$newfile;
300
-				//print "file=".$file;
301
-				//print "conf->user->dir_temp=".$conf->user->dir_temp;
302
-
303
-				dol_mkdir($conf->user->dir_temp);
304
-
305
-
306
-				// If CUSTOMER contact defined on user, we use it
307
-				$usecontact=false;
308
-				$arrayidcontact=$object->getIdContact('external','CUSTOMER');
309
-				if (count($arrayidcontact) > 0)
310
-				{
311
-					$usecontact=true;
312
-					$result=$object->fetch_contact($arrayidcontact[0]);
313
-				}
314
-
315
-				// Recipient name
316
-				if (! empty($usecontact))
317
-				{
318
-					// On peut utiliser le nom de la societe du contact
319
-					if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact;
320
-					else {
321
-                        			$socobject = $object->thirdparty;
322
-                        			// if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use
323
-                        			$contactobject = $object->contact;
324
-                    			}
325
-				}
326
-				else
327
-				{
328
-					$socobject=$object->thirdparty;
329
-				}
330
-
331
-				// Open and load template
332
-				require_once ODTPHP_PATH.'odf.php';
333
-				try {
334
-					$odfHandler = new odf(
335
-						$srctemplatepath,
336
-						array(
337
-							'PATH_TO_TMP'	  => $conf->user->dir_temp,
338
-							'ZIP_PROXY'		  => 'PclZipProxy',	// PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
339
-							'DELIMITER_LEFT'  => '{',
340
-							'DELIMITER_RIGHT' => '}'
341
-						)
342
-					);
343
-				}
344
-				catch(Exception $e)
345
-				{
346
-					$this->error=$e->getMessage();
347
-					dol_syslog($e->getMessage(), LOG_WARNING);
348
-					return -1;
349
-				}
350
-
351
-				// Make substitutions into odt
352
-				$array_user=$this->get_substitutionarray_user($object,$outputlangs);
353
-				$array_soc=$this->get_substitutionarray_mysoc($mysoc,$outputlangs);
354
-				$array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs);
355
-				$array_other=$this->get_substitutionarray_other($outputlangs);
356
-				// retrieve contact information for use in object as contact_xxx tags
357
-				$array_thirdparty_contact = array();
358
-				if ($usecontact && is_object($contactobject)) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact');
359
-
360
-				$tmparray = array_merge($array_user,$array_soc,$array_thirdparty,$array_other,$array_thirdparty_contact);
361
-				complete_substitutions_array($tmparray, $outputlangs, $object);
362
-				$object->fetch_optionals();
363
-				// Call the ODTSubstitution hook
364
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
365
-				$reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
366
-				foreach($tmparray as $key=>$value)
367
-				{
368
-					try {
369
-						if (preg_match('/logo$/',$key)) // Image
370
-						{
371
-							if (file_exists($value)) $odfHandler->setImage($key, $value);
372
-							else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
373
-						}
374
-						else    // Text
375
-						{
376
-							$odfHandler->setVars($key, $value, true, 'UTF-8');
377
-						}
378
-					}
379
-					catch(OdfException $e)
380
-					{
381
-						dol_syslog($e->getMessage(), LOG_WARNING);
382
-					}
383
-				}
384
-
385
-				// Replace labels translated
386
-				$tmparray=$outputlangs->get_translations_for_substitutions();
387
-				foreach($tmparray as $key=>$value)
388
-				{
389
-					try {
390
-						$odfHandler->setVars($key, $value, true, 'UTF-8');
391
-					}
392
-					catch (OdfException $e)
393
-					{
394
-						dol_syslog($e->getMessage(), LOG_WARNING);
395
-					}
396
-				}
397
-
398
-				// Call the beforeODTSave hook
399
-				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
400
-				$reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
401
-
402
-				// Write new file
403
-				if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
404
-					try {
405
-						$odfHandler->exportAsAttachedPDF($file);
406
-					} catch (Exception $e) {
407
-						$this->error=$e->getMessage();
408
-						dol_syslog($e->getMessage(), LOG_WARNING);
409
-						return -1;
410
-					}
411
-				}
412
-				else {
413
-					try {
414
-						$odfHandler->saveToDisk($file);
415
-					} catch (Exception $e) {
416
-						$this->error=$e->getMessage();
417
-						dol_syslog($e->getMessage(), LOG_WARNING);
418
-						return -1;
419
-					}
420
-				}
421
-
422
-				$reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
423
-
424
-				if (! empty($conf->global->MAIN_UMASK))
425
-					@chmod($file, octdec($conf->global->MAIN_UMASK));
426
-
427
-				$odfHandler=null;	// Destroy object
428
-
429
-				$this->result = array('fullpath'=>$file);
430
-
431
-				return 1;   // Success
432
-			}
433
-			else
434
-			{
435
-				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
436
-				return -1;
437
-			}
438
-		}
439
-
440
-		return -1;
441
-	}
222
+        global $user, $langs, $conf, $mysoc, $hookmanager;
223
+
224
+        if (empty($srctemplatepath))
225
+        {
226
+            dol_syslog("doc_generic_odt::write_file parameter srctemplatepath empty", LOG_WARNING);
227
+            return -1;
228
+        }
229
+
230
+        // Add odtgeneration hook
231
+        if (! is_object($hookmanager))
232
+        {
233
+            include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
234
+            $hookmanager=new HookManager($this->db);
235
+        }
236
+        $hookmanager->initHooks(array('odtgeneration'));
237
+        global $action;
238
+
239
+        if (! is_object($outputlangs)) $outputlangs=$langs;
240
+        $sav_charset_output=$outputlangs->charset_output;
241
+        $outputlangs->charset_output='UTF-8';
242
+
243
+        // Load translation files required by the page
244
+        $outputlangs->loadLangs(array("main", "companies", "bills", "dict"));
245
+
246
+        if ($conf->user->dir_output)
247
+        {
248
+            // If $object is id instead of object
249
+            if (! is_object($object))
250
+            {
251
+                $id = $object;
252
+                $object = new User($this->db);
253
+                $result=$object->fetch($id);
254
+                if ($result < 0)
255
+                {
256
+                    dol_print_error($this->db,$object->error);
257
+                    return -1;
258
+                }
259
+            }
260
+
261
+            $dir = $conf->user->dir_output;
262
+            $objectref = dol_sanitizeFileName($object->ref);
263
+            if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
264
+            $file = $dir . "/" . $objectref . ".odt";
265
+
266
+            if (! file_exists($dir))
267
+            {
268
+                if (dol_mkdir($dir) < 0)
269
+                {
270
+                    $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
271
+                    return -1;
272
+                }
273
+            }
274
+
275
+            if (file_exists($dir))
276
+            {
277
+                //print "srctemplatepath=".$srctemplatepath;	// Src filename
278
+                $newfile=basename($srctemplatepath);
279
+                $newfiletmp=preg_replace('/\.od(t|s)/i','',$newfile);
280
+                $newfiletmp=preg_replace('/template_/i','',$newfiletmp);
281
+                $newfiletmp=preg_replace('/modele_/i','',$newfiletmp);
282
+
283
+                $newfiletmp=$objectref.'_'.$newfiletmp;
284
+
285
+                // Get extension (ods or odt)
286
+                $newfileformat=substr($newfile, strrpos($newfile, '.')+1);
287
+                if ( ! empty($conf->global->MAIN_DOC_USE_TIMING))
288
+                {
289
+                    $format=$conf->global->MAIN_DOC_USE_TIMING;
290
+                    if ($format == '1') $format='%Y%m%d%H%M%S';
291
+                    $filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat;
292
+                }
293
+                else
294
+                {
295
+                    $filename=$newfiletmp.'.'.$newfileformat;
296
+                }
297
+                $file=$dir.'/'.$filename;
298
+                //print "newdir=".$dir;
299
+                //print "newfile=".$newfile;
300
+                //print "file=".$file;
301
+                //print "conf->user->dir_temp=".$conf->user->dir_temp;
302
+
303
+                dol_mkdir($conf->user->dir_temp);
304
+
305
+
306
+                // If CUSTOMER contact defined on user, we use it
307
+                $usecontact=false;
308
+                $arrayidcontact=$object->getIdContact('external','CUSTOMER');
309
+                if (count($arrayidcontact) > 0)
310
+                {
311
+                    $usecontact=true;
312
+                    $result=$object->fetch_contact($arrayidcontact[0]);
313
+                }
314
+
315
+                // Recipient name
316
+                if (! empty($usecontact))
317
+                {
318
+                    // On peut utiliser le nom de la societe du contact
319
+                    if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact;
320
+                    else {
321
+                                    $socobject = $object->thirdparty;
322
+                                    // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use
323
+                                    $contactobject = $object->contact;
324
+                                }
325
+                }
326
+                else
327
+                {
328
+                    $socobject=$object->thirdparty;
329
+                }
330
+
331
+                // Open and load template
332
+                require_once ODTPHP_PATH.'odf.php';
333
+                try {
334
+                    $odfHandler = new odf(
335
+                        $srctemplatepath,
336
+                        array(
337
+                            'PATH_TO_TMP'	  => $conf->user->dir_temp,
338
+                            'ZIP_PROXY'		  => 'PclZipProxy',	// PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
339
+                            'DELIMITER_LEFT'  => '{',
340
+                            'DELIMITER_RIGHT' => '}'
341
+                        )
342
+                    );
343
+                }
344
+                catch(Exception $e)
345
+                {
346
+                    $this->error=$e->getMessage();
347
+                    dol_syslog($e->getMessage(), LOG_WARNING);
348
+                    return -1;
349
+                }
350
+
351
+                // Make substitutions into odt
352
+                $array_user=$this->get_substitutionarray_user($object,$outputlangs);
353
+                $array_soc=$this->get_substitutionarray_mysoc($mysoc,$outputlangs);
354
+                $array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs);
355
+                $array_other=$this->get_substitutionarray_other($outputlangs);
356
+                // retrieve contact information for use in object as contact_xxx tags
357
+                $array_thirdparty_contact = array();
358
+                if ($usecontact && is_object($contactobject)) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact');
359
+
360
+                $tmparray = array_merge($array_user,$array_soc,$array_thirdparty,$array_other,$array_thirdparty_contact);
361
+                complete_substitutions_array($tmparray, $outputlangs, $object);
362
+                $object->fetch_optionals();
363
+                // Call the ODTSubstitution hook
364
+                $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
365
+                $reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
366
+                foreach($tmparray as $key=>$value)
367
+                {
368
+                    try {
369
+                        if (preg_match('/logo$/',$key)) // Image
370
+                        {
371
+                            if (file_exists($value)) $odfHandler->setImage($key, $value);
372
+                            else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
373
+                        }
374
+                        else    // Text
375
+                        {
376
+                            $odfHandler->setVars($key, $value, true, 'UTF-8');
377
+                        }
378
+                    }
379
+                    catch(OdfException $e)
380
+                    {
381
+                        dol_syslog($e->getMessage(), LOG_WARNING);
382
+                    }
383
+                }
384
+
385
+                // Replace labels translated
386
+                $tmparray=$outputlangs->get_translations_for_substitutions();
387
+                foreach($tmparray as $key=>$value)
388
+                {
389
+                    try {
390
+                        $odfHandler->setVars($key, $value, true, 'UTF-8');
391
+                    }
392
+                    catch (OdfException $e)
393
+                    {
394
+                        dol_syslog($e->getMessage(), LOG_WARNING);
395
+                    }
396
+                }
397
+
398
+                // Call the beforeODTSave hook
399
+                $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
400
+                $reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
401
+
402
+                // Write new file
403
+                if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
404
+                    try {
405
+                        $odfHandler->exportAsAttachedPDF($file);
406
+                    } catch (Exception $e) {
407
+                        $this->error=$e->getMessage();
408
+                        dol_syslog($e->getMessage(), LOG_WARNING);
409
+                        return -1;
410
+                    }
411
+                }
412
+                else {
413
+                    try {
414
+                        $odfHandler->saveToDisk($file);
415
+                    } catch (Exception $e) {
416
+                        $this->error=$e->getMessage();
417
+                        dol_syslog($e->getMessage(), LOG_WARNING);
418
+                        return -1;
419
+                    }
420
+                }
421
+
422
+                $reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
423
+
424
+                if (! empty($conf->global->MAIN_UMASK))
425
+                    @chmod($file, octdec($conf->global->MAIN_UMASK));
426
+
427
+                $odfHandler=null;	// Destroy object
428
+
429
+                $this->result = array('fullpath'=>$file);
430
+
431
+                return 1;   // Success
432
+            }
433
+            else
434
+            {
435
+                $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
436
+                return -1;
437
+            }
438
+        }
439
+
440
+        return -1;
441
+    }
442 442
 
443 443
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
444 444
     /**
@@ -452,12 +452,12 @@  discard block
 block discarded – undo
452 452
     function get_substitutionarray_object($object,$outputlangs,$array_key='object')
453 453
     {
454 454
         // phpcs:enable
455
-		$array_other = array();
456
-		foreach($object as $key => $value) {
457
-			if (!is_array($value) && !is_object($value)) {
458
-				$array_other[$array_key.'_'.$key] = $value;
459
-			}
460
-		}
461
-		return $array_other;
462
-	}
455
+        $array_other = array();
456
+        foreach($object as $key => $value) {
457
+            if (!is_array($value) && !is_object($value)) {
458
+                $array_other[$array_key.'_'.$key] = $value;
459
+            }
460
+        }
461
+        return $array_other;
462
+    }
463 463
 }
Please login to merge, or discard this patch.
Spacing   +138 added lines, -138 removed lines patch added patch discarded remove patch
@@ -65,37 +65,37 @@  discard block
 block discarded – undo
65 65
 		global $conf, $langs, $mysoc;
66 66
 
67 67
 		// Load translation files required by the page
68
-    $langs->loadLangs(array("main","companies"));
68
+    $langs->loadLangs(array("main", "companies"));
69 69
 
70 70
 		$this->db = $db;
71 71
 		$this->name = "ODT templates";
72 72
 		$this->description = $langs->trans("DocumentModelOdt");
73
-		$this->scandir = 'USER_ADDON_PDF_ODT_PATH';	// Name of constant that is used to save list of directories to scan
73
+		$this->scandir = 'USER_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan
74 74
 
75 75
 		// Dimension page pour format A4
76 76
 		$this->type = 'odt';
77 77
 		$this->page_largeur = 0;
78 78
 		$this->page_hauteur = 0;
79
-		$this->format = array($this->page_largeur,$this->page_hauteur);
80
-		$this->marge_gauche=0;
81
-		$this->marge_droite=0;
82
-		$this->marge_haute=0;
83
-		$this->marge_basse=0;
84
-
85
-		$this->option_logo = 1;                    // Affiche logo
86
-		$this->option_tva = 0;                     // Gere option tva USER_TVAOPTION
87
-		$this->option_modereg = 0;                 // Affiche mode reglement
88
-		$this->option_condreg = 0;                 // Affiche conditions reglement
89
-		$this->option_codeproduitservice = 0;      // Affiche code produit-service
90
-		$this->option_multilang = 1;               // Dispo en plusieurs langues
91
-		$this->option_escompte = 0;                // Affiche si il y a eu escompte
92
-		$this->option_credit_note = 0;             // Support credit notes
93
-		$this->option_freetext = 1;				   // Support add of a personalised text
94
-		$this->option_draft_watermark = 0;		   // Support add of a watermark on drafts
79
+		$this->format = array($this->page_largeur, $this->page_hauteur);
80
+		$this->marge_gauche = 0;
81
+		$this->marge_droite = 0;
82
+		$this->marge_haute = 0;
83
+		$this->marge_basse = 0;
84
+
85
+		$this->option_logo = 1; // Affiche logo
86
+		$this->option_tva = 0; // Gere option tva USER_TVAOPTION
87
+		$this->option_modereg = 0; // Affiche mode reglement
88
+		$this->option_condreg = 0; // Affiche conditions reglement
89
+		$this->option_codeproduitservice = 0; // Affiche code produit-service
90
+		$this->option_multilang = 1; // Dispo en plusieurs langues
91
+		$this->option_escompte = 0; // Affiche si il y a eu escompte
92
+		$this->option_credit_note = 0; // Support credit notes
93
+		$this->option_freetext = 1; // Support add of a personalised text
94
+		$this->option_draft_watermark = 0; // Support add of a watermark on drafts
95 95
 
96 96
 		// Recupere emetteur
97
-		$this->emetteur=$mysoc;
98
-		if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
97
+		$this->emetteur = $mysoc;
98
+		if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined
99 99
 	}
100 100
 
101 101
 
@@ -115,91 +115,91 @@  discard block
 block discarded – undo
115 115
 		$form = new Form($this->db);
116 116
 
117 117
 		$texte = $this->description.".<br>\n";
118
-		$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
119
-		$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
120
-		$texte.= '<input type="hidden" name="action" value="setModuleOptions">';
121
-		$texte.= '<input type="hidden" name="param1" value="USER_ADDON_PDF_ODT_PATH">';
118
+		$texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
119
+		$texte .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
120
+		$texte .= '<input type="hidden" name="action" value="setModuleOptions">';
121
+		$texte .= '<input type="hidden" name="param1" value="USER_ADDON_PDF_ODT_PATH">';
122 122
 		if ($conf->global->MAIN_PROPAL_CHOOSE_ODT_DOCUMENT > 0)
123 123
 		{
124
-			$texte.= '<input type="hidden" name="param2" value="USER_ADDON_PDF_ODT_DEFAULT">';
125
-			$texte.= '<input type="hidden" name="param3" value="USER_ADDON_PDF_ODT_TOBILL">';
126
-			$texte.= '<input type="hidden" name="param4" value="USER_ADDON_PDF_ODT_CLOSED">';
124
+			$texte .= '<input type="hidden" name="param2" value="USER_ADDON_PDF_ODT_DEFAULT">';
125
+			$texte .= '<input type="hidden" name="param3" value="USER_ADDON_PDF_ODT_TOBILL">';
126
+			$texte .= '<input type="hidden" name="param4" value="USER_ADDON_PDF_ODT_CLOSED">';
127 127
 		}
128
-		$texte.= '<table class="nobordernopadding" width="100%">';
128
+		$texte .= '<table class="nobordernopadding" width="100%">';
129 129
 
130 130
 		// List of directories area
131
-		$texte.= '<tr><td>';
132
-		$texttitle=$langs->trans("ListOfDirectories");
133
-		$listofdir=explode(',',preg_replace('/[\r\n]+/',',',trim($conf->global->USER_ADDON_PDF_ODT_PATH)));
134
-		$listoffiles=array();
135
-		foreach($listofdir as $key=>$tmpdir)
131
+		$texte .= '<tr><td>';
132
+		$texttitle = $langs->trans("ListOfDirectories");
133
+		$listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->USER_ADDON_PDF_ODT_PATH)));
134
+		$listoffiles = array();
135
+		foreach ($listofdir as $key=>$tmpdir)
136 136
 		{
137
-			$tmpdir=trim($tmpdir);
138
-			$tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir);
139
-			if (! $tmpdir) {
137
+			$tmpdir = trim($tmpdir);
138
+			$tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir);
139
+			if (!$tmpdir) {
140 140
 				unset($listofdir[$key]); continue;
141 141
 			}
142
-			if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
142
+			if (!is_dir($tmpdir)) $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0);
143 143
 			else
144 144
 			{
145
-				$tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)');
146
-				if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles);
145
+				$tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)');
146
+				if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles);
147 147
 			}
148 148
 		}
149
-		$texthelp=$langs->trans("ListOfDirectoriesForModelGenODT");
149
+		$texthelp = $langs->trans("ListOfDirectoriesForModelGenODT");
150 150
 		// Add list of substitution keys
151
-		$texthelp.='<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
152
-		$texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation");    // This contains an url, we don't modify it
153
-
154
-		$texte.= $form->textwithpicto($texttitle,$texthelp,1,'help','',1);
155
-		$texte.= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
156
-		$texte.= '<textarea class="flat" cols="60" name="value1">';
157
-		$texte.=$conf->global->USER_ADDON_PDF_ODT_PATH;
158
-		$texte.= '</textarea>';
159
-		$texte.= '</div><div style="display: inline-block; vertical-align: middle;">';
160
-		$texte.= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
161
-		$texte.= '<br></div></div>';
151
+		$texthelp .= '<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
152
+		$texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it
153
+
154
+		$texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1);
155
+		$texte .= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
156
+		$texte .= '<textarea class="flat" cols="60" name="value1">';
157
+		$texte .= $conf->global->USER_ADDON_PDF_ODT_PATH;
158
+		$texte .= '</textarea>';
159
+		$texte .= '</div><div style="display: inline-block; vertical-align: middle;">';
160
+		$texte .= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
161
+		$texte .= '<br></div></div>';
162 162
 
163 163
 		// Scan directories
164 164
 		if (count($listofdir))
165 165
 		{
166
-			$texte.=$langs->trans("NumberOfModelFilesFound").': <b>'.count($listoffiles).'</b>';
166
+			$texte .= $langs->trans("NumberOfModelFilesFound").': <b>'.count($listoffiles).'</b>';
167 167
 
168 168
 			if ($conf->global->MAIN_PROPAL_CHOOSE_ODT_DOCUMENT > 0)
169 169
 			{
170 170
 				// Model for creation
171
-				$liste=ModelePDFUser::liste_modeles($this->db);
172
-				$texte.= '<table width="50%;">';
173
-				$texte.= '<tr>';
174
-				$texte.= '<td width="60%;">'.$langs->trans("DefaultModelPropalCreate").'</td>';
175
-				$texte.= '<td colspan="">';
176
-				$texte.= $form->selectarray('value2',$liste,$conf->global->USER_ADDON_PDF_ODT_DEFAULT);
177
-				$texte.= "</td></tr>";
178
-
179
-				$texte.= '<tr>';
180
-				$texte.= '<td width="60%;">'.$langs->trans("DefaultModelPropalToBill").'</td>';
181
-				$texte.= '<td colspan="">';
182
-				$texte.= $form->selectarray('value3',$liste,$conf->global->USER_ADDON_PDF_ODT_TOBILL);
183
-				$texte.= "</td></tr>";
184
-				$texte.= '<tr>';
185
-
186
-				$texte.= '<td width="60%;">'.$langs->trans("DefaultModelPropalClosed").'</td>';
187
-				$texte.= '<td colspan="">';
188
-				$texte.= $form->selectarray('value4',$liste,$conf->global->USER_ADDON_PDF_ODT_CLOSED);
189
-				$texte.= "</td></tr>";
190
-				$texte.= '</table>';
171
+				$liste = ModelePDFUser::liste_modeles($this->db);
172
+				$texte .= '<table width="50%;">';
173
+				$texte .= '<tr>';
174
+				$texte .= '<td width="60%;">'.$langs->trans("DefaultModelPropalCreate").'</td>';
175
+				$texte .= '<td colspan="">';
176
+				$texte .= $form->selectarray('value2', $liste, $conf->global->USER_ADDON_PDF_ODT_DEFAULT);
177
+				$texte .= "</td></tr>";
178
+
179
+				$texte .= '<tr>';
180
+				$texte .= '<td width="60%;">'.$langs->trans("DefaultModelPropalToBill").'</td>';
181
+				$texte .= '<td colspan="">';
182
+				$texte .= $form->selectarray('value3', $liste, $conf->global->USER_ADDON_PDF_ODT_TOBILL);
183
+				$texte .= "</td></tr>";
184
+				$texte .= '<tr>';
185
+
186
+				$texte .= '<td width="60%;">'.$langs->trans("DefaultModelPropalClosed").'</td>';
187
+				$texte .= '<td colspan="">';
188
+				$texte .= $form->selectarray('value4', $liste, $conf->global->USER_ADDON_PDF_ODT_CLOSED);
189
+				$texte .= "</td></tr>";
190
+				$texte .= '</table>';
191 191
 			}
192 192
 		}
193 193
 
194
-		$texte.= '</td>';
194
+		$texte .= '</td>';
195 195
 
196
-		$texte.= '<td valign="top" rowspan="2" class="hideonsmartphone">';
197
-		$texte.= $langs->trans("ExampleOfDirectoriesForModelGen");
198
-		$texte.= '</td>';
199
-		$texte.= '</tr>';
196
+		$texte .= '<td valign="top" rowspan="2" class="hideonsmartphone">';
197
+		$texte .= $langs->trans("ExampleOfDirectoriesForModelGen");
198
+		$texte .= '</td>';
199
+		$texte .= '</tr>';
200 200
 
201
-		$texte.= '</table>';
202
-		$texte.= '</form>';
201
+		$texte .= '</table>';
202
+		$texte .= '</form>';
203 203
 
204 204
 		return $texte;
205 205
 	}
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 	 *  @param		int			$hideref			Do not show ref
217 217
 	 *	@return		int         					1 if OK, <=0 if KO
218 218
 	 */
219
-	function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0)
219
+	function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
220 220
 	{
221 221
         // phpcs:enable
222 222
 		global $user, $langs, $conf, $mysoc, $hookmanager;
@@ -228,17 +228,17 @@  discard block
 block discarded – undo
228 228
 		}
229 229
 
230 230
 		// Add odtgeneration hook
231
-		if (! is_object($hookmanager))
231
+		if (!is_object($hookmanager))
232 232
 		{
233 233
 			include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
234
-			$hookmanager=new HookManager($this->db);
234
+			$hookmanager = new HookManager($this->db);
235 235
 		}
236 236
 		$hookmanager->initHooks(array('odtgeneration'));
237 237
 		global $action;
238 238
 
239
-		if (! is_object($outputlangs)) $outputlangs=$langs;
240
-		$sav_charset_output=$outputlangs->charset_output;
241
-		$outputlangs->charset_output='UTF-8';
239
+		if (!is_object($outputlangs)) $outputlangs = $langs;
240
+		$sav_charset_output = $outputlangs->charset_output;
241
+		$outputlangs->charset_output = 'UTF-8';
242 242
 
243 243
 		// Load translation files required by the page
244 244
 		$outputlangs->loadLangs(array("main", "companies", "bills", "dict"));
@@ -246,28 +246,28 @@  discard block
 block discarded – undo
246 246
 		if ($conf->user->dir_output)
247 247
 		{
248 248
 			// If $object is id instead of object
249
-			if (! is_object($object))
249
+			if (!is_object($object))
250 250
 			{
251 251
 				$id = $object;
252 252
 				$object = new User($this->db);
253
-				$result=$object->fetch($id);
253
+				$result = $object->fetch($id);
254 254
 				if ($result < 0)
255 255
 				{
256
-					dol_print_error($this->db,$object->error);
256
+					dol_print_error($this->db, $object->error);
257 257
 					return -1;
258 258
 				}
259 259
 			}
260 260
 
261 261
 			$dir = $conf->user->dir_output;
262 262
 			$objectref = dol_sanitizeFileName($object->ref);
263
-			if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
264
-			$file = $dir . "/" . $objectref . ".odt";
263
+			if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref;
264
+			$file = $dir."/".$objectref.".odt";
265 265
 
266
-			if (! file_exists($dir))
266
+			if (!file_exists($dir))
267 267
 			{
268 268
 				if (dol_mkdir($dir) < 0)
269 269
 				{
270
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
270
+					$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
271 271
 					return -1;
272 272
 				}
273 273
 			}
@@ -275,26 +275,26 @@  discard block
 block discarded – undo
275 275
 			if (file_exists($dir))
276 276
 			{
277 277
 				//print "srctemplatepath=".$srctemplatepath;	// Src filename
278
-				$newfile=basename($srctemplatepath);
279
-				$newfiletmp=preg_replace('/\.od(t|s)/i','',$newfile);
280
-				$newfiletmp=preg_replace('/template_/i','',$newfiletmp);
281
-				$newfiletmp=preg_replace('/modele_/i','',$newfiletmp);
278
+				$newfile = basename($srctemplatepath);
279
+				$newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile);
280
+				$newfiletmp = preg_replace('/template_/i', '', $newfiletmp);
281
+				$newfiletmp = preg_replace('/modele_/i', '', $newfiletmp);
282 282
 
283
-				$newfiletmp=$objectref.'_'.$newfiletmp;
283
+				$newfiletmp = $objectref.'_'.$newfiletmp;
284 284
 
285 285
 				// Get extension (ods or odt)
286
-				$newfileformat=substr($newfile, strrpos($newfile, '.')+1);
287
-				if ( ! empty($conf->global->MAIN_DOC_USE_TIMING))
286
+				$newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
287
+				if (!empty($conf->global->MAIN_DOC_USE_TIMING))
288 288
 				{
289
-				    $format=$conf->global->MAIN_DOC_USE_TIMING;
290
-				    if ($format == '1') $format='%Y%m%d%H%M%S';
291
-					$filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat;
289
+				    $format = $conf->global->MAIN_DOC_USE_TIMING;
290
+				    if ($format == '1') $format = '%Y%m%d%H%M%S';
291
+					$filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat;
292 292
 				}
293 293
 				else
294 294
 				{
295
-					$filename=$newfiletmp.'.'.$newfileformat;
295
+					$filename = $newfiletmp.'.'.$newfileformat;
296 296
 				}
297
-				$file=$dir.'/'.$filename;
297
+				$file = $dir.'/'.$filename;
298 298
 				//print "newdir=".$dir;
299 299
 				//print "newfile=".$newfile;
300 300
 				//print "file=".$file;
@@ -304,19 +304,19 @@  discard block
 block discarded – undo
304 304
 
305 305
 
306 306
 				// If CUSTOMER contact defined on user, we use it
307
-				$usecontact=false;
308
-				$arrayidcontact=$object->getIdContact('external','CUSTOMER');
307
+				$usecontact = false;
308
+				$arrayidcontact = $object->getIdContact('external', 'CUSTOMER');
309 309
 				if (count($arrayidcontact) > 0)
310 310
 				{
311
-					$usecontact=true;
312
-					$result=$object->fetch_contact($arrayidcontact[0]);
311
+					$usecontact = true;
312
+					$result = $object->fetch_contact($arrayidcontact[0]);
313 313
 				}
314 314
 
315 315
 				// Recipient name
316
-				if (! empty($usecontact))
316
+				if (!empty($usecontact))
317 317
 				{
318 318
 					// On peut utiliser le nom de la societe du contact
319
-					if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact;
319
+					if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact;
320 320
 					else {
321 321
                         			$socobject = $object->thirdparty;
322 322
                         			// if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
 				}
326 326
 				else
327 327
 				{
328
-					$socobject=$object->thirdparty;
328
+					$socobject = $object->thirdparty;
329 329
 				}
330 330
 
331 331
 				// Open and load template
@@ -335,38 +335,38 @@  discard block
 block discarded – undo
335 335
 						$srctemplatepath,
336 336
 						array(
337 337
 							'PATH_TO_TMP'	  => $conf->user->dir_temp,
338
-							'ZIP_PROXY'		  => 'PclZipProxy',	// PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
338
+							'ZIP_PROXY'		  => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
339 339
 							'DELIMITER_LEFT'  => '{',
340 340
 							'DELIMITER_RIGHT' => '}'
341 341
 						)
342 342
 					);
343 343
 				}
344
-				catch(Exception $e)
344
+				catch (Exception $e)
345 345
 				{
346
-					$this->error=$e->getMessage();
346
+					$this->error = $e->getMessage();
347 347
 					dol_syslog($e->getMessage(), LOG_WARNING);
348 348
 					return -1;
349 349
 				}
350 350
 
351 351
 				// Make substitutions into odt
352
-				$array_user=$this->get_substitutionarray_user($object,$outputlangs);
353
-				$array_soc=$this->get_substitutionarray_mysoc($mysoc,$outputlangs);
354
-				$array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs);
355
-				$array_other=$this->get_substitutionarray_other($outputlangs);
352
+				$array_user = $this->get_substitutionarray_user($object, $outputlangs);
353
+				$array_soc = $this->get_substitutionarray_mysoc($mysoc, $outputlangs);
354
+				$array_thirdparty = $this->get_substitutionarray_thirdparty($socobject, $outputlangs);
355
+				$array_other = $this->get_substitutionarray_other($outputlangs);
356 356
 				// retrieve contact information for use in object as contact_xxx tags
357 357
 				$array_thirdparty_contact = array();
358
-				if ($usecontact && is_object($contactobject)) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact');
358
+				if ($usecontact && is_object($contactobject)) $array_thirdparty_contact = $this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact');
359 359
 
360
-				$tmparray = array_merge($array_user,$array_soc,$array_thirdparty,$array_other,$array_thirdparty_contact);
360
+				$tmparray = array_merge($array_user, $array_soc, $array_thirdparty, $array_other, $array_thirdparty_contact);
361 361
 				complete_substitutions_array($tmparray, $outputlangs, $object);
362 362
 				$object->fetch_optionals();
363 363
 				// Call the ODTSubstitution hook
364
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
365
-				$reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
366
-				foreach($tmparray as $key=>$value)
364
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
365
+				$reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
366
+				foreach ($tmparray as $key=>$value)
367 367
 				{
368 368
 					try {
369
-						if (preg_match('/logo$/',$key)) // Image
369
+						if (preg_match('/logo$/', $key)) // Image
370 370
 						{
371 371
 							if (file_exists($value)) $odfHandler->setImage($key, $value);
372 372
 							else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
@@ -376,15 +376,15 @@  discard block
 block discarded – undo
376 376
 							$odfHandler->setVars($key, $value, true, 'UTF-8');
377 377
 						}
378 378
 					}
379
-					catch(OdfException $e)
379
+					catch (OdfException $e)
380 380
 					{
381 381
 						dol_syslog($e->getMessage(), LOG_WARNING);
382 382
 					}
383 383
 				}
384 384
 
385 385
 				// Replace labels translated
386
-				$tmparray=$outputlangs->get_translations_for_substitutions();
387
-				foreach($tmparray as $key=>$value)
386
+				$tmparray = $outputlangs->get_translations_for_substitutions();
387
+				foreach ($tmparray as $key=>$value)
388 388
 				{
389 389
 					try {
390 390
 						$odfHandler->setVars($key, $value, true, 'UTF-8');
@@ -396,15 +396,15 @@  discard block
 block discarded – undo
396 396
 				}
397 397
 
398 398
 				// Call the beforeODTSave hook
399
-				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
400
-				$reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
399
+				$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
400
+				$reshook = $hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
401 401
 
402 402
 				// Write new file
403 403
 				if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
404 404
 					try {
405 405
 						$odfHandler->exportAsAttachedPDF($file);
406 406
 					} catch (Exception $e) {
407
-						$this->error=$e->getMessage();
407
+						$this->error = $e->getMessage();
408 408
 						dol_syslog($e->getMessage(), LOG_WARNING);
409 409
 						return -1;
410 410
 					}
@@ -413,26 +413,26 @@  discard block
 block discarded – undo
413 413
 					try {
414 414
 						$odfHandler->saveToDisk($file);
415 415
 					} catch (Exception $e) {
416
-						$this->error=$e->getMessage();
416
+						$this->error = $e->getMessage();
417 417
 						dol_syslog($e->getMessage(), LOG_WARNING);
418 418
 						return -1;
419 419
 					}
420 420
 				}
421 421
 
422
-				$reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
422
+				$reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
423 423
 
424
-				if (! empty($conf->global->MAIN_UMASK))
424
+				if (!empty($conf->global->MAIN_UMASK))
425 425
 					@chmod($file, octdec($conf->global->MAIN_UMASK));
426 426
 
427
-				$odfHandler=null;	// Destroy object
427
+				$odfHandler = null; // Destroy object
428 428
 
429 429
 				$this->result = array('fullpath'=>$file);
430 430
 
431
-				return 1;   // Success
431
+				return 1; // Success
432 432
 			}
433 433
 			else
434 434
 			{
435
-				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
435
+				$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
436 436
 				return -1;
437 437
 			}
438 438
 		}
@@ -449,11 +449,11 @@  discard block
 block discarded – undo
449 449
      * @param string        $array_key      key for array
450 450
      * @return array                        array of substitutions
451 451
      */
452
-    function get_substitutionarray_object($object,$outputlangs,$array_key='object')
452
+    function get_substitutionarray_object($object, $outputlangs, $array_key = 'object')
453 453
     {
454 454
         // phpcs:enable
455 455
 		$array_other = array();
456
-		foreach($object as $key => $value) {
456
+		foreach ($object as $key => $value) {
457 457
 			if (!is_array($value) && !is_object($value)) {
458 458
 				$array_other[$array_key.'_'.$key] = $value;
459 459
 			}
Please login to merge, or discard this patch.
Braces   +41 added lines, -30 removed lines patch added patch discarded remove patch
@@ -95,7 +95,10 @@  discard block
 block discarded – undo
95 95
 
96 96
 		// Recupere emetteur
97 97
 		$this->emetteur=$mysoc;
98
-		if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
98
+		if (! $this->emetteur->country_code) {
99
+		    $this->emetteur->country_code=substr($langs->defaultlang,-2);
100
+		}
101
+		// By default if not defined
99 102
 	}
100 103
 
101 104
 
@@ -139,11 +142,14 @@  discard block
 block discarded – undo
139 142
 			if (! $tmpdir) {
140 143
 				unset($listofdir[$key]); continue;
141 144
 			}
142
-			if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
143
-			else
145
+			if (! is_dir($tmpdir)) {
146
+			    $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
147
+			} else
144 148
 			{
145 149
 				$tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)');
146
-				if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles);
150
+				if (count($tmpfiles)) {
151
+				    $listoffiles=array_merge($listoffiles,$tmpfiles);
152
+				}
147 153
 			}
148 154
 		}
149 155
 		$texthelp=$langs->trans("ListOfDirectoriesForModelGenODT");
@@ -236,7 +242,9 @@  discard block
 block discarded – undo
236 242
 		$hookmanager->initHooks(array('odtgeneration'));
237 243
 		global $action;
238 244
 
239
-		if (! is_object($outputlangs)) $outputlangs=$langs;
245
+		if (! is_object($outputlangs)) {
246
+		    $outputlangs=$langs;
247
+		}
240 248
 		$sav_charset_output=$outputlangs->charset_output;
241 249
 		$outputlangs->charset_output='UTF-8';
242 250
 
@@ -260,7 +268,9 @@  discard block
 block discarded – undo
260 268
 
261 269
 			$dir = $conf->user->dir_output;
262 270
 			$objectref = dol_sanitizeFileName($object->ref);
263
-			if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
271
+			if (! preg_match('/specimen/i',$objectref)) {
272
+			    $dir.= "/" . $objectref;
273
+			}
264 274
 			$file = $dir . "/" . $objectref . ".odt";
265 275
 
266 276
 			if (! file_exists($dir))
@@ -287,10 +297,11 @@  discard block
 block discarded – undo
287 297
 				if ( ! empty($conf->global->MAIN_DOC_USE_TIMING))
288 298
 				{
289 299
 				    $format=$conf->global->MAIN_DOC_USE_TIMING;
290
-				    if ($format == '1') $format='%Y%m%d%H%M%S';
300
+				    if ($format == '1') {
301
+				        $format='%Y%m%d%H%M%S';
302
+				    }
291 303
 					$filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat;
292
-				}
293
-				else
304
+				} else
294 305
 				{
295 306
 					$filename=$newfiletmp.'.'.$newfileformat;
296 307
 				}
@@ -316,14 +327,14 @@  discard block
 block discarded – undo
316 327
 				if (! empty($usecontact))
317 328
 				{
318 329
 					// On peut utiliser le nom de la societe du contact
319
-					if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact;
320
-					else {
330
+					if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
331
+					    $socobject = $object->contact;
332
+					} else {
321 333
                         			$socobject = $object->thirdparty;
322 334
                         			// if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use
323 335
                         			$contactobject = $object->contact;
324 336
                     			}
325
-				}
326
-				else
337
+				} else
327 338
 				{
328 339
 					$socobject=$object->thirdparty;
329 340
 				}
@@ -340,8 +351,7 @@  discard block
 block discarded – undo
340 351
 							'DELIMITER_RIGHT' => '}'
341 352
 						)
342 353
 					);
343
-				}
344
-				catch(Exception $e)
354
+				} catch(Exception $e)
345 355
 				{
346 356
 					$this->error=$e->getMessage();
347 357
 					dol_syslog($e->getMessage(), LOG_WARNING);
@@ -355,7 +365,9 @@  discard block
 block discarded – undo
355 365
 				$array_other=$this->get_substitutionarray_other($outputlangs);
356 366
 				// retrieve contact information for use in object as contact_xxx tags
357 367
 				$array_thirdparty_contact = array();
358
-				if ($usecontact && is_object($contactobject)) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact');
368
+				if ($usecontact && is_object($contactobject)) {
369
+				    $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact');
370
+				}
359 371
 
360 372
 				$tmparray = array_merge($array_user,$array_soc,$array_thirdparty,$array_other,$array_thirdparty_contact);
361 373
 				complete_substitutions_array($tmparray, $outputlangs, $object);
@@ -366,17 +378,18 @@  discard block
 block discarded – undo
366 378
 				foreach($tmparray as $key=>$value)
367 379
 				{
368 380
 					try {
369
-						if (preg_match('/logo$/',$key)) // Image
381
+						if (preg_match('/logo$/',$key)) {
382
+						    // Image
370 383
 						{
371 384
 							if (file_exists($value)) $odfHandler->setImage($key, $value);
372
-							else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
373
-						}
374
-						else    // Text
385
+						} else {
386
+							    $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
387
+							}
388
+						} else    // Text
375 389
 						{
376 390
 							$odfHandler->setVars($key, $value, true, 'UTF-8');
377 391
 						}
378
-					}
379
-					catch(OdfException $e)
392
+					} catch(OdfException $e)
380 393
 					{
381 394
 						dol_syslog($e->getMessage(), LOG_WARNING);
382 395
 					}
@@ -388,8 +401,7 @@  discard block
 block discarded – undo
388 401
 				{
389 402
 					try {
390 403
 						$odfHandler->setVars($key, $value, true, 'UTF-8');
391
-					}
392
-					catch (OdfException $e)
404
+					} catch (OdfException $e)
393 405
 					{
394 406
 						dol_syslog($e->getMessage(), LOG_WARNING);
395 407
 					}
@@ -408,8 +420,7 @@  discard block
 block discarded – undo
408 420
 						dol_syslog($e->getMessage(), LOG_WARNING);
409 421
 						return -1;
410 422
 					}
411
-				}
412
-				else {
423
+				} else {
413 424
 					try {
414 425
 						$odfHandler->saveToDisk($file);
415 426
 					} catch (Exception $e) {
@@ -421,16 +432,16 @@  discard block
 block discarded – undo
421 432
 
422 433
 				$reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
423 434
 
424
-				if (! empty($conf->global->MAIN_UMASK))
425
-					@chmod($file, octdec($conf->global->MAIN_UMASK));
435
+				if (! empty($conf->global->MAIN_UMASK)) {
436
+									@chmod($file, octdec($conf->global->MAIN_UMASK));
437
+				}
426 438
 
427 439
 				$odfHandler=null;	// Destroy object
428 440
 
429 441
 				$this->result = array('fullpath'=>$file);
430 442
 
431 443
 				return 1;   // Success
432
-			}
433
-			else
444
+			} else
434 445
 			{
435 446
 				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
436 447
 				return -1;
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/user/modules_user.class.php 2 patches
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -31,37 +31,37 @@
 block discarded – undo
31 31
  *  \brief      File with parent class for generating contracts to PDF and File of class to manage contract numbering
32 32
  */
33 33
 
34
- require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php';
34
+    require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php';
35 35
 
36 36
 /**
37 37
  *	Parent class to manage intervention document templates
38 38
  */
39 39
 abstract class ModelePDFUser extends CommonDocGenerator
40 40
 {
41
-	/**
42
-	 * @var string Error code (or message)
43
-	 */
44
-	public $error='';
41
+    /**
42
+     * @var string Error code (or message)
43
+     */
44
+    public $error='';
45 45
 
46 46
 
47 47
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
48
-	/**
49
-	 *	Return list of active generation modules
50
-	 *
48
+    /**
49
+     *	Return list of active generation modules
50
+     *
51 51
      *  @param	DoliDB	$db     			Database handler
52 52
      *  @param  integer	$maxfilenamelength  Max length of value to show
53 53
      *  @return	array						List of templates
54
-	 */
55
-	static function liste_modeles($db,$maxfilenamelength=0)
56
-	{
54
+     */
55
+    static function liste_modeles($db,$maxfilenamelength=0)
56
+    {
57 57
         // phpcs:enable
58
-		global $conf;
58
+        global $conf;
59 59
 
60
-		$type='user';
61
-		$liste=array();
60
+        $type='user';
61
+        $liste=array();
62 62
 
63
-		include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
64
-		$liste=getListOfModels($db,$type,$maxfilenamelength);
65
-		return $liste;
66
-	}
63
+        include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
64
+        $liste=getListOfModels($db,$type,$maxfilenamelength);
65
+        return $liste;
66
+    }
67 67
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 	/**
42 42
 	 * @var string Error code (or message)
43 43
 	 */
44
-	public $error='';
44
+	public $error = '';
45 45
 
46 46
 
47 47
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
@@ -52,16 +52,16 @@  discard block
 block discarded – undo
52 52
      *  @param  integer	$maxfilenamelength  Max length of value to show
53 53
      *  @return	array						List of templates
54 54
 	 */
55
-	static function liste_modeles($db,$maxfilenamelength=0)
55
+	static function liste_modeles($db, $maxfilenamelength = 0)
56 56
 	{
57 57
         // phpcs:enable
58 58
 		global $conf;
59 59
 
60
-		$type='user';
61
-		$liste=array();
60
+		$type = 'user';
61
+		$liste = array();
62 62
 
63 63
 		include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
64
-		$liste=getListOfModels($db,$type,$maxfilenamelength);
64
+		$liste = getListOfModels($db, $type, $maxfilenamelength);
65 65
 		return $liste;
66 66
 	}
67 67
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/modBlockedLog.class.php 3 patches
Indentation   +92 added lines, -92 removed lines patch added patch discarded remove patch
@@ -30,21 +30,21 @@  discard block
 block discarded – undo
30 30
 class modBlockedLog extends DolibarrModules
31 31
 {
32 32
     /**
33
-	 *   Constructor. Define names, constants, directories, boxes, permissions
34
-	 *
35
-	 *   @param      DoliDB		$db      Database handler
33
+     *   Constructor. Define names, constants, directories, boxes, permissions
34
+     *
35
+     *   @param      DoliDB		$db      Database handler
36 36
      */
37 37
     function __construct($db)
38 38
     {
39
-    	global $langs, $conf, $mysoc;
39
+        global $langs, $conf, $mysoc;
40 40
 
41 41
         $this->db = $db;
42 42
         $this->numero = 3200;
43 43
         // Key text used to identify module (for permissions, menus, etc...)
44 44
         $this->rights_class = 'blockedlog';
45 45
 
46
-		// Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
47
-		// It is used to group modules in module setup page
46
+        // Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
47
+        // It is used to group modules in module setup page
48 48
         $this->family = "base";
49 49
         // Module position in the family on 2 digits ('01', '10', '20', ...)
50 50
         $this->module_position = '75';
@@ -67,10 +67,10 @@  discard block
 block discarded – undo
67 67
 
68 68
         // Dependancies
69 69
         //-------------
70
-	    $this->hidden = false;	// A condition to disable module
71
-	    $this->depends = array('always'=>'modFacture');	   // List of modules id that must be enabled if this module is enabled
70
+        $this->hidden = false;	// A condition to disable module
71
+        $this->depends = array('always'=>'modFacture');	   // List of modules id that must be enabled if this module is enabled
72 72
         $this->requiredby = array();	                   // List of modules id to disable if this one is disabled
73
-	    $this->conflictwith = array();	                   // List of modules id this module is in conflict with
73
+        $this->conflictwith = array();	                   // List of modules id this module is in conflict with
74 74
         $this->langfiles = array('blockedlog');
75 75
 
76 76
         $this->warnings_activation = array();                     // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...)
@@ -91,14 +91,14 @@  discard block
 block discarded – undo
91 91
         //var_dump($this->automatic_activation);
92 92
 
93 93
         $this->always_enabled = (!empty($conf->blockedlog->enabled)
94
-        	&& !empty($conf->global->BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY)
95
-        	&& in_array($mysoc->country_code, explode(',', $conf->global->BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY))
96
-        	&& $this->alreadyUsed(1));
94
+            && !empty($conf->global->BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY)
95
+            && in_array($mysoc->country_code, explode(',', $conf->global->BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY))
96
+            && $this->alreadyUsed(1));
97 97
 
98 98
         // Constants
99 99
         //-----------
100 100
         $this->const = array(
101
-        	1=>array('BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY', 'chaine', 'FR', 'This is list of country code where the module may be mandatory', 0, 'current', 0)
101
+            1=>array('BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY', 'chaine', 'FR', 'This is list of country code where the module may be mandatory', 0, 'current', 0)
102 102
         );
103 103
 
104 104
         // New pages on tabs
@@ -148,9 +148,9 @@  discard block
 block discarded – undo
148 148
     function alreadyUsed()
149 149
     {
150 150
 
151
-    	require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php';
152
-    	$b=new BlockedLog($this->db);
153
-    	return $b->alreadyUsed(1);
151
+        require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php';
152
+        $b=new BlockedLog($this->db);
153
+        return $b->alreadyUsed(1);
154 154
     }
155 155
 
156 156
 
@@ -164,87 +164,87 @@  discard block
 block discarded – undo
164 164
      */
165 165
     function init($options='')
166 166
     {
167
-    	global $conf, $user;
168
-
169
-    	$sql = array();
170
-
171
-    	// If already used, we add an entry to show we enable module
172
-   		require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php';
173
-
174
-   		$object=new stdClass();
175
-    	$object->id = 1;
176
-    	$object->element = 'module';
177
-    	$object->ref = 'systemevent';
178
-    	$object->entity = $conf->entity;
179
-    	$object->date = dol_now();
180
-
181
-    	$b=new BlockedLog($this->db);
182
-    	$result = $b->setObjectData($object, 'MODULE_SET', 0);
183
-    	if ($result < 0)
184
-    	{
185
-    		$this->error = $b->error;
186
-    		$this->errors = $b->erros;
187
-    		return 0;
188
-    	}
189
-
190
-    	$res = $b->create($user);
191
-    	if ($res<=0) {
192
-    		$this->error = $b->error;
193
-    		$this->errors = $b->errors;
194
-    		return $res;
195
-    	}
196
-
197
-    	return $this->_init($sql, $options);
167
+        global $conf, $user;
168
+
169
+        $sql = array();
170
+
171
+        // If already used, we add an entry to show we enable module
172
+            require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php';
173
+
174
+            $object=new stdClass();
175
+        $object->id = 1;
176
+        $object->element = 'module';
177
+        $object->ref = 'systemevent';
178
+        $object->entity = $conf->entity;
179
+        $object->date = dol_now();
180
+
181
+        $b=new BlockedLog($this->db);
182
+        $result = $b->setObjectData($object, 'MODULE_SET', 0);
183
+        if ($result < 0)
184
+        {
185
+            $this->error = $b->error;
186
+            $this->errors = $b->erros;
187
+            return 0;
188
+        }
189
+
190
+        $res = $b->create($user);
191
+        if ($res<=0) {
192
+            $this->error = $b->error;
193
+            $this->errors = $b->errors;
194
+            return $res;
195
+        }
196
+
197
+        return $this->_init($sql, $options);
198 198
     }
199 199
 
200 200
     /**
201
-	 * Function called when module is disabled.
202
-	 * The remove function removes tabs, constants, boxes, permissions and menus from Dolibarr database.
203
-	 * Data directories are not deleted
204
-	 *
205
-	 * @param      string	$options    Options when enabling module ('', 'noboxes')
206
-	 * @return     int             		1 if OK, 0 if KO
207
-	 */
201
+     * Function called when module is disabled.
202
+     * The remove function removes tabs, constants, boxes, permissions and menus from Dolibarr database.
203
+     * Data directories are not deleted
204
+     *
205
+     * @param      string	$options    Options when enabling module ('', 'noboxes')
206
+     * @return     int             		1 if OK, 0 if KO
207
+     */
208 208
     function remove($options = '')
209 209
     {
210 210
 
211
-    	global $conf, $user;
212
-
213
-    	$sql = array();
214
-
215
-		// If already used, we add an entry to show we enable module
216
-		require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php';
217
-
218
-		$object=new stdClass();
219
-    	$object->id = 1;
220
-    	$object->element = 'module';
221
-    	$object->ref = 'systemevent';
222
-    	$object->entity = $conf->entity;
223
-    	$object->date = dol_now();
224
-
225
-    	$b=new BlockedLog($this->db);
226
-    	$result = $b->setObjectData($object, 'MODULE_RESET', 0);
227
-    	if ($result < 0)
228
-    	{
229
-    		$this->error = $b->error;
230
-    		$this->errors = $b->erros;
231
-    		return 0;
232
-    	}
233
-
234
-    	if ($b->alreadyUsed(1))
235
-    	{
236
-    		$res = $b->create($user, '0000000000');		// If already used for something else than SET or UNSET, we log with error
237
-    	}
238
-    	else
239
-    	{
240
-    		$res = $b->create($user);
241
-    	}
242
-	    if ($res<=0) {
243
-	    	$this->error = $b->error;
244
-	    	$this->errors = $b->errors;
245
-	    	return $res;
246
-    	}
247
-
248
-    	return $this->_remove($sql, $options);
211
+        global $conf, $user;
212
+
213
+        $sql = array();
214
+
215
+        // If already used, we add an entry to show we enable module
216
+        require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php';
217
+
218
+        $object=new stdClass();
219
+        $object->id = 1;
220
+        $object->element = 'module';
221
+        $object->ref = 'systemevent';
222
+        $object->entity = $conf->entity;
223
+        $object->date = dol_now();
224
+
225
+        $b=new BlockedLog($this->db);
226
+        $result = $b->setObjectData($object, 'MODULE_RESET', 0);
227
+        if ($result < 0)
228
+        {
229
+            $this->error = $b->error;
230
+            $this->errors = $b->erros;
231
+            return 0;
232
+        }
233
+
234
+        if ($b->alreadyUsed(1))
235
+        {
236
+            $res = $b->create($user, '0000000000');		// If already used for something else than SET or UNSET, we log with error
237
+        }
238
+        else
239
+        {
240
+            $res = $b->create($user);
241
+        }
242
+        if ($res<=0) {
243
+            $this->error = $b->error;
244
+            $this->errors = $b->errors;
245
+            return $res;
246
+        }
247
+
248
+        return $this->_remove($sql, $options);
249 249
     }
250 250
 }
Please login to merge, or discard this patch.
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
  *  \ingroup    blockedlog
23 23
  *  \brief      Description and activation file for module BlockedLog
24 24
  */
25
-include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
25
+include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
26 26
 
27 27
 /**
28 28
  *	Class to describe a BlockedLog module
@@ -49,14 +49,14 @@  discard block
 block discarded – undo
49 49
         // Module position in the family on 2 digits ('01', '10', '20', ...)
50 50
         $this->module_position = '75';
51 51
         // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
52
-        $this->name = preg_replace('/^mod/i','',get_class($this));
52
+        $this->name = preg_replace('/^mod/i', '', get_class($this));
53 53
         $this->description = "Enable a log on some business events into a non reversible log. This module may be mandatory for some countries.";
54 54
         // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
55 55
         $this->version = 'dolibarr';
56 56
         // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)
57 57
         $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
58 58
         // Name of image file used for this module.
59
-        $this->picto='technic';
59
+        $this->picto = 'technic';
60 60
 
61 61
         // Data directories to create when module is enabled
62 62
         $this->dirs = array();
@@ -67,14 +67,14 @@  discard block
 block discarded – undo
67 67
 
68 68
         // Dependancies
69 69
         //-------------
70
-	    $this->hidden = false;	// A condition to disable module
71
-	    $this->depends = array('always'=>'modFacture');	   // List of modules id that must be enabled if this module is enabled
72
-        $this->requiredby = array();	                   // List of modules id to disable if this one is disabled
73
-	    $this->conflictwith = array();	                   // List of modules id this module is in conflict with
70
+	    $this->hidden = false; // A condition to disable module
71
+	    $this->depends = array('always'=>'modFacture'); // List of modules id that must be enabled if this module is enabled
72
+        $this->requiredby = array(); // List of modules id to disable if this one is disabled
73
+	    $this->conflictwith = array(); // List of modules id this module is in conflict with
74 74
         $this->langfiles = array('blockedlog');
75 75
 
76
-        $this->warnings_activation = array();                     // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...)
77
-        $this->warnings_activation_ext = array();                 // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...)
76
+        $this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...)
77
+        $this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...)
78 78
         $this->warnings_unactivation = array('FR'=>'BlockedLogAreRequiredByYourCountryLegislation');
79 79
 
80 80
         // Currently, activation is not automatic because only companies (in France) making invoices to non business customers must
@@ -111,31 +111,31 @@  discard block
 block discarded – undo
111 111
 
112 112
         // Permissions
113 113
         // -----------------
114
-        $this->rights = array();		// Permission array used by this module
114
+        $this->rights = array(); // Permission array used by this module
115 115
 
116
-        $r=0;
117
-        $this->rights[$r][0] = $this->numero + $r;	// Permission id (must not be already used)
118
-        $this->rights[$r][1] = 'Read archived events and fingerprints';	// Permission label
119
-        $this->rights[$r][3] = 0; 					// Permission by default for new user (0/1)
120
-        $this->rights[$r][4] = 'read';				// In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2)
116
+        $r = 0;
117
+        $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)
118
+        $this->rights[$r][1] = 'Read archived events and fingerprints'; // Permission label
119
+        $this->rights[$r][3] = 0; // Permission by default for new user (0/1)
120
+        $this->rights[$r][4] = 'read'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2)
121 121
         $this->rights[$r][5] = '';
122 122
 
123 123
         // Main menu entries
124 124
         // -----------------
125
-        $r=0;
126
-        $this->menu[$r]=array(
127
-        'fk_menu'=>'fk_mainmenu=tools',		    // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
125
+        $r = 0;
126
+        $this->menu[$r] = array(
127
+        'fk_menu'=>'fk_mainmenu=tools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
128 128
         'mainmenu'=>'tools',
129 129
         'leftmenu'=>'blockedlogbrowser',
130
-        'type'=>'left',			                // This is a Left menu entry
130
+        'type'=>'left', // This is a Left menu entry
131 131
         'titre'=>'BrowseBlockedLog',
132 132
         'url'=>'/blockedlog/admin/blockedlog_list.php?mainmenu=tools&leftmenu=blockedlogbrowser',
133
-        'langs'=>'blockedlog',	        // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
133
+        'langs'=>'blockedlog', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
134 134
         'position'=>200,
135
-        'enabled'=>'$conf->blockedlog->enabled',  // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
136
-        'perms'=>'$user->rights->blockedlog->read',			    // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
135
+        'enabled'=>'$conf->blockedlog->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
136
+        'perms'=>'$user->rights->blockedlog->read', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
137 137
         'target'=>'',
138
-        'user'=>2);				                // 0=Menu for internal users, 1=external users, 2=both
138
+        'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
139 139
         $r++;
140 140
     }
141 141
 
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
     {
150 150
 
151 151
     	require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php';
152
-    	$b=new BlockedLog($this->db);
152
+    	$b = new BlockedLog($this->db);
153 153
     	return $b->alreadyUsed(1);
154 154
     }
155 155
 
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
      *      @param      string	$options    Options when enabling module ('', 'noboxes')
163 163
      *      @return     int             	1 if OK, 0 if KO
164 164
      */
165
-    function init($options='')
165
+    function init($options = '')
166 166
     {
167 167
     	global $conf, $user;
168 168
 
@@ -171,14 +171,14 @@  discard block
 block discarded – undo
171 171
     	// If already used, we add an entry to show we enable module
172 172
    		require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php';
173 173
 
174
-   		$object=new stdClass();
174
+   		$object = new stdClass();
175 175
     	$object->id = 1;
176 176
     	$object->element = 'module';
177 177
     	$object->ref = 'systemevent';
178 178
     	$object->entity = $conf->entity;
179 179
     	$object->date = dol_now();
180 180
 
181
-    	$b=new BlockedLog($this->db);
181
+    	$b = new BlockedLog($this->db);
182 182
     	$result = $b->setObjectData($object, 'MODULE_SET', 0);
183 183
     	if ($result < 0)
184 184
     	{
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
     	}
189 189
 
190 190
     	$res = $b->create($user);
191
-    	if ($res<=0) {
191
+    	if ($res <= 0) {
192 192
     		$this->error = $b->error;
193 193
     		$this->errors = $b->errors;
194 194
     		return $res;
@@ -215,14 +215,14 @@  discard block
 block discarded – undo
215 215
 		// If already used, we add an entry to show we enable module
216 216
 		require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php';
217 217
 
218
-		$object=new stdClass();
218
+		$object = new stdClass();
219 219
     	$object->id = 1;
220 220
     	$object->element = 'module';
221 221
     	$object->ref = 'systemevent';
222 222
     	$object->entity = $conf->entity;
223 223
     	$object->date = dol_now();
224 224
 
225
-    	$b=new BlockedLog($this->db);
225
+    	$b = new BlockedLog($this->db);
226 226
     	$result = $b->setObjectData($object, 'MODULE_RESET', 0);
227 227
     	if ($result < 0)
228 228
     	{
@@ -233,13 +233,13 @@  discard block
 block discarded – undo
233 233
 
234 234
     	if ($b->alreadyUsed(1))
235 235
     	{
236
-    		$res = $b->create($user, '0000000000');		// If already used for something else than SET or UNSET, we log with error
236
+    		$res = $b->create($user, '0000000000'); // If already used for something else than SET or UNSET, we log with error
237 237
     	}
238 238
     	else
239 239
     	{
240 240
     		$res = $b->create($user);
241 241
     	}
242
-	    if ($res<=0) {
242
+	    if ($res <= 0) {
243 243
 	    	$this->error = $b->error;
244 244
 	    	$this->errors = $b->errors;
245 245
 	    	return $res;
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -234,8 +234,7 @@
 block discarded – undo
234 234
     	if ($b->alreadyUsed(1))
235 235
     	{
236 236
     		$res = $b->create($user, '0000000000');		// If already used for something else than SET or UNSET, we log with error
237
-    	}
238
-    	else
237
+    	} else
239 238
     	{
240 239
     		$res = $b->create($user);
241 240
     	}
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/mailings/fraise.modules.php 3 patches
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 class mailing_fraise extends MailingTargets
35 35
 {
36 36
     var $name='FundationMembers';                    // Identifiant du module mailing
37
-	// This label is used if no translation is found for key XXX neither MailingModuleDescXXX where XXX=name is found
37
+    // This label is used if no translation is found for key XXX neither MailingModuleDescXXX where XXX=name is found
38 38
     var $desc='Foundation members with emails';
39 39
     // Set to 1 if selector is available for admin users only
40 40
     var $require_admin=0;
@@ -175,24 +175,24 @@  discard block
 block discarded – undo
175 175
         $resql = $this->db->query($sql);
176 176
         if ($resql)
177 177
         {
178
-        	$num = $this->db->num_rows($resql);
178
+            $num = $this->db->num_rows($resql);
179 179
 
180
-        	$s.='<option value="0">&nbsp;</option>';
181
-        	if (! $num) $s.='<option value="0" disabled>'.$langs->trans("NoCategoriesDefined").'</option>';
180
+            $s.='<option value="0">&nbsp;</option>';
181
+            if (! $num) $s.='<option value="0" disabled>'.$langs->trans("NoCategoriesDefined").'</option>';
182 182
 
183
-        	$i = 0;
184
-        	while ($i < $num)
185
-        	{
186
-        		$obj = $this->db->fetch_object($resql);
183
+            $i = 0;
184
+            while ($i < $num)
185
+            {
186
+                $obj = $this->db->fetch_object($resql);
187 187
 
188
-        		$s.='<option value="'.$obj->rowid.'">'.dol_trunc($obj->label,38,'middle');
189
-        		$s.='</option>';
190
-        		$i++;
191
-        	}
188
+                $s.='<option value="'.$obj->rowid.'">'.dol_trunc($obj->label,38,'middle');
189
+                $s.='</option>';
190
+                $i++;
191
+            }
192 192
         }
193 193
         else
194 194
         {
195
-        	dol_print_error($this->db);
195
+            dol_print_error($this->db);
196 196
         }
197 197
 
198 198
         $s.='</select>';
@@ -230,9 +230,9 @@  discard block
 block discarded – undo
230 230
     function add_to_target($mailing_id)
231 231
     {
232 232
         // phpcs:enable
233
-    	global $langs,$_POST;
233
+        global $langs,$_POST;
234 234
 
235
-    	// Load translation files required by the page
235
+        // Load translation files required by the page
236 236
         $langs->loadLangs(array("members","companies"));
237 237
 
238 238
         $cibles = array();
@@ -248,8 +248,8 @@  discard block
 block discarded – undo
248 248
         $sql.= " FROM ".MAIN_DB_PREFIX."adherent as a";
249 249
         if ($_POST['filter_category'])
250 250
         {
251
-        	$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_member as cm ON cm.fk_member = a.rowid";
252
-        	$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON c.rowid = cm.fk_categorie";
251
+            $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_member as cm ON cm.fk_member = a.rowid";
252
+            $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON c.rowid = cm.fk_categorie";
253 253
         }
254 254
         $sql.= " , ".MAIN_DB_PREFIX."adherent_type as ta";
255 255
         $sql.= " WHERE a.entity IN (".getEntity('member').") AND a.email <> ''";     // Note that null != '' is false
Please login to merge, or discard this patch.
Spacing   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -33,14 +33,14 @@  discard block
 block discarded – undo
33 33
  */
34 34
 class mailing_fraise extends MailingTargets
35 35
 {
36
-    var $name='FundationMembers';                    // Identifiant du module mailing
36
+    var $name = 'FundationMembers'; // Identifiant du module mailing
37 37
 	// This label is used if no translation is found for key XXX neither MailingModuleDescXXX where XXX=name is found
38
-    var $desc='Foundation members with emails';
38
+    var $desc = 'Foundation members with emails';
39 39
     // Set to 1 if selector is available for admin users only
40
-    var $require_admin=0;
40
+    var $require_admin = 0;
41 41
 
42
-    var $require_module=array('adherent');
43
-    var $picto='user';
42
+    var $require_module = array('adherent');
43
+    var $picto = 'user';
44 44
 
45 45
     /**
46 46
      * @var DoliDB Database handler.
@@ -73,10 +73,10 @@  discard block
 block discarded – undo
73 73
         $langs->load("members");
74 74
 
75 75
         // Array for requests for statistics board
76
-        $statssql=array();
76
+        $statssql = array();
77 77
 
78
-        $statssql[0] ="SELECT '".$this->db->escape($langs->trans("FundationMembers"))."' as label, count(*) as nb";
79
-        $statssql[0].=" FROM ".MAIN_DB_PREFIX."adherent where statut = 1 and entity IN (".getEntity('member').")";
78
+        $statssql[0] = "SELECT '".$this->db->escape($langs->trans("FundationMembers"))."' as label, count(*) as nb";
79
+        $statssql[0] .= " FROM ".MAIN_DB_PREFIX."adherent where statut = 1 and entity IN (".getEntity('member').")";
80 80
 
81 81
         return $statssql;
82 82
     }
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
      *  @param    string    $sql        Requete sql de comptage
91 91
      *    @return        int            Nb of recipients
92 92
      */
93
-    function getNbOfRecipients($sql='')
93
+    function getNbOfRecipients($sql = '')
94 94
     {
95 95
         $sql  = "SELECT count(distinct(a.email)) as nb";
96 96
         $sql .= " FROM ".MAIN_DB_PREFIX."adherent as a";
@@ -112,42 +112,42 @@  discard block
 block discarded – undo
112 112
         global $conf, $langs;
113 113
 
114 114
         // Load translation files required by the page
115
-        $langs->loadLangs(array("members","companies","categories"));
115
+        $langs->loadLangs(array("members", "companies", "categories"));
116 116
 
117
-        $form=new Form($this->db);
117
+        $form = new Form($this->db);
118 118
 
119
-        $s='';
119
+        $s = '';
120 120
 
121 121
         // Status
122
-        $s.=$langs->trans("Status").': ';
123
-        $s.='<select name="filter" class="flat">';
124
-        $s.='<option value="none">&nbsp;</option>';
125
-        $s.='<option value="-1">'.$langs->trans("MemberStatusDraft").'</option>';
126
-        $s.='<option value="1a">'.$langs->trans("MemberStatusActiveShort").' ('.$langs->trans("MemberStatusPaidShort").')</option>';
127
-        $s.='<option value="1b">'.$langs->trans("MemberStatusActiveShort").' ('.$langs->trans("MemberStatusActiveLateShort").')</option>';
128
-        $s.='<option value="0">'.$langs->trans("MemberStatusResiliatedShort").'</option>';
129
-        $s.='</select> ';
130
-        $s.=$langs->trans("Type").': ';
131
-        $s.='<select name="filter_type" class="flat">';
122
+        $s .= $langs->trans("Status").': ';
123
+        $s .= '<select name="filter" class="flat">';
124
+        $s .= '<option value="none">&nbsp;</option>';
125
+        $s .= '<option value="-1">'.$langs->trans("MemberStatusDraft").'</option>';
126
+        $s .= '<option value="1a">'.$langs->trans("MemberStatusActiveShort").' ('.$langs->trans("MemberStatusPaidShort").')</option>';
127
+        $s .= '<option value="1b">'.$langs->trans("MemberStatusActiveShort").' ('.$langs->trans("MemberStatusActiveLateShort").')</option>';
128
+        $s .= '<option value="0">'.$langs->trans("MemberStatusResiliatedShort").'</option>';
129
+        $s .= '</select> ';
130
+        $s .= $langs->trans("Type").': ';
131
+        $s .= '<select name="filter_type" class="flat">';
132 132
         $sql = "SELECT rowid, libelle, statut";
133
-        $sql.= " FROM ".MAIN_DB_PREFIX."adherent_type";
134
-        $sql.= " WHERE entity IN (".getEntity('member_type').")";
135
-        $sql.= " ORDER BY rowid";
133
+        $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type";
134
+        $sql .= " WHERE entity IN (".getEntity('member_type').")";
135
+        $sql .= " ORDER BY rowid";
136 136
         $resql = $this->db->query($sql);
137 137
         if ($resql)
138 138
         {
139 139
             $num = $this->db->num_rows($resql);
140 140
 
141
-            $s.='<option value="0">&nbsp;</option>';
142
-            if (! $num) $s.='<option value="0" disabled="disabled">'.$langs->trans("NoCategoriesDefined").'</option>';
141
+            $s .= '<option value="0">&nbsp;</option>';
142
+            if (!$num) $s .= '<option value="0" disabled="disabled">'.$langs->trans("NoCategoriesDefined").'</option>';
143 143
 
144 144
             $i = 0;
145 145
             while ($i < $num)
146 146
             {
147 147
                 $obj = $this->db->fetch_object($resql);
148 148
 
149
-                $s.='<option value="'.$obj->rowid.'">'.dol_trunc($obj->libelle,38,'middle');
150
-                $s.='</option>';
149
+                $s .= '<option value="'.$obj->rowid.'">'.dol_trunc($obj->libelle, 38, 'middle');
150
+                $s .= '</option>';
151 151
                 $i++;
152 152
             }
153 153
         }
@@ -156,20 +156,20 @@  discard block
 block discarded – undo
156 156
             dol_print_error($this->db);
157 157
         }
158 158
 
159
-        $s.='</select>';
159
+        $s .= '</select>';
160 160
 
161
-        $s.=' ';
161
+        $s .= ' ';
162 162
 
163
-        $s.=$langs->trans("Category").': ';
164
-        $s.='<select name="filter_category" class="flat">';
163
+        $s .= $langs->trans("Category").': ';
164
+        $s .= '<select name="filter_category" class="flat">';
165 165
 
166 166
         // Show categories
167 167
         $sql = "SELECT rowid, label, type, visible";
168
-        $sql.= " FROM ".MAIN_DB_PREFIX."categorie";
169
-        $sql.= " WHERE type = 3";	// We keep only categories for members
168
+        $sql .= " FROM ".MAIN_DB_PREFIX."categorie";
169
+        $sql .= " WHERE type = 3"; // We keep only categories for members
170 170
         // $sql.= " AND visible > 0";	// We ignore the property visible because member's categories does not use this property (only products categories use it).
171
-        $sql.= " AND entity = ".$conf->entity;
172
-        $sql.= " ORDER BY label";
171
+        $sql .= " AND entity = ".$conf->entity;
172
+        $sql .= " ORDER BY label";
173 173
 
174 174
         //print $sql;
175 175
         $resql = $this->db->query($sql);
@@ -177,16 +177,16 @@  discard block
 block discarded – undo
177 177
         {
178 178
         	$num = $this->db->num_rows($resql);
179 179
 
180
-        	$s.='<option value="0">&nbsp;</option>';
181
-        	if (! $num) $s.='<option value="0" disabled>'.$langs->trans("NoCategoriesDefined").'</option>';
180
+        	$s .= '<option value="0">&nbsp;</option>';
181
+        	if (!$num) $s .= '<option value="0" disabled>'.$langs->trans("NoCategoriesDefined").'</option>';
182 182
 
183 183
         	$i = 0;
184 184
         	while ($i < $num)
185 185
         	{
186 186
         		$obj = $this->db->fetch_object($resql);
187 187
 
188
-        		$s.='<option value="'.$obj->rowid.'">'.dol_trunc($obj->label,38,'middle');
189
-        		$s.='</option>';
188
+        		$s .= '<option value="'.$obj->rowid.'">'.dol_trunc($obj->label, 38, 'middle');
189
+        		$s .= '</option>';
190 190
         		$i++;
191 191
         	}
192 192
         }
@@ -195,14 +195,14 @@  discard block
 block discarded – undo
195 195
         	dol_print_error($this->db);
196 196
         }
197 197
 
198
-        $s.='</select>';
198
+        $s .= '</select>';
199 199
 
200 200
 
201
-        $s.='<br>';
202
-        $s.=$langs->trans("DateEndSubscription").': &nbsp;';
203
-        $s.=$langs->trans("After").' > '.$form->selectDate(-1,'subscriptionafter',0,0,1,'fraise',1,0,0);
204
-        $s.=' &nbsp; ';
205
-        $s.=$langs->trans("Before").' < '.$form->selectDate(-1,'subscriptionbefore',0,0,1,'fraise',1,0,0);
201
+        $s .= '<br>';
202
+        $s .= $langs->trans("DateEndSubscription").': &nbsp;';
203
+        $s .= $langs->trans("After").' > '.$form->selectDate(-1, 'subscriptionafter', 0, 0, 1, 'fraise', 1, 0, 0);
204
+        $s .= ' &nbsp; ';
205
+        $s .= $langs->trans("Before").' < '.$form->selectDate(-1, 'subscriptionbefore', 0, 0, 1, 'fraise', 1, 0, 0);
206 206
 
207 207
         return $s;
208 208
     }
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
      */
217 217
     function url($id)
218 218
     {
219
-        return '<a href="'.DOL_URL_ROOT.'/adherents/card.php?rowid='.$id.'">'.img_object('',"user").'</a>';
219
+        return '<a href="'.DOL_URL_ROOT.'/adherents/card.php?rowid='.$id.'">'.img_object('', "user").'</a>';
220 220
     }
221 221
 
222 222
 
@@ -230,49 +230,49 @@  discard block
 block discarded – undo
230 230
     function add_to_target($mailing_id)
231 231
     {
232 232
         // phpcs:enable
233
-    	global $langs,$_POST;
233
+    	global $langs, $_POST;
234 234
 
235 235
     	// Load translation files required by the page
236
-        $langs->loadLangs(array("members","companies"));
236
+        $langs->loadLangs(array("members", "companies"));
237 237
 
238 238
         $cibles = array();
239
-        $now=dol_now();
239
+        $now = dol_now();
240 240
 
241
-        $dateendsubscriptionafter=dol_mktime($_POST['subscriptionafterhour'],$_POST['subscriptionaftermin'],$_POST['subscriptionaftersec'],$_POST['subscriptionaftermonth'],$_POST['subscriptionafterday'],$_POST['subscriptionafteryear']);
242
-        $dateendsubscriptionbefore=dol_mktime($_POST['subscriptionbeforehour'],$_POST['subscriptionbeforemin'],$_POST['subscriptionbeforesec'],$_POST['subscriptionbeforemonth'],$_POST['subscriptionbeforeday'],$_POST['subscriptionbeforeyear']);
241
+        $dateendsubscriptionafter = dol_mktime($_POST['subscriptionafterhour'], $_POST['subscriptionaftermin'], $_POST['subscriptionaftersec'], $_POST['subscriptionaftermonth'], $_POST['subscriptionafterday'], $_POST['subscriptionafteryear']);
242
+        $dateendsubscriptionbefore = dol_mktime($_POST['subscriptionbeforehour'], $_POST['subscriptionbeforemin'], $_POST['subscriptionbeforesec'], $_POST['subscriptionbeforemonth'], $_POST['subscriptionbeforeday'], $_POST['subscriptionbeforeyear']);
243 243
 
244 244
         // La requete doit retourner: id, email, fk_contact, name, firstname
245 245
         $sql = "SELECT a.rowid as id, a.email as email, null as fk_contact, ";
246
-        $sql.= " a.lastname, a.firstname,";
247
-        $sql.= " a.datefin, a.civility as civility_id, a.login, a.societe";    // Other fields
248
-        $sql.= " FROM ".MAIN_DB_PREFIX."adherent as a";
246
+        $sql .= " a.lastname, a.firstname,";
247
+        $sql .= " a.datefin, a.civility as civility_id, a.login, a.societe"; // Other fields
248
+        $sql .= " FROM ".MAIN_DB_PREFIX."adherent as a";
249 249
         if ($_POST['filter_category'])
250 250
         {
251
-        	$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_member as cm ON cm.fk_member = a.rowid";
252
-        	$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON c.rowid = cm.fk_categorie";
251
+        	$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_member as cm ON cm.fk_member = a.rowid";
252
+        	$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON c.rowid = cm.fk_categorie";
253 253
         }
254
-        $sql.= " , ".MAIN_DB_PREFIX."adherent_type as ta";
255
-        $sql.= " WHERE a.entity IN (".getEntity('member').") AND a.email <> ''";     // Note that null != '' is false
256
-        $sql.= " AND a.email NOT IN (SELECT email FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE fk_mailing=".$this->db->escape($mailing_id).")";
254
+        $sql .= " , ".MAIN_DB_PREFIX."adherent_type as ta";
255
+        $sql .= " WHERE a.entity IN (".getEntity('member').") AND a.email <> ''"; // Note that null != '' is false
256
+        $sql .= " AND a.email NOT IN (SELECT email FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE fk_mailing=".$this->db->escape($mailing_id).")";
257 257
         // Filter on status
258
-        if (isset($_POST["filter"]) && $_POST["filter"] == '-1') $sql.= " AND a.statut=-1";
259
-        if (isset($_POST["filter"]) && $_POST["filter"] == '1a') $sql.= " AND a.statut=1 AND a.datefin >= '".$this->db->idate($now)."'";
260
-        if (isset($_POST["filter"]) && $_POST["filter"] == '1b') $sql.= " AND a.statut=1 AND (a.datefin IS NULL or a.datefin < '".$this->db->idate($now)."')";
261
-        if (isset($_POST["filter"]) && $_POST["filter"] == '0')  $sql.= " AND a.statut=0";
258
+        if (isset($_POST["filter"]) && $_POST["filter"] == '-1') $sql .= " AND a.statut=-1";
259
+        if (isset($_POST["filter"]) && $_POST["filter"] == '1a') $sql .= " AND a.statut=1 AND a.datefin >= '".$this->db->idate($now)."'";
260
+        if (isset($_POST["filter"]) && $_POST["filter"] == '1b') $sql .= " AND a.statut=1 AND (a.datefin IS NULL or a.datefin < '".$this->db->idate($now)."')";
261
+        if (isset($_POST["filter"]) && $_POST["filter"] == '0')  $sql .= " AND a.statut=0";
262 262
         // Filter on date
263
-        if ($dateendsubscriptionafter > 0)  $sql.=" AND datefin > '".$this->db->idate($dateendsubscriptionafter)."'";
264
-        if ($dateendsubscriptionbefore > 0) $sql.=" AND datefin < '".$this->db->idate($dateendsubscriptionbefore)."'";
265
-        $sql.= " AND a.fk_adherent_type = ta.rowid";
263
+        if ($dateendsubscriptionafter > 0)  $sql .= " AND datefin > '".$this->db->idate($dateendsubscriptionafter)."'";
264
+        if ($dateendsubscriptionbefore > 0) $sql .= " AND datefin < '".$this->db->idate($dateendsubscriptionbefore)."'";
265
+        $sql .= " AND a.fk_adherent_type = ta.rowid";
266 266
         // Filter on type
267
-        if ($_POST['filter_type']) $sql.= " AND ta.rowid='".$_POST['filter_type']."'";
267
+        if ($_POST['filter_type']) $sql .= " AND ta.rowid='".$_POST['filter_type']."'";
268 268
         // Filter on category
269
-        if ($_POST['filter_category']) $sql.= " AND c.rowid='".$_POST['filter_category']."'";
270
-        $sql.= " ORDER BY a.email";
269
+        if ($_POST['filter_category']) $sql .= " AND c.rowid='".$_POST['filter_category']."'";
270
+        $sql .= " ORDER BY a.email";
271 271
         //print $sql;
272 272
 
273 273
         // Add targets into table
274 274
         dol_syslog(get_class($this)."::add_to_target", LOG_DEBUG);
275
-        $result=$this->db->query($sql);
275
+        $result = $this->db->query($sql);
276 276
         if ($result)
277 277
         {
278 278
             $num = $this->db->num_rows($result);
@@ -294,8 +294,8 @@  discard block
 block discarded – undo
294 294
                                 'firstname' => $obj->firstname,
295 295
                                 'other' =>
296 296
                                 ($langs->transnoentities("Login").'='.$obj->login).';'.
297
-                                ($langs->transnoentities("UserTitle").'='.($obj->civility_id?$langs->transnoentities("Civility".$obj->civility_id):'')).';'.
298
-                                ($langs->transnoentities("DateEnd").'='.dol_print_date($this->db->jdate($obj->datefin),'day')).';'.
297
+                                ($langs->transnoentities("UserTitle").'='.($obj->civility_id ? $langs->transnoentities("Civility".$obj->civility_id) : '')).';'.
298
+                                ($langs->transnoentities("DateEnd").'='.dol_print_date($this->db->jdate($obj->datefin), 'day')).';'.
299 299
                                 ($langs->transnoentities("Company").'='.$obj->societe),
300 300
                                 'source_url' => $this->url($obj->id),
301 301
                                 'source_id' => $obj->id,
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
         else
312 312
         {
313 313
             dol_syslog($this->db->error());
314
-            $this->error=$this->db->error();
314
+            $this->error = $this->db->error();
315 315
             return -1;
316 316
         }
317 317
 
Please login to merge, or discard this patch.
Braces   +33 added lines, -16 removed lines patch added patch discarded remove patch
@@ -139,7 +139,9 @@  discard block
 block discarded – undo
139 139
             $num = $this->db->num_rows($resql);
140 140
 
141 141
             $s.='<option value="0">&nbsp;</option>';
142
-            if (! $num) $s.='<option value="0" disabled="disabled">'.$langs->trans("NoCategoriesDefined").'</option>';
142
+            if (! $num) {
143
+                $s.='<option value="0" disabled="disabled">'.$langs->trans("NoCategoriesDefined").'</option>';
144
+            }
143 145
 
144 146
             $i = 0;
145 147
             while ($i < $num)
@@ -150,8 +152,7 @@  discard block
 block discarded – undo
150 152
                 $s.='</option>';
151 153
                 $i++;
152 154
             }
153
-        }
154
-        else
155
+        } else
155 156
         {
156 157
             dol_print_error($this->db);
157 158
         }
@@ -178,7 +179,9 @@  discard block
 block discarded – undo
178 179
         	$num = $this->db->num_rows($resql);
179 180
 
180 181
         	$s.='<option value="0">&nbsp;</option>';
181
-        	if (! $num) $s.='<option value="0" disabled>'.$langs->trans("NoCategoriesDefined").'</option>';
182
+        	if (! $num) {
183
+        	    $s.='<option value="0" disabled>'.$langs->trans("NoCategoriesDefined").'</option>';
184
+        	}
182 185
 
183 186
         	$i = 0;
184 187
         	while ($i < $num)
@@ -189,8 +192,7 @@  discard block
 block discarded – undo
189 192
         		$s.='</option>';
190 193
         		$i++;
191 194
         	}
192
-        }
193
-        else
195
+        } else
194 196
         {
195 197
         	dol_print_error($this->db);
196 198
         }
@@ -255,18 +257,34 @@  discard block
 block discarded – undo
255 257
         $sql.= " WHERE a.entity IN (".getEntity('member').") AND a.email <> ''";     // Note that null != '' is false
256 258
         $sql.= " AND a.email NOT IN (SELECT email FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE fk_mailing=".$this->db->escape($mailing_id).")";
257 259
         // Filter on status
258
-        if (isset($_POST["filter"]) && $_POST["filter"] == '-1') $sql.= " AND a.statut=-1";
259
-        if (isset($_POST["filter"]) && $_POST["filter"] == '1a') $sql.= " AND a.statut=1 AND a.datefin >= '".$this->db->idate($now)."'";
260
-        if (isset($_POST["filter"]) && $_POST["filter"] == '1b') $sql.= " AND a.statut=1 AND (a.datefin IS NULL or a.datefin < '".$this->db->idate($now)."')";
261
-        if (isset($_POST["filter"]) && $_POST["filter"] == '0')  $sql.= " AND a.statut=0";
260
+        if (isset($_POST["filter"]) && $_POST["filter"] == '-1') {
261
+            $sql.= " AND a.statut=-1";
262
+        }
263
+        if (isset($_POST["filter"]) && $_POST["filter"] == '1a') {
264
+            $sql.= " AND a.statut=1 AND a.datefin >= '".$this->db->idate($now)."'";
265
+        }
266
+        if (isset($_POST["filter"]) && $_POST["filter"] == '1b') {
267
+            $sql.= " AND a.statut=1 AND (a.datefin IS NULL or a.datefin < '".$this->db->idate($now)."')";
268
+        }
269
+        if (isset($_POST["filter"]) && $_POST["filter"] == '0') {
270
+            $sql.= " AND a.statut=0";
271
+        }
262 272
         // Filter on date
263
-        if ($dateendsubscriptionafter > 0)  $sql.=" AND datefin > '".$this->db->idate($dateendsubscriptionafter)."'";
264
-        if ($dateendsubscriptionbefore > 0) $sql.=" AND datefin < '".$this->db->idate($dateendsubscriptionbefore)."'";
273
+        if ($dateendsubscriptionafter > 0) {
274
+            $sql.=" AND datefin > '".$this->db->idate($dateendsubscriptionafter)."'";
275
+        }
276
+        if ($dateendsubscriptionbefore > 0) {
277
+            $sql.=" AND datefin < '".$this->db->idate($dateendsubscriptionbefore)."'";
278
+        }
265 279
         $sql.= " AND a.fk_adherent_type = ta.rowid";
266 280
         // Filter on type
267
-        if ($_POST['filter_type']) $sql.= " AND ta.rowid='".$_POST['filter_type']."'";
281
+        if ($_POST['filter_type']) {
282
+            $sql.= " AND ta.rowid='".$_POST['filter_type']."'";
283
+        }
268 284
         // Filter on category
269
-        if ($_POST['filter_category']) $sql.= " AND c.rowid='".$_POST['filter_category']."'";
285
+        if ($_POST['filter_category']) {
286
+            $sql.= " AND c.rowid='".$_POST['filter_category']."'";
287
+        }
270 288
         $sql.= " ORDER BY a.email";
271 289
         //print $sql;
272 290
 
@@ -307,8 +325,7 @@  discard block
 block discarded – undo
307 325
 
308 326
                 $i++;
309 327
             }
310
-        }
311
-        else
328
+        } else
312 329
         {
313 330
             dol_syslog($this->db->error());
314 331
             $this->error=$this->db->error();
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/mailings/modules_mailings.php 3 patches
Indentation   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -37,22 +37,22 @@  discard block
 block discarded – undo
37 37
     public $db;
38 38
 
39 39
     /**
40
-	 * @var string Error code (or message)
41
-	 */
42
-	public $error='';
40
+     * @var string Error code (or message)
41
+     */
42
+    public $error='';
43 43
 
44 44
     public $tooltip='';
45 45
 
46 46
 
47 47
     /**
48
-	 *	Constructor
49
-	 *
50
-	 *  @param		DoliDB		$db      Database handler
51
-	 */
52
-	function __construct($db)
53
-	{
48
+     *	Constructor
49
+     *
50
+     *  @param		DoliDB		$db      Database handler
51
+     */
52
+    function __construct($db)
53
+    {
54 54
         $this->db = $db;
55
-	}
55
+    }
56 56
 
57 57
     /**
58 58
      * Return description of email selector
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
     }
77 77
 
78 78
     /**
79
-	 *	Return number of records for email selector
79
+     *	Return number of records for email selector
80 80
      *
81 81
      *  @return     integer      Example
82 82
      */
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
         }
102 102
         else
103 103
         {
104
-        	$this->error=$this->db->lasterror();
104
+            $this->error=$this->db->lasterror();
105 105
             return -1;
106 106
         }
107 107
     }
@@ -162,51 +162,51 @@  discard block
 block discarded – undo
162 162
     function add_to_target($mailing_id, $cibles)
163 163
     {
164 164
         // phpcs:enable
165
-    	global $conf;
165
+        global $conf;
166 166
 
167
-    	$this->db->begin();
167
+        $this->db->begin();
168 168
 
169 169
         // Insert emailing targets from array into database
170 170
         $j = 0;
171 171
         $num = count($cibles);
172 172
         foreach ($cibles as $targetarray)
173 173
         {
174
-        	if (! empty($targetarray['email'])) // avoid empty email address
175
-        	{
176
-        		$sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing_cibles";
177
-        		$sql.= " (fk_mailing,";
178
-        		$sql.= " fk_contact,";
179
-        		$sql.= " lastname, firstname, email, other, source_url, source_id,";
180
-       			$sql.= " tag,";
181
-        		$sql.= " source_type)";
182
-        		$sql.= " VALUES (".$mailing_id.",";
183
-        		$sql.= (empty($targetarray['fk_contact']) ? '0' : "'".$targetarray['fk_contact']."'") .",";
184
-        		$sql.= "'".$this->db->escape($targetarray['lastname'])."',";
185
-        		$sql.= "'".$this->db->escape($targetarray['firstname'])."',";
186
-        		$sql.= "'".$this->db->escape($targetarray['email'])."',";
187
-        		$sql.= "'".$this->db->escape($targetarray['other'])."',";
188
-        		$sql.= "'".$this->db->escape($targetarray['source_url'])."',";
189
-        		$sql.= (empty($targetarray['source_id']) ? 'null' : "'".$this->db->escape($targetarray['source_id'])."'").",";
190
-       			$sql .= "'".$this->db->escape(dol_hash($targetarray['email'].';'.$targetarray['lastname'].';'.$mailing_id.';'.$conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY))."',";
191
-        		$sql .= "'".$this->db->escape($targetarray['source_type'])."')";
192
-        		dol_syslog(get_class($this)."::".__METHOD__,LOG_DEBUG);
193
-        		$result=$this->db->query($sql);
194
-        		if ($result)
195
-        		{
196
-        			$j++;
197
-        		}
198
-        		else
199
-        		{
200
-        			if ($this->db->errno() != 'DB_ERROR_RECORD_ALREADY_EXISTS')
201
-        			{
202
-        				// Si erreur autre que doublon
203
-        				dol_syslog($this->db->error());
204
-        				$this->error=$this->db->error();
205
-        				$this->db->rollback();
206
-        				return -1;
207
-        			}
208
-        		}
209
-        	}
174
+            if (! empty($targetarray['email'])) // avoid empty email address
175
+            {
176
+                $sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing_cibles";
177
+                $sql.= " (fk_mailing,";
178
+                $sql.= " fk_contact,";
179
+                $sql.= " lastname, firstname, email, other, source_url, source_id,";
180
+                    $sql.= " tag,";
181
+                $sql.= " source_type)";
182
+                $sql.= " VALUES (".$mailing_id.",";
183
+                $sql.= (empty($targetarray['fk_contact']) ? '0' : "'".$targetarray['fk_contact']."'") .",";
184
+                $sql.= "'".$this->db->escape($targetarray['lastname'])."',";
185
+                $sql.= "'".$this->db->escape($targetarray['firstname'])."',";
186
+                $sql.= "'".$this->db->escape($targetarray['email'])."',";
187
+                $sql.= "'".$this->db->escape($targetarray['other'])."',";
188
+                $sql.= "'".$this->db->escape($targetarray['source_url'])."',";
189
+                $sql.= (empty($targetarray['source_id']) ? 'null' : "'".$this->db->escape($targetarray['source_id'])."'").",";
190
+                    $sql .= "'".$this->db->escape(dol_hash($targetarray['email'].';'.$targetarray['lastname'].';'.$mailing_id.';'.$conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY))."',";
191
+                $sql .= "'".$this->db->escape($targetarray['source_type'])."')";
192
+                dol_syslog(get_class($this)."::".__METHOD__,LOG_DEBUG);
193
+                $result=$this->db->query($sql);
194
+                if ($result)
195
+                {
196
+                    $j++;
197
+                }
198
+                else
199
+                {
200
+                    if ($this->db->errno() != 'DB_ERROR_RECORD_ALREADY_EXISTS')
201
+                    {
202
+                        // Si erreur autre que doublon
203
+                        dol_syslog($this->db->error());
204
+                        $this->error=$this->db->error();
205
+                        $this->db->rollback();
206
+                        return -1;
207
+                    }
208
+                }
209
+            }
210 210
         }
211 211
 
212 212
         dol_syslog(get_class($this)."::".__METHOD__.": mailing ".$j." targets added");
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
         $result=$this->db->query($sql);
238 238
         if (! $result)
239 239
         {
240
-        	dol_print_error($this->db);
240
+            dol_print_error($this->db);
241 241
         }
242 242
 
243 243
         $this->update_nb($mailing_id);
Please login to merge, or discard this patch.
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -39,9 +39,9 @@  discard block
 block discarded – undo
39 39
     /**
40 40
 	 * @var string Error code (or message)
41 41
 	 */
42
-	public $error='';
42
+	public $error = '';
43 43
 
44
-    public $tooltip='';
44
+    public $tooltip = '';
45 45
 
46 46
 
47 47
     /**
@@ -64,12 +64,12 @@  discard block
 block discarded – undo
64 64
         global $langs, $form;
65 65
 
66 66
         $langs->load("mails");
67
-        $transstring="MailingModuleDesc".$this->name;
68
-        $s='';
67
+        $transstring = "MailingModuleDesc".$this->name;
68
+        $s = '';
69 69
 
70
-        if ($langs->trans($this->name) != $this->name) $s=$langs->trans($this->name);
71
-        elseif ($langs->trans($transstring) != $transstring) $s=$langs->trans($transstring);
72
-        else $s=$this->desc;
70
+        if ($langs->trans($this->name) != $this->name) $s = $langs->trans($this->name);
71
+        elseif ($langs->trans($transstring) != $transstring) $s = $langs->trans($transstring);
72
+        else $s = $this->desc;
73 73
 
74 74
         if ($this->tooltip && is_object($form)) $s .= ' '.$form->textwithpicto('', $langs->trans($this->tooltip), 1, 1);
75 75
         return $s;
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
      */
94 94
     function getNbOfRecipients($sql)
95 95
     {
96
-        $result=$this->db->query($sql);
96
+        $result = $this->db->query($sql);
97 97
         if ($result)
98 98
         {
99 99
             $obj = $this->db->fetch_object($result);
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
         }
102 102
         else
103 103
         {
104
-        	$this->error=$this->db->lasterror();
104
+        	$this->error = $this->db->lasterror();
105 105
             return -1;
106 106
         }
107 107
     }
@@ -130,18 +130,18 @@  discard block
 block discarded – undo
130 130
         // Mise a jour nombre de destinataire dans table des mailings
131 131
         $sql = "SELECT COUNT(*) nb FROM ".MAIN_DB_PREFIX."mailing_cibles";
132 132
         $sql .= " WHERE fk_mailing = ".$mailing_id;
133
-        $result=$this->db->query($sql);
133
+        $result = $this->db->query($sql);
134 134
         if ($result)
135 135
         {
136
-            $obj=$this->db->fetch_object($result);
137
-            $nb=$obj->nb;
136
+            $obj = $this->db->fetch_object($result);
137
+            $nb = $obj->nb;
138 138
 
139 139
             $sql = "UPDATE ".MAIN_DB_PREFIX."mailing";
140 140
             $sql .= " SET nbemail = ".$nb." WHERE rowid = ".$mailing_id;
141 141
             if (!$this->db->query($sql))
142 142
             {
143 143
                 dol_syslog($this->db->error());
144
-                $this->error=$this->db->error();
144
+                $this->error = $this->db->error();
145 145
                 return -1;
146 146
             }
147 147
         }
@@ -171,26 +171,26 @@  discard block
 block discarded – undo
171 171
         $num = count($cibles);
172 172
         foreach ($cibles as $targetarray)
173 173
         {
174
-        	if (! empty($targetarray['email'])) // avoid empty email address
174
+        	if (!empty($targetarray['email'])) // avoid empty email address
175 175
         	{
176 176
         		$sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing_cibles";
177
-        		$sql.= " (fk_mailing,";
178
-        		$sql.= " fk_contact,";
179
-        		$sql.= " lastname, firstname, email, other, source_url, source_id,";
180
-       			$sql.= " tag,";
181
-        		$sql.= " source_type)";
182
-        		$sql.= " VALUES (".$mailing_id.",";
183
-        		$sql.= (empty($targetarray['fk_contact']) ? '0' : "'".$targetarray['fk_contact']."'") .",";
184
-        		$sql.= "'".$this->db->escape($targetarray['lastname'])."',";
185
-        		$sql.= "'".$this->db->escape($targetarray['firstname'])."',";
186
-        		$sql.= "'".$this->db->escape($targetarray['email'])."',";
187
-        		$sql.= "'".$this->db->escape($targetarray['other'])."',";
188
-        		$sql.= "'".$this->db->escape($targetarray['source_url'])."',";
189
-        		$sql.= (empty($targetarray['source_id']) ? 'null' : "'".$this->db->escape($targetarray['source_id'])."'").",";
177
+        		$sql .= " (fk_mailing,";
178
+        		$sql .= " fk_contact,";
179
+        		$sql .= " lastname, firstname, email, other, source_url, source_id,";
180
+       			$sql .= " tag,";
181
+        		$sql .= " source_type)";
182
+        		$sql .= " VALUES (".$mailing_id.",";
183
+        		$sql .= (empty($targetarray['fk_contact']) ? '0' : "'".$targetarray['fk_contact']."'").",";
184
+        		$sql .= "'".$this->db->escape($targetarray['lastname'])."',";
185
+        		$sql .= "'".$this->db->escape($targetarray['firstname'])."',";
186
+        		$sql .= "'".$this->db->escape($targetarray['email'])."',";
187
+        		$sql .= "'".$this->db->escape($targetarray['other'])."',";
188
+        		$sql .= "'".$this->db->escape($targetarray['source_url'])."',";
189
+        		$sql .= (empty($targetarray['source_id']) ? 'null' : "'".$this->db->escape($targetarray['source_id'])."'").",";
190 190
        			$sql .= "'".$this->db->escape(dol_hash($targetarray['email'].';'.$targetarray['lastname'].';'.$mailing_id.';'.$conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY))."',";
191 191
         		$sql .= "'".$this->db->escape($targetarray['source_type'])."')";
192
-        		dol_syslog(get_class($this)."::".__METHOD__,LOG_DEBUG);
193
-        		$result=$this->db->query($sql);
192
+        		dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG);
193
+        		$result = $this->db->query($sql);
194 194
         		if ($result)
195 195
         		{
196 196
         			$j++;
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
         			{
202 202
         				// Si erreur autre que doublon
203 203
         				dol_syslog($this->db->error());
204
-        				$this->error=$this->db->error();
204
+        				$this->error = $this->db->error();
205 205
         				$this->db->rollback();
206 206
         				return -1;
207 207
         			}
@@ -234,8 +234,8 @@  discard block
 block discarded – undo
234 234
         $sql .= " WHERE fk_mailing=".$mailing_id." AND email IN (SELECT mu.email FROM ".MAIN_DB_PREFIX."mailing_unsubscribe AS mu WHERE mu.entity IN ('".getEntity('mailing')."'))";
235 235
 
236 236
         dol_syslog(get_class($this)."::".__METHOD__.":mailing update status to display emails that do not want to be contacted anymore", LOG_DEBUG);
237
-        $result=$this->db->query($sql);
238
-        if (! $result)
237
+        $result = $this->db->query($sql);
238
+        if (!$result)
239 239
         {
240 240
         	dol_print_error($this->db);
241 241
         }
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
         $sql = "DELETE FROM ".MAIN_DB_PREFIX."mailing_cibles";
261 261
         $sql .= " WHERE fk_mailing = ".$mailing_id;
262 262
 
263
-        if (! $this->db->query($sql))
263
+        if (!$this->db->query($sql))
264 264
         {
265 265
             dol_syslog($this->db->error());
266 266
         }
Please login to merge, or discard this patch.
Braces   +16 added lines, -11 removed lines patch added patch discarded remove patch
@@ -67,11 +67,17 @@  discard block
 block discarded – undo
67 67
         $transstring="MailingModuleDesc".$this->name;
68 68
         $s='';
69 69
 
70
-        if ($langs->trans($this->name) != $this->name) $s=$langs->trans($this->name);
71
-        elseif ($langs->trans($transstring) != $transstring) $s=$langs->trans($transstring);
72
-        else $s=$this->desc;
70
+        if ($langs->trans($this->name) != $this->name) {
71
+            $s=$langs->trans($this->name);
72
+        } elseif ($langs->trans($transstring) != $transstring) {
73
+            $s=$langs->trans($transstring);
74
+        } else {
75
+            $s=$this->desc;
76
+        }
73 77
 
74
-        if ($this->tooltip && is_object($form)) $s .= ' '.$form->textwithpicto('', $langs->trans($this->tooltip), 1, 1);
78
+        if ($this->tooltip && is_object($form)) {
79
+            $s .= ' '.$form->textwithpicto('', $langs->trans($this->tooltip), 1, 1);
80
+        }
75 81
         return $s;
76 82
     }
77 83
 
@@ -98,8 +104,7 @@  discard block
 block discarded – undo
98 104
         {
99 105
             $obj = $this->db->fetch_object($result);
100 106
             return $obj->nb;
101
-        }
102
-        else
107
+        } else
103 108
         {
104 109
         	$this->error=$this->db->lasterror();
105 110
             return -1;
@@ -144,8 +149,7 @@  discard block
 block discarded – undo
144 149
                 $this->error=$this->db->error();
145 150
                 return -1;
146 151
             }
147
-        }
148
-        else {
152
+        } else {
149 153
             return -1;
150 154
         }
151 155
         return $nb;
@@ -171,9 +175,11 @@  discard block
 block discarded – undo
171 175
         $num = count($cibles);
172 176
         foreach ($cibles as $targetarray)
173 177
         {
174
-        	if (! empty($targetarray['email'])) // avoid empty email address
178
+        	if (! empty($targetarray['email'])) {
179
+        	    // avoid empty email address
175 180
         	{
176 181
         		$sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing_cibles";
182
+        	}
177 183
         		$sql.= " (fk_mailing,";
178 184
         		$sql.= " fk_contact,";
179 185
         		$sql.= " lastname, firstname, email, other, source_url, source_id,";
@@ -194,8 +200,7 @@  discard block
 block discarded – undo
194 200
         		if ($result)
195 201
         		{
196 202
         			$j++;
197
-        		}
198
-        		else
203
+        		} else
199 204
         		{
200 205
         			if ($this->db->errno() != 'DB_ERROR_RECORD_ALREADY_EXISTS')
201 206
         			{
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/mailings/thirdparties.modules.php 3 patches
Indentation   +204 added lines, -204 removed lines patch added patch discarded remove patch
@@ -24,77 +24,77 @@  discard block
 block discarded – undo
24 24
  */
25 25
 class mailing_thirdparties extends MailingTargets
26 26
 {
27
-	var $name='ThirdPartiesByCategories';
28
-	// This label is used if no translation is found for key XXX neither MailingModuleDescXXX where XXX=name is found
29
-	var $desc="Third parties (by categories)";
30
-	var $require_admin=0;
27
+    var $name='ThirdPartiesByCategories';
28
+    // This label is used if no translation is found for key XXX neither MailingModuleDescXXX where XXX=name is found
29
+    var $desc="Third parties (by categories)";
30
+    var $require_admin=0;
31 31
 
32
-	var $require_module=array("societe");	// This module allows to select by categories must be also enabled if category module is not activated
33
-	var $picto='company';
32
+    var $require_module=array("societe");	// This module allows to select by categories must be also enabled if category module is not activated
33
+    var $picto='company';
34 34
 
35
-	/**
35
+    /**
36 36
      * @var DoliDB Database handler.
37 37
      */
38 38
     public $db;
39 39
 
40 40
 
41
-	/**
42
-	 *	Constructor
43
-	 *
44
-	 *  @param		DoliDB		$db      Database handler
45
-	 */
46
-	function __construct($db)
47
-	{
48
-		global $conf, $langs;
41
+    /**
42
+     *	Constructor
43
+     *
44
+     *  @param		DoliDB		$db      Database handler
45
+     */
46
+    function __construct($db)
47
+    {
48
+        global $conf, $langs;
49 49
         $langs->load("companies");
50 50
 
51
-		$this->db=$db;
52
-	}
51
+        $this->db=$db;
52
+    }
53 53
 
54 54
 
55 55
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
56
-	/**
57
-	 *    This is the main function that returns the array of emails
58
-	 *
59
-	 *    @param	int		$mailing_id    	Id of mailing. No need to use it.
60
-	 *    @return   int 					<0 if error, number of emails added if ok
61
-	 */
62
-	function add_to_target($mailing_id)
63
-	{
56
+    /**
57
+     *    This is the main function that returns the array of emails
58
+     *
59
+     *    @param	int		$mailing_id    	Id of mailing. No need to use it.
60
+     *    @return   int 					<0 if error, number of emails added if ok
61
+     */
62
+    function add_to_target($mailing_id)
63
+    {
64 64
         // phpcs:enable
65
-		global $conf, $langs;
66
-
67
-		$cibles = array();
68
-
69
-		// Select the third parties from category
70
-		if (empty($_POST['filter']))
71
-		{
72
-		    $sql = "SELECT s.rowid as id, s.email as email, s.nom as name, null as fk_contact, null as firstname, null as label";
73
-		    $sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
74
-		    $sql.= " WHERE s.email <> ''";
75
-		    $sql.= " AND s.entity IN (".getEntity('societe').")";
76
-		    $sql.= " AND s.email NOT IN (SELECT email FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE fk_mailing=".$mailing_id.")";
77
-		}
78
-		else
79
-		{
80
-		    $sql = "SELECT s.rowid as id, s.email as email, s.nom as name, null as fk_contact, null as firstname, c.label as label";
81
-		    $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."categorie_societe as cs, ".MAIN_DB_PREFIX."categorie as c";
82
-		    $sql.= " WHERE s.email <> ''";
83
-		    $sql.= " AND s.entity IN (".getEntity('societe').")";
84
-		    $sql.= " AND s.email NOT IN (SELECT email FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE fk_mailing=".$mailing_id.")";
85
-		    $sql.= " AND cs.fk_soc = s.rowid";
86
-		    $sql.= " AND c.rowid = cs.fk_categorie";
87
-		    $sql.= " AND c.rowid='".$this->db->escape($_POST['filter'])."'";
88
-		    $sql.= " UNION ";
89
-		    $sql.= "SELECT s.rowid as id, s.email as email, s.nom as name, null as fk_contact, null as firstname, c.label as label";
90
-		    $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."categorie_fournisseur as cs, ".MAIN_DB_PREFIX."categorie as c";
91
-		    $sql.= " WHERE s.email <> ''";
92
-		    $sql.= " AND s.entity IN (".getEntity('societe').")";
93
-		    $sql.= " AND s.email NOT IN (SELECT email FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE fk_mailing=".$mailing_id.")";
94
-		    $sql.= " AND cs.fk_soc = s.rowid";
95
-		    $sql.= " AND c.rowid = cs.fk_categorie";
96
-		    $sql.= " AND c.rowid='".$this->db->escape($_POST['filter'])."'";
97
-		}
65
+        global $conf, $langs;
66
+
67
+        $cibles = array();
68
+
69
+        // Select the third parties from category
70
+        if (empty($_POST['filter']))
71
+        {
72
+            $sql = "SELECT s.rowid as id, s.email as email, s.nom as name, null as fk_contact, null as firstname, null as label";
73
+            $sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
74
+            $sql.= " WHERE s.email <> ''";
75
+            $sql.= " AND s.entity IN (".getEntity('societe').")";
76
+            $sql.= " AND s.email NOT IN (SELECT email FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE fk_mailing=".$mailing_id.")";
77
+        }
78
+        else
79
+        {
80
+            $sql = "SELECT s.rowid as id, s.email as email, s.nom as name, null as fk_contact, null as firstname, c.label as label";
81
+            $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."categorie_societe as cs, ".MAIN_DB_PREFIX."categorie as c";
82
+            $sql.= " WHERE s.email <> ''";
83
+            $sql.= " AND s.entity IN (".getEntity('societe').")";
84
+            $sql.= " AND s.email NOT IN (SELECT email FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE fk_mailing=".$mailing_id.")";
85
+            $sql.= " AND cs.fk_soc = s.rowid";
86
+            $sql.= " AND c.rowid = cs.fk_categorie";
87
+            $sql.= " AND c.rowid='".$this->db->escape($_POST['filter'])."'";
88
+            $sql.= " UNION ";
89
+            $sql.= "SELECT s.rowid as id, s.email as email, s.nom as name, null as fk_contact, null as firstname, c.label as label";
90
+            $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."categorie_fournisseur as cs, ".MAIN_DB_PREFIX."categorie as c";
91
+            $sql.= " WHERE s.email <> ''";
92
+            $sql.= " AND s.entity IN (".getEntity('societe').")";
93
+            $sql.= " AND s.email NOT IN (SELECT email FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE fk_mailing=".$mailing_id.")";
94
+            $sql.= " AND cs.fk_soc = s.rowid";
95
+            $sql.= " AND c.rowid = cs.fk_categorie";
96
+            $sql.= " AND c.rowid='".$this->db->escape($_POST['filter'])."'";
97
+        }
98 98
 
99 99
         $addDescription= "";
100 100
         if (isset($_POST["filter_client"]) && $_POST["filter_client"] <> '-1')
@@ -143,149 +143,149 @@  discard block
 block discarded – undo
143 143
         $sql.= " ORDER BY email";
144 144
 
145 145
         // Stock recipients emails into targets table
146
-		$result=$this->db->query($sql);
147
-		if ($result)
148
-		{
149
-			$num = $this->db->num_rows($result);
150
-			$i = 0;
151
-			$j = 0;
152
-
153
-			dol_syslog(get_class($this)."::add_to_target mailing ".$num." targets found");
154
-
155
-			$old = '';
156
-			while ($i < $num)
157
-			{
158
-				$obj = $this->db->fetch_object($result);
159
-				if ($old <> $obj->email)
160
-				{
161
-					$otherTxt= ($obj->label?$langs->transnoentities("Category").'='.$obj->label:'');
162
-					if (strlen($addDescription) > 0 && strlen($otherTxt) > 0)
163
-					{
164
-						$otherTxt.= ";";
165
-					}
166
-					$otherTxt.= $addDescription;
167
-					$cibles[$j] = array(
168
-                    			'email' => $obj->email,
169
-                    			'fk_contact' => $obj->fk_contact,
170
-                    			'lastname' => $obj->name,	// For a thirdparty, we must use name
171
-                    			'firstname' => '',			// For a thirdparty, lastname is ''
172
-                    			'other' => $otherTxt,
146
+        $result=$this->db->query($sql);
147
+        if ($result)
148
+        {
149
+            $num = $this->db->num_rows($result);
150
+            $i = 0;
151
+            $j = 0;
152
+
153
+            dol_syslog(get_class($this)."::add_to_target mailing ".$num." targets found");
154
+
155
+            $old = '';
156
+            while ($i < $num)
157
+            {
158
+                $obj = $this->db->fetch_object($result);
159
+                if ($old <> $obj->email)
160
+                {
161
+                    $otherTxt= ($obj->label?$langs->transnoentities("Category").'='.$obj->label:'');
162
+                    if (strlen($addDescription) > 0 && strlen($otherTxt) > 0)
163
+                    {
164
+                        $otherTxt.= ";";
165
+                    }
166
+                    $otherTxt.= $addDescription;
167
+                    $cibles[$j] = array(
168
+                                'email' => $obj->email,
169
+                                'fk_contact' => $obj->fk_contact,
170
+                                'lastname' => $obj->name,	// For a thirdparty, we must use name
171
+                                'firstname' => '',			// For a thirdparty, lastname is ''
172
+                                'other' => $otherTxt,
173 173
                                 'source_url' => $this->url($obj->id),
174 174
                                 'source_id' => $obj->id,
175 175
                                 'source_type' => 'thirdparty'
176
-					);
177
-					$old = $obj->email;
178
-					$j++;
179
-				}
176
+                    );
177
+                    $old = $obj->email;
178
+                    $j++;
179
+                }
180
+
181
+                $i++;
182
+            }
183
+        }
184
+        else
185
+        {
186
+            dol_syslog($this->db->error());
187
+            $this->error=$this->db->error();
188
+            return -1;
189
+        }
190
+
191
+        return parent::add_to_target($mailing_id, $cibles);
192
+    }
193
+
180 194
 
181
-				$i++;
182
-			}
183
-		}
184
-		else
185
-		{
186
-			dol_syslog($this->db->error());
187
-			$this->error=$this->db->error();
188
-			return -1;
189
-		}
195
+    /**
196
+     *	On the main mailing area, there is a box with statistics.
197
+     *	If you want to add a line in this report you must provide an
198
+     *	array of SQL request that returns two field:
199
+     *	One called "label", One called "nb".
200
+     *
201
+     *	@return		array		Array with SQL requests
202
+     */
203
+    function getSqlArrayForStats()
204
+    {
205
+        // CHANGE THIS: Optionnal
206
+
207
+        //var $statssql=array();
208
+        //$this->statssql[0]="SELECT field1 as label, count(distinct(email)) as nb FROM mytable WHERE email IS NOT NULL";
209
+        return array();
210
+    }
211
+
212
+
213
+    /**
214
+     *	Return here number of distinct emails returned by your selector.
215
+     *	For example if this selector is used to extract 500 different
216
+     *	emails from a text file, this function must return 500.
217
+     *
218
+     *  @param      string	$sql        Requete sql de comptage
219
+     *	@return		int					Nb of recipients
220
+     */
221
+    function getNbOfRecipients($sql='')
222
+    {
223
+        global $conf;
190 224
 
191
-		return parent::add_to_target($mailing_id, $cibles);
192
-	}
225
+        $sql = "SELECT count(distinct(s.email)) as nb";
226
+        $sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
227
+        $sql.= " WHERE s.email != ''";
228
+        $sql.= " AND s.entity IN (".getEntity('societe').")";
193 229
 
230
+        // La requete doit retourner un champ "nb" pour etre comprise
231
+        // par parent::getNbOfRecipients
232
+        return parent::getNbOfRecipients($sql);
233
+    }
194 234
 
195 235
     /**
196
-	 *	On the main mailing area, there is a box with statistics.
197
-	 *	If you want to add a line in this report you must provide an
198
-	 *	array of SQL request that returns two field:
199
-	 *	One called "label", One called "nb".
200
-	 *
201
-	 *	@return		array		Array with SQL requests
202
-	 */
203
-	function getSqlArrayForStats()
204
-	{
205
-		// CHANGE THIS: Optionnal
206
-
207
-		//var $statssql=array();
208
-		//$this->statssql[0]="SELECT field1 as label, count(distinct(email)) as nb FROM mytable WHERE email IS NOT NULL";
209
-		return array();
210
-	}
211
-
212
-
213
-	/**
214
-	 *	Return here number of distinct emails returned by your selector.
215
-	 *	For example if this selector is used to extract 500 different
216
-	 *	emails from a text file, this function must return 500.
217
-	 *
218
-	 *  @param      string	$sql        Requete sql de comptage
219
-	 *	@return		int					Nb of recipients
220
-	 */
221
-	function getNbOfRecipients($sql='')
222
-	{
223
-		global $conf;
224
-
225
-		$sql = "SELECT count(distinct(s.email)) as nb";
226
-		$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
227
-		$sql.= " WHERE s.email != ''";
228
-		$sql.= " AND s.entity IN (".getEntity('societe').")";
229
-
230
-		// La requete doit retourner un champ "nb" pour etre comprise
231
-		// par parent::getNbOfRecipients
232
-		return parent::getNbOfRecipients($sql);
233
-	}
234
-
235
-	/**
236
-	 *  This is to add a form filter to provide variant of selector
237
-	 *	If used, the HTML select must be called "filter"
238
-	 *
239
-	 *  @return     string      A html select zone
240
-	 */
241
-	function formFilter()
242
-	{
243
-		global $conf, $langs;
244
-
245
-		$langs->load("companies");
246
-
247
-		$s=$langs->trans("Categories").': ';
248
-		$s.='<select name="filter" class="flat">';
249
-
250
-		// Show categories
251
-		$sql = "SELECT rowid, label, type, visible";
252
-		$sql.= " FROM ".MAIN_DB_PREFIX."categorie";
253
-		$sql.= " WHERE type in (1,2)";	// We keep only categories for suppliers and customers/prospects
254
-		// $sql.= " AND visible > 0";	// We ignore the property visible because third party's categories does not use this property (only products categories use it).
255
-		$sql.= " AND entity = ".$conf->entity;
256
-		$sql.= " ORDER BY label";
257
-
258
-		//print $sql;
259
-		$resql = $this->db->query($sql);
260
-		if ($resql)
261
-		{
262
-			$num = $this->db->num_rows($resql);
263
-
264
-			if (empty($conf->categorie->enabled)) $num=0;	// Force empty list if category module is not enabled
265
-
266
-			if ($num) $s.='<option value="0">&nbsp;</option>';
267
-			else $s.='<option value="0">'.$langs->trans("ContactsAllShort").'</option>';
268
-
269
-			$i = 0;
270
-			while ($i < $num)
271
-			{
272
-				$obj = $this->db->fetch_object($resql);
273
-
274
-				$type='';
275
-				if ($obj->type == 1) $type=$langs->trans("Supplier");
276
-				if ($obj->type == 2) $type=$langs->trans("Customer");
277
-				$s.='<option value="'.$obj->rowid.'">'.dol_trunc($obj->label,38,'middle');
278
-				if ($type) $s.=' ('.$type.')';
279
-				$s.='</option>';
280
-				$i++;
281
-			}
282
-		}
283
-		else
284
-		{
285
-			dol_print_error($this->db);
286
-		}
287
-
288
-		$s.='</select> ';
236
+     *  This is to add a form filter to provide variant of selector
237
+     *	If used, the HTML select must be called "filter"
238
+     *
239
+     *  @return     string      A html select zone
240
+     */
241
+    function formFilter()
242
+    {
243
+        global $conf, $langs;
244
+
245
+        $langs->load("companies");
246
+
247
+        $s=$langs->trans("Categories").': ';
248
+        $s.='<select name="filter" class="flat">';
249
+
250
+        // Show categories
251
+        $sql = "SELECT rowid, label, type, visible";
252
+        $sql.= " FROM ".MAIN_DB_PREFIX."categorie";
253
+        $sql.= " WHERE type in (1,2)";	// We keep only categories for suppliers and customers/prospects
254
+        // $sql.= " AND visible > 0";	// We ignore the property visible because third party's categories does not use this property (only products categories use it).
255
+        $sql.= " AND entity = ".$conf->entity;
256
+        $sql.= " ORDER BY label";
257
+
258
+        //print $sql;
259
+        $resql = $this->db->query($sql);
260
+        if ($resql)
261
+        {
262
+            $num = $this->db->num_rows($resql);
263
+
264
+            if (empty($conf->categorie->enabled)) $num=0;	// Force empty list if category module is not enabled
265
+
266
+            if ($num) $s.='<option value="0">&nbsp;</option>';
267
+            else $s.='<option value="0">'.$langs->trans("ContactsAllShort").'</option>';
268
+
269
+            $i = 0;
270
+            while ($i < $num)
271
+            {
272
+                $obj = $this->db->fetch_object($resql);
273
+
274
+                $type='';
275
+                if ($obj->type == 1) $type=$langs->trans("Supplier");
276
+                if ($obj->type == 2) $type=$langs->trans("Customer");
277
+                $s.='<option value="'.$obj->rowid.'">'.dol_trunc($obj->label,38,'middle');
278
+                if ($type) $s.=' ('.$type.')';
279
+                $s.='</option>';
280
+                $i++;
281
+            }
282
+        }
283
+        else
284
+        {
285
+            dol_print_error($this->db);
286
+        }
287
+
288
+        $s.='</select> ';
289 289
                 $s.= $langs->trans('ProspectCustomer');
290 290
                 $s.=': <select name="filter_client" class="flat">';
291 291
                 $s.= '<option value="-1">&nbsp;</option>';
@@ -308,19 +308,19 @@  discard block
 block discarded – undo
308 308
                 $s.='<option value="-1">&nbsp;</option>';
309 309
                 $s.='<option value="1" selected>'.$langs->trans("Enabled").'</option>';
310 310
                 $s.='<option value="0">'.$langs->trans("Disabled").'</option>';
311
-		$s.='</select>';
312
-		return $s;
313
-	}
311
+        $s.='</select>';
312
+        return $s;
313
+    }
314 314
 
315 315
 
316 316
     /**
317
-	 *  Can include an URL link on each record provided by selector shown on target page.
318
-	 *
317
+     *  Can include an URL link on each record provided by selector shown on target page.
318
+     *
319 319
      *  @param	int		$id		ID
320
-	 *  @return string      	Url link
321
-	 */
322
-	function url($id)
323
-	{
324
-		return '<a href="'.DOL_URL_ROOT.'/societe/card.php?socid='.$id.'">'.img_object('',"company").'</a>';
325
-	}
320
+     *  @return string      	Url link
321
+     */
322
+    function url($id)
323
+    {
324
+        return '<a href="'.DOL_URL_ROOT.'/societe/card.php?socid='.$id.'">'.img_object('',"company").'</a>';
325
+    }
326 326
 }
Please login to merge, or discard this patch.
Spacing   +83 added lines, -83 removed lines patch added patch discarded remove patch
@@ -24,13 +24,13 @@  discard block
 block discarded – undo
24 24
  */
25 25
 class mailing_thirdparties extends MailingTargets
26 26
 {
27
-	var $name='ThirdPartiesByCategories';
27
+	var $name = 'ThirdPartiesByCategories';
28 28
 	// This label is used if no translation is found for key XXX neither MailingModuleDescXXX where XXX=name is found
29
-	var $desc="Third parties (by categories)";
30
-	var $require_admin=0;
29
+	var $desc = "Third parties (by categories)";
30
+	var $require_admin = 0;
31 31
 
32
-	var $require_module=array("societe");	// This module allows to select by categories must be also enabled if category module is not activated
33
-	var $picto='company';
32
+	var $require_module = array("societe"); // This module allows to select by categories must be also enabled if category module is not activated
33
+	var $picto = 'company';
34 34
 
35 35
 	/**
36 36
      * @var DoliDB Database handler.
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 		global $conf, $langs;
49 49
         $langs->load("companies");
50 50
 
51
-		$this->db=$db;
51
+		$this->db = $db;
52 52
 	}
53 53
 
54 54
 
@@ -70,80 +70,80 @@  discard block
 block discarded – undo
70 70
 		if (empty($_POST['filter']))
71 71
 		{
72 72
 		    $sql = "SELECT s.rowid as id, s.email as email, s.nom as name, null as fk_contact, null as firstname, null as label";
73
-		    $sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
74
-		    $sql.= " WHERE s.email <> ''";
75
-		    $sql.= " AND s.entity IN (".getEntity('societe').")";
76
-		    $sql.= " AND s.email NOT IN (SELECT email FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE fk_mailing=".$mailing_id.")";
73
+		    $sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
74
+		    $sql .= " WHERE s.email <> ''";
75
+		    $sql .= " AND s.entity IN (".getEntity('societe').")";
76
+		    $sql .= " AND s.email NOT IN (SELECT email FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE fk_mailing=".$mailing_id.")";
77 77
 		}
78 78
 		else
79 79
 		{
80 80
 		    $sql = "SELECT s.rowid as id, s.email as email, s.nom as name, null as fk_contact, null as firstname, c.label as label";
81
-		    $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."categorie_societe as cs, ".MAIN_DB_PREFIX."categorie as c";
82
-		    $sql.= " WHERE s.email <> ''";
83
-		    $sql.= " AND s.entity IN (".getEntity('societe').")";
84
-		    $sql.= " AND s.email NOT IN (SELECT email FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE fk_mailing=".$mailing_id.")";
85
-		    $sql.= " AND cs.fk_soc = s.rowid";
86
-		    $sql.= " AND c.rowid = cs.fk_categorie";
87
-		    $sql.= " AND c.rowid='".$this->db->escape($_POST['filter'])."'";
88
-		    $sql.= " UNION ";
89
-		    $sql.= "SELECT s.rowid as id, s.email as email, s.nom as name, null as fk_contact, null as firstname, c.label as label";
90
-		    $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."categorie_fournisseur as cs, ".MAIN_DB_PREFIX."categorie as c";
91
-		    $sql.= " WHERE s.email <> ''";
92
-		    $sql.= " AND s.entity IN (".getEntity('societe').")";
93
-		    $sql.= " AND s.email NOT IN (SELECT email FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE fk_mailing=".$mailing_id.")";
94
-		    $sql.= " AND cs.fk_soc = s.rowid";
95
-		    $sql.= " AND c.rowid = cs.fk_categorie";
96
-		    $sql.= " AND c.rowid='".$this->db->escape($_POST['filter'])."'";
81
+		    $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."categorie_societe as cs, ".MAIN_DB_PREFIX."categorie as c";
82
+		    $sql .= " WHERE s.email <> ''";
83
+		    $sql .= " AND s.entity IN (".getEntity('societe').")";
84
+		    $sql .= " AND s.email NOT IN (SELECT email FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE fk_mailing=".$mailing_id.")";
85
+		    $sql .= " AND cs.fk_soc = s.rowid";
86
+		    $sql .= " AND c.rowid = cs.fk_categorie";
87
+		    $sql .= " AND c.rowid='".$this->db->escape($_POST['filter'])."'";
88
+		    $sql .= " UNION ";
89
+		    $sql .= "SELECT s.rowid as id, s.email as email, s.nom as name, null as fk_contact, null as firstname, c.label as label";
90
+		    $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."categorie_fournisseur as cs, ".MAIN_DB_PREFIX."categorie as c";
91
+		    $sql .= " WHERE s.email <> ''";
92
+		    $sql .= " AND s.entity IN (".getEntity('societe').")";
93
+		    $sql .= " AND s.email NOT IN (SELECT email FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE fk_mailing=".$mailing_id.")";
94
+		    $sql .= " AND cs.fk_soc = s.rowid";
95
+		    $sql .= " AND c.rowid = cs.fk_categorie";
96
+		    $sql .= " AND c.rowid='".$this->db->escape($_POST['filter'])."'";
97 97
 		}
98 98
 
99
-        $addDescription= "";
99
+        $addDescription = "";
100 100
         if (isset($_POST["filter_client"]) && $_POST["filter_client"] <> '-1')
101 101
         {
102
-            $sql.= " AND s.client=" . $_POST["filter_client"];
103
-            $addDescription= $langs->trans('ProspectCustomer')."=";
102
+            $sql .= " AND s.client=".$_POST["filter_client"];
103
+            $addDescription = $langs->trans('ProspectCustomer')."=";
104 104
             if ($_POST["filter_client"] == 0)
105 105
             {
106
-                $addDescription.= $langs->trans('NorProspectNorCustomer');
106
+                $addDescription .= $langs->trans('NorProspectNorCustomer');
107 107
             }
108 108
             elseif ($_POST["filter_client"] == 1)
109 109
             {
110
-                $addDescription.= $langs->trans('Customer');
110
+                $addDescription .= $langs->trans('Customer');
111 111
             }
112 112
             elseif ($_POST["filter_client"] == 2)
113 113
             {
114
-                $addDescription.= $langs->trans('Prospect');
114
+                $addDescription .= $langs->trans('Prospect');
115 115
             }
116 116
             elseif ($_POST["filter_client"] == 3)
117 117
             {
118
-                $addDescription.= $langs->trans('ProspectCustomer');
118
+                $addDescription .= $langs->trans('ProspectCustomer');
119 119
             }
120 120
             else
121 121
             {
122
-                $addDescription.= "Unknown status ".$_POST["filter_client"];
122
+                $addDescription .= "Unknown status ".$_POST["filter_client"];
123 123
             }
124 124
         }
125 125
         if (isset($_POST["filter_status"]))
126 126
         {
127 127
             if (strlen($addDescription) > 0)
128 128
             {
129
-                $addDescription.= ";";
129
+                $addDescription .= ";";
130 130
             }
131
-            $addDescription.= $langs->trans("Status")."=";
131
+            $addDescription .= $langs->trans("Status")."=";
132 132
             if ($_POST["filter_status"] == '1')
133 133
             {
134
-                $sql.= " AND s.status=1";
135
-                $addDescription.= $langs->trans("Enabled");
134
+                $sql .= " AND s.status=1";
135
+                $addDescription .= $langs->trans("Enabled");
136 136
             }
137 137
             else
138 138
             {
139
-                $sql.= " AND s.status=0";
140
-                $addDescription.= $langs->trans("Disabled");
139
+                $sql .= " AND s.status=0";
140
+                $addDescription .= $langs->trans("Disabled");
141 141
             }
142 142
         }
143
-        $sql.= " ORDER BY email";
143
+        $sql .= " ORDER BY email";
144 144
 
145 145
         // Stock recipients emails into targets table
146
-		$result=$this->db->query($sql);
146
+		$result = $this->db->query($sql);
147 147
 		if ($result)
148 148
 		{
149 149
 			$num = $this->db->num_rows($result);
@@ -158,17 +158,17 @@  discard block
 block discarded – undo
158 158
 				$obj = $this->db->fetch_object($result);
159 159
 				if ($old <> $obj->email)
160 160
 				{
161
-					$otherTxt= ($obj->label?$langs->transnoentities("Category").'='.$obj->label:'');
161
+					$otherTxt = ($obj->label ? $langs->transnoentities("Category").'='.$obj->label : '');
162 162
 					if (strlen($addDescription) > 0 && strlen($otherTxt) > 0)
163 163
 					{
164
-						$otherTxt.= ";";
164
+						$otherTxt .= ";";
165 165
 					}
166
-					$otherTxt.= $addDescription;
166
+					$otherTxt .= $addDescription;
167 167
 					$cibles[$j] = array(
168 168
                     			'email' => $obj->email,
169 169
                     			'fk_contact' => $obj->fk_contact,
170
-                    			'lastname' => $obj->name,	// For a thirdparty, we must use name
171
-                    			'firstname' => '',			// For a thirdparty, lastname is ''
170
+                    			'lastname' => $obj->name, // For a thirdparty, we must use name
171
+                    			'firstname' => '', // For a thirdparty, lastname is ''
172 172
                     			'other' => $otherTxt,
173 173
                                 'source_url' => $this->url($obj->id),
174 174
                                 'source_id' => $obj->id,
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 		else
185 185
 		{
186 186
 			dol_syslog($this->db->error());
187
-			$this->error=$this->db->error();
187
+			$this->error = $this->db->error();
188 188
 			return -1;
189 189
 		}
190 190
 
@@ -218,14 +218,14 @@  discard block
 block discarded – undo
218 218
 	 *  @param      string	$sql        Requete sql de comptage
219 219
 	 *	@return		int					Nb of recipients
220 220
 	 */
221
-	function getNbOfRecipients($sql='')
221
+	function getNbOfRecipients($sql = '')
222 222
 	{
223 223
 		global $conf;
224 224
 
225 225
 		$sql = "SELECT count(distinct(s.email)) as nb";
226
-		$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
227
-		$sql.= " WHERE s.email != ''";
228
-		$sql.= " AND s.entity IN (".getEntity('societe').")";
226
+		$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
227
+		$sql .= " WHERE s.email != ''";
228
+		$sql .= " AND s.entity IN (".getEntity('societe').")";
229 229
 
230 230
 		// La requete doit retourner un champ "nb" pour etre comprise
231 231
 		// par parent::getNbOfRecipients
@@ -244,16 +244,16 @@  discard block
 block discarded – undo
244 244
 
245 245
 		$langs->load("companies");
246 246
 
247
-		$s=$langs->trans("Categories").': ';
248
-		$s.='<select name="filter" class="flat">';
247
+		$s = $langs->trans("Categories").': ';
248
+		$s .= '<select name="filter" class="flat">';
249 249
 
250 250
 		// Show categories
251 251
 		$sql = "SELECT rowid, label, type, visible";
252
-		$sql.= " FROM ".MAIN_DB_PREFIX."categorie";
253
-		$sql.= " WHERE type in (1,2)";	// We keep only categories for suppliers and customers/prospects
252
+		$sql .= " FROM ".MAIN_DB_PREFIX."categorie";
253
+		$sql .= " WHERE type in (1,2)"; // We keep only categories for suppliers and customers/prospects
254 254
 		// $sql.= " AND visible > 0";	// We ignore the property visible because third party's categories does not use this property (only products categories use it).
255
-		$sql.= " AND entity = ".$conf->entity;
256
-		$sql.= " ORDER BY label";
255
+		$sql .= " AND entity = ".$conf->entity;
256
+		$sql .= " ORDER BY label";
257 257
 
258 258
 		//print $sql;
259 259
 		$resql = $this->db->query($sql);
@@ -261,22 +261,22 @@  discard block
 block discarded – undo
261 261
 		{
262 262
 			$num = $this->db->num_rows($resql);
263 263
 
264
-			if (empty($conf->categorie->enabled)) $num=0;	// Force empty list if category module is not enabled
264
+			if (empty($conf->categorie->enabled)) $num = 0; // Force empty list if category module is not enabled
265 265
 
266
-			if ($num) $s.='<option value="0">&nbsp;</option>';
267
-			else $s.='<option value="0">'.$langs->trans("ContactsAllShort").'</option>';
266
+			if ($num) $s .= '<option value="0">&nbsp;</option>';
267
+			else $s .= '<option value="0">'.$langs->trans("ContactsAllShort").'</option>';
268 268
 
269 269
 			$i = 0;
270 270
 			while ($i < $num)
271 271
 			{
272 272
 				$obj = $this->db->fetch_object($resql);
273 273
 
274
-				$type='';
275
-				if ($obj->type == 1) $type=$langs->trans("Supplier");
276
-				if ($obj->type == 2) $type=$langs->trans("Customer");
277
-				$s.='<option value="'.$obj->rowid.'">'.dol_trunc($obj->label,38,'middle');
278
-				if ($type) $s.=' ('.$type.')';
279
-				$s.='</option>';
274
+				$type = '';
275
+				if ($obj->type == 1) $type = $langs->trans("Supplier");
276
+				if ($obj->type == 2) $type = $langs->trans("Customer");
277
+				$s .= '<option value="'.$obj->rowid.'">'.dol_trunc($obj->label, 38, 'middle');
278
+				if ($type) $s .= ' ('.$type.')';
279
+				$s .= '</option>';
280 280
 				$i++;
281 281
 			}
282 282
 		}
@@ -285,30 +285,30 @@  discard block
 block discarded – undo
285 285
 			dol_print_error($this->db);
286 286
 		}
287 287
 
288
-		$s.='</select> ';
289
-                $s.= $langs->trans('ProspectCustomer');
290
-                $s.=': <select name="filter_client" class="flat">';
291
-                $s.= '<option value="-1">&nbsp;</option>';
288
+		$s .= '</select> ';
289
+                $s .= $langs->trans('ProspectCustomer');
290
+                $s .= ': <select name="filter_client" class="flat">';
291
+                $s .= '<option value="-1">&nbsp;</option>';
292 292
                 if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS))
293 293
                 {
294
-                    $s.= '<option value="2">'.$langs->trans('Prospect').'</option>';
294
+                    $s .= '<option value="2">'.$langs->trans('Prospect').'</option>';
295 295
                 }
296 296
                 if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTSCUSTOMERS)) {
297
-                    $s.= '<option value="3">'.$langs->trans('ProspectCustomer').'</option>';
297
+                    $s .= '<option value="3">'.$langs->trans('ProspectCustomer').'</option>';
298 298
                 }
299 299
                 if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) {
300
-                    $s.= '<option value="1">'.$langs->trans('Customer').'</option>';
300
+                    $s .= '<option value="1">'.$langs->trans('Customer').'</option>';
301 301
                 }
302
-                $s.= '<option value="0">'.$langs->trans('NorProspectNorCustomer').'</option>';
302
+                $s .= '<option value="0">'.$langs->trans('NorProspectNorCustomer').'</option>';
303 303
 
304
-                $s.='</select> ';
304
+                $s .= '</select> ';
305 305
 
306
-                $s.=$langs->trans("Status");
307
-                $s.=': <select name="filter_status" class="flat">';
308
-                $s.='<option value="-1">&nbsp;</option>';
309
-                $s.='<option value="1" selected>'.$langs->trans("Enabled").'</option>';
310
-                $s.='<option value="0">'.$langs->trans("Disabled").'</option>';
311
-		$s.='</select>';
306
+                $s .= $langs->trans("Status");
307
+                $s .= ': <select name="filter_status" class="flat">';
308
+                $s .= '<option value="-1">&nbsp;</option>';
309
+                $s .= '<option value="1" selected>'.$langs->trans("Enabled").'</option>';
310
+                $s .= '<option value="0">'.$langs->trans("Disabled").'</option>';
311
+		$s .= '</select>';
312 312
 		return $s;
313 313
 	}
314 314
 
@@ -321,6 +321,6 @@  discard block
 block discarded – undo
321 321
 	 */
322 322
 	function url($id)
323 323
 	{
324
-		return '<a href="'.DOL_URL_ROOT.'/societe/card.php?socid='.$id.'">'.img_object('',"company").'</a>';
324
+		return '<a href="'.DOL_URL_ROOT.'/societe/card.php?socid='.$id.'">'.img_object('', "company").'</a>';
325 325
 	}
326 326
 }
Please login to merge, or discard this patch.
Braces   +26 added lines, -22 removed lines patch added patch discarded remove patch
@@ -74,8 +74,7 @@  discard block
 block discarded – undo
74 74
 		    $sql.= " WHERE s.email <> ''";
75 75
 		    $sql.= " AND s.entity IN (".getEntity('societe').")";
76 76
 		    $sql.= " AND s.email NOT IN (SELECT email FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE fk_mailing=".$mailing_id.")";
77
-		}
78
-		else
77
+		} else
79 78
 		{
80 79
 		    $sql = "SELECT s.rowid as id, s.email as email, s.nom as name, null as fk_contact, null as firstname, c.label as label";
81 80
 		    $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."categorie_societe as cs, ".MAIN_DB_PREFIX."categorie as c";
@@ -104,20 +103,16 @@  discard block
 block discarded – undo
104 103
             if ($_POST["filter_client"] == 0)
105 104
             {
106 105
                 $addDescription.= $langs->trans('NorProspectNorCustomer');
107
-            }
108
-            elseif ($_POST["filter_client"] == 1)
106
+            } elseif ($_POST["filter_client"] == 1)
109 107
             {
110 108
                 $addDescription.= $langs->trans('Customer');
111
-            }
112
-            elseif ($_POST["filter_client"] == 2)
109
+            } elseif ($_POST["filter_client"] == 2)
113 110
             {
114 111
                 $addDescription.= $langs->trans('Prospect');
115
-            }
116
-            elseif ($_POST["filter_client"] == 3)
112
+            } elseif ($_POST["filter_client"] == 3)
117 113
             {
118 114
                 $addDescription.= $langs->trans('ProspectCustomer');
119
-            }
120
-            else
115
+            } else
121 116
             {
122 117
                 $addDescription.= "Unknown status ".$_POST["filter_client"];
123 118
             }
@@ -133,8 +128,7 @@  discard block
 block discarded – undo
133 128
             {
134 129
                 $sql.= " AND s.status=1";
135 130
                 $addDescription.= $langs->trans("Enabled");
136
-            }
137
-            else
131
+            } else
138 132
             {
139 133
                 $sql.= " AND s.status=0";
140 134
                 $addDescription.= $langs->trans("Disabled");
@@ -180,8 +174,7 @@  discard block
 block discarded – undo
180 174
 
181 175
 				$i++;
182 176
 			}
183
-		}
184
-		else
177
+		} else
185 178
 		{
186 179
 			dol_syslog($this->db->error());
187 180
 			$this->error=$this->db->error();
@@ -261,10 +254,16 @@  discard block
 block discarded – undo
261 254
 		{
262 255
 			$num = $this->db->num_rows($resql);
263 256
 
264
-			if (empty($conf->categorie->enabled)) $num=0;	// Force empty list if category module is not enabled
257
+			if (empty($conf->categorie->enabled)) {
258
+			    $num=0;
259
+			}
260
+			// Force empty list if category module is not enabled
265 261
 
266
-			if ($num) $s.='<option value="0">&nbsp;</option>';
267
-			else $s.='<option value="0">'.$langs->trans("ContactsAllShort").'</option>';
262
+			if ($num) {
263
+			    $s.='<option value="0">&nbsp;</option>';
264
+			} else {
265
+			    $s.='<option value="0">'.$langs->trans("ContactsAllShort").'</option>';
266
+			}
268 267
 
269 268
 			$i = 0;
270 269
 			while ($i < $num)
@@ -272,15 +271,20 @@  discard block
 block discarded – undo
272 271
 				$obj = $this->db->fetch_object($resql);
273 272
 
274 273
 				$type='';
275
-				if ($obj->type == 1) $type=$langs->trans("Supplier");
276
-				if ($obj->type == 2) $type=$langs->trans("Customer");
274
+				if ($obj->type == 1) {
275
+				    $type=$langs->trans("Supplier");
276
+				}
277
+				if ($obj->type == 2) {
278
+				    $type=$langs->trans("Customer");
279
+				}
277 280
 				$s.='<option value="'.$obj->rowid.'">'.dol_trunc($obj->label,38,'middle');
278
-				if ($type) $s.=' ('.$type.')';
281
+				if ($type) {
282
+				    $s.=' ('.$type.')';
283
+				}
279 284
 				$s.='</option>';
280 285
 				$i++;
281 286
 			}
282
-		}
283
-		else
287
+		} else
284 288
 		{
285 289
 			dol_print_error($this->db);
286 290
 		}
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/mailings/advthirdparties.modules.php 3 patches
Indentation   +263 added lines, -263 removed lines patch added patch discarded remove patch
@@ -25,278 +25,278 @@
 block discarded – undo
25 25
  */
26 26
 class mailing_advthirdparties extends MailingTargets
27 27
 {
28
-	var $name='ThirdPartyAdvancedTargeting';
29
-	// This label is used if no translation is found for key XXX neither MailingModuleDescXXX where XXX=name is found
30
-	var $desc="Third parties";
31
-	var $require_admin=0;
28
+    var $name='ThirdPartyAdvancedTargeting';
29
+    // This label is used if no translation is found for key XXX neither MailingModuleDescXXX where XXX=name is found
30
+    var $desc="Third parties";
31
+    var $require_admin=0;
32 32
 
33
-	var $require_module=array("none");	// This module should not be displayed as Selector in mailling
34
-	var $picto='company';
33
+    var $require_module=array("none");	// This module should not be displayed as Selector in mailling
34
+    var $picto='company';
35 35
 
36
-	/**
36
+    /**
37 37
      * @var DoliDB Database handler.
38 38
      */
39 39
     public $db;
40 40
 
41 41
 
42
-	/**
43
-	 *	Constructor
44
-	 *
45
-	 *  @param		DoliDB		$db      Database handler
46
-	 */
47
-	function __construct($db)
48
-	{
49
-		$this->db=$db;
50
-	}
42
+    /**
43
+     *	Constructor
44
+     *
45
+     *  @param		DoliDB		$db      Database handler
46
+     */
47
+    function __construct($db)
48
+    {
49
+        $this->db=$db;
50
+    }
51 51
 
52 52
 
53 53
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
54
-	/**
55
-	 *    This is the main function that returns the array of emails
56
-	 *
57
-	 *    @param	int		$mailing_id    	Id of mailing. No need to use it.
58
-	 *    @param	array	$socid  		Array of id soc to add
59
-	 *    @param	int		$type_of_target	Defined in advtargetemailing.class.php
60
-	 *    @param	array	$contactid 		Array of contact id to add
61
-	 *    @return   int 					<0 if error, number of emails added if ok
62
-	 */
63
-	function add_to_target_spec($mailing_id,$socid,$type_of_target, $contactid)
64
-	{
54
+    /**
55
+     *    This is the main function that returns the array of emails
56
+     *
57
+     *    @param	int		$mailing_id    	Id of mailing. No need to use it.
58
+     *    @param	array	$socid  		Array of id soc to add
59
+     *    @param	int		$type_of_target	Defined in advtargetemailing.class.php
60
+     *    @param	array	$contactid 		Array of contact id to add
61
+     *    @return   int 					<0 if error, number of emails added if ok
62
+     */
63
+    function add_to_target_spec($mailing_id,$socid,$type_of_target, $contactid)
64
+    {
65 65
         // phpcs:enable
66
-		global $conf, $langs;
67
-
68
-		dol_syslog(get_class($this)."::add_to_target socid=".var_export($socid,true).' contactid='.var_export($contactid,true));
69
-
70
-		$cibles = array();
71
-
72
-		if (($type_of_target==1) || ($type_of_target==3)) {
73
-			// Select the third parties from category
74
-			if (count($socid)>0)
75
-			{
76
-				$sql= "SELECT s.rowid as id, s.email as email, s.nom as name, null as fk_contact";
77
-				$sql.= " FROM ".MAIN_DB_PREFIX."societe as s LEFT OUTER JOIN ".MAIN_DB_PREFIX."societe_extrafields se ON se.fk_object=s.rowid";
78
-				$sql.= " WHERE s.entity IN (".getEntity('societe').")";
79
-				$sql.= " AND s.rowid IN (".implode(',',$socid).")";
80
-				$sql.= " ORDER BY email";
81
-
82
-    			// Stock recipients emails into targets table
83
-    			$result=$this->db->query($sql);
84
-    			if ($result)
85
-    			{
86
-    				$num = $this->db->num_rows($result);
87
-    				$i = 0;
88
-
89
-    				dol_syslog(get_class($this)."::add_to_target mailing ".$num." targets found", LOG_DEBUG);
90
-
91
-    				$old = '';
92
-    				while ($i < $num)
93
-    				{
94
-    					$obj = $this->db->fetch_object($result);
95
-
96
-    					if (!empty($obj->email) && filter_var($obj->email, FILTER_VALIDATE_EMAIL)) {
97
-    						if (!array_key_exists($obj->email, $cibles)) {
98
-    							$cibles[$obj->email] = array(
99
-    								'email' => $obj->email,
100
-    								'fk_contact' => $obj->fk_contact,
101
-    								'name' => $obj->name,
102
-    								'firstname' => $obj->firstname,
103
-    								'other' => '',
104
-    								'source_url' => $this->url($obj->id,'thirdparty'),
105
-    								'source_id' => $obj->id,
106
-    								'source_type' => 'thirdparty'
107
-    							);
108
-    						}
109
-    					}
110
-
111
-    					$i++;
112
-    				}
113
-    			}
114
-    			else
115
-    			{
116
-    				dol_syslog($this->db->error());
117
-    				$this->error=$this->db->error();
118
-    				return -1;
119
-    			}
120
-			}
121
-		}
122
-
123
-		if  (($type_of_target==1) || ($type_of_target==2) || ($type_of_target==4)) {
124
-			// Select the third parties from category
125
-			if (count($socid)>0 || count($contactid)>0)
126
-			{
127
-				$sql= "SELECT socp.rowid as id, socp.email as email, socp.lastname as lastname, socp.firstname as firstname";
128
-				$sql.= " FROM ".MAIN_DB_PREFIX."socpeople as socp";
129
-				$sql.= " WHERE socp.entity IN (".getEntity('socpeople').")";
130
-				if (count($contactid)>0) {
131
-					$sql.= " AND socp.rowid IN (".implode(',',$contactid).")";
132
-				}
133
-				if (count($socid)>0) {
134
-					$sql.= " AND socp.fk_soc IN (".implode(',',$socid).")";
135
-				}
136
-				$sql.= " ORDER BY email";
137
-
138
-    			// Stock recipients emails into targets table
139
-    			$result=$this->db->query($sql);
140
-    			if ($result)
141
-    			{
142
-    				$num = $this->db->num_rows($result);
143
-    				$i = 0;
144
-
145
-    				dol_syslog(get_class($this)."::add_to_target mailing ".$num." targets found");
146
-
147
-    				$old = '';
148
-    				while ($i < $num)
149
-    				{
150
-    					$obj = $this->db->fetch_object($result);
151
-
152
-    					if (!empty($obj->email) && filter_var($obj->email, FILTER_VALIDATE_EMAIL)) {
153
-    						if (!array_key_exists($obj->email, $cibles)) {
154
-    							$cibles[$obj->email] = array(
155
-    								'email' => $obj->email,
156
-    								'fk_contact' =>$obj->id,
157
-    								'lastname' => $obj->lastname,
158
-    								'firstname' => $obj->firstname,
159
-    								'other' => '',
160
-    								'source_url' => $this->url($obj->id,'contact'),
161
-    								'source_id' => $obj->id,
162
-    								'source_type' => 'contact'
163
-    							);
164
-    						}
165
-    					}
166
-
167
-    					$i++;
168
-    				}
169
-    			}
170
-    			else
171
-    			{
172
-    				dol_syslog($this->db->error());
173
-    				$this->error=$this->db->error();
174
-    				return -1;
175
-    			}
176
-			}
177
-		}
178
-
179
-
180
-		dol_syslog(get_class($this)."::add_to_target mailing cibles=".var_export($cibles,true), LOG_DEBUG);
181
-		return parent::add_to_target($mailing_id, $cibles);
182
-	}
183
-
184
-
185
-	/**
186
-	 *	On the main mailing area, there is a box with statistics.
187
-	 *	If you want to add a line in this report you must provide an
188
-	 *	array of SQL request that returns two field:
189
-	 *	One called "label", One called "nb".
190
-	 *
191
-	 *	@return		array		Array with SQL requests
192
-	 */
193
-	function getSqlArrayForStats()
194
-	{
195
-		// CHANGE THIS: Optionnal
196
-
197
-		//var $statssql=array();
198
-		//$this->statssql[0]="SELECT field1 as label, count(distinct(email)) as nb FROM mytable WHERE email IS NOT NULL";
199
-		return array();
200
-	}
201
-
202
-
203
-	/**
204
-	 *	Return here number of distinct emails returned by your selector.
205
-	 *	For example if this selector is used to extract 500 different
206
-	 *	emails from a text file, this function must return 500.
207
-	 *
208
-	 *  @param	string	$sql 		Not use here
209
-	 *	@return	    int			          Nb of recipients
210
-	 */
211
-	function getNbOfRecipients($sql='')
212
-	{
213
-		global $conf;
214
-
215
-		$sql = "SELECT count(distinct(s.email)) as nb";
216
-		$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
217
-		$sql.= " WHERE s.email != ''";
218
-		$sql.= " AND s.entity IN (".getEntity('societe').")";
219
-
220
-		// La requete doit retourner un champ "nb" pour etre comprise
221
-		// par parent::getNbOfRecipients
222
-		return parent::getNbOfRecipients($sql);
223
-	}
224
-
225
-	/**
226
-	 *  This is to add a form filter to provide variant of selector
227
-	 *	If used, the HTML select must be called "filter"
228
-	 *
229
-	 *  @return     string      A html select zone
230
-	 */
231
-	function formFilter()
232
-	{
233
-		global $conf, $langs;
234
-
235
-		$langs->load("companies");
236
-
237
-		$s='';
238
-		$s.='<select name="filter" class="flat">';
239
-
240
-		// Show categories
241
-		$sql = "SELECT rowid, label, type, visible";
242
-		$sql.= " FROM ".MAIN_DB_PREFIX."categorie";
243
-		$sql.= " WHERE type in (1,2)";	// We keep only categories for suppliers and customers/prospects
244
-		// $sql.= " AND visible > 0";	// We ignore the property visible because third party's categories does not use this property (only products categories use it).
245
-		$sql.= " AND entity = ".$conf->entity;
246
-		$sql.= " ORDER BY label";
247
-
248
-		//print $sql;
249
-		$resql = $this->db->query($sql);
250
-		if ($resql)
251
-		{
252
-			$num = $this->db->num_rows($resql);
253
-
254
-			if (empty($conf->categorie->enabled)) $num=0;	// Force empty list if category module is not enabled
255
-
256
-			if ($num) $s.='<option value="0">&nbsp;</option>';
257
-			else $s.='<option value="0">'.$langs->trans("ContactsAllShort").'</option>';
258
-
259
-			$i = 0;
260
-			while ($i < $num)
261
-			{
262
-				$obj = $this->db->fetch_object($resql);
263
-
264
-				$type='';
265
-				if ($obj->type == 1) $type=$langs->trans("Supplier");
266
-				if ($obj->type == 2) $type=$langs->trans("Customer");
267
-				$s.='<option value="'.$obj->rowid.'">'.dol_trunc($obj->label,38,'middle');
268
-				if ($type) $s.=' ('.$type.')';
269
-				$s.='</option>';
270
-				$i++;
271
-			}
272
-		}
273
-		else
274
-		{
275
-			dol_print_error($this->db);
276
-		}
277
-
278
-		$s.='</select>';
279
-		return $s;
280
-	}
281
-
282
-
283
-	/**
284
-	 *  Can include an URL link on each record provided by selector shown on target page.
285
-	 *
286
-	 *  @param	int		$id		ID
287
-	 *  @param	string		$type	type
288
-	 *  @return string      	Url link
289
-	 */
290
-	function url($id,$type)
291
-	{
292
-		if ($type=='thirdparty') {
293
-			$companystatic=new Societe($this->db);
294
-			$companystatic->fetch($id);
295
-			return $companystatic->getNomUrl(0, '', 0, 1);
296
-		} elseif ($type=='contact') {
297
-			$contactstatic=new Contact($this->db);
298
-			$contactstatic->fetch($id);
299
-			return $contactstatic->getNomUrl(0, '', 0, '', -1, 1);
300
-		}
301
-	}
66
+        global $conf, $langs;
67
+
68
+        dol_syslog(get_class($this)."::add_to_target socid=".var_export($socid,true).' contactid='.var_export($contactid,true));
69
+
70
+        $cibles = array();
71
+
72
+        if (($type_of_target==1) || ($type_of_target==3)) {
73
+            // Select the third parties from category
74
+            if (count($socid)>0)
75
+            {
76
+                $sql= "SELECT s.rowid as id, s.email as email, s.nom as name, null as fk_contact";
77
+                $sql.= " FROM ".MAIN_DB_PREFIX."societe as s LEFT OUTER JOIN ".MAIN_DB_PREFIX."societe_extrafields se ON se.fk_object=s.rowid";
78
+                $sql.= " WHERE s.entity IN (".getEntity('societe').")";
79
+                $sql.= " AND s.rowid IN (".implode(',',$socid).")";
80
+                $sql.= " ORDER BY email";
81
+
82
+                // Stock recipients emails into targets table
83
+                $result=$this->db->query($sql);
84
+                if ($result)
85
+                {
86
+                    $num = $this->db->num_rows($result);
87
+                    $i = 0;
88
+
89
+                    dol_syslog(get_class($this)."::add_to_target mailing ".$num." targets found", LOG_DEBUG);
90
+
91
+                    $old = '';
92
+                    while ($i < $num)
93
+                    {
94
+                        $obj = $this->db->fetch_object($result);
95
+
96
+                        if (!empty($obj->email) && filter_var($obj->email, FILTER_VALIDATE_EMAIL)) {
97
+                            if (!array_key_exists($obj->email, $cibles)) {
98
+                                $cibles[$obj->email] = array(
99
+                                    'email' => $obj->email,
100
+                                    'fk_contact' => $obj->fk_contact,
101
+                                    'name' => $obj->name,
102
+                                    'firstname' => $obj->firstname,
103
+                                    'other' => '',
104
+                                    'source_url' => $this->url($obj->id,'thirdparty'),
105
+                                    'source_id' => $obj->id,
106
+                                    'source_type' => 'thirdparty'
107
+                                );
108
+                            }
109
+                        }
110
+
111
+                        $i++;
112
+                    }
113
+                }
114
+                else
115
+                {
116
+                    dol_syslog($this->db->error());
117
+                    $this->error=$this->db->error();
118
+                    return -1;
119
+                }
120
+            }
121
+        }
122
+
123
+        if  (($type_of_target==1) || ($type_of_target==2) || ($type_of_target==4)) {
124
+            // Select the third parties from category
125
+            if (count($socid)>0 || count($contactid)>0)
126
+            {
127
+                $sql= "SELECT socp.rowid as id, socp.email as email, socp.lastname as lastname, socp.firstname as firstname";
128
+                $sql.= " FROM ".MAIN_DB_PREFIX."socpeople as socp";
129
+                $sql.= " WHERE socp.entity IN (".getEntity('socpeople').")";
130
+                if (count($contactid)>0) {
131
+                    $sql.= " AND socp.rowid IN (".implode(',',$contactid).")";
132
+                }
133
+                if (count($socid)>0) {
134
+                    $sql.= " AND socp.fk_soc IN (".implode(',',$socid).")";
135
+                }
136
+                $sql.= " ORDER BY email";
137
+
138
+                // Stock recipients emails into targets table
139
+                $result=$this->db->query($sql);
140
+                if ($result)
141
+                {
142
+                    $num = $this->db->num_rows($result);
143
+                    $i = 0;
144
+
145
+                    dol_syslog(get_class($this)."::add_to_target mailing ".$num." targets found");
146
+
147
+                    $old = '';
148
+                    while ($i < $num)
149
+                    {
150
+                        $obj = $this->db->fetch_object($result);
151
+
152
+                        if (!empty($obj->email) && filter_var($obj->email, FILTER_VALIDATE_EMAIL)) {
153
+                            if (!array_key_exists($obj->email, $cibles)) {
154
+                                $cibles[$obj->email] = array(
155
+                                    'email' => $obj->email,
156
+                                    'fk_contact' =>$obj->id,
157
+                                    'lastname' => $obj->lastname,
158
+                                    'firstname' => $obj->firstname,
159
+                                    'other' => '',
160
+                                    'source_url' => $this->url($obj->id,'contact'),
161
+                                    'source_id' => $obj->id,
162
+                                    'source_type' => 'contact'
163
+                                );
164
+                            }
165
+                        }
166
+
167
+                        $i++;
168
+                    }
169
+                }
170
+                else
171
+                {
172
+                    dol_syslog($this->db->error());
173
+                    $this->error=$this->db->error();
174
+                    return -1;
175
+                }
176
+            }
177
+        }
178
+
179
+
180
+        dol_syslog(get_class($this)."::add_to_target mailing cibles=".var_export($cibles,true), LOG_DEBUG);
181
+        return parent::add_to_target($mailing_id, $cibles);
182
+    }
183
+
184
+
185
+    /**
186
+     *	On the main mailing area, there is a box with statistics.
187
+     *	If you want to add a line in this report you must provide an
188
+     *	array of SQL request that returns two field:
189
+     *	One called "label", One called "nb".
190
+     *
191
+     *	@return		array		Array with SQL requests
192
+     */
193
+    function getSqlArrayForStats()
194
+    {
195
+        // CHANGE THIS: Optionnal
196
+
197
+        //var $statssql=array();
198
+        //$this->statssql[0]="SELECT field1 as label, count(distinct(email)) as nb FROM mytable WHERE email IS NOT NULL";
199
+        return array();
200
+    }
201
+
202
+
203
+    /**
204
+     *	Return here number of distinct emails returned by your selector.
205
+     *	For example if this selector is used to extract 500 different
206
+     *	emails from a text file, this function must return 500.
207
+     *
208
+     *  @param	string	$sql 		Not use here
209
+     *	@return	    int			          Nb of recipients
210
+     */
211
+    function getNbOfRecipients($sql='')
212
+    {
213
+        global $conf;
214
+
215
+        $sql = "SELECT count(distinct(s.email)) as nb";
216
+        $sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
217
+        $sql.= " WHERE s.email != ''";
218
+        $sql.= " AND s.entity IN (".getEntity('societe').")";
219
+
220
+        // La requete doit retourner un champ "nb" pour etre comprise
221
+        // par parent::getNbOfRecipients
222
+        return parent::getNbOfRecipients($sql);
223
+    }
224
+
225
+    /**
226
+     *  This is to add a form filter to provide variant of selector
227
+     *	If used, the HTML select must be called "filter"
228
+     *
229
+     *  @return     string      A html select zone
230
+     */
231
+    function formFilter()
232
+    {
233
+        global $conf, $langs;
234
+
235
+        $langs->load("companies");
236
+
237
+        $s='';
238
+        $s.='<select name="filter" class="flat">';
239
+
240
+        // Show categories
241
+        $sql = "SELECT rowid, label, type, visible";
242
+        $sql.= " FROM ".MAIN_DB_PREFIX."categorie";
243
+        $sql.= " WHERE type in (1,2)";	// We keep only categories for suppliers and customers/prospects
244
+        // $sql.= " AND visible > 0";	// We ignore the property visible because third party's categories does not use this property (only products categories use it).
245
+        $sql.= " AND entity = ".$conf->entity;
246
+        $sql.= " ORDER BY label";
247
+
248
+        //print $sql;
249
+        $resql = $this->db->query($sql);
250
+        if ($resql)
251
+        {
252
+            $num = $this->db->num_rows($resql);
253
+
254
+            if (empty($conf->categorie->enabled)) $num=0;	// Force empty list if category module is not enabled
255
+
256
+            if ($num) $s.='<option value="0">&nbsp;</option>';
257
+            else $s.='<option value="0">'.$langs->trans("ContactsAllShort").'</option>';
258
+
259
+            $i = 0;
260
+            while ($i < $num)
261
+            {
262
+                $obj = $this->db->fetch_object($resql);
263
+
264
+                $type='';
265
+                if ($obj->type == 1) $type=$langs->trans("Supplier");
266
+                if ($obj->type == 2) $type=$langs->trans("Customer");
267
+                $s.='<option value="'.$obj->rowid.'">'.dol_trunc($obj->label,38,'middle');
268
+                if ($type) $s.=' ('.$type.')';
269
+                $s.='</option>';
270
+                $i++;
271
+            }
272
+        }
273
+        else
274
+        {
275
+            dol_print_error($this->db);
276
+        }
277
+
278
+        $s.='</select>';
279
+        return $s;
280
+    }
281
+
282
+
283
+    /**
284
+     *  Can include an URL link on each record provided by selector shown on target page.
285
+     *
286
+     *  @param	int		$id		ID
287
+     *  @param	string		$type	type
288
+     *  @return string      	Url link
289
+     */
290
+    function url($id,$type)
291
+    {
292
+        if ($type=='thirdparty') {
293
+            $companystatic=new Societe($this->db);
294
+            $companystatic->fetch($id);
295
+            return $companystatic->getNomUrl(0, '', 0, 1);
296
+        } elseif ($type=='contact') {
297
+            $contactstatic=new Contact($this->db);
298
+            $contactstatic->fetch($id);
299
+            return $contactstatic->getNomUrl(0, '', 0, '', -1, 1);
300
+        }
301
+    }
302 302
 }
Please login to merge, or discard this patch.
Spacing   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -25,13 +25,13 @@  discard block
 block discarded – undo
25 25
  */
26 26
 class mailing_advthirdparties extends MailingTargets
27 27
 {
28
-	var $name='ThirdPartyAdvancedTargeting';
28
+	var $name = 'ThirdPartyAdvancedTargeting';
29 29
 	// This label is used if no translation is found for key XXX neither MailingModuleDescXXX where XXX=name is found
30
-	var $desc="Third parties";
31
-	var $require_admin=0;
30
+	var $desc = "Third parties";
31
+	var $require_admin = 0;
32 32
 
33
-	var $require_module=array("none");	// This module should not be displayed as Selector in mailling
34
-	var $picto='company';
33
+	var $require_module = array("none"); // This module should not be displayed as Selector in mailling
34
+	var $picto = 'company';
35 35
 
36 36
 	/**
37 37
      * @var DoliDB Database handler.
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 	 */
47 47
 	function __construct($db)
48 48
 	{
49
-		$this->db=$db;
49
+		$this->db = $db;
50 50
 	}
51 51
 
52 52
 
@@ -60,27 +60,27 @@  discard block
 block discarded – undo
60 60
 	 *    @param	array	$contactid 		Array of contact id to add
61 61
 	 *    @return   int 					<0 if error, number of emails added if ok
62 62
 	 */
63
-	function add_to_target_spec($mailing_id,$socid,$type_of_target, $contactid)
63
+	function add_to_target_spec($mailing_id, $socid, $type_of_target, $contactid)
64 64
 	{
65 65
         // phpcs:enable
66 66
 		global $conf, $langs;
67 67
 
68
-		dol_syslog(get_class($this)."::add_to_target socid=".var_export($socid,true).' contactid='.var_export($contactid,true));
68
+		dol_syslog(get_class($this)."::add_to_target socid=".var_export($socid, true).' contactid='.var_export($contactid, true));
69 69
 
70 70
 		$cibles = array();
71 71
 
72
-		if (($type_of_target==1) || ($type_of_target==3)) {
72
+		if (($type_of_target == 1) || ($type_of_target == 3)) {
73 73
 			// Select the third parties from category
74
-			if (count($socid)>0)
74
+			if (count($socid) > 0)
75 75
 			{
76
-				$sql= "SELECT s.rowid as id, s.email as email, s.nom as name, null as fk_contact";
77
-				$sql.= " FROM ".MAIN_DB_PREFIX."societe as s LEFT OUTER JOIN ".MAIN_DB_PREFIX."societe_extrafields se ON se.fk_object=s.rowid";
78
-				$sql.= " WHERE s.entity IN (".getEntity('societe').")";
79
-				$sql.= " AND s.rowid IN (".implode(',',$socid).")";
80
-				$sql.= " ORDER BY email";
76
+				$sql = "SELECT s.rowid as id, s.email as email, s.nom as name, null as fk_contact";
77
+				$sql .= " FROM ".MAIN_DB_PREFIX."societe as s LEFT OUTER JOIN ".MAIN_DB_PREFIX."societe_extrafields se ON se.fk_object=s.rowid";
78
+				$sql .= " WHERE s.entity IN (".getEntity('societe').")";
79
+				$sql .= " AND s.rowid IN (".implode(',', $socid).")";
80
+				$sql .= " ORDER BY email";
81 81
 
82 82
     			// Stock recipients emails into targets table
83
-    			$result=$this->db->query($sql);
83
+    			$result = $this->db->query($sql);
84 84
     			if ($result)
85 85
     			{
86 86
     				$num = $this->db->num_rows($result);
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
     								'name' => $obj->name,
102 102
     								'firstname' => $obj->firstname,
103 103
     								'other' => '',
104
-    								'source_url' => $this->url($obj->id,'thirdparty'),
104
+    								'source_url' => $this->url($obj->id, 'thirdparty'),
105 105
     								'source_id' => $obj->id,
106 106
     								'source_type' => 'thirdparty'
107 107
     							);
@@ -114,29 +114,29 @@  discard block
 block discarded – undo
114 114
     			else
115 115
     			{
116 116
     				dol_syslog($this->db->error());
117
-    				$this->error=$this->db->error();
117
+    				$this->error = $this->db->error();
118 118
     				return -1;
119 119
     			}
120 120
 			}
121 121
 		}
122 122
 
123
-		if  (($type_of_target==1) || ($type_of_target==2) || ($type_of_target==4)) {
123
+		if (($type_of_target == 1) || ($type_of_target == 2) || ($type_of_target == 4)) {
124 124
 			// Select the third parties from category
125
-			if (count($socid)>0 || count($contactid)>0)
125
+			if (count($socid) > 0 || count($contactid) > 0)
126 126
 			{
127
-				$sql= "SELECT socp.rowid as id, socp.email as email, socp.lastname as lastname, socp.firstname as firstname";
128
-				$sql.= " FROM ".MAIN_DB_PREFIX."socpeople as socp";
129
-				$sql.= " WHERE socp.entity IN (".getEntity('socpeople').")";
130
-				if (count($contactid)>0) {
131
-					$sql.= " AND socp.rowid IN (".implode(',',$contactid).")";
127
+				$sql = "SELECT socp.rowid as id, socp.email as email, socp.lastname as lastname, socp.firstname as firstname";
128
+				$sql .= " FROM ".MAIN_DB_PREFIX."socpeople as socp";
129
+				$sql .= " WHERE socp.entity IN (".getEntity('socpeople').")";
130
+				if (count($contactid) > 0) {
131
+					$sql .= " AND socp.rowid IN (".implode(',', $contactid).")";
132 132
 				}
133
-				if (count($socid)>0) {
134
-					$sql.= " AND socp.fk_soc IN (".implode(',',$socid).")";
133
+				if (count($socid) > 0) {
134
+					$sql .= " AND socp.fk_soc IN (".implode(',', $socid).")";
135 135
 				}
136
-				$sql.= " ORDER BY email";
136
+				$sql .= " ORDER BY email";
137 137
 
138 138
     			// Stock recipients emails into targets table
139
-    			$result=$this->db->query($sql);
139
+    			$result = $this->db->query($sql);
140 140
     			if ($result)
141 141
     			{
142 142
     				$num = $this->db->num_rows($result);
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
     								'lastname' => $obj->lastname,
158 158
     								'firstname' => $obj->firstname,
159 159
     								'other' => '',
160
-    								'source_url' => $this->url($obj->id,'contact'),
160
+    								'source_url' => $this->url($obj->id, 'contact'),
161 161
     								'source_id' => $obj->id,
162 162
     								'source_type' => 'contact'
163 163
     							);
@@ -170,14 +170,14 @@  discard block
 block discarded – undo
170 170
     			else
171 171
     			{
172 172
     				dol_syslog($this->db->error());
173
-    				$this->error=$this->db->error();
173
+    				$this->error = $this->db->error();
174 174
     				return -1;
175 175
     			}
176 176
 			}
177 177
 		}
178 178
 
179 179
 
180
-		dol_syslog(get_class($this)."::add_to_target mailing cibles=".var_export($cibles,true), LOG_DEBUG);
180
+		dol_syslog(get_class($this)."::add_to_target mailing cibles=".var_export($cibles, true), LOG_DEBUG);
181 181
 		return parent::add_to_target($mailing_id, $cibles);
182 182
 	}
183 183
 
@@ -208,14 +208,14 @@  discard block
 block discarded – undo
208 208
 	 *  @param	string	$sql 		Not use here
209 209
 	 *	@return	    int			          Nb of recipients
210 210
 	 */
211
-	function getNbOfRecipients($sql='')
211
+	function getNbOfRecipients($sql = '')
212 212
 	{
213 213
 		global $conf;
214 214
 
215 215
 		$sql = "SELECT count(distinct(s.email)) as nb";
216
-		$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
217
-		$sql.= " WHERE s.email != ''";
218
-		$sql.= " AND s.entity IN (".getEntity('societe').")";
216
+		$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
217
+		$sql .= " WHERE s.email != ''";
218
+		$sql .= " AND s.entity IN (".getEntity('societe').")";
219 219
 
220 220
 		// La requete doit retourner un champ "nb" pour etre comprise
221 221
 		// par parent::getNbOfRecipients
@@ -234,16 +234,16 @@  discard block
 block discarded – undo
234 234
 
235 235
 		$langs->load("companies");
236 236
 
237
-		$s='';
238
-		$s.='<select name="filter" class="flat">';
237
+		$s = '';
238
+		$s .= '<select name="filter" class="flat">';
239 239
 
240 240
 		// Show categories
241 241
 		$sql = "SELECT rowid, label, type, visible";
242
-		$sql.= " FROM ".MAIN_DB_PREFIX."categorie";
243
-		$sql.= " WHERE type in (1,2)";	// We keep only categories for suppliers and customers/prospects
242
+		$sql .= " FROM ".MAIN_DB_PREFIX."categorie";
243
+		$sql .= " WHERE type in (1,2)"; // We keep only categories for suppliers and customers/prospects
244 244
 		// $sql.= " AND visible > 0";	// We ignore the property visible because third party's categories does not use this property (only products categories use it).
245
-		$sql.= " AND entity = ".$conf->entity;
246
-		$sql.= " ORDER BY label";
245
+		$sql .= " AND entity = ".$conf->entity;
246
+		$sql .= " ORDER BY label";
247 247
 
248 248
 		//print $sql;
249 249
 		$resql = $this->db->query($sql);
@@ -251,22 +251,22 @@  discard block
 block discarded – undo
251 251
 		{
252 252
 			$num = $this->db->num_rows($resql);
253 253
 
254
-			if (empty($conf->categorie->enabled)) $num=0;	// Force empty list if category module is not enabled
254
+			if (empty($conf->categorie->enabled)) $num = 0; // Force empty list if category module is not enabled
255 255
 
256
-			if ($num) $s.='<option value="0">&nbsp;</option>';
257
-			else $s.='<option value="0">'.$langs->trans("ContactsAllShort").'</option>';
256
+			if ($num) $s .= '<option value="0">&nbsp;</option>';
257
+			else $s .= '<option value="0">'.$langs->trans("ContactsAllShort").'</option>';
258 258
 
259 259
 			$i = 0;
260 260
 			while ($i < $num)
261 261
 			{
262 262
 				$obj = $this->db->fetch_object($resql);
263 263
 
264
-				$type='';
265
-				if ($obj->type == 1) $type=$langs->trans("Supplier");
266
-				if ($obj->type == 2) $type=$langs->trans("Customer");
267
-				$s.='<option value="'.$obj->rowid.'">'.dol_trunc($obj->label,38,'middle');
268
-				if ($type) $s.=' ('.$type.')';
269
-				$s.='</option>';
264
+				$type = '';
265
+				if ($obj->type == 1) $type = $langs->trans("Supplier");
266
+				if ($obj->type == 2) $type = $langs->trans("Customer");
267
+				$s .= '<option value="'.$obj->rowid.'">'.dol_trunc($obj->label, 38, 'middle');
268
+				if ($type) $s .= ' ('.$type.')';
269
+				$s .= '</option>';
270 270
 				$i++;
271 271
 			}
272 272
 		}
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
 			dol_print_error($this->db);
276 276
 		}
277 277
 
278
-		$s.='</select>';
278
+		$s .= '</select>';
279 279
 		return $s;
280 280
 	}
281 281
 
@@ -287,14 +287,14 @@  discard block
 block discarded – undo
287 287
 	 *  @param	string		$type	type
288 288
 	 *  @return string      	Url link
289 289
 	 */
290
-	function url($id,$type)
290
+	function url($id, $type)
291 291
 	{
292
-		if ($type=='thirdparty') {
293
-			$companystatic=new Societe($this->db);
292
+		if ($type == 'thirdparty') {
293
+			$companystatic = new Societe($this->db);
294 294
 			$companystatic->fetch($id);
295 295
 			return $companystatic->getNomUrl(0, '', 0, 1);
296
-		} elseif ($type=='contact') {
297
-			$contactstatic=new Contact($this->db);
296
+		} elseif ($type == 'contact') {
297
+			$contactstatic = new Contact($this->db);
298 298
 			$contactstatic->fetch($id);
299 299
 			return $contactstatic->getNomUrl(0, '', 0, '', -1, 1);
300 300
 		}
Please login to merge, or discard this patch.
Braces   +21 added lines, -12 removed lines patch added patch discarded remove patch
@@ -110,8 +110,7 @@  discard block
 block discarded – undo
110 110
 
111 111
     					$i++;
112 112
     				}
113
-    			}
114
-    			else
113
+    			} else
115 114
     			{
116 115
     				dol_syslog($this->db->error());
117 116
     				$this->error=$this->db->error();
@@ -166,8 +165,7 @@  discard block
 block discarded – undo
166 165
 
167 166
     					$i++;
168 167
     				}
169
-    			}
170
-    			else
168
+    			} else
171 169
     			{
172 170
     				dol_syslog($this->db->error());
173 171
     				$this->error=$this->db->error();
@@ -251,10 +249,16 @@  discard block
 block discarded – undo
251 249
 		{
252 250
 			$num = $this->db->num_rows($resql);
253 251
 
254
-			if (empty($conf->categorie->enabled)) $num=0;	// Force empty list if category module is not enabled
252
+			if (empty($conf->categorie->enabled)) {
253
+			    $num=0;
254
+			}
255
+			// Force empty list if category module is not enabled
255 256
 
256
-			if ($num) $s.='<option value="0">&nbsp;</option>';
257
-			else $s.='<option value="0">'.$langs->trans("ContactsAllShort").'</option>';
257
+			if ($num) {
258
+			    $s.='<option value="0">&nbsp;</option>';
259
+			} else {
260
+			    $s.='<option value="0">'.$langs->trans("ContactsAllShort").'</option>';
261
+			}
258 262
 
259 263
 			$i = 0;
260 264
 			while ($i < $num)
@@ -262,15 +266,20 @@  discard block
 block discarded – undo
262 266
 				$obj = $this->db->fetch_object($resql);
263 267
 
264 268
 				$type='';
265
-				if ($obj->type == 1) $type=$langs->trans("Supplier");
266
-				if ($obj->type == 2) $type=$langs->trans("Customer");
269
+				if ($obj->type == 1) {
270
+				    $type=$langs->trans("Supplier");
271
+				}
272
+				if ($obj->type == 2) {
273
+				    $type=$langs->trans("Customer");
274
+				}
267 275
 				$s.='<option value="'.$obj->rowid.'">'.dol_trunc($obj->label,38,'middle');
268
-				if ($type) $s.=' ('.$type.')';
276
+				if ($type) {
277
+				    $s.=' ('.$type.')';
278
+				}
269 279
 				$s.='</option>';
270 280
 				$i++;
271 281
 			}
272
-		}
273
-		else
282
+		} else
274 283
 		{
275 284
 			dol_print_error($this->db);
276 285
 		}
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/mailings/xinputuser.modules.php 3 patches
Indentation   +112 added lines, -112 removed lines patch added patch discarded remove patch
@@ -30,133 +30,133 @@
 block discarded – undo
30 30
  */
31 31
 class mailing_xinputuser extends MailingTargets
32 32
 {
33
-	var $name='EmailsFromUser';              // Identifiant du module mailing
34
-	// This label is used if no translation is found for key XXX neither MailingModuleDescXXX where XXX=name is found
35
-	var $desc='EMails input by user';        // Libelle utilise si aucune traduction pour MailingModuleDescXXX ou XXX=name trouv�e
36
-	var $require_module=array();            // Module mailing actif si modules require_module actifs
37
-	var $require_admin=0;                    // Module mailing actif pour user admin ou non
38
-	var $picto='generic';
39
-	var $tooltip='UseFormatInputEmailToTarget';
40
-
41
-
42
-	/**
43
-	 *	Constructor
44
-	 *
45
-	 *  @param		DoliDB		$db      Database handler
46
-	 */
47
-	function __construct($db)
48
-	{
49
-		$this->db=$db;
50
-	}
33
+    var $name='EmailsFromUser';              // Identifiant du module mailing
34
+    // This label is used if no translation is found for key XXX neither MailingModuleDescXXX where XXX=name is found
35
+    var $desc='EMails input by user';        // Libelle utilise si aucune traduction pour MailingModuleDescXXX ou XXX=name trouv�e
36
+    var $require_module=array();            // Module mailing actif si modules require_module actifs
37
+    var $require_admin=0;                    // Module mailing actif pour user admin ou non
38
+    var $picto='generic';
39
+    var $tooltip='UseFormatInputEmailToTarget';
51 40
 
52 41
 
53 42
     /**
54
-	 *	On the main mailing area, there is a box with statistics.
55
-	 *	If you want to add a line in this report you must provide an
56
-	 *	array of SQL request that returns two field:
57
-	 *	One called "label", One called "nb".
58
-	 *
59
-	 *	@return		array		Array with SQL requests
60
-	 */
61
-	function getSqlArrayForStats()
62
-	{
63
-		global $langs;
64
-		$langs->load("users");
65
-
66
-		$statssql=array();
67
-		return $statssql;
68
-	}
69
-
70
-
71
-	/**
72
-	 *	Return here number of distinct emails returned by your selector.
73
-	 *	For example if this selector is used to extract 500 different
74
-	 *	emails from a text file, this function must return 500.
75
-	 *
76
-	 *  @param      string	$sql   	Sql request to count
77
-	 *	@return		string			'' means NA
78
-	 */
79
-	function getNbOfRecipients($sql='')
80
-	{
81
-		return '';
82
-	}
83
-
84
-
85
-	/**
86
-	 *  Renvoie url lien vers fiche de la source du destinataire du mailing
87
-	 *
43
+     *	Constructor
44
+     *
45
+     *  @param		DoliDB		$db      Database handler
46
+     */
47
+    function __construct($db)
48
+    {
49
+        $this->db=$db;
50
+    }
51
+
52
+
53
+    /**
54
+     *	On the main mailing area, there is a box with statistics.
55
+     *	If you want to add a line in this report you must provide an
56
+     *	array of SQL request that returns two field:
57
+     *	One called "label", One called "nb".
58
+     *
59
+     *	@return		array		Array with SQL requests
60
+     */
61
+    function getSqlArrayForStats()
62
+    {
63
+        global $langs;
64
+        $langs->load("users");
65
+
66
+        $statssql=array();
67
+        return $statssql;
68
+    }
69
+
70
+
71
+    /**
72
+     *	Return here number of distinct emails returned by your selector.
73
+     *	For example if this selector is used to extract 500 different
74
+     *	emails from a text file, this function must return 500.
75
+     *
76
+     *  @param      string	$sql   	Sql request to count
77
+     *	@return		string			'' means NA
78
+     */
79
+    function getNbOfRecipients($sql='')
80
+    {
81
+        return '';
82
+    }
83
+
84
+
85
+    /**
86
+     *  Renvoie url lien vers fiche de la source du destinataire du mailing
87
+     *
88 88
      *  @param	int		$id		ID
89
-	 *  @return string      	Url lien
90
-	 */
91
-	function url($id)
92
-	{
93
-		return '';
94
-	}
95
-
96
-
97
-	/**
98
-	 *   Affiche formulaire de filtre qui apparait dans page de selection des destinataires de mailings
99
-	 *
100
-	 *   @return     string      Retourne zone select
101
-	 */
102
-	function formFilter()
103
-	{
104
-		global $langs;
105
-
106
-		$s='';
107
-		$s.='<input type="text" name="xinputuser" class="flat minwidth300" value="'.GETPOST("xinputuser").'">';
108
-		return $s;
109
-	}
89
+     *  @return string      	Url lien
90
+     */
91
+    function url($id)
92
+    {
93
+        return '';
94
+    }
95
+
96
+
97
+    /**
98
+     *   Affiche formulaire de filtre qui apparait dans page de selection des destinataires de mailings
99
+     *
100
+     *   @return     string      Retourne zone select
101
+     */
102
+    function formFilter()
103
+    {
104
+        global $langs;
105
+
106
+        $s='';
107
+        $s.='<input type="text" name="xinputuser" class="flat minwidth300" value="'.GETPOST("xinputuser").'">';
108
+        return $s;
109
+    }
110 110
 
111 111
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
112
-	/**
113
-	 *  Ajoute destinataires dans table des cibles
114
-	 *
115
-	 *  @param	int		$mailing_id    	Id of emailing
116
-	 *  @return int           			< 0 si erreur, nb ajout si ok
117
-	 */
118
-	function add_to_target($mailing_id)
119
-	{
112
+    /**
113
+     *  Ajoute destinataires dans table des cibles
114
+     *
115
+     *  @param	int		$mailing_id    	Id of emailing
116
+     *  @return int           			< 0 si erreur, nb ajout si ok
117
+     */
118
+    function add_to_target($mailing_id)
119
+    {
120 120
         // phpcs:enable
121
-		global $conf,$langs,$_FILES;
121
+        global $conf,$langs,$_FILES;
122 122
 
123
-		require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
123
+        require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
124 124
 
125
-		$tmparray=explode(';',GETPOST('xinputuser'));
126
-		$email=$tmparray[0];
127
-		$lastname=$tmparray[1];
128
-		$firstname=$tmparray[2];
129
-		$other=$tmparray[3];
125
+        $tmparray=explode(';',GETPOST('xinputuser'));
126
+        $email=$tmparray[0];
127
+        $lastname=$tmparray[1];
128
+        $firstname=$tmparray[2];
129
+        $other=$tmparray[3];
130 130
 
131
-		$cibles=array();
131
+        $cibles=array();
132 132
         if (! empty($email))
133 133
         {
134
-			if (isValidEMail($email))
135
-			{
136
-				$cibles[] = array(
137
-           			'email' => $email,
138
-           			'lastname' => $lastname,
139
-           			'firstname' => $firstname,
140
-					'other' => $other,
134
+            if (isValidEMail($email))
135
+            {
136
+                $cibles[] = array(
137
+                        'email' => $email,
138
+                        'lastname' => $lastname,
139
+                        'firstname' => $firstname,
140
+                    'other' => $other,
141 141
                     'source_url' => '',
142 142
                     'source_id' => '',
143 143
                     'source_type' => 'file'
144
-				);
145
-
146
-				return parent::add_to_target($mailing_id, $cibles);
147
-			}
148
-			else
149
-			{
150
-				$langs->load("errors");
151
-				$this->error = $langs->trans("ErrorBadEMail",$email);
152
-				return -1;
153
-			}
154
-		}
155
-		else
156
-		{
144
+                );
145
+
146
+                return parent::add_to_target($mailing_id, $cibles);
147
+            }
148
+            else
149
+            {
150
+                $langs->load("errors");
151
+                $this->error = $langs->trans("ErrorBadEMail",$email);
152
+                return -1;
153
+            }
154
+        }
155
+        else
156
+        {
157 157
             $langs->load("errors");
158 158
             $this->error = $langs->trans("ErrorBadEmail",$email);
159
-			return -1;
160
-		}
161
-	}
159
+            return -1;
160
+        }
161
+    }
162 162
 }
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -30,13 +30,13 @@  discard block
 block discarded – undo
30 30
  */
31 31
 class mailing_xinputuser extends MailingTargets
32 32
 {
33
-	var $name='EmailsFromUser';              // Identifiant du module mailing
33
+	var $name = 'EmailsFromUser'; // Identifiant du module mailing
34 34
 	// This label is used if no translation is found for key XXX neither MailingModuleDescXXX where XXX=name is found
35
-	var $desc='EMails input by user';        // Libelle utilise si aucune traduction pour MailingModuleDescXXX ou XXX=name trouv�e
36
-	var $require_module=array();            // Module mailing actif si modules require_module actifs
37
-	var $require_admin=0;                    // Module mailing actif pour user admin ou non
38
-	var $picto='generic';
39
-	var $tooltip='UseFormatInputEmailToTarget';
35
+	var $desc = 'EMails input by user'; // Libelle utilise si aucune traduction pour MailingModuleDescXXX ou XXX=name trouv�e
36
+	var $require_module = array(); // Module mailing actif si modules require_module actifs
37
+	var $require_admin = 0; // Module mailing actif pour user admin ou non
38
+	var $picto = 'generic';
39
+	var $tooltip = 'UseFormatInputEmailToTarget';
40 40
 
41 41
 
42 42
 	/**
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 	 */
47 47
 	function __construct($db)
48 48
 	{
49
-		$this->db=$db;
49
+		$this->db = $db;
50 50
 	}
51 51
 
52 52
 
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 		global $langs;
64 64
 		$langs->load("users");
65 65
 
66
-		$statssql=array();
66
+		$statssql = array();
67 67
 		return $statssql;
68 68
 	}
69 69
 
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 	 *  @param      string	$sql   	Sql request to count
77 77
 	 *	@return		string			'' means NA
78 78
 	 */
79
-	function getNbOfRecipients($sql='')
79
+	function getNbOfRecipients($sql = '')
80 80
 	{
81 81
 		return '';
82 82
 	}
@@ -103,8 +103,8 @@  discard block
 block discarded – undo
103 103
 	{
104 104
 		global $langs;
105 105
 
106
-		$s='';
107
-		$s.='<input type="text" name="xinputuser" class="flat minwidth300" value="'.GETPOST("xinputuser").'">';
106
+		$s = '';
107
+		$s .= '<input type="text" name="xinputuser" class="flat minwidth300" value="'.GETPOST("xinputuser").'">';
108 108
 		return $s;
109 109
 	}
110 110
 
@@ -118,18 +118,18 @@  discard block
 block discarded – undo
118 118
 	function add_to_target($mailing_id)
119 119
 	{
120 120
         // phpcs:enable
121
-		global $conf,$langs,$_FILES;
121
+		global $conf, $langs, $_FILES;
122 122
 
123 123
 		require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
124 124
 
125
-		$tmparray=explode(';',GETPOST('xinputuser'));
126
-		$email=$tmparray[0];
127
-		$lastname=$tmparray[1];
128
-		$firstname=$tmparray[2];
129
-		$other=$tmparray[3];
125
+		$tmparray = explode(';', GETPOST('xinputuser'));
126
+		$email = $tmparray[0];
127
+		$lastname = $tmparray[1];
128
+		$firstname = $tmparray[2];
129
+		$other = $tmparray[3];
130 130
 
131
-		$cibles=array();
132
-        if (! empty($email))
131
+		$cibles = array();
132
+        if (!empty($email))
133 133
         {
134 134
 			if (isValidEMail($email))
135 135
 			{
@@ -148,14 +148,14 @@  discard block
 block discarded – undo
148 148
 			else
149 149
 			{
150 150
 				$langs->load("errors");
151
-				$this->error = $langs->trans("ErrorBadEMail",$email);
151
+				$this->error = $langs->trans("ErrorBadEMail", $email);
152 152
 				return -1;
153 153
 			}
154 154
 		}
155 155
 		else
156 156
 		{
157 157
             $langs->load("errors");
158
-            $this->error = $langs->trans("ErrorBadEmail",$email);
158
+            $this->error = $langs->trans("ErrorBadEmail", $email);
159 159
 			return -1;
160 160
 		}
161 161
 	}
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -144,15 +144,13 @@
 block discarded – undo
144 144
 				);
145 145
 
146 146
 				return parent::add_to_target($mailing_id, $cibles);
147
-			}
148
-			else
147
+			} else
149 148
 			{
150 149
 				$langs->load("errors");
151 150
 				$this->error = $langs->trans("ErrorBadEMail",$email);
152 151
 				return -1;
153 152
 			}
154
-		}
155
-		else
153
+		} else
156 154
 		{
157 155
             $langs->load("errors");
158 156
             $this->error = $langs->trans("ErrorBadEmail",$email);
Please login to merge, or discard this patch.