Passed
Push — master ( a56e33...222e44 )
by Alxarafe
36:56
created
dolibarr/htdocs/core/modules/societe/modules_societe.class.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -34,9 +34,9 @@  discard block
 block discarded – undo
34 34
 abstract class ModeleThirdPartyDoc extends CommonDocGenerator
35 35
 {
36 36
     /**
37
-	 * @var string Error code (or message)
38
-	 */
39
-	public $error='';
37
+     * @var string Error code (or message)
38
+     */
39
+    public $error='';
40 40
 
41 41
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
42 42
     /**
@@ -69,8 +69,8 @@  discard block
 block discarded – undo
69 69
 {
70 70
     /**
71 71
      * @var string Error code (or message)
72
-	 */
73
-	public $error='';
72
+     */
73
+    public $error='';
74 74
 
75 75
     /**     Renvoi la description par defaut du modele de numerotation
76 76
      *
@@ -246,10 +246,10 @@  discard block
 block discarded – undo
246 246
     }
247 247
 
248 248
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
249
-	/**
250
-	 *   Check if mask/numbering use prefix
251
-	 *
252
-	 *   @return    int	    0=no, 1=yes
249
+    /**
250
+     *   Check if mask/numbering use prefix
251
+     *
252
+     *   @return    int	    0=no, 1=yes
253 253
      */
254 254
     function verif_prefixIsUsed()
255 255
     {
@@ -266,9 +266,9 @@  discard block
 block discarded – undo
266 266
 abstract class ModeleAccountancyCode
267 267
 {
268 268
     /**
269
-	 * @var string Error code (or message)
270
-	 */
271
-	public $error='';
269
+     * @var string Error code (or message)
270
+     */
271
+    public $error='';
272 272
 
273 273
 
274 274
     /**		Return description of module
@@ -397,7 +397,7 @@  discard block
 block discarded – undo
397 397
 function thirdparty_doc_create(DoliDB $db, Societe $object, $message, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0)
398 398
 {
399 399
     // phpcs:enable
400
-	dol_syslog(__METHOD__ . " is deprecated", LOG_WARNING);
400
+    dol_syslog(__METHOD__ . " is deprecated", LOG_WARNING);
401 401
 
402
-	return $object->generateDocument($modele, $outputlangs, $hidedetails, $hidedesc, $hideref);
402
+    return $object->generateDocument($modele, $outputlangs, $hidedetails, $hidedesc, $hideref);
403 403
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/societe/mod_codeclient_elephant.php 1 patch
Indentation   +298 added lines, -298 removed lines patch added patch discarded remove patch
@@ -34,319 +34,319 @@
 block discarded – undo
34 34
  */
35 35
 class mod_codeclient_elephant extends ModeleThirdPartyCode
36 36
 {
37
-	/**
38
-	 * @var string Nom du modele
39
-	 * @deprecated
40
-	 * @see name
41
-	 */
42
-	public $nom='Elephant';
37
+    /**
38
+     * @var string Nom du modele
39
+     * @deprecated
40
+     * @see name
41
+     */
42
+    public $nom='Elephant';
43 43
 
44
-	/**
45
-	 * @var string model name
46
-	 */
47
-	public $name='Elephant';
44
+    /**
45
+     * @var string model name
46
+     */
47
+    public $name='Elephant';
48 48
 
49
-	public $code_modifiable;				// Code modifiable
49
+    public $code_modifiable;				// Code modifiable
50 50
 
51
-	public $code_modifiable_invalide;		// Code modifiable si il est invalide
51
+    public $code_modifiable_invalide;		// Code modifiable si il est invalide
52 52
 
53
-	public $code_modifiable_null;			// Code modifiables si il est null
53
+    public $code_modifiable_null;			// Code modifiables si il est null
54 54
 
55
-	public $code_null;						// Code facultatif
55
+    public $code_null;						// Code facultatif
56 56
 
57
-	/**
57
+    /**
58 58
      * Dolibarr version of the loaded document
59 59
      * @public string
60 60
      */
61
-	public $version = 'dolibarr';    		// 'development', 'experimental', 'dolibarr'
62
-
63
-	public $code_auto;                     // Numerotation automatique
64
-
65
-	public $searchcode; // String de recherche
66
-
67
-	public $numbitcounter; // Nombre de chiffres du compteur
68
-
69
-	public $prefixIsRequired; // Le champ prefix du tiers doit etre renseigne quand on utilise {pre}
70
-
71
-
72
-	/**
73
-	 *	Constructor
74
-	 */
75
-	function __construct()
76
-	{
77
-		$this->code_null = 0;
78
-		$this->code_modifiable = 1;
79
-		$this->code_modifiable_invalide = 1;
80
-		$this->code_modifiable_null = 1;
81
-		$this->code_auto = 1;
82
-		$this->prefixIsRequired = 0;
83
-	}
84
-
85
-
86
-	/**		Return description of module
87
-	 *
88
-	 * 		@param	Translate	$langs		Object langs
89
-	 * 		@return string      			Description of module
90
-	 */
91
-	function info($langs)
92
-	{
93
-		global $conf, $mc;
94
-		global $form;
95
-
96
-		$langs->load("companies");
97
-
98
-		$disabled = ((! empty($mc->sharings['referent']) && $mc->sharings['referent'] != $conf->entity) ? ' disabled' : '');
99
-
100
-		$texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
101
-		$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
102
-		$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
103
-		$texte.= '<input type="hidden" name="action" value="setModuleOptions">';
104
-		$texte.= '<input type="hidden" name="param1" value="COMPANY_ELEPHANT_MASK_CUSTOMER">';
105
-		$texte.= '<input type="hidden" name="param2" value="COMPANY_ELEPHANT_MASK_SUPPLIER">';
106
-		$texte.= '<table class="nobordernopadding" width="100%">';
107
-
108
-		$tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("ThirdParty"),$langs->transnoentities("ThirdParty"));
109
-		//$tooltip.=$langs->trans("GenericMaskCodes2");	Not required for third party numbering
110
-		$tooltip.=$langs->trans("GenericMaskCodes3");
111
-		$tooltip.=$langs->trans("GenericMaskCodes4b");
112
-		$tooltip.=$langs->trans("GenericMaskCodes5");
113
-
114
-		// Parametrage du prefix customers
115
-		$texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("CustomerCodeModel").'):</td>';
116
-		$texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="value1" value="'.$conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER.'"'.$disabled.'>',$tooltip,1,1).'</td>';
117
-
118
-		$texte.= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"'.$disabled.'></td>';
119
-
120
-		$texte.= '</tr>';
121
-
122
-		// Parametrage du prefix suppliers
123
-		$texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("SupplierCodeModel").'):</td>';
124
-		$texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="value2" value="'.$conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER.'"'.$disabled.'>',$tooltip,1,1).'</td>';
125
-		$texte.= '</tr>';
126
-
127
-		$texte.= '</table>';
128
-		$texte.= '</form>';
129
-
130
-		return $texte;
131
-	}
132
-
133
-
134
-	/**
135
-	 * Return an example of result returned by getNextValue
136
-	 *
137
-	 * @param	Translate	$langs		Object langs
138
-	 * @param	societe		$objsoc		Object thirdparty
139
-	 * @param	int			$type		Type of third party (1:customer, 2:supplier, -1:autodetect)
140
-	 * @return	string					Return string example
141
-	 */
142
-	function getExample($langs,$objsoc=0,$type=-1)
143
-	{
144
-		if ($type == 0 || $type == -1)
145
-		{
146
-			$examplecust = $this->getNextValue($objsoc,0);
147
-			if (! $examplecust)
148
-			{
149
-				$examplecust = $langs->trans('NotConfigured');
150
-			}
151
-			if($examplecust=="ErrorBadMask")
152
-			{
153
-				$langs->load("errors");
154
-				$examplecust=$langs->trans($examplecust);
155
-			}
156
-			if($examplecust=="ErrorCantUseRazIfNoYearInMask")
157
-			{
158
-				$langs->load("errors");
159
-				$examplecust=$langs->trans($examplecust);
160
-			}
161
-			if($examplecust=="ErrorCantUseRazInStartedYearIfNoYearMonthInMask")
162
-			{
163
-				$langs->load("errors");
164
-				$examplecust=$langs->trans($examplecust);
165
-			}
166
-		}
167
-		if ($type == 1 || $type == -1)
168
-		{
169
-			$examplesup = $this->getNextValue($objsoc,1);
170
-			if (! $examplesup)
171
-			{
172
-				$examplesup = $langs->trans('NotConfigured');
173
-			}
174
-			if($examplesup=="ErrorBadMask")
175
-			{
176
-				$langs->load("errors");
177
-				$examplesup=$langs->trans($examplesup);
178
-			}
179
-			if($examplesup=="ErrorCantUseRazIfNoYearInMask")
180
-			{
181
-				$langs->load("errors");
182
-				$examplesup=$langs->trans($examplesup);
183
-			}
184
-			if($examplesup=="ErrorCantUseRazInStartedYearIfNoYearMonthInMask")
185
-			{
186
-				$langs->load("errors");
187
-				$examplesup=$langs->trans($examplesup);
188
-			}
189
-		}
190
-
191
-		if ($type == 0) return $examplecust;
192
-		if ($type == 1) return $examplesup;
193
-		return $examplecust.'<br>'.$examplesup;
194
-	}
195
-
196
-	/**
197
-	 * Return next value
198
-	 *
199
-	 * @param	Societe		$objsoc     Object third party
200
-	 * @param  	int		    $type       Client ou fournisseur (0:customer, 1:supplier)
201
-	 * @return 	string      			Value if OK, '' if module not configured, <0 if KO
202
-	 */
203
-	function getNextValue($objsoc=0,$type=-1)
204
-	{
205
-		global $db,$conf;
206
-
207
-		require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
208
-
209
-		// Get Mask value
210
-		$mask = '';
211
-		if ($type==0) $mask = $conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER;
212
-		if ($type==1) $mask = $conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER;
213
-		if (! $mask)
214
-		{
215
-			$this->error='NotConfigured';
216
-			return '';
217
-		}
218
-
219
-		$field='';$where='';
220
-		if ($type == 0)
221
-		{
222
-			$field = 'code_client';
223
-			//$where = ' AND client in (1,2)';
224
-		}
225
-		else if ($type == 1)
226
-		{
227
-			$field = 'code_fournisseur';
228
-			//$where = ' AND fournisseur = 1';
229
-		}
230
-		else return -1;
231
-
232
-		$now=dol_now();
233
-
234
-		$numFinal=get_next_value($db,$mask,'societe',$field,$where,'',$now);
235
-
236
-		return  $numFinal;
237
-	}
61
+    public $version = 'dolibarr';    		// 'development', 'experimental', 'dolibarr'
62
+
63
+    public $code_auto;                     // Numerotation automatique
64
+
65
+    public $searchcode; // String de recherche
66
+
67
+    public $numbitcounter; // Nombre de chiffres du compteur
68
+
69
+    public $prefixIsRequired; // Le champ prefix du tiers doit etre renseigne quand on utilise {pre}
70
+
71
+
72
+    /**
73
+     *	Constructor
74
+     */
75
+    function __construct()
76
+    {
77
+        $this->code_null = 0;
78
+        $this->code_modifiable = 1;
79
+        $this->code_modifiable_invalide = 1;
80
+        $this->code_modifiable_null = 1;
81
+        $this->code_auto = 1;
82
+        $this->prefixIsRequired = 0;
83
+    }
84
+
85
+
86
+    /**		Return description of module
87
+     *
88
+     * 		@param	Translate	$langs		Object langs
89
+     * 		@return string      			Description of module
90
+     */
91
+    function info($langs)
92
+    {
93
+        global $conf, $mc;
94
+        global $form;
95
+
96
+        $langs->load("companies");
97
+
98
+        $disabled = ((! empty($mc->sharings['referent']) && $mc->sharings['referent'] != $conf->entity) ? ' disabled' : '');
99
+
100
+        $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
101
+        $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
102
+        $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
103
+        $texte.= '<input type="hidden" name="action" value="setModuleOptions">';
104
+        $texte.= '<input type="hidden" name="param1" value="COMPANY_ELEPHANT_MASK_CUSTOMER">';
105
+        $texte.= '<input type="hidden" name="param2" value="COMPANY_ELEPHANT_MASK_SUPPLIER">';
106
+        $texte.= '<table class="nobordernopadding" width="100%">';
107
+
108
+        $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("ThirdParty"),$langs->transnoentities("ThirdParty"));
109
+        //$tooltip.=$langs->trans("GenericMaskCodes2");	Not required for third party numbering
110
+        $tooltip.=$langs->trans("GenericMaskCodes3");
111
+        $tooltip.=$langs->trans("GenericMaskCodes4b");
112
+        $tooltip.=$langs->trans("GenericMaskCodes5");
113
+
114
+        // Parametrage du prefix customers
115
+        $texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("CustomerCodeModel").'):</td>';
116
+        $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="value1" value="'.$conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER.'"'.$disabled.'>',$tooltip,1,1).'</td>';
117
+
118
+        $texte.= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"'.$disabled.'></td>';
119
+
120
+        $texte.= '</tr>';
121
+
122
+        // Parametrage du prefix suppliers
123
+        $texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("SupplierCodeModel").'):</td>';
124
+        $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="value2" value="'.$conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER.'"'.$disabled.'>',$tooltip,1,1).'</td>';
125
+        $texte.= '</tr>';
126
+
127
+        $texte.= '</table>';
128
+        $texte.= '</form>';
129
+
130
+        return $texte;
131
+    }
132
+
133
+
134
+    /**
135
+     * Return an example of result returned by getNextValue
136
+     *
137
+     * @param	Translate	$langs		Object langs
138
+     * @param	societe		$objsoc		Object thirdparty
139
+     * @param	int			$type		Type of third party (1:customer, 2:supplier, -1:autodetect)
140
+     * @return	string					Return string example
141
+     */
142
+    function getExample($langs,$objsoc=0,$type=-1)
143
+    {
144
+        if ($type == 0 || $type == -1)
145
+        {
146
+            $examplecust = $this->getNextValue($objsoc,0);
147
+            if (! $examplecust)
148
+            {
149
+                $examplecust = $langs->trans('NotConfigured');
150
+            }
151
+            if($examplecust=="ErrorBadMask")
152
+            {
153
+                $langs->load("errors");
154
+                $examplecust=$langs->trans($examplecust);
155
+            }
156
+            if($examplecust=="ErrorCantUseRazIfNoYearInMask")
157
+            {
158
+                $langs->load("errors");
159
+                $examplecust=$langs->trans($examplecust);
160
+            }
161
+            if($examplecust=="ErrorCantUseRazInStartedYearIfNoYearMonthInMask")
162
+            {
163
+                $langs->load("errors");
164
+                $examplecust=$langs->trans($examplecust);
165
+            }
166
+        }
167
+        if ($type == 1 || $type == -1)
168
+        {
169
+            $examplesup = $this->getNextValue($objsoc,1);
170
+            if (! $examplesup)
171
+            {
172
+                $examplesup = $langs->trans('NotConfigured');
173
+            }
174
+            if($examplesup=="ErrorBadMask")
175
+            {
176
+                $langs->load("errors");
177
+                $examplesup=$langs->trans($examplesup);
178
+            }
179
+            if($examplesup=="ErrorCantUseRazIfNoYearInMask")
180
+            {
181
+                $langs->load("errors");
182
+                $examplesup=$langs->trans($examplesup);
183
+            }
184
+            if($examplesup=="ErrorCantUseRazInStartedYearIfNoYearMonthInMask")
185
+            {
186
+                $langs->load("errors");
187
+                $examplesup=$langs->trans($examplesup);
188
+            }
189
+        }
190
+
191
+        if ($type == 0) return $examplecust;
192
+        if ($type == 1) return $examplesup;
193
+        return $examplecust.'<br>'.$examplesup;
194
+    }
195
+
196
+    /**
197
+     * Return next value
198
+     *
199
+     * @param	Societe		$objsoc     Object third party
200
+     * @param  	int		    $type       Client ou fournisseur (0:customer, 1:supplier)
201
+     * @return 	string      			Value if OK, '' if module not configured, <0 if KO
202
+     */
203
+    function getNextValue($objsoc=0,$type=-1)
204
+    {
205
+        global $db,$conf;
206
+
207
+        require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
208
+
209
+        // Get Mask value
210
+        $mask = '';
211
+        if ($type==0) $mask = $conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER;
212
+        if ($type==1) $mask = $conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER;
213
+        if (! $mask)
214
+        {
215
+            $this->error='NotConfigured';
216
+            return '';
217
+        }
218
+
219
+        $field='';$where='';
220
+        if ($type == 0)
221
+        {
222
+            $field = 'code_client';
223
+            //$where = ' AND client in (1,2)';
224
+        }
225
+        else if ($type == 1)
226
+        {
227
+            $field = 'code_fournisseur';
228
+            //$where = ' AND fournisseur = 1';
229
+        }
230
+        else return -1;
231
+
232
+        $now=dol_now();
233
+
234
+        $numFinal=get_next_value($db,$mask,'societe',$field,$where,'',$now);
235
+
236
+        return  $numFinal;
237
+    }
238 238
 
239 239
 
240 240
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
241
-	/**
242
-	 *   Check if mask/numbering use prefix
243
-	 *
244
-	 *   @return	int			0 or 1
245
-	 */
246
-	function verif_prefixIsUsed()
247
-	{
241
+    /**
242
+     *   Check if mask/numbering use prefix
243
+     *
244
+     *   @return	int			0 or 1
245
+     */
246
+    function verif_prefixIsUsed()
247
+    {
248 248
         // phpcs:enable
249
-		global $conf;
250
-
251
-		$mask = $conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER;
252
-		if (preg_match('/\{pre\}/i',$mask)) return 1;
253
-
254
-		$mask = $conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER;
255
-		if (preg_match('/\{pre\}/i',$mask)) return 1;
256
-
257
-		return 0;
258
-	}
259
-
260
-
261
-	/**
262
-	 * 	Check validity of code according to its rules
263
-	 *
264
-	 *	@param	DoliDB		$db		Database handler
265
-	 *	@param	string		$code	Code to check/correct
266
-	 *	@param	Societe		$soc	Object third party
267
-	 *  @param  int		  	$type   0 = customer/prospect , 1 = supplier
268
-	 *  @return int					0 if OK
269
-	 * 								-1 ErrorBadCustomerCodeSyntax
270
-	 * 								-2 ErrorCustomerCodeRequired
271
-	 * 								-3 ErrorCustomerCodeAlreadyUsed
272
-	 * 								-4 ErrorPrefixRequired
273
-	 * 								-5 Other (see this->error)
274
-	 */
275
-	function verif($db, &$code, $soc, $type)
276
-	{
277
-		global $conf;
278
-
279
-		require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
280
-
281
-		$result=0;
282
-		$code = strtoupper(trim($code));
283
-
284
-		if (empty($code) && $this->code_null && empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED))
285
-		{
286
-			$result=0;
287
-		}
288
-		else if (empty($code) && (! $this->code_null || ! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) )
289
-		{
290
-			$result=-2;
291
-		}
292
-		else
293
-		{
294
-			// Get Mask value
295
-			$mask = '';
296
-			if ($type==0) $mask = empty($conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER)?'':$conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER;
297
-			if ($type==1) $mask = empty($conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER)?'':$conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER;
298
-			if (! $mask)
299
-			{
300
-				$this->error='NotConfigured';
301
-				return -5;
302
-			}
303
-
304
-			$result=check_value($mask,$code);
305
-			if (is_string($result))
306
-			{
307
-				$this->error = $result;
308
-				return -5;
309
-			}
310
-		}
311
-
312
-		dol_syslog("mod_codeclient_elephant::verif type=".$type." result=".$result);
313
-		return $result;
314
-	}
249
+        global $conf;
250
+
251
+        $mask = $conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER;
252
+        if (preg_match('/\{pre\}/i',$mask)) return 1;
253
+
254
+        $mask = $conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER;
255
+        if (preg_match('/\{pre\}/i',$mask)) return 1;
256
+
257
+        return 0;
258
+    }
259
+
260
+
261
+    /**
262
+     * 	Check validity of code according to its rules
263
+     *
264
+     *	@param	DoliDB		$db		Database handler
265
+     *	@param	string		$code	Code to check/correct
266
+     *	@param	Societe		$soc	Object third party
267
+     *  @param  int		  	$type   0 = customer/prospect , 1 = supplier
268
+     *  @return int					0 if OK
269
+     * 								-1 ErrorBadCustomerCodeSyntax
270
+     * 								-2 ErrorCustomerCodeRequired
271
+     * 								-3 ErrorCustomerCodeAlreadyUsed
272
+     * 								-4 ErrorPrefixRequired
273
+     * 								-5 Other (see this->error)
274
+     */
275
+    function verif($db, &$code, $soc, $type)
276
+    {
277
+        global $conf;
278
+
279
+        require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
280
+
281
+        $result=0;
282
+        $code = strtoupper(trim($code));
283
+
284
+        if (empty($code) && $this->code_null && empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED))
285
+        {
286
+            $result=0;
287
+        }
288
+        else if (empty($code) && (! $this->code_null || ! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) )
289
+        {
290
+            $result=-2;
291
+        }
292
+        else
293
+        {
294
+            // Get Mask value
295
+            $mask = '';
296
+            if ($type==0) $mask = empty($conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER)?'':$conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER;
297
+            if ($type==1) $mask = empty($conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER)?'':$conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER;
298
+            if (! $mask)
299
+            {
300
+                $this->error='NotConfigured';
301
+                return -5;
302
+            }
303
+
304
+            $result=check_value($mask,$code);
305
+            if (is_string($result))
306
+            {
307
+                $this->error = $result;
308
+                return -5;
309
+            }
310
+        }
311
+
312
+        dol_syslog("mod_codeclient_elephant::verif type=".$type." result=".$result);
313
+        return $result;
314
+    }
315 315
 
