@@ -30,76 +30,76 @@ |
||
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 | } |
@@ -35,18 +35,18 @@ discard block |
||
35 | 35 | * @deprecated |
36 | 36 | * @see name |
37 | 37 | */ |
38 | - public $nom='Panicum'; |
|
38 | + public $nom = 'Panicum'; |
|
39 | 39 | |
40 | 40 | /** |
41 | 41 | * @var string model name |
42 | 42 | */ |
43 | - public $name='Panicum'; |
|
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 | 52 | /** |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | * @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect) |
77 | 77 | * @return string Example |
78 | 78 | */ |
79 | - function getExample($langs,$objsoc=0,$type=-1) |
|
79 | + function getExample($langs, $objsoc = 0, $type = -1) |
|
80 | 80 | { |
81 | 81 | return ''; |
82 | 82 | } |
@@ -90,14 +90,14 @@ discard block |
||
90 | 90 | * @param int $type 'customer' or 'supplier' |
91 | 91 | * @return int >=0 if OK, <0 if KO |
92 | 92 | */ |
93 | - function get_code($db, $societe, $type='') |
|
93 | + function get_code($db, $societe, $type = '') |
|
94 | 94 | { |
95 | 95 | // phpcs:enable |
96 | - $this->code=''; |
|
96 | + $this->code = ''; |
|
97 | 97 | |
98 | 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:''); |
|
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 | 101 | } |
102 | 102 | |
103 | 103 | return 0; // return ok |
@@ -96,8 +96,11 @@ |
||
96 | 96 | $this->code=''; |
97 | 97 | |
98 | 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:''); |
|
99 | + if ($type == 'supplier') { |
|
100 | + $this->code = (! empty($societe->code_compta_fournisseur)?$societe->code_compta_fournisseur:''); |
|
101 | + } else { |
|
102 | + $this->code = (! empty($societe->code_compta)?$societe->code_compta:''); |
|
103 | + } |
|
101 | 104 | } |
102 | 105 | |
103 | 106 | return 0; // return ok |
@@ -31,112 +31,112 @@ |
||
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 |
@@ -43,28 +43,28 @@ discard block |
||
43 | 43 | * @deprecated |
44 | 44 | * @see name |
45 | 45 | */ |
46 | - public $nom='Leopard'; |
|
46 | + public $nom = 'Leopard'; |
|
47 | 47 | |
48 | 48 | /** |
49 | 49 | * @var string model name |
50 | 50 | */ |
51 | - public $name='Leopard'; |
|
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' |
|
65 | + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' |
|
66 | 66 | |
67 | - public $code_auto; // Numerotation automatique |
|
67 | + public $code_auto; // Numerotation automatique |
|
68 | 68 | |
69 | 69 | |
70 | 70 | /** |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | * @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect) |
100 | 100 | * @return string Return next value |
101 | 101 | */ |
102 | - function getNextValue($objsoc=0,$type=-1) |
|
102 | + function getNextValue($objsoc = 0, $type = -1) |
|
103 | 103 | { |
104 | 104 | global $langs; |
105 | 105 | return ''; |
@@ -123,16 +123,16 @@ discard block |
||
123 | 123 | { |
124 | 124 | global $conf; |
125 | 125 | |
126 | - $result=0; |
|
126 | + $result = 0; |
|
127 | 127 | $code = trim($code); |
128 | 128 | |
129 | 129 | if (empty($code) && $this->code_null && empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) |
130 | 130 | { |
131 | - $result=0; |
|
131 | + $result = 0; |
|
132 | 132 | } |
133 | - else if (empty($code) && (! $this->code_null || ! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) ) |
|
133 | + else if (empty($code) && (!$this->code_null || !empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED))) |
|
134 | 134 | { |
135 | - $result=-2; |
|
135 | + $result = -2; |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | dol_syslog(get_class($this)."::verif type=".$type." result=".$result); |
@@ -129,8 +129,7 @@ |
||
129 | 129 | if (empty($code) && $this->code_null && empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) |
130 | 130 | { |
131 | 131 | $result=0; |
132 | - } |
|
133 | - else if (empty($code) && (! $this->code_null || ! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) ) |
|
132 | + } else if (empty($code) && (! $this->code_null || ! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) ) |
|
134 | 133 | { |
135 | 134 | $result=-2; |
136 | 135 | } |
@@ -31,201 +31,201 @@ |
||
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"> <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"> <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 | } |
@@ -36,18 +36,18 @@ discard block |
||
36 | 36 | * @deprecated |
37 | 37 | * @see name |
38 | 38 | */ |
39 | - public $nom='Aquarium'; |
|
39 | + public $nom = 'Aquarium'; |
|
40 | 40 | |
41 | 41 | /** |
42 | 42 | * @var string model name |
43 | 43 | */ |
44 | - public $name='Aquarium'; |
|
44 | + public $name = 'Aquarium'; |
|
45 | 45 | |
46 | 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 | 52 | public $prefixcustomeraccountancycode; |
53 | 53 | |
@@ -60,10 +60,10 @@ discard block |
||
60 | 60 | function __construct() |
61 | 61 | { |
62 | 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 | - 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; |
|
63 | + if (!isset($conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER) || trim($conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER) == '') $conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER = '411'; |
|
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 | 67 | } |
68 | 68 | |
69 | 69 | |
@@ -80,26 +80,26 @@ discard block |
||
80 | 80 | |
81 | 81 | $langs->load("companies"); |
82 | 82 | |
83 | - $tooltip=''; |
|
83 | + $tooltip = ''; |
|
84 | 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"; |
|
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 | 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"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>'; |
|
101 | - $texte.= '</tr></table>'; |
|
102 | - $texte.= '</form>'; |
|
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"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>'; |
|
101 | + $texte .= '</tr></table>'; |
|
102 | + $texte .= '</form>'; |
|
103 | 103 | |
104 | 104 | return $texte; |
105 | 105 | } |
@@ -112,12 +112,12 @@ discard block |
||
112 | 112 | * @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect) |
113 | 113 | * @return string Return string example |
114 | 114 | */ |
115 | - function getExample($langs,$objsoc=0,$type=-1) |
|
115 | + function getExample($langs, $objsoc = 0, $type = -1) |
|
116 | 116 | { |
117 | - $s=''; |
|
118 | - $s.=$this->prefixcustomeraccountancycode.'CUSTCODE'; |
|
119 | - $s.="<br>\n"; |
|
120 | - $s.=$this->prefixsupplieraccountancycode.'SUPPCODE'; |
|
117 | + $s = ''; |
|
118 | + $s .= $this->prefixcustomeraccountancycode.'CUSTCODE'; |
|
119 | + $s .= "<br>\n"; |
|
120 | + $s .= $this->prefixsupplieraccountancycode.'SUPPCODE'; |
|
121 | 121 | return $s; |
122 | 122 | } |
123 | 123 | |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | * @param string $type 'customer' or 'supplier' |
132 | 132 | * @return int >=0 if OK, <0 if KO |
133 | 133 | */ |
134 | - function get_code($db, $societe, $type='') |
|
134 | + function get_code($db, $societe, $type = '') |
|
135 | 135 | { |
136 | 136 | // phpcs:enable |
137 | 137 | global $conf; |
@@ -139,17 +139,17 @@ discard block |
||
139 | 139 | $i = 0; |
140 | 140 | $this->db = $db; |
141 | 141 | |
142 | - dol_syslog("mod_codecompta_aquarium::get_code search code for type=".$type." company=".(! empty($societe->name)?$societe->name:'')); |
|
142 | + dol_syslog("mod_codecompta_aquarium::get_code search code for type=".$type." company=".(!empty($societe->name) ? $societe->name : '')); |
|
143 | 143 | |
144 | 144 | // Regle gestion compte compta |
145 | 145 | if ($type == 'customer') |
146 | 146 | { |
147 | - $codetouse=(! empty($societe->code_client)?$societe->code_client:'CUSTCODE'); |
|
147 | + $codetouse = (!empty($societe->code_client) ? $societe->code_client : 'CUSTCODE'); |
|
148 | 148 | $prefix = $this->prefixcustomeraccountancycode; |
149 | 149 | } |
150 | 150 | else if ($type == 'supplier') |
151 | 151 | { |
152 | - $codetouse=(! empty($societe->code_fournisseur)?$societe->code_fournisseur:'SUPPCODE'); |
|
152 | + $codetouse = (!empty($societe->code_fournisseur) ? $societe->code_fournisseur : 'SUPPCODE'); |
|
153 | 153 | $prefix = $this->prefixsupplieraccountancycode; |
154 | 154 | } |
155 | 155 | else |
@@ -161,26 +161,26 @@ discard block |
||
161 | 161 | //$conf->global->COMPANY_AQUARIUM_CLEAN_REGEX='^..(..)..'; |
162 | 162 | |
163 | 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); |
|
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 | 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); |
|
166 | + if (!empty($conf->global->COMPANY_AQUARIUM_REMOVE_ALPHA)) $codetouse = preg_replace('/([a-z])/i', '', $codetouse); |
|
167 | 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='^..(..)..'; |
|
168 | + if (!empty($conf->global->COMPANY_AQUARIUM_CLEAN_REGEX)) // Example: $conf->global->COMPANY_AQUARIUM_CLEAN_REGEX='^..(..)..'; |
|
169 | 169 | { |
170 | - $codetouse=preg_replace('/'.$conf->global->COMPANY_AQUARIUM_CLEAN_REGEX.'/','\1\2\3',$codetouse); |
|
170 | + $codetouse = preg_replace('/'.$conf->global->COMPANY_AQUARIUM_CLEAN_REGEX.'/', '\1\2\3', $codetouse); |
|
171 | 171 | } |
172 | 172 | |
173 | - $codetouse=$prefix.strtoupper($codetouse); |
|
173 | + $codetouse = $prefix.strtoupper($codetouse); |
|
174 | 174 | |
175 | 175 | $is_dispo = $this->verif($db, $codetouse, $societe, $type); |
176 | - if (! $is_dispo) |
|
176 | + if (!$is_dispo) |
|
177 | 177 | { |
178 | - $this->code=$codetouse; |
|
178 | + $this->code = $codetouse; |
|
179 | 179 | } |
180 | 180 | else |
181 | 181 | { |
182 | 182 | // Pour retour |
183 | - $this->code=$codetouse; |
|
183 | + $this->code = $codetouse; |
|
184 | 184 | } |
185 | 185 | dol_syslog("mod_codecompta_aquarium::get_code found code=".$this->code); |
186 | 186 | return $is_dispo; |
@@ -199,33 +199,33 @@ discard block |
||
199 | 199 | function verif($db, $code, $societe, $type) |
200 | 200 | { |
201 | 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); |
|
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 | 212 | if ($resql) |
213 | 213 | { |
214 | 214 | if ($db->num_rows($resql) == 0) |
215 | 215 | { |
216 | 216 | dol_syslog("mod_codecompta_aquarium::verif code '".$code."' available"); |
217 | - return 1; // Dispo |
|
217 | + return 1; // Dispo |
|
218 | 218 | } |
219 | 219 | else |
220 | 220 | { |
221 | 221 | dol_syslog("mod_codecompta_aquarium::verif code '".$code."' not available"); |
222 | - return 0; // Non dispo |
|
222 | + return 0; // Non dispo |
|
223 | 223 | } |
224 | 224 | } |
225 | 225 | else |
226 | 226 | { |
227 | - $this->error=$db->error()." sql=".$sql; |
|
228 | - return -1; // Erreur |
|
227 | + $this->error = $db->error()." sql=".$sql; |
|
228 | + return -1; // Erreur |
|
229 | 229 | } |
230 | 230 | } |
231 | 231 | } |
@@ -60,8 +60,12 @@ discard block |
||
60 | 60 | function __construct() |
61 | 61 | { |
62 | 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 | - if (! isset($conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER) || trim($conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER) == '') $conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER='401'; |
|
63 | + if (! isset($conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER) || trim($conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER) == '') { |
|
64 | + $conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER='411'; |
|
65 | + } |
|
66 | + if (! isset($conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER) || trim($conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER) == '') { |
|
67 | + $conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER='401'; |
|
68 | + } |
|
65 | 69 | $this->prefixcustomeraccountancycode=$conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER; |
66 | 70 | $this->prefixsupplieraccountancycode=$conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER; |
67 | 71 | } |
@@ -93,9 +97,13 @@ discard block |
||
93 | 97 | $texte.=$langs->trans("ModuleCompanyCodeCustomer".$this->name,$s2)."<br>\n"; |
94 | 98 | $texte.=$langs->trans("ModuleCompanyCodeSupplier".$this->name,$s1)."<br>\n"; |
95 | 99 | $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"; |
|
100 | + if (! isset($conf->global->COMPANY_AQUARIUM_REMOVE_SPECIAL) || ! empty($conf->global->$conf->global->COMPANY_AQUARIUM_REMOVE_SPECIAL)) { |
|
101 | + $texte.=$langs->trans('COMPANY_AQUARIUM_REMOVE_SPECIAL').' = '.yn(1)."<br>\n"; |
|
102 | + } |
|
97 | 103 | //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"; |
|
104 | + if (! empty($conf->global->COMPANY_AQUARIUM_CLEAN_REGEX)) { |
|
105 | + $texte.=$langs->trans('COMPANY_AQUARIUM_CLEAN_REGEX').' = '.$conf->global->COMPANY_AQUARIUM_CLEAN_REGEX."<br>\n"; |
|
106 | + } |
|
99 | 107 | $texte.= '</td>'; |
100 | 108 | $texte.= '<td align="left"> <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>'; |
101 | 109 | $texte.= '</tr></table>'; |
@@ -146,13 +154,11 @@ discard block |
||
146 | 154 | { |
147 | 155 | $codetouse=(! empty($societe->code_client)?$societe->code_client:'CUSTCODE'); |
148 | 156 | $prefix = $this->prefixcustomeraccountancycode; |
149 | - } |
|
150 | - else if ($type == 'supplier') |
|
157 | + } else if ($type == 'supplier') |
|
151 | 158 | { |
152 | 159 | $codetouse=(! empty($societe->code_fournisseur)?$societe->code_fournisseur:'SUPPCODE'); |
153 | 160 | $prefix = $this->prefixsupplieraccountancycode; |
154 | - } |
|
155 | - else |
|
161 | + } else |
|
156 | 162 | { |
157 | 163 | $this->error = 'Bad value for parameter type'; |
158 | 164 | return -1; |
@@ -161,14 +167,20 @@ discard block |
||
161 | 167 | //$conf->global->COMPANY_AQUARIUM_CLEAN_REGEX='^..(..)..'; |
162 | 168 | |
163 | 169 | // 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); |
|
170 | + if (! isset($conf->global->COMPANY_AQUARIUM_REMOVE_SPECIAL) || ! empty($conf->global->COMPANY_AQUARIUM_REMOVE_SPECIAL)) { |
|
171 | + $codetouse=preg_replace('/([^a-z0-9])/i','',$codetouse); |
|
172 | + } |
|
165 | 173 | // 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); |
|
174 | + if (! empty($conf->global->COMPANY_AQUARIUM_REMOVE_ALPHA)) { |
|
175 | + $codetouse=preg_replace('/([a-z])/i','',$codetouse); |
|
176 | + } |
|
167 | 177 | // 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='^..(..)..'; |
|
178 | + if (! empty($conf->global->COMPANY_AQUARIUM_CLEAN_REGEX)) { |
|
179 | + // Example: $conf->global->COMPANY_AQUARIUM_CLEAN_REGEX='^..(..)..'; |
|
169 | 180 | { |
170 | 181 | $codetouse=preg_replace('/'.$conf->global->COMPANY_AQUARIUM_CLEAN_REGEX.'/','\1\2\3',$codetouse); |
171 | 182 | } |
183 | + } |
|
172 | 184 | |
173 | 185 | $codetouse=$prefix.strtoupper($codetouse); |
174 | 186 | |
@@ -176,8 +188,7 @@ discard block |
||
176 | 188 | if (! $is_dispo) |
177 | 189 | { |
178 | 190 | $this->code=$codetouse; |
179 | - } |
|
180 | - else |
|
191 | + } else |
|
181 | 192 | { |
182 | 193 | // Pour retour |
183 | 194 | $this->code=$codetouse; |
@@ -199,14 +210,22 @@ discard block |
||
199 | 210 | function verif($db, $code, $societe, $type) |
200 | 211 | { |
201 | 212 | $sql = "SELECT "; |
202 | - if ($type == 'customer') $sql.= "code_compta"; |
|
203 | - else if ($type == 'supplier') $sql.= "code_compta_fournisseur"; |
|
213 | + if ($type == 'customer') { |
|
214 | + $sql.= "code_compta"; |
|
215 | + } else if ($type == 'supplier') { |
|
216 | + $sql.= "code_compta_fournisseur"; |
|
217 | + } |
|
204 | 218 | $sql.= " FROM ".MAIN_DB_PREFIX."societe"; |
205 | 219 | $sql.= " WHERE "; |
206 | - if ($type == 'customer') $sql.= "code_compta"; |
|
207 | - else if ($type == 'supplier') $sql.= "code_compta_fournisseur"; |
|
220 | + if ($type == 'customer') { |
|
221 | + $sql.= "code_compta"; |
|
222 | + } else if ($type == 'supplier') { |
|
223 | + $sql.= "code_compta_fournisseur"; |
|
224 | + } |
|
208 | 225 | $sql.= " = '".$db->escape($code)."'"; |
209 | - if (! empty($societe->id)) $sql.= " AND rowid <> ".$societe->id; |
|
226 | + if (! empty($societe->id)) { |
|
227 | + $sql.= " AND rowid <> ".$societe->id; |
|
228 | + } |
|
210 | 229 | |
211 | 230 | $resql=$db->query($sql); |
212 | 231 | if ($resql) |
@@ -215,14 +234,12 @@ discard block |
||
215 | 234 | { |
216 | 235 | dol_syslog("mod_codecompta_aquarium::verif code '".$code."' available"); |
217 | 236 | return 1; // Dispo |
218 | - } |
|
219 | - else |
|
237 | + } else |
|
220 | 238 | { |
221 | 239 | dol_syslog("mod_codecompta_aquarium::verif code '".$code."' not available"); |
222 | 240 | return 0; // Non dispo |
223 | 241 | } |
224 | - } |
|
225 | - else |
|
242 | + } else |
|
226 | 243 | { |
227 | 244 | $this->error=$db->error()." sql=".$sql; |
228 | 245 | return -1; // Erreur |
@@ -37,224 +37,224 @@ |
||
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&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&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&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&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 |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | * \ingroup supplier_proposal |
29 | 29 | * \brief File to describe and activate module SupplierProposal |
30 | 30 | */ |
31 | -include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; |
|
31 | +include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php'; |
|
32 | 32 | |
33 | 33 | |
34 | 34 | /** |
@@ -50,13 +50,13 @@ discard block |
||
50 | 50 | $this->numero = 1120; |
51 | 51 | |
52 | 52 | $this->family = "srm"; |
53 | - $this->name = preg_replace('/^mod/i','',get_class($this)); |
|
53 | + $this->name = preg_replace('/^mod/i', '', get_class($this)); |
|
54 | 54 | $this->description = "supplier_proposalDESC"; |
55 | 55 | |
56 | 56 | $this->version = 'dolibarr'; |
57 | 57 | |
58 | 58 | $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); |
59 | - $this->picto='supplier_proposal'; |
|
59 | + $this->picto = 'supplier_proposal'; |
|
60 | 60 | |
61 | 61 | // Data directories to create when module is enabled. |
62 | 62 | $this->dirs = array(); |
@@ -65,16 +65,16 @@ discard block |
||
65 | 65 | $this->config_page_url = array("supplier_proposal.php"); |
66 | 66 | |
67 | 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 |
|
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 | 73 | $this->langfiles = array("supplier_proposal"); |
74 | 74 | |
75 | 75 | // Constants |
76 | 76 | $this->const = array(); |
77 | - $r=0; |
|
77 | + $r = 0; |
|
78 | 78 | |
79 | 79 | $this->const[$r][0] = "SUPPLIER_PROPOSAL_ADDON_PDF"; |
80 | 80 | $this->const[$r][1] = "chaine"; |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | // Permissions |
103 | 103 | $this->rights = array(); |
104 | 104 | $this->rights_class = 'supplier_proposal'; |
105 | - $r=0; |
|
105 | + $r = 0; |
|
106 | 106 | |
107 | 107 | $r++; |
108 | 108 | $this->rights[$r][0] = $this->numero + $r; // id de la permission |
@@ -141,23 +141,23 @@ discard block |
||
141 | 141 | $this->rights[$r][4] = 'cloturer'; |
142 | 142 | |
143 | 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 |
|
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 | 149 | 'titre'=>'SupplierProposalsShort', |
150 | 150 | 'leftmenu'=>'supplier_proposalsubmenu', |
151 | 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 |
|
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 | 155 | 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both |
156 | 156 | 'position'=>300 |
157 | 157 | ); |
158 | 158 | $r++; |
159 | 159 | |
160 | - $this->menu[$r]=array( |
|
160 | + $this->menu[$r] = array( |
|
161 | 161 | 'fk_menu'=>'fk_mainmenu=commercial,fk_leftmenu=supplier_proposalsubmenu', |
162 | 162 | 'type'=>'left', |
163 | 163 | 'titre'=>'SupplierProposalNew', |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | ); |
171 | 171 | $r++; |
172 | 172 | |
173 | - $this->menu[$r]=array( |
|
173 | + $this->menu[$r] = array( |
|
174 | 174 | 'fk_menu'=>'fk_mainmenu=commercial,fk_leftmenu=supplier_proposalsubmenu', |
175 | 175 | 'type'=>'left', |
176 | 176 | 'titre'=>'List', |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | ); |
184 | 184 | $r++; |
185 | 185 | |
186 | - $this->menu[$r]=array( |
|
186 | + $this->menu[$r] = array( |
|
187 | 187 | 'fk_menu'=>'fk_mainmenu=commercial,fk_leftmenu=supplier_proposalsubmenu', |
188 | 188 | 'type'=>'left', |
189 | 189 | 'titre'=>'Statistics', |
@@ -206,27 +206,27 @@ discard block |
||
206 | 206 | * @param string $options Options when enabling module ('', 'noboxes') |
207 | 207 | * @return int 1 if OK, 0 if KO |
208 | 208 | */ |
209 | - function init($options='') |
|
209 | + function init($options = '') |
|
210 | 210 | { |
211 | - global $conf,$langs; |
|
211 | + global $conf, $langs; |
|
212 | 212 | |
213 | 213 | // Remove permissions and default values |
214 | 214 | $this->remove($options); |
215 | 215 | |
216 | 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'; |
|
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 | 220 | |
221 | - if (file_exists($src) && ! file_exists($dest)) |
|
221 | + if (file_exists($src) && !file_exists($dest)) |
|
222 | 222 | { |
223 | 223 | require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; |
224 | 224 | dol_mkdir($dirodt); |
225 | - $result=dol_copy($src,$dest,0,0); |
|
225 | + $result = dol_copy($src, $dest, 0, 0); |
|
226 | 226 | if ($result < 0) |
227 | 227 | { |
228 | 228 | $langs->load("errors"); |
229 | - $this->error=$langs->trans('ErrorFailToCopyFile',$src,$dest); |
|
229 | + $this->error = $langs->trans('ErrorFailToCopyFile', $src, $dest); |
|
230 | 230 | return 0; |
231 | 231 | } |
232 | 232 | } |
@@ -31,197 +31,197 @@ |
||
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 | } |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * \ingroup expensereport |
24 | 24 | * \brief Description and activation file for module ExpenseReport |
25 | 25 | */ |
26 | -include_once DOL_DOCUMENT_ROOT ."/core/modules/DolibarrModules.class.php"; |
|
26 | +include_once DOL_DOCUMENT_ROOT."/core/modules/DolibarrModules.class.php"; |
|
27 | 27 | |
28 | 28 | |
29 | 29 | /** |
@@ -46,32 +46,32 @@ discard block |
||
46 | 46 | $this->family = "hr"; |
47 | 47 | $this->module_position = '40'; |
48 | 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)); |
|
49 | + $this->name = preg_replace('/^mod/i', '', get_class($this)); |
|
50 | 50 | // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module) |
51 | 51 | $this->description = "Manage and claim expense reports (transportation, meal, ...)"; |
52 | 52 | $this->version = 'dolibarr'; |
53 | 53 | $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); |
54 | - $this->picto='trip'; |
|
54 | + $this->picto = 'trip'; |
|
55 | 55 | |
56 | 56 | // Data directories to create when module is enabled. |
57 | 57 | $this->dirs = array("/expensereport/temp"); |
58 | - $r=0; |
|
58 | + $r = 0; |
|
59 | 59 | |
60 | 60 | // Config pages. Put here list of php page names stored in admmin directory used to setup module. |
61 | 61 | $this->config_page_url = array('expensereport.php'); |
62 | 62 | |
63 | 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 |
|
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 | 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"); |
|
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 | 71 | |
72 | 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; |
|
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 | 75 | |
76 | 76 | $this->const[$r][0] = "EXPENSEREPORT_ADDON_PDF"; |
77 | 77 | $this->const[$r][1] = "chaine"; |
@@ -105,11 +105,11 @@ discard block |
||
105 | 105 | $this->tabs[] = array('data'=>'user:+expensereport:ExpenseReport:expensereport:$user->rights->expensereport->lire:/expensereport/list.php?mainmenu=hrm&id=__ID__'); |
106 | 106 | |
107 | 107 | // Boxes |
108 | - $this->boxes = array(); // List of boxes |
|
109 | - $r=0; |
|
108 | + $this->boxes = array(); // List of boxes |
|
109 | + $r = 0; |
|
110 | 110 | |
111 | 111 | // Permissions |
112 | - $this->rights = array(); // Permission array used by this module |
|
112 | + $this->rights = array(); // Permission array used by this module |
|
113 | 113 | $this->rights_class = 'expensereport'; |
114 | 114 | |
115 | 115 | $this->rights[$r][0] = 771; |
@@ -170,36 +170,36 @@ discard block |
||
170 | 170 | |
171 | 171 | // Menus |
172 | 172 | //------- |
173 | - $this->menu = 1; // This module add menu entries. They are coded into menu manager. |
|
173 | + $this->menu = 1; // This module add menu entries. They are coded into menu manager. |
|
174 | 174 | |
175 | 175 | // Exports |
176 | - $r=0; |
|
176 | + $r = 0; |
|
177 | 177 | |
178 | 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 | - $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' |
|
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 | + $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 | 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' |
|
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 | 193 | ); |
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').')'; |
|
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 | 203 | } |
204 | 204 | |
205 | 205 | /** |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | * @param string $options Options |
211 | 211 | * @return int 1 if OK, 0 if KO |
212 | 212 | */ |
213 | - function init($options='') |
|
213 | + function init($options = '') |
|
214 | 214 | { |
215 | 215 | global $conf; |
216 | 216 | |
@@ -222,6 +222,6 @@ discard block |
||
222 | 222 | "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('standard','expensereport',".$conf->entity.")" |
223 | 223 | ); |
224 | 224 | |
225 | - return $this->_init($sql,$options); |
|
225 | + return $this->_init($sql, $options); |
|
226 | 226 | } |
227 | 227 | } |
@@ -71,10 +71,10 @@ |
||
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 |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * \ingroup paypal |
25 | 25 | * \brief Description and activation file for module Paypal |
26 | 26 | */ |
27 | -include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; |
|
27 | +include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php'; |
|
28 | 28 | |
29 | 29 | |
30 | 30 | /** |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | // It is used to group modules in module setup page |
52 | 52 | $this->family = "interface"; |
53 | 53 | // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) |
54 | - $this->name = preg_replace('/^mod/i','',get_class($this)); |
|
54 | + $this->name = preg_replace('/^mod/i', '', get_class($this)); |
|
55 | 55 | // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module) |
56 | 56 | $this->description = "Module to offer an online payment page with PayPal"; |
57 | 57 | // Possible values for version are: 'development', 'experimental', 'dolibarr' or version |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | // Name of image file used for this module. |
62 | 62 | // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' |
63 | 63 | // If file is in module/img directory, use this->picto=DOL_URL_ROOT.'/module/img/file.png' |
64 | - $this->picto='paypal@paypal'; |
|
64 | + $this->picto = 'paypal@paypal'; |
|
65 | 65 | |
66 | 66 | // Data directories to create when module is enabled. |
67 | 67 | $this->dirs = array('/paypal/temp'); |
@@ -70,16 +70,16 @@ discard block |
||
70 | 70 | $this->config_page_url = array("paypal.php@paypal"); |
71 | 71 | |
72 | 72 | // Dependencies |
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 |
|
78 | - $this->need_dolibarr_version = array(3,0); // Minimum version of Dolibarr required by module |
|
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 |
|
78 | + $this->need_dolibarr_version = array(3, 0); // Minimum version of Dolibarr required by module |
|
79 | 79 | $this->langfiles = array("paypal"); |
80 | 80 | |
81 | 81 | // Constants |
82 | - $this->const = array(); // List of particular constants to add when module is enabled |
|
82 | + $this->const = array(); // List of particular constants to add when module is enabled |
|
83 | 83 | //Example: $this->const=array(0=>array('MODULE_MY_NEW_CONST1','chaine','myvalue','This is a constant to add',0), |
84 | 84 | // 1=>array('MODULE_MY_NEW_CONST2','chaine','myvalue','This is another constant to add',0) ); |
85 | 85 | |
@@ -88,8 +88,8 @@ discard block |
||
88 | 88 | |
89 | 89 | |
90 | 90 | // Boxes |
91 | - $this->boxes = array(); // List of boxes |
|
92 | - $r=0; |
|
91 | + $this->boxes = array(); // List of boxes |
|
92 | + $r = 0; |
|
93 | 93 | |
94 | 94 | // Add here list of php file(s) stored in core/boxes that contains class to show a box. |
95 | 95 | // Example: |
@@ -100,13 +100,13 @@ discard block |
||
100 | 100 | |
101 | 101 | |
102 | 102 | // Permissions |
103 | - $this->rights = array(); // Permission array used by this module |
|
104 | - $r=0; |
|
103 | + $this->rights = array(); // Permission array used by this module |
|
104 | + $r = 0; |
|
105 | 105 | |
106 | 106 | |
107 | 107 | // Main menu entries |
108 | - $this->menus = array(); // List of menus to add |
|
109 | - $r=0; |
|
108 | + $this->menus = array(); // List of menus to add |
|
109 | + $r = 0; |
|
110 | 110 | /*$this->menu[$r]=array( |
111 | 111 | 'fk_menu'=>'fk_mainmenu=billing,fk_leftmenu=customers_bills_payment', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode |
112 | 112 | 'mainmenu'=>'billing', |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | |
166 | 166 | |
167 | 167 | // Exports |
168 | - $r=1; |
|
168 | + $r = 1; |
|
169 | 169 | |
170 | 170 | // Example: |
171 | 171 | // $this->export_code[$r]=$this->rights_class.'_'.$r; |
@@ -31,9 +31,9 @@ discard block |
||
31 | 31 | abstract class ModeleGenPassword |
32 | 32 | { |
33 | 33 | /** |
34 | - * @var string Error code (or message) |
|
35 | - */ |
|
36 | - public $error=''; |
|
34 | + * @var string Error code (or message) |
|
35 | + */ |
|
36 | + public $error=''; |
|
37 | 37 | |
38 | 38 | /** |
39 | 39 | * Return if a module can be used or not |
@@ -68,23 +68,23 @@ discard block |
||
68 | 68 | return $langs->trans("NoExample"); |
69 | 69 | } |
70 | 70 | |
71 | - /** |
|
72 | - * Build new password |
|
73 | - * |
|
74 | - * @return string Return a new generated password |
|
75 | - */ |
|
71 | + /** |
|
72 | + * Build new password |
|
73 | + * |
|
74 | + * @return string Return a new generated password |
|
75 | + */ |
|
76 | 76 | function getNewGeneratedPassword() |
77 | 77 | { |
78 | 78 | global $langs; |
79 | 79 | return $langs->trans("NotAvailable"); |
80 | 80 | } |
81 | 81 | |
82 | - /** |
|
83 | - * Validate a password |
|
84 | - * |
|
85 | - * @param string $password Password to check |
|
86 | - * @return int 0 if KO, >0 if OK |
|
87 | - */ |
|
82 | + /** |
|
83 | + * Validate a password |
|
84 | + * |
|
85 | + * @param string $password Password to check |
|
86 | + * @return int 0 if KO, >0 if OK |
|
87 | + */ |
|
88 | 88 | function validatePassword($password) |
89 | 89 | { |
90 | 90 | return 1; |
@@ -33,7 +33,7 @@ |
||
33 | 33 | /** |
34 | 34 | * @var string Error code (or message) |
35 | 35 | */ |
36 | - public $error=''; |
|
36 | + public $error = ''; |
|
37 | 37 | |
38 | 38 | /** |
39 | 39 | * Return if a module can be used or not |
@@ -31,108 +31,108 @@ |
||
31 | 31 | */ |
32 | 32 | class modGeneratePassStandard extends ModeleGenPassword |
33 | 33 | { |
34 | - /** |
|
35 | - * @var int ID |
|
36 | - */ |
|
37 | - public $id; |
|
34 | + /** |
|
35 | + * @var int ID |
|
36 | + */ |
|
37 | + public $id; |
|
38 | 38 | |
39 | - public $length; |
|
39 | + public $length; |
|
40 | 40 | |
41 | - /** |
|
41 | + /** |
|
42 | 42 | * @var DoliDB Database handler. |
43 | 43 | */ |
44 | 44 | public $db; |
45 | 45 | |
46 | - public $conf; |
|
47 | - public $lang; |
|
48 | - public $user; |
|
49 | - |
|
50 | - |
|
51 | - /** |
|
52 | - * Constructor |
|
53 | - * |
|
54 | - * @param DoliDB $db Database handler |
|
55 | - * @param Conf $conf Handler de conf |
|
56 | - * @param Translate $langs Handler de langue |
|
57 | - * @param User $user Handler du user connecte |
|
58 | - */ |
|
59 | - function __construct($db, $conf, $langs, $user) |
|
60 | - { |
|
61 | - $this->id = "standard"; |
|
62 | - $this->length = 8; |
|
63 | - |
|
64 | - $this->db=$db; |
|
65 | - $this->conf=$conf; |
|
66 | - $this->langs=$langs; |
|
67 | - $this->user=$user; |
|
68 | - } |
|
69 | - |
|
70 | - /** |
|
71 | - * Return description of module |
|
72 | - * |
|
73 | - * @return string Description of module |
|
74 | - */ |
|
75 | - function getDescription() |
|
76 | - { |
|
77 | - global $langs; |
|
78 | - return $langs->trans("PasswordGenerationStandard"); |
|
79 | - } |
|
80 | - |
|
81 | - /** |
|
82 | - * Return an example of password generated by this module |
|
83 | - * |
|
84 | - * @return string Example of password |
|
85 | - */ |
|
86 | - function getExample() |
|
87 | - { |
|
88 | - return $this->getNewGeneratedPassword(); |
|
89 | - } |
|
90 | - |
|
91 | - /** |
|
92 | - * Build new password |
|
93 | - * |
|
94 | - * @return string Return a new generated password |
|
95 | - */ |
|
96 | - function getNewGeneratedPassword() |
|
97 | - { |
|
98 | - // start with a blank password |
|
99 | - $password = ""; |
|
100 | - |
|
101 | - // define possible characters |
|
102 | - $possible = "0123456789bcdfghjkmnpqrstvwxyz"; |
|
103 | - |
|
104 | - // set up a counter |
|
105 | - $i = 0; |
|
106 | - |
|
107 | - // add random characters to $password until $length is reached |
|
108 | - while ($i < $this->length) |
|
109 | - { |
|
110 | - |
|
111 | - // pick a random character from the possible ones |
|
112 | - $char = substr($possible, mt_rand(0, dol_strlen($possible)-1), 1); |
|
113 | - |
|
114 | - // we don't want this character if it's already in the password |
|
115 | - if (!strstr($password, $char)) |
|
116 | - { |
|
117 | - $password .= $char; |
|
118 | - $i++; |
|
119 | - } |
|
120 | - } |
|
121 | - |
|
122 | - // done! |
|
123 | - return $password; |
|
124 | - } |
|
125 | - |
|
126 | - /** |
|
127 | - * Validate a password |
|
128 | - * |
|
129 | - * @param string $password Password to check |
|
130 | - * @return int 0 if KO, >0 if OK |
|
131 | - */ |
|
132 | - function validatePassword($password) |
|
133 | - { |
|
134 | - if (dol_strlen($password) < $this->length) return 0; |
|
135 | - return 1; |
|
136 | - } |
|
46 | + public $conf; |
|
47 | + public $lang; |
|
48 | + public $user; |
|
49 | + |
|
50 | + |
|
51 | + /** |
|
52 | + * Constructor |
|
53 | + * |
|
54 | + * @param DoliDB $db Database handler |
|
55 | + * @param Conf $conf Handler de conf |
|
56 | + * @param Translate $langs Handler de langue |
|
57 | + * @param User $user Handler du user connecte |
|
58 | + */ |
|
59 | + function __construct($db, $conf, $langs, $user) |
|
60 | + { |
|
61 | + $this->id = "standard"; |
|
62 | + $this->length = 8; |
|
63 | + |
|
64 | + $this->db=$db; |
|
65 | + $this->conf=$conf; |
|
66 | + $this->langs=$langs; |
|
67 | + $this->user=$user; |
|
68 | + } |
|
69 | + |
|
70 | + /** |
|
71 | + * Return description of module |
|
72 | + * |
|
73 | + * @return string Description of module |
|
74 | + */ |
|
75 | + function getDescription() |
|
76 | + { |
|
77 | + global $langs; |
|
78 | + return $langs->trans("PasswordGenerationStandard"); |
|
79 | + } |
|
80 | + |
|
81 | + /** |
|
82 | + * Return an example of password generated by this module |
|
83 | + * |
|
84 | + * @return string Example of password |
|
85 | + */ |
|
86 | + function getExample() |
|
87 | + { |
|
88 | + return $this->getNewGeneratedPassword(); |
|
89 | + } |
|
90 | + |
|
91 | + /** |
|
92 | + * Build new password |
|
93 | + * |
|
94 | + * @return string Return a new generated password |
|
95 | + */ |
|
96 | + function getNewGeneratedPassword() |
|
97 | + { |
|
98 | + // start with a blank password |
|
99 | + $password = ""; |
|
100 | + |
|
101 | + // define possible characters |
|
102 | + $possible = "0123456789bcdfghjkmnpqrstvwxyz"; |
|
103 | + |
|
104 | + // set up a counter |
|
105 | + $i = 0; |
|
106 | + |
|
107 | + // add random characters to $password until $length is reached |
|
108 | + while ($i < $this->length) |
|
109 | + { |
|
110 | + |
|
111 | + // pick a random character from the possible ones |
|
112 | + $char = substr($possible, mt_rand(0, dol_strlen($possible)-1), 1); |
|
113 | + |
|
114 | + // we don't want this character if it's already in the password |
|
115 | + if (!strstr($password, $char)) |
|
116 | + { |
|
117 | + $password .= $char; |
|
118 | + $i++; |
|
119 | + } |
|
120 | + } |
|
121 | + |
|
122 | + // done! |
|
123 | + return $password; |
|
124 | + } |
|
125 | + |
|
126 | + /** |
|
127 | + * Validate a password |
|
128 | + * |
|
129 | + * @param string $password Password to check |
|
130 | + * @return int 0 if KO, >0 if OK |
|
131 | + */ |
|
132 | + function validatePassword($password) |
|
133 | + { |
|
134 | + if (dol_strlen($password) < $this->length) return 0; |
|
135 | + return 1; |
|
136 | + } |
|
137 | 137 | } |
138 | 138 |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | * \brief File to manage password generation according to standard rule |
23 | 23 | */ |
24 | 24 | |
25 | -require_once DOL_DOCUMENT_ROOT .'/core/modules/security/generate/modules_genpassword.php'; |
|
25 | +require_once DOL_DOCUMENT_ROOT.'/core/modules/security/generate/modules_genpassword.php'; |
|
26 | 26 | |
27 | 27 | |
28 | 28 | /** |
@@ -61,10 +61,10 @@ discard block |
||
61 | 61 | $this->id = "standard"; |
62 | 62 | $this->length = 8; |
63 | 63 | |
64 | - $this->db=$db; |
|
65 | - $this->conf=$conf; |
|
66 | - $this->langs=$langs; |
|
67 | - $this->user=$user; |
|
64 | + $this->db = $db; |
|
65 | + $this->conf = $conf; |
|
66 | + $this->langs = $langs; |
|
67 | + $this->user = $user; |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | /** |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | { |
110 | 110 | |
111 | 111 | // pick a random character from the possible ones |
112 | - $char = substr($possible, mt_rand(0, dol_strlen($possible)-1), 1); |
|
112 | + $char = substr($possible, mt_rand(0, dol_strlen($possible) - 1), 1); |
|
113 | 113 | |
114 | 114 | // we don't want this character if it's already in the password |
115 | 115 | if (!strstr($password, $char)) |
@@ -131,7 +131,9 @@ |
||
131 | 131 | */ |
132 | 132 | function validatePassword($password) |
133 | 133 | { |
134 | - if (dol_strlen($password) < $this->length) return 0; |
|
134 | + if (dol_strlen($password) < $this->length) { |
|
135 | + return 0; |
|
136 | + } |
|
135 | 137 | return 1; |
136 | 138 | } |
137 | 139 | } |
@@ -33,198 +33,198 @@ |
||
33 | 33 | */ |
34 | 34 | class modGeneratePassPerso extends ModeleGenPassword |
35 | 35 | { |
36 | - /** |
|
37 | - * @var int ID |
|
38 | - */ |
|
39 | - public $id; |
|
40 | - |
|
41 | - public $length; |
|
42 | - public $length2; // didn't overright display |
|
43 | - public $NbMaj; |
|
44 | - public $NbNum; |
|
45 | - public $NbSpe; |
|
46 | - public $NbRepeat; |
|
47 | - public $WithoutAmbi; |
|
48 | - |
|
49 | - /** |
|
36 | + /** |
|
37 | + * @var int ID |
|
38 | + */ |
|
39 | + public $id; |
|
40 | + |
|
41 | + public $length; |
|
42 | + public $length2; // didn't overright display |
|
43 | + public $NbMaj; |
|
44 | + public $NbNum; |
|
45 | + public $NbSpe; |
|
46 | + public $NbRepeat; |
|
47 | + public $WithoutAmbi; |
|
48 | + |
|
49 | + /** |
|
50 | 50 | * @var DoliDB Database handler. |
51 | 51 | */ |
52 | 52 | public $db; |
53 | 53 | |
54 | - public $conf; |
|
55 | - public $lang; |
|
56 | - public $user; |
|
57 | - |
|
58 | - public $Maj; |
|
59 | - public $Min; |
|
60 | - public $Nb; |
|
61 | - public $Spe; |
|
62 | - public $Ambi; |
|
63 | - public $All; |
|
64 | - |
|
65 | - /** |
|
66 | - * Constructor |
|
67 | - * |
|
68 | - * @param DoliDB $db Database handler |
|
69 | - * @param Conf $conf Handler de conf |
|
70 | - * @param Translate $langs Handler de langue |
|
71 | - * @param User $user Handler du user connecte |
|
72 | - */ |
|
73 | - function __construct($db, $conf, $langs, $user) |
|
74 | - { |
|
75 | - $this->id = "Perso"; |
|
76 | - $this->length = $langs->trans("SetupPerso"); |
|
77 | - |
|
78 | - $this->db=$db; |
|
79 | - $this->conf=$conf; |
|
80 | - $this->langs=$langs; |
|
81 | - $this->user=$user; |
|
82 | - |
|
83 | - if (empty($conf->global->USER_PASSWORD_PATTERN)) { |
|
84 | - // default value (8carac, 1maj, 1digit, 1spe, 3 repeat, no ambi at auto generation. |
|
85 | - dolibarr_set_const($db, "USER_PASSWORD_PATTERN", '8;1;1;1;3;1','chaine',0,'',$conf->entity); |
|
86 | - } |
|
87 | - |
|
88 | - $this->Maj = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; |
|
89 | - $this->Min = strtolower($this->Maj); |
|
90 | - $this->Nb = "0123456789"; |
|
91 | - $this->Spe = "!@#$%&*()_-+={}[]\\|:;'/"; |
|
92 | - $this->Ambi = array("1","I","l","|","O","0"); |
|
93 | - |
|
94 | - $tabConf = explode(";",$conf->global->USER_PASSWORD_PATTERN); |
|
95 | - $this->length2 = $tabConf[0]; |
|
96 | - $this->NbMaj = $tabConf[1]; |
|
97 | - $this->NbNum = $tabConf[2]; |
|
98 | - $this->NbSpe = $tabConf[3]; |
|
99 | - $this->NbRepeat = $tabConf[4]; |
|
100 | - $this->WithoutAmbi = $tabConf[5]; |
|
101 | - |
|
102 | - if ($this->WithoutAmbi) |
|
103 | - { |
|
104 | - $this->Maj = str_replace($this->Ambi,"",$this->Maj); |
|
105 | - $this->Min = str_replace($this->Ambi,"",$this->Min); |
|
106 | - $this->Nb = str_replace($this->Ambi,"",$this->Nb); |
|
107 | - $this->Spe = str_replace($this->Ambi,"",$this->Spe); |
|
108 | - } |
|
109 | - |
|
110 | - $pattern = $this->Min . (! empty($this->NbMaj)?$this->Maj:'') . (! empty($this->NbNum)?$this->Nb:'') . (! empty($this->NbSpe)?$this->Spe:''); |
|
111 | - $this->All = str_shuffle($pattern); |
|
112 | - |
|
113 | - //$this->All = str_shuffle($this->Maj. $this->Min. $this->Nb. $this->Spe); |
|
114 | - //$this->All = $this->Maj. $this->Min. $this->Nb. $this->Spe; |
|
115 | - //$this->All = $this->Spe; |
|
116 | - } |
|
117 | - |
|
118 | - /** |
|
119 | - * Return description of module |
|
120 | - * |
|
121 | - * @return string Description of text |
|
122 | - */ |
|
123 | - function getDescription() |
|
124 | - { |
|
125 | - global $langs; |
|
126 | - return $langs->trans("PasswordGenerationPerso"); |
|
127 | - } |
|
128 | - |
|
129 | - /** |
|
130 | - * Return an example of password generated by this module |
|
131 | - * |
|
132 | - * @return string Example of password |
|
133 | - */ |
|
134 | - function getExample() |
|
135 | - { |
|
136 | - return $this->getNewGeneratedPassword(); |
|
137 | - } |
|
138 | - |
|
139 | - /** |
|
140 | - * Build new password |
|
141 | - * |
|
142 | - * @return string Return a new generated password |
|
143 | - */ |
|
144 | - function getNewGeneratedPassword() |
|
145 | - { |
|
146 | - $pass = ""; |
|
147 | - for($i=0; $i<$this->NbMaj; $i++){ // Y |
|
148 | - $pass .= $this->Maj[mt_rand(0,strlen($this->Maj) - 1)]; |
|
149 | - } |
|
150 | - |
|
151 | - for($i=0; $i<$this->NbNum; $i++){ // X |
|
152 | - $pass .= $this->Nb[mt_rand(0,strlen($this->Nb) - 1)]; |
|
153 | - } |
|
154 | - |
|
155 | - for($i=0; $i<$this->NbSpe; $i++){ // @ |
|
156 | - $pass .= $this->Spe[mt_rand(0,strlen($this->Spe) - 1)]; |
|
157 | - } |
|
158 | - |
|
159 | - for($i=strlen($pass);$i<$this->length2; $i++){ // y |
|
160 | - $pass .= $this->All[mt_rand(0,strlen($this->All) -1)]; |
|
161 | - } |
|
162 | - |
|
163 | - $pass = str_shuffle($pass); |
|
164 | - |
|
165 | - if ($this->validatePassword($pass)) |
|
166 | - { |
|
167 | - return $pass; |
|
168 | - } |
|
169 | - |
|
170 | - return $this->getNewGeneratedPassword(); |
|
171 | - } |
|
172 | - |
|
173 | - /** |
|
174 | - * Validate a password |
|
175 | - * |
|
176 | - * @param string $password Password to check |
|
177 | - * @return int 0 if KO, >0 if OK |
|
178 | - */ |
|
179 | - function validatePassword($password) |
|
180 | - { |
|
181 | - $password_a = str_split($password); |
|
182 | - $maj = str_split($this->Maj); |
|
183 | - $num = str_split($this->Nb); |
|
184 | - $spe = str_split($this->Spe); |
|
185 | - |
|
186 | - if(count(array_intersect($password_a, $maj)) < $this->NbMaj){ |
|
187 | - return 0; |
|
188 | - } |
|
189 | - |
|
190 | - if(count(array_intersect($password_a, $num)) < $this->NbNum){ |
|
191 | - return 0; |
|
192 | - } |
|
193 | - |
|
194 | - if(count(array_intersect($password_a, $spe)) < $this->NbSpe){ |
|
195 | - return 0; |
|
196 | - } |
|
197 | - |
|
198 | - if(!$this->consecutiveInterationSameCharacter($password)){ |
|
199 | - return 0; |
|
200 | - } |
|
201 | - |
|
202 | - return 1; |
|
203 | - } |
|
204 | - |
|
205 | - /** |
|
206 | - * consecutive iterations of the same character |
|
207 | - * |
|
208 | - * @param string $password Password to check |
|
209 | - * @return int 0 if KO, >0 if OK |
|
210 | - */ |
|
54 | + public $conf; |
|
55 | + public $lang; |
|
56 | + public $user; |
|
57 | + |
|
58 | + public $Maj; |
|
59 | + public $Min; |
|
60 | + public $Nb; |
|
61 | + public $Spe; |
|
62 | + public $Ambi; |
|
63 | + public $All; |
|
64 | + |
|
65 | + /** |
|
66 | + * Constructor |
|
67 | + * |
|
68 | + * @param DoliDB $db Database handler |
|
69 | + * @param Conf $conf Handler de conf |
|
70 | + * @param Translate $langs Handler de langue |
|
71 | + * @param User $user Handler du user connecte |
|
72 | + */ |
|
73 | + function __construct($db, $conf, $langs, $user) |
|
74 | + { |
|
75 | + $this->id = "Perso"; |
|
76 | + $this->length = $langs->trans("SetupPerso"); |
|
77 | + |
|
78 | + $this->db=$db; |
|
79 | + $this->conf=$conf; |
|
80 | + $this->langs=$langs; |
|
81 | + $this->user=$user; |
|
82 | + |
|
83 | + if (empty($conf->global->USER_PASSWORD_PATTERN)) { |
|
84 | + // default value (8carac, 1maj, 1digit, 1spe, 3 repeat, no ambi at auto generation. |
|
85 | + dolibarr_set_const($db, "USER_PASSWORD_PATTERN", '8;1;1;1;3;1','chaine',0,'',$conf->entity); |
|
86 | + } |
|
87 | + |
|
88 | + $this->Maj = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; |
|
89 | + $this->Min = strtolower($this->Maj); |
|
90 | + $this->Nb = "0123456789"; |
|
91 | + $this->Spe = "!@#$%&*()_-+={}[]\\|:;'/"; |
|
92 | + $this->Ambi = array("1","I","l","|","O","0"); |
|
93 | + |
|
94 | + $tabConf = explode(";",$conf->global->USER_PASSWORD_PATTERN); |
|
95 | + $this->length2 = $tabConf[0]; |
|
96 | + $this->NbMaj = $tabConf[1]; |
|
97 | + $this->NbNum = $tabConf[2]; |
|
98 | + $this->NbSpe = $tabConf[3]; |
|
99 | + $this->NbRepeat = $tabConf[4]; |
|
100 | + $this->WithoutAmbi = $tabConf[5]; |
|
101 | + |
|
102 | + if ($this->WithoutAmbi) |
|
103 | + { |
|
104 | + $this->Maj = str_replace($this->Ambi,"",$this->Maj); |
|
105 | + $this->Min = str_replace($this->Ambi,"",$this->Min); |
|
106 | + $this->Nb = str_replace($this->Ambi,"",$this->Nb); |
|
107 | + $this->Spe = str_replace($this->Ambi,"",$this->Spe); |
|
108 | + } |
|
109 | + |
|
110 | + $pattern = $this->Min . (! empty($this->NbMaj)?$this->Maj:'') . (! empty($this->NbNum)?$this->Nb:'') . (! empty($this->NbSpe)?$this->Spe:''); |
|
111 | + $this->All = str_shuffle($pattern); |
|
112 | + |
|
113 | + //$this->All = str_shuffle($this->Maj. $this->Min. $this->Nb. $this->Spe); |
|
114 | + //$this->All = $this->Maj. $this->Min. $this->Nb. $this->Spe; |
|
115 | + //$this->All = $this->Spe; |
|
116 | + } |
|
117 | + |
|
118 | + /** |
|
119 | + * Return description of module |
|
120 | + * |
|
121 | + * @return string Description of text |
|
122 | + */ |
|
123 | + function getDescription() |
|
124 | + { |
|
125 | + global $langs; |
|
126 | + return $langs->trans("PasswordGenerationPerso"); |
|
127 | + } |
|
128 | + |
|
129 | + /** |
|
130 | + * Return an example of password generated by this module |
|
131 | + * |
|
132 | + * @return string Example of password |
|
133 | + */ |
|
134 | + function getExample() |
|
135 | + { |
|
136 | + return $this->getNewGeneratedPassword(); |
|
137 | + } |
|
138 | + |
|
139 | + /** |
|
140 | + * Build new password |
|
141 | + * |
|
142 | + * @return string Return a new generated password |
|
143 | + */ |
|
144 | + function getNewGeneratedPassword() |
|
145 | + { |
|
146 | + $pass = ""; |
|
147 | + for($i=0; $i<$this->NbMaj; $i++){ // Y |
|
148 | + $pass .= $this->Maj[mt_rand(0,strlen($this->Maj) - 1)]; |
|
149 | + } |
|
150 | + |
|
151 | + for($i=0; $i<$this->NbNum; $i++){ // X |
|
152 | + $pass .= $this->Nb[mt_rand(0,strlen($this->Nb) - 1)]; |
|
153 | + } |
|
154 | + |
|
155 | + for($i=0; $i<$this->NbSpe; $i++){ // @ |
|
156 | + $pass .= $this->Spe[mt_rand(0,strlen($this->Spe) - 1)]; |
|
157 | + } |
|
158 | + |
|
159 | + for($i=strlen($pass);$i<$this->length2; $i++){ // y |
|
160 | + $pass .= $this->All[mt_rand(0,strlen($this->All) -1)]; |
|
161 | + } |
|
162 | + |
|
163 | + $pass = str_shuffle($pass); |
|
164 | + |
|
165 | + if ($this->validatePassword($pass)) |
|
166 | + { |
|
167 | + return $pass; |
|
168 | + } |
|
169 | + |
|
170 | + return $this->getNewGeneratedPassword(); |
|
171 | + } |
|
172 | + |
|
173 | + /** |
|
174 | + * Validate a password |
|
175 | + * |
|
176 | + * @param string $password Password to check |
|
177 | + * @return int 0 if KO, >0 if OK |
|
178 | + */ |
|
179 | + function validatePassword($password) |
|
180 | + { |
|
181 | + $password_a = str_split($password); |
|
182 | + $maj = str_split($this->Maj); |
|
183 | + $num = str_split($this->Nb); |
|
184 | + $spe = str_split($this->Spe); |
|
185 | + |
|
186 | + if(count(array_intersect($password_a, $maj)) < $this->NbMaj){ |
|
187 | + return 0; |
|
188 | + } |
|
189 | + |
|
190 | + if(count(array_intersect($password_a, $num)) < $this->NbNum){ |
|
191 | + return 0; |
|
192 | + } |
|
193 | + |
|
194 | + if(count(array_intersect($password_a, $spe)) < $this->NbSpe){ |
|
195 | + return 0; |
|
196 | + } |
|
197 | + |
|
198 | + if(!$this->consecutiveInterationSameCharacter($password)){ |
|
199 | + return 0; |
|
200 | + } |
|
201 | + |
|
202 | + return 1; |
|
203 | + } |
|
204 | + |
|
205 | + /** |
|
206 | + * consecutive iterations of the same character |
|
207 | + * |
|
208 | + * @param string $password Password to check |
|
209 | + * @return int 0 if KO, >0 if OK |
|
210 | + */ |
|
211 | 211 | function consecutiveInterationSameCharacter($password) |
212 | 212 | { |
213 | - $last = ""; |
|
214 | - $count = 0; |
|
215 | - $char = str_split($password); |
|
216 | - foreach($char as $c){ |
|
217 | - if($c != $last){ |
|
218 | - $last = $c; |
|
219 | - $count = 0; |
|
220 | - }else{ |
|
221 | - $count++; |
|
222 | - } |
|
223 | - |
|
224 | - if($count >= $this->NbRepeat) { |
|
225 | - return 0; |
|
226 | - } |
|
227 | - } |
|
228 | - return 1; |
|
229 | - } |
|
213 | + $last = ""; |
|
214 | + $count = 0; |
|
215 | + $char = str_split($password); |
|
216 | + foreach($char as $c){ |
|
217 | + if($c != $last){ |
|
218 | + $last = $c; |
|
219 | + $count = 0; |
|
220 | + }else{ |
|
221 | + $count++; |
|
222 | + } |
|
223 | + |
|
224 | + if($count >= $this->NbRepeat) { |
|
225 | + return 0; |
|
226 | + } |
|
227 | + } |
|
228 | + return 1; |
|
229 | + } |
|
230 | 230 | } |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * \brief File to manage no password generation. |
25 | 25 | */ |
26 | 26 | |
27 | -require_once DOL_DOCUMENT_ROOT .'/core/modules/security/generate/modules_genpassword.php'; |
|
27 | +require_once DOL_DOCUMENT_ROOT.'/core/modules/security/generate/modules_genpassword.php'; |
|
28 | 28 | |
29 | 29 | |
30 | 30 | /** |
@@ -75,23 +75,23 @@ discard block |
||
75 | 75 | $this->id = "Perso"; |
76 | 76 | $this->length = $langs->trans("SetupPerso"); |
77 | 77 | |
78 | - $this->db=$db; |
|
79 | - $this->conf=$conf; |
|
80 | - $this->langs=$langs; |
|
81 | - $this->user=$user; |
|
78 | + $this->db = $db; |
|
79 | + $this->conf = $conf; |
|
80 | + $this->langs = $langs; |
|
81 | + $this->user = $user; |
|
82 | 82 | |
83 | 83 | if (empty($conf->global->USER_PASSWORD_PATTERN)) { |
84 | 84 | // default value (8carac, 1maj, 1digit, 1spe, 3 repeat, no ambi at auto generation. |
85 | - dolibarr_set_const($db, "USER_PASSWORD_PATTERN", '8;1;1;1;3;1','chaine',0,'',$conf->entity); |
|
85 | + dolibarr_set_const($db, "USER_PASSWORD_PATTERN", '8;1;1;1;3;1', 'chaine', 0, '', $conf->entity); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | $this->Maj = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; |
89 | 89 | $this->Min = strtolower($this->Maj); |
90 | 90 | $this->Nb = "0123456789"; |
91 | 91 | $this->Spe = "!@#$%&*()_-+={}[]\\|:;'/"; |
92 | - $this->Ambi = array("1","I","l","|","O","0"); |
|
92 | + $this->Ambi = array("1", "I", "l", "|", "O", "0"); |
|
93 | 93 | |
94 | - $tabConf = explode(";",$conf->global->USER_PASSWORD_PATTERN); |
|
94 | + $tabConf = explode(";", $conf->global->USER_PASSWORD_PATTERN); |
|
95 | 95 | $this->length2 = $tabConf[0]; |
96 | 96 | $this->NbMaj = $tabConf[1]; |
97 | 97 | $this->NbNum = $tabConf[2]; |
@@ -101,13 +101,13 @@ discard block |
||
101 | 101 | |
102 | 102 | if ($this->WithoutAmbi) |
103 | 103 | { |
104 | - $this->Maj = str_replace($this->Ambi,"",$this->Maj); |
|
105 | - $this->Min = str_replace($this->Ambi,"",$this->Min); |
|
106 | - $this->Nb = str_replace($this->Ambi,"",$this->Nb); |
|
107 | - $this->Spe = str_replace($this->Ambi,"",$this->Spe); |
|
104 | + $this->Maj = str_replace($this->Ambi, "", $this->Maj); |
|
105 | + $this->Min = str_replace($this->Ambi, "", $this->Min); |
|
106 | + $this->Nb = str_replace($this->Ambi, "", $this->Nb); |
|
107 | + $this->Spe = str_replace($this->Ambi, "", $this->Spe); |
|
108 | 108 | } |
109 | 109 | |
110 | - $pattern = $this->Min . (! empty($this->NbMaj)?$this->Maj:'') . (! empty($this->NbNum)?$this->Nb:'') . (! empty($this->NbSpe)?$this->Spe:''); |
|
110 | + $pattern = $this->Min.(!empty($this->NbMaj) ? $this->Maj : '').(!empty($this->NbNum) ? $this->Nb : '').(!empty($this->NbSpe) ? $this->Spe : ''); |
|
111 | 111 | $this->All = str_shuffle($pattern); |
112 | 112 | |
113 | 113 | //$this->All = str_shuffle($this->Maj. $this->Min. $this->Nb. $this->Spe); |
@@ -144,20 +144,20 @@ discard block |
||
144 | 144 | function getNewGeneratedPassword() |
145 | 145 | { |
146 | 146 | $pass = ""; |
147 | - for($i=0; $i<$this->NbMaj; $i++){ // Y |
|
148 | - $pass .= $this->Maj[mt_rand(0,strlen($this->Maj) - 1)]; |
|
147 | + for ($i = 0; $i < $this->NbMaj; $i++) { // Y |
|
148 | + $pass .= $this->Maj[mt_rand(0, strlen($this->Maj) - 1)]; |
|
149 | 149 | } |
150 | 150 | |
151 | - for($i=0; $i<$this->NbNum; $i++){ // X |
|
152 | - $pass .= $this->Nb[mt_rand(0,strlen($this->Nb) - 1)]; |
|
151 | + for ($i = 0; $i < $this->NbNum; $i++) { // X |
|
152 | + $pass .= $this->Nb[mt_rand(0, strlen($this->Nb) - 1)]; |
|
153 | 153 | } |
154 | 154 | |
155 | - for($i=0; $i<$this->NbSpe; $i++){ // @ |
|
156 | - $pass .= $this->Spe[mt_rand(0,strlen($this->Spe) - 1)]; |
|
155 | + for ($i = 0; $i < $this->NbSpe; $i++) { // @ |
|
156 | + $pass .= $this->Spe[mt_rand(0, strlen($this->Spe) - 1)]; |
|
157 | 157 | } |
158 | 158 | |
159 | - for($i=strlen($pass);$i<$this->length2; $i++){ // y |
|
160 | - $pass .= $this->All[mt_rand(0,strlen($this->All) -1)]; |
|
159 | + for ($i = strlen($pass); $i < $this->length2; $i++) { // y |
|
160 | + $pass .= $this->All[mt_rand(0, strlen($this->All) - 1)]; |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | $pass = str_shuffle($pass); |
@@ -183,19 +183,19 @@ discard block |
||
183 | 183 | $num = str_split($this->Nb); |
184 | 184 | $spe = str_split($this->Spe); |
185 | 185 | |
186 | - if(count(array_intersect($password_a, $maj)) < $this->NbMaj){ |
|
186 | + if (count(array_intersect($password_a, $maj)) < $this->NbMaj) { |
|
187 | 187 | return 0; |
188 | 188 | } |
189 | 189 | |
190 | - if(count(array_intersect($password_a, $num)) < $this->NbNum){ |
|
190 | + if (count(array_intersect($password_a, $num)) < $this->NbNum) { |
|
191 | 191 | return 0; |
192 | 192 | } |
193 | 193 | |
194 | - if(count(array_intersect($password_a, $spe)) < $this->NbSpe){ |
|
194 | + if (count(array_intersect($password_a, $spe)) < $this->NbSpe) { |
|
195 | 195 | return 0; |
196 | 196 | } |
197 | 197 | |
198 | - if(!$this->consecutiveInterationSameCharacter($password)){ |
|
198 | + if (!$this->consecutiveInterationSameCharacter($password)) { |
|
199 | 199 | return 0; |
200 | 200 | } |
201 | 201 | |
@@ -213,15 +213,15 @@ discard block |
||
213 | 213 | $last = ""; |
214 | 214 | $count = 0; |
215 | 215 | $char = str_split($password); |
216 | - foreach($char as $c){ |
|
217 | - if($c != $last){ |
|
216 | + foreach ($char as $c) { |
|
217 | + if ($c != $last) { |
|
218 | 218 | $last = $c; |
219 | 219 | $count = 0; |
220 | - }else{ |
|
220 | + } else { |
|
221 | 221 | $count++; |
222 | 222 | } |
223 | 223 | |
224 | - if($count >= $this->NbRepeat) { |
|
224 | + if ($count >= $this->NbRepeat) { |
|
225 | 225 | return 0; |
226 | 226 | } |
227 | 227 | } |
@@ -217,7 +217,7 @@ |
||
217 | 217 | if($c != $last){ |
218 | 218 | $last = $c; |
219 | 219 | $count = 0; |
220 | - }else{ |
|
220 | + } else{ |
|
221 | 221 | $count++; |
222 | 222 | } |
223 | 223 |