316 316
 
317 317
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
318
-	/**
319
-	 *		Renvoi si un code est pris ou non (par autre tiers)
320
-	 *
321
-	 *		@param	DoliDB		$db			Handler acces base
322
-	 *		@param	string		$code		Code a verifier
323
-	 *		@param	Societe		$soc		Objet societe
324
-	 *		@param  int		  	$type   	0 = customer/prospect , 1 = supplier
325
-	 *		@return	int						0 if available, <0 if KO
326
-	 */
327
-	function verif_dispo($db, $code, $soc, $type=0)
328
-	{
318
+    /**
319
+     *		Renvoi si un code est pris ou non (par autre tiers)
320
+     *
321
+     *		@param	DoliDB		$db			Handler acces base
322
+     *		@param	string		$code		Code a verifier
323
+     *		@param	Societe		$soc		Objet societe
324
+     *		@param  int		  	$type   	0 = customer/prospect , 1 = supplier
325
+     *		@return	int						0 if available, <0 if KO
326
+     */
327
+    function verif_dispo($db, $code, $soc, $type=0)
328
+    {
329 329
         // phpcs:enable
330
-		$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe";
331
-		if ($type == 1) $sql.= " WHERE code_fournisseur = '".$code."'";
332
-		else $sql.= " WHERE code_client = '".$code."'";
333
-		if ($soc->id > 0) $sql.= " AND rowid <> ".$soc->id;
334
-
335
-		$resql=$db->query($sql);
336
-		if ($resql)
337
-		{
338
-			if ($db->num_rows($resql) == 0)
339
-			{
340
-				return 0;
341
-			}
342
-			else
343
-			{
344
-				return -1;
345
-			}
346
-		}
347
-		else
348
-		{
349
-			return -2;
350
-		}
351
-	}
330
+        $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe";
331
+        if ($type == 1) $sql.= " WHERE code_fournisseur = '".$code."'";
332
+        else $sql.= " WHERE code_client = '".$code."'";
333
+        if ($soc->id > 0) $sql.= " AND rowid <> ".$soc->id;
334
+
335
+        $resql=$db->query($sql);
336
+        if ($resql)
337
+        {
338
+            if ($db->num_rows($resql) == 0)
339
+            {
340
+                return 0;
341
+            }
342
+            else
343
+            {
344
+                return -1;
345
+            }
346
+        }
347
+        else
348
+        {
349
+            return -2;
350
+        }
351
+    }
352 352
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/societe/mod_codeclient_monkey.php 1 patch
Indentation   +230 added lines, -230 removed lines patch added patch discarded remove patch
@@ -32,259 +32,259 @@
 block discarded – undo
32 32
  */
33 33
 class mod_codeclient_monkey extends ModeleThirdPartyCode
34 34
 {
35
-	/**
36
-	 * @var string Nom du modele
37
-	 * @deprecated
38
-	 * @see name
39
-	 */
40
-	public $nom='Monkey';
35
+    /**
36
+     * @var string Nom du modele
37
+     * @deprecated
38
+     * @see name
39
+     */
40
+    public $nom='Monkey';
41 41
 
42
-	/**
43
-	 * @var string model name
44
-	 */
45
-	public $name='Monkey';
42
+    /**
43
+     * @var string model name
44
+     */
45
+    public $name='Monkey';
46 46
 
47
-	public $code_modifiable;				// Code modifiable
47
+    public $code_modifiable;				// Code modifiable
48 48
 
49
-	public $code_modifiable_invalide;		// Code modifiable si il est invalide
49
+    public $code_modifiable_invalide;		// Code modifiable si il est invalide
50 50
 
51
-	public $code_modifiable_null;			// Code modifiables si il est null
51
+    public $code_modifiable_null;			// Code modifiables si il est null
52 52
 
53
-	public $code_null;						// Code facultatif
53
+    public $code_null;						// Code facultatif
54 54
 
55
-	/**
55
+    /**
56 56
      * Dolibarr version of the loaded document
57 57
      * @public string
58 58
      */
59
-	public $version = 'dolibarr';	    	// 'development', 'experimental', 'dolibarr'
60
-
61
-	public $code_auto;                     // Numerotation automatique
62
-
63
-	public $prefixcustomer='CU';
64
-
65
-	public $prefixsupplier='SU';
66
-
67
-	public $prefixIsRequired; // Le champ prefix du tiers doit etre renseigne quand on utilise {pre}
68
-
69
-
70
-	/**
71
-	 * 	Constructor
72
-	 */
73
-	function __construct()
74
-	{
75
-		$this->nom = "Monkey";
76
-		$this->name = "Monkey";
77
-		$this->version = "dolibarr";
78
-		$this->code_null = 1;
79
-		$this->code_modifiable = 1;
80
-		$this->code_modifiable_invalide = 1;
81
-		$this->code_modifiable_null = 1;
82
-		$this->code_auto = 1;
83
-		$this->prefixIsRequired = 0;
84
-	}
85
-
86
-
87
-	/**		Return description of module
88
-	 *
89
-	 * 		@param	Translate	$langs	Object langs
90
-	 * 		@return string      		Description of module
91
-	 */
92
-	function info($langs)
93
-	{
94
-		return $langs->trans("MonkeyNumRefModelDesc",$this->prefixcustomer,$this->prefixsupplier);
95
-	}
96
-
97
-
98
-	/**
99
-	 * Return an example of result returned by getNextValue
100
-	 *
101
-	 * @param	Translate	$langs		Object langs
102
-	 * @param	societe		$objsoc		Object thirdparty
103
-	 * @param	int			$type		Type of third party (1:customer, 2:supplier, -1:autodetect)
104
-	 * @return	string					Return string example
105
-	 */
106
-	function getExample($langs,$objsoc=0,$type=-1)
107
-	{
108
-		return $this->prefixcustomer.'0901-00001<br>'.$this->prefixsupplier.'0901-00001';
109
-	}
110
-
111
-
112
-	/**
113
-	 *  Return next value
114
-	 *
115
-	 * 	@param	Societe		$objsoc     Object third party
116
-	 *	@param  int			$type       Client ou fournisseur (1:client, 2:fournisseur)
117
-	 *  @return string      			Value if OK, '' if module not configured, <0 if KO
118
-	 */
119
-	function getNextValue($objsoc=0,$type=-1)
120
-	{
121
-		global $db, $conf, $mc;
122
-
123
-		$field='';
59
+    public $version = 'dolibarr';	    	// 'development', 'experimental', 'dolibarr'
60
+
61
+    public $code_auto;                     // Numerotation automatique
62
+
63
+    public $prefixcustomer='CU';
64
+
65
+    public $prefixsupplier='SU';
66
+
67
+    public $prefixIsRequired; // Le champ prefix du tiers doit etre renseigne quand on utilise {pre}
68
+
69
+
70
+    /**
71
+     * 	Constructor
72
+     */
73
+    function __construct()
74
+    {
75
+        $this->nom = "Monkey";
76
+        $this->name = "Monkey";
77
+        $this->version = "dolibarr";
78
+        $this->code_null = 1;
79
+        $this->code_modifiable = 1;
80
+        $this->code_modifiable_invalide = 1;
81
+        $this->code_modifiable_null = 1;
82
+        $this->code_auto = 1;
83
+        $this->prefixIsRequired = 0;
84
+    }
85
+
86
+
87
+    /**		Return description of module
88
+     *
89
+     * 		@param	Translate	$langs	Object langs
90
+     * 		@return string      		Description of module
91
+     */
92
+    function info($langs)
93
+    {
94
+        return $langs->trans("MonkeyNumRefModelDesc",$this->prefixcustomer,$this->prefixsupplier);
95
+    }
96
+
97
+
98
+    /**
99
+     * Return an example of result returned by getNextValue
100
+     *
101
+     * @param	Translate	$langs		Object langs
102
+     * @param	societe		$objsoc		Object thirdparty
103
+     * @param	int			$type		Type of third party (1:customer, 2:supplier, -1:autodetect)
104
+     * @return	string					Return string example
105
+     */
106
+    function getExample($langs,$objsoc=0,$type=-1)
107
+    {
108
+        return $this->prefixcustomer.'0901-00001<br>'.$this->prefixsupplier.'0901-00001';
109
+    }
110
+
111
+
112
+    /**
113
+     *  Return next value
114
+     *
115
+     * 	@param	Societe		$objsoc     Object third party
116
+     *	@param  int			$type       Client ou fournisseur (1:client, 2:fournisseur)
117
+     *  @return string      			Value if OK, '' if module not configured, <0 if KO
118
+     */
119
+    function getNextValue($objsoc=0,$type=-1)
120
+    {
121
+        global $db, $conf, $mc;
122
+
123
+        $field='';
124 124
         $prefix = '';
125
-		if ($type == 0) {
126
-			$field = 'code_client';
125
+        if ($type == 0) {
126
+            $field = 'code_client';
127 127
             $prefix = $this->prefixcustomer;
128
-		} elseif ($type == 1) {
129
-			$field = 'code_fournisseur';
128
+        } elseif ($type == 1) {
129
+            $field = 'code_fournisseur';
130 130
             $prefix = $this->prefixsupplier;
131
-		} else {
131
+        } else {
132 132
             return -1;
133 133
         }
134 134
 
135 135
         // D'abord on recupere la valeur max (reponse immediate car champ indexe)
136
-		$posindice=8;
136
+        $posindice=8;
137 137
         $sql = "SELECT MAX(CAST(SUBSTRING(".$field." FROM ".$posindice.") AS SIGNED)) as max";   // This is standard SQL
138
-		$sql.= " FROM ".MAIN_DB_PREFIX."societe";
139
-		$sql.= " WHERE ".$field." LIKE '".$prefix."____-%'";
140
-		$sql.= " AND entity IN (".getEntity('societe').")";
141
-
142
-		dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG);
143
-
144
-		$resql=$db->query($sql);
145
-		if ($resql)
146
-		{
147
-			$obj = $db->fetch_object($resql);
148
-			if ($obj) $max = intval($obj->max);
149
-			else $max=0;
150
-		}
151
-		else
152
-		{
153
-			return -1;
154
-		}
155
-
156
-		$date	= dol_now();
157
-		$yymm	= strftime("%y%m",$date);
158
-
159
-		if ($max >= (pow(10, 5) - 1)) $num=$max+1;	// If counter > 99999, we do not format on 5 chars, we take number as it is
160
-		else $num = sprintf("%05s",$max+1);
161
-
162
-		dol_syslog(get_class($this)."::getNextValue return ".$prefix.$yymm."-".$num);
163
-		return $prefix.$yymm."-".$num;
164
-	}
165
-
166
-
167
-	/**
168
-	 * 	Check validity of code according to its rules
169
-	 *
170
-	 *	@param	DoliDB		$db		Database handler
171
-	 *	@param	string		$code	Code to check/correct
172
-	 *	@param	Societe		$soc	Object third party
173
-	 *  @param  int		  	$type   0 = customer/prospect , 1 = supplier
174
-	 *  @return int					0 if OK
175
-	 * 								-1 ErrorBadCustomerCodeSyntax
176
-	 * 								-2 ErrorCustomerCodeRequired
177
-	 * 								-3 ErrorCustomerCodeAlreadyUsed
178
-	 * 								-4 ErrorPrefixRequired
179
-	 */
180
-	function verif($db, &$code, $soc, $type)
181
-	{
182
-		global $conf;
183
-
184
-		$result=0;
185
-		$code = strtoupper(trim($code));
186
-
187
-		if (empty($code) && $this->code_null && empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED))
188
-		{
189
-			$result=0;
190
-		}
191
-		else if (empty($code) && (! $this->code_null || ! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) )
192
-		{
193
-			$result=-2;
194
-		}
195
-		else
196
-		{
197
-			if ($this->verif_syntax($code) >= 0)
198
-			{
199
-				$is_dispo = $this->verif_dispo($db, $code, $soc, $type);
200
-				if ($is_dispo <> 0)
201
-				{
202
-					$result=-3;
203
-				}
204
-				else
205
-				{
206
-					$result=0;
207
-				}
208
-			}
209
-			else
210
-			{
211
-				if (dol_strlen($code) == 0)
212
-				{
213
-					$result=-2;
214
-				}
215
-				else
216
-				{
217
-					$result=-1;
218
-				}
219
-			}
220
-		}
221
-
222
-		dol_syslog(get_class($this)."::verif code=".$code." type=".$type." result=".$result);
223
-		return $result;
224
-	}
138
+        $sql.= " FROM ".MAIN_DB_PREFIX."societe";
139
+        $sql.= " WHERE ".$field." LIKE '".$prefix."____-%'";
140
+        $sql.= " AND entity IN (".getEntity('societe').")";
141
+
142
+        dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG);
143
+
144
+        $resql=$db->query($sql);
145
+        if ($resql)
146
+        {
147
+            $obj = $db->fetch_object($resql);
148
+            if ($obj) $max = intval($obj->max);
149
+            else $max=0;
150
+        }
151
+        else
152
+        {
153
+            return -1;
154
+        }
155
+
156
+        $date	= dol_now();
157
+        $yymm	= strftime("%y%m",$date);
158
+
159
+        if ($max >= (pow(10, 5) - 1)) $num=$max+1;	// If counter > 99999, we do not format on 5 chars, we take number as it is
160
+        else $num = sprintf("%05s",$max+1);
161
+
162
+        dol_syslog(get_class($this)."::getNextValue return ".$prefix.$yymm."-".$num);
163
+        return $prefix.$yymm."-".$num;
164
+    }
165
+
166
+
167
+    /**
168
+     * 	Check validity of code according to its rules
169
+     *
170
+     *	@param	DoliDB		$db		Database handler
171
+     *	@param	string		$code	Code to check/correct
172
+     *	@param	Societe		$soc	Object third party
173
+     *  @param  int		  	$type   0 = customer/prospect , 1 = supplier
174
+     *  @return int					0 if OK
175
+     * 								-1 ErrorBadCustomerCodeSyntax
176
+     * 								-2 ErrorCustomerCodeRequired
177
+     * 								-3 ErrorCustomerCodeAlreadyUsed
178
+     * 								-4 ErrorPrefixRequired
179
+     */
180
+    function verif($db, &$code, $soc, $type)
181
+    {
182
+        global $conf;
183
+
184
+        $result=0;
185
+        $code = strtoupper(trim($code));
186
+
187
+        if (empty($code) && $this->code_null && empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED))
188
+        {
189
+            $result=0;
190
+        }
191
+        else if (empty($code) && (! $this->code_null || ! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) )
192
+        {
193
+            $result=-2;
194
+        }
195
+        else
196
+        {
197
+            if ($this->verif_syntax($code) >= 0)
198
+            {
199
+                $is_dispo = $this->verif_dispo($db, $code, $soc, $type);
200
+                if ($is_dispo <> 0)
201
+                {
202
+                    $result=-3;
203
+                }
204
+                else
205
+                {
206
+                    $result=0;
207
+                }
208
+            }
209
+            else
210
+            {
211
+                if (dol_strlen($code) == 0)
212
+                {
213
+                    $result=-2;
214
+                }
215
+                else
216
+                {
217
+                    $result=-1;
218
+                }
219
+            }
220
+        }
221
+
222
+        dol_syslog(get_class($this)."::verif code=".$code." type=".$type." result=".$result);
223
+        return $result;
224
+    }
225 225
 
226 226
 
227 227
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
228
-	/**
229
-	 *		Renvoi si un code est pris ou non (par autre tiers)
230
-	 *
231
-	 *		@param	DoliDB		$db			Handler acces base
232
-	 *		@param	string		$code		Code a verifier
233
-	 *		@param	Societe		$soc		Objet societe
234
-	 *		@param  int		  	$type   	0 = customer/prospect , 1 = supplier
235
-	 *		@return	int						0 if available, <0 if KO
236
-	 */
237
-	function verif_dispo($db, $code, $soc, $type=0)
238
-	{
228
+    /**
229
+     *		Renvoi si un code est pris ou non (par autre tiers)
230
+     *
231
+     *		@param	DoliDB		$db			Handler acces base
232
+     *		@param	string		$code		Code a verifier
233
+     *		@param	Societe		$soc		Objet societe
234
+     *		@param  int		  	$type   	0 = customer/prospect , 1 = supplier
235
+     *		@return	int						0 if available, <0 if KO
236
+     */
237
+    function verif_dispo($db, $code, $soc, $type=0)
238
+    {
239 239
         // phpcs:enable
240
-		global $conf, $mc;
241
-
242
-		$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe";
243
-		if ($type == 1) $sql.= " WHERE code_fournisseur = '".$code."'";
244
-		else $sql.= " WHERE code_client = '".$code."'";
245
-		$sql.= " AND entity IN (".getEntity('societe').")";
246
-		if ($soc->id > 0) $sql.= " AND rowid <> ".$soc->id;
247
-
248
-		dol_syslog(get_class($this)."::verif_dispo", LOG_DEBUG);
249
-		$resql=$db->query($sql);
250
-		if ($resql)
251
-		{
252
-			if ($db->num_rows($resql) == 0)
253
-			{
254
-				return 0;
255
-			}
256
-			else
257
-			{
258
-				return -1;
259
-			}
260
-		}
261
-		else
262
-		{
263
-			return -2;
264
-		}
265
-	}
240
+        global $conf, $mc;
241
+
242
+        $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe";
243
+        if ($type == 1) $sql.= " WHERE code_fournisseur = '".$code."'";
244
+        else $sql.= " WHERE code_client = '".$code."'";
245
+        $sql.= " AND entity IN (".getEntity('societe').")";
246
+        if ($soc->id > 0) $sql.= " AND rowid <> ".$soc->id;
247
+
248
+        dol_syslog(get_class($this)."::verif_dispo", LOG_DEBUG);
249
+        $resql=$db->query($sql);
250
+        if ($resql)
251
+        {
252
+            if ($db->num_rows($resql) == 0)
253
+            {
254
+                return 0;
255
+            }
256
+            else
257
+            {
258
+                return -1;
259
+            }
260
+        }
261
+        else
262
+        {
263
+            return -2;
264
+        }
265
+    }
266 266
 
267 267
 
268 268
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
269
-	/**
270
-	 *	Renvoi si un code respecte la syntaxe
271
-	 *
272
-	 *	@param	string		$code		Code a verifier
273
-	 *	@return	int						0 si OK, <0 si KO
274
-	 */
275
-	function verif_syntax($code)
276
-	{
269
+    /**
270
+     *	Renvoi si un code respecte la syntaxe
271
+     *
272
+     *	@param	string		$code		Code a verifier
273
+     *	@return	int						0 si OK, <0 si KO
274
+     */
275
+    function verif_syntax($code)
276
+    {
277 277
         // phpcs:enable
278
-		$res = 0;
279
-
280
-		if (dol_strlen($code) < 11)
281
-		{
282
-			$res = -1;
283
-		}
284
-		else
285
-		{
286
-			$res = 0;
287
-		}
288
-		return $res;
289
-	}
278
+        $res = 0;
279
+
280
+        if (dol_strlen($code) < 11)
281
+        {
282
+            $res = -1;
283
+        }
284
+        else
285
+        {
286
+            $res = 0;
287
+        }
288
+        return $res;
289
+    }
290 290
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/societe/mod_codecompta_panicum.php 1 patch
Indentation   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -30,76 +30,76 @@
 block discarded – undo
30 30
  */
31 31
 class mod_codecompta_panicum extends ModeleAccountancyCode
32 32
 {
33
-	/**
34
-	 * @var string Nom du modele
35
-	 * @deprecated
36
-	 * @see name
37
-	 */
38
-	public $nom='Panicum';
33
+    /**
34
+     * @var string Nom du modele
35
+     * @deprecated
36
+     * @see name
37
+     */
38
+    public $nom='Panicum';
39 39
 
40
-	/**
41
-	 * @var string model name
42
-	 */
43
-	public $name='Panicum';
40
+    /**
41
+     * @var string model name
42
+     */
43
+    public $name='Panicum';
44 44
 
45
-	/**
45
+    /**
46 46
      * Dolibarr version of the loaded document
47 47
      * @public string
48 48
      */
49
-	public $version = 'dolibarr';        // 'development', 'experimental', 'dolibarr'
49
+    public $version = 'dolibarr';        // 'development', 'experimental', 'dolibarr'
50 50
 
51 51
 
52
-	/**
53
-	 * 	Constructor
54
-	 */
55
-	function __construct()
56
-	{
57
-	}
52
+    /**
53
+     * 	Constructor
54
+     */
55
+    function __construct()
56
+    {
57
+    }
58 58
 
59 59
 
60
-	/**
61
-	 * Return description of module
62
-	 *
63
-	 * @param	Translate	$langs	Object langs
64
-	 * @return 	string      		Description of module
65
-	 */
66
-	function info($langs)
67
-	{
68
-		return $langs->trans("ModuleCompanyCode".$this->name);
69
-	}
60
+    /**
61
+     * Return description of module
62
+     *
63
+     * @param	Translate	$langs	Object langs
64
+     * @return 	string      		Description of module
65
+     */
66
+    function info($langs)
67
+    {
68
+        return $langs->trans("ModuleCompanyCode".$this->name);
69
+    }
70 70
 
71
-	/**
72
-	 *  Return an example of result returned by getNextValue
73
-	 *
74
-	 *  @param	Translate	$langs		Object langs
75
-	 *  @param	Societe		$objsoc		Object thirdparty
76
-	 *  @param	int			$type		Type of third party (1:customer, 2:supplier, -1:autodetect)
77
-	 *  @return	string					Example
78
-	 */
79
-	function getExample($langs,$objsoc=0,$type=-1)
80
-	{
81
-		return '';
82
-	}
71
+    /**
72
+     *  Return an example of result returned by getNextValue
73
+     *
74
+     *  @param	Translate	$langs		Object langs
75
+     *  @param	Societe		$objsoc		Object thirdparty
76
+     *  @param	int			$type		Type of third party (1:customer, 2:supplier, -1:autodetect)
77
+     *  @return	string					Example
78
+     */
79
+    function getExample($langs,$objsoc=0,$type=-1)
80
+    {
81
+        return '';
82
+    }
83 83
 
84 84
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
85
-	/**
86
-	 *  Set accountancy account code for a third party into this->code
87
-	 *
88
-	 *  @param	DoliDB	$db              Database handler
89
-	 *  @param  Societe	$societe         Third party object
90
-	 *  @param  int		$type			'customer' or 'supplier'
91
-	 *  @return	int						>=0 if OK, <0 if KO
92
-	 */
93
-	function get_code($db, $societe, $type='')
94
-	{
85
+    /**
86
+     *  Set accountancy account code for a third party into this->code
87
+     *
88
+     *  @param	DoliDB	$db              Database handler
89
+     *  @param  Societe	$societe         Third party object
90
+     *  @param  int		$type			'customer' or 'supplier'
91
+     *  @return	int						>=0 if OK, <0 if KO
92
+     */
93
+    function get_code($db, $societe, $type='')
94
+    {
95 95
         // phpcs:enable
96
-		$this->code='';
96
+        $this->code='';
97 97
 
98
-		if (is_object($societe)) {
99
-			if ($type == 'supplier') $this->code = (! empty($societe->code_compta_fournisseur)?$societe->code_compta_fournisseur:'');
100
-			else $this->code = (! empty($societe->code_compta)?$societe->code_compta:'');
101
-		}
98
+        if (is_object($societe)) {
99
+            if ($type == 'supplier') $this->code = (! empty($societe->code_compta_fournisseur)?$societe->code_compta_fournisseur:'');
100
+            else $this->code = (! empty($societe->code_compta)?$societe->code_compta:'');
101
+        }
102 102
 
103
-		return 0; // return ok
104
-	}
103
+        return 0; // return ok
104
+    }
105 105
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/societe/mod_codeclient_leopard.php 1 patch
Indentation   +89 added lines, -89 removed lines patch added patch discarded remove patch
@@ -31,112 +31,112 @@
 block discarded – undo
31 31
  */
32 32
 class mod_codeclient_leopard extends ModeleThirdPartyCode
33 33
 {
34
-	/*
34
+    /*
35 35
 	 * Attention ce module est utilise par defaut si aucun module n'a
36 36
 	 * ete definit dans la configuration
37 37
 	 *
38 38
 	 * Le fonctionnement de celui-ci doit donc rester le plus ouvert possible
39 39
 	 */
40 40
 
41
-	/**
42
-	 * @var string Nom du modele
43
-	 * @deprecated
44
-	 * @see name
45
-	 */
46
-	public $nom='Leopard';
41
+    /**
42
+     * @var string Nom du modele
43
+     * @deprecated
44
+     * @see name
45
+     */
46
+    public $nom='Leopard';
47 47
 
48
-	/**
49
-	 * @var string model name
50
-	 */
51
-	public $name='Leopard';
48
+    /**
49
+     * @var string model name
50
+     */
51
+    public $name='Leopard';
52 52
 
53
-	public $code_modifiable;				// Code modifiable
53
+    public $code_modifiable;				// Code modifiable
54 54
 
55
-	public $code_modifiable_invalide;		// Code modifiable si il est invalide
55
+    public $code_modifiable_invalide;		// Code modifiable si il est invalide
56 56
 
57
-	public $code_modifiable_null;			// Code modifiables si il est null
57
+    public $code_modifiable_null;			// Code modifiables si il est null
58 58
 
59
-	public $code_null;						// Code facultatif
59
+    public $code_null;						// Code facultatif
60 60
 
61
-	/**
61
+    /**
62 62
      * Dolibarr version of the loaded document
63 63
      * @public string
64 64
      */
65
-	public $version = 'dolibarr';    		// 'development', 'experimental', 'dolibarr'
66
-
67
-	public $code_auto; 	                // Numerotation automatique
68
-
65
+    public $version = 'dolibarr';    		// 'development', 'experimental', 'dolibarr'
69 66
 
70
-	/**
71
-	 *	Constructor
72
-	 */
73
-	function __construct()
74
-	{
75
-		$this->code_null = 1;
76
-		$this->code_modifiable = 1;
77
-		$this->code_modifiable_invalide = 1;
78
-		$this->code_modifiable_null = 1;
79
-		$this->code_auto = 0;
80
-	}
81
-
82
-
83
-	/**		Return description of module
84
-	 *
85
-	 * 		@param	Translate	$langs	Object langs
86
-	 * 		@return string      		Description of module
87
-	 */
88
-	function info($langs)
89
-	{
90
-		$langs->load("companies");
91
-		return $langs->trans("LeopardNumRefModelDesc");
92
-	}
67
+    public $code_auto; 	                // Numerotation automatique
93 68
 
94 69
 
95
-	/**
96
-	 * Return an example of result returned by getNextValue
97
-	 *
98
-	 * @param	societe		$objsoc		Object thirdparty
99
-	 * @param	int			$type		Type of third party (1:customer, 2:supplier, -1:autodetect)
100
-	 * @return	string					Return next value
101
-	 */
102
-	function getNextValue($objsoc=0,$type=-1)
103
-	{
104
-		global $langs;
105
-		return '';
106
-	}
107
-
108
-
109
-	/**
110
-	 * 	Check validity of code according to its rules
111
-	 *
112
-	 *	@param	DoliDB		$db		Database handler
113
-	 *	@param	string		$code	Code to check/correct
114
-	 *	@param	Societe		$soc	Object third party
115
-	 *  @param  int		  	$type   0 = customer/prospect , 1 = supplier
116
-	 *  @return int					0 if OK
117
-	 * 								-1 ErrorBadCustomerCodeSyntax
118
-	 * 								-2 ErrorCustomerCodeRequired
119
-	 * 								-3 ErrorCustomerCodeAlreadyUsed
120
-	 * 								-4 ErrorPrefixRequired
121
-	 */
122
-	function verif($db, &$code, $soc, $type)
123
-	{
124
-		global $conf;
125
-
126
-		$result=0;
127
-		$code = trim($code);
128
-
129
-		if (empty($code) && $this->code_null && empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED))
130
-		{
131
-			$result=0;
132
-		}
133
-		else if (empty($code) && (! $this->code_null || ! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) )
134
-		{
135
-			$result=-2;
136
-		}
137
-
138
-		dol_syslog(get_class($this)."::verif type=".$type." result=".$result);
139
-		return $result;
140
-	}
70
+    /**
71
+     *	Constructor
72
+     */
73
+    function __construct()
74
+    {
75
+        $this->code_null = 1;
76
+        $this->code_modifiable = 1;
77
+        $this->code_modifiable_invalide = 1;
78
+        $this->code_modifiable_null = 1;
79
+        $this->code_auto = 0;
80
+    }
81
+
82
+
83
+    /**		Return description of module
84
+     *
85
+     * 		@param	Translate	$langs	Object langs
86
+     * 		@return string      		Description of module
87
+     */
88
+    function info($langs)
89
+    {
90
+        $langs->load("companies");
91
+        return $langs->trans("LeopardNumRefModelDesc");
92
+    }
93
+
94
+
95
+    /**
96
+     * Return an example of result returned by getNextValue
97
+     *
98
+     * @param	societe		$objsoc		Object thirdparty
99
+     * @param	int			$type		Type of third party (1:customer, 2:supplier, -1:autodetect)
100
+     * @return	string					Return next value
101
+     */
102
+    function getNextValue($objsoc=0,$type=-1)
103
+    {
104
+        global $langs;
105
+        return '';
106
+    }
107
+
108
+
109
+    /**
110
+     * 	Check validity of code according to its rules
111
+     *
112
+     *	@param	DoliDB		$db		Database handler
113
+     *	@param	string		$code	Code to check/correct
114
+     *	@param	Societe		$soc	Object third party
115
+     *  @param  int		  	$type   0 = customer/prospect , 1 = supplier
116
+     *  @return int					0 if OK
117
+     * 								-1 ErrorBadCustomerCodeSyntax
118
+     * 								-2 ErrorCustomerCodeRequired
119
+     * 								-3 ErrorCustomerCodeAlreadyUsed
120
+     * 								-4 ErrorPrefixRequired
121
+     */
122
+    function verif($db, &$code, $soc, $type)
123
+    {
124
+        global $conf;
125
+
126
+        $result=0;
127
+        $code = trim($code);
128
+
129
+        if (empty($code) && $this->code_null && empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED))
130
+        {
131
+            $result=0;
132
+        }
133
+        else if (empty($code) && (! $this->code_null || ! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) )
134
+        {
135
+            $result=-2;
136
+        }
137
+
138
+        dol_syslog(get_class($this)."::verif type=".$type." result=".$result);
139
+        return $result;
140
+    }
141 141
 }
142 142
 
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/societe/mod_codecompta_aquarium.php 1 patch
Indentation   +177 added lines, -177 removed lines patch added patch discarded remove patch
@@ -31,201 +31,201 @@
 block discarded – undo
31 31
  */
32 32
 class mod_codecompta_aquarium extends ModeleAccountancyCode
33 33
 {
34
-	/**
35
-	 * @var string Nom du modele
36
-	 * @deprecated
37
-	 * @see name
38
-	 */
39
-	public $nom='Aquarium';
40
-
41
-	/**
42
-	 * @var string model name
43
-	 */
44
-	public $name='Aquarium';
45
-
46
-	/**
34
+    /**
35
+     * @var string Nom du modele
36
+     * @deprecated
37
+     * @see name
38
+     */
39
+    public $nom='Aquarium';
40
+
41
+    /**
42
+     * @var string model name
43
+     */
44
+    public $name='Aquarium';
45
+
46
+    /**
47 47
      * Dolibarr version of the loaded document
48 48
      * @public string
49 49
      */
50
-	public $version = 'dolibarr';        // 'development', 'experimental', 'dolibarr'
50
+    public $version = 'dolibarr';        // 'development', 'experimental', 'dolibarr'
51 51
 
52
-	public	$prefixcustomeraccountancycode;
52
+    public	$prefixcustomeraccountancycode;
53 53
 
54
-	public	$prefixsupplieraccountancycode;
54
+    public	$prefixsupplieraccountancycode;
55 55
 
56 56
 
57
-	/**
58
-	 * 	Constructor
59
-	 */
60
-	function __construct()
61
-	{
62
-	    global $conf;
63
-		if (! isset($conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER) || trim($conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER) == '') $conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER='411';
57
+    /**
58
+     * 	Constructor
59
+     */
60
+    function __construct()
61
+    {
62
+        global $conf;
63
+        if (! isset($conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER) || trim($conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER) == '') $conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER='411';
64 64
         if (! isset($conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER) || trim($conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER) == '') $conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER='401';
65
-		$this->prefixcustomeraccountancycode=$conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER;
66
-	    $this->prefixsupplieraccountancycode=$conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER;
67
-	}
65
+        $this->prefixcustomeraccountancycode=$conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER;
66
+        $this->prefixsupplieraccountancycode=$conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER;
67
+    }
68 68
 
69 69
 
70
-	/**
71
-	 * Return description of module
72
-	 *
73
-	 * @param	Translate	$langs		Object langs
74
-	 * @return	string   		   		Description of module
75
-	 */
76
-	function info($langs)
77
-	{
78
-	    global $conf;
79
-	    global $form;
70
+    /**
71
+     * Return description of module
72
+     *
73
+     * @param	Translate	$langs		Object langs
74
+     * @return	string   		   		Description of module
75
+     */
76
+    function info($langs)
77
+    {
78
+        global $conf;
79
+        global $form;
80 80
 
81
-		$langs->load("companies");
81
+        $langs->load("companies");
82 82
 
83 83
         $tooltip='';
84
-		$texte = '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
85
-		$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
86
-		$texte.= '<input type="hidden" name="action" value="setModuleOptions">';
87
-		$texte.= '<input type="hidden" name="param1" value="COMPANY_AQUARIUM_MASK_SUPPLIER">';
88
-		$texte.= '<input type="hidden" name="param2" value="COMPANY_AQUARIUM_MASK_CUSTOMER">';
89
-		$texte.= '<table class="nobordernopadding" width="100%">';
90
-		$s1= $form->textwithpicto('<input type="text" class="flat" size="4" name="value1" value="'.$conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER.'">',$tooltip,1,1);
91
-		$s2= $form->textwithpicto('<input type="text" class="flat" size="4" name="value2" value="'.$conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER.'">',$tooltip,1,1);
92
-		$texte.= '<tr><td>';
93
-		$texte.=$langs->trans("ModuleCompanyCodeCustomer".$this->name,$s2)."<br>\n";
94
-		$texte.=$langs->trans("ModuleCompanyCodeSupplier".$this->name,$s1)."<br>\n";
95
-		$texte.="<br>\n";
96
-		if (! isset($conf->global->COMPANY_AQUARIUM_REMOVE_SPECIAL) || ! empty($conf->global->$conf->global->COMPANY_AQUARIUM_REMOVE_SPECIAL)) $texte.=$langs->trans('COMPANY_AQUARIUM_REMOVE_SPECIAL').' = '.yn(1)."<br>\n";
97
-		//if (! empty($conf->global->COMPANY_AQUARIUM_REMOVE_ALPHA)) $texte.=$langs->trans('COMPANY_AQUARIUM_REMOVE_ALPHA').' = '.yn($conf->global->COMPANY_AQUARIUM_REMOVE_ALPHA)."<br>\n";
98
-		if (! empty($conf->global->COMPANY_AQUARIUM_CLEAN_REGEX))  $texte.=$langs->trans('COMPANY_AQUARIUM_CLEAN_REGEX').' = '.$conf->global->COMPANY_AQUARIUM_CLEAN_REGEX."<br>\n";
99
-		$texte.= '</td>';
100
-		$texte.= '<td align="left">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
84
+        $texte = '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
85
+        $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
86
+        $texte.= '<input type="hidden" name="action" value="setModuleOptions">';
87
+        $texte.= '<input type="hidden" name="param1" value="COMPANY_AQUARIUM_MASK_SUPPLIER">';
88
+        $texte.= '<input type="hidden" name="param2" value="COMPANY_AQUARIUM_MASK_CUSTOMER">';
89
+        $texte.= '<table class="nobordernopadding" width="100%">';
90
+        $s1= $form->textwithpicto('<input type="text" class="flat" size="4" name="value1" value="'.$conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER.'">',$tooltip,1,1);
91
+        $s2= $form->textwithpicto('<input type="text" class="flat" size="4" name="value2" value="'.$conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER.'">',$tooltip,1,1);
92
+        $texte.= '<tr><td>';
93
+        $texte.=$langs->trans("ModuleCompanyCodeCustomer".$this->name,$s2)."<br>\n";
94
+        $texte.=$langs->trans("ModuleCompanyCodeSupplier".$this->name,$s1)."<br>\n";
95
+        $texte.="<br>\n";
96
+        if (! isset($conf->global->COMPANY_AQUARIUM_REMOVE_SPECIAL) || ! empty($conf->global->$conf->global->COMPANY_AQUARIUM_REMOVE_SPECIAL)) $texte.=$langs->trans('COMPANY_AQUARIUM_REMOVE_SPECIAL').' = '.yn(1)."<br>\n";
97
+        //if (! empty($conf->global->COMPANY_AQUARIUM_REMOVE_ALPHA)) $texte.=$langs->trans('COMPANY_AQUARIUM_REMOVE_ALPHA').' = '.yn($conf->global->COMPANY_AQUARIUM_REMOVE_ALPHA)."<br>\n";
98
+        if (! empty($conf->global->COMPANY_AQUARIUM_CLEAN_REGEX))  $texte.=$langs->trans('COMPANY_AQUARIUM_CLEAN_REGEX').' = '.$conf->global->COMPANY_AQUARIUM_CLEAN_REGEX."<br>\n";
99
+        $texte.= '</td>';
100
+        $texte.= '<td align="left">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
101 101
         $texte.= '</tr></table>';
102 102
         $texte.= '</form>';
103 103
 
104
-		return $texte;
105
-	}
106
-
107
-	/**
108
-	 * Return an example of result returned by getNextValue
109
-	 *
110
-	 * @param	Translate	$langs		Object langs
111
-	 * @param	societe		$objsoc		Object thirdparty
112
-	 * @param	int			$type		Type of third party (1:customer, 2:supplier, -1:autodetect)
113
-	 * @return	string					Return string example
114
-	 */
115
-	function getExample($langs,$objsoc=0,$type=-1)
116
-	{
117
-		$s='';
118
-		$s.=$this->prefixcustomeraccountancycode.'CUSTCODE';
119
-	    $s.="<br>\n";
120
-	    $s.=$this->prefixsupplieraccountancycode.'SUPPCODE';
121
-	    return $s;
122
-	}
104
+        return $texte;
105
+    }
106
+
107
+    /**
108
+     * Return an example of result returned by getNextValue
109
+     *
110
+     * @param	Translate	$langs		Object langs
111
+     * @param	societe		$objsoc		Object thirdparty
112
+     * @param	int			$type		Type of third party (1:customer, 2:supplier, -1:autodetect)
113
+     * @return	string					Return string example
114
+     */
115
+    function getExample($langs,$objsoc=0,$type=-1)
116
+    {
117
+        $s='';
118
+        $s.=$this->prefixcustomeraccountancycode.'CUSTCODE';
119
+        $s.="<br>\n";
120
+        $s.=$this->prefixsupplieraccountancycode.'SUPPCODE';
121
+        return $s;
122
+    }
123 123
 
124 124
 
125 125
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
126
-	/**
127
-	 *  Set accountancy account code for a third party into this->code
128
-	 *
129
-	 *  @param	DoliDB		$db             Database handler
130
-	 *  @param  Societe		$societe        Third party object
131
-	 *  @param  string		$type			'customer' or 'supplier'
132
-	 *  @return	int							>=0 if OK, <0 if KO
133
-	 */
134
-	function get_code($db, $societe, $type='')
135
-	{
126
+    /**
127
+     *  Set accountancy account code for a third party into this->code
128
+     *
129
+     *  @param	DoliDB		$db             Database handler
130
+     *  @param  Societe		$societe        Third party object
131
+     *  @param  string		$type			'customer' or 'supplier'
132
+     *  @return	int							>=0 if OK, <0 if KO
133
+     */
134
+    function get_code($db, $societe, $type='')
135
+    {
136 136
         // phpcs:enable
137
-		global $conf;
138
-
139
-		$i = 0;
140
-		$this->db = $db;
141
-
142
-		dol_syslog("mod_codecompta_aquarium::get_code search code for type=".$type." company=".(! empty($societe->name)?$societe->name:''));
143
-
144
-		// Regle gestion compte compta
145
-		if ($type == 'customer')
146
-		{
147
-			$codetouse=(! empty($societe->code_client)?$societe->code_client:'CUSTCODE');
148
-			$prefix = $this->prefixcustomeraccountancycode;
149
-		}
150
-		else if ($type == 'supplier')
151
-		{
152
-			$codetouse=(! empty($societe->code_fournisseur)?$societe->code_fournisseur:'SUPPCODE');
153
-			$prefix = $this->prefixsupplieraccountancycode;
154
-		}
155
-		else
156
-		{
157
-			$this->error = 'Bad value for parameter type';
158
-			return -1;
159
-		}
160
-
161
-		//$conf->global->COMPANY_AQUARIUM_CLEAN_REGEX='^..(..)..';
162
-
163
-		// Remove special char if COMPANY_AQUARIUM_REMOVE_SPECIAL is set to 1 or not set (default)
164
-		if (! isset($conf->global->COMPANY_AQUARIUM_REMOVE_SPECIAL) || ! empty($conf->global->COMPANY_AQUARIUM_REMOVE_SPECIAL)) $codetouse=preg_replace('/([^a-z0-9])/i','',$codetouse);
165
-		// Remove special alpha if COMPANY_AQUARIUM_REMOVE_ALPHA is set to 1
166
-		if (! empty($conf->global->COMPANY_AQUARIUM_REMOVE_ALPHA))   $codetouse=preg_replace('/([a-z])/i','',$codetouse);
167
-		// Apply a regex replacement pattern on code if COMPANY_AQUARIUM_CLEAN_REGEX is set. Value must be a regex with parenthesis. The part into parenthesis is kept, the rest removed.
168
-		if (! empty($conf->global->COMPANY_AQUARIUM_CLEAN_REGEX))	// Example: $conf->global->COMPANY_AQUARIUM_CLEAN_REGEX='^..(..)..';
169
-		{
170
-			$codetouse=preg_replace('/'.$conf->global->COMPANY_AQUARIUM_CLEAN_REGEX.'/','\1\2\3',$codetouse);
171
-		}
172
-
173
-		$codetouse=$prefix.strtoupper($codetouse);
174
-
175
-		$is_dispo = $this->verif($db, $codetouse, $societe, $type);
176
-		if (! $is_dispo)
177
-		{
178
-			$this->code=$codetouse;
179
-		}
180
-		else
181
-		{
182
-			// Pour retour
183
-			$this->code=$codetouse;
184
-		}
185
-		dol_syslog("mod_codecompta_aquarium::get_code found code=".$this->code);
186
-		return $is_dispo;
187
-	}
188
-
189
-
190
-	/**
191
-	 *  Return if a code is available
192
-	 *
193
-	 *	@param	DoliDB		$db			Database handler
194
-	 * 	@param	string		$code		Code of third party
195
-	 * 	@param	Societe		$societe	Object third party
196
-	 * 	@param	string		$type		'supplier' or 'customer'
197
-	 *	@return	int						0 if OK but not available, >0 if OK and available, <0 if KO
198
-	 */
199
-	function verif($db, $code, $societe, $type)
200
-	{
201
-		$sql = "SELECT ";
202
-		if ($type == 'customer') $sql.= "code_compta";
203
-		else if ($type == 'supplier') $sql.= "code_compta_fournisseur";
204
-		$sql.= " FROM ".MAIN_DB_PREFIX."societe";
205
-		$sql.= " WHERE ";
206
-		if ($type == 'customer') $sql.= "code_compta";
207
-		else if ($type == 'supplier') $sql.= "code_compta_fournisseur";
208
-		$sql.= " = '".$db->escape($code)."'";
209
-		if (! empty($societe->id)) $sql.= " AND rowid <> ".$societe->id;
210
-
211
-		$resql=$db->query($sql);
212
-		if ($resql)
213
-		{
214
-			if ($db->num_rows($resql) == 0)
215
-			{
216
-				dol_syslog("mod_codecompta_aquarium::verif code '".$code."' available");
217
-				return 1;	// Dispo
218
-			}
219
-			else
220
-			{
221
-				dol_syslog("mod_codecompta_aquarium::verif code '".$code."' not available");
222
-				return 0;	// Non dispo
223
-			}
224
-		}
225
-		else
226
-		{
227
-			$this->error=$db->error()." sql=".$sql;
228
-			return -1;		// Erreur
229
-		}
230
-	}
137
+        global $conf;
138
+
139
+        $i = 0;
140
+        $this->db = $db;
141
+
142
+        dol_syslog("mod_codecompta_aquarium::get_code search code for type=".$type." company=".(! empty($societe->name)?$societe->name:''));
143
+
144
+        // Regle gestion compte compta
145
+        if ($type == 'customer')
146
+        {
147
+            $codetouse=(! empty($societe->code_client)?$societe->code_client:'CUSTCODE');
148
+            $prefix = $this->prefixcustomeraccountancycode;
149
+        }
150
+        else if ($type == 'supplier')
151
+        {
152
+            $codetouse=(! empty($societe->code_fournisseur)?$societe->code_fournisseur:'SUPPCODE');
153
+            $prefix = $this->prefixsupplieraccountancycode;
154
+        }
155
+        else
156
+        {
157
+            $this->error = 'Bad value for parameter type';
158
+            return -1;
159
+        }
160
+
161
+        //$conf->global->COMPANY_AQUARIUM_CLEAN_REGEX='^..(..)..';
162
+
163
+        // Remove special char if COMPANY_AQUARIUM_REMOVE_SPECIAL is set to 1 or not set (default)
164
+        if (! isset($conf->global->COMPANY_AQUARIUM_REMOVE_SPECIAL) || ! empty($conf->global->COMPANY_AQUARIUM_REMOVE_SPECIAL)) $codetouse=preg_replace('/([^a-z0-9])/i','',$codetouse);
165
+        // Remove special alpha if COMPANY_AQUARIUM_REMOVE_ALPHA is set to 1
166
+        if (! empty($conf->global->COMPANY_AQUARIUM_REMOVE_ALPHA))   $codetouse=preg_replace('/([a-z])/i','',$codetouse);
167
+        // Apply a regex replacement pattern on code if COMPANY_AQUARIUM_CLEAN_REGEX is set. Value must be a regex with parenthesis. The part into parenthesis is kept, the rest removed.
168
+        if (! empty($conf->global->COMPANY_AQUARIUM_CLEAN_REGEX))	// Example: $conf->global->COMPANY_AQUARIUM_CLEAN_REGEX='^..(..)..';
169
+        {
170
+            $codetouse=preg_replace('/'.$conf->global->COMPANY_AQUARIUM_CLEAN_REGEX.'/','\1\2\3',$codetouse);
171
+        }
172
+
173
+        $codetouse=$prefix.strtoupper($codetouse);
174
+
175
+        $is_dispo = $this->verif($db, $codetouse, $societe, $type);
176
+        if (! $is_dispo)
177
+        {
178
+            $this->code=$codetouse;
179
+        }
180
+        else
181
+        {
182
+            // Pour retour
183
+            $this->code=$codetouse;
184
+        }
185
+        dol_syslog("mod_codecompta_aquarium::get_code found code=".$this->code);
186
+        return $is_dispo;
187
+    }
188
+
189
+
190
+    /**
191
+     *  Return if a code is available
192
+     *
193
+     *	@param	DoliDB		$db			Database handler
194
+     * 	@param	string		$code		Code of third party
195
+     * 	@param	Societe		$societe	Object third party
196
+     * 	@param	string		$type		'supplier' or 'customer'
197
+     *	@return	int						0 if OK but not available, >0 if OK and available, <0 if KO
198
+     */
199
+    function verif($db, $code, $societe, $type)
200
+    {
201
+        $sql = "SELECT ";
202
+        if ($type == 'customer') $sql.= "code_compta";
203
+        else if ($type == 'supplier') $sql.= "code_compta_fournisseur";
204
+        $sql.= " FROM ".MAIN_DB_PREFIX."societe";
205
+        $sql.= " WHERE ";
206
+        if ($type == 'customer') $sql.= "code_compta";
207
+        else if ($type == 'supplier') $sql.= "code_compta_fournisseur";
208
+        $sql.= " = '".$db->escape($code)."'";
209
+        if (! empty($societe->id)) $sql.= " AND rowid <> ".$societe->id;
210
+
211
+        $resql=$db->query($sql);
212
+        if ($resql)
213
+        {
214
+            if ($db->num_rows($resql) == 0)
215
+            {
216
+                dol_syslog("mod_codecompta_aquarium::verif code '".$code."' available");
217
+                return 1;	// Dispo
218
+            }
219
+            else
220
+            {
221
+                dol_syslog("mod_codecompta_aquarium::verif code '".$code."' not available");
222
+                return 0;	// Non dispo
223
+            }
224
+        }
225
+        else
226
+        {
227
+            $this->error=$db->error()." sql=".$sql;
228
+            return -1;		// Erreur
229
+        }
230
+    }
231 231
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/modSupplierProposal.class.php 1 patch
Indentation   +210 added lines, -210 removed lines patch added patch discarded remove patch
@@ -37,224 +37,224 @@
 block discarded – undo
37 37
 class modSupplierProposal extends DolibarrModules
38 38
 {
39 39
 
40
-	/**
41
-	 *   Constructor. Define names, constants, directories, boxes, permissions
42
-	 *
43
-	 *   @param      DoliDB		$db      Database handler
44
-	 */
45
-	function __construct($db)
46
-	{
47
-		global $conf;
48
-
49
-		$this->db = $db;
50
-		$this->numero = 1120;
51
-
52
-		$this->family = "srm";
53
-		$this->name = preg_replace('/^mod/i','',get_class($this));
54
-		$this->description = "supplier_proposalDESC";
55
-
56
-		$this->version = 'dolibarr';
57
-
58
-		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
59
-		$this->picto='supplier_proposal';
40
+    /**
41
+     *   Constructor. Define names, constants, directories, boxes, permissions
42
+     *
43
+     *   @param      DoliDB		$db      Database handler
44
+     */
45
+    function __construct($db)
46
+    {
47
+        global $conf;
48
+
49
+        $this->db = $db;
50
+        $this->numero = 1120;
51
+
52
+        $this->family = "srm";
53
+        $this->name = preg_replace('/^mod/i','',get_class($this));
54
+        $this->description = "supplier_proposalDESC";
55
+
56
+        $this->version = 'dolibarr';
57
+
58
+        $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
59
+        $this->picto='supplier_proposal';
60 60
         
61
-		// Data directories to create when module is enabled.
62
-		$this->dirs = array();
61
+        // Data directories to create when module is enabled.
62
+        $this->dirs = array();
63 63
 		
64
-		 // Config pages. Put here list of php page names stored in admin directory used to setup module.
64
+            // Config pages. Put here list of php page names stored in admin directory used to setup module.
65 65
         $this->config_page_url = array("supplier_proposal.php");
66 66
 
67
-		// Dependencies
68
-		$this->hidden = false;			// A condition to hide module
69
-		$this->depends = array('modFournisseur');		// List of module class names as string that must be enabled if this module is enabled
70
-		$this->requiredby = array();	// List of module ids to disable if this one is disabled
71
-		$this->conflictwith = array();	// List of module class names as string this module is in conflict with
72
-		$this->phpmin = array(5,4);		// Minimum version of PHP required by module
73
-		$this->langfiles = array("supplier_proposal");
74
-
75
-		// Constants
76
-		$this->const = array();
77
-		$r=0;
78
-
79
-		$this->const[$r][0] = "SUPPLIER_PROPOSAL_ADDON_PDF";
80
-		$this->const[$r][1] = "chaine";
81
-		$this->const[$r][2] = "aurore";
82
-		$this->const[$r][3] = 'Name of submodule to generate PDF for supplier quotation request';
83
-		$this->const[$r][4] = 0;
84
-		$r++;
85
-
86
-		$this->const[$r][0] = "SUPPLIER_PROPOSAL_ADDON";
87
-		$this->const[$r][1] = "chaine";
88
-		$this->const[$r][2] = "mod_supplier_proposal_marbre";
89
-		$this->const[$r][3] = 'Name of submodule to number supplier quotation request';
90
-		$this->const[$r][4] = 0;
91
-		$r++;
92
-
93
-		$this->const[$r][0] = "SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH";
94
-		$this->const[$r][1] = "chaine";
95
-		$this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/supplier_proposal";
96
-		$this->const[$r][3] = "";
97
-		$this->const[$r][4] = 0;
98
-
99
-		// Boxes
100
-		$this->boxes = array();
101
-
102
-		// Permissions
103
-		$this->rights = array();
104
-		$this->rights_class = 'supplier_proposal';
105
-		$r=0;
106
-
107
-		$r++;
108
-		$this->rights[$r][0] = $this->numero + $r; // id de la permission
109
-		$this->rights[$r][1] = 'Read supplier proposals'; // libelle de la permission
110
-		$this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
111
-		$this->rights[$r][4] = 'lire';
112
-
113
-		$r++;
114
-		$this->rights[$r][0] = $this->numero + $r; // id de la permission
115
-		$this->rights[$r][1] = 'Create/modify supplier proposals'; // libelle de la permission
116
-		$this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
117
-		$this->rights[$r][4] = 'creer';
118
-
119
-		$r++;
120
-		$this->rights[$r][0] = $this->numero + $r; // id de la permission
121
-		$this->rights[$r][1] = 'Validate supplier proposals'; // libelle de la permission
122
-		$this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
123
-		$this->rights[$r][4] = 'validate_advance';
124
-
125
-		$r++;
126
-		$this->rights[$r][0] = $this->numero + $r; // id de la permission
127
-		$this->rights[$r][1] = 'Envoyer les demandes fournisseurs'; // libelle de la permission
128
-		$this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
67
+        // Dependencies
68
+        $this->hidden = false;			// A condition to hide module
69
+        $this->depends = array('modFournisseur');		// List of module class names as string that must be enabled if this module is enabled
70
+        $this->requiredby = array();	// List of module ids to disable if this one is disabled
71
+        $this->conflictwith = array();	// List of module class names as string this module is in conflict with
72
+        $this->phpmin = array(5,4);		// Minimum version of PHP required by module
73
+        $this->langfiles = array("supplier_proposal");
74
+
75
+        // Constants
76
+        $this->const = array();
77
+        $r=0;
78
+
79
+        $this->const[$r][0] = "SUPPLIER_PROPOSAL_ADDON_PDF";
80
+        $this->const[$r][1] = "chaine";
81
+        $this->const[$r][2] = "aurore";
82
+        $this->const[$r][3] = 'Name of submodule to generate PDF for supplier quotation request';
83
+        $this->const[$r][4] = 0;
84
+        $r++;
85
+
86
+        $this->const[$r][0] = "SUPPLIER_PROPOSAL_ADDON";
87
+        $this->const[$r][1] = "chaine";
88
+        $this->const[$r][2] = "mod_supplier_proposal_marbre";
89
+        $this->const[$r][3] = 'Name of submodule to number supplier quotation request';
90
+        $this->const[$r][4] = 0;
91
+        $r++;
92
+
93
+        $this->const[$r][0] = "SUPPLIER_PROPOSAL_ADDON_PDF_ODT_PATH";
94
+        $this->const[$r][1] = "chaine";
95
+        $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/supplier_proposal";
96
+        $this->const[$r][3] = "";
97
+        $this->const[$r][4] = 0;
98
+
99
+        // Boxes
100
+        $this->boxes = array();
101
+
102
+        // Permissions
103
+        $this->rights = array();
104
+        $this->rights_class = 'supplier_proposal';
105
+        $r=0;
106
+
107
+        $r++;
108
+        $this->rights[$r][0] = $this->numero + $r; // id de la permission
109
+        $this->rights[$r][1] = 'Read supplier proposals'; // libelle de la permission
110
+        $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
111
+        $this->rights[$r][4] = 'lire';
112
+
113
+        $r++;
114
+        $this->rights[$r][0] = $this->numero + $r; // id de la permission
115
+        $this->rights[$r][1] = 'Create/modify supplier proposals'; // libelle de la permission
116
+        $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
117
+        $this->rights[$r][4] = 'creer';
118
+
119
+        $r++;
120
+        $this->rights[$r][0] = $this->numero + $r; // id de la permission
121
+        $this->rights[$r][1] = 'Validate supplier proposals'; // libelle de la permission
122
+        $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
123
+        $this->rights[$r][4] = 'validate_advance';
124
+
125
+        $r++;
126
+        $this->rights[$r][0] = $this->numero + $r; // id de la permission
127
+        $this->rights[$r][1] = 'Envoyer les demandes fournisseurs'; // libelle de la permission
128
+        $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
129 129
         $this->rights[$r][4] = 'send_advance';
130 130
 
131
-		$r++;
132
-		$this->rights[$r][0] = $this->numero + $r; // id de la permission
133
-		$this->rights[$r][1] = 'Delete supplier proposals'; // libelle de la permission
134
-		$this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
135
-		$this->rights[$r][4] = 'supprimer';
136
-
137
-		$r++;
138
-		$this->rights[$r][0] = $this->numero + $r; // id de la permission
139
-		$this->rights[$r][1] = 'Close supplier price requests'; // libelle de la permission
140
-		$this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
141
-		$this->rights[$r][4] = 'cloturer';
142
-
143
- 		// Main menu entries
144
-		$this->menu = array();			// List of menus to add
145
-		$r=0;
146
-		$this->menu[$r]=array(
147
-			'fk_menu'=>'fk_mainmenu=commercial',		    // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
148
-			'type'=>'left',			                // This is a Left menu entry
149
-			'titre'=>'SupplierProposalsShort',
150
-			'leftmenu'=>'supplier_proposalsubmenu',
151
-			'url'=>'/supplier_proposal/index.php',
152
-			'langs'=>'supplier_proposal',	        // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
153
-			'enabled'=>'$conf->supplier_proposal->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.
154
-			'perms'=>'$user->rights->supplier_proposal->lire',	// Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
155
-			'user'=>2, // 0=Menu for internal users, 1=external users, 2=both
131
+        $r++;
132
+        $this->rights[$r][0] = $this->numero + $r; // id de la permission
133
+        $this->rights[$r][1] = 'Delete supplier proposals'; // libelle de la permission
134
+        $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
135
+        $this->rights[$r][4] = 'supprimer';
136
+
137
+        $r++;
138
+        $this->rights[$r][0] = $this->numero + $r; // id de la permission
139
+        $this->rights[$r][1] = 'Close supplier price requests'; // libelle de la permission
140
+        $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
141
+        $this->rights[$r][4] = 'cloturer';
142
+
143
+            // Main menu entries
144
+        $this->menu = array();			// List of menus to add
145
+        $r=0;
146
+        $this->menu[$r]=array(
147
+            'fk_menu'=>'fk_mainmenu=commercial',		    // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
148
+            'type'=>'left',			                // This is a Left menu entry
149
+            'titre'=>'SupplierProposalsShort',
150
+            'leftmenu'=>'supplier_proposalsubmenu',
151
+            'url'=>'/supplier_proposal/index.php',
152
+            'langs'=>'supplier_proposal',	        // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
153
+            'enabled'=>'$conf->supplier_proposal->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.
154
+            'perms'=>'$user->rights->supplier_proposal->lire',	// Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
155
+            'user'=>2, // 0=Menu for internal users, 1=external users, 2=both
156 156
             'position'=>300
157
-		);
158
-		$r++;
159
-
160
-		$this->menu[$r]=array(
161
-			'fk_menu'=>'fk_mainmenu=commercial,fk_leftmenu=supplier_proposalsubmenu',
162
-			'type'=>'left',
163
-			'titre'=>'SupplierProposalNew',
164
-			'url'=>'/supplier_proposal/card.php?action=create&amp;leftmenu=supplier_proposals',
165
-			'langs'=>'supplier_proposal',
166
-			'enabled'=>'$conf->supplier_proposal->enabled',
167
-			'perms'=>'$user->rights->supplier_proposal->creer',
168
-			'user'=>2,
157
+        );
158
+        $r++;
159
+
160
+        $this->menu[$r]=array(
161
+            'fk_menu'=>'fk_mainmenu=commercial,fk_leftmenu=supplier_proposalsubmenu',
162
+            'type'=>'left',
163
+            'titre'=>'SupplierProposalNew',
164
+            'url'=>'/supplier_proposal/card.php?action=create&amp;leftmenu=supplier_proposals',
165
+            'langs'=>'supplier_proposal',
166
+            'enabled'=>'$conf->supplier_proposal->enabled',
167
+            'perms'=>'$user->rights->supplier_proposal->creer',
168
+            'user'=>2,
169 169
             'position'=>301
170
-		);
171
-		$r++;
172
-
173
-		$this->menu[$r]=array(
174
-			'fk_menu'=>'fk_mainmenu=commercial,fk_leftmenu=supplier_proposalsubmenu',
175
-			'type'=>'left',
176
-			'titre'=>'List',
177
-			'url'=>'/supplier_proposal/list.php?leftmenu=supplier_proposals',
178
-			'langs'=>'supplier_proposal',
179
-			'enabled'=>'$conf->supplier_proposal->enabled',
180
-			'perms'=>'$user->rights->supplier_proposal->lire',
181
-			'user'=>2,
170
+        );
171
+        $r++;
172
+
173
+        $this->menu[$r]=array(
174
+            'fk_menu'=>'fk_mainmenu=commercial,fk_leftmenu=supplier_proposalsubmenu',
175
+            'type'=>'left',
176
+            'titre'=>'List',
177
+            'url'=>'/supplier_proposal/list.php?leftmenu=supplier_proposals',
178
+            'langs'=>'supplier_proposal',
179
+            'enabled'=>'$conf->supplier_proposal->enabled',
180
+            'perms'=>'$user->rights->supplier_proposal->lire',
181
+            'user'=>2,
182 182
             'position'=>302
183
-		);
184
-		$r++;
185
-
186
-		$this->menu[$r]=array(
187
-		    'fk_menu'=>'fk_mainmenu=commercial,fk_leftmenu=supplier_proposalsubmenu',
188
-		    'type'=>'left',
189
-		    'titre'=>'Statistics',
190
-		    'url'=>'/comm/propal/stats/index.php?leftmenu=supplier_proposals&amp;mode=supplier',
191
-		    'langs'=>'supplier_proposal',
192
-		    'enabled'=>'$conf->supplier_proposal->enabled',
193
-		    'perms'=>'$user->rights->supplier_proposal->lire',
194
-		    'user'=>2,
195
-		    'position'=>303
196
-		);
197
-		$r++;
198
-	}
199
-
200
-
201
-	/**
202
-	 *		Function called when module is enabled.
203
-	 *		The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
204
-	 *		It also creates data directories
205
-	 *
183
+        );
184
+        $r++;
185
+
186
+        $this->menu[$r]=array(
187
+            'fk_menu'=>'fk_mainmenu=commercial,fk_leftmenu=supplier_proposalsubmenu',
188
+            'type'=>'left',
189
+            'titre'=>'Statistics',
190
+            'url'=>'/comm/propal/stats/index.php?leftmenu=supplier_proposals&amp;mode=supplier',
191
+            'langs'=>'supplier_proposal',
192
+            'enabled'=>'$conf->supplier_proposal->enabled',
193
+            'perms'=>'$user->rights->supplier_proposal->lire',
194
+            'user'=>2,
195
+            'position'=>303
196
+        );
197
+        $r++;
198
+    }
199
+
200
+
201
+    /**
202
+     *		Function called when module is enabled.
203
+     *		The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
204
+     *		It also creates data directories
205
+     *
206 206
      *      @param      string	$options    Options when enabling module ('', 'noboxes')
207
-	 *      @return     int             	1 if OK, 0 if KO
208
-	 */
209
-	function init($options='')
210
-	{
211
-		global $conf,$langs;
212
-
213
-		// Remove permissions and default values
214
-		$this->remove($options);
215
-
216
-		//ODT template
217
-		$src=DOL_DOCUMENT_ROOT.'/install/doctemplates/supplier_proposal/template_supplier_proposal.odt';
218
-		$dirodt=DOL_DATA_ROOT.'/doctemplates/supplier_proposal';
219
-		$dest=$dirodt.'/template_supplier_proposal.odt';
220
-
221
-		if (file_exists($src) && ! file_exists($dest))
222
-		{
223
-			require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
224
-			dol_mkdir($dirodt);
225
-			$result=dol_copy($src,$dest,0,0);
226
-			if ($result < 0)
227
-			{
228
-				$langs->load("errors");
229
-				$this->error=$langs->trans('ErrorFailToCopyFile',$src,$dest);
230
-				return 0;
231
-			}
232
-		}
233
-
234
-		$sql = array(
235
-				"DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'supplier_proposal' AND entity = ".$conf->entity,
236
-				"INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','supplier_proposal',".$conf->entity.")",
237
-		);
238
-
239
-		return $this->_init($sql, $options);
240
-	}
241
-
242
-
243
-
244
-	/**
245
-	 * Function called when module is disabled.
246
-	 * Remove from database constants, boxes and permissions from Dolibarr database.
247
-	 * Data directories are not deleted
248
-	 *
249
-	 * @param      string	$options    Options when enabling module ('', 'noboxes')
250
-	 * @return     int             	1 if OK, 0 if KO
251
-	 */
252
-	public function remove($options = '')
253
-	{
254
-	    $sql = array(
255
-	        "DELETE FROM ".MAIN_DB_PREFIX."rights_def WHERE module = 'askpricesupplier'"		// To delete/clean deprecated entries
256
-	    );
257
-
258
-	    return $this->_remove($sql, $options);
259
-	}
207
+     *      @return     int             	1 if OK, 0 if KO
208
+     */
209
+    function init($options='')
210
+    {
211
+        global $conf,$langs;
212
+
213
+        // Remove permissions and default values
214
+        $this->remove($options);
215
+
216
+        //ODT template
217
+        $src=DOL_DOCUMENT_ROOT.'/install/doctemplates/supplier_proposal/template_supplier_proposal.odt';
218
+        $dirodt=DOL_DATA_ROOT.'/doctemplates/supplier_proposal';
219
+        $dest=$dirodt.'/template_supplier_proposal.odt';
220
+
221
+        if (file_exists($src) && ! file_exists($dest))
222
+        {
223
+            require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
224
+            dol_mkdir($dirodt);
225
+            $result=dol_copy($src,$dest,0,0);
226
+            if ($result < 0)
227
+            {
228
+                $langs->load("errors");
229
+                $this->error=$langs->trans('ErrorFailToCopyFile',$src,$dest);
230
+                return 0;
231
+            }
232
+        }
233
+
234
+        $sql = array(
235
+                "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'supplier_proposal' AND entity = ".$conf->entity,
236
+                "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','supplier_proposal',".$conf->entity.")",
237
+        );
238
+
239
+        return $this->_init($sql, $options);
240
+    }
241
+
242
+
243
+
244
+    /**
245
+     * Function called when module is disabled.
246
+     * Remove from database constants, boxes and permissions from Dolibarr database.
247
+     * Data directories are not deleted
248
+     *
249
+     * @param      string	$options    Options when enabling module ('', 'noboxes')
250
+     * @return     int             	1 if OK, 0 if KO
251
+     */
252
+    public function remove($options = '')
253
+    {
254
+        $sql = array(
255
+            "DELETE FROM ".MAIN_DB_PREFIX."rights_def WHERE module = 'askpricesupplier'"		// To delete/clean deprecated entries
256
+        );
257
+
258
+        return $this->_remove($sql, $options);
259
+    }
260 260
 }
261 261
\ No newline at end of file
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/modExpenseReport.class.php 1 patch
Indentation   +191 added lines, -191 removed lines patch added patch discarded remove patch
@@ -31,197 +31,197 @@
 block discarded – undo
31 31
  */
32 32
 class modExpenseReport extends DolibarrModules
33 33
 {
34
-	/**
35
-	 *   Constructor. Define names, constants, directories, boxes, permissions
36
-	 *
37
-	 *   @param		Database	$db      Database handler
38
-	 */
39
-	function __construct($db)
40
-	{
41
-		global $conf;
42
-
43
-		$this->db = $db;
44
-		$this->numero = 770;
45
-
46
-		$this->family = "hr";
47
-		$this->module_position = '40';
48
-		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
49
-		$this->name = preg_replace('/^mod/i','',get_class($this));
50
-		// Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)
51
-		$this->description = "Manage and claim expense reports (transportation, meal, ...)";
52
-		$this->version = 'dolibarr';
53
-		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
54
-		$this->picto='trip';
55
-
56
-		// Data directories to create when module is enabled.
57
-		$this->dirs = array("/expensereport/temp");
58
-		$r=0;
59
-
60
-		// Config pages. Put here list of php page names stored in admmin directory used to setup module.
61
-		$this->config_page_url = array('expensereport.php');
62
-
63
-		// Dependencies
64
-		$this->hidden = false;			// A condition to hide module
65
-		$this->depends = array();		// List of module class names as string that must be enabled if this module is enabled
66
-		// $this->conflictwith = array("modDeplacement"); // Deactivate for access on old information
67
-		$this->requiredby = array();	// List of modules id to disable if this one is disabled
68
-		$this->phpmin = array(5,4);					// Minimum version of PHP required by module
69
-		$this->need_dolibarr_version = array(3,7);	// Minimum version of Dolibarr required by module
70
-		$this->langfiles = array("companies","trips");
71
-
72
-		// Constants
73
-		$this->const = array();			// List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 0 or 'allentities')
74
-		$r=0;
75
-
76
-		$this->const[$r][0] = "EXPENSEREPORT_ADDON_PDF";
77
-		$this->const[$r][1] = "chaine";
78
-		$this->const[$r][2] = "standard";
79
-		$this->const[$r][3] = 'Name of manager to build PDF expense reports documents';
80
-		$this->const[$r][4] = 0;
81
-		$r++;
82
-
83
-		$this->const[$r][0] = "EXPENSEREPORT_ADDON";
84
-		$this->const[$r][1] = "chaine";
85
-		$this->const[$r][2] = "mod_expensereport_jade";
86
-		$this->const[$r][3] = 'Name of manager to generate expense report ref number';
87
-		$this->const[$r][4] = 0;
88
-		$r++;
89
-
90
-		$this->const[$r][0] = "MAIN_DELAY_EXPENSEREPORTS";
91
-		$this->const[$r][1] = "chaine";
92
-		$this->const[$r][2] = "15";
93
-		$this->const[$r][3] = 'Tolerance delay (in days) before alert for expense reports to approve';
94
-		$this->const[$r][4] = 0;
95
-		$r++;
96
-
97
-		$this->const[$r][0] = "MAIN_DELAY_EXPENSEREPORTS_TO_PAY";
98
-		$this->const[$r][1] = "chaine";
99
-		$this->const[$r][2] = "15";
100
-		$this->const[$r][3] = 'Tolerance delay (in days) before alert for expense reports to pay';
101
-		$this->const[$r][4] = 0;
102
-		$r++;
103
-
104
-		// Array to add new pages in new tabs
105
-		$this->tabs[] = array('data'=>'user:+expensereport:ExpenseReport:expensereport:$user->rights->expensereport->lire:/expensereport/list.php?mainmenu=hrm&id=__ID__');
106
-
107
-		// Boxes
108
-		$this->boxes = array();			// List of boxes
109
-		$r=0;
110
-
111
-		// Permissions
112
-		$this->rights = array();		// Permission array used by this module
113
-		$this->rights_class = 'expensereport';
114
-
115
-		$this->rights[$r][0] = 771;
116
-		$this->rights[$r][1] = 'Read expense reports (yours and your subordinates)';
117
-		$this->rights[$r][2] = 'r';
118
-		$this->rights[$r][3] = 0;
119
-		$this->rights[$r][4] = 'lire';
120
-		$r++;
121
-
122
-		$this->rights[$r][0] = 772;
123
-		$this->rights[$r][1] = 'Create/modify expense reports';
124
-		$this->rights[$r][2] = 'w';
125
-		$this->rights[$r][3] = 0;
126
-		$this->rights[$r][4] = 'creer';
127
-		$r++;
128
-
129
-		$this->rights[$r][0] = 773;
130
-		$this->rights[$r][1] = 'Delete expense reports';
131
-		$this->rights[$r][2] = 'd';
132
-		$this->rights[$r][3] = 0;
133
-		$this->rights[$r][4] = 'supprimer';
134
-		$r++;
135
-
136
-		$this->rights[$r][0] = 775;
137
-		$this->rights[$r][1] = 'Approve expense reports';
138
-		$this->rights[$r][2] = 'w';
139
-		$this->rights[$r][3] = 0;
140
-		$this->rights[$r][4] = 'approve';
141
-		$r++;
142
-
143
-		$this->rights[$r][0] = 776;
144
-		$this->rights[$r][1] = 'Pay expense reports';
145
-		$this->rights[$r][2] = 'w';
146
-		$this->rights[$r][3] = 0;
147
-		$this->rights[$r][4] = 'to_paid';
148
-		$r++;
149
-
150
-		$this->rights[$r][0] = 777;
151
-		$this->rights[$r][1] = 'Read expense reports of everybody';
152
-		$this->rights[$r][2] = 'r';
153
-		$this->rights[$r][3] = 1;
154
-		$this->rights[$r][4] = 'readall';
155
-		$r++;
156
-
157
-		$this->rights[$r][0] = 778;
158
-		$this->rights[$r][1] = 'Create expense reports for everybody';
159
-		$this->rights[$r][2] = 'w';
160
-		$this->rights[$r][3] = 0;
161
-		$this->rights[$r][4] = 'writeall_advance';
162
-		$r++;
163
-
164
-		$this->rights[$r][0] = 779;
165
-		$this->rights[$r][1] = 'Export expense reports';
166
-		$this->rights[$r][2] = 'r';
167
-		$this->rights[$r][3] = 0;
168
-		$this->rights[$r][4] = 'export';
169
-		$r++;
170
-
171
-		// Menus
172
-		//-------
173
-		$this->menu = 1;        // This module add menu entries. They are coded into menu manager.
174
-
175
-		// Exports
176
-		$r=0;
177
-
178
-		$r++;
179
-		$this->export_code[$r]='expensereport_'.$r;
180
-		$this->export_label[$r]='ListTripsAndExpenses';
181
-		$this->export_icon[$r]='trip';
182
-		$this->export_permission[$r]=array(array("expensereport","export"));
34
+    /**
35
+     *   Constructor. Define names, constants, directories, boxes, permissions
36
+     *
37
+     *   @param		Database	$db      Database handler
38
+     */
39
+    function __construct($db)
40
+    {
41
+        global $conf;
42
+
43
+        $this->db = $db;
44
+        $this->numero = 770;
45
+
46
+        $this->family = "hr";
47
+        $this->module_position = '40';
48
+        // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
49
+        $this->name = preg_replace('/^mod/i','',get_class($this));
50
+        // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)
51
+        $this->description = "Manage and claim expense reports (transportation, meal, ...)";
52
+        $this->version = 'dolibarr';
53
+        $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
54
+        $this->picto='trip';
55
+
56
+        // Data directories to create when module is enabled.
57
+        $this->dirs = array("/expensereport/temp");
58
+        $r=0;
59
+
60
+        // Config pages. Put here list of php page names stored in admmin directory used to setup module.
61
+        $this->config_page_url = array('expensereport.php');
62
+
63
+        // Dependencies
64
+        $this->hidden = false;			// A condition to hide module
65
+        $this->depends = array();		// List of module class names as string that must be enabled if this module is enabled
66
+        // $this->conflictwith = array("modDeplacement"); // Deactivate for access on old information
67
+        $this->requiredby = array();	// List of modules id to disable if this one is disabled
68
+        $this->phpmin = array(5,4);					// Minimum version of PHP required by module
69
+        $this->need_dolibarr_version = array(3,7);	// Minimum version of Dolibarr required by module
70
+        $this->langfiles = array("companies","trips");
71
+
72
+        // Constants
73
+        $this->const = array();			// List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 0 or 'allentities')
74
+        $r=0;
75
+
76
+        $this->const[$r][0] = "EXPENSEREPORT_ADDON_PDF";
77
+        $this->const[$r][1] = "chaine";
78
+        $this->const[$r][2] = "standard";
79
+        $this->const[$r][3] = 'Name of manager to build PDF expense reports documents';
80
+        $this->const[$r][4] = 0;
81
+        $r++;
82
+
83
+        $this->const[$r][0] = "EXPENSEREPORT_ADDON";
84
+        $this->const[$r][1] = "chaine";
85
+        $this->const[$r][2] = "mod_expensereport_jade";
86
+        $this->const[$r][3] = 'Name of manager to generate expense report ref number';
87
+        $this->const[$r][4] = 0;
88
+        $r++;
89
+
90
+        $this->const[$r][0] = "MAIN_DELAY_EXPENSEREPORTS";
91
+        $this->const[$r][1] = "chaine";
92
+        $this->const[$r][2] = "15";
93
+        $this->const[$r][3] = 'Tolerance delay (in days) before alert for expense reports to approve';
94
+        $this->const[$r][4] = 0;
95
+        $r++;
96
+
97
+        $this->const[$r][0] = "MAIN_DELAY_EXPENSEREPORTS_TO_PAY";
98
+        $this->const[$r][1] = "chaine";
99
+        $this->const[$r][2] = "15";
100
+        $this->const[$r][3] = 'Tolerance delay (in days) before alert for expense reports to pay';
101
+        $this->const[$r][4] = 0;
102
+        $r++;
103
+
104
+        // Array to add new pages in new tabs
105
+        $this->tabs[] = array('data'=>'user:+expensereport:ExpenseReport:expensereport:$user->rights->expensereport->lire:/expensereport/list.php?mainmenu=hrm&id=__ID__');
106
+
107
+        // Boxes
108
+        $this->boxes = array();			// List of boxes
109
+        $r=0;
110
+
111
+        // Permissions
112
+        $this->rights = array();		// Permission array used by this module
113
+        $this->rights_class = 'expensereport';
114
+
115
+        $this->rights[$r][0] = 771;
116
+        $this->rights[$r][1] = 'Read expense reports (yours and your subordinates)';
117
+        $this->rights[$r][2] = 'r';
118
+        $this->rights[$r][3] = 0;
119
+        $this->rights[$r][4] = 'lire';
120
+        $r++;
121
+
122
+        $this->rights[$r][0] = 772;
123
+        $this->rights[$r][1] = 'Create/modify expense reports';
124
+        $this->rights[$r][2] = 'w';
125
+        $this->rights[$r][3] = 0;
126
+        $this->rights[$r][4] = 'creer';
127
+        $r++;
128
+
129
+        $this->rights[$r][0] = 773;
130
+        $this->rights[$r][1] = 'Delete expense reports';
131
+        $this->rights[$r][2] = 'd';
132
+        $this->rights[$r][3] = 0;
133
+        $this->rights[$r][4] = 'supprimer';
134
+        $r++;
135
+
136
+        $this->rights[$r][0] = 775;
137
+        $this->rights[$r][1] = 'Approve expense reports';
138
+        $this->rights[$r][2] = 'w';
139
+        $this->rights[$r][3] = 0;
140
+        $this->rights[$r][4] = 'approve';
141
+        $r++;
142
+
143
+        $this->rights[$r][0] = 776;
144
+        $this->rights[$r][1] = 'Pay expense reports';
145
+        $this->rights[$r][2] = 'w';
146
+        $this->rights[$r][3] = 0;
147
+        $this->rights[$r][4] = 'to_paid';
148
+        $r++;
149
+
150
+        $this->rights[$r][0] = 777;
151
+        $this->rights[$r][1] = 'Read expense reports of everybody';
152
+        $this->rights[$r][2] = 'r';
153
+        $this->rights[$r][3] = 1;
154
+        $this->rights[$r][4] = 'readall';
155
+        $r++;
156
+
157
+        $this->rights[$r][0] = 778;
158
+        $this->rights[$r][1] = 'Create expense reports for everybody';
159
+        $this->rights[$r][2] = 'w';
160
+        $this->rights[$r][3] = 0;
161
+        $this->rights[$r][4] = 'writeall_advance';
162
+        $r++;
163
+
164
+        $this->rights[$r][0] = 779;
165
+        $this->rights[$r][1] = 'Export expense reports';
166
+        $this->rights[$r][2] = 'r';
167
+        $this->rights[$r][3] = 0;
168
+        $this->rights[$r][4] = 'export';
169
+        $r++;
170
+
171
+        // Menus
172
+        //-------
173
+        $this->menu = 1;        // This module add menu entries. They are coded into menu manager.
174
+
175
+        // Exports
176
+        $r=0;
177
+
178
+        $r++;
179
+        $this->export_code[$r]='expensereport_'.$r;
180
+        $this->export_label[$r]='ListTripsAndExpenses';
181
+        $this->export_icon[$r]='trip';
182
+        $this->export_permission[$r]=array(array("expensereport","export"));
183 183
         $this->export_fields_array[$r]=array(
184
-			'd.rowid'=>"TripId",'d.ref'=>'Ref','d.date_debut'=>'DateStart','d.date_fin'=>'DateEnd','d.date_create'=>'DateCreation','d.date_approve'=>'DateApprove',
185
-			'd.total_ht'=>"TotalHT",'d.total_tva'=>'TotalVAT','d.total_ttc'=>'TotalTTC','d.note_private'=>'NotePrivate','d.note_public'=>'NotePublic',
186
-			'u.lastname'=>'Lastname','u.firstname'=>'Firstname','u.login'=>"Login",'ed.rowid'=>'LineId','tf.code'=>'Type','ed.date'=>'Date','ed.tva_tx'=>'VATRate',
187
-			'ed.total_ht'=>'TotalHT','ed.total_tva'=>'TotalVAT','ed.total_ttc'=>'TotalTTC','ed.comments'=>'Comment','p.rowid'=>'ProjectId','p.ref'=>'Ref'
188
-		);
189
-		$this->export_entities_array[$r]=array(
190
-			'u.lastname'=>'user','u.firstname'=>'user','u.login'=>'user','ed.rowid'=>'expensereport_line','ed.date'=>'expensereport_line',
191
-			'ed.tva_tx'=>'expensereport_line','ed.total_ht'=>'expensereport_line','ed.total_tva'=>'expensereport_line','ed.total_ttc'=>'expensereport_line',
192
-			'ed.comments'=>'expensereport_line','tf.code'=>'expensereport_line','p.project_ref'=>'expensereport_line','p.rowid'=>'project','p.ref'=>'project'
193
-		);
184
+            'd.rowid'=>"TripId",'d.ref'=>'Ref','d.date_debut'=>'DateStart','d.date_fin'=>'DateEnd','d.date_create'=>'DateCreation','d.date_approve'=>'DateApprove',
185
+            'd.total_ht'=>"TotalHT",'d.total_tva'=>'TotalVAT','d.total_ttc'=>'TotalTTC','d.note_private'=>'NotePrivate','d.note_public'=>'NotePublic',
186
+            'u.lastname'=>'Lastname','u.firstname'=>'Firstname','u.login'=>"Login",'ed.rowid'=>'LineId','tf.code'=>'Type','ed.date'=>'Date','ed.tva_tx'=>'VATRate',
187
+            'ed.total_ht'=>'TotalHT','ed.total_tva'=>'TotalVAT','ed.total_ttc'=>'TotalTTC','ed.comments'=>'Comment','p.rowid'=>'ProjectId','p.ref'=>'Ref'
188
+        );
189
+        $this->export_entities_array[$r]=array(
190
+            'u.lastname'=>'user','u.firstname'=>'user','u.login'=>'user','ed.rowid'=>'expensereport_line','ed.date'=>'expensereport_line',
191
+            'ed.tva_tx'=>'expensereport_line','ed.total_ht'=>'expensereport_line','ed.total_tva'=>'expensereport_line','ed.total_ttc'=>'expensereport_line',
192
+            'ed.comments'=>'expensereport_line','tf.code'=>'expensereport_line','p.project_ref'=>'expensereport_line','p.rowid'=>'project','p.ref'=>'project'
193
+        );
194 194
         $this->export_alias_array[$r]=array('d.rowid'=>"idtrip",'d.type'=>"type",'d.note_private'=>'note_private','d.note_public'=>'note_public','u.lastname'=>'name','u.firstname'=>'firstname','u.login'=>'login');
195
-		$this->export_dependencies_array[$r]=array('expensereport_line'=>'ed.rowid','type_fees'=>'tf.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
196
-
197
-		$this->export_sql_start[$r]='SELECT DISTINCT ';
198
-		$this->export_sql_end[$r]  =' FROM '.MAIN_DB_PREFIX.'expensereport as d, '.MAIN_DB_PREFIX.'user as u,';
199
-		$this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'expensereport_det as ed LEFT JOIN '.MAIN_DB_PREFIX.'c_type_fees as tf ON ed.fk_c_type_fees = tf.id';
200
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet as p ON ed.fk_projet = p.rowid';
201
-		$this->export_sql_end[$r] .=' WHERE ed.fk_expensereport = d.rowid AND d.fk_user_author = u.rowid';
202
-		$this->export_sql_end[$r] .=' AND d.entity IN ('.getEntity('expensereport').')';
203
-	}
204
-
205
-	/**
206
-	 *	Function called when module is enabled.
207
-	 *	The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
208
-	 *	It also creates data directories.
209
-	 *
210
-	 *	@param		string	$options	Options
211
-	 *	@return     int             	1 if OK, 0 if KO
212
-	 */
213
-	function init($options='')
214
-	{
215
-		global $conf;
216
-
217
-		// Remove permissions and default values
218
-		$this->remove($options);
219
-
220
-		$sql = array(
221
-				"DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = 'standard' AND type='expensereport' AND entity = ".$conf->entity,
222
-				"INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('standard','expensereport',".$conf->entity.")"
223
-		);
224
-
225
-		return $this->_init($sql,$options);
226
-	}
195
+        $this->export_dependencies_array[$r]=array('expensereport_line'=>'ed.rowid','type_fees'=>'tf.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
196
+
197
+        $this->export_sql_start[$r]='SELECT DISTINCT ';
198
+        $this->export_sql_end[$r]  =' FROM '.MAIN_DB_PREFIX.'expensereport as d, '.MAIN_DB_PREFIX.'user as u,';
199
+        $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'expensereport_det as ed LEFT JOIN '.MAIN_DB_PREFIX.'c_type_fees as tf ON ed.fk_c_type_fees = tf.id';
200
+        $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet as p ON ed.fk_projet = p.rowid';
201
+        $this->export_sql_end[$r] .=' WHERE ed.fk_expensereport = d.rowid AND d.fk_user_author = u.rowid';
202
+        $this->export_sql_end[$r] .=' AND d.entity IN ('.getEntity('expensereport').')';
203
+    }
204
+
205
+    /**
206
+     *	Function called when module is enabled.
207
+     *	The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
208
+     *	It also creates data directories.
209
+     *
210
+     *	@param		string	$options	Options
211
+     *	@return     int             	1 if OK, 0 if KO
212
+     */
213
+    function init($options='')
214
+    {
215
+        global $conf;
216
+
217
+        // Remove permissions and default values
218
+        $this->remove($options);
219
+
220
+        $sql = array(
221
+                "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = 'standard' AND type='expensereport' AND entity = ".$conf->entity,
222
+                "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('standard','expensereport',".$conf->entity.")"
223
+        );
224
+
225
+        return $this->_init($sql,$options);
226
+    }
227 227
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/modPaypal.class.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -71,10 +71,10 @@
 block discarded – undo
71 71
 
72 72
         // Dependencies
73 73
         $this->hidden = false;			// A condition to hide module
74
-		$this->depends = array();		// List of module class names as string that must be enabled if this module is enabled
75
-		$this->requiredby = array('modPaypalPlus');	// List of module ids to disable if this one is disabled
76
-		$this->conflictwith = array();	// List of module class names as string this module is in conflict with
77
-		$this->phpmin = array(5,4);		// Minimum version of PHP required by module
74
+        $this->depends = array();		// List of module class names as string that must be enabled if this module is enabled
75
+        $this->requiredby = array('modPaypalPlus');	// List of module ids to disable if this one is disabled
76
+        $this->conflictwith = array();	// List of module class names as string this module is in conflict with
77
+        $this->phpmin = array(5,4);		// Minimum version of PHP required by module
78 78
         $this->need_dolibarr_version = array(3,0);		// Minimum version of Dolibarr required by module
79 79
         $this->langfiles = array("paypal");
80 80
 
Please login to merge, or discard this patch